From 23e8f02b8aa3a74fed70f1a496bdb5423908133a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 10 Nov 2012 16:11:30 +0100 Subject: [PATCH] added 'text' to config plugin for multi line text configs --- lib/plugins/config/settings/config.class.php | 33 +++++++++++++++++-- .../config/settings/config.metadata.php | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 8c48018d79..9f98231e32 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -35,6 +35,7 @@ function configuration($datafile) { msg('No configuration metadata found at - '.htmlspecialchars($datafile),-1); return; } + $meta = array(); include($datafile); if (isset($config['varname'])) $this->_name = $config['varname']; @@ -68,6 +69,7 @@ function retrieve_settings() { $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]; @@ -425,11 +427,9 @@ function out($var, $fmt='php') { $out = ''; if ($fmt=='php') { - // translation string needs to be improved FIXME - $tr = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t', "\\" => '\\\\', "'" => '\\\''); $tr = array("\\" => '\\\\', "'" => '\\\''); - $out = '$'.$var."['".$this->_out_key()."'] = '".strtr($this->_local, $tr)."';\n"; + $out = '$'.$var."['".$this->_out_key()."'] = '".strtr( cleanText($this->_local), $tr)."';\n"; } return $out; @@ -494,6 +494,33 @@ function html(&$plugin, $echo=false) { } } +if (!class_exists('setting_text')) { + class setting_text 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; + } + } + + $key = htmlspecialchars($this->_key); + $value = formText($value); + + $label = ''; + $input = ''; + return array($label,$input); + } + } +} + if (!class_exists('setting_password')) { class setting_password extends setting_string { diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index 3607f56c65..33ebb7fd84 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -15,6 +15,7 @@ * ------------------------------------------- * '' - default class ('setting'), textarea, minimal input validation, setting output in quotes * 'string' - single line text input, minimal input validation, setting output in quotes + * 'text' - multi line text input, minimal input validation, setting output in quotes * 'numeric' - text input, accepts numbers and arithmetic operators, setting output without quotes * if given the '_min' and '_max' parameters are used for validation * 'numericopt' - like above, but accepts empty values