本文整理汇总了PHP中eZContentObject::fetchAttributesByIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::fetchAttributesByIdentifier方法的具体用法?PHP eZContentObject::fetchAttributesByIdentifier怎么用?PHP eZContentObject::fetchAttributesByIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::fetchAttributesByIdentifier方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchContentAttributes
/**
* Fetches the list of available class-identifiers in the token, and it
* will only fetch the attributes which appear amongst the identifiers
* found in tokens.
*
* @return void
*/
private function fetchContentAttributes()
{
$returnAttributeArray = array();
$identifierArray = $this->getIdentifiers($this->origNamePattern);
$attributes = $this->contentObject->fetchAttributesByIdentifier($identifierArray, $this->version, array($this->translation));
if (is_array($attributes)) {
foreach ($attributes as $attribute) {
$identifier = $attribute->contentClassAttributeIdentifier();
$returnAttributeArray[$identifier] = $attribute->title();
}
} else {
$returnAttributeArray = array();
}
$this->attributeArray = $returnAttributeArray;
}
示例2: modify
public function modify(eZContentObject $contentObject, &$docList)
{
$isEvent = $from = $to = false;
$attributes = $contentObject->fetchAttributesByIdentifier(array('from_time', 'to_time'));
if (empty($attributes)) {
return false;
}
foreach ($attributes as $attribute) {
if ($attribute instanceof eZContentObjectAttribute) {
if ($attribute->attribute('contentclass_attribute_identifier') == 'from_time' && $attribute->hasContent()) {
$from = $attribute->toString();
}
if ($attribute->attribute('contentclass_attribute_identifier') == 'to_time' && $attribute->hasContent()) {
$to = $attribute->toString();
}
}
}
if ($from && $to) {
$isEvent = true;
}
if ($isEvent) {
$duration = $to - $from;
$version = $contentObject->currentVersion();
if ($version === false) {
return;
}
$availableLanguages = $version->translationList(false, false);
foreach ($availableLanguages as $languageCode) {
if ($docList[$languageCode] instanceof eZSolrDoc) {
if ($docList[$languageCode]->Doc instanceof DOMDocument) {
$xpath = new DomXpath($docList[$languageCode]->Doc);
if ($xpath->evaluate('//field[@name="extra_event_duration_s"]')->length == 0) {
$docList[$languageCode]->addField('extra_event_duration_s', $duration);
$docList[$languageCode]->addField('extra_event_duration_si', intval($duration));
}
} elseif (is_array($docList[$languageCode]->Doc) && !isset($docList[$languageCode]->Doc['extra_event_duration_s'])) {
$docList[$languageCode]->addField('extra_event_duration_s', $duration);
$docList[$languageCode]->addField('extra_event_duration_si', intval($duration));
}
}
}
}
}
示例3: restoreXmlRelations
/**
* Parses the XML for the attributes in $classAttributeIdentifiers, and fixes the relations for $object
* @param eZContentObject $object
* @param array $classAttributeIdentifiers
* @return int The number of created relations
*/
function restoreXmlRelations(eZContentObject $object, array $classAttributeIdentifiers)
{
$currentVersion = $object->currentVersion();
$langMask = $currentVersion->attribute('language_mask');
$languageList = eZContentLanguage::decodeLanguageMask($langMask, true);
$languageList = $languageList['language_list'];
// nothing to do if the object isn't translated
if (count($languageList) < 2) {
return 0;
}
$attributeArray = $object->fetchAttributesByIdentifier($classAttributeIdentifiers, $currentVersion->attribute('version'), $languageList);
$embedRelationsCount = $object->relatedContentObjectCount(false, 0, array('AllRelations' => eZContentObject::RELATION_EMBED));
$linkRelationsCount = $object->relatedContentObjectCount(false, 0, array('AllRelations' => eZContentObject::RELATION_LINK));
$embeddedObjectIdArray = $linkedObjectIdArray = array();
foreach ($attributeArray as $attribute) {
$xmlText = eZXMLTextType::rawXMLText($attribute);
$dom = new DOMDocument('1.0', 'utf-8');
if (!$dom->loadXML($xmlText)) {
continue;
}
// linked objects
$linkedObjectIdArray = array_merge($linkedObjectIdArray, getRelatedObjectList($dom->getElementsByTagName('link')));
// embedded objects
$embeddedObjectIdArray = array_merge($embeddedObjectIdArray, getRelatedObjectList($dom->getElementsByTagName('embed')), getRelatedObjectList($dom->getElementsByTagName('embed-inline')));
}
$doCommit = false;
$restoredRelations = 0;
if (!empty($embeddedObjectIdArray)) {
$object->appendInputRelationList($embeddedObjectIdArray, eZContentObject::RELATION_EMBED);
$restoredRelations += count($embeddedObjectIdArray) - $embedRelationsCount;
$doCommit = true;
}
if (!empty($linkedObjectIdArray)) {
$object->appendInputRelationList($linkedObjectIdArray, eZContentObject::RELATION_LINK);
$restoredRelations += count($linkedObjectIdArray) - $linkRelationsCount;
$doCommit = true;
}
if ($doCommit) {
$object->commitInputRelations($currentVersion->attribute('version'));
}
return $restoredRelations;
}
示例4: onPublish
/**
* Method triggered on publish for xml text datatype
*
* This method makes sure that links from all translations of an xml text
* are registered in the ezurl_object_link table, and thus retained, if
* previous versions of an object are removed.
*
* It also checks for embedded objects in other languages xml, and makes
* sure the matching object relations are stored for the publish version.
*
* @param eZContentObjectAttribute $contentObjectAttribute
* @param eZContentObject $object
* @param array $publishedNodes
* @return boolean
*/
function onPublish($contentObjectAttribute, $object, $publishedNodes)
{
$currentVersion = $object->currentVersion();
$langMask = $currentVersion->attribute('language_mask');
// We find all translations present in the current version. We calculate
// this from the language mask already present in the fetched version,
// so no further round-trip to the DB is required.
$languageList = eZContentLanguage::decodeLanguageMask($langMask, true);
$languageList = $languageList['language_list'];
// We want to have the class attribute identifier of the attribute
// containing the current ezxmltext, as we then can use the more efficient
// eZContentObject->fetchAttributesByIdentifier() to get the data
$identifier = $contentObjectAttribute->attribute('contentclass_attribute_identifier');
$attributeArray = $object->fetchAttributesByIdentifier(array($identifier), $currentVersion->attribute('version'), $languageList);
foreach ($attributeArray as $attribute) {
$xmlText = eZXMLTextType::rawXMLText($attribute);
$dom = new DOMDocument('1.0', 'utf-8');
if (!$dom->loadXML($xmlText)) {
continue;
}
// urls
$urlIdArray = array();
foreach ($dom->getElementsByTagName('link') as $link) {
// We are looking for external 'http://'-style links, not the internal
// object or node links.
if ($link->hasAttribute('url_id')) {
$urlIdArray[] = $link->getAttribute('url_id');
}
}
if (count($urlIdArray) > 0) {
eZSimplifiedXMLInput::updateUrlObjectLinks($attribute, $urlIdArray);
}
// linked objects
$linkedObjectIdArray = $this->getRelatedObjectList($dom->getElementsByTagName('link'));
// embedded objects
$embeddedObjectIdArray = array_merge($this->getRelatedObjectList($dom->getElementsByTagName('embed')), $this->getRelatedObjectList($dom->getElementsByTagName('embed-inline')));
if (!empty($embeddedObjectIdArray)) {
$object->appendInputRelationList($embeddedObjectIdArray, eZContentObject::RELATION_EMBED);
}
if (!empty($linkedObjectIdArray)) {
$object->appendInputRelationList($linkedObjectIdArray, eZContentObject::RELATION_LINK);
}
if (!empty($linkedObjectIdArray) || !empty($embeddedObjectIdArray)) {
$object->commitInputRelations($currentVersion->attribute('version'));
}
}
}
示例5: processObject
/**
* Processes Open Graph metadata from object attributes
*
* @param eZContentObject $contentObject
* @param array $returnArray
*
* @return array
*/
function processObject($contentObject, $returnArray)
{
if ($this->ogIni->hasVariable($contentObject->contentClassIdentifier(), 'LiteralMap')) {
$literalValues = $this->ogIni->variable($contentObject->contentClassIdentifier(), 'LiteralMap');
if ($this->debug) {
eZDebug::writeDebug($literalValues, 'LiteralMap');
}
if ($literalValues) {
foreach ($literalValues as $key => $value) {
if (!empty($value)) {
$returnArray[$key] = $value;
}
}
}
}
if ($this->ogIni->hasVariable($contentObject->contentClassIdentifier(), 'AttributeMap')) {
$attributeValues = $this->ogIni->variableArray($contentObject->contentClassIdentifier(), 'AttributeMap');
if ($this->debug) {
eZDebug::writeDebug($attributeValues, 'AttributeMap');
}
if ($attributeValues) {
foreach ($attributeValues as $key => $value) {
$contentObjectAttributeArray = $contentObject->fetchAttributesByIdentifier(array($value[0]));
if (!is_array($contentObjectAttributeArray)) {
continue;
}
$contentObjectAttributeArray = array_values($contentObjectAttributeArray);
$contentObjectAttribute = $contentObjectAttributeArray[0];
if ($contentObjectAttribute instanceof eZContentObjectAttribute) {
$openGraphHandler = ngOpenGraphBase::getInstance($contentObjectAttribute);
if (count($value) == 1) {
$data = $openGraphHandler->getData();
} else {
if (count($value) == 2) {
$data = $openGraphHandler->getDataMember($value[1]);
} else {
$data = "";
}
}
if (!empty($data)) {
$returnArray[$key] = $data;
}
}
}
}
}
return $returnArray;
}