46 $this->docURL = $doc_url;
62 $this->
fields[
'default']->cols = $cols;
65 $this->
fields[
'default']->rows = $rows;
74 return file_get_contents(HTMLPURIFIER_PREFIX .
'/HTMLPurifier/Printer/ConfigForm.css');
82 return file_get_contents(HTMLPURIFIER_PREFIX .
'/HTMLPurifier/Printer/ConfigForm.js');
93 public function render(
$config, $allowed =
true, $render_controls =
true)
103 $this->genConfig = $gen_config;
108 foreach ($allowed as $key) {
109 list($ns, $directive) = $key;
110 $all[$ns][$directive] =
$config->get($ns .
'.' . $directive);
114 $ret .= $this->
start(
'table', array(
'class' =>
'hp-config'));
117 $ret .= $this->
element(
'th',
'Directive', array(
'class' =>
'hp-directive'));
118 $ret .= $this->
element(
'th',
'Value', array(
'class' =>
'hp-value'));
121 foreach ($all as $ns => $directives) {
124 if ($render_controls) {
127 $ret .= $this->
start(
'td', array(
'colspan' => 2,
'class' =>
'controls'));
128 $ret .= $this->
elementEmpty(
'input', array(
'type' =>
'submit',
'value' =>
'Submit'));
129 $ret .=
'[<a href="?">Reset</a>]';
147 $ret .= $this->
start(
'tbody', array(
'class' =>
'namespace'));
149 $ret .= $this->
element(
'th', $ns, array(
'colspan' => 2));
153 foreach ($directives as $directive => $value) {
157 $url = str_replace(
'%s', urlencode(
"$ns.$directive"), $this->docURL);
158 $ret .= $this->
start(
'a', array(
'href' => $url));
160 $attr = array(
'for' =>
"{$this->name}:$ns.$directive");
163 if (!$this->compress || (strlen($directive) < $this->compress)) {
164 $directive_disp = $directive;
166 $directive_disp = substr($directive, 0, $this->compress - 2) .
'...';
167 $attr[
'title'] = $directive;
182 $def = $this->config->def->info[
"$ns.$directive"];
184 $allow_null = $def < 0;
188 $allow_null = isset($def->allow_null);
190 if (!isset($this->
fields[$type])) {
193 $type_obj = $this->
fields[$type];
197 $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config));
246 $ret .= $this->
start(
'label', array(
'for' =>
"$name:Null_$ns.$directive"));
247 $ret .= $this->
element(
'span',
"$ns.$directive:", array(
'class' =>
'verbose'));
248 $ret .= $this->
text(
' Null/Disabled');
251 'type' =>
'checkbox',
253 'class' =>
'null-toggle',
254 'name' =>
"$name" .
"[Null_$ns.$directive]",
255 'id' =>
"$name:Null_$ns.$directive",
256 'onclick' =>
"toggleWriteability('$name:$ns.$directive',checked)"
261 "toggleWriteability('$name:Yes_$ns.$directive',checked);" .
262 "toggleWriteability('$name:No_$ns.$directive',checked)";
264 if ($value === null) {
265 $attr[
'checked'] =
'checked';
270 $ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config,
$config));
309 $def =
$config->def->info[
"$ns.$directive"];
315 if (is_array($value)) {
320 foreach ($array as $val => $b) {
325 $value = implode(PHP_EOL, $value);
329 foreach ($value as $i => $v) {
330 $nvalue .=
"$i:$v" . PHP_EOL;
339 return 'Not supported';
340 $value = serialize($value);
343 'name' =>
"$name" .
"[$ns.$directive]",
344 'id' =>
"$name:$ns.$directive"
346 if ($value === null) {
347 $attr[
'disabled'] =
'disabled';
349 if (isset($def->allowed)) {
351 foreach ($def->allowed as $val => $b) {
353 if ($value == $val) {
354 $attr[
'selected'] =
'selected';
368 $ret .= $this->
end(
'textarea');
370 $attr[
'value'] = $value;
371 $attr[
'type'] =
'text';
401 $ret .= $this->
start(
'div', array(
'id' =>
"$name:$ns.$directive"));
403 $ret .= $this->
start(
'label', array(
'for' =>
"$name:Yes_$ns.$directive"));
404 $ret .= $this->
element(
'span',
"$ns.$directive:", array(
'class' =>
'verbose'));
410 'name' =>
"$name" .
"[$ns.$directive]",
411 'id' =>
"$name:Yes_$ns.$directive",
414 if ($value ===
true) {
415 $attr[
'checked'] =
'checked';
417 if ($value === null) {
418 $attr[
'disabled'] =
'disabled';
422 $ret .= $this->
start(
'label', array(
'for' =>
"$name:No_$ns.$directive"));
423 $ret .= $this->
element(
'span',
"$ns.$directive:", array(
'class' =>
'verbose'));
429 'name' =>
"$name" .
"[$ns.$directive]",
430 'id' =>
"$name:No_$ns.$directive",
433 if ($value ===
false) {
434 $attr[
'checked'] =
'checked';
436 if ($value === null) {
437 $attr[
'disabled'] =
'disabled';