mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
[2.1.0] ConfigForm generates textareas instead of text inputs for lists, hashes, lookups, text and itext fields
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1273 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
5e5c0f3aa4
commit
ed44b5c5ba
2
NEWS
2
NEWS
@ -25,6 +25,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
longer strings that would be more appropriately edited with a textarea
|
longer strings that would be more appropriately edited with a textarea
|
||||||
. Allow newlines to act as separators for lists, hashes, lookups and
|
. Allow newlines to act as separators for lists, hashes, lookups and
|
||||||
%HTML.Allowed
|
%HTML.Allowed
|
||||||
|
. ConfigForm generates textareas instead of text inputs for lists, hashes,
|
||||||
|
lookups, text and itext fields
|
||||||
|
|
||||||
2.0.2, unknown release date
|
2.0.2, unknown release date
|
||||||
(none)
|
(none)
|
||||||
|
@ -34,7 +34,9 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
|
|||||||
* @param $doc_url String documentation URL, will have fragment tagged on
|
* @param $doc_url String documentation URL, will have fragment tagged on
|
||||||
* @param $compress Integer max length before compressing a directive name, set to false to turn off
|
* @param $compress Integer max length before compressing a directive name, set to false to turn off
|
||||||
*/
|
*/
|
||||||
function HTMLPurifier_Printer_ConfigForm($name, $doc_url = null, $compress = false) {
|
function HTMLPurifier_Printer_ConfigForm(
|
||||||
|
$name, $doc_url = null, $compress = false
|
||||||
|
) {
|
||||||
parent::HTMLPurifier_Printer();
|
parent::HTMLPurifier_Printer();
|
||||||
$this->docURL = $doc_url;
|
$this->docURL = $doc_url;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@ -43,6 +45,15 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
|
|||||||
$this->fields['bool'] = new HTMLPurifier_Printer_ConfigForm_bool();
|
$this->fields['bool'] = new HTMLPurifier_Printer_ConfigForm_bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cols Integer columns of textarea, null to use default
|
||||||
|
* @param $rows Integer rows of textarea, null to use default
|
||||||
|
*/
|
||||||
|
function setTextareaDimensions($cols = null, $rows = null) {
|
||||||
|
if ($cols) $this->fields['default']->cols = $cols;
|
||||||
|
if ($rows) $this->fields['default']->rows = $rows;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves styling, in case the directory it's in is not publically
|
* Retrieves styling, in case the directory it's in is not publically
|
||||||
* available
|
* available
|
||||||
@ -200,6 +211,8 @@ class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer
|
|||||||
* Swiss-army knife configuration form field printer
|
* Swiss-army knife configuration form field printer
|
||||||
*/
|
*/
|
||||||
class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer {
|
class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer {
|
||||||
|
var $cols = 18;
|
||||||
|
var $rows = 5;
|
||||||
function render($ns, $directive, $value, $name, $config) {
|
function render($ns, $directive, $value, $name, $config) {
|
||||||
$this->prepareGenerator($config);
|
$this->prepareGenerator($config);
|
||||||
// this should probably be split up a little
|
// this should probably be split up a little
|
||||||
@ -214,12 +227,12 @@ class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer {
|
|||||||
$value[] = $val;
|
$value[] = $val;
|
||||||
}
|
}
|
||||||
case 'list':
|
case 'list':
|
||||||
$value = implode(',', $value);
|
$value = implode(PHP_EOL, $value);
|
||||||
break;
|
break;
|
||||||
case 'hash':
|
case 'hash':
|
||||||
$nvalue = '';
|
$nvalue = '';
|
||||||
foreach ($value as $i => $v) {
|
foreach ($value as $i => $v) {
|
||||||
$nvalue .= "$i:$v,";
|
$nvalue .= "$i:$v" . PHP_EOL;
|
||||||
}
|
}
|
||||||
$value = $nvalue;
|
$value = $nvalue;
|
||||||
break;
|
break;
|
||||||
@ -244,6 +257,15 @@ class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer {
|
|||||||
$ret .= $this->element('option', $val, $attr);
|
$ret .= $this->element('option', $val, $attr);
|
||||||
}
|
}
|
||||||
$ret .= $this->end('select');
|
$ret .= $this->end('select');
|
||||||
|
} elseif (
|
||||||
|
$def->type == 'text' || $def->type == 'itext' ||
|
||||||
|
$def->type == 'list' || $def->type == 'hash' || $def->type == 'lookup'
|
||||||
|
) {
|
||||||
|
$attr['cols'] = $this->cols;
|
||||||
|
$attr['rows'] = $this->rows;
|
||||||
|
$ret .= $this->start('textarea', $attr);
|
||||||
|
$ret .= $this->text($value);
|
||||||
|
$ret .= $this->end('textarea');
|
||||||
} else {
|
} else {
|
||||||
$attr['value'] = $value;
|
$attr['value'] = $value;
|
||||||
$attr['type'] = 'text';
|
$attr['type'] = 'text';
|
||||||
|
@ -37,3 +37,7 @@ HTMLPurifier_ConfigSchema::defineNamespace('ReportCard', 'It is for grades.');
|
|||||||
HTMLPurifier_ConfigSchema::define('ReportCard', 'English', null, 'string/null', 'Grade from English class.');
|
HTMLPurifier_ConfigSchema::define('ReportCard', 'English', null, 'string/null', 'Grade from English class.');
|
||||||
HTMLPurifier_ConfigSchema::define('ReportCard', 'Absences', 0, 'int', 'How many times missing from school?');
|
HTMLPurifier_ConfigSchema::define('ReportCard', 'Absences', 0, 'int', 'How many times missing from school?');
|
||||||
|
|
||||||
|
HTMLPurifier_ConfigSchema::defineNamespace('Text', 'This stuff is long, boring, and English.');
|
||||||
|
HTMLPurifier_ConfigSchema::define('Text', 'AboutUs', 'Nothing much, but this should be decently long so that a textarea would be better', 'text', 'Who are we? What are we up to?');
|
||||||
|
HTMLPurifier_ConfigSchema::define('Text', 'Hash', "not-case-sensitive\nstill-not-case-sensitive\nsuper-not-case-sensitive", 'itext', 'This is of limited utility, but of course it ends up being used.');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user