|
|
| 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(); |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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; |
|
|
| 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 |
?> |