diff options
Diffstat (limited to 'lib/plugins/config')
-rw-r--r-- | lib/plugins/config/admin.php | 488 | ||||
-rw-r--r-- | lib/plugins/config/lang/de-informal/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/lang/de/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/lang/en/lang.php | 6 | ||||
-rw-r--r-- | lib/plugins/config/lang/ko/intro.txt | 8 | ||||
-rw-r--r-- | lib/plugins/config/lang/ko/lang.php | 30 | ||||
-rw-r--r-- | lib/plugins/config/lang/pt-br/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.class.php | 1523 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.metadata.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/settings/extra.class.php | 270 |
10 files changed, 1152 insertions, 1177 deletions
diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php index 29529760c..835d27775 100644 --- a/lib/plugins/config/admin.php +++ b/lib/plugins/config/admin.php @@ -38,168 +38,168 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { * handle user request */ function handle() { - global $ID, $INPUT; + global $ID, $INPUT; - if (!$this->_restore_session()) return $this->_close_session(); - if ($INPUT->int('save') != 1) return $this->_close_session(); - if (!checkSecurityToken()) return $this->_close_session(); + if (!$this->_restore_session()) return $this->_close_session(); + if ($INPUT->int('save') != 1) return $this->_close_session(); + if (!checkSecurityToken()) return $this->_close_session(); - if (is_null($this->_config)) { $this->_config = new configuration($this->_file); } + 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(); + // don't go any further if the configuration is locked + if ($this->_config->_locked) return $this->_close_session(); - $this->_input = $INPUT->arr('config'); + $this->_input = $INPUT->arr('config'); - while (list($key) = each($this->_config->setting)) { - $input = isset($this->_input[$key]) ? $this->_input[$key] : NULL; - if ($this->_config->setting[$key]->update($input)) { - $this->_changed = true; + while (list($key) = each($this->_config->setting)) { + $input = isset($this->_input[$key]) ? $this->_input[$key] : null; + if ($this->_config->setting[$key]->update($input)) { + $this->_changed = true; + } + if ($this->_config->setting[$key]->error()) $this->_error = true; } - if ($this->_config->setting[$key]->error()) $this->_error = true; - } - if ($this->_changed && !$this->_error) { - $this->_config->save_settings($this->getPluginName()); + 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(); - send_redirect(wl($ID,array('do'=>'admin','page'=>'config'),true,'&')); - exit(); - } elseif(!$this->_error) { - $this->_config->touch_settings(); // just touch to refresh cache - } + // 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(); + send_redirect(wl($ID,array('do'=>'admin','page'=>'config'),true,'&')); + exit(); + } elseif(!$this->_error) { + $this->_config->touch_settings(); // just touch to refresh cache + } - $this->_close_session(); + $this->_close_session(); } /** * output appropriate html */ function html() { - $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here. - 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="config__manager">'); - - if ($this->_config->locked) - ptln('<div class="info">'.$this->getLang('locked').'</div>'); - elseif ($this->_error) - ptln('<div class="error">'.$this->getLang('error').'</div>'); - elseif ($this->_changed) - ptln('<div class="success">'.$this->getLang('updated').'</div>'); - - // POST to script() instead of wl($ID) so config manager still works if - // rewrite config is broken. Add $ID as hidden field to remember - // current ID in most cases. - ptln('<form action="'.script().'" method="post">'); - ptln('<div class="no"><input type="hidden" name="id" value="'.$ID.'" /></div>'); - formSecurityToken(); - $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki')); - - $undefined_settings = array(); - $in_fieldset = false; - $first_plugin_fieldset = true; - $first_template_fieldset = true; - foreach($this->_config->setting as $setting) { - if (is_a($setting, 'setting_hidden')) { - // skip hidden (and undefined) settings - if ($allow_debug && is_a($setting, 'setting_undefined')) { - $undefined_settings[] = $setting; - } else { - continue; - } - } else if (is_a($setting, 'setting_fieldset')) { - // config setting group - if ($in_fieldset) { - ptln(' </table>'); - ptln(' </div>'); - ptln(' </fieldset>'); - } else { - $in_fieldset = true; - } - if ($first_plugin_fieldset && substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) { - $this->_print_h1('plugin_settings', $this->getLang('_header_plugin')); - $first_plugin_fieldset = false; - } else if ($first_template_fieldset && substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) { - $this->_print_h1('template_settings', $this->getLang('_header_template')); - $first_template_fieldset = false; - } - ptln(' <fieldset id="'.$setting->_key.'">'); - ptln(' <legend>'.$setting->prompt($this).'</legend>'); - ptln(' <div class="table">'); - ptln(' <table class="inline">'); - } else { - // config settings - list($label,$input) = $setting->html($this, $this->_error); - - $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : ''); - $error = $setting->error() ? ' class="value error"' : ' class="value"'; - $icon = $setting->caution() ? '<img src="'.DOKU_PLUGIN_IMAGES.$setting->caution().'.png" alt="'.$setting->caution().'" title="'.$this->getLang($setting->caution()).'" />' : ''; - - ptln(' <tr'.$class.'>'); - ptln(' <td class="label">'); - ptln(' <span class="outkey">'.$setting->_out_key(true, true).'</span>'); - ptln(' '.$icon.$label); - ptln(' </td>'); - ptln(' <td'.$error.'>'.$input.'</td>'); - ptln(' </tr>'); + $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here. + 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="config__manager">'); + + if ($this->_config->locked) + ptln('<div class="info">'.$this->getLang('locked').'</div>'); + elseif ($this->_error) + ptln('<div class="error">'.$this->getLang('error').'</div>'); + elseif ($this->_changed) + ptln('<div class="success">'.$this->getLang('updated').'</div>'); + + // POST to script() instead of wl($ID) so config manager still works if + // rewrite config is broken. Add $ID as hidden field to remember + // current ID in most cases. + ptln('<form action="'.script().'" method="post">'); + ptln('<div class="no"><input type="hidden" name="id" value="'.$ID.'" /></div>'); + formSecurityToken(); + $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki')); + + $undefined_settings = array(); + $in_fieldset = false; + $first_plugin_fieldset = true; + $first_template_fieldset = true; + foreach($this->_config->setting as $setting) { + if (is_a($setting, 'setting_hidden')) { + // skip hidden (and undefined) settings + if ($allow_debug && is_a($setting, 'setting_undefined')) { + $undefined_settings[] = $setting; + } else { + continue; + } + } else if (is_a($setting, 'setting_fieldset')) { + // config setting group + if ($in_fieldset) { + ptln(' </table>'); + ptln(' </div>'); + ptln(' </fieldset>'); + } else { + $in_fieldset = true; + } + if ($first_plugin_fieldset && substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) { + $this->_print_h1('plugin_settings', $this->getLang('_header_plugin')); + $first_plugin_fieldset = false; + } else if ($first_template_fieldset && substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) { + $this->_print_h1('template_settings', $this->getLang('_header_template')); + $first_template_fieldset = false; + } + ptln(' <fieldset id="'.$setting->_key.'">'); + ptln(' <legend>'.$setting->prompt($this).'</legend>'); + ptln(' <div class="table">'); + ptln(' <table class="inline">'); + } else { + // config settings + list($label,$input) = $setting->html($this, $this->_error); + + $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : ''); + $error = $setting->error() ? ' class="value error"' : ' class="value"'; + $icon = $setting->caution() ? '<img src="'.DOKU_PLUGIN_IMAGES.$setting->caution().'.png" alt="'.$setting->caution().'" title="'.$this->getLang($setting->caution()).'" />' : ''; + + ptln(' <tr'.$class.'>'); + ptln(' <td class="label">'); + ptln(' <span class="outkey">'.$setting->_out_key(true, true).'</span>'); + ptln(' '.$icon.$label); + ptln(' </td>'); + ptln(' <td'.$error.'>'.$input.'</td>'); + ptln(' </tr>'); + } } - } - ptln(' </table>'); - ptln(' </div>'); - if ($in_fieldset) { - ptln(' </fieldset>'); - } + ptln(' </table>'); + ptln(' </div>'); + if ($in_fieldset) { + ptln(' </fieldset>'); + } - // show undefined settings list - if ($allow_debug && !empty($undefined_settings)) { - function _setting_natural_comparison($a, $b) { return strnatcmp($a->_key, $b->_key); } - usort($undefined_settings, '_setting_natural_comparison'); - $this->_print_h1('undefined_settings', $this->getLang('_header_undefined')); - ptln('<fieldset>'); - ptln('<div class="table">'); - ptln('<table class="inline">'); - $undefined_setting_match = array(); - foreach($undefined_settings as $setting) { - if (preg_match('/^(?:plugin|tpl)'.CM_KEYMARKER.'.*?'.CM_KEYMARKER.'(.*)$/', $setting->_key, $undefined_setting_match)) { - $undefined_setting_key = $undefined_setting_match[1]; - } else { - $undefined_setting_key = $setting->_key; - } - ptln(' <tr>'); - ptln(' <td class="label"><span title="$meta[\''.$undefined_setting_key.'\']">$'.$this->_config->_name.'[\''.$setting->_out_key().'\']</span></td>'); - ptln(' <td>'.$this->getLang('_msg_'.get_class($setting)).'</td>'); - ptln(' </tr>'); + // show undefined settings list + if ($allow_debug && !empty($undefined_settings)) { + function _setting_natural_comparison($a, $b) { return strnatcmp($a->_key, $b->_key); } + usort($undefined_settings, '_setting_natural_comparison'); + $this->_print_h1('undefined_settings', $this->getLang('_header_undefined')); + ptln('<fieldset>'); + ptln('<div class="table">'); + ptln('<table class="inline">'); + $undefined_setting_match = array(); + foreach($undefined_settings as $setting) { + if (preg_match('/^(?:plugin|tpl)'.CM_KEYMARKER.'.*?'.CM_KEYMARKER.'(.*)$/', $setting->_key, $undefined_setting_match)) { + $undefined_setting_key = $undefined_setting_match[1]; + } else { + $undefined_setting_key = $setting->_key; + } + ptln(' <tr>'); + ptln(' <td class="label"><span title="$meta[\''.$undefined_setting_key.'\']">$'.$this->_config->_name.'[\''.$setting->_out_key().'\']</span></td>'); + ptln(' <td>'.$this->getLang('_msg_'.get_class($setting)).'</td>'); + ptln(' </tr>'); + } + ptln('</table>'); + ptln('</div>'); + ptln('</fieldset>'); } - ptln('</table>'); - ptln('</div>'); - ptln('</fieldset>'); - } - // finish up form - ptln('<p>'); - ptln(' <input type="hidden" name="do" value="admin" />'); - ptln(' <input type="hidden" name="page" value="config" />'); + // finish up form + 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" class="button" value="'.$lang['btn_save'].'" accesskey="s" />'); - ptln(' <input type="reset" class="button" value="'.$lang['btn_reset'].'" />'); - } + if (!$this->_config->locked) { + ptln(' <input type="hidden" name="save" value="1" />'); + ptln(' <input type="submit" name="submit" class="button" value="'.$lang['btn_save'].'" accesskey="s" />'); + ptln(' <input type="reset" class="button" value="'.$lang['btn_reset'].'" />'); + } - ptln('</p>'); + ptln('</p>'); - ptln('</form>'); - ptln('</div>'); + ptln('</form>'); + ptln('</div>'); } /** @@ -207,28 +207,28 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { */ 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 - if (!headers_sent()) { - session_start(); - $this->_session_started = true; - } + // 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; + if (!isset($_SESSION['PLUGIN_CONFIG'])) return true; - $session = $_SESSION['PLUGIN_CONFIG']; - unset($_SESSION['PLUGIN_CONFIG']); + $session = $_SESSION['PLUGIN_CONFIG']; + unset($_SESSION['PLUGIN_CONFIG']); - // still valid? - if (time() - $session['time'] > 120) return true; + // still valid? + if (time() - $session['time'] > 120) return true; - switch ($session['state']) { - case 'updated' : - $this->_changed = true; - return false; - } + switch ($session['state']) { + case 'updated' : + $this->_changed = true; + return false; + } - return true; + return true; } function _close_session() { @@ -237,62 +237,62 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { function setupLocale($prompts=false) { - parent::setupLocale(); - if (!$prompts || $this->_localised_prompts) return; + parent::setupLocale(); + if (!$prompts || $this->_localised_prompts) return; - $this->_setup_localised_plugin_prompts(); - $this->_localised_prompts = true; + $this->_setup_localised_plugin_prompts(); + $this->_localised_prompts = true; } function _setup_localised_plugin_prompts() { - global $conf; - - $langfile = '/lang/'.$conf['lang'].'/settings.php'; - $enlangfile = '/lang/en/settings.php'; + global $conf; + + $langfile = '/lang/'.$conf['lang'].'/settings.php'; + $enlangfile = '/lang/en/settings.php'; + + if ($dh = opendir(DOKU_PLUGIN)) { + while (false !== ($plugin = readdir($dh))) { + if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue; + if (is_file(DOKU_PLUGIN.$plugin)) continue; + + if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){ + $lang = array(); + @include(DOKU_PLUGIN.$plugin.$enlangfile); + if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile); + foreach ($lang as $key => $value){ + $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; + } + } + + // fill in the plugin name if missing (should exist for plugins with settings) + if (!isset($this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'])) { + $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = + ucwords(str_replace('_', ' ', $plugin)); + } + } + closedir($dh); + } - if ($dh = opendir(DOKU_PLUGIN)) { - while (false !== ($plugin = readdir($dh))) { - if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue; - if (is_file(DOKU_PLUGIN.$plugin)) continue; + // the same for the active template + $tpl = $conf['template']; - if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){ + if (@file_exists(tpl_incdir().$enlangfile)){ $lang = array(); - @include(DOKU_PLUGIN.$plugin.$enlangfile); - if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile); + @include(tpl_incdir().$enlangfile); + if ($conf['lang'] != 'en') @include(tpl_incdir().$langfile); foreach ($lang as $key => $value){ - $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; + $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; } - } - - // fill in the plugin name if missing (should exist for plugins with settings) - if (!isset($this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'])) { - $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = - ucwords(str_replace('_', ' ', $plugin)); - } } - closedir($dh); - } - - // the same for the active template - $tpl = $conf['template']; - if (@file_exists(tpl_incdir().$enlangfile)){ - $lang = array(); - @include(tpl_incdir().$enlangfile); - if ($conf['lang'] != 'en') @include(tpl_incdir().$langfile); - foreach ($lang as $key => $value){ - $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; + // fill in the template name if missing (should exist for templates with settings) + if (!isset($this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'])) { + $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = + ucwords(str_replace('_', ' ', $tpl)); } - } - - // fill in the template name if missing (should exist for templates with settings) - if (!isset($this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'])) { - $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = - ucwords(str_replace('_', ' ', $tpl)); - } - return true; + return true; } /** @@ -301,59 +301,59 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { * @author Ben Coburn <btcoburn@silicodon.net> */ function getTOC() { - if (is_null($this->_config)) { $this->_config = new configuration($this->_file); } - $this->setupLocale(true); - - $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here. - - // gather toc data - $has_undefined = false; - $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null); - foreach($this->_config->setting as $setting) { - if (is_a($setting, 'setting_fieldset')) { - if (substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) { - $toc['plugin'][] = $setting; - } else if (substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) { - $toc['template'] = $setting; - } else { - $toc['conf'][] = $setting; - } - } else if (!$has_undefined && is_a($setting, 'setting_undefined')) { - $has_undefined = true; + if (is_null($this->_config)) { $this->_config = new configuration($this->_file); } + $this->setupLocale(true); + + $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here. + + // gather toc data + $has_undefined = false; + $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null); + foreach($this->_config->setting as $setting) { + if (is_a($setting, 'setting_fieldset')) { + if (substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) { + $toc['plugin'][] = $setting; + } else if (substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) { + $toc['template'] = $setting; + } else { + $toc['conf'][] = $setting; + } + } else if (!$has_undefined && is_a($setting, 'setting_undefined')) { + $has_undefined = true; + } } - } - // build toc - $t = array(); + // build toc + $t = array(); - $t[] = html_mktocitem('configuration_manager', $this->getLang('_configuration_manager'), 1); - $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1); - foreach($toc['conf'] as $setting) { - $name = $setting->prompt($this); - $t[] = html_mktocitem($setting->_key, $name, 2); - } - if (!empty($toc['plugin'])) { - $t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1); - } - foreach($toc['plugin'] as $setting) { - $name = $setting->prompt($this); - $t[] = html_mktocitem($setting->_key, $name, 2); - } - if (isset($toc['template'])) { - $t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1); - $setting = $toc['template']; - $name = $setting->prompt($this); - $t[] = html_mktocitem($setting->_key, $name, 2); - } - if ($has_undefined && $allow_debug) { - $t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1); - } + $t[] = html_mktocitem('configuration_manager', $this->getLang('_configuration_manager'), 1); + $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1); + foreach($toc['conf'] as $setting) { + $name = $setting->prompt($this); + $t[] = html_mktocitem($setting->_key, $name, 2); + } + if (!empty($toc['plugin'])) { + $t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1); + } + foreach($toc['plugin'] as $setting) { + $name = $setting->prompt($this); + $t[] = html_mktocitem($setting->_key, $name, 2); + } + if (isset($toc['template'])) { + $t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1); + $setting = $toc['template']; + $name = $setting->prompt($this); + $t[] = html_mktocitem($setting->_key, $name, 2); + } + if ($has_undefined && $allow_debug) { + $t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1); + } - return $t; + return $t; } function _print_h1($id, $text) { - ptln('<h1 id="'.$id.'">'.$text.'</h1>'); + ptln('<h1 id="'.$id.'">'.$text.'</h1>'); } diff --git a/lib/plugins/config/lang/de-informal/lang.php b/lib/plugins/config/lang/de-informal/lang.php index 598c1a72d..7a17ace4a 100644 --- a/lib/plugins/config/lang/de-informal/lang.php +++ b/lib/plugins/config/lang/de-informal/lang.php @@ -108,7 +108,6 @@ $lang['target____media'] = 'Zielfenstername für Medienlinks'; $lang['target____windows'] = 'Zielfenstername für Windows-Freigaben-Links'; $lang['mediarevisions'] = 'Media-Revisionen (ältere Versionen) aktivieren?'; $lang['refcheck'] = 'Auf Verwendung beim Löschen von Media-Dateien testen'; -$lang['refshow'] = 'Wie viele Verwendungsorte der Media-Datei zeigen'; $lang['gdlib'] = 'GD Lib Version'; $lang['im_convert'] = 'Pfad zu ImageMagicks-Konvertierwerkzeug'; $lang['jpg_quality'] = 'JPEG Kompressionsqualität (0-100)'; diff --git a/lib/plugins/config/lang/de/lang.php b/lib/plugins/config/lang/de/lang.php index 07eb4a750..e55081a91 100644 --- a/lib/plugins/config/lang/de/lang.php +++ b/lib/plugins/config/lang/de/lang.php @@ -76,7 +76,6 @@ $lang['camelcase'] = 'CamelCase-Verlinkungen verwenden'; $lang['deaccent'] = 'Seitennamen bereinigen'; $lang['useheading'] = 'Erste Überschrift als Seitennamen verwenden'; $lang['refcheck'] = 'Auf Verwendung beim Löschen von Media-Dateien testen'; -$lang['refshow'] = 'Wie viele Verwendungsorte der Media-Datei zeigen'; $lang['allowdebug'] = 'Debug-Ausgaben erlauben <b>Abschalten wenn nicht benötigt!</b>'; $lang['mediarevisions'] = 'Media-Revisionen (ältere Versionen) aktivieren?'; $lang['usewordblock'] = 'Spam-Blocking benutzen'; diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php index 67d3ce51f..cdef85a85 100644 --- a/lib/plugins/config/lang/en/lang.php +++ b/lib/plugins/config/lang/en/lang.php @@ -63,7 +63,7 @@ $lang['baseurl'] = 'Server URL (eg. <code>http://www.yourserver.com</code>). $lang['cookiedir'] = 'Cookie path. Leave blank for using baseurl.'; $lang['dmode'] = 'Directory creation mode'; $lang['fmode'] = 'File creation mode'; -$lang['allowdebug'] = 'Allow debug <b>disable if not needed!</b>'; +$lang['allowdebug'] = 'Allow debug. <b>Disable if not needed!</b>'; /* Display Settings */ $lang['recent'] = 'Number of entries per page in the recent changes'; @@ -83,7 +83,7 @@ $lang['camelcase'] = 'Use CamelCase for links'; $lang['deaccent'] = 'How to clean pagenames'; $lang['useheading'] = 'Use first heading for pagenames'; $lang['sneaky_index'] = 'By default, DokuWiki will show all namespaces in the sitemap. Enabling this option will hide those where the user doesn\'t have read permissions. This might result in hiding of accessable subnamespaces which may make the index unusable with certain ACL setups.'; -$lang['hidepages'] = 'Hide pages matching this regular expressions from search, the sitemap and other automatic indexes'; +$lang['hidepages'] = 'Hide pages matching this regular expression from search, the sitemap and other automatic indexes'; /* Authentication Settings */ $lang['useacl'] = 'Use access control lists'; @@ -181,7 +181,7 @@ $lang['proxy____port'] = 'Proxy port'; $lang['proxy____user'] = 'Proxy user name'; $lang['proxy____pass'] = 'Proxy password'; $lang['proxy____ssl'] = 'Use SSL to connect to proxy'; -$lang['proxy____except'] = 'Regular expression to match URLs for which the proxy should be skipped for.'; +$lang['proxy____except'] = 'Regular expression to match URLs for which the proxy should be skipped.'; /* Safemode Hack */ $lang['safemodehack'] = 'Enable safemode hack'; diff --git a/lib/plugins/config/lang/ko/intro.txt b/lib/plugins/config/lang/ko/intro.txt index c8b146930..d0b85606c 100644 --- a/lib/plugins/config/lang/ko/intro.txt +++ b/lib/plugins/config/lang/ko/intro.txt @@ -1,7 +1,9 @@ ====== 환경 설정 관리자 ====== -DokuWiki 설치할 때 설정을 바꾸기 위해 사용하는 페이지입니다. 각 설정에 대한 자세한 도움말이 필요하다면 [[doku>ko:config|설정]] 문서를 참고하세요. 플러그인에 대한 자세한 정보가 필요하다면 [[doku>ko:plugin:config|플러그인 설정]] 문서를 참고하세요. +도쿠위키를 설치할 때 설정을 바꾸려면 이 페이지를 사용하세요. 개별 설정에 대한 도움말은 [[doku>ko:config]]를 참고하세요. 이 플러그인에 대한 자세한 내용은 [[doku>ko:plugin:config]]를 참고하세요. + +밝은 빨간색 배경으로 보이는 설정은 이 플러그인에서 바꿀 수 없도록 보호되어 있습니다. 파란색 배경으로 보이는 설정은 기본값이며 하얀색 배경으로 보이는 설정은 특수한 설치를 위해 로컬로 설정되어 있습니다. 파란색과 하얀색 배경으로 된 설정은 바꿀 수 있습니다. + +이 페이지를 떠나기 전에 **저장** 버튼을 누르지 않으면 바뀜이 사라지는 것에 주의하세요. -빨간 배경색으로 보이는 설정은 이 플러그인에서 바꾸지 못하도록 되어있습니다. 파란 배경색으로 보이는 설정은 기본 설정값을 가지고 있습니다. 하얀 배경색으로 보이는 설정은 특별한 설치를 위해 설정되어 있습니다. 파란색과 하얀색 배경으로 된 설정은 바꿀 수 있습니다. -이 페이지를 떠나기 전에 **저장** 버튼을 누르지 않으면 바뀐 값은 적용되지 않습니다.
\ No newline at end of file diff --git a/lib/plugins/config/lang/ko/lang.php b/lib/plugins/config/lang/ko/lang.php index 1aab4731a..ac52090e3 100644 --- a/lib/plugins/config/lang/ko/lang.php +++ b/lib/plugins/config/lang/ko/lang.php @@ -21,7 +21,7 @@ $lang['danger'] = '위험: 이 옵션을 잘못 바꾸면 환경 $lang['warning'] = '경고: 이 옵션을 잘못 바꾸면 잘못 동작할 수 있습니다.'; $lang['security'] = '보안 경고: 이 옵션은 보안에 위험이 있을 수 있습니다.'; $lang['_configuration_manager'] = '환경 설정 관리자'; -$lang['_header_dokuwiki'] = 'DokuWiki 설정'; +$lang['_header_dokuwiki'] = '도쿠위키 설정'; $lang['_header_plugin'] = '플러그인 설정'; $lang['_header_template'] = '템플릿 설정'; $lang['_header_undefined'] = '정의되지 않은 설정'; @@ -45,12 +45,12 @@ $lang['lang'] = '인터페이스 언어'; $lang['template'] = '템플릿 (위키 디자인)'; $lang['tagline'] = '태그 라인 (템플릿이 지원할 때에 한함)'; $lang['sidebar'] = '사이드바 문서 이름 (템플릿이 지원할 때에 한함), 비워두면 사이드바를 비활성화'; -$lang['license'] = '콘텐츠에 어떤 라이선스를 적용하겠습니까?'; -$lang['savedir'] = '데이터 저장 디렉토리'; +$lang['license'] = '내용에 어떤 라이선스를 적용하겠습니까?'; +$lang['savedir'] = '데이터 저장 디렉터리'; $lang['basedir'] = '서버 경로 (예를 들어 <code>/dokuwiki/</code>). 자동 감지를 하려면 비우세요.'; $lang['baseurl'] = '서버 URL (예를 들어 <code>http://www.yourserver.com</code>). 자동 감지를 하려면 비우세요.'; $lang['cookiedir'] = '쿠키 위치. 비워두면 기본 URL 위치로 지정됩니다.'; -$lang['dmode'] = '디렉토리 만들기 모드'; +$lang['dmode'] = '디렉터리 만들기 모드'; $lang['fmode'] = '파일 만들기 모드'; $lang['allowdebug'] = '디버그 허용 <b>필요하지 않으면 비활성화하세요!</b>'; $lang['recent'] = '최근 바뀐 문서당 항목 수'; @@ -69,7 +69,7 @@ $lang['maxseclevel'] = '문단 최대 편집 단계'; $lang['camelcase'] = '링크에 CamelCase 사용'; $lang['deaccent'] = '문서 이름을 지우는 방법'; $lang['useheading'] = '문서 이름으로 첫 문단 제목 사용'; -$lang['sneaky_index'] = '기본적으로 DokuWiki는 색인 목록에 모든 이름공간을 보여줍니다. +$lang['sneaky_index'] = '기본적으로 도쿠위키는 색인 목록에 모든 이름공간을 보여줍니다. 이 옵션을 설정하면 사용자가 읽기 권한을 가지고 있지 않은 이름공간은 보여주지 않습니다. 접근 가능한 하위 이름공간을 보이지 않게 설정하면 자동으로 설정됩니다. 특정 ACL 설정은 색인 사용이 불가능하게 할 수도 있습니다.'; $lang['hidepages'] = '사이트맵과 기타 자동 색인과 같은 찾기에서 정규 표현식과 일치하는 문서 숨기기'; $lang['useacl'] = '접근 제어 목록 (ACL) 사용'; @@ -81,14 +81,14 @@ $lang['superuser'] = '슈퍼 유저 - ACL 설정과 상관없이 모 $lang['manager'] = '관리자 - 관리 기능을 사용할 수 있는 그룹이나 사용자 또는 사용자1,@그룹1,사용자2 쉼표로 구분한 목록'; $lang['profileconfirm'] = '개인 정보를 바꿀 때 비밀번호 다시 확인'; $lang['rememberme'] = '항상 로그인 정보 저장 허용 (기억하기)'; -$lang['disableactions'] = 'DokuWiki 활동 비활성화'; +$lang['disableactions'] = '도쿠위키 활동 비활성화'; $lang['disableactions_check'] = '검사'; $lang['disableactions_subscription'] = '구독 신청/구독 취소'; $lang['disableactions_wikicode'] = '원본 보기/원본 내보내기'; $lang['disableactions_other'] = '다른 활동 (쉼표로 구분)'; $lang['auth_security_timeout'] = '인증 보안 초과 시간 (초)'; $lang['securecookie'] = 'HTTPS로 보내진 쿠키는 HTTPS에만 적용 할까요? 위키의 로그인 페이지만 SSL로 암호화하고 위키 문서는 그렇지 않은 경우 비활성화 합니다.'; -$lang['remote'] = '원격 API를 활성화 합니다. 이 항목을 허용하면 XML-RPC 및 기타 메카니즘을 통해 다른 어플리케이션으로 접근 가능합니다.'; +$lang['remote'] = '원격 API를 활성화 합니다. 이 항목을 허용하면 XML-RPC 및 기타 메커니즘을 통해 다른 어플리케이션으로 접근 가능합니다.'; $lang['remoteuser'] = '이 항목에 입력된 쉼표로 나눠진 그룹이나 사용자에게 원격 API 접근을 제한합니다. 빈칸으로 두면 모두에게 허용합니다.'; $lang['usewordblock'] = '금지 단어를 사용해 스팸 막기'; $lang['relnofollow'] = '바깥 링크에 rel="nofollow" 사용'; @@ -117,7 +117,7 @@ $lang['notify'] = '항상 이 이메일 주소로 바뀜 알림 $lang['registernotify'] = '항상 새 사용자한테 이 이메일 주소로 정보를 보냄'; $lang['mailfrom'] = '자동으로 보내지는 메일 발신자'; $lang['mailprefix'] = '자동으로 보내지는 메일의 제목 말머리 내용. 비웠을 경우 위키 제목 사용'; -$lang['htmlmail'] = '용량은 조금 더 크지만 보기 좋은 HTML 태그가 포함된 메일을 보냅니다. 텍스트만의 메일을 보내고자하면 비활성화하세요.'; +$lang['htmlmail'] = '용량은 조금 더 크지만 보기 좋은 HTML 태그가 포함된 메일을 보냅니다. 텍스트만의 메일을 보내려면 비활성화하세요.'; $lang['sitemap'] = '구글 사이트맵 생성 날짜 빈도. 0일 경우 비활성화합니다'; $lang['rss_type'] = 'XML 피드 타입'; $lang['rss_linkto'] = 'XML 피드 링크 정보'; @@ -125,7 +125,7 @@ $lang['rss_content'] = 'XML 피드 항목에 표시되는 내용은 $lang['rss_update'] = 'XML 피드 업데이트 주기 (초)'; $lang['rss_show_summary'] = 'XML 피드 제목에서 요약 보여주기'; $lang['rss_media'] = '어떤 규격으로 XML 피드를 받아보시겠습니까?'; -$lang['updatecheck'] = '업데이트와 보안 문제를 검사할까요? 이 기능을 사용하려면 DokuWiki를 update.dokuwiki.org에 연결해야 합니다.'; +$lang['updatecheck'] = '업데이트와 보안 문제를 검사할까요? 이 기능을 사용하려면 도쿠위키를 update.dokuwiki.org에 연결해야 합니다.'; $lang['userewrite'] = '멋진 URL 사용'; $lang['useslash'] = 'URL에서 이름 구분자로 슬래시 문자 사용'; $lang['sepchar'] = '문서 이름 단어 구분자'; @@ -136,13 +136,13 @@ $lang['compression'] = '첨부 파일 압축 방법 선택'; $lang['gzip_output'] = 'xhml 내용 gzip 압축 사용'; $lang['compress'] = '최적화된 CSS, 자바스크립트 출력'; $lang['cssdatauri'] = '그림이 렌더링될 최대 용량 크기를 CSS에 규정해야 HTTP 요청 헤더 오버헤드 크기를 감소시킬 수 있습니다. 이 기술은 IE 7 이하에서는 작동하지 않습니다! <code>400</code>에서 <code>600</code> 정도면 좋은 효율을 가져옵니다. <code>0</code>로 지정할 경우 비활성화 됩니다.'; -$lang['send404'] = '존재하지 않는 페이지에 대해 "HTTP 404/Page Not Found" 응답'; +$lang['send404'] = '존재하지 않는 페이지에 대해 "HTTP 404/페이지를 찾을 수 없습니다" 응답'; $lang['broken_iua'] = '설치된 시스템에서 ignore_user_abort 기능에 문제가 있습니까? 문제가 있다면 색인이 정상적으로 동작하지 않습니다. 이 기능이 IIS+PHP/CGI에서 문제가 있는 것으로 알려졌습니다. 자세한 정보는 <a href="http://bugs.dokuwiki.org/?do=details&task_id=852">버그 852</a>를 참고하시기 바랍니다.'; $lang['xsendfile'] = '웹 서버가 정적 파일을 제공하도록 X-Sendfile 헤더를 사용하겠습니까? 웹 서버가 이 기능을 지원해야 합니다.'; $lang['renderer_xhtml'] = '주 (xhtml) 위키 출력 처리기'; -$lang['renderer__core'] = '%s (DokuWiki 내부)'; +$lang['renderer__core'] = '%s (도쿠위키 내부)'; $lang['renderer__plugin'] = '%s (플러그인)'; -$lang['dnslookups'] = '이 옵션을 활성화하면 DokuWiki가 문서를 편집하는 사용자의 호스트 네임과 원격 IP 주소를 확인합니다. 서버가 느리거나, DNS를 운영하지 않거나 이 기능을 원치 않으면 비활성화하세요'; +$lang['dnslookups'] = '이 옵션을 활성화하면 도쿠위키가 문서를 편집하는 사용자의 호스트 네임과 원격 IP 주소를 확인합니다. 서버가 느리거나, DNS를 운영하지 않거나 이 기능을 원치 않으면 비활성화하세요'; $lang['proxy____host'] = '프록시 서버 이름'; $lang['proxy____port'] = '프록시 서버 포트'; $lang['proxy____user'] = '프록시 사용자 이름'; @@ -154,14 +154,14 @@ $lang['ftp____host'] = 'safemode hack의 FTP 서버'; $lang['ftp____port'] = 'safemode hack의 FTP 포트'; $lang['ftp____user'] = 'safemode hack의 FTP 사용자 이름'; $lang['ftp____pass'] = 'safemode hack의 FTP 비밀번호'; -$lang['ftp____root'] = 'safemode hack의 FTP 루트 디렉토리'; +$lang['ftp____root'] = 'safemode hack의 FTP 루트 디렉터리'; $lang['license_o_'] = '선택하지 않음'; $lang['typography_o_0'] = '사용 안함'; $lang['typography_o_1'] = '이중 인용부호("")만 지원'; $lang['typography_o_2'] = '모든 가능한 인용 부호 (동작 안될 수도 있음)'; $lang['userewrite_o_0'] = '사용 안함'; $lang['userewrite_o_1'] = '.htaccess'; -$lang['userewrite_o_2'] = 'DokuWiki 내부 기능'; +$lang['userewrite_o_2'] = '도쿠위키 내부 기능'; $lang['deaccent_o_0'] = '끄기'; $lang['deaccent_o_1'] = '악센트 제거'; $lang['deaccent_o_2'] = '라틴문자화'; @@ -190,7 +190,7 @@ $lang['xsendfile_o_2'] = '표준 X-Sendfile 헤더'; $lang['xsendfile_o_3'] = '비공개 Nginx X-Accel-Redirect 헤더'; $lang['showuseras_o_loginname'] = '로그인 이름'; $lang['showuseras_o_username'] = '사용자의 전체 이름'; -$lang['showuseras_o_email'] = '사용자의 이메일 주소 (메일 주소 보호 설정에 따라 안보일 수 있음)'; +$lang['showuseras_o_email'] = '사용자의 이메일 주소 (메일 주소 설정에 따라 안보일 수 있음)'; $lang['showuseras_o_email_link'] = 'mailto: link로 표현될 사용자 이메일 주소'; $lang['useheading_o_0'] = '아니오'; $lang['useheading_o_navigation'] = '둘러보기에만'; diff --git a/lib/plugins/config/lang/pt-br/lang.php b/lib/plugins/config/lang/pt-br/lang.php index ee1447b4e..795ee81c0 100644 --- a/lib/plugins/config/lang/pt-br/lang.php +++ b/lib/plugins/config/lang/pt-br/lang.php @@ -114,7 +114,6 @@ $lang['target____media'] = 'Parâmetro "target" para links de mídia'; $lang['target____windows'] = 'Parâmetro "target" para links do Windows'; $lang['mediarevisions'] = 'Habilitar revisões de mídias?'; $lang['refcheck'] = 'Verificação de referência da mídia'; -$lang['refshow'] = 'Número de referências de mídia a exibir'; $lang['gdlib'] = 'Versão da biblioteca "GD Lib"'; $lang['im_convert'] = 'Caminho para a ferramenta de conversão ImageMagick'; $lang['jpg_quality'] = 'Qualidade de compressão do JPG (0-100)'; diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 6d582ad30..a5a11cda1 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -1,9 +1,9 @@ <?php /** - * Configuration Class and generic setting classes + * Configuration Class and generic setting classes * - * @author Chris Smith <chris@jalakai.co.uk> - * @author Ben Coburn <btcoburn@silicodon.net> + * @author Chris Smith <chris@jalakai.co.uk> + * @author Ben Coburn <btcoburn@silicodon.net> */ @@ -11,500 +11,498 @@ if(!defined('CM_KEYMARKER')) define('CM_KEYMARKER','____'); if (!class_exists('configuration')) { - class 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 $_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 - var $show_disabled_plugins = false; - - // configuration filenames - var $_default_files = array(); - var $_local_files = array(); // updated configuration is written to the first file - var $_protected_files = array(); - - var $_plugin_list = null; - - /** - * constructor - */ - function configuration($datafile) { - global $conf, $config_cascade; - - if (!@file_exists($datafile)) { - msg('No configuration metadata found at - '.htmlspecialchars($datafile),-1); - return; - } - $meta = array(); - include($datafile); - - if (isset($config['varname'])) $this->_name = $config['varname']; - if (isset($config['format'])) $this->_format = $config['format']; - if (isset($config['heading'])) $this->_heading = $config['heading']; - - $this->_default_files = $config_cascade['main']['default']; - $this->_local_files = $config_cascade['main']['local']; - $this->_protected_files = $config_cascade['main']['protected']; - - $this->locked = $this->_is_locked(); - $this->_metadata = array_merge($meta, $this->get_plugintpl_metadata($conf['template'])); - $this->retrieve_settings(); - } - - function retrieve_settings() { - global $conf; - $no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class'); + class configuration { - if (!$this->_loaded) { - $default = array_merge($this->get_plugintpl_default($conf['template']), $this->_read_config_group($this->_default_files)); - $local = $this->_read_config_group($this->_local_files); - $protected = $this->_read_config_group($this->_protected_files); + 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 $_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 + var $show_disabled_plugins = false; - $keys = array_merge(array_keys($this->_metadata),array_keys($default), array_keys($local), array_keys($protected)); - $keys = array_unique($keys); + // configuration filenames + var $_default_files = array(); + var $_local_files = array(); // updated configuration is written to the first file + var $_protected_files = array(); - $param = null; - foreach ($keys as $key) { - if (isset($this->_metadata[$key])) { - $class = $this->_metadata[$key][0]; + var $_plugin_list = null; - if($class && class_exists('setting_'.$class)){ - $class = 'setting_'.$class; - } else { - if($class != '') { - $this->setting[] = new setting_no_class($key,$param); - } - $class = 'setting'; - } + /** + * constructor + */ + function configuration($datafile) { + global $conf, $config_cascade; - $param = $this->_metadata[$key]; - array_shift($param); - } else { - $class = 'setting_undefined'; - $param = null; + if (!@file_exists($datafile)) { + msg('No configuration metadata found at - '.htmlspecialchars($datafile),-1); + return; } + $meta = array(); + include($datafile); - if (!in_array($class, $no_default_check) && !isset($default[$key])) { - $this->setting[] = new setting_no_default($key,$param); - } + if (isset($config['varname'])) $this->_name = $config['varname']; + if (isset($config['format'])) $this->_format = $config['format']; + if (isset($config['heading'])) $this->_heading = $config['heading']; - $this->setting[$key] = new $class($key,$param); - $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]); - } + $this->_default_files = $config_cascade['main']['default']; + $this->_local_files = $config_cascade['main']['local']; + $this->_protected_files = $config_cascade['main']['protected']; - $this->_loaded = true; + $this->locked = $this->_is_locked(); + $this->_metadata = array_merge($meta, $this->get_plugintpl_metadata($conf['template'])); + $this->retrieve_settings(); } - } - - function save_settings($id, $header='', $backup=true) { - global $conf; - - if ($this->locked) return false; - // write back to the last file in the local config cascade - $file = end($this->_local_files); - - // backup current file (remove any existing backup) - if (@file_exists($file) && $backup) { - if (@file_exists($file.'.bak')) @unlink($file.'.bak'); - if (!io_rename($file, $file.'.bak')) return false; - } + function retrieve_settings() { + global $conf; + $no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class'); + + if (!$this->_loaded) { + $default = array_merge($this->get_plugintpl_default($conf['template']), $this->_read_config_group($this->_default_files)); + $local = $this->_read_config_group($this->_local_files); + $protected = $this->_read_config_group($this->_protected_files); + + $keys = array_merge(array_keys($this->_metadata),array_keys($default), array_keys($local), array_keys($protected)); + $keys = array_unique($keys); + + $param = null; + foreach ($keys as $key) { + if (isset($this->_metadata[$key])) { + $class = $this->_metadata[$key][0]; + + if($class && class_exists('setting_'.$class)){ + $class = 'setting_'.$class; + } else { + if($class != '') { + $this->setting[] = new setting_no_class($key,$param); + } + $class = 'setting'; + } + + $param = $this->_metadata[$key]; + array_shift($param); + } else { + $class = 'setting_undefined'; + $param = null; + } + + if (!in_array($class, $no_default_check) && !isset($default[$key])) { + $this->setting[] = new setting_no_default($key,$param); + } + + $this->setting[$key] = new $class($key,$param); + $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]); + } - if (!$fh = @fopen($file, 'wb')) { - io_rename($file.'.bak', $file); // problem opening, restore the backup - return false; - } + $this->_loaded = true; + } + } - if (empty($header)) $header = $this->_heading; + function save_settings($id, $header='', $backup=true) { + global $conf; - $out = $this->_out_header($id,$header); + if ($this->locked) return false; - foreach ($this->setting as $setting) { - $out .= $setting->out($this->_name, $this->_format); - } + // write back to the last file in the local config cascade + $file = end($this->_local_files); - $out .= $this->_out_footer(); + // backup current file (remove any existing backup) + if (@file_exists($file) && $backup) { + if (@file_exists($file.'.bak')) @unlink($file.'.bak'); + if (!io_rename($file, $file.'.bak')) return false; + } - @fwrite($fh, $out); - fclose($fh); - if($conf['fperm']) chmod($file, $conf['fperm']); - return true; - } + if (!$fh = @fopen($file, 'wb')) { + io_rename($file.'.bak', $file); // problem opening, restore the backup + return false; + } - /** - * Update last modified time stamp of the config file - */ - function touch_settings(){ - if ($this->locked) return false; - $file = end($this->_local_files); - return @touch($file); - } + if (empty($header)) $header = $this->_heading; - function _read_config_group($files) { - $config = array(); - foreach ($files as $file) { - $config = array_merge($config, $this->_read_config($file)); - } + $out = $this->_out_header($id,$header); - return $config; - } + foreach ($this->setting as $setting) { + $out .= $setting->out($this->_name, $this->_format); + } - /** - * return an array of config settings - */ - function _read_config($file) { + $out .= $this->_out_footer(); - if (!$file) return array(); + @fwrite($fh, $out); + fclose($fh); + if($conf['fperm']) chmod($file, $conf['fperm']); + return true; + } - $config = array(); + /** + * Update last modified time stamp of the config file + */ + function touch_settings(){ + if ($this->locked) return false; + $file = end($this->_local_files); + return @touch($file); + } - if ($this->_format == 'php') { + function _read_config_group($files) { + $config = array(); + foreach ($files as $file) { + $config = array_merge($config, $this->_read_config($file)); + } - if(@file_exists($file)){ - $contents = @php_strip_whitespace($file); - }else{ - $contents = ''; + return $config; } - $pattern = '/\$'.$this->_name.'\[[\'"]([^=]+)[\'"]\] ?= ?(.*?);(?=[^;]*(?:\$'.$this->_name.'|$))/s'; - $matches=array(); - preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER); - - for ($i=0; $i<count($matches); $i++) { - $value = $matches[$i][2]; + /** + * return an array of config settings + */ + function _read_config($file) { - // correct issues with the incoming data - // FIXME ... for now merge multi-dimensional array indices using ____ - $key = preg_replace('/.\]\[./',CM_KEYMARKER,$matches[$i][1]); + if (!$file) return array(); + $config = array(); - // handle arrays - if(preg_match('/^array ?\((.*)\)/', $value, $match)){ - $arr = explode(',', $match[1]); + if ($this->_format == 'php') { - // 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('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"')); + if(@file_exists($file)){ + $contents = @php_strip_whitespace($file); + }else{ + $contents = ''; + } + $pattern = '/\$'.$this->_name.'\[[\'"]([^=]+)[\'"]\] ?= ?(.*?);(?=[^;]*(?:\$'.$this->_name.'|$))/s'; + $matches=array(); + 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]); + + // 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; + } } - $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; + return $config; } - } - return $config; - } + function _out_header($id, $header) { + $out = ''; + if ($this->_format == 'php') { + $out .= '<'.'?php'."\n". + "/*\n". + " * ".$header."\n". + " * Auto-generated by ".$id." plugin\n". + " * Run for user: ".$_SERVER['REMOTE_USER']."\n". + " * Date: ".date('r')."\n". + " */\n\n"; + } - function _out_header($id, $header) { - $out = ''; - if ($this->_format == 'php') { - $out .= '<'.'?php'."\n". - "/*\n". - " * ".$header."\n". - " * Auto-generated by ".$id." plugin\n". - " * Run for user: ".$_SERVER['REMOTE_USER']."\n". - " * Date: ".date('r')."\n". - " */\n\n"; - } - - return $out; - } + return $out; + } - function _out_footer() { - $out = ''; - if ($this->_format == 'php') { - $out .= "\n// end auto-generated content\n"; - } + function _out_footer() { + $out = ''; + if ($this->_format == 'php') { + $out .= "\n// end auto-generated content\n"; + } - return $out; - } + return $out; + } - // configuration is considered locked if there is no local settings filename - // or the directory its in is not writable or the file exists and is not writable - function _is_locked() { - if (!$this->_local_files) return true; + // configuration is considered locked if there is no local settings filename + // or the directory its in is not writable or the file exists and is not writable + function _is_locked() { + if (!$this->_local_files) return true; - $local = $this->_local_files[0]; + $local = $this->_local_files[0]; - if (!is_writable(dirname($local))) return true; - if (@file_exists($local) && !is_writable($local)) return true; + if (!is_writable(dirname($local))) return true; + if (@file_exists($local) && !is_writable($local)) return true; - return false; - } + return false; + } - /** - * not used ... conf's contents are an array! - * reduce any multidimensional settings to one dimension using CM_KEYMARKER - */ - function _flatten($conf,$prefix='') { + /** + * not used ... conf's contents are an array! + * reduce any multidimensional settings to one dimension using CM_KEYMARKER + */ + function _flatten($conf,$prefix='') { - $out = array(); + $out = array(); - foreach($conf as $key => $value) { - if (!is_array($value)) { - $out[$prefix.$key] = $value; - continue; - } + foreach($conf as $key => $value) { + if (!is_array($value)) { + $out[$prefix.$key] = $value; + continue; + } - $tmp = $this->_flatten($value,$prefix.$key.CM_KEYMARKER); - $out = array_merge($out,$tmp); + $tmp = $this->_flatten($value,$prefix.$key.CM_KEYMARKER); + $out = array_merge($out,$tmp); + } + + return $out; } - return $out; - } + function get_plugin_list() { + if (is_null($this->_plugin_list)) { + $list = plugin_list('',$this->show_disabled_plugins); - function get_plugin_list() { - if (is_null($this->_plugin_list)) { - $list = plugin_list('',$this->show_disabled_plugins); + // remove this plugin from the list + $idx = array_search('config',$list); + unset($list[$idx]); - // remove this plugin from the list - $idx = array_search('config',$list); - unset($list[$idx]); + trigger_event('PLUGIN_CONFIG_PLUGINLIST',$list); + $this->_plugin_list = $list; + } - trigger_event('PLUGIN_CONFIG_PLUGINLIST',$list); - $this->_plugin_list = $list; - } + return $this->_plugin_list; + } - return $this->_plugin_list; - } + /** + * load metadata for plugin and template settings + */ + function get_plugintpl_metadata($tpl){ + $file = '/conf/metadata.php'; + $class = '/conf/settings.class.php'; + $metadata = array(); + + foreach ($this->get_plugin_list() as $plugin) { + $plugin_dir = plugin_directory($plugin); + if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){ + $meta = array(); + @include(DOKU_PLUGIN.$plugin_dir.$file); + @include(DOKU_PLUGIN.$plugin_dir.$class); + if (!empty($meta)) { + $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = array('fieldset'); + } + foreach ($meta as $key => $value){ + if ($value[0]=='fieldset') { continue; } //plugins only get one fieldset + $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; + } + } + } - /** - * load metadata for plugin and template settings - */ - function get_plugintpl_metadata($tpl){ - $file = '/conf/metadata.php'; - $class = '/conf/settings.class.php'; - $metadata = array(); - - foreach ($this->get_plugin_list() as $plugin) { - $plugin_dir = plugin_directory($plugin); - if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){ - $meta = array(); - @include(DOKU_PLUGIN.$plugin_dir.$file); - @include(DOKU_PLUGIN.$plugin_dir.$class); - if (!empty($meta)) { - $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = array('fieldset'); - } - foreach ($meta as $key => $value){ - if ($value[0]=='fieldset') { continue; } //plugins only get one fieldset - $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; - } - } - } - - // the same for the active template - if (@file_exists(tpl_incdir().$file)){ - $meta = array(); - @include(tpl_incdir().$file); - @include(tpl_incdir().$class); - if (!empty($meta)) { - $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = array('fieldset'); - } - foreach ($meta as $key => $value){ - if ($value[0]=='fieldset') { continue; } //template only gets one fieldset - $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; + // the same for the active template + if (@file_exists(tpl_incdir().$file)){ + $meta = array(); + @include(tpl_incdir().$file); + @include(tpl_incdir().$class); + if (!empty($meta)) { + $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = array('fieldset'); + } + foreach ($meta as $key => $value){ + if ($value[0]=='fieldset') { continue; } //template only gets one fieldset + $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; + } + } + + return $metadata; } - } - return $metadata; - } + /** + * load default settings for plugins and templates + */ + function get_plugintpl_default($tpl){ + $file = '/conf/default.php'; + $default = array(); + + foreach ($this->get_plugin_list() as $plugin) { + $plugin_dir = plugin_directory($plugin); + if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){ + $conf = array(); + @include(DOKU_PLUGIN.$plugin_dir.$file); + foreach ($conf as $key => $value){ + $default['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; + } + } + } - /** - * load default settings for plugins and templates - */ - function get_plugintpl_default($tpl){ - $file = '/conf/default.php'; - $default = array(); - - foreach ($this->get_plugin_list() as $plugin) { - $plugin_dir = plugin_directory($plugin); - if (@file_exists(DOKU_PLUGIN.$plugin_dir.$file)){ - $conf = array(); - @include(DOKU_PLUGIN.$plugin_dir.$file); - foreach ($conf as $key => $value){ - $default['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; - } - } - } - - // the same for the active template - if (@file_exists(tpl_incdir().$file)){ - $conf = array(); - @include(tpl_incdir().$file); - foreach ($conf as $key => $value){ - $default['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; + // the same for the active template + if (@file_exists(tpl_incdir().$file)){ + $conf = array(); + @include(tpl_incdir().$file); + foreach ($conf as $key => $value){ + $default['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; + } + } + + return $default; } - } - return $default; } - - } } if (!class_exists('setting')) { - class setting { + class setting { - var $_key = ''; - var $_default = null; - var $_local = null; - var $_protected = null; + var $_key = ''; + var $_default = null; + var $_local = null; + var $_protected = null; - var $_pattern = ''; - var $_error = false; // only used by those classes which error check - var $_input = null; // only used by those classes which error check - var $_caution = null; // used by any setting to provide an alert along with the setting - // valid alerts, 'warning', 'danger', 'security' - // images matching the alerts are in the plugin's images directory + var $_pattern = ''; + var $_error = false; // only used by those classes which error check + var $_input = null; // only used by those classes which error check + var $_caution = null; // used by any setting to provide an alert along with the setting + // valid alerts, 'warning', 'danger', 'security' + // images matching the alerts are in the plugin's images directory - static protected $_validCautions = array('warning','danger','security'); + static protected $_validCautions = array('warning','danger','security'); - function setting($key, $params=null) { - $this->_key = $key; + function setting($key, $params=null) { + $this->_key = $key; - if (is_array($params)) { - foreach($params as $property => $value) { - $this->$property = $value; - } + if (is_array($params)) { + foreach($params as $property => $value) { + $this->$property = $value; + } + } } - } - - /** - * receives current values for the setting $key - */ - function initialize($default, $local, $protected) { - if (isset($default)) $this->_default = $default; - if (isset($local)) $this->_local = $local; - if (isset($protected)) $this->_protected = $protected; - } - /** - * update changed setting with user provided value $input - * - if changed value fails error check, save it to $this->_input (to allow echoing later) - * - if changed value passes error check, set $this->_local to the new value - * - * @param mixed $input the new value - * @return boolean true if changed, false otherwise (incl. on error) - */ - function update($input) { - if (is_null($input)) return false; - if ($this->is_protected()) return false; - - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; - - if ($this->_pattern && !preg_match($this->_pattern,$input)) { - $this->_error = true; - $this->_input = $input; - return false; + /** + * receives current values for the setting $key + */ + function initialize($default, $local, $protected) { + if (isset($default)) $this->_default = $default; + if (isset($local)) $this->_local = $local; + if (isset($protected)) $this->_protected = $protected; } - $this->_local = $input; - return true; - } + /** + * update changed setting with user provided value $input + * - if changed value fails error check, save it to $this->_input (to allow echoing later) + * - if changed value passes error check, set $this->_local to the new value + * + * @param mixed $input the new value + * @return boolean true if changed, false otherwise (incl. on error) + */ + function update($input) { + if (is_null($input)) return false; + if ($this->is_protected()) return false; - /** - * @return array(string $label_html, string $input_html) - */ - function html(&$plugin, $echo=false) { - $value = ''; - $disable = ''; - - if ($this->is_protected()) { - $value = $this->_protected; - $disable = 'disabled="disabled"'; - } else { - if ($echo && $this->_error) { - $value = $this->_input; - } else { $value = is_null($this->_local) ? $this->_default : $this->_local; - } - } + if ($value == $input) return false; - $key = htmlspecialchars($this->_key); - $value = formText($value); + if ($this->_pattern && !preg_match($this->_pattern,$input)) { + $this->_error = true; + $this->_input = $input; + return false; + } - $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; - $input = '<textarea rows="3" cols="40" id="config___'.$key.'" name="config['.$key.']" class="edit" '.$disable.'>'.$value.'</textarea>'; - return array($label,$input); - } + $this->_local = $input; + return true; + } - /** - * generate string to save setting value to file according to $fmt - */ - function out($var, $fmt='php') { + /** + * @return array(string $label_html, string $input_html) + */ + function html(&$plugin, $echo=false) { + $value = ''; + $disable = ''; - if ($this->is_protected()) return ''; - if (is_null($this->_local) || ($this->_default == $this->_local)) return ''; + if ($this->is_protected()) { + $value = $this->_protected; + $disable = 'disabled="disabled"'; + } else { + if ($echo && $this->_error) { + $value = $this->_input; + } else { + $value = is_null($this->_local) ? $this->_default : $this->_local; + } + } - $out = ''; + $key = htmlspecialchars($this->_key); + $value = formText($value); - if ($fmt=='php') { - $tr = array("\\" => '\\\\', "'" => '\\\''); + $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; + $input = '<textarea rows="3" cols="40" id="config___'.$key.'" name="config['.$key.']" class="edit" '.$disable.'>'.$value.'</textarea>'; + return array($label,$input); + } - $out = '$'.$var."['".$this->_out_key()."'] = '".strtr( cleanText($this->_local), $tr)."';\n"; - } + /** + * generate string to save setting value to file according to $fmt + */ + function out($var, $fmt='php') { - return $out; - } + if ($this->is_protected()) return ''; + if (is_null($this->_local) || ($this->_default == $this->_local)) return ''; - function prompt(&$plugin) { - $prompt = $plugin->getLang($this->_key); - if (!$prompt) $prompt = htmlspecialchars(str_replace(array('____','_'),' ',$this->_key)); - return $prompt; - } + $out = ''; - function is_protected() { return !is_null($this->_protected); } - function is_default() { return !$this->is_protected() && is_null($this->_local); } - function error() { return $this->_error; } + if ($fmt=='php') { + $tr = array("\\" => '\\\\', "'" => '\\\''); - function caution() { - if (!empty($this->_caution)) { - if (!in_array($this->_caution, setting::$_validCautions)) { - trigger_error('Invalid caution string ('.$this->_caution.') in metadata for setting "'.$this->_key.'"', E_USER_WARNING); - return false; + $out = '$'.$var."['".$this->_out_key()."'] = '".strtr( cleanText($this->_local), $tr)."';\n"; } - return $this->_caution; + + return $out; } - // compatibility with previous cautionList - // TODO: check if any plugins use; remove - if (!empty($this->_cautionList[$this->_key])) { - $this->_caution = $this->_cautionList[$this->_key]; - unset($this->_cautionList); - return $this->caution(); + function prompt(&$plugin) { + $prompt = $plugin->getLang($this->_key); + if (!$prompt) $prompt = htmlspecialchars(str_replace(array('____','_'),' ',$this->_key)); + return $prompt; } - return false; - } - function _out_key($pretty=false,$url=false) { - if($pretty){ - $out = str_replace(CM_KEYMARKER,"»",$this->_key); - if ($url && !strstr($out,'»')) {//provide no urls for plugins, etc. - if ($out == 'start') //one exception - return '<a href="http://www.dokuwiki.org/config:startpage">'.$out.'</a>'; - else - return '<a href="http://www.dokuwiki.org/config:'.$out.'">'.$out.'</a>'; + 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 caution() { + if (!empty($this->_caution)) { + if (!in_array($this->_caution, setting::$_validCautions)) { + trigger_error('Invalid caution string ('.$this->_caution.') in metadata for setting "'.$this->_key.'"', E_USER_WARNING); + return false; + } + return $this->_caution; + } + // compatibility with previous cautionList + // TODO: check if any plugins use; remove + if (!empty($this->_cautionList[$this->_key])) { + $this->_caution = $this->_cautionList[$this->_key]; + unset($this->_cautionList); + + return $this->caution(); + } + return false; + } + + function _out_key($pretty=false,$url=false) { + if($pretty){ + $out = str_replace(CM_KEYMARKER,"»",$this->_key); + if ($url && !strstr($out,'»')) {//provide no urls for plugins, etc. + if ($out == 'start') //one exception + return '<a href="http://www.dokuwiki.org/config:startpage">'.$out.'</a>'; + else + return '<a href="http://www.dokuwiki.org/config:'.$out.'">'.$out.'</a>'; + } + return $out; + }else{ + return str_replace(CM_KEYMARKER,"']['",$this->_key); } - return $out; - }else{ - return str_replace(CM_KEYMARKER,"']['",$this->_key); } } - } } @@ -612,201 +610,178 @@ if (!class_exists('setting_array')) { } if (!class_exists('setting_string')) { - class setting_string extends setting { - function html(&$plugin, $echo=false) { - $value = ''; - $disable = ''; - - if ($this->is_protected()) { - $value = $this->_protected; - $disable = 'disabled="disabled"'; - } else { - if ($echo && $this->_error) { - $value = $this->_input; - } else { - $value = is_null($this->_local) ? $this->_default : $this->_local; - } - } + class setting_string extends setting { + function html(&$plugin, $echo=false) { + $value = ''; + $disable = ''; - $key = htmlspecialchars($this->_key); - $value = htmlspecialchars($value); + if ($this->is_protected()) { + $value = $this->_protected; + $disable = 'disabled="disabled"'; + } else { + if ($echo && $this->_error) { + $value = $this->_input; + } else { + $value = is_null($this->_local) ? $this->_default : $this->_local; + } + } - $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; - $input = '<input id="config___'.$key.'" name="config['.$key.']" type="text" class="edit" value="'.$value.'" '.$disable.'/>'; - return array($label,$input); + $key = htmlspecialchars($this->_key); + $value = htmlspecialchars($value); + + $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; + $input = '<input id="config___'.$key.'" name="config['.$key.']" type="text" class="edit" value="'.$value.'" '.$disable.'/>'; + return array($label,$input); + } } - } } if (!class_exists('setting_password')) { - class setting_password extends setting_string { + class setting_password extends setting_string { - var $_code = 'plain'; // mechanism to be used to obscure passwords + var $_code = 'plain'; // mechanism to be used to obscure passwords - function update($input) { - if ($this->is_protected()) return false; - if (!$input) return false; + function update($input) { + if ($this->is_protected()) return false; + if (!$input) return false; - if ($this->_pattern && !preg_match($this->_pattern,$input)) { - $this->_error = true; - $this->_input = $input; - return false; - } + if ($this->_pattern && !preg_match($this->_pattern,$input)) { + $this->_error = true; + $this->_input = $input; + return false; + } - $this->_local = conf_encodeString($input,$this->_code); - return true; - } + $this->_local = conf_encodeString($input,$this->_code); + return true; + } - function html(&$plugin, $echo=false) { + function html(&$plugin, $echo=false) { - $value = ''; - $disable = $this->is_protected() ? 'disabled="disabled"' : ''; + $value = ''; + $disable = $this->is_protected() ? 'disabled="disabled"' : ''; - $key = htmlspecialchars($this->_key); + $key = htmlspecialchars($this->_key); - $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; - $input = '<input id="config___'.$key.'" name="config['.$key.']" autocomplete="off" type="password" class="edit" value="" '.$disable.' />'; - return array($label,$input); + $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; + $input = '<input id="config___'.$key.'" name="config['.$key.']" autocomplete="off" type="password" class="edit" value="" '.$disable.' />'; + return array($label,$input); + } } - } } if (!class_exists('setting_email')) { - class setting_email extends setting_string { - var $_multiple = false; - var $_placeholders = false; - - /** - * update setting with user provided value $input - * if value fails error check, save it - * - * @return boolean true if changed, false otherwise (incl. on error) - */ - function update($input) { - if (is_null($input)) return false; - if ($this->is_protected()) return false; - - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; - if($input === ''){ - $this->_local = $input; - return true; - } - $mail = $input; + class setting_email extends setting_string { + var $_multiple = false; + var $_placeholders = false; - if($this->_placeholders){ - // replace variables with pseudo values - $mail = str_replace('@USER@','joe',$mail); - $mail = str_replace('@NAME@','Joe Schmoe',$mail); - $mail = str_replace('@MAIL@','joe@example.com',$mail); - } + /** + * update setting with user provided value $input + * if value fails error check, save it + * + * @return boolean true if changed, false otherwise (incl. on error) + */ + function update($input) { + if (is_null($input)) return false; + if ($this->is_protected()) return false; - // multiple mail addresses? - if ($this->_multiple) { - $mails = array_filter(array_map('trim', explode(',', $mail))); - } else { - $mails = array($mail); - } + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; + if($input === ''){ + $this->_local = $input; + return true; + } + $mail = $input; - // check them all - foreach ($mails as $mail) { - // only check the address part - if(preg_match('#(.*?)<(.*?)>#', $mail, $matches)){ - $addr = $matches[2]; - }else{ - $addr = $mail; + if($this->_placeholders){ + // replace variables with pseudo values + $mail = str_replace('@USER@','joe',$mail); + $mail = str_replace('@NAME@','Joe Schmoe',$mail); + $mail = str_replace('@MAIL@','joe@example.com',$mail); } - if (!mail_isvalid($addr)) { - $this->_error = true; - $this->_input = $input; - return false; + // multiple mail addresses? + if ($this->_multiple) { + $mails = array_filter(array_map('trim', explode(',', $mail))); + } else { + $mails = array($mail); } - } - $this->_local = $input; - return true; - } - function html(&$plugin, $echo=false) { - $value = ''; - $disable = ''; - - if ($this->is_protected()) { - $value = $this->_protected; - $disable = 'disabled="disabled"'; - } else { - if ($echo && $this->_error) { - $value = $this->_input; - } else { - $value = is_null($this->_local) ? $this->_default : $this->_local; - } - } + // check them all + foreach ($mails as $mail) { + // only check the address part + if(preg_match('#(.*?)<(.*?)>#', $mail, $matches)){ + $addr = $matches[2]; + }else{ + $addr = $mail; + } - $multiple = $this->_multiple ? 'multiple="multiple"' : ''; - $key = htmlspecialchars($this->_key); - $value = htmlspecialchars($value); + if (!mail_isvalid($addr)) { + $this->_error = true; + $this->_input = $input; + return false; + } + } - $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; - $input = '<input id="config___'.$key.'" name="config['.$key.']" type="email" class="edit" value="'.$value.'" '.$multiple.' '.$disable.'/>'; - return array($label,$input); + $this->_local = $input; + return true; + } } - } } /** * @deprecated 2013-02-16 */ if (!class_exists('setting_richemail')) { - class setting_richemail extends setting_email { - function update($input) { - $this->_placeholders = true; - return parent::update($input); - } - } + class setting_richemail extends setting_email { + function update($input) { + $this->_placeholders = true; + return parent::update($input); + } + } } if (!class_exists('setting_numeric')) { - class setting_numeric extends setting_string { - // This allows for many PHP syntax errors... - // var $_pattern = '/^[-+\/*0-9 ]*$/'; - // much more restrictive, but should eliminate syntax errors. - var $_pattern = '/^[-+]? *[0-9]+ *(?:[-+*] *[0-9]+ *)*$/'; - var $_min = null; - var $_max = null; - - function update($input) { - $local = $this->_local; - $valid = parent::update($input); - if ($valid && !(is_null($this->_min) && is_null($this->_max))) { - $numeric_local = (int) eval('return '.$this->_local.';'); - if ((!is_null($this->_min) && $numeric_local < $this->_min) || - (!is_null($this->_max) && $numeric_local > $this->_max)) { - $this->_error = true; - $this->_input = $input; - $this->_local = $local; - $valid = false; + class setting_numeric extends setting_string { + // This allows for many PHP syntax errors... + // var $_pattern = '/^[-+\/*0-9 ]*$/'; + // much more restrictive, but should eliminate syntax errors. + var $_pattern = '/^[-+]? *[0-9]+ *(?:[-+*] *[0-9]+ *)*$/'; + var $_min = null; + var $_max = null; + + function update($input) { + $local = $this->_local; + $valid = parent::update($input); + if ($valid && !(is_null($this->_min) && is_null($this->_max))) { + $numeric_local = (int) eval('return '.$this->_local.';'); + if ((!is_null($this->_min) && $numeric_local < $this->_min) || + (!is_null($this->_max) && $numeric_local > $this->_max)) { + $this->_error = true; + $this->_input = $input; + $this->_local = $local; + $valid = false; + } } + return $valid; } - return $valid; - } - function out($var, $fmt='php') { + function out($var, $fmt='php') { - if ($this->is_protected()) return ''; - if (is_null($this->_local) || ($this->_default == $this->_local)) return ''; + if ($this->is_protected()) return ''; + if (is_null($this->_local) || ($this->_default == $this->_local)) return ''; - $out = ''; + $out = ''; - if ($fmt=='php') { - $local = $this->_local === '' ? "''" : $this->_local; - $out .= '$'.$var."['".$this->_out_key()."'] = ".$local.";\n"; - } + if ($fmt=='php') { + $local = $this->_local === '' ? "''" : $this->_local; + $out .= '$'.$var."['".$this->_out_key()."'] = ".$local.";\n"; + } - return $out; + return $out; + } } - } } if (!class_exists('setting_numericopt')) { @@ -817,320 +792,320 @@ if (!class_exists('setting_numericopt')) { } if (!class_exists('setting_onoff')) { - class setting_onoff extends setting_numeric { + class setting_onoff extends setting_numeric { - function html(&$plugin) { - $value = ''; - $disable = ''; + function html(&$plugin, $echo = false) { + $value = ''; + $disable = ''; - if ($this->is_protected()) { - $value = $this->_protected; - $disable = ' disabled="disabled"'; - } else { - $value = is_null($this->_local) ? $this->_default : $this->_local; - } + if ($this->is_protected()) { + $value = $this->_protected; + $disable = ' disabled="disabled"'; + } else { + $value = is_null($this->_local) ? $this->_default : $this->_local; + } - $key = htmlspecialchars($this->_key); - $checked = ($value) ? ' checked="checked"' : ''; + $key = htmlspecialchars($this->_key); + $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); - } + $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); + } - function update($input) { - if ($this->is_protected()) return false; + function update($input) { + if ($this->is_protected()) return false; - $input = ($input) ? 1 : 0; - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; + $input = ($input) ? 1 : 0; + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; - $this->_local = $input; - return true; + $this->_local = $input; + return true; + } } - } } if (!class_exists('setting_multichoice')) { - class setting_multichoice extends setting_string { - var $_choices = array(); - - function html(&$plugin) { - $value = ''; - $disable = ''; - $nochoice = ''; - - if ($this->is_protected()) { - $value = $this->_protected; - $disable = ' disabled="disabled"'; - } else { - $value = is_null($this->_local) ? $this->_default : $this->_local; - } + class setting_multichoice extends setting_string { + var $_choices = array(); - // ensure current value is included - if (!in_array($value, $this->_choices)) { - $this->_choices[] = $value; - } - // disable if no other choices - if (!$this->is_protected() && count($this->_choices) <= 1) { - $disable = ' disabled="disabled"'; - $nochoice = $plugin->getLang('nochoice'); - } + function html(&$plugin, $echo = false) { + $value = ''; + $disable = ''; + $nochoice = ''; - $key = htmlspecialchars($this->_key); + if ($this->is_protected()) { + $value = $this->_protected; + $disable = ' disabled="disabled"'; + } else { + $value = is_null($this->_local) ? $this->_default : $this->_local; + } - $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; + // ensure current value is included + if (!in_array($value, $this->_choices)) { + $this->_choices[] = $value; + } + // disable if no other choices + if (!$this->is_protected() && count($this->_choices) <= 1) { + $disable = ' disabled="disabled"'; + $nochoice = $plugin->getLang('nochoice'); + } - $input = "<div class=\"input\">\n"; - $input .= '<select class="edit" 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); - if (!$option && isset($this->lang[$this->_key.'_o_'.$choice])) $option = $this->lang[$this->_key.'_o_'.$choice]; - if (!$option) $option = $choice; + $key = htmlspecialchars($this->_key); - $choice = htmlspecialchars($choice); - $option = htmlspecialchars($option); - $input .= ' <option value="'.$choice.'"'.$selected.' >'.$option.'</option>'."\n"; - } - $input .= "</select> $nochoice \n"; - $input .= "</div>\n"; + $label = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>'; - return array($label,$input); - } + $input = "<div class=\"input\">\n"; + $input .= '<select class="edit" 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); + if (!$option && isset($this->lang[$this->_key.'_o_'.$choice])) $option = $this->lang[$this->_key.'_o_'.$choice]; + if (!$option) $option = $choice; + + $choice = htmlspecialchars($choice); + $option = htmlspecialchars($option); + $input .= ' <option value="'.$choice.'"'.$selected.' >'.$option.'</option>'."\n"; + } + $input .= "</select> $nochoice \n"; + $input .= "</div>\n"; + + return array($label,$input); + } - function update($input) { - if (is_null($input)) return false; - if ($this->is_protected()) return false; + function update($input) { + if (is_null($input)) return false; + if ($this->is_protected()) return false; - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; - if (!in_array($input, $this->_choices)) return false; + if (!in_array($input, $this->_choices)) return false; - $this->_local = $input; - return true; + $this->_local = $input; + return true; + } } - } } if (!class_exists('setting_dirchoice')) { - class setting_dirchoice extends setting_multichoice { + class setting_dirchoice extends setting_multichoice { - var $_dir = ''; + var $_dir = ''; - function initialize($default,$local,$protected) { + function initialize($default,$local,$protected) { - // populate $this->_choices with a list of directories - $list = array(); + // populate $this->_choices with a list of directories + $list = array(); - if ($dh = @opendir($this->_dir)) { - while (false !== ($entry = readdir($dh))) { - if ($entry == '.' || $entry == '..') continue; - if ($this->_pattern && !preg_match($this->_pattern,$entry)) continue; + if ($dh = @opendir($this->_dir)) { + while (false !== ($entry = readdir($dh))) { + if ($entry == '.' || $entry == '..') continue; + if ($this->_pattern && !preg_match($this->_pattern,$entry)) continue; - $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $this->_dir.$entry; - if (is_dir($file)) $list[] = $entry; - } - closedir($dh); - } - sort($list); - $this->_choices = $list; + $file = (is_link($this->_dir.$entry)) ? readlink($this->_dir.$entry) : $this->_dir.$entry; + if (is_dir($file)) $list[] = $entry; + } + closedir($dh); + } + sort($list); + $this->_choices = $list; - parent::initialize($default,$local,$protected); + parent::initialize($default,$local,$protected); + } } - } } if (!class_exists('setting_hidden')) { - class setting_hidden extends setting { - // Used to explicitly ignore a setting in the configuration manager. - } + class setting_hidden extends setting { + // Used to explicitly ignore a setting in the configuration manager. + } } if (!class_exists('setting_fieldset')) { - class setting_fieldset extends setting { - // A do-nothing class used to detect the 'fieldset' type. - // Used to start a new settings "display-group". - } + class setting_fieldset extends setting { + // A do-nothing class used to detect the 'fieldset' type. + // Used to start a new settings "display-group". + } } if (!class_exists('setting_undefined')) { - class setting_undefined extends setting_hidden { - // A do-nothing class used to detect settings with no metadata entry. - // Used internaly to hide undefined settings, and generate the undefined settings list. - } + class setting_undefined extends setting_hidden { + // A do-nothing class used to detect settings with no metadata entry. + // Used internaly to hide undefined settings, and generate the undefined settings list. + } } if (!class_exists('setting_no_class')) { - class setting_no_class extends setting_undefined { - // A do-nothing class used to detect settings with a missing setting class. - // Used internaly to hide undefined settings, and generate the undefined settings list. - } + class setting_no_class extends setting_undefined { + // A do-nothing class used to detect settings with a missing setting class. + // Used internaly to hide undefined settings, and generate the undefined settings list. + } } if (!class_exists('setting_no_default')) { - class setting_no_default extends setting_undefined { - // A do-nothing class used to detect settings with no default value. - // Used internaly to hide undefined settings, and generate the undefined settings list. - } + class setting_no_default extends setting_undefined { + // A do-nothing class used to detect settings with no default value. + // Used internaly to hide undefined settings, and generate the undefined settings list. + } } if (!class_exists('setting_multicheckbox')) { - class setting_multicheckbox extends setting_string { + class setting_multicheckbox extends setting_string { - var $_choices = array(); - var $_combine = array(); + var $_choices = array(); + var $_combine = array(); - function update($input) { - if ($this->is_protected()) return false; + function update($input) { + if ($this->is_protected()) return false; - // split any combined values + convert from array to comma separated string - $input = ($input) ? $input : array(); - $input = $this->_array2str($input); + // split any combined values + convert from array to comma separated string + $input = ($input) ? $input : array(); + $input = $this->_array2str($input); - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; + + if ($this->_pattern && !preg_match($this->_pattern,$input)) { + $this->_error = true; + $this->_input = $input; + return false; + } - if ($this->_pattern && !preg_match($this->_pattern,$input)) { - $this->_error = true; - $this->_input = $input; - return false; + $this->_local = $input; + return true; } - $this->_local = $input; - return true; - } + function html(&$plugin, $echo=false) { - function html(&$plugin, $echo=false) { + $value = ''; + $disable = ''; - $value = ''; - $disable = ''; + if ($this->is_protected()) { + $value = $this->_protected; + $disable = 'disabled="disabled"'; + } else { + if ($echo && $this->_error) { + $value = $this->_input; + } else { + $value = is_null($this->_local) ? $this->_default : $this->_local; + } + } - if ($this->is_protected()) { - $value = $this->_protected; - $disable = 'disabled="disabled"'; - } else { - if ($echo && $this->_error) { - $value = $this->_input; - } else { - $value = is_null($this->_local) ? $this->_default : $this->_local; - } - } + $key = htmlspecialchars($this->_key); - $key = htmlspecialchars($this->_key); + // convert from comma separated list into array + combine complimentary actions + $value = $this->_str2array($value); + $default = $this->_str2array($this->_default); - // convert from comma separated list into array + combine complimentary actions - $value = $this->_str2array($value); - $default = $this->_str2array($this->_default); + $input = ''; + foreach ($this->_choices as $choice) { + $idx = array_search($choice, $value); + $idx_default = array_search($choice,$default); - $input = ''; - foreach ($this->_choices as $choice) { - $idx = array_search($choice, $value); - $idx_default = array_search($choice,$default); + $checked = ($idx !== false) ? 'checked="checked"' : ''; - $checked = ($idx !== false) ? 'checked="checked"' : ''; + // ideally this would be handled using a second class of "default", however IE6 does not + // correctly support CSS selectors referencing multiple class names on the same element + // (e.g. .default.selection). + $class = (($idx !== false) == (false !== $idx_default)) ? " selectiondefault" : ""; - // ideally this would be handled using a second class of "default", however IE6 does not - // correctly support CSS selectors referencing multiple class names on the same element - // (e.g. .default.selection). - $class = (($idx !== false) == (false !== $idx_default)) ? " selectiondefault" : ""; + $prompt = ($plugin->getLang($this->_key.'_'.$choice) ? + $plugin->getLang($this->_key.'_'.$choice) : htmlspecialchars($choice)); - $prompt = ($plugin->getLang($this->_key.'_'.$choice) ? - $plugin->getLang($this->_key.'_'.$choice) : htmlspecialchars($choice)); + $input .= '<div class="selection'.$class.'">'."\n"; + $input .= '<label for="config___'.$key.'_'.$choice.'">'.$prompt."</label>\n"; + $input .= '<input id="config___'.$key.'_'.$choice.'" name="config['.$key.'][]" type="checkbox" class="checkbox" value="'.$choice.'" '.$disable.' '.$checked."/>\n"; + $input .= "</div>\n"; - $input .= '<div class="selection'.$class.'">'."\n"; - $input .= '<label for="config___'.$key.'_'.$choice.'">'.$prompt."</label>\n"; - $input .= '<input id="config___'.$key.'_'.$choice.'" name="config['.$key.'][]" type="checkbox" class="checkbox" value="'.$choice.'" '.$disable.' '.$checked."/>\n"; - $input .= "</div>\n"; + // remove this action from the disabledactions array + if ($idx !== false) unset($value[$idx]); + if ($idx_default !== false) unset($default[$idx_default]); + } - // remove this action from the disabledactions array - if ($idx !== false) unset($value[$idx]); - if ($idx_default !== false) unset($default[$idx_default]); - } + // handle any remaining values + $other = join(',',$value); - // handle any remaining values - $other = join(',',$value); + $class = (count($default == count($value)) && (count($value) == count(array_intersect($value,$default)))) ? + " selectiondefault" : ""; - $class = (count($default == count($value)) && (count($value) == count(array_intersect($value,$default)))) ? - " selectiondefault" : ""; + $input .= '<div class="other'.$class.'">'."\n"; + $input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n"; + $input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n"; + $input .= "</div>\n"; - $input .= '<div class="other'.$class.'">'."\n"; - $input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n"; - $input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n"; - $input .= "</div>\n"; + $label = '<label>'.$this->prompt($plugin).'</label>'; + return array($label,$input); + } - $label = '<label>'.$this->prompt($plugin).'</label>'; - return array($label,$input); - } + /** + * convert comma separated list to an array and combine any complimentary values + */ + function _str2array($str) { + $array = explode(',',$str); + + if (!empty($this->_combine)) { + foreach ($this->_combine as $key => $combinators) { + $idx = array(); + foreach ($combinators as $val) { + if (($idx[] = array_search($val, $array)) === false) break; + } + + if (count($idx) && $idx[count($idx)-1] !== false) { + foreach ($idx as $i) unset($array[$i]); + $array[] = $key; + } + } + } - /** - * convert comma separated list to an array and combine any complimentary values - */ - function _str2array($str) { - $array = explode(',',$str); - - if (!empty($this->_combine)) { - foreach ($this->_combine as $key => $combinators) { - $idx = array(); - foreach ($combinators as $val) { - if (($idx[] = array_search($val, $array)) === false) break; - } - - if (count($idx) && $idx[count($idx)-1] !== false) { - foreach ($idx as $i) unset($array[$i]); - $array[] = $key; - } + return $array; } - } - return $array; - } + /** + * convert array of values + other back to a comma separated list, incl. splitting any combined values + */ + function _array2str($input) { - /** - * convert array of values + other back to a comma separated list, incl. splitting any combined values - */ - function _array2str($input) { + // handle other + $other = trim($input['other']); + $other = !empty($other) ? explode(',',str_replace(' ','',$input['other'])) : array(); + unset($input['other']); - // handle other - $other = trim($input['other']); - $other = !empty($other) ? explode(',',str_replace(' ','',$input['other'])) : array(); - unset($input['other']); + $array = array_unique(array_merge($input, $other)); - $array = array_unique(array_merge($input, $other)); + // deconstruct any combinations + if (!empty($this->_combine)) { + foreach ($this->_combine as $key => $combinators) { - // deconstruct any combinations - if (!empty($this->_combine)) { - foreach ($this->_combine as $key => $combinators) { + $idx = array_search($key,$array); + if ($idx !== false) { + unset($array[$idx]); + $array = array_merge($array, $combinators); + } + } + } - $idx = array_search($key,$array); - if ($idx !== false) { - unset($array[$idx]); - $array = array_merge($array, $combinators); - } + return join(',',array_unique($array)); } - } - - return join(',',array_unique($array)); } - } } if (!class_exists('setting_regex')){ - class setting_regex extends setting_string { + class setting_regex extends setting_string { var $_delimiter = '/'; // regex delimiter to be used in testing input var $_pregflags = 'ui'; // regex pattern modifiers to be used in testing input /** - * update changed setting with user provided value $input - * - if changed value fails error check, save it to $this->_input (to allow echoing later) - * - if changed value passes error check, set $this->_local to the new value + * update changed setting with user provided value $input + * - if changed value fails error check, save it to $this->_input (to allow echoing later) + * - if changed value passes error check, set $this->_local to the new value * - * @param mixed $input the new value - * @return boolean true if changed, false otherwise (incl. on error) + * @param mixed $input the new value + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index f4c2ed265..f9dabfeb0 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -48,6 +48,7 @@ * 'compression' - no additional parameters. checks php installation supports possible compression alternatives * 'licence' - as multichoice, selection constructed from licence strings in language files * 'renderer' - as multichoice, selection constructed from enabled renderer plugins which canRender() + * 'authtype' - as multichoice, selection constructed from the enabled auth plugins * * Any setting commented or missing will use 'setting' class - text input, minimal validation, quoted output * diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php index e4b97eb01..83de802a3 100644 --- a/lib/plugins/config/settings/extra.class.php +++ b/lib/plugins/config/settings/extra.class.php @@ -6,204 +6,204 @@ */ if (!class_exists('setting_sepchar')) { - class setting_sepchar extends setting_multichoice { + class setting_sepchar extends setting_multichoice { - function setting_sepchar($key,$param=NULL) { - $str = '_-.'; - for ($i=0;$i<strlen($str);$i++) $this->_choices[] = $str{$i}; + function setting_sepchar($key,$param=null) { + $str = '_-.'; + for ($i=0;$i<strlen($str);$i++) $this->_choices[] = $str{$i}; - // call foundation class constructor - $this->setting($key,$param); + // call foundation class constructor + $this->setting($key,$param); + } } - } } if (!class_exists('setting_savedir')) { - class setting_savedir extends setting_string { + class setting_savedir extends setting_string { - function update($input) { - if ($this->is_protected()) return false; + function update($input) { + if ($this->is_protected()) return false; - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; - if (!init_path($input)) { - $this->_error = true; - $this->_input = $input; - return false; - } + if (!init_path($input)) { + $this->_error = true; + $this->_input = $input; + return false; + } - $this->_local = $input; - return true; + $this->_local = $input; + return true; + } } - } } if (!class_exists('setting_authtype')) { - class setting_authtype extends setting_multichoice { + class setting_authtype extends setting_multichoice { - function initialize($default,$local,$protected) { - global $plugin_controller; + function initialize($default,$local,$protected) { + global $plugin_controller; - // retrieve auth types provided by plugins - foreach ($plugin_controller->getList('auth') as $plugin) { - $this->_choices[] = $plugin; - } - - parent::initialize($default,$local,$protected); - } - - function update($input) { - global $plugin_controller; - - // is an update possible/requested? - $local = $this->_local; // save this, parent::update() may change it - if (!parent::update($input)) return false; // nothing changed or an error caught by parent - $this->_local = $local; // restore original, more error checking to come - - // attempt to load the plugin - $auth_plugin = $plugin_controller->load('auth', $input); - - // @TODO: throw an error in plugin controller instead of returning null - if (is_null($auth_plugin)) { - $this->_error = true; - msg('Cannot load Auth Plugin "' . $input . '"', -1); - return false; - } + // retrieve auth types provided by plugins + foreach ($plugin_controller->getList('auth') as $plugin) { + $this->_choices[] = $plugin; + } - // verify proper instantiation (is this really a plugin?) @TODO use instanceof? implement interface? - if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) { - $this->_error = true; - msg('Cannot create Auth Plugin "' . $input . '"', -1); - return false; + parent::initialize($default,$local,$protected); } - // did we change the auth type? logout - global $conf; - if($conf['authtype'] != $input) { - msg('Authentication system changed. Please re-login.'); - auth_logoff(); + function update($input) { + global $plugin_controller; + + // is an update possible/requested? + $local = $this->_local; // save this, parent::update() may change it + if (!parent::update($input)) return false; // nothing changed or an error caught by parent + $this->_local = $local; // restore original, more error checking to come + + // attempt to load the plugin + $auth_plugin = $plugin_controller->load('auth', $input); + + // @TODO: throw an error in plugin controller instead of returning null + if (is_null($auth_plugin)) { + $this->_error = true; + msg('Cannot load Auth Plugin "' . $input . '"', -1); + return false; + } + + // verify proper instantiation (is this really a plugin?) @TODO use instanceof? implement interface? + if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) { + $this->_error = true; + msg('Cannot create Auth Plugin "' . $input . '"', -1); + return false; + } + + // did we change the auth type? logout + global $conf; + if($conf['authtype'] != $input) { + msg('Authentication system changed. Please re-login.'); + auth_logoff(); + } + + $this->_local = $input; + return true; } - - $this->_local = $input; - return true; } - } } if (!class_exists('setting_im_convert')) { - class setting_im_convert extends setting_string { + class setting_im_convert extends setting_string { - function update($input) { - if ($this->is_protected()) return false; + function update($input) { + if ($this->is_protected()) return false; - $input = trim($input); + $input = trim($input); - $value = is_null($this->_local) ? $this->_default : $this->_local; - if ($value == $input) return false; + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; - if ($input && !@file_exists($input)) { - $this->_error = true; - $this->_input = $input; - return false; - } + if ($input && !@file_exists($input)) { + $this->_error = true; + $this->_input = $input; + return false; + } - $this->_local = $input; - return true; + $this->_local = $input; + return true; + } } - } } if (!class_exists('setting_disableactions')) { - class setting_disableactions extends setting_multicheckbox { + class setting_disableactions extends setting_multicheckbox { - function html(&$plugin, $echo=false) { - global $lang; + function html(&$plugin, $echo=false) { + global $lang; - // make some language adjustments (there must be a better way) - // transfer some DokuWiki language strings to the plugin - if (!$plugin->localised) $this->setupLocale(); - $plugin->lang[$this->_key.'_revisions'] = $lang['btn_revs']; + // make some language adjustments (there must be a better way) + // transfer some DokuWiki language strings to the plugin + if (!$plugin->localised) $this->setupLocale(); + $plugin->lang[$this->_key.'_revisions'] = $lang['btn_revs']; - foreach ($this->_choices as $choice) - if (isset($lang['btn_'.$choice])) $plugin->lang[$this->_key.'_'.$choice] = $lang['btn_'.$choice]; + foreach ($this->_choices as $choice) + if (isset($lang['btn_'.$choice])) $plugin->lang[$this->_key.'_'.$choice] = $lang['btn_'.$choice]; - return parent::html($plugin, $echo); + return parent::html($plugin, $echo); + } } - } } if (!class_exists('setting_compression')) { - class setting_compression extends setting_multichoice { + class setting_compression extends setting_multichoice { - var $_choices = array('0'); // 0 = no compression, always supported + var $_choices = array('0'); // 0 = no compression, always supported - function initialize($default,$local,$protected) { + function initialize($default,$local,$protected) { - // populate _choices with the compression methods supported by this php installation - if (function_exists('gzopen')) $this->_choices[] = 'gz'; - if (function_exists('bzopen')) $this->_choices[] = 'bz2'; + // populate _choices with the compression methods supported by this php installation + if (function_exists('gzopen')) $this->_choices[] = 'gz'; + if (function_exists('bzopen')) $this->_choices[] = 'bz2'; - parent::initialize($default,$local,$protected); + parent::initialize($default,$local,$protected); + } } - } } if (!class_exists('setting_license')) { - class setting_license extends setting_multichoice { + class setting_license extends setting_multichoice { - var $_choices = array(''); // none choosen + var $_choices = array(''); // none choosen - function initialize($default,$local,$protected) { - global $license; + function initialize($default,$local,$protected) { + global $license; - foreach($license as $key => $data){ - $this->_choices[] = $key; - $this->lang[$this->_key.'_o_'.$key] = $data['name']; - } + foreach($license as $key => $data){ + $this->_choices[] = $key; + $this->lang[$this->_key.'_o_'.$key] = $data['name']; + } - parent::initialize($default,$local,$protected); + parent::initialize($default,$local,$protected); + } } - } } if (!class_exists('setting_renderer')) { - class setting_renderer extends setting_multichoice { - var $_prompts = array(); + class setting_renderer extends setting_multichoice { + var $_prompts = array(); - function initialize($default,$local,$protected) { - $format = $this->_format; + function initialize($default,$local,$protected) { + $format = $this->_format; - foreach (plugin_list('renderer') as $plugin) { - $renderer =& plugin_load('renderer',$plugin); - if (method_exists($renderer,'canRender') && $renderer->canRender($format)) { - $this->_choices[] = $plugin; + foreach (plugin_list('renderer') as $plugin) { + $renderer = plugin_load('renderer',$plugin); + if (method_exists($renderer,'canRender') && $renderer->canRender($format)) { + $this->_choices[] = $plugin; - $info = $renderer->getInfo(); - $this->_prompts[$plugin] = $info['name']; - } - } - - parent::initialize($default,$local,$protected); - } + $info = $renderer->getInfo(); + $this->_prompts[$plugin] = $info['name']; + } + } - function html(&$plugin, $echo=false) { - - // make some language adjustments (there must be a better way) - // transfer some plugin names to the config plugin - if (!$plugin->localised) $this->setupLocale(); + parent::initialize($default,$local,$protected); + } - foreach ($this->_choices as $choice) { - if (!isset($plugin->lang[$this->_key.'_o_'.$choice])) { - if (!isset($this->_prompts[$choice])) { - $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__core'],$choice); - } else { - $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__plugin'],$this->_prompts[$choice]); - } + function html(&$plugin, $echo=false) { + + // make some language adjustments (there must be a better way) + // transfer some plugin names to the config plugin + if (!$plugin->localised) $this->setupLocale(); + + foreach ($this->_choices as $choice) { + if (!isset($plugin->lang[$this->_key.'_o_'.$choice])) { + if (!isset($this->_prompts[$choice])) { + $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__core'],$choice); + } else { + $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__plugin'],$this->_prompts[$choice]); + } + } + } + return parent::html($plugin, $echo); } - } - return parent::html($plugin, $echo); } - } } |