diff -u -r1.6 Locale.inc.php
--- classes/i18n/Locale.inc.php 12 May 2009 20:12:43 -0000 1.6
+++ classes/i18n/Locale.inc.php 3 Jul 2009 00:08:12 -0000
@@ -27,7 +27,7 @@
class Locale extends PKPLocale {
/**
- * Get all supported locales for the current context.
+ * Get all supported UI locales for the current context.
* @return array
*/
function getSupportedLocales() {
@@ -46,6 +46,25 @@
}
/**
+ * Get all supported form locales for the current context.
+ * @return array
+ */
+ function getSupportedFormLocales() {
+ static $supportedFormLocales;
+ if (!isset($supportedFormLocales)) {
+ if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
+ $supportedFormLocales = Locale::getAllLocales();
+ } elseif (($press =& Request::getPress())) {
+ $supportedFormLocales = $press->getSupportedFormLocaleNames();
+ } else {
+ $site =& Request::getSite();
+ $supportedFormLocales = $site->getSupportedLocaleNames();
+ }
+ }
+ return $supportedFormLocales;
+ }
+
+ /**
* Return the key name of the user's currently selected locale (default
* is "en_US" for U.S. English).
* @return string
diff -u -r1.3 LanguageSettingsForm.inc.php
--- classes/manager/form/LanguageSettingsForm.inc.php 12 May 2009 20:12:43 -0000 1.3
+++ classes/manager/form/LanguageSettingsForm.inc.php 3 Jul 2009 00:08:12 -0000
@@ -32,7 +32,8 @@
parent::Form('manager/languageSettings.tpl');
$this->settings = array(
- 'supportedLocales' => 'object'
+ 'supportedLocales' => 'object',
+ 'supportedFormLocales' => 'object'
);
$site =& Request::getSite();
@@ -68,8 +69,10 @@
$this->setData('primaryLocale', $press->getPrimaryLocale());
- if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
- $this->setData('supportedLocales', array());
+ foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
+ if ($this->getData($name) == null || !is_array($this->getData($name))) {
+ $this->setData($name, array());
+ }
}
}
@@ -81,8 +84,10 @@
$vars[] = 'primaryLocale';
$this->readUserVars($vars);
- if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
- $this->setData('supportedLocales', array());
+ foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
+ if ($this->getData($name) == null || !is_array($this->getData($name))) {
+ $this->setData($name, array());
+ }
}
}
@@ -94,19 +99,27 @@
$settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
// Verify additional locales
- $supportedLocales = array();
- foreach ($this->getData('supportedLocales') as $locale) {
- if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
- array_push($supportedLocales, $locale);
+ foreach (array('supportedLocales', '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');
- if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) {
- array_push($supportedLocales, $primaryLocale);
+ // Make sure at least the primary locale is chosen as available
+ if ($primaryLocale != null && !empty($primaryLocale)) {
+ foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
+ if (!in_array($primaryLocale, $$name)) {
+ array_push($$name, $primaryLocale);
+ }
+ }
}
$this->setData('supportedLocales', $supportedLocales);
+ $this->setData('supportedFormLocales', $supportedFormLocales);
foreach ($this->_data as $name => $value) {
if (!in_array($name, array_keys($this->settings))) continue;
@@ -122,7 +135,6 @@
$press->setPrimaryLocale($this->getData('primaryLocale'));
$pressDao->updatePress($press);
}
-
}
?>
diff -u -r1.5 Press.inc.php
--- classes/press/Press.inc.php 23 Jun 2009 01:40:29 -0000 1.5
+++ classes/press/Press.inc.php 3 Jul 2009 00:08:13 -0000
@@ -188,6 +188,31 @@
return $returner;
}
/**
+ * Return associative array of all locales supported by forms on the site.
+ * These locales are used to provide a language toggle on the main site pages.
+ * @return array
+ */
+ function &getSupportedFormLocaleNames() {
+ $supportedLocales =& $this->getData('supportedFormLocales');
+
+ if (!isset($supportedLocales)) {
+ $supportedLocales = array();
+ $localeNames =& Locale::getAllLocales();
+
+ $locales = $this->getSetting('supportedFormLocales');
+ if (!isset($locales) || !is_array($locales)) {
+ $locales = array();
+ }
+
+ foreach ($locales as $localeKey) {
+ $supportedLocales[$localeKey] = $localeNames[$localeKey];
+ }
+ }
+
+ return $supportedLocales;
+ }
+
+ /**
* Get "localized" press page title (if applicable).
* param $home boolean get homepage title
* @return string
diff -u -r1.12 manager.xml
--- locale/en_US/manager.xml 30 Jun 2009 01:16:33 -0000 1.12
+++ locale/en_US/manager.xml 3 Jul 2009 00:08:15 -0000
@@ -44,6 +44,8 @@
People in About the Press:]]>
No editorial team positions have been created.
Press Management
+ UI
+ Forms
This will replace any locale-specific press settings you had for this locale
Reload locale-specific default settings
If a language supported by OMP is not listed below, ask your site administrator to install the language from the site administration interface. For instructions on adding support for new languages, please consult the OMP documentation.]]>
@@ -461,4 +463,4 @@
No. of reviews
Select the sections for calculating this press's peer-reviewed statistics.
Show users with no role
-
\ No newline at end of file
+
diff -u -r1.1.1.1 languageSettings.tpl
--- templates/manager/languageSettings.tpl 20 Oct 2008 21:27:09 -0000 1.1.1.1
+++ templates/manager/languageSettings.tpl 3 Jul 2009 00:08:17 -0000
@@ -22,33 +22,39 @@
- | {fieldLabel name="primaryLocale" required="true" key="locale.primary"} |
- |
+ {fieldLabel name="primaryLocale" required="true" key="locale.primary"} |
+
+
+ |
- | |
- {translate key="manager.languages.primaryLocaleInstructions"} |
+ {translate key="manager.languages.primaryLocaleInstructions"} |
- | {fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"} |
-
+ | {fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"} |
+
|
- | |
- {translate key="manager.languages.supportedLocalesInstructions"} |
+ {translate key="manager.languages.supportedLocalesInstructions"} |