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


PHP eZContentLanguage::fetchLocaleList方法代码示例

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


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

示例1: canInstantiateClassList

 static function canInstantiateClassList($asObject = false, $includeFilter = true, $groupList = false, $fetchID = false)
 {
     $ini = eZINI::instance();
     $groupArray = array();
     $enableCaching = $ini->variable('RoleSettings', 'EnableCaching') == 'true';
     if (is_array($groupList)) {
         if ($fetchID == false) {
             $enableCaching = false;
         }
     }
     if ($enableCaching) {
         $http = eZHTTPTool::instance();
         eZExpiryHandler::registerShutdownFunction();
         $handler = eZExpiryHandler::instance();
         $expiredTimeStamp = 0;
         if ($handler->hasTimestamp('user-class-cache')) {
             $expiredTimeStamp = $handler->timestamp('user-class-cache');
         }
         $classesCachedForUser = $http->sessionVariable('ClassesCachedForUser');
         $classesCachedTimestamp = $http->sessionVariable('ClassesCachedTimestamp');
         $cacheVar = 'CanInstantiateClassList';
         if (is_array($groupList) and $fetchID !== false) {
             $cacheVar = 'CanInstantiateClassListGroup';
         }
         $user = eZUser::currentUser();
         $userID = $user->id();
         if ($classesCachedTimestamp >= $expiredTimeStamp && $classesCachedForUser == $userID) {
             if ($http->hasSessionVariable($cacheVar)) {
                 if ($fetchID !== false) {
                     // Check if the group contains our ID, if not we need to fetch from DB
                     $groupArray = $http->sessionVariable($cacheVar);
                     if (isset($groupArray[$fetchID])) {
                         return $groupArray[$fetchID];
                     }
                 } else {
                     return $http->sessionVariable($cacheVar);
                 }
             }
         } else {
             $http->setSessionVariable('ClassesCachedForUser', $userID);
             $http->setSessionVariable('ClassesCachedTimestamp', time());
         }
     }
     $languageCodeList = eZContentLanguage::fetchLocaleList();
     $allowedLanguages = array('*' => array());
     $user = eZUser::currentUser();
     $accessResult = $user->hasAccessTo('content', 'create');
     $accessWord = $accessResult['accessWord'];
     $classIDArray = array();
     $classList = array();
     $fetchAll = false;
     if ($accessWord == 'yes') {
         $fetchAll = true;
         $allowedLanguages['*'] = $languageCodeList;
     } else {
         if ($accessWord == 'no') {
             // Cannot create any objects, return empty list.
             return $classList;
         } else {
             $policies = $accessResult['policies'];
             foreach ($policies as $policyKey => $policy) {
                 $classIDArrayPart = '*';
                 if (isset($policy['Class'])) {
                     $classIDArrayPart = $policy['Class'];
                 }
                 $languageCodeArrayPart = $languageCodeList;
                 if (isset($policy['Language'])) {
                     $languageCodeArrayPart = array_intersect($policy['Language'], $languageCodeList);
                 }
                 // No class limitation for this policy AND no previous limitation(s)
                 if ($classIDArrayPart == '*' && empty($classIDArray)) {
                     $fetchAll = true;
                     $allowedLanguages['*'] = array_unique(array_merge($allowedLanguages['*'], $languageCodeArrayPart));
                 } else {
                     if (is_array($classIDArrayPart)) {
                         $fetchAll = false;
                         foreach ($classIDArrayPart as $class) {
                             if (isset($allowedLanguages[$class])) {
                                 $allowedLanguages[$class] = array_unique(array_merge($allowedLanguages[$class], $languageCodeArrayPart));
                             } else {
                                 $allowedLanguages[$class] = $languageCodeArrayPart;
                             }
                         }
                         $classIDArray = array_merge($classIDArray, array_diff($classIDArrayPart, $classIDArray));
                     }
                 }
             }
         }
     }
     $db = eZDB::instance();
     $filterTableSQL = '';
     $filterSQL = '';
     // Create extra SQL statements for the class group filters.
     if (is_array($groupList)) {
         if (count($groupList) == 0) {
             return $classList;
         }
         $filterTableSQL = ', ezcontentclass_classgroup ccg';
         $filterSQL = " AND" . "      cc.id = ccg.contentclass_id AND" . "      ";
         $filterSQL .= $db->generateSQLINStatement($groupList, 'ccg.group_id', !$includeFilter, true, 'int');
//.........这里部分代码省略.........
开发者ID:nlenardou,项目名称:ezpublish,代码行数:101,代码来源:ezcontentclass.php

示例2: handleParameters


//.........这里部分代码省略.........
             else if ( $optionName == 'node-selected' )
             {
                 $nodeAssignmentType = 'selected';
             }
             else if ( $optionName == 'siteaccess' )
             {
                 $siteAccessList = explode( ',', $optionValue );
             }
             else if ( $optionName == 'language' )
             {
                 $languageList = explode( ',', $optionValue );
             }
             else if ( $optionName == 'current-version' )
             {
                 $versionType = 'current';
             }
             else if ( $optionName == 'all-versions' )
             {
                 $versionType = 'all';
             }
             else if ( $optionName == 'minimal-template-set' )
             {
                 $minimalTemplateSet = true;
             }
         }
         else
         {
             $nodeID = false;
             $subtree = false;
             if ( is_numeric( $argument ) )
             {
                 $nodeID = (int)$argument;
                 $node = eZContentObjectTreeNode::fetch( $nodeID );
                 if ( !is_object( $node ) )
                 {
                     $error = true;
                     $nodeID = false;
                     $cli->notice( "Could not find content-node using ID " . $cli->stylize( 'emphasize', $nodeID ) );
                 }
             }
             else
             {
                 $path = $argument;
                 if ( preg_match( "#(.+)/\*$#", $path, $matches ) )
                 {
                     $path = $matches[1];
                     $subtree = true;
                 }
                 $node = eZContentObjectTreeNode::fetchByURLPath( $path );
                 if ( is_object( $node ) )
                 {
                     $nodeID = $node->attribute( 'node_id' );
                 }
                 else
                 {
                     $cli->notice( "Could not find content-node using path " . $cli->stylize( 'emphasize', $path ) );
                     $error = true;
                 }
             }
             if ( $nodeID )
             {
                 $nodeItem['node-id-list'][] = array( 'id' => $nodeID,
                                                      'subtree' => $subtree,
                                                      'node' => &$node );
             }
             if ( $error )
                 return false;
         }
     }
     if ( count( $nodeItem['node-id-list'] ) > 0 )
     {
         $nodeList[] = $nodeItem;
     }
     if ( count( $nodeList ) == 0 )
     {
         $cli->error( "No objects chosen" );
         return false;
     }
     if ( count( $languageList ) == 0 )
     {
         // The default is to fetch all languages
         $languageList = eZContentLanguage::fetchLocaleList();
     }
     if ( count( $siteAccessList ) == 0 )
     {
         $ini = eZINI::instance();
         $siteAccessList[] = $ini->variable( 'SiteSettings', 'DefaultAccess' );
     }
     return array( 'node-list' => $nodeList,
                   'include-classes' => $includeClasses,
                   'include-templates' => $includeTemplates,
                   'siteaccess-list' => $siteAccessList,
                   'language-list' => $languageList,
                   'node-assignment-type' => $nodeAssignmentType,
                   'related-type' => $relatedObjectType,
                   'embed-type' => $embedObjectType,
                   'version-type' => $versionType,
                   'minimal-template-set' => $minimalTemplateSet,
                   );
 }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:101,代码来源:ezcontentobjectpackagehandler.php

