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


PHP eZContentLanguage::topPriorityLanguage方法代码示例

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


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

示例1: __construct

 /**
  * Initialize ezpClass object
  *
  * @param string $name
  * @param string $identifier
  * @param string $contentObjectName
  * @param int $creatorID
  * @param string $language
  * @param int $groupID
  * @param string $groupName
  */
 public function __construct($name = 'Test class', $identifier = 'test_class', $contentObjectName = '<test_attribute>', $creatorID = 14, $language = 'eng-GB', $groupID = 1, $groupName = 'Content')
 {
     if (eZContentLanguage::fetchByLocale($language) === false) {
         $topPriorityLanguage = eZContentLanguage::topPriorityLanguage();
         if ($topPriorityLanguage) {
             $language = $topPriorityLanguage->attribute('locale');
         }
     }
     $this->language = $language;
     $this->class = eZContentClass::create($creatorID, array(), $this->language);
     $this->class->setName($name, $this->language);
     $this->class->setAttribute('contentobject_name', $contentObjectName);
     $this->class->setAttribute('identifier', $identifier);
     $this->class->store();
     $languageID = eZContentLanguage::idByLocale($this->language);
     $this->class->setAlwaysAvailableLanguageID($languageID);
     $this->classGroup = eZContentClassClassGroup::create($this->id, $this->version, $groupID, $groupName);
     $this->classGroup->store();
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:30,代码来源:class.php

示例2: checkContentRequirements

 public static function checkContentRequirements($module, $http)
 {
     // Check that the object params are 'ok'
     if (!$http->hasPostVariable('ContentObjectID')) {
         eZDebug::writeError('No content object id is provided', 'ezcomments');
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
     }
     $contentObjectId = (int) $http->postVariable('ContentObjectID');
     // Either use provided language code, or fallback on siteaccess default
     if ($http->hasPostVariable('CommentLanguageCode')) {
         $languageCode = $http->postVariable('CommentLanguageCode');
         $language = eZContentLanguage::fetchByLocale($languageCode);
         if ($language === false) {
             eZDebug::writeError("The language code [{$languageCode}] given is not valid in the system.", 'ezcomments');
             return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
         }
     } else {
         $defaultLanguage = eZContentLanguage::topPriorityLanguage();
         $languageCode = $defaultLanguage->attribute('locale');
     }
     // Check that our object is actually a valid holder of comments
     $contentObject = eZContentObject::fetch($contentObjectId);
     if (!$contentObject instanceof eZContentObject) {
         eZDebug::writeError('No content object exists for the given id.', 'ezcomments');
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
     }
     $dataMap = $contentObject->fetchDataMap(false, $languageCode);
     $foundCommentAttribute = false;
     foreach ($dataMap as $attr) {
         if ($attr->attribute('data_type_string') === 'ezcomcomments') {
             $foundCommentAttribute = $attr;
             break;
         }
     }
     // if there is no ezcomcomments attribute inside the content, return
     if (!$foundCommentAttribute) {
         eZDebug::writeError("Content object with id [{$contentObjectId}], does not contain an ezcomments attribute.", 'ezcomments');
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
     }
     return compact('contentObjectId', 'languageCode', 'contentObject', 'foundCommentAttribute');
 }
开发者ID:legende91,项目名称:ez,代码行数:41,代码来源:ezcomposthelper.php

示例3: storePath

 static function storePath($path, $action, $languageName = false, $linkID = false, $alwaysAvailable = false, $rootID = false, $cleanupElements = true, $autoAdjustName = false, $reportErrors = true, $aliasRedirects = true)
 {
     $path = eZURLAliasML::cleanURL($path);
     if ($languageName === false) {
         $languageName = eZContentLanguage::topPriorityLanguage();
     }
     if (is_object($languageName)) {
         $languageObj = $languageName;
         $languageID = (int) $languageName->attribute('id');
         $languageName = $languageName->attribute('locale');
     } else {
         $languageObj = eZContentLanguage::fetchByLocale($languageName);
         $languageID = (int) $languageObj->attribute('id');
     }
     $languageMask = $languageID;
     if ($alwaysAvailable) {
         $languageMask |= 1;
     }
     $path = eZURLAliasML::cleanURL($path);
     $elements = explode('/', $path);
     $db = eZDB::instance();
     $parentID = 0;
     // If the root ID is specified we will start the parent search from that
     if ($rootID !== false) {
         $parentID = $rootID;
     }
     $i = 0;
     // Top element is handled separately.
     $topElement = array_pop($elements);
     // Find correct parent, and create missing ones if necessary
     $createdPath = array();
     foreach ($elements as $element) {
         $actionStr = $db->escapeString($action);
         if ($cleanupElements) {
             $element = eZURLAliasML::convertToAlias($element, 'noname' . (count($createdPath) + 1));
         }
         $elementStr = $db->escapeString(eZURLAliasML::strtolower($element));
         $query = "SELECT * FROM ezurlalias_ml WHERE text_md5 = " . eZURLAliasML::md5($db, $elementStr, false) . " AND parent = {$parentID}";
         $rows = $db->arrayQuery($query);
         if (count($rows) == 0) {
             // Create a fake element to ensure we have a parent
             $elementObj = eZURLAliasML::create($element, "nop:", $parentID, 1);
             $elementObj->store();
             $parentID = (int) $elementObj->attribute('id');
         } else {
             $parentID = (int) $rows[0]['link'];
         }
         $createdPath[] = $element;
         ++$i;
     }
     if ($parentID != 0) {
         $sql = "SELECT text, parent FROM ezurlalias_ml WHERE id = {$parentID}";
         $rows = $db->arrayQuery($sql);
         if (count($rows) > 0) {
             // A special case. If the special entry with empty text is used as parent
             // the parent must be adjust to 0 (ie. real top level).
             if (strlen($rows[0]['text']) == 0 && $rows[0]['parent'] == 0) {
                 $createdPath = array();
                 $parentID = 0;
             }
         }
     }
     if (!preg_match("#^(.+):(.+)\$#", $action, $matches)) {
         return array('status' => self::ACTION_INVALID, 'error_message' => "The action value " . var_export($action, true) . " is invalid", 'error_number' => self::ACTION_INVALID, 'path' => null, 'element' => null);
     }
     $actionName = $matches[1];
     $actionValue = $matches[2];
     $existingElementID = null;
     $alwaysMask = $alwaysAvailable ? 1 : 0;
     $actionStr = $db->escapeString($action);
     $actionTypeStr = $db->escapeString($actionName);
     $createdElement = null;
     if ($linkID === false) {
         if ($cleanupElements) {
             $topElement = eZURLAliasML::convertToAlias($topElement, 'noname' . (count($createdPath) + 1));
         }
         $adjustName = false;
         $curElementID = null;
         $newElementID = null;
         $newText = $topElement;
         $uniqueCounter = 0;
         // Loop until we a valid entry point, which means:
         // 1. The entry does not exist yet, so create a new one
         // 2. The entry exists but is re-usable (e.g. nop or same action)
         // 3. The entry exists and cannot be re-used, instead the name is adjusted to be unique.
         while (true) {
             $newText = $topElement;
             if ($uniqueCounter > 0) {
                 $newText .= $uniqueCounter + 1;
             }
             $textMD5 = eZURLAliasML::md5($db, $newText);
             $query = "SELECT * FROM ezurlalias_ml WHERE parent = {$parentID} AND text_md5 = {$textMD5}";
             $rows = $db->arrayQuery($query);
             if (count($rows) == 0) {
                 // No such entry, create a new one
                 break;
             }
             $row = $rows[0];
             $curID = (int) $row['id'];
             $curAction = $row['action'];
//.........这里部分代码省略.........
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:101,代码来源:ezurlaliasml.php

示例4: decodeLanguageMask

 /**
  * Decodes $langMask into all languages it comprises and whether or not
  * the language mask signifies always available or not.
  *
  * The constituent languages are returned as an array of language ids. If
  * the second parameter, $returnLanguageLocale is set to TRUE, locale-codes
  * are used instead of language ids.
  *
  * @param int $langMask
  * @param boolean $returnLanguageLocale
  * @return array
  */
 public static function decodeLanguageMask($langMask, $returnLanguageLocale = false)
 {
     $maxNumberOfLanguges = self::maxCount();
     $maxInteger = pow(2, $maxNumberOfLanguges);
     $list = array();
     // Applying this bit-logic on negative numbers, or numbers out of bounds
     // will have unexpected results.
     if ($langMask < 0 or $langMask > $maxInteger or $langMask == 1) {
         // We use the default language if the situation above occurs
         $defaultLanguage = eZContentLanguage::topPriorityLanguage();
         $langMask = $defaultLanguage->attribute('id');
     }
     $alwaysAvailable = $langMask % 2;
     $mask = $langMask & ~1;
     // Calculating which translations are present in the current version
     for ($i = 1; $i < $maxNumberOfLanguges; ++$i) {
         $newMask = 1 << $i;
         if (($newMask & $mask) > 0) {
             if ($returnLanguageLocale) {
                 $list[] = eZContentLanguage::fetch($newMask)->attribute('locale');
             } else {
                 $list[] = $newMask;
             }
         }
     }
     return array('always_available' => $alwaysAvailable, 'language_list' => $list);
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:39,代码来源:ezcontentlanguage.php

示例5: array

$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');
}
$lockGroup = new eZContentObjectStateGroup(array('identifier' => 'ez_lock'));
$trans = $lockGroup->translationByLocale($localeToUse);
$trans->setAttribute('name', 'Lock');
$trans->setAttribute('description', 'Lock group');
$messages = array();
if ($lockGroup->isValid($messages)) {
    $cli->output('storing state group ez_lock');
    $lockGroup->store();
} else {
    eZDebug::writeDebug($messages);
    $db->rollback();
    $script->shutdown(2);
}
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:31,代码来源:addlockstategroup.php

示例6: defaultLanguage

    /**
     * @return string|bool
     */
    static function defaultLanguage()
    {
        if ( ! isset( $GLOBALS['eZContentObjectDefaultLanguage'] ) )
        {
            $defaultLanguage = false;
            $language = eZContentLanguage::topPriorityLanguage();
            if ( $language )
            {
                $defaultLanguage = $language->attribute( 'locale' );
            }
            else
            {
                $ini = eZINI::instance();
                if ( $ini->hasVariable( 'RegionalSettings', 'ContentObjectLocale' ) )
                {
                    $defaultLanguage = $ini->variable( 'RegionalSettings', 'ContentObjectLocale' );
                    eZContentLanguage::fetchByLocale( $defaultLanguage, true );
                }
            }
            $GLOBALS['eZContentObjectDefaultLanguage'] = $defaultLanguage;
        }

        return $GLOBALS['eZContentObjectDefaultLanguage'];
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:27,代码来源:ezcontentobject.php

示例7: array

            // Class ID
            $tpl->setVariable('class', $class);
            $tpl->setVariable('lock_timeout', $timeOut);
            $Result = array();
            $Result['content'] = $tpl->fetch('design:class/edit_denied.tpl');
            $Result['path'] = array(array('url' => '/class/grouplist/', 'text' => ezpI18n::tr('kernel/class', 'Class groups')));
            if ($mainGroupID !== false) {
                $Result['path'][] = array('url' => '/class/classlist/' . $mainGroupID, 'text' => $mainGroupName);
            }
            $Result['path'][] = array('url' => false, 'text' => $class->attribute('name'));
            return $Result;
        }
    }
} else {
    if (!$EditLanguage) {
        $language = eZContentLanguage::topPriorityLanguage();
        if ($language) {
            $EditLanguage = $language->attribute('locale');
        } else {
            eZDebug::writeError('Undefined default language', 'class/edit.php');
            $Module->setExitStatus(eZModule::STATUS_FAILED);
            return;
        }
    }
    if (is_numeric($GroupID) and is_string($GroupName) and $GroupName != '') {
        $user = eZUser::currentUser();
        $user_id = $user->attribute('contentobject_id');
        $class = eZContentClass::create($user_id, array(), $EditLanguage);
        $class->setName(ezpI18n::tr('kernel/class/edit', 'New Class'), $EditLanguage);
        $class->store();
        $editLanguageID = eZContentLanguage::idByLocale($EditLanguage);
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:31,代码来源:edit.php

示例8: defaultLanguage

 function defaultLanguage()
 {
     if (!is_object($this->DefaultLanguage)) {
         $this->DefaultLanguage = eZContentLanguage::topPriorityLanguage();
     }
     return $this->DefaultLanguage;
 }
开发者ID:rmiguel,项目名称:ezpublish,代码行数:7,代码来源:ezserializedobjectnamelist.php

示例9: createClass

 private function createClass($displayName, $classIdentifier, $groupIdentifier, $groupId)
 {
     $adminUserObject = eZUser::fetchByName("admin");
     $adminUserObject->loginCurrent();
     $adminUserId = $adminUserObject->attribute('contentobject_id');
     $language = eZContentLanguage::topPriorityLanguage();
     $editLanguage = $language->attribute('locale');
     $class = eZContentClass::create($adminUserId, array(), $editLanguage);
     // this is the display name, ez automatically creates the content-class-identifier from it
     $class->setName($displayName, $editLanguage);
     $class->setAttribute("identifier", $classIdentifier);
     // default naming for objects - content classes should update this value once they have attributes added
     $class->setAttribute('contentobject_name', 'eep-created-content-class');
     $class->store();
     $editLanguageID = eZContentLanguage::idByLocale($editLanguage);
     $class->setAlwaysAvailableLanguageID($editLanguageID);
     $ClassID = $class->attribute('id');
     $ClassVersion = $class->attribute('version');
     $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $groupId, $groupIdentifier);
     $ingroup->store();
     // clean up the content class status
     $class->storeDefined(array());
     $adminUserObject->logoutCurrent();
 }
开发者ID:truffo,项目名称:eep,代码行数:24,代码来源:index.php


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