View | Details | Raw Unified | Return to bug 3865 | Differences between
and this patch

Collapse All | Expand All

(-)classes/i18n/Locale.inc.php (-1 / +20 lines)
 Lines 27-33    Link Here 
27
27
28
class Locale extends PKPLocale {
28
class Locale extends PKPLocale {
29
	/**
29
	/**
30
	 * Get all supported locales for the current context.
30
	 * Get all supported UI locales for the current context.
31
	 * @return array
31
	 * @return array
32
	 */
32
	 */
33
	function getSupportedLocales() {
33
	function getSupportedLocales() {
 Lines 46-51    Link Here 
46
	}
46
	}
47
47
48
	/**
48
	/**
49
	 * Get all supported form locales for the current context.
50
	 * @return array
51
	 */
52
	function getSupportedFormLocales() {
53
		static $supportedFormLocales;
54
		if (!isset($supportedFormLocales)) {
55
			if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
56
				$supportedFormLocales = Locale::getAllLocales();
57
			} elseif (($press =& Request::getPress())) {
58
				$supportedFormLocales = $press->getSupportedFormLocaleNames();
59
			} else {
60
				$site =& Request::getSite();
61
				$supportedFormLocales = $site->getSupportedLocaleNames();
62
			}
63
		}
64
		return $supportedFormLocales;
65
	}
66
67
	/**
49
	 * Return the key name of the user's currently selected locale (default
68
	 * Return the key name of the user's currently selected locale (default
50
	 * is "en_US" for U.S. English).
69
	 * is "en_US" for U.S. English).
51
	 * @return string 
70
	 * @return string 
(-)classes/manager/form/LanguageSettingsForm.inc.php (-12 / +24 lines)
 Lines 32-38    Link Here 
32
		parent::Form('manager/languageSettings.tpl');
32
		parent::Form('manager/languageSettings.tpl');
33
33
34
		$this->settings = array(
34
		$this->settings = array(
35
			'supportedLocales' => 'object'
35
			'supportedLocales' => 'object',
36
			'supportedFormLocales' => 'object'
36
		);
37
		);
37
38
38
		$site =& Request::getSite();
39
		$site =& Request::getSite();
 Lines 68-75    Link Here 
68
69
69
		$this->setData('primaryLocale', $press->getPrimaryLocale());
70
		$this->setData('primaryLocale', $press->getPrimaryLocale());
70
71
71
		if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
72
		foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
72
			$this->setData('supportedLocales', array());
73
			if ($this->getData($name) == null || !is_array($this->getData($name))) {
74
				$this->setData($name, array());
75
			}
73
		}
76
		}
74
	}
77
	}
75
78
 Lines 81-88    Link Here 
81
		$vars[] = 'primaryLocale';
84
		$vars[] = 'primaryLocale';
82
		$this->readUserVars($vars);
85
		$this->readUserVars($vars);
83
86
84
		if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
87
		foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
85
			$this->setData('supportedLocales', array());
88
			if ($this->getData($name) == null || !is_array($this->getData($name))) {
89
				$this->setData($name, array());
90
			}
86
		}
91
		}
87
	}
92
	}
88
93
 Lines 94-112    Link Here 
94
		$settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
99
		$settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
95
100
96
		// Verify additional locales
101
		// Verify additional locales
97
		$supportedLocales = array();
102
		foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
98
		foreach ($this->getData('supportedLocales') as $locale) {
103
			$$name = array();
99
			if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
104
			foreach ($this->getData($name) as $locale) {
100
				array_push($supportedLocales, $locale);
105
				if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
106
					array_push($$name, $locale);
107
				}
101
			}
108
			}
102
		}
109
		}
103
110
104
		$primaryLocale = $this->getData('primaryLocale');
111
		$primaryLocale = $this->getData('primaryLocale');
105
112
106
		if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) {
113
		// Make sure at least the primary locale is chosen as available
107
			array_push($supportedLocales, $primaryLocale);
114
		if ($primaryLocale != null && !empty($primaryLocale)) {
115
			foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
116
				if (!in_array($primaryLocale, $$name)) {
117
					array_push($$name, $primaryLocale);
118
				}
119
			}
108
		}
120
		}
109
		$this->setData('supportedLocales', $supportedLocales);
121
		$this->setData('supportedLocales', $supportedLocales);
122
		$this->setData('supportedFormLocales', $supportedFormLocales);
110
123
111
		foreach ($this->_data as $name => $value) {
124
		foreach ($this->_data as $name => $value) {
112
			if (!in_array($name, array_keys($this->settings))) continue;
125
			if (!in_array($name, array_keys($this->settings))) continue;
 Lines 122-128    Link Here 
122
		$press->setPrimaryLocale($this->getData('primaryLocale'));
135
		$press->setPrimaryLocale($this->getData('primaryLocale'));
123
		$pressDao->updatePress($press);
136
		$pressDao->updatePress($press);
124
	}
137
	}
125
126
}
138
}
127
139
128
?>
140
?>
(-)classes/press/Press.inc.php (+25 lines)
 Lines 188-193    Link Here 
188
		return $returner;
188
		return $returner;
189
	}
189
	}
190
	/**
190
	/**
191
	 * Return associative array of all locales supported by forms on the site.
192
	 * These locales are used to provide a language toggle on the main site pages.
193
	 * @return array
194
	 */
195
	function &getSupportedFormLocaleNames() {
196
		$supportedLocales =& $this->getData('supportedFormLocales');
197
198
		if (!isset($supportedLocales)) {
199
			$supportedLocales = array();
200
			$localeNames =& Locale::getAllLocales();
201
202
			$locales = $this->getSetting('supportedFormLocales');
203
			if (!isset($locales) || !is_array($locales)) {
204
				$locales = array();
205
			}
206
207
			foreach ($locales as $localeKey) {
208
				$supportedLocales[$localeKey] = $localeNames[$localeKey];
209
			}
210
		}
211
212
		return $supportedLocales;
213
	}
214
215
	/**
191
	 * Get "localized" press page title (if applicable).
216
	 * Get "localized" press page title (if applicable).
192
	 * param $home boolean get homepage title
217
	 * param $home boolean get homepage title
193
	 * @return string
218
	 * @return string
(-)locale/en_US/manager.xml (-1 / +3 lines)
 Lines 44-49    Link Here 
44
	<message key="manager.groups.enableBoard.description"><![CDATA[Under <a href="{$aboutEditorialTeamUrl}">People</a> in About the Press:]]></message>
44
	<message key="manager.groups.enableBoard.description"><![CDATA[Under <a href="{$aboutEditorialTeamUrl}">People</a> in About the Press:]]></message>
45
	<message key="manager.groups.noneCreated">No editorial team positions have been created.</message>
45
	<message key="manager.groups.noneCreated">No editorial team positions have been created.</message>
46
	<message key="manager.pressManagement">Press Management</message>
46
	<message key="manager.pressManagement">Press Management</message>
47
 	<message key="manager.language.ui">UI</message>
48
 	<message key="manager.language.forms">Forms</message>
47
	<message key="manager.language.confirmDefaultSettingsOverwrite">This will replace any locale-specific press settings you had for this locale</message>
49
	<message key="manager.language.confirmDefaultSettingsOverwrite">This will replace any locale-specific press settings you had for this locale</message>
48
	<message key="manager.language.reloadLocalizedDefaultSettings">Reload locale-specific default settings</message>
50
	<message key="manager.language.reloadLocalizedDefaultSettings">Reload locale-specific default settings</message>
49
	<message key="manager.languages.languageInstructions"><![CDATA[OMP can be made available to users in any of several supported languages. As well, OMP can operate as a multilingual system, providing users with an ability to toggle between languages on each page, and allowing certain data to be entered in several additional languages.<br /><br/>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.]]></message>
51
	<message key="manager.languages.languageInstructions"><![CDATA[OMP can be made available to users in any of several supported languages. As well, OMP can operate as a multilingual system, providing users with an ability to toggle between languages on each page, and allowing certain data to be entered in several additional languages.<br /><br/>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.]]></message>
 Lines 461-464    Link Here 
461
	<message key="manager.statistics.statistics.reviewsPerReviewer">No. of reviews</message>
463
	<message key="manager.statistics.statistics.reviewsPerReviewer">No. of reviews</message>
462
	<message key="manager.statistics.statistics.selectSections">Select the sections for calculating this press's peer-reviewed statistics.</message>
464
	<message key="manager.statistics.statistics.selectSections">Select the sections for calculating this press's peer-reviewed statistics.</message>
463
	<message key="manager.people.showNoRole">Show users with no role</message>
465
	<message key="manager.people.showNoRole">Show users with no role</message>
464
</locale>
466
</locale>
(-)templates/manager/languageSettings.tpl (-14 / +20 lines)
 Lines 22-54    Link Here 
22
22
23
<table class="data" width="100%">
23
<table class="data" width="100%">
24
<tr valign="top">
24
<tr valign="top">
25
	<td width="20%" class="label">{fieldLabel name="primaryLocale" required="true" key="locale.primary"}</td>
25
	<td width="20%" rowspan="2" class="label">{fieldLabel name="primaryLocale" required="true" key="locale.primary"}</td>
26
	<td width="80%" colspan="2" class="value"><select id="primaryLocale" name="primaryLocale" size="1" class="selectMenu">
26
	<td width="80%" colspan="3" class="value">
27
	{foreach from=$availableLocales key=localeKey item=localeName}
27
		<select id="primaryLocale" name="primaryLocale" size="1" class="selectMenu">
28
		<option value="{$localeKey|escape}"{if $localeKey == $primaryLocale} selected="selected"{/if}>{$localeName|escape}</option>
28
			{html_options options=$availableLocales selected=$primaryLocale}
29
	{/foreach}
29
		</select>
30
	</select></td>
30
	</td>
31
</tr>
31
</tr>
32
<tr valign="top">
32
<tr valign="top">
33
	<td>&nbsp;</td>
33
	<td colspan="3" class="value"><span class="instruct">{translate key="manager.languages.primaryLocaleInstructions"}</span></td>
34
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.primaryLocaleInstructions"}</span></td>
35
</tr>
34
</tr>
36
<tr valign="top">
35
<tr valign="top">
37
	<td class="label">{fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"}</td>
36
	<td class="label" rowspan="2">{fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"}</td>
38
	<td colspan="2" class="value">
37
	<td colspan="3" class="value">
39
		<table class="data" width="100%">
38
		<table class="data" width="100%">
39
		<tr valign="top">
40
			<td width="20%">&nbsp;</td>
41
			<td align="center" width="10%">{translate key="manager.language.ui"}</td>
42
			<td align="center" width="10%">{translate key="manager.language.forms"}</td>
43
			<td width="60%">&nbsp;</td>
44
		</tr>
40
		{foreach from=$availableLocales key=localeKey item=localeName}
45
		{foreach from=$availableLocales key=localeKey item=localeName}
41
			<tr>
46
			<tr>
42
				<td width="30%"><input type="checkbox" name="supportedLocales[]" id="supportedLocales-{$localeKey|escape}" value="{$localeKey|escape}"{if in_array($localeKey, $supportedLocales)} checked="checked"{/if}/> <label for="supportedLocales-{$localeKey|escape}">{$localeName|escape}</label></td>
47
				<td>{$localeName|escape}</td>
43
				<td width="70%"><a href="{url op="reloadLocalizedDefaultSettings" localeToLoad=$localeKey}" onclick="return confirm('{translate|escape:"jsparam" key="manager.language.confirmDefaultSettingsOverwrite"}')" class="action">{translate key="manager.language.reloadLocalizedDefaultSettings"}</a></td>
48
				<td align="center"><input type="checkbox" name="supportedLocales[]" value="{$localeKey|escape}"{if in_array($localeKey, $supportedLocales)} checked="checked"{/if}/></td>
49
				<td align="center"><input type="checkbox" name="supportedFormLocales[]" value="{$localeKey|escape}"{if in_array($localeKey, $supportedFormLocales)} checked="checked"{/if}/></td>
50
				<td><a href="{url op="reloadLocalizedDefaultSettings" localeToLoad=$localeKey}" onclick="return confirm('{translate|escape:"jsparam" key="manager.language.confirmDefaultSettingsOverwrite"}')" class="action">{translate key="manager.language.reloadLocalizedDefaultSettings"}</a></td>
44
			</tr>
51
			</tr>
45
		{/foreach}
52
		{/foreach}
46
		</table>
53
		</table>
47
	</td>
54
	</td>
48
</tr>
55
</tr>
49
<tr valign="top">
56
<tr valign="top">
50
	<td>&nbsp;</td>
57
	<td colspan="3" class="value"><span class="instruct">{translate key="manager.languages.supportedLocalesInstructions"}</span></td>
51
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.supportedLocalesInstructions"}</span></td>
52
</tr>
58
</tr>
53
</table>
59
</table>
54
60

Return to bug 3865