本文整理汇总了PHP中eZContentLanguage::definition方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::definition方法的具体用法?PHP eZContentLanguage::definition怎么用?PHP eZContentLanguage::definition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::definition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchList
/**
* Fetches the list of the languages used on the site.
*
* \param forceReloading Optional. If true, the list will be fetched from database even if it is cached in memory.
* Default value is false.
* \return Array of the eZContentLanguage objects of languages used on the site.
* \static
*/
static function fetchList($forceReloading = false)
{
if (isset($GLOBALS['eZContentLanguageList']) && $forceReloading === false) {
return $GLOBALS['eZContentLanguageList'];
}
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
$clusterFileHandler = eZClusterFileHandler::instance($cachePath);
if ($forceReloading || !$clusterFileHandler->fileExists($cachePath)) {
$languages = eZPersistentObject::fetchObjectList(eZContentLanguage::definition());
$clusterFileHandler->fileStoreContents($cachePath, serialize($languages), 'content', 'php');
} else {
$languages = unserialize($clusterFileHandler->fetchContents());
// If for some reason unserialize operation fails, we force the cache file to regenerate
// See http://issues.ez.no/18613
if ($languages === false) {
eZDebug::writeError("An error occurred while reading content language cache file {$cachePath}. File is being re-generated", __METHOD__);
return self::fetchList(true);
}
}
unset($GLOBALS['eZContentLanguageList']);
unset($GLOBALS['eZContentLanguageMask']);
$GLOBALS['eZContentLanguageList'] = array();
$mask = 1;
// we want have 0-th bit set too!
foreach ($languages as $language) {
$GLOBALS['eZContentLanguageList'][$language->attribute('id')] = $language;
$mask += $language->attribute('id');
}
$GLOBALS['eZContentLanguageMask'] = $mask;
return $GLOBALS['eZContentLanguageList'];
}
示例2: fetchList
/**
* Fetches the list of the languages used on the site.
*
* \param forceReloading Optional. If true, the list will be fetched from database even if it is cached in memory.
* Default value is false.
* \return Array of the eZContentLanguage objects of languages used on the site.
* \static
*/
static function fetchList( $forceReloading = false )
{
if( isset( $GLOBALS['eZContentLanguageList'] ) && $forceReloading === false )
return $GLOBALS['eZContentLanguageList'];
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
$clusterFileHandler = eZClusterFileHandler::instance( $cachePath );
if( $forceReloading || !$clusterFileHandler->fileExists( $cachePath ) )
{
$languages = eZPersistentObject::fetchObjectList( eZContentLanguage::definition() );
$clusterFileHandler->fileStoreContents( $cachePath, serialize( $languages ), 'content', 'php' );
}
else
$languages = unserialize( $clusterFileHandler->fetchContents() );
unset( $GLOBALS['eZContentLanguageList'] );
unset( $GLOBALS['eZContentLanguageMask'] );
$GLOBALS['eZContentLanguageList'] = array();
$mask = 1; // we want have 0-th bit set too!
foreach ( $languages as $language )
{
$GLOBALS['eZContentLanguageList'][$language->attribute( 'id' )] = $language;
$mask += $language->attribute( 'id' );
}
$GLOBALS['eZContentLanguageMask'] = $mask;
return $GLOBALS['eZContentLanguageList'];
}