45 parent::__construct();
46 $this->docURL = $doc_url;
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);
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);
197 $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config));
223 parent::__construct();
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));
315 if (is_array($value)) {
320 foreach ($array as $val => $b) {
325 $value = implode(
PHP_EOL, $value);
329 foreach ($value as
$i => $v) {
332 $v = implode(
";", $v);
343 return 'Not supported';
344 $value = serialize($value);
347 'name' =>
"$name" .
"[$ns.$directive]",
348 'id' =>
"$name:$ns.$directive" 350 if ($value === null) {
351 $attr[
'disabled'] =
'disabled';
353 if (isset(
$def->allowed)) {
355 foreach (
$def->allowed as $val => $b) {
357 if ($value == $val) {
358 $attr[
'selected'] =
'selected';
372 $ret .= $this->
end(
'textarea');
374 $attr[
'value'] = $value;
375 $attr[
'type'] =
'text';
405 $ret .= $this->
start(
'div', array(
'id' =>
"$name:$ns.$directive"));
407 $ret .= $this->
start(
'label', array(
'for' =>
"$name:Yes_$ns.$directive"));
408 $ret .= $this->
element(
'span',
"$ns.$directive:", array(
'class' =>
'verbose'));
414 'name' =>
"$name" .
"[$ns.$directive]",
415 'id' =>
"$name:Yes_$ns.$directive",
418 if ($value ===
true) {
419 $attr[
'checked'] =
'checked';
421 if ($value === null) {
422 $attr[
'disabled'] =
'disabled';
426 $ret .= $this->
start(
'label', array(
'for' =>
"$name:No_$ns.$directive"));
427 $ret .= $this->
element(
'span',
"$ns.$directive:", array(
'class' =>
'verbose'));
433 'name' =>
"$name" .
"[$ns.$directive]",
434 'id' =>
"$name:No_$ns.$directive",
437 if ($value ===
false) {
438 $attr[
'checked'] =
'checked';
440 if ($value === null) {
441 $attr[
'disabled'] =
'disabled';
start($tag, $attr=array())
Main function that renders object or aspect of that object.
elementEmpty($tag, $attr=array())
prepareGenerator($config)
Give generator necessary configuration if possible.
end($tag)
Returns an end tag.
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
static getAllowedDirectivesForForm($allowed, $schema=null)
Returns a list of array(namespace, directive) for all directives that are allowed in a web-form conte...