本文整理汇总了PHP中AppLocale::isLocaleValid方法的典型用法代码示例。如果您正苦于以下问题:PHP AppLocale::isLocaleValid方法的具体用法?PHP AppLocale::isLocaleValid怎么用?PHP AppLocale::isLocaleValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppLocale
的用法示例。
在下文中一共展示了AppLocale::isLocaleValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* @copydoc SetupListbuilderHandler::initialize()
*/
function initialize($request)
{
parent::initialize($request);
$context = $request->getContext();
$this->setTitle('plugins.generic.translator.localeFileContents');
$this->setInstructions('plugins.generic.translator.localeFileContentsDescription');
// Get and validate the locale and filename parameters
$this->locale = $request->getUserVar('locale');
if (!AppLocale::isLocaleValid($this->locale)) {
fatalError('Invalid locale.');
}
$this->filename = $request->getUserVar('filename');
if (!in_array($this->filename, TranslatorAction::getLocaleFiles($this->locale))) {
fatalError('Invalid locale file specified!');
}
// Basic configuration
$this->setSourceType(LISTBUILDER_SOURCE_TYPE_TEXT);
$this->setSaveType(LISTBUILDER_SAVE_TYPE_EXTERNAL);
$this->setSaveFieldName('localeKeys');
self::$plugin->import('controllers.listbuilder.LocaleFileListbuilderGridCellProvider');
$cellProvider = new LocaleFileListbuilderGridCellProvider($this->locale);
// Key column
$this->addColumn(new ListbuilderGridColumn($this, 'key', 'plugins.generic.translator.localeKey', null, self::$plugin->getTemplatePath() . 'localeFileKeyGridCell.tpl', $cellProvider, array('tabIndex' => 1)));
// Value column (custom template displays English text)
$this->addColumn(new ListbuilderGridColumn($this, 'value', 'plugins.generic.translator.localeKeyValue', null, self::$plugin->getTemplatePath() . 'localeFileValueGridCell.tpl', $cellProvider, array('tabIndex' => 2, 'width' => 70, 'alignment' => COLUMN_ALIGNMENT_LEFT)));
}
示例2: getFilename
/**
* Get the filename of the qualifier database
* @param $locale string
* @return string
*/
function getFilename($locale)
{
if (!AppLocale::isLocaleValid($locale)) {
$locale = AppLocale::MASTER_LOCALE;
}
return "lib/pkp/locale/{$locale}/bic21qualifiers.xml";
}
示例3: upgrade
/**
* Display upgrade form.
*/
function upgrade()
{
$this->validate();
$this->setupTemplate();
if (($setLocale = PKPRequest::getUserVar('setLocale')) != null && AppLocale::isLocaleValid($setLocale)) {
PKPRequest::setCookieVar('currentLocale', $setLocale);
}
$installForm = new UpgradeForm();
$installForm->initData();
$installForm->display();
}
示例4: initialize
/**
* @copydoc Gridhandler::initialize()
*/
function initialize($request, $args = null)
{
parent::initialize($request);
$this->tabsSelector = $request->getUserVar('tabsSelector');
$this->locale = $request->getUserVar('locale');
if (!AppLocale::isLocaleValid($this->locale)) {
fatalError('Invalid locale.');
}
$this->addColumns();
if ($this->locale != MASTER_LOCALE) {
$this->addColumn(new GridColumn('status', 'common.status', null, 'controllers/grid/gridCell.tpl', null, array('html' => true, 'alignment' => COLUMN_ALIGNMENT_LEFT)));
}
}
示例5: reloadLocalizedDefaultSettings
/**
* Reload the default localized settings for this conference
* @param $args array
* @param $request object
*/
function reloadLocalizedDefaultSettings($args, &$request)
{
// make sure the locale is valid
$locale = $request->getUserVar('localeToLoad');
if (!AppLocale::isLocaleValid($locale)) {
$request->redirect(null, null, null, 'languages');
}
$this->validate();
$this->setupTemplate(true);
$conference =& $request->getConference();
$conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
$conferenceSettingsDao->reloadLocalizedDefaultSettings($conference->getId(), 'registry/conferenceSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'conferencePath' => $conference->getData('path'), 'primaryLocale' => $conference->getPrimaryLocale(), 'conferenceName' => $conference->getTitle($conference->getPrimaryLocale())), $locale);
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign(array('currentUrl' => $request->url(null, null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => $request->url(null, null, $request->getRequestedPage()), 'backLinkLabel' => 'manager.conferenceSiteManagement'));
$templateMgr->display('common/message.tpl');
}
示例6: setLocale
/**
* Change the locale for the current user.
* @param $args array first parameter is the new locale
*/
function setLocale($args, &$request)
{
$setLocale = isset($args[0]) ? $args[0] : null;
$site =& $request->getSite();
if (AppLocale::isLocaleValid($setLocale) && in_array($setLocale, $site->getSupportedLocales())) {
$session =& $request->getSession();
$session->setSessionVar('currentLocale', $setLocale);
}
if (isset($_SERVER['HTTP_REFERER'])) {
$request->redirectUrl($_SERVER['HTTP_REFERER']);
}
$source = $request->getUserVar('source');
if (isset($source) && !empty($source)) {
$request->redirectUrl($request->getProtocol() . '://' . $request->getServerHost() . $source, false);
}
$request->redirect('index');
}
示例7: setLocale
/**
* Change the locale for the current user.
* @param $args array first parameter is the new locale
*/
function setLocale($args, $request)
{
$setLocale = array_shift($args);
$site = $request->getSite();
$context = $request->getContext();
if ($context != null) {
$contextSupportedLocales = (array) $context->getSupportedLocales();
}
if (AppLocale::isLocaleValid($setLocale) && (!isset($contextSupportedLocales) || in_array($setLocale, $contextSupportedLocales)) && in_array($setLocale, $site->getSupportedLocales())) {
$session = $request->getSession();
$session->setSessionVar('currentLocale', $setLocale);
}
if (isset($_SERVER['HTTP_REFERER'])) {
$request->redirectUrl($_SERVER['HTTP_REFERER']);
}
$request->redirect(null, 'index');
}
示例8: getLocaleFiles
function getLocaleFiles($locale)
{
if (!AppLocale::isLocaleValid($locale)) {
return null;
}
$localeFiles = AppLocale::getFilenameComponentMap($locale);
$plugins =& PluginRegistry::loadAllPlugins();
foreach (array_keys($plugins) as $key) {
$plugin =& $plugins[$key];
$localeFile = $plugin->getLocaleFilename($locale);
if (!empty($localeFile)) {
$localeFiles[] = $localeFile;
}
unset($plugin);
}
return $localeFiles;
}
示例9: reloadLocalizedDefaultSettings
/**
* Reload the default localized settings for the journal.
* @param $args array
* @param $request object
*/
function reloadLocalizedDefaultSettings($args, &$request)
{
// make sure the locale is valid
$locale = $request->getUserVar('localeToLoad');
if (!AppLocale::isLocaleValid($locale)) {
$request->redirect(null, null, 'languages');
}
$this->validate();
$this->setupTemplate(true);
$journal =& $request->getJournal();
$journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
$journalSettingsDao->reloadLocalizedDefaultSettings($journal->getId(), 'registry/journalSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'journalPath' => $journal->getData('path'), 'primaryLocale' => $journal->getPrimaryLocale(), 'journalName' => $journal->getTitle($journal->getPrimaryLocale())), $locale);
// Display a notification
import('lib.pkp.classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved');
$request->redirect(null, null, 'languages');
}
示例10: execute
/**
* Save contact settings.
* @param $request PKPRequest
*/
function execute($request)
{
$user = $this->getUser();
$user->setCountry($this->getData('country'));
$user->setEmail($this->getData('email'));
$user->setPhone($this->getData('phone'));
$user->setMailingAddress($this->getData('mailingAddress'));
$user->setAffiliation($this->getData('affiliation'), null);
// Localized
$site = $request->getSite();
$availableLocales = $site->getSupportedLocales();
$locales = array();
foreach ($this->getData('userLocales') as $locale) {
if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
array_push($locales, $locale);
}
}
$user->setLocales($locales);
parent::execute($request, $user);
}
示例11: execute
/**
* @copydoc Form::execute()
*/
function execute($request)
{
$site = $request->getSite();
$localesToInstall = $this->getData('localesToInstall');
if (isset($localesToInstall) && is_array($localesToInstall)) {
$installedLocales = $site->getInstalledLocales();
$supportedLocales = $site->getSupportedLocales();
foreach ($localesToInstall as $locale) {
if (AppLocale::isLocaleValid($locale) && !in_array($locale, $installedLocales)) {
array_push($installedLocales, $locale);
// Activate/support by default.
if (!in_array($locale, $supportedLocales)) {
array_push($supportedLocales, $locale);
}
AppLocale::installLocale($locale);
}
}
$site->setInstalledLocales($installedLocales);
$site->setSupportedLocales($supportedLocales);
$siteDao = DAORegistry::getDAO('SiteDAO');
$siteDao->updateObject($site);
}
}
示例12: preInstall
/**
* Pre-installation.
* @return boolean
*/
function preInstall()
{
if (!isset($this->currentVersion)) {
$this->currentVersion = Version::fromString('');
}
$this->locale = $this->getParam('locale');
$this->installedLocales = $this->getParam('additionalLocales');
if (!isset($this->installedLocales) || !is_array($this->installedLocales)) {
$this->installedLocales = array();
}
if (!in_array($this->locale, $this->installedLocales) && AppLocale::isLocaleValid($this->locale)) {
array_push($this->installedLocales, $this->locale);
}
// Connect to database
$conn = new DBConnection($this->getParam('databaseDriver'), $this->getParam('databaseHost'), $this->getParam('databaseUsername'), $this->getParam('databasePassword'), $this->getParam('createDatabase') ? null : $this->getParam('databaseName'), false, $this->getParam('connectionCharset') == '' ? false : $this->getParam('connectionCharset'));
$this->dbconn =& $conn->getDBConn();
if (!$conn->isConnected()) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
DBConnection::getInstance($conn);
return parent::preInstall();
}
示例13: translateLanguageToLocale
/**
* Try to translate an ISO language code to an OJS locale.
* @param $language string 2- or 3-letter ISO language code
* @return string|null An OJS locale or null if no matching
* locale could be found.
*/
function translateLanguageToLocale($language)
{
$locale = null;
if (strlen($language) == 2) {
$language = AppLocale::get3LetterFrom2LetterIsoLanguage($language);
}
if (strlen($language) == 3) {
$language = AppLocale::getLocaleFrom3LetterIso($language);
}
if (AppLocale::isLocaleValid($language)) {
$locale = $language;
}
return $locale;
}
示例14: array
/**
* Create or update a user.
* @param $args array
* @param $request PKPRequest
*/
function &execute($args, $request)
{
parent::execute($request);
$userDao = DAORegistry::getDAO('UserDAO');
$context = $request->getContext();
if (isset($this->userId)) {
$userId = $this->userId;
$user = $userDao->getById($userId);
}
if (!isset($user)) {
$user = $userDao->newDataObject();
$user->setInlineHelp(1);
// default new users to having inline help visible
}
$user->setSalutation($this->getData('salutation'));
$user->setFirstName($this->getData('firstName'));
$user->setMiddleName($this->getData('middleName'));
$user->setLastName($this->getData('lastName'));
$user->setSuffix($this->getData('suffix'));
$user->setInitials($this->getData('initials'));
$user->setGender($this->getData('gender'));
$user->setAffiliation($this->getData('affiliation'), null);
// Localized
$user->setSignature($this->getData('signature'), null);
// Localized
$user->setEmail($this->getData('email'));
$user->setUrl($this->getData('userUrl'));
$user->setPhone($this->getData('phone'));
$user->setOrcid($this->getData('orcid'));
$user->setMailingAddress($this->getData('mailingAddress'));
$user->setCountry($this->getData('country'));
$user->setBiography($this->getData('biography'), null);
// Localized
$user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
$user->setAuthId((int) $this->getData('authId'));
$site = $request->getSite();
$availableLocales = $site->getSupportedLocales();
$locales = array();
foreach ($this->getData('userLocales') as $locale) {
if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
array_push($locales, $locale);
}
}
$user->setLocales($locales);
if ($user->getAuthId()) {
$authDao = DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if ($user->getId() != null) {
if ($this->getData('password') !== '') {
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
}
if (isset($auth)) {
// FIXME Should try to create user here too?
$auth->doSetUserInfo($user);
}
$userDao->updateObject($user);
} else {
$user->setUsername($this->getData('username'));
if ($this->getData('generatePassword')) {
$password = Validation::generatePassword();
$sendNotify = true;
} else {
$password = $this->getData('password');
$sendNotify = $this->getData('sendNotify');
}
if (isset($auth)) {
$user->setPassword($password);
// FIXME Check result and handle failures
$auth->doCreateUser($user);
$user->setAuthId($auth->authId);
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
}
$user->setDateRegistered(Core::getCurrentDate());
$userId = $userDao->insertObject($user);
if ($sendNotify) {
// Send welcome email to user
import('lib.pkp.classes.mail.MailTemplate');
$mail = new MailTemplate('USER_REGISTER');
$mail->setReplyTo($context->getSetting('contactEmail'), $context->getSetting('contactName'));
$mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName()));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send();
}
}
import('lib.pkp.classes.user.InterestManager');
//.........这里部分代码省略.........
示例15: removeBookForReviewCoverPage
/**
* Remove book for review cover page image.
*/
function removeBookForReviewCoverPage($args = array(), &$request)
{
$this->setupTemplate();
if (empty($args) || count($args) < 2) {
$request->redirect(null, 'editor');
}
$bookId = (int) $args[0];
$formLocale = $args[1];
if (!AppLocale::isLocaleValid($formLocale)) {
$request->redirect(null, 'editor');
}
$bfrPlugin =& PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME);
$returnPage = $request->getUserVar('returnPage');
if ($returnPage != null) {
$validPages =& $this->getValidReturnPages();
if (!in_array($returnPage, $validPages)) {
$returnPage = null;
}
}
$journal =& $request->getJournal();
$journalId = $journal->getId();
$bfrDao =& DAORegistry::getDAO('BookForReviewDAO');
// Ensure book for review is for this journal
if ($bfrDao->getBookForReviewJournalId($bookId) == $journalId) {
$bfrDao->removeCoverPage($bookId, $formLocale);
$request->redirect(null, 'editor', 'editBookForReview', $bookId, array('returnPage' => $returnPage));
}
$request->redirect(null, 'editor', 'booksForReview', $returnPage);
}