ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_Printer_ConfigForm Class Reference
+ Inheritance diagram for HTMLPurifier_Printer_ConfigForm:
+ Collaboration diagram for HTMLPurifier_Printer_ConfigForm:

Public Member Functions

 __construct ($name, $doc_url=null, $compress=false)
 setTextareaDimensions ($cols=null, $rows=null)
 Sets default column and row size for textareas in sub-printers.
 render ($config, $allowed=true, $render_controls=true)
 Returns HTML output for a configuration form.
- Public Member Functions inherited from HTMLPurifier_Printer
 __construct ()
 Initialize $generator.
 prepareGenerator ($config)
 Give generator necessary configuration if possible.

Static Public Member Functions

static getCSS ()
 Retrieves styling, in case it is not accessible by webserver.
static getJavaScript ()
 Retrieves JavaScript, in case it is not accessible by webserver.

Protected Member Functions

 renderNamespace ($ns, $directives)
 Renders a single namespace.
- Protected Member Functions inherited from HTMLPurifier_Printer
 start ($tag, $attr=array())
 Main function that renders object or aspect of that object.
 end ($tag)
 Returns an end teg.
 element ($tag, $contents, $attr=array(), $escape=true)
 Prints a complete element with content inside.
 elementEmpty ($tag, $attr=array())
 text ($text)
 row ($name, $value)
 Prints a simple key/value row in a table.
 escape ($string)
 Escapes a string for HTML output.
 listify ($array, $polite=false)
 Takes a list of strings and turns them into a single list.
 getClass ($obj, $sec_prefix= '')
 Retrieves the class of an object without prefixes, as well as metadata.

Protected Attributes

 $fields = array()
 Printers for specific fields.
 $docURL
 Documentation URL, can have fragment tagged on end.
 $name
 Name of form element to stuff config in.
 $compress = false
 Whether or not to compress directive names, clipping them off after a certain amount of letters.
- Protected Attributes inherited from HTMLPurifier_Printer
 $generator
 Instance of HTMLPurifier_Generator for HTML generation convenience funcs.
 $config
 Instance of HTMLPurifier_Config, for easy access.

Detailed Description

Todo:
Rewrite to use Interchange objects

Definition at line 6 of file ConfigForm.php.

Constructor & Destructor Documentation

HTMLPurifier_Printer_ConfigForm::__construct (   $name,
  $doc_url = null,
  $compress = false 
)
Parameters
$nameForm element name for directives to be stuffed into
$doc_urlString documentation URL, will have fragment tagged on
$compressInteger max length before compressing a directive name, set to false to turn off

Definition at line 36 of file ConfigForm.php.

References $compress, $name, HTMLPurifier_Printer\__construct(), and HTMLPurifier_VarParser\BOOL.

{
$this->docURL = $doc_url;
$this->name = $name;
$this->compress = $compress;
// initialize sub-printers
$this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default();
}

+ Here is the call graph for this function:

Member Function Documentation

static HTMLPurifier_Printer_ConfigForm::getCSS ( )
static

Retrieves styling, in case it is not accessible by webserver.

Definition at line 61 of file ConfigForm.php.

{
return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css');
}
static HTMLPurifier_Printer_ConfigForm::getJavaScript ( )
static

Retrieves JavaScript, in case it is not accessible by webserver.

Definition at line 68 of file ConfigForm.php.

{
return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js');
}
HTMLPurifier_Printer_ConfigForm::render (   $config,
  $allowed = true,
  $render_controls = true 
)

Returns HTML output for a configuration form.

Parameters
$configConfiguration object of current form state, or an array where [0] has an HTML namespace and [1] is being rendered.
$allowedOptional namespace(s) and directives to restrict form to.

Definition at line 78 of file ConfigForm.php.

References HTMLPurifier_Printer\$config, $key, $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\elementEmpty(), HTMLPurifier_Printer\end(), HTMLPurifier_Config\getAllowedDirectivesForForm(), HTMLPurifier_Printer\prepareGenerator(), renderNamespace(), and HTMLPurifier_Printer\start().

