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


PHP eZContentLanguage::maxCount方法代码示例

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


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

示例1: makeList

 public static function makeList($rows)
 {
     if (!is_array($rows) || count($rows) == 0) {
         return array();
     }
     $list = array();
     $maxNumberOfLanguages = eZContentLanguage::maxCount();
     foreach ($rows as $row) {
         $row['always_available'] = $row['lang_mask'] % 2;
         $mask = $row['lang_mask'] & ~1;
         for ($i = 1; $i < $maxNumberOfLanguages; ++$i) {
             $newMask = 1 << $i;
             if (($newMask & $mask) > 0) {
                 $row['lang_mask'] = 1 << $i;
                 $list[] = $row;
             }
         }
     }
     $objectList = eZPersistentObject::handleRows($list, 'eZPathElement', true);
     return $objectList;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:21,代码来源:ezurlaliasquery.php

示例2: 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 = eZContentLanguage::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:sushilbshinde,项目名称:ezpublish-study,代码行数:53,代码来源:ezcontentlanguage.php


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