Skip to content

Commit

Permalink
added 'text' to config plugin for multi line text configs
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Nov 10, 2012
1 parent c189f40 commit 23e8f02
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
33 changes: 30 additions & 3 deletions lib/plugins/config/settings/config.class.php
Expand Up @@ -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'];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = '<label for="config___'.$key.'">'.$this->prompt($plugin).'</label>';
$input = '<textarea id="config___'.$key.'" name="config['.$key.']" class="edit" '.$disable.'>'.$value.'</textarea>';
return array($label,$input);
}
}
}

if (!class_exists('setting_password')) {
class setting_password extends setting_string {

Expand Down
1 change: 1 addition & 0 deletions lib/plugins/config/settings/config.metadata.php
Expand Up @@ -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
Expand Down

0 comments on commit 23e8f02

Please sign in to comment.