本文整理汇总了PHP中Locale::isLocaleValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::isLocaleValid方法的具体用法?PHP Locale::isLocaleValid怎么用?PHP Locale::isLocaleValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::isLocaleValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preInstall
/**
* Pre-installation.
* @return boolean
*/
function preInstall()
{
$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) && Locale::isLocaleValid($this->locale)) {
array_push($this->installedLocales, $this->locale);
}
if ($this->getParam('manualInstall')) {
// Do not perform database installation for manual install
// Create connection object with the appropriate database driver for adodb-xmlschema
$conn =& new DBConnection($this->getParam('databaseDriver'), null, null, null, null);
$this->dbconn =& $conn->getDBConn();
} else {
// 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'), true, $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();
}
示例2: execute
/**
* Save modified settings.
*/
function execute()
{
$journal =& Request::getJournal();
$settingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
// Verify additional locales
$supportedLocales = array();
foreach ($this->getData('supportedLocales') as $locale) {
if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
array_push($supportedLocales, $locale);
}
}
$primaryLocale = $this->getData('primaryLocale');
if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) {
array_push($supportedLocales, $primaryLocale);
}
$this->setData('supportedLocales', $supportedLocales);
foreach ($this->_data as $name => $value) {
if (!in_array($name, array_keys($this->settings))) {
continue;
}
$settingsDao->updateSetting($journal->getJournalId(), $name, $value, $this->settings[$name]);
}
$journalDao =& DAORegistry::getDAO('JournalDAO');
$journal->setPrimaryLocale($this->getData('primaryLocale'));
$journalDao->updateJournal($journal);
}
示例3: upgrade
/**
* Display upgrade form.
*/
function upgrade()
{
InstallHandler::validate();
if (($setLocale = Request::getUserVar('setLocale')) != null && Locale::isLocaleValid($setLocale)) {
Request::setCookieVar('currentLocale', $setLocale);
}
$installForm =& new UpgradeForm();
$installForm->initData();
$installForm->display();
}
示例4: upgrade
/**
* Display upgrade form.
*/
function upgrade()
{
$this->validate();
$this->setupTemplate();
if (($setLocale = PKPRequest::getUserVar('setLocale')) != null && Locale::isLocaleValid($setLocale)) {
PKPRequest::setCookieVar('currentLocale', $setLocale);
}
$installForm = new UpgradeForm();
$installForm->initData();
$installForm->display();
}
示例5: reloadLocalizedDefaultSettings
function reloadLocalizedDefaultSettings()
{
// make sure the locale is valid
$locale = Request::getUserVar('localeToLoad');
if (!Locale::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: 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 (!Locale::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);
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign(array('currentUrl' => $request->url(null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => $request->url(null, $request->getRequestedPage()), 'backLinkLabel' => 'manager.journalManagement'));
$templateMgr->display('common/message.tpl');
}
示例7: setLocale
/**
* Change the locale for the current user.
* @param $args array first parameter is the new locale
*/
function setLocale($args)
{
$setLocale = isset($args[0]) ? $args[0] : null;
$site =& Request::getSite();
if (Locale::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(null, 'index');
}
示例8: getLocaleFiles
function getLocaleFiles($locale)
{
if (!Locale::isLocaleValid($locale)) {
return null;
}
$localeFiles = array(Locale::getMainLocaleFilename($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 (!Locale::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: installLocale
/**
* Install a new locale.
*/
function installLocale()
{
$this->validate();
$site =& Request::getSite();
$installLocale = Request::getUserVar('installLocale');
if (isset($installLocale) && is_array($installLocale)) {
$installedLocales = $site->getInstalledLocales();
foreach ($installLocale as $locale) {
if (Locale::isLocaleValid($locale) && !in_array($locale, $installedLocales)) {
array_push($installedLocales, $locale);
Locale::installLocale($locale);
}
}
$site->setInstalledLocales($installedLocales);
$siteDao =& DAORegistry::getDAO('SiteDAO');
$siteDao->updateObject($site);
}
Request::redirect('admin', 'languages');
}
示例11: reloadLocalizedDefaultSettings
/**
* Reload the default localized settings for the press
* @param $args array
* @param $request object
*/
function reloadLocalizedDefaultSettings($args, &$request)
{
// make sure the locale is valid
$locale = $request->getUserVar('localeToLoad');
if (!Locale::isLocaleValid($locale)) {
$request->redirect(null, null, 'languages');
}
$this->setupTemplate(true);
$press =& $request->getPress();
$pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
$pressSettingsDao->reloadLocalizedDefaultSettings($press->getId(), 'registry/pressSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'pressPath' => $press->getData('path'), 'primaryLocale' => $press->getPrimaryLocale(), 'pressName' => $press->getName($press->getPrimaryLocale())), $locale);
// also reload the user group localizable data
$userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
$userGroupDao->installLocale($locale, $press->getId());
// Display a notification
import('lib.pkp.classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved');
$request->redirect(null, null, 'languages');
}
示例12: getLocaleFiles
function getLocaleFiles($locale)
{
if (!Locale::isLocaleValid($locale)) {
return null;
}
$localeFiles =& Locale::makeComponentMap($locale);
$plugins =& PluginRegistry::loadAllPlugins();
foreach (array_keys($plugins) as $key) {
$plugin =& $plugins[$key];
$localeFile = $plugin->getLocaleFilename($locale);
if (!empty($localeFile)) {
if (is_scalar($localeFile)) {
$localeFiles[] = $localeFile;
}
if (is_array($localeFile)) {
$localeFiles = array_merge($localeFiles, $localeFile);
}
}
unset($plugin);
}
return $localeFiles;
}
示例13: execute
/**
* Save modified settings.
*/
function execute()
{
$press =& Request::getPress();
$settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
// Verify additional locales
foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) {
${$name} = array();
foreach ($this->getData($name) as $locale) {
if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
array_push(${$name}, $locale);
}
}
}
$primaryLocale = $this->getData('primaryLocale');
// Make sure at least the primary locale is chosen as available
if ($primaryLocale != null && !empty($primaryLocale)) {
foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) {
if (!in_array($primaryLocale, ${$name})) {
array_push(${$name}, $primaryLocale);
}
}
}
$this->setData('supportedLocales', $supportedLocales);
$this->setData('supportedSubmissionLocales', $supportedSubmissionLocales);
$this->setData('supportedFormLocales', $supportedFormLocales);
foreach ($this->_data as $name => $value) {
if (!in_array($name, array_keys($this->settings))) {
continue;
}
$settingsDao->updateSetting($press->getId(), $name, $value, $this->settings[$name]);
}
$pressDao =& DAORegistry::getDAO('PressDAO');
$press->setPrimaryLocale($this->getData('primaryLocale'));
$pressDao->updatePress($press);
}
示例14: array
//.........这里部分代码省略.........
} else {
$newUser->setUnencryptedPassword($attrib->getValue());
}
break;
case 'salutation':
$newUser->setSalutation($attrib->getValue());
break;
case 'first_name':
$newUser->setFirstName($attrib->getValue());
break;
case 'middle_name':
$newUser->setMiddleName($attrib->getValue());
break;
case 'last_name':
$newUser->setLastName($attrib->getValue());
break;
case 'initials':
$newUser->setInitials($attrib->getValue());
break;
case 'gender':
$newUser->setGender($attrib->getValue());
break;
case 'affiliation':
$locale = $attrib->getAttribute('locale');
if (empty($locale)) {
$locale = $schedConfPrimaryLocale;
}
$newUser->setAffiliation($attrib->getValue(), $locale);
break;
case 'email':
$newUser->setEmail($attrib->getValue());
break;
case 'url':
$newUser->setUrl($attrib->getValue());
break;
case 'phone':
$newUser->setPhone($attrib->getValue());
break;
case 'fax':
$newUser->setFax($attrib->getValue());
break;
case 'mailing_address':
$newUser->setMailingAddress($attrib->getValue());
break;
case 'country':
$newUser->setCountry($attrib->getValue());
break;
case 'signature':
$locale = $attrib->getAttribute('locale');
if (empty($locale)) {
$locale = $schedConfPrimaryLocale;
}
$newUser->setSignature($attrib->getValue(), $locale);
break;
case 'interests':
$locale = $attrib->getAttribute('locale');
if (empty($locale)) {
$locale = $schedConfPrimaryLocale;
}
$newUser->setInterests($attrib->getValue(), $locale);
break;
case 'gossip':
$locale = $attrib->getAttribute('locale');
if (empty($locale)) {
$locale = $schedConfPrimaryLocale;
}
$newUser->setGossip($attrib->getValue(), $locale);
break;
case 'biography':
$locale = $attrib->getAttribute('locale');
if (empty($locale)) {
$locale = $schedConfPrimaryLocale;
}
$newUser->setBiography($attrib->getValue(), $locale);
break;
case 'locales':
$locales = array();
foreach (explode(':', $attrib->getValue()) as $locale) {
if (Locale::isLocaleValid($locale) && in_array($locale, $siteSupportedLocales)) {
array_push($locales, $locale);
}
}
$newUser->setLocales($locales);
break;
case 'role':
$roleType = $attrib->getAttribute('type');
if ($this->validRole($roleType)) {
$role = new Role();
$role->setRoleId($roleDao->getRoleIdFromPath($roleType));
$newUser->addRole($role);
}
break;
}
}
array_push($this->usersToImport, $newUser);
}
}
}
return $this->usersToImport;
}
示例15: saveLocaleFile
function saveLocaleFile($args)
{
$this->validate();
$plugin =& PluginRegistry::getPlugin('generic', 'CustomLocalePlugin');
$this->setupTemplate($plugin, true);
$locale = array_shift($args);
if (!Locale::isLocaleValid($locale)) {
$path = array($plugin->getCategory(), $plugin->getName(), 'index');
Request::redirect(null, null, null, $path);
}
$filename = urldecode(urldecode(array_shift($args)));
if (!CustomLocaleAction::isLocaleFile($locale, $filename)) {
$path = array($plugin->getCategory(), $plugin->getName(), 'edit', $locale);
Request::redirect(null, null, null, $path);
}
$journal =& Request::getJournal();
$journalId = $journal->getId();
$changes = Request::getUserVar('changes');
$customFilesDir = Config::getVar('files', 'public_files_dir') . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale;
$customFilePath = $customFilesDir . DIRECTORY_SEPARATOR . $filename;
// Create empty custom locale file if it doesn't exist
import('file.FileManager');
import('file.EditableLocaleFile');
if (!FileManager::fileExists($customFilePath)) {
$numParentDirs = substr_count($customFilePath, DIRECTORY_SEPARATOR);
$parentDirs = '';
for ($i = 0; $i < $numParentDirs; $i++) {
$parentDirs .= '..' . DIRECTORY_SEPARATOR;
}
$newFileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$newFileContents .= '<!DOCTYPE locale SYSTEM "' . $parentDirs . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'dtd' . DIRECTORY_SEPARATOR . 'locale.dtd' . '">' . "\n";
$newFileContents .= '<locale name="' . $locale . '">' . "\n";
$newFileContents .= '</locale>';
FileManager::writeFile($customFilePath, $newFileContents);
}
$file = new EditableLocaleFile($locale, $customFilePath);
while (!empty($changes)) {
$key = array_shift($changes);
$value = $this->correctCr(array_shift($changes));
if (!empty($value)) {
if (!$file->update($key, $value)) {
$file->insert($key, $value);
}
} else {
$file->delete($key);
}
}
$file->write();
Request::redirectUrl(Request::getUserVar('redirectUrl'));
}