{
if (is_array($config) && isset($config[0])) {
$gen_config = $config[0];
} else {
$gen_config = $config;
}
$this->config = $config;
$this->genConfig = $gen_config;
$this->prepareGenerator($gen_config);
$all = array();
foreach ($allowed as $key) {
list($ns, $directive) = $key;
$all[$ns][$directive] = $config->get($ns .'.'. $directive);
}
$ret = '';
$ret .= $this->start('table', array('class' => 'hp-config'));
$ret .= $this->start('thead');
$ret .= $this->start('tr');
$ret .= $this->element('th', 'Directive', array('class' => 'hp-directive'));
$ret .= $this->element('th', 'Value', array('class' => 'hp-value'));
$ret .= $this->end('tr');
$ret .= $this->end('thead');
foreach ($all as $ns => $directives) {
$ret .= $this->renderNamespace($ns, $directives);
}
if ($render_controls) {
$ret .= $this->start('tbody');
$ret .= $this->start('tr');
$ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls'));
$ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit'));
$ret .= '[<a href="?">Reset</a>]';
$ret .= $this->end('td');
$ret .= $this->end('tr');
$ret .= $this->end('tbody');
}
$ret .= $this->end('table');
return $ret;
}

+ Here is the call graph for this function:

HTMLPurifier_Printer_ConfigForm::renderNamespace (   $ns,
  $directives 
)
protected

Renders a single namespace.

Parameters
$nsString namespace name
$directiveAssociative array of directives to values

Definition at line 127 of file ConfigForm.php.

References $ret, $type, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), and HTMLPurifier_Printer\start().

Referenced by render().

{
$ret = '';
$ret .= $this->start('tbody', array('class' => 'namespace'));
$ret .= $this->start('tr');
$ret .= $this->element('th', $ns, array('colspan' => 2));
$ret .= $this->end('tr');
$ret .= $this->end('tbody');
$ret .= $this->start('tbody');
foreach ($directives as $directive => $value) {
$ret .= $this->start('tr');
$ret .= $this->start('th');
if ($this->docURL) {
$url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL);
$ret .= $this->start('a', array('href' => $url));
}
$attr = array('for' => "{$this->name}:$ns.$directive");
// crop directive name if it's too long
if (!$this->compress || (strlen($directive) < $this->compress)) {
$directive_disp = $directive;
} else {
$directive_disp = substr($directive, 0, $this->compress - 2) . '...';
$attr['title'] = $directive;
}
$ret .= $this->element(
'label',
$directive_disp,
// component printers must create an element with this id
$attr
);
if ($this->docURL) $ret .= $this->end('a');
$ret .= $this->end('th');
$ret .= $this->start('td');
$def = $this->config->def->info["$ns.$directive"];
if (is_int($def)) {
$allow_null = $def < 0;
$type = abs($def);
} else {
$type = $def->type;
$allow_null = isset($def->allow_null);
}
if (!isset($this->fields[$type])) $type = 0; // default
$type_obj = $this->fields[$type];
if ($allow_null) {
}
$ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config));
$ret .= $this->end('td');
$ret .= $this->end('tr');
}
$ret .= $this->end('tbody');
return $ret;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HTMLPurifier_Printer_ConfigForm::setTextareaDimensions (   $cols = null,
  $rows = null 
)

Sets default column and row size for textareas in sub-printers.

Parameters
$colsInteger columns of textarea, null to use default
$rowsInteger rows of textarea, null to use default

Definition at line 53 of file ConfigForm.php.

{
if ($cols) $this->fields['default']->cols = $cols;
if ($rows) $this->fields['default']->rows = $rows;
}

Field Documentation

HTMLPurifier_Printer_ConfigForm::$compress = false
protected

Whether or not to compress directive names, clipping them off after a certain amount of letters.

False to disable or integer letters before clipping.

Definition at line 29 of file ConfigForm.php.

Referenced by __construct().

HTMLPurifier_Printer_ConfigForm::$docURL
protected

Documentation URL, can have fragment tagged on end.

Definition at line 17 of file ConfigForm.php.

HTMLPurifier_Printer_ConfigForm::$fields = array()
protected

Printers for specific fields.

Definition at line 12 of file ConfigForm.php.

HTMLPurifier_Printer_ConfigForm::$name
protected

Name of form element to stuff config in.

Definition at line 22 of file ConfigForm.php.

Referenced by __construct().


The documentation for this class was generated from the following file: