diff --git a/core/config.class.php b/core/config.class.php
index b6d4cc64..9e04374f 100644
--- a/core/config.class.php
+++ b/core/config.class.php
@@ -8,14 +8,17 @@ interface Config {
public function set_int($name, $value);
public function set_string($name, $value);
public function set_bool($name, $value);
+ public function set_array($name, $value);
public function set_default_int($name, $value);
public function set_default_string($name, $value);
public function set_default_bool($name, $value);
+ public function set_default_array($name, $value);
public function get_int($name, $default=null);
public function get_string($name, $default=null);
public function get_bool($name, $default=null);
+ public function get_array($name, $default=array());
}
@@ -38,6 +41,11 @@ abstract class BaseConfig implements Config {
$this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N');
$this->save($name);
}
+ public function set_array($name, $value) {
+ assert(is_array($value));
+ $this->values[$name] = implode(",", $value);
+ $this->save($name);
+ }
public function set_default_int($name, $value) {
if(is_null($this->get($name))) {
@@ -54,6 +62,12 @@ abstract class BaseConfig implements Config {
$this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N');
}
}
+ public function set_default_array($name, $value) {
+ assert(is_array($value));
+ if(is_null($this->get($name))) {
+ $this->values[$name] = implode(",", $value);
+ }
+ }
public function get_int($name, $default=null) {
return (int)($this->get($name, $default));
@@ -64,6 +78,9 @@ abstract class BaseConfig implements Config {
public function get_bool($name, $default=null) {
return ($this->get($name, $default) == 'Y');
}
+ public function get_array($name, $default=array()) {
+ return explode(",", $this->get($name, ""));
+ }
private function get($name, $default=null) {
if(isset($this->values[$name])) {
diff --git a/ext/setup/main.php b/ext/setup/main.php
index dde0275d..cc4c923a 100644
--- a/ext/setup/main.php
+++ b/ext/setup/main.php
@@ -132,6 +132,26 @@ class SetupBlock extends Block {
$this->body .= $html;
}
+
+ public function add_multichoice_option($name, $options, $label=null) {
+ global $config;
+ $current = $config->get_array($name);
+
+ if(!is_null($label)) {
+ $this->body .= "";
+ }
+ $html = "";
+ $this->body .= "\n";
+ $this->body .= "\n"; // setup page auto-layout counts
tags
+
+ $this->body .= $html;
+ }
}
// }}}
@@ -225,6 +245,7 @@ class Setup extends SimpleExtension {
$sb->add_text_option("main_page", "
Main page: ");
$sb->add_text_option("contact_link", "
Contact URL: ");
$sb->add_choice_option("theme", $themes, "
Theme: ");
+ //$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "
Test Array: ");
$sb->add_bool_option("nice_urls", "
Nice URLs: ");
$sb->add_label("(Javascript inactive, can't test!)$nicescript");
$event->panel->add_block($sb);
@@ -241,6 +262,7 @@ class Setup extends SimpleExtension {
case "string": $config->set_string($name, $value); break;
case "int": $config->set_int($name, $value); break;
case "bool": $config->set_bool($name, $value); break;
+ case "array": $config->set_array($name, $value); break;
}
}
}