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

Collapse All | Expand All

(-)classes/conference/Conference.inc.php (+25 lines)
 Lines 240-245    Link Here 
240
	}
240
	}
241
241
242
	/**
242
	/**
243
	 * Return associative array of all locales supported by forms on the site.
244
	 * These locales are used to provide a language toggle on the main site pages.
245
	 * @return array
246
	 */
247
	function &getSupportedFormLocaleNames() {
248
		$supportedLocales =& $this->getData('supportedFormLocales');
249
250
		if (!isset($supportedLocales)) {
251
			$supportedLocales = array();
252
			$localeNames =& Locale::getAllLocales();
253
254
			$locales = $this->getSetting('supportedFormLocales');
255
			if (!isset($locales) || !is_array($locales)) {
256
				$locales = array();
257
			}
258
259
			foreach ($locales as $localeKey) {
260
				$supportedLocales[$localeKey] = $localeNames[$localeKey];
261
			}
262
		}
263
264
		return $supportedLocales;
265
	}
266
267
	/**
243
	 * Get "localized" conference page title (if applicable).
268
	 * Get "localized" conference page title (if applicable).
244
	 * param $home boolean get homepage title
269
	 * param $home boolean get homepage title
245
	 * @return string
270
	 * @return string
(-)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 (($conference =& Request::getConference())) {
58
				$supportedFormLocales = $conference->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 31-37    Link Here 
31
		parent::Form('manager/languageSettings.tpl');
31
		parent::Form('manager/languageSettings.tpl');
32
32
33
		$this->settings = array(
33
		$this->settings = array(
34
			'supportedLocales' => 'object'
34
			'supportedLocales' => 'object',
35
			'supportedFormLocales' => 'object'
35
		);
36
		);
36
37
37
		$site =& Request::getSite();
38
		$site =& Request::getSite();
 Lines 67-74    Link Here 
67
68
68
		$this->setData('primaryLocale', $conference->getPrimaryLocale());
69
		$this->setData('primaryLocale', $conference->getPrimaryLocale());
69
70
70
		if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
71
		foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
71
			$this->setData('supportedLocales', array());
72
			if ($this->getData($name) == null || !is_array($this->getData($name))) {
73
				$this->setData($name, array());
74
			}
72
		}
75
		}
73
	}
76
	}
74
77
 Lines 80-87    Link Here 
80
		$vars[] = 'primaryLocale';
83
		$vars[] = 'primaryLocale';
81
		$this->readUserVars($vars);
84
		$this->readUserVars($vars);
82
85
83
		if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
86
		foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
84
			$this->setData('supportedLocales', array());
87
			if ($this->getData($name) == null || !is_array($this->getData($name))) {
88
				$this->setData($name, array());
89
			}
85
		}
90
		}
86
	}
91
	}
87
92
 Lines 93-111    Link Here 
93
		$settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
98
		$settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
94
99
95
		// Verify additional locales
100
		// Verify additional locales
96
		$supportedLocales = array();
101
		foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
97
		foreach ($this->getData('supportedLocales') as $locale) {
102
			$$name = array();
98
			if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
103
			foreach ($this->getData($name) as $locale) {
99
				array_push($supportedLocales, $locale);
104
				if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
105
					array_push($$name, $locale);
106
				}
100
			}
107
			}
101
		}
108
		}
102
109
103
		$primaryLocale = $this->getData('primaryLocale');
110
		$primaryLocale = $this->getData('primaryLocale');
104
111
105
		if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) {
112
		// Make sure at least the primary locale is chosen as available
106
			array_push($supportedLocales, $primaryLocale);
113
		if ($primaryLocale != null && !empty($primaryLocale)) {
114
			foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
115
				if (!in_array($primaryLocale, $$name)) {
116
					array_push($$name, $primaryLocale);
117
				}
118
			}
107
		}
119
		}
108
		$this->setData('supportedLocales', $supportedLocales);
120
		$this->setData('supportedLocales', $supportedLocales);
121
		$this->setData('supportedFormLocales', $supportedFormLocales);
109
122
110
		foreach ($this->_data as $name => $value) {
123
		foreach ($this->_data as $name => $value) {
111
			if (!in_array($name, array_keys($this->settings))) continue;
124
			if (!in_array($name, array_keys($this->settings))) continue;
 Lines 121-127    Link Here 
121
		$conference->setPrimaryLocale($this->getData('primaryLocale'));
134
		$conference->setPrimaryLocale($this->getData('primaryLocale'));
122
		$conferenceDao->updateConference($conference);
135
		$conferenceDao->updateConference($conference);
123
	}
136
	}
124
125
}
137
}
126
138
127
?>
139
?>
(-)locale/en_US/manager.xml (+2 lines)
 Lines 33-38    Link Here 
33
	<message key="manager.groups.enableBoard.description"><![CDATA[For the <a href="{$aboutOrganizingTeamUrl}">Organizing Team</a> in About the Conference:]]></message>
33
	<message key="manager.groups.enableBoard.description"><![CDATA[For the <a href="{$aboutOrganizingTeamUrl}">Organizing Team</a> in About the Conference:]]></message>
34
	<message key="manager.groups.noneCreated">No organizing team positions have been created.</message>
34
	<message key="manager.groups.noneCreated">No organizing team positions have been created.</message>
35
	<message key="manager.importExport.noPlugins">There are no import/export plugins currently installed.</message>
35
	<message key="manager.importExport.noPlugins">There are no import/export plugins currently installed.</message>
36
 	<message key="manager.language.ui">UI</message>
37
 	<message key="manager.language.forms">Forms</message>
36
	<message key="manager.languages.languageInstructions"><![CDATA[OCS can be made available to users in any of several supported languages. As well, OCS can operate as a partially 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 OCS 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 OCS documentation.]]></message>
38
	<message key="manager.languages.languageInstructions"><![CDATA[OCS can be made available to users in any of several supported languages. As well, OCS can operate as a partially 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 OCS 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 OCS documentation.]]></message>
37
	<message key="manager.languages.noneAvailable">Sorry, no additional languages are available. Contact your site administrator if you wish to use additional languages with this conference.</message>
39
	<message key="manager.languages.noneAvailable">Sorry, no additional languages are available. Contact your site administrator if you wish to use additional languages with this conference.</message>
38
	<message key="manager.languages.primaryLocaleInstructions">This will be the default language for the conference site.</message>
40
	<message key="manager.languages.primaryLocaleInstructions">This will be the default language for the conference site.</message>
(-)templates/manager/languageSettings.tpl (-13 / +24 lines)
 Lines 6-12    Link Here 
6
 *
6
 *
7
 * Form to edit conference language settings.
7
 * Form to edit conference language settings.
8
 *
8
 *
9
 * $Id: languageSettings.tpl,v 1.9 2009/04/08 20:01:39 asmecher Exp $
9
 * $Id: languageSettings.tpl,v 1.26 2009/07/03 00:11:18 asmecher Exp $
10
 *}
10
 *}
11
{strip}
11
{strip}
12
{assign var="pageTitle" value="common.languages"}
12
{assign var="pageTitle" value="common.languages"}
 Lines 22-46    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="2" 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>
34
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.primaryLocaleInstructions"}</span></td>
33
	<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">{foreach from=$availableLocales key=localeKey item=localeName}
37
	<td colspan="2" class="value">
39
		<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><br />
38
		<table class="data" width="100%">
40
	{/foreach}</td>
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
		</tr>
44
		{foreach from=$availableLocales key=localeKey item=localeName}
45
			<tr>
46
				<td>{$localeName|escape}</td>
47
				<td align="center"><input type="checkbox" name="supportedLocales[]" value="{$localeKey|escape}"{if in_array($localeKey, $supportedLocales)} checked="checked"{/if}/></td>
48
				<td align="center"><input type="checkbox" name="supportedFormLocales[]" value="{$localeKey|escape}"{if in_array($localeKey, $supportedFormLocales)} checked="checked"{/if}/></td>
49
			</tr>
50
		{/foreach}
51
		</table>
52
	</td>
41
</tr>
53
</tr>
42
<tr valign="top">
54
<tr valign="top">
43
	<td>&nbsp;</td>
44
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.supportedLocalesInstructions"}</span></td>
55
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.supportedLocalesInstructions"}</span></td>
45
</tr>
56
</tr>
46
</table>
57
</table>

Return to bug 3865