当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentLanguage::decodeLanguageMask方法代码示例

本文整理汇总了PHP中eZContentLanguage::decodeLanguageMask方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::decodeLanguageMask方法的具体用法?PHP eZContentLanguage::decodeLanguageMask怎么用?PHP eZContentLanguage::decodeLanguageMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZContentLanguage的用法示例。


在下文中一共展示了eZContentLanguage::decodeLanguageMask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
}
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:48,代码来源:restorexmlrelations.php

示例2: simplify

 /**
  * Function for simplifying a content object or node
  *
  * @param mixed $obj
  * @param array $params
  * @return array
  */
 public static function simplify($obj, $params = array())
 {
     if (!$obj) {
         return array();
     } else {
         if ($obj instanceof eZContentObject) {
             $node = $obj->attribute('main_node');
             $contentObject = $obj;
         } else {
             if ($obj instanceof eZContentObjectTreeNode || $obj instanceof eZFindResultNode) {
                 $node = $obj;
                 $contentObject = $obj->attribute('object');
             } else {
                 if (isset($params['fetchNodeFunction']) && method_exists($obj, $params['fetchNodeFunction'])) {
                     // You can supply fetchNodeFunction parameter to be able to support other node related classes
                     $node = call_user_func(array($obj, $params['fetchNodeFunction']));
                     if (!$node instanceof eZContentObjectTreeNode) {
                         return '';
                     }
                     $contentObject = $node->attribute('object');
                 } else {
                     if (is_array($obj)) {
                         return $obj;
                         // Array is returned as is
                     } else {
                         return '';
                         // Other passed objects are not supported
                     }
                 }
             }
         }
     }
     $ini = eZINI::instance('site.ini');
     $params = array_merge(array('dataMap' => array(), 'fetchPath' => false, 'fetchSection' => false, 'fetchChildrenCount' => false, 'dataMapType' => array(), 'loadImages' => false, 'imagePreGenerateSizes' => array('small')), $params);
     if (!isset($params['imageSizes'])) {
         $imageIni = eZINI::instance('image.ini');
         $params['imageSizes'] = $imageIni->variable('AliasSettings', 'AliasList');
     }
     if ($params['imageSizes'] === null || !isset($params['imageSizes'][0])) {
         $params['imageSizes'] = array();
     }
     if (!isset($params['imageDataTypes'])) {
         $params['imageDataTypes'] = $ini->variable('ImageDataTypeSettings', 'AvailableImageDataTypes');
     }
     $ret = array();
     $attrtibuteArray = array();
     $ret['name'] = htmlentities($contentObject->attribute('name'), ENT_QUOTES, "UTF-8");
     $ret['contentobject_id'] = $ret['id'] = (int) $contentObject->attribute('id');
     $ret['contentobject_remote_id'] = $contentObject->attribute('remote_id');
     $ret['contentobject_state'] = implode(", ", $contentObject->attribute('state_identifier_array'));
     $ret['main_node_id'] = (int) $contentObject->attribute('main_node_id');
     $ret['version'] = (int) $contentObject->attribute('current_version');
     $ret['modified'] = $contentObject->attribute('modified');
     $ret['published'] = $contentObject->attribute('published');
     $ret['section_id'] = (int) $contentObject->attribute('section_id');
     $ret['current_language'] = $contentObject->attribute('current_language');
     $ret['owner_id'] = (int) $contentObject->attribute('owner_id');
     $ret['class_id'] = (int) $contentObject->attribute('contentclass_id');
     $ret['class_name'] = $contentObject->attribute('class_name');
     $ret['path_identification_string'] = $node->attribute('path_identification_string');
     $ret['translations'] = eZContentLanguage::decodeLanguageMask($contentObject->attribute('language_mask'), true);
     $ret['can_edit'] = $contentObject->attribute('can_edit');
     if (isset($params['formatDate'])) {
         $ret['modified_date'] = self::formatLocaleDate($contentObject->attribute('modified'), $params['formatDate']);
         $ret['published_date'] = self::formatLocaleDate($contentObject->attribute('published'), $params['formatDate']);
     }
     if (isset($params['fetchCreator'])) {
         $creator = $contentObject->attribute('current')->attribute('creator');
         if ($creator instanceof eZContentObject) {
             $ret['creator'] = array('id' => $creator->attribute('id'), 'name' => $creator->attribute('name'));
         } else {
             $ret['creator'] = array('id' => $contentObject->attribute('current')->attribute('creator_id'), 'name' => null);
             // user has been deleted
         }
     }
     if (isset($params['fetchClassIcon'])) {
         $operator = new eZWordToImageOperator();
         $tpl = eZTemplate::instance();
         $operatorValue = $contentObject->attribute('class_identifier');
         $operatorParameters = array(array(array(1, 'small')));
         $namedParameters = array();
         $operatorName = 'class_icon';
         $operator->modify($tpl, $operatorName, $operatorParameters, '', '', $operatorValue, $namedParameters, array());
         $ret['class_icon'] = $operatorValue;
     }
     if (isset($params['fetchThumbPreview'])) {
         $thumbUrl = '';
         $thumbWidth = 0;
         $thumbHeight = 0;
         $thumbDataType = isset($params['thumbDataType']) ? $params['thumbDataType'] : 'ezimage';
         $thumbImageSize = isset($params['thumbImageSize']) ? $params['thumbImageSize'] : 'small';
         foreach ($contentObject->attribute('data_map') as $key => $atr) {
             if ($atr->attribute('data_type_string') == $thumbDataType && $atr->attribute('has_content')) {
//.........这里部分代码省略.........
开发者ID:nfrp,项目名称:ezpublish,代码行数:101,代码来源:ezjscajaxcontent.php

示例3: 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'));
         }
     }
 }
开发者ID:nlescure,项目名称:ezpublish,代码行数:62,代码来源:ezxmltexttype.php

示例4: getAvailableLanguages

 /**
  * Returns the list of locales for which this tag is translated
  *
  * @return array
  */
 public function getAvailableLanguages()
 {
     $languages = eZContentLanguage::decodeLanguageMask($this->attribute('language_mask'), true);
     return $languages['language_list'];
 }
开发者ID:oki34,项目名称:eztags,代码行数:10,代码来源:eztagsobject.php


注:本文中的eZContentLanguage::decodeLanguageMask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。