summaryrefslogtreecommitdiff
path: root/lib/plugins/config
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/config')
-rw-r--r--lib/plugins/config/admin.php78
-rw-r--r--lib/plugins/config/settings/config.class.php120
-rw-r--r--lib/plugins/config/style.css30
3 files changed, 114 insertions, 114 deletions
diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php
index 5f628e687..1859c45fa 100644
--- a/lib/plugins/config/admin.php
+++ b/lib/plugins/config/admin.php
@@ -54,15 +54,15 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
*/
function handle() {
global $ID;
-
+
if (!$this->_restore_session()) return $this->_close_session();
if (!isset($_REQUEST['save']) || ($_REQUEST['save'] != 1)) return $this->_close_session();
-
+
if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
-
+
// don't go any further if the configuration is locked
if ($this->_config->_locked) return $this->_close_session();
-
+
$this->_input = $_REQUEST['config'];
while (list($key) = each($this->_config->setting)) {
@@ -72,101 +72,101 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
}
if ($this->_config->setting[$key]->error()) $this->_error = true;
}
-
+
if ($this->_changed && !$this->_error) {
$this->_config->save_settings($this->getPluginName());
-
+
// save state & force a page reload to get the new settings to take effect
$_SESSION['PLUGIN_CONFIG'] = array('state' => 'updated', 'time' => time());
$this->_close_session();
header("Location: ".wl($ID,array('do'=>'admin','page'=>'config'),true,'&'));
exit();
}
-
+
$this->_close_session();
}
/**
* output appropriate html
*/
- function html() {
+ function html() {
global $lang;
global $ID;
-
+
if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
$this->setupLocale(true);
print $this->locale_xhtml('intro');
-
- ptln('<div id="configmanager">');
-
+
+ ptln('<div id="config__manager">');
+
if ($this->_config->locked)
ptln('<p class="info">'.$this->getLang('locked').'</p>');
- elseif ($this->_error)
+ elseif ($this->_error)
ptln('<p class="error">'.$this->getLang('error').'</p>');
elseif ($this->_changed)
ptln('<p class="ok">'.$this->getLang('updated').'</p>');
-
+
ptln('<form action="'.wl($ID).'" method="post">');
ptln(' <table class="inline">');
-
+
foreach($this->_config->setting as $setting) {
-
+
list($label,$input) = $setting->html($this, $this->_error);
-
- $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : '');
+
+ $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : '');
$error = $setting->error() ? ' class="error"' : '';
-
+
ptln(' <tr'.$class.'>');
ptln(' <td>'.$label.'</td>');
ptln(' <td'.$error.'>'.$input.'</td>');
ptln(' </tr>');
}
-
+
ptln(' </table>');
-
+
ptln('<p>');
ptln(' <input type="hidden" name="do" value="admin" />');
ptln(' <input type="hidden" name="page" value="config" />');
-
+
if (!$this->_config->locked) {
ptln(' <input type="hidden" name="save" value="1" />');
ptln(' <input type="submit" name="submit" value="'.$lang['btn_save'].'" />');
ptln(' <input type="reset" value="'.$lang['btn_reset'].'" />');
}
-
+
ptln('</p>');
-
+
ptln('</form>');
ptln('</div>');
}
-
+
/**
* @return boolean true - proceed with handle, false - don't proceed
*/
function _restore_session() {
-
- // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
- // however they can't be changed without starting the session again
+
+ // dokuwiki closes the session before act_dispatch. $_SESSION variables are all set,
+ // however they can't be changed without starting the session again
if (!headers_sent()) {
session_start();
$this->_session_started = true;
- }
-
+ }
+
if (!isset($_SESSION['PLUGIN_CONFIG'])) return true;
-
+
$session = $_SESSION['PLUGIN_CONFIG'];
unset($_SESSION['PLUGIN_CONFIG']);
-
+
// still valid?
if (time() - $session['time'] > 120) return true;
-
+
switch ($session['state']) {
case 'updated' :
$this->_changed = true;
return false;
}
-
+
return true;
}
@@ -186,12 +186,12 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
function _setup_localised_plugin_prompts() {
global $conf;
-
+
$langfile = '/lang/'.$conf[lang].'/settings.php';
$enlangfile = '/lang/en/settings.php';
-
+
$lang = array();
-
+
if ($dh = opendir(DOKU_PLUGIN)) {
while (false !== ($plugin = readdir($dh))) {
if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue;
@@ -199,7 +199,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){
@include(DOKU_PLUGIN.$plugin.$enlangfile);
- if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
+ if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile);
}
}
closedir($dh);
@@ -209,5 +209,5 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
return true;
}
-
+
}
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 86bb4e9fa..620d9c3b2 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -12,11 +12,11 @@ if (!class_exists('configuration')) {
var $_name = 'conf'; // name of the config variable found in the files (overridden by $config['varname'])
var $_format = 'php'; // format of the config file, supported formats - php (overridden by $config['format'])
var $_heading = ''; // heading string written at top of config file - don't include comment indicators
- var $_loaded = false; // set to true after configuration files are loaded
+ var $_loaded = false; // set to true after configuration files are loaded
var $_metadata = array(); // holds metadata describing the settings
var $setting = array(); // array of setting objects
var $locked = false; // configuration is considered locked if it can't be updated
-
+
// filenames, these will be eval()'d prior to use so maintain any constants in output
var $_default_file = '';
var $_local_file = '';
@@ -42,7 +42,7 @@ if (!class_exists('configuration')) {
if (isset($file['protected'])) $this->_protected_file = $file['protected'];
$this->locked = $this->_is_locked();
-
+
$this->_metadata = array_merge($meta, $this->get_plugin_metadata());
$this->retrieve_settings();
@@ -70,16 +70,16 @@ if (!class_exists('configuration')) {
$param = NULL;
}
- $this->setting[$key] = new $class($key,$param);
- $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
+ $this->setting[$key] = new $class($key,$param);
+ $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
}
-
+
$this->_loaded = true;
- }
+ }
}
-
+
function save_settings($id, $header='', $backup=true) {
-
+
if ($this->locked) return false;
$file = eval('return '.$this->_local_file.';');
@@ -93,23 +93,23 @@ if (!class_exists('configuration')) {
if (!$fh = @fopen($file, 'wb')) {
@rename($file.'.bak', $file); // problem opening, restore the backup
return false;
- }
+ }
if (empty($header)) $header = $this->_heading;
$out = $this->_out_header($id,$header);
-
+
foreach ($this->setting as $setting) {
$out .= $setting->out($this->_name, $this->_format);
}
-
+
$out .= $this->_out_footer();
@fwrite($fh, $out);
fclose($fh);
return true;
}
-
+
/**
* return an array of config settings
*/
@@ -119,7 +119,7 @@ if (!class_exists('configuration')) {
$config = array();
$file = eval('return '.$file.';');
-
+
if ($this->_format == 'php') {
$contents = @php_strip_whitespace($file);
@@ -143,7 +143,7 @@ if (!class_exists('configuration')) {
return $config;
}
-
+
function _out_header($id, $header) {
$out = '';
if ($this->_format == 'php') {
@@ -155,10 +155,10 @@ if (!class_exists('configuration')) {
" * Date: ".date('r')."\n".
" */\n\n";
}
-
+
return $out;
}
-
+
function _out_footer() {
$out = '';
if ($this->_format == 'php') {
@@ -167,7 +167,7 @@ if (!class_exists('configuration')) {
}
$out .= "\n// end auto-generated content\n";
}
-
+
return $out;
}
@@ -196,7 +196,7 @@ if (!class_exists('configuration')) {
if (!is_array($value)) {
$out[$prefix.$key] = $value;
continue;
- }
+ }
$tmp = $this->_flatten($value,$prefix.$key.CM_KEYMARKER);
$out = array_merge($out,$tmp);
@@ -218,7 +218,7 @@ if (!class_exists('configuration')) {
if (is_file(DOKU_PLUGIN.$plugin)) continue;
if (@file_exists(DOKU_PLUGIN.$plugin.$file)){
- @include(DOKU_PLUGIN.$plugin.$file);
+ @include(DOKU_PLUGIN.$plugin.$file);
}
}
closedir($dh);
@@ -243,7 +243,7 @@ if (!class_exists('configuration')) {
}
return $default;
}
-
+
}
}
@@ -300,12 +300,12 @@ if (!class_exists('setting')) {
$this->_local = $input;
return true;
}
-
+
/**
* @return array(string $label_html, string $input_html)
*/
function html(&$plugin, $echo=false) {
-
+
$value = '';
$disable = '';
@@ -321,11 +321,11 @@ if (!class_exists('setting')) {
}
$key = htmlspecialchars($this->_key);
- $value = htmlspecialchars($value);
+ $value = htmlspecialchars($value);
- $label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<input id="config_'.$key.'" name="config['.$key.']" type="text" class="text" value="'.$value.'" '.$disable.'/>';
- return array($label,$input);
+ $label = '<label for="config__'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<input id="config__'.$key.'" name="config['.$key.']" type="text" class="text" value="'.$value.'" '.$disable.'/>';
+ return array($label,$input);
}
/**
@@ -347,19 +347,19 @@ if (!class_exists('setting')) {
return $out;
}
-
- function prompt(&$plugin) {
+
+ function prompt(&$plugin) {
$prompt = $plugin->getLang($this->_key);
if (!$prompt) $prompt = str_replace(array('____','_'),' ',$this->_key);
return htmlspecialchars($prompt);
}
-
+
function is_protected() { return !is_null($this->_protected); }
function is_default() { return !$this->is_protected() && is_null($this->_local); }
function error() { return $this->_error; }
-
- function _out_key() { return str_replace(CM_KEYMARKER,"']['",$this->_key); }
- }
+
+ function _out_key() { return str_replace(CM_KEYMARKER,"']['",$this->_key); }
+ }
}
if (!class_exists('setting_password')) {
@@ -386,9 +386,9 @@ if (!class_exists('setting_password')) {
$key = htmlspecialchars($this->_key);
- $label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
- $input = '<input id="config_'.$key.'" name="config['.$key.']" type="password" class="text" value="" '.$disable.'/>';
- return array($label,$input);
+ $label = '<label for="config__'.$key.'">'.$this->prompt($plugin).'</label>';
+ $input = '<input id="config__'.$key.'" name="config['.$key.']" type="password" class="text" value="" '.$disable.'/>';
+ return array($label,$input);
}
}
}
@@ -402,9 +402,9 @@ if (!class_exists('setting_email')) {
if (!class_exists('setting_numeric')) {
class setting_numeric extends setting {
var $_pattern = '/^[-+\/*0-9 ]*$/';
-
+
function out($var, $fmt='php') {
-
+
if ($this->is_protected()) return '';
if (is_null($this->_local) || ($this->_default == $this->_local)) return '';
@@ -431,25 +431,25 @@ if (!class_exists('setting_onoff')) {
$disable = ' disabled="disabled"';
} else {
$value = is_null($this->_local) ? $this->_default : $this->_local;
- }
+ }
$key = htmlspecialchars($this->_key);
- $checked = ($value) ? ' checked="checked"' : '';
+ $checked = ($value) ? ' checked="checked"' : '';
$label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
$input = '<div class="input"><input id="config_'.$key.'" name="config['.$key.']" type="checkbox" class="checkbox" value="1"'.$checked.$disable.'/></div>';
- return array($label,$input);
+ return array($label,$input);
}
function update($input) {
if ($this->is_protected()) return false;
- $input = ($input) ? 1 : 0;
+ $input = ($input) ? 1 : 0;
$value = is_null($this->_local) ? $this->_default : $this->_local;
if ($value == $input) return false;
$this->_local = $input;
- return true;
+ return true;
}
}
}
@@ -467,7 +467,7 @@ if (!class_exists('setting_mulitchoice')) {
$value = $this->_protected;
$disable = ' disabled="disabled"';
} else {
- $value = is_null($this->_local) ? $this->_default : $this->_local;
+ $value = is_null($this->_local) ? $this->_default : $this->_local;
}
// ensure current value is included
@@ -478,14 +478,14 @@ if (!class_exists('setting_mulitchoice')) {
if (!$this->is_protected() && count($this->_choices) <= 1) {
$disable = ' disabled="disabled"';
$nochoice = $plugin->getLang('nochoice');
- }
+ }
$key = htmlspecialchars($this->_key);
$label = '<label for="config_'.$key.'">'.$this->prompt($plugin).'</label>';
$input = "<div class=\"input\">\n";
- $input .= '<select id="config_'.$key.'" name="config['.$key.']"'.$disable.'>'."\n";
+ $input .= '<select id="config__'.$key.'" name="config['.$key.']"'.$disable.'>'."\n";
foreach ($this->_choices as $choice) {
$selected = ($value == $choice) ? ' selected="selected"' : '';
$option = $plugin->getLang($this->_key.'_o_'.$choice);
@@ -498,7 +498,7 @@ if (!class_exists('setting_mulitchoice')) {
$input .= "</select> $nochoice \n";
$input .= "</div>\n";
- return array($label,$input);
+ return array($label,$input);
}
function update($input) {
@@ -527,26 +527,26 @@ if (!class_exists('setting_dirchoice')) {
// populate $this->_choices with a list of available templates
$list = array();
- if ($dh = @opendir($this->_dir)) {
+ if ($dh = @opendir($this->_dir)) {
while (false !== ($entry = readdir($dh))) {
if ($entry == '.' || $entry == '..') continue;
- $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $entry;
- if (is_dir($this->_dir.$file)) $list[] = $entry;
+ $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $entry;
+ if (is_dir($this->_dir.$file)) $list[] = $entry;
}
closedir($dh);
}
sort($list);
$this->_choices = $list;
-
+
parent::initialize($default,$local,$protected);
}
- }
+ }
}
/**
- * Provide php_strip_whitespace (php5 function) functionality
+ * Provide php_strip_whitespace (php5 function) functionality
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
@@ -567,11 +567,11 @@ if (!function_exists('php_strip_whitespace')) {
function php_strip_whitespace($file) {
if (!@is_readable($file)) return '';
- $in = join('',@file($file));
+ $in = join('',@file($file));
$out = '';
$tokens = token_get_all($in);
-
+
foreach ($tokens as $token) {
if (is_string ($token)) {
$out .= $token;
@@ -580,13 +580,13 @@ if (!function_exists('php_strip_whitespace')) {
switch ($id) {
case T_COMMENT : // fall thru
case T_ML_COMMENT : // fall thru
- case T_DOC_COMMENT : // fall thru
- case T_WHITESPACE :
+ case T_DOC_COMMENT : // fall thru
+ case T_WHITESPACE :
break;
default : $out .= $text; break;
}
}
- }
+ }
return ($out);
}
@@ -614,7 +614,7 @@ if (!function_exists('php_strip_whitespace')) {
if (!@is_readable($file)) return '';
- $contents = join('',@file($file));
+ $contents = join('',@file($file));
$out = '';
$state = 0;
@@ -636,5 +636,5 @@ if (!function_exists('php_strip_whitespace')) {
return $out;
}
- }
+ }
}
diff --git a/lib/plugins/config/style.css b/lib/plugins/config/style.css
index ab8d20060..d10a7c0e4 100644
--- a/lib/plugins/config/style.css
+++ b/lib/plugins/config/style.css
@@ -1,25 +1,25 @@
/* plugin:configmanager */
-#configmanager {margin: 1em;}
-#configmanager p.error {border: 1px solid red; background-color: #c66; color: white; padding: 0.5em; text-align:center}
-#configmanager p.ok {border: 1px solid green; background-color: #6c6; color: black; padding: 0.5em; text-align:center}
-#configmanager p.info {border: 1px solid __dark__; background-color: __medium__; color: black; padding: 0.5em; text-align:center}
-#configmanager form { }
-#configmanager table {margin: 1em 0;}
-#configmanager td input.text {width: 30em; border: 1px solid __medium__;}
-#configmanager td select {border: 1px solid __medium__;}
+#config__manager {margin: 1em;}
+#config__manager p.error {border: 1px solid red; background-color: #c66; color: white; padding: 0.5em; text-align:center}
+#config__manager p.ok {border: 1px solid green; background-color: #6c6; color: black; padding: 0.5em; text-align:center}
+#config__manager p.info {border: 1px solid __dark__; background-color: __medium__; color: black; padding: 0.5em; text-align:center}
+#config__manager form { }
+#config__manager table {margin: 1em 0;}
+#config__manager td input.text {width: 30em; border: 1px solid __medium__;}
+#config__manager td select {border: 1px solid __medium__;}
-#configmanager tr.default .input,
-#configmanager tr.default input,
-#configmanager tr.default select {
+#config__manager tr.default .input,
+#config__manager tr.default input,
+#config__manager tr.default select {
background-color: #ccddff;
}
-#configmanager tr.protected .input,
-#configmanager tr.protected input,
-#configmanager tr.protected select {
+#config__manager tr.protected .input,
+#config__manager tr.protected input,
+#config__manager tr.protected select {
background-color: #ffcccc;
}
-#configmanager td.error {background-color: red;}
+#config__manager td.error {background-color: red;}
/* end plugin:configmanager */