示例3: canCreateClassList

 function canCreateClassList($asObject = false, $includeFilter = true, $groupList = false, $fetchID = false)
 {
     $ini = eZINI::instance();
     $groupArray = array();
     $languageCodeList = eZContentLanguage::fetchLocaleList();
     $allowedLanguages = array('*' => array());
     $user = eZUser::currentUser();
     $accessResult = $user->hasAccessTo('content', 'create');
     $accessWord = $accessResult['accessWord'];
     $classIDArray = array();
     $classList = array();
     $fetchAll = false;
     if ($accessWord == 'yes') {
         $fetchAll = true;
         $allowedLanguages['*'] = $languageCodeList;
     } else {
         if ($accessWord == 'no') {
             // Cannot create any objects, return empty list.
             return $classList;
         } else {
             foreach ($accessResult['policies'] as $policy) {
                 $policyArray = $this->classListFromPolicy($policy, $languageCodeList);
                 if (empty($policyArray)) {
                     continue;
                 }
                 // Wildcard on all classes
                 if ($policyArray['classes'] == '*') {
                     $fetchAll = true;
                     $allowedLanguages['*'] = array_unique(array_merge($allowedLanguages['*'], $policyArray['language_codes']));
                     // we remove individual class ids that are overriden in all languages by the wildcard (#EZP-20933)
                     foreach ($allowedLanguages as $classId => $classLanguageCodes) {
                         if ($classId == '*') {
                             continue;
                         }
                         if (!count(array_diff($classLanguageCodes, $allowedLanguages['*']))) {
                             unset($allowedLanguages[$classId]);
                         }
                     }
                 } else {
                     if (is_array($policyArray['classes']) && $this->hasCurrentSubtreeLimitation($policy)) {
                         foreach ($policyArray['classes'] as $class) {
                             if (isset($allowedLanguages[$class])) {
                                 $allowedLanguages[$class] = array_unique(array_merge($allowedLanguages[$class], $policyArray['language_codes']));
                             } else {
                                 // we don't add class identifiers that are already covered by the 'all classes' in a language
                                 if (!empty($allowedLanguages['*'])) {
                                     if (!count(array_diff($policyArray['language_codes'], $allowedLanguages['*']))) {
                                         continue;
                                     }
                                 }
                                 $allowedLanguages[$class] = $policyArray['language_codes'];
                             }
                         }
                         $classIDArray = array_merge($classIDArray, array_diff($policyArray['classes'], $classIDArray));
                     }
                 }
             }
         }
     }
     $db = eZDB::instance();
     $filterTableSQL = '';
     $filterSQL = '';
     // Create extra SQL statements for the class group filters.
     if (is_array($groupList)) {
         if (count($groupList) == 0) {
             return $classList;
         }
         $filterTableSQL = ', ezcontentclass_classgroup ccg';
         $filterSQL = " AND" . "      cc.id = ccg.contentclass_id AND" . "      ";
         $filterSQL .= $db->generateSQLINStatement($groupList, 'ccg.group_id', !$includeFilter, true, 'int');
     }
     $classNameFilter = eZContentClassName::sqlFilter('cc');
     if ($fetchAll) {
         // If $asObject is true we fetch all fields in class
         $fields = $asObject ? "cc.*, {$classNameFilter['nameField']}" : "cc.id, {$classNameFilter['nameField']}";
         $rows = $db->arrayQuery("SELECT DISTINCT {$fields} " . "FROM ezcontentclass cc{$filterTableSQL}, {$classNameFilter['from']} " . "WHERE cc.version = " . eZContentClass::VERSION_STATUS_DEFINED . " {$filterSQL} AND {$classNameFilter['where']} " . "ORDER BY {$classNameFilter['nameField']} ASC");
         $classList = eZPersistentObject::handleRows($rows, 'eZContentClass', $asObject);
     } else {
         // If the constrained class list is empty we are not allowed to create any class
         if (count($classIDArray) == 0) {
             return $classList;
         }
         $classIDCondition = $db->generateSQLINStatement($classIDArray, 'cc.id');
         // If $asObject is true we fetch all fields in class
         $fields = $asObject ? "cc.*, {$classNameFilter['nameField']}" : "cc.id, {$classNameFilter['nameField']}";
         $rows = $db->arrayQuery("SELECT DISTINCT {$fields} " . "FROM ezcontentclass cc{$filterTableSQL}, {$classNameFilter['from']} " . "WHERE {$classIDCondition} AND" . "      cc.version = " . eZContentClass::VERSION_STATUS_DEFINED . " {$filterSQL} AND {$classNameFilter['where']} " . "ORDER BY {$classNameFilter['nameField']} ASC");
         $classList = eZPersistentObject::handleRows($rows, 'eZContentClass', $asObject);
     }
     if ($asObject) {
         foreach ($classList as $key => $class) {
             $id = $class->attribute('id');
             if (isset($allowedLanguages[$id])) {
                 $languageCodes = array_unique(array_merge($allowedLanguages['*'], $allowedLanguages[$id]));
             } else {
                 $languageCodes = $allowedLanguages['*'];
             }
             $classList[$key]->setCanInstantiateLanguages($languageCodes);
         }
     }
     eZDebugSetting::writeDebug('kernel-content-class', $classList, "class list fetched from db");
//.........这里部分代码省略.........
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:101,代码来源:ezcontentobjecttreenode.php

示例4: array

$script->startup();
$config = '';
$argumentConfig = '';
$optionHelp = false;
$arguments = false;
$useStandardOptions = true;
$options = $script->getOptions($config, $argumentConfig, $optionHelp, $arguments, $useStandardOptions);
$script->initialize();
eZContentObjectStateGroup::$allowInternalCUD = true;
$lockGroup = eZContentObjectStateGroup::fetchByIdentifier('ez_lock');
if ($lockGroup) {
    $script->shutdown(1, 'ez_lock state group already exists');
}
$db = eZDB::instance();
$db->begin();
$locales = eZContentLanguage::fetchLocaleList();
$localeToUse = false;
$localeIDToUse = false;
// this script inserts English names, so preferably use an English locale
$preferredLocales = array('eng-GB', 'eng-US');
foreach ($preferredLocales as $preferredLocale) {
    if (in_array($preferredLocale, $locales)) {
        $localeToUse = $preferredLocale;
        break;
    }
}
// when none of the preferred locales are in use, then use the top priority language
if ($localeToUse === false) {
    $prioritizedLanguage = eZContentLanguage::topPriorityLanguage();
    $localeToUse = $prioritizedLanguage->attribute('locale');
}
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:31,代码来源:addlockstategroup.php

示例5: canCreateClassList

    /**
     * Finds all classes that the current user can create objects from and returns.
     * It is also possible to filter the list event more with $includeFilter and $groupList.
     *
     * @param bool $asObject If true then it return eZContentClass objects, if not it will be an associative array
     * @param bool $includeFilter If true then it will include only from class groups defined in $groupList, if not it will exclude those groups.
     * @param bool $groupList An array with class group IDs that should be used in filtering, use false if you do not wish to filter at all.
     * @param bool $fetchID A unique name for the current fetch, this must be supplied when filtering is used if you want caching to work.
     * @return array|eZPersistentObject[]
     */
    function canCreateClassList( $asObject = false, $includeFilter = true, $groupList = false, $fetchID = false )
    {
        $ini = eZINI::instance();
        $groupArray = array();
        $languageCodeList = eZContentLanguage::fetchLocaleList();
        $allowedLanguages = array( '*' => array() );

        $user = eZUser::currentUser();
        $accessResult = $user->hasAccessTo( 'content' , 'create' );
        $accessWord = $accessResult['accessWord'];

        $classIDArray = array();
        $classList = array();
        $fetchAll = false;
        if ( $accessWord == 'yes' )
        {
            $fetchAll = true;
            $allowedLanguages['*'] = $languageCodeList;
        }
        else if ( $accessWord == 'no' )
        {
            // Cannot create any objects, return empty list.
            return $classList;
        }
        else
        {
            $policies = $accessResult['policies'];
            foreach ( $policies as $policyKey => $policy )
            {
                $policyArray = $this->classListFromPolicy( $policy, $languageCodeList );
                if ( empty( $policyArray ) )
                {
                    continue;
                }
                $classIDArrayPart = $policyArray['classes'];
                $languageCodeArrayPart = $policyArray['language_codes'];
                // No class limitation for this policy AND no previous limitation(s)
                if ( $classIDArrayPart == '*' && empty( $classIDArray ) )
                {
                    $fetchAll = true;
                    $allowedLanguages['*'] = array_unique( array_merge( $allowedLanguages['*'], $languageCodeArrayPart ) );
                }
                else if ( is_array( $classIDArrayPart ) )
                {
                    $fetchAll = false;
                    foreach( $classIDArrayPart as $class )
                    {
                        if ( isset( $allowedLanguages[$class] ) )
                        {
                            $allowedLanguages[$class] = array_unique( array_merge( $allowedLanguages[$class], $languageCodeArrayPart ) );
                        }
                        else
                        {
                            $allowedLanguages[$class] = $languageCodeArrayPart;
                        }
                    }
                    $classIDArray = array_merge( $classIDArray, array_diff( $classIDArrayPart, $classIDArray ) );
                }
            }
        }

        $db = eZDB::instance();

        $filterTableSQL = '';
        $filterSQL = '';
        // Create extra SQL statements for the class group filters.
        if ( is_array( $groupList ) )
        {
            if ( count( $groupList ) == 0 )
            {
                return $classList;
            }

            $filterTableSQL = ', ezcontentclass_classgroup ccg';
            $filterSQL = ( " AND" .
                           "      cc.id = ccg.contentclass_id AND" .
                           "      " );
            $filterSQL .= $db->generateSQLINStatement( $groupList, 'ccg.group_id', !$includeFilter, true, 'int' );
        }

        $classNameFilter = eZContentClassName::sqlFilter( 'cc' );

        if ( $fetchAll )
        {
            // If $asObject is true we fetch all fields in class
            $fields = $asObject ? "cc.*, $classNameFilter[nameField]" : "cc.id, $classNameFilter[nameField]";
            $rows = $db->arrayQuery( "SELECT DISTINCT $fields " .
                                     "FROM ezcontentclass cc$filterTableSQL, $classNameFilter[from] " .
                                     "WHERE cc.version = " . eZContentClass::VERSION_STATUS_DEFINED . " $filterSQL AND $classNameFilter[where] " .
                                     "ORDER BY $classNameFilter[nameField] ASC" );
//.........这里部分代码省略.........
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:101,代码来源:ezcontentobject.php

示例6: execute

 function execute($xml)
 {
     $classList = $xml->getElementsByTagName('ContentClass');
     $refArray = array();
     $availableLanguageList = eZContentLanguage::fetchLocaleList();
     foreach ($classList as $class) {
         $this->adjustAttributesPlacement = false;
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
         $classIdentifier = $class->getAttribute('identifier');
         $classRemoteID = $class->getAttribute('remoteID');
         $classObjectNamePattern = $class->getAttribute('objectNamePattern');
         $classExistAction = $class->getAttribute('classExistAction');
         $referenceID = $class->getAttribute('referenceID');
         $this->writeMessage("\tClass '{$classIdentifier}' will be updated.", 'notice');
         $classURLAliasPattern = $class->getAttribute('urlAliasPattern') ? $class->getAttribute('urlAliasPattern') : null;
         $classIsContainer = $class->getAttribute('isContainer');
         if ($classIsContainer !== false) {
             $classIsContainer = $classIsContainer == 'true' ? 1 : 0;
         }
         $classGroupsNode = $class->getElementsByTagName('Groups')->item(0);
         $classAttributesNode = $class->getElementsByTagName('Attributes')->item(0);
         $nameList = array();
         $nameListObject = $class->getElementsByTagName('Names')->item(0);
         if ($nameListObject && $nameListObject->parentNode === $class && $nameListObject->hasAttributes()) {
             $attributes = $nameListObject->attributes;
             if (!is_null($attributes)) {
                 foreach ($attributes as $index => $attr) {
                     if (in_array($attr->name, $availableLanguageList)) {
                         $nameList[$attr->name] = $attr->value;
                     }
                 }
             }
         }
         if (!empty($nameList)) {
             $classNameList = new eZContentClassNameList(serialize($nameList));
             $classNameList->validate();
         } else {
             $classNameList = null;
         }
         $dateTime = time();
         $classCreated = $dateTime;
         $classModified = $dateTime;
         $class = eZContentClass::fetchByRemoteID($classRemoteID);
         if (!$class) {
             $class = eZContentClass::fetchByIdentifier($classIdentifier);
         }
         if ($class) {
             $className = $class->name();
             switch ($classExistAction) {
                 case 'replace':
                     $this->writeMessage("\t\tClass '{$classIdentifier}' will be replaced.", 'notice');
                     foreach ($nameList as $lang => $name) {
                         if (in_array($lang, $availableLanguageList)) {
                             $class->setName($name, $lang);
                         }
                     }
                     $class->setAttribute('contentobject_name', $classObjectNamePattern);
                     $class->setAttribute('identifier', $classIdentifier);
                     $class->setAttribute('is_container', $classIsContainer);
                     $class->setAttribute('url_alias_name', $classURLAliasPattern);
                     $class->store();
                     $class->removeAttributes();
                     break;
                 case 'new':
                     unset($class);
                     $class = false;
                     break;
                     break;
                 case 'extend':
                     $this->writeMessage("\t\tClass '{$classIdentifier}' will be extended.", 'notice');
                     foreach ($nameList as $lang => $name) {
                         if (in_array($lang, $availableLanguageList)) {
                             $class->setName($name, $lang);
                         }
                     }
                     $class->setAttribute('contentobject_name', $classObjectNamePattern);
                     $class->setAttribute('identifier', $classIdentifier);
                     $class->setAttribute('is_container', $classIsContainer);
                     $class->setAttribute('url_alias_name', $classURLAliasPattern);
                     $class->store();
                     break;
                 case 'skip':
                 default:
                     continue;
                     break;
             }
         }
         if (!$class) {
             // Try to create a unique class identifier
             $currentClassIdentifier = $classIdentifier;
             $unique = false;
             while (!$unique) {
                 $classList = eZContentClass::fetchByIdentifier($currentClassIdentifier);
                 if ($classList) {
                     // "increment" class identifier
                     if (preg_match('/^(.*)_(\\d+)$/', $currentClassIdentifier, $matches)) {
                         $currentClassIdentifier = $matches[1] . '_' . ($matches[2] + 1);
                     } else {
                         $currentClassIdentifier = $currentClassIdentifier . '_1';
//.........这里部分代码省略.........
开发者ID:heliopsis,项目名称:ezxmlinstaller,代码行数:101,代码来源:ezcreateclass.php


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