本文整理汇总了PHP中AppLocale::getLocalePrecedence方法的典型用法代码示例。如果您正苦于以下问题:PHP AppLocale::getLocalePrecedence方法的具体用法?PHP AppLocale::getLocalePrecedence怎么用?PHP AppLocale::getLocalePrecedence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppLocale
的用法示例。
在下文中一共展示了AppLocale::getLocalePrecedence方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
/**
* Get a piece of data for this object, localized to the current
* locale if possible.
* @param $key string
* @return mixed
*/
function &getLocalizedData($key)
{
$localePrecedence = AppLocale::getLocalePrecedence();
foreach ($localePrecedence as $locale) {
$value =& $this->getData($key, $locale);
if (!empty($value)) {
return $value;
}
unset($value);
}
// Fallback: Get the first available piece of data.
$data =& $this->getData($key, null);
if (is_string($data)) {
return $data;
} else {
if (is_array($data)) {
// WARNING: Collapsing the following into a single line causes PHP 5.0.5 to die.
$locales = array_keys($data);
$firstLocale = array_shift($locales);
return $data[$firstLocale];
}
}
// No data available; return null.
unset($data);
$data = null;
return $data;
}
示例2: foreach
function &getLocalizedData($key)
{
$localePrecedence = AppLocale::getLocalePrecedence();
foreach ($localePrecedence as $locale) {
$value =& $this->getData($key, $locale);
if (!empty($value)) {
return $value;
}
unset($value);
}
// Fallback: Get the first available piece of data.
$data =& $this->getData($key, null);
if (!empty($data)) {
return $data[array_shift(array_keys($data))];
}
// No data available; return null.
unset($data);
$data = null;
return $data;
}
示例3: TemplateManager
/**
* Return an instance of the template manager.
* @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory
* @return TemplateManager the template manager object
*/
function &getManager($request = null)
{
$instance =& Registry::get('templateManager', true, null);
if ($instance === null) {
$instance = new TemplateManager($request);
}
$supportedLocales = AppLocale::getSupportedLocales();
$instance->assign('supportedLocales', $supportedLocales);
$instance->assign('localePrecedence', AppLocale::getLocalePrecedence());
$instance->assign('requestedPage', Request::getRequestedPage());
$instance->assign('requestedOp', Request::getRequestedOp());
$conference =& Request::getConference();
if (isset($conference)) {
$instance->assign('conferenceId', $conference->getId());
$instance->assign('isConferenceManager', Validation::isConferenceManager($conference->getId()));
$instance->assign('analyticsTrackingID', $conference->getSetting('analyticsTrackingID'));
$schedConf =& Request::getSchedConf();
if (isset($schedConf)) {
$instance->assign('isDirector', Validation::isDirector($conference->getId(), $schedConf->getId()));
$instance->assign('isTrackDirector', Validation::isTrackDirector($conference->getId(), $schedConf->getId()));
$instance->assign('isAuthor', Validation::isAuthor($conference->getId(), $schedConf->getId()));
$registrationDao =& DAORegistry::getDAO('RegistrationDAO');
$user = Request::getUser();
if (isset($user)) {
$instance->assign('isRegistrationUser', $registrationDao->isValidRegistrationByUser($user->getUserId(), $schedConf->getId()));
}
}
}
AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_MANAGER, LOCALE_COMPONENT_OCS_ADMIN, LOCALE_COMPONENT_OCS_DIRECTOR, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_PKP_SUBMISSION));
// FIXME: For timeline constants
return $instance;
}
示例4: getLocalizedCopyrightHolder
/**
* Get the localized copyright holder for this article.
*/
function getLocalizedCopyrightHolder()
{
$copyrightHolders = (array) $this->getCopyrightHolder(null);
foreach (AppLocale::getLocalePrecedence() as $locale) {
if (isset($copyrightHolders[$locale])) {
return $copyrightHolders[$locale];
}
}
// Fallback: return anything available
return array_shift($copyrightHolders);
}