本文整理汇总了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;
}
示例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
);
}