summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-01-25 11:12:53 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-01-25 11:12:53 +0100
commitb303add4e27e10fbdc4ed64f40ab2046232027bf (patch)
tree0fa9a95149c6a3eef0e90ae30f27c4a18925fc19 /lib
parent33e75ca2f63b10ae1c7c7e9891ae857ce80d1811 (diff)
parentd12150d88f5fe8d5718313ab6c14ab8c907c61ff (diff)
downloadrpg-b303add4e27e10fbdc4ed64f40ab2046232027bf.tar.gz
rpg-b303add4e27e10fbdc4ed64f40ab2046232027bf.tar.bz2
Merge branch 'confmanager' into future
* confmanager: fixed problems with spaced arrays parse arrays from config file
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/config/_test/configuration.test.php2
-rw-r--r--lib/plugins/config/_test/data/config.php2
-rw-r--r--lib/plugins/config/settings/config.class.php24
3 files changed, 23 insertions, 5 deletions
diff --git a/lib/plugins/config/_test/configuration.test.php b/lib/plugins/config/_test/configuration.test.php
index ee03f3849..b808ad505 100644
--- a/lib/plugins/config/_test/configuration.test.php
+++ b/lib/plugins/config/_test/configuration.test.php
@@ -30,4 +30,4 @@ class plugin_config_configuration_test extends DokuWikiTest {
$this->assertEquals(array('foo', 'bar', 'baz'), $conf['arr1']);
}
-} \ No newline at end of file
+}
diff --git a/lib/plugins/config/_test/data/config.php b/lib/plugins/config/_test/data/config.php
index 15d6359ad..83255f937 100644
--- a/lib/plugins/config/_test/data/config.php
+++ b/lib/plugins/config/_test/data/config.php
@@ -10,7 +10,7 @@ $conf['str3'] = "Hello World";
$conf['str4'] = "Hello 'World'";
$conf['str5'] = "Hello \"World\"";
-$conf['arr1'] = array('foo','bar','baz');
+$conf['arr1'] = array('foo','bar', 'baz');
$conf['foo']['bar'] = 'x1';
$conf['foo']['baz'] = 'x2';
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index d4d98ee01..5e472d16b 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -159,14 +159,32 @@ if (!class_exists('configuration')) {
preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER);
for ($i=0; $i<count($matches); $i++) {
+ $value = $matches[$i][2];
+
// correct issues with the incoming data
// FIXME ... for now merge multi-dimensional array indices using ____
$key = preg_replace('/.\]\[./',CM_KEYMARKER,$matches[$i][1]);
- // remove quotes from quoted strings & unescape escaped data
- $value = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$matches[$i][2]);
- $value = strtr($value, array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+
+ // handle arrays
+ if(preg_match('/^array ?\((.*)\)/', $value, $match)){
+ $arr = explode(',', $match[1]);
+
+ // remove quotes from quoted strings & unescape escaped data
+ $len = count($arr);
+ for($j=0; $j<$len; $j++){
+ $arr[$j] = trim($arr[$j]);
+ $arr[$j] = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$arr[$j]);
+ $arr[$j] = strtr($arr[$j], array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ }
+
+ $value = $arr;
+ }else{
+ // remove quotes from quoted strings & unescape escaped data
+ $value = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$value);
+ $value = strtr($value, array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ }
$config[$key] = $value;
}