28 if (!isset($settingCache)) {
29 $settingCache = array();
31 if (!isset($settingCache[$contextId])) {
32 $settingCache[$contextId] = array();
34 if (!isset($settingCache[$contextId][$pluginName])) {
36 $settingCache[$contextId][$pluginName] = $cacheManager->getCache(
37 'pluginSettings-' . $contextId, $pluginName,
38 array($this,
'_cacheMiss')
41 return $settingCache[$contextId][$pluginName];
56 $cache = $this->
_getCache($contextId, $pluginName);
57 return $cache->get($name);
70 'SELECT COUNT(*) FROM plugin_settings WHERE plugin_name = ? AND context_id = ? AND setting_name = ?', array($pluginName, (
int) $contextId, $name)
72 $returner = $result->fields[0] ? true :
false;
84 $contextParts = explode(
'-', $cache->getContext());
85 $contextId = array_pop($contextParts);
87 if (!isset($settings[$id])) {
89 $cache->setCache($id,
null);
92 return $settings[$id];
106 'SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ? AND context_id = ?', array($pluginName, (
int) $contextId)
109 $pluginSettings = array();
110 while (!$result->EOF) {
111 $row = $result->getRowAssoc(
false);
112 $pluginSettings[$row[
'setting_name']] = $this->
convertFromDB($row[
'setting_value'], $row[
'setting_type']);
117 $cache = $this->
_getCache($contextId, $pluginName);
118 $cache->setEntireCache($pluginSettings);
120 return $pluginSettings;
132 function updateSetting($contextId, $pluginName, $name, $value, $type =
null) {
136 $cache = $this->
_getCache($contextId, $pluginName);
137 $cache->setCache($name, $value);
144 'context_id' => (
int) $contextId,
145 'plugin_name' => $pluginName,
146 'setting_name' => $name,
147 'setting_value' => $value,
148 'setting_type' => $type,
150 array(
'context_id',
'plugin_name',
'setting_name')
164 $cache = $this->
_getCache($contextId, $pluginName);
165 $cache->setCache($name,
null);
168 'DELETE FROM plugin_settings WHERE plugin_name = ? AND setting_name = ? AND context_id = ?',
169 array($pluginName, $name, (
int) $contextId)
182 $cache = $this->
_getCache($contextId, $pluginName);
186 'DELETE FROM plugin_settings WHERE context_id = ? AND plugin_name = ?',
187 array((
int) $contextId, $pluginName)
197 'DELETE FROM plugin_settings WHERE context_id = ?', (
int) $contextId
208 $value = preg_replace_callback(
'{{translate key="([^"]+)"}}',
'_installer_plugin_regexp_callback', $rawInput);
209 foreach ($paramArray as $pKey => $pValue) {
210 $value = str_replace(
'{$' . $pKey .
'}', $pValue, $value);
223 foreach ($node->getChildren() as $element) {
224 $key = $element->getAttribute(
'key');
225 $childArray = $element->getChildByName(
'array');
226 if (isset($childArray)) {
227 $content = $this->
_buildObject($childArray, $paramArray);
233 $value[$key] = $content;
234 }
else $value[] = $content;
247 $tree = $xmlParser->parse($filename);
249 if (!$tree)
return false;
254 foreach ($tree->getChildren() as $setting) {
255 $nameNode = $setting->getChildByName(
'name');
256 $valueNode = $setting->getChildByName(
'value');
258 if (isset($nameNode) && isset($valueNode)) {
259 $type = $setting->getAttribute(
'type');
260 $name = $nameNode->getValue();
263 if (isset($currentSettings[$name]))
continue;
265 if ($type ==
'object') {
266 $arrayNode = $valueNode->getChildByName(
'array');
273 $this->
updateSetting($contextId, $pluginName, $name, $value, $type);
285 function _installer_plugin_regexp_callback($matches) {
286 return __($matches[1]);