30 while (!$result->EOF) {
31 $row = $result->getRowAssoc(
false);
32 $value = $this->
convertFromDB($row[
'setting_value'], $row[
'setting_type']);
33 if ($row[
'locale'] ==
'') $settings[$row[
'setting_name']] = $value;
34 else $settings[$row[
'setting_name']][$row[
'locale']] = $value;
40 if ($cache) $cache->setEntireCache($settings);
52 if ($cache)
return $cache->getContents();
65 $returner = $cache->get($name);
68 if (isset($settings[$name])) $returner = $settings[$name];
69 else $returner =
null;
71 if ($locale !==
null) {
72 if (!isset($returner[$locale]) || !is_array($returner)) {
77 return $returner[$locale];
90 if (!isset($settings[$id])) {
91 $cache->setCache($id,
null);
94 return $settings[$id];
104 $value = preg_replace_callback(
'{{translate key="([^"]+)"}}', array($this,
'_installer_regexp_callback'), $rawInput);
105 foreach ($paramArray as $pKey => $pValue) {
106 $value = str_replace(
'{$' . $pKey .
'}', $pValue, $value);
119 foreach ($node->getChildren() as $element) {
120 $key = $element->getAttribute(
'key');
121 $childArray = $element->getChildByName(
'array');
122 if (isset($childArray)) {
123 $content = $this->
_buildObject($childArray, $paramArray);
129 $value[$key] = $content;
130 }
else $value[] = $content;
143 $tree = $xmlParser->parse($filename);
144 if (!$tree)
return false;
146 foreach ($tree->getChildren() as $setting) {
147 $nameNode = $setting->getChildByName(
'name');
148 $valueNode = $setting->getChildByName(
'value');
150 if (isset($nameNode) && isset($valueNode)) {
151 $type = $setting->getAttribute(
'type');
152 $isLocaleField = $setting->getAttribute(
'locale');
153 $name = $nameNode->getValue();
155 if ($type ==
'object') {
156 $arrayNode = $valueNode->getChildByName(
'array');
178 return __($matches[1]);
189 function updateSetting($id, $name, $value, $type =
null, $isLocalized =
false) {
196 'setting_name' => $name,
197 'setting_value' => $value,
198 'setting_type' => $type,
204 if (is_array($value))
foreach ($value as $locale => $localeValue) {
206 if (empty($localeValue))
continue;
210 VALUES (?, ?, ?, ?, ?)',
212 $id, $name, $this->
convertToDB($localeValue, $type), $type, $locale
219 if ($cache) $cache->setCache($name, $value);
229 if ($cache) $cache->setCache($name,
null);
231 $params = array($id, $name);
233 if ($locale !==
null) {
235 $sql .=
' AND locale = ?';
238 return $this->
update($sql, $params);
247 if ($cache) $cache->flush();
262 if ($cacheName ===
null)
return null;
264 static $settingCache;
265 if (!isset($settingCache)) {
266 $settingCache = array();
268 if (!isset($settingCache[$id])) {
270 $settingCache[$id] = $cacheManager->getCache(
272 array($this,
'_cacheMiss')
275 return $settingCache[$id];