From 130a2d436991cc35bee5893795220b01f457a3e3 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Mon, 6 Oct 2014 17:48:55 +0200
Subject: Support list type for configuration variable
---
modules/baseconfig.inc.php | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
(limited to 'modules')
diff --git a/modules/baseconfig.inc.php b/modules/baseconfig.inc.php
index 1e4093b2..2f62320e 100644
--- a/modules/baseconfig.inc.php
+++ b/modules/baseconfig.inc.php
@@ -75,22 +75,46 @@ class Page_BaseConfig extends Page
}
// List global config option
$settings = array();
- $res = Database::simpleQuery('SELECT cat_setting.catid, setting.setting, setting.defaultvalue, setting.permissions, tbl.value
+ $res = Database::simpleQuery('SELECT cat_setting.catid, setting.setting, setting.defaultvalue, setting.permissions, setting.validator, tbl.value
FROM setting
INNER JOIN cat_setting USING (catid)
LEFT JOIN setting_global AS tbl USING (setting)
- ORDER BY cat_setting.sortval ASC, setting.setting ASC'); // TODO: Add setting groups and sort order
+ ORDER BY cat_setting.sortval ASC, setting.setting ASC');
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$row['description'] = Util::markup(Dictionary::translate('settings/setting', $row['setting']));
if (is_null($row['value'])) $row['value'] = $row['defaultvalue'];
- $row['big'] = false;
+ $row['item'] = $this->makeInput($row['validator'], $row['setting'], $row['value']);
$settings[$row['catid']]['settings'][] = $row;
$settings[$row['catid']]['category_name'] = Dictionary::translate('settings/cat_setting', 'cat_' . $row['catid']);
}
- Render::addTemplate('page-baseconfig', array(
+ Render::addTemplate('baseconfig/_page', array(
'categories' => array_values($settings)
));
}
+
+ /**
+ * Create html snippet for setting, based on given validator
+ * @param type $validator
+ * @return boolean
+ */
+ private function makeInput($validator, $setting, $current)
+ {
+ $parts = explode(':', $validator, 2);
+ if ($parts[0] === 'list') {
+ $items = explode('|', $parts[1]);
+ $ret = '';
+ }
+ // Fallback: single line input
+ return '';
+ }
}
--
cgit v1.2.3-55-g7522