/** * 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; }
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; }
/** * 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; }
/** * 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); }