ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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. More...
 
 render ($config, $allowed=true, $render_controls=true)
 Returns HTML output for a configuration form. More...
 
- Public Member Functions inherited from HTMLPurifier_Printer
 __construct ()
 Initialize $generator. More...
 
 prepareGenerator ($config)
 Give generator necessary configuration if possible. More...
 

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Todo:
Rewrite to use Interchange objects

Definition at line 6 of file ConfigForm.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 40 of file ConfigForm.php.

References $compress, $name, HTMLPurifier_VarParser\C_BOOL, and fields.

44  {
45  parent::__construct();
46  $this->docURL = $doc_url;
47  $this->name = $name;
48  $this->compress = $compress;
49  // initialize sub-printers
52  }
Swiss-army knife configuration form field printer.
Definition: ConfigForm.php:278
$errors fields
Definition: imgupload.php:51
Bool form field printer.
Definition: ConfigForm.php:385
$name
Name of form element to stuff config in.
Definition: ConfigForm.php:25
$compress
Whether or not to compress directive names, clipping them off after a certain amount of letters...
Definition: ConfigForm.php:33

Member Function Documentation

◆ getCSS()

static HTMLPurifier_Printer_ConfigForm::getCSS ( )
static

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

Definition at line 72 of file ConfigForm.php.

73  {
74  return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css');
75  }

◆ getJavaScript()

static HTMLPurifier_Printer_ConfigForm::getJavaScript ( )
static

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

Definition at line 80 of file ConfigForm.php.

81  {
82  return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js');
83  }

◆ render()

HTMLPurifier_Printer_ConfigForm::render (   $config,
  $allowed = true,
  $render_controls = true 
)

Returns HTML output for a configuration form.

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

Definition at line 93 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().

94  {
95  if (is_array($config) && isset($config[0])) {
96  $gen_config = $config[0];
97  $config = $config[1];
98  } else {
99  $gen_config = $config;
100  }
101 
102  $this->config = $config;
103  $this->genConfig = $gen_config;
104  $this->prepareGenerator($gen_config);
105 
107  $all = array();
108  foreach ($allowed as $key) {
109  list($ns, $directive) = $key;
110  $all[$ns][$directive] = $config->get($ns . '.' . $directive);
111  }
112 
113  $ret = '';
114  $ret .= $this->start('table', array('class' => 'hp-config'));
115  $ret .= $this->start('thead');
116  $ret .= $this->start('tr');
117  $ret .= $this->element('th', 'Directive', array('class' => 'hp-directive'));
118  $ret .= $this->element('th', 'Value', array('class' => 'hp-value'));
119  $ret .= $this->end('tr');
120  $ret .= $this->end('thead');
121  foreach ($all as $ns => $directives) {
122  $ret .= $this->renderNamespace($ns, $directives);
123  }
124  if ($render_controls) {
125  $ret .= $this->start('tbody');
126  $ret .= $this->start('tr');
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>]';
130  $ret .= $this->end('td');
131  $ret .= $this->end('tr');
132  $ret .= $this->end('tbody');
133  }
134  $ret .= $this->end('table');
135  return $ret;
136  }
renderNamespace($ns, $directives)
Renders a single namespace.
Definition: ConfigForm.php:144
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:51
elementEmpty($tag, $attr=array())
Definition: Printer.php:90
prepareGenerator($config)
Give generator necessary configuration if possible.
Definition: Printer.php:32
end($tag)
Returns an end tag.
Definition: Printer.php:63
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
Definition: Printer.php:78
$ret
Definition: parser.php:6
$config
For easy access.
Definition: Printer.php:19
static getAllowedDirectivesForForm($allowed, $schema=null)
Returns a list of array(namespace, directive) for all directives that are allowed in a web-form conte...
Definition: Config.php:708
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ renderNamespace()

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

Renders a single namespace.

Parameters
$nsString namespace name
array$directivesarray of directives to values
Returns
string

Definition at line 144 of file ConfigForm.php.

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

Referenced by render().

145  {
146  $ret = '';
147  $ret .= $this->start('tbody', array('class' => 'namespace'));
148  $ret .= $this->start('tr');
149  $ret .= $this->element('th', $ns, array('colspan' => 2));
150  $ret .= $this->end('tr');
151  $ret .= $this->end('tbody');
152  $ret .= $this->start('tbody');
153  foreach ($directives as $directive => $value) {
154  $ret .= $this->start('tr');
155  $ret .= $this->start('th');
156  if ($this->docURL) {
157  $url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL);
158  $ret .= $this->start('a', array('href' => $url));
159  }
160  $attr = array('for' => "{$this->name}:$ns.$directive");
161 
162  // crop directive name if it's too long
163  if (!$this->compress || (strlen($directive) < $this->compress)) {
164  $directive_disp = $directive;
165  } else {
166  $directive_disp = substr($directive, 0, $this->compress - 2) . '...';
167  $attr['title'] = $directive;
168  }
169 
170  $ret .= $this->element(
171  'label',
172  $directive_disp,
173  // component printers must create an element with this id
174  $attr
175  );
176  if ($this->docURL) {
177  $ret .= $this->end('a');
178  }
179  $ret .= $this->end('th');
180 
181  $ret .= $this->start('td');
182  $def = $this->config->def->info["$ns.$directive"];
183  if (is_int($def)) {
184  $allow_null = $def < 0;
185  $type = abs($def);
186  } else {
187  $type = $def->type;
188  $allow_null = isset($def->allow_null);
189  }
190  if (!isset($this->fields[$type])) {
191  $type = 0;
192  } // default
193  $type_obj = $this->fields[$type];
194  if ($allow_null) {
195  $type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj);
196  }
197  $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config));
198  $ret .= $this->end('td');
199  $ret .= $this->end('tr');
200  }
201  $ret .= $this->end('tbody');
202  return $ret;
203  }
Printer decorator for directives that accept null.
Definition: ConfigForm.php:210
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:51
$type
end($tag)
Returns an end tag.
Definition: Printer.php:63
$errors fields
Definition: imgupload.php:51
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
Definition: Printer.php:78
$ret
Definition: parser.php:6
$def
Definition: croninfo.php:21
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTextareaDimensions()

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 59 of file ConfigForm.php.

References $cols, $rows, and fields.

60  {
61  if ($cols) {
62  $this->fields['default']->cols = $cols;
63  }
64  if ($rows) {
65  $this->fields['default']->rows = $rows;
66  }
67  }
$errors fields
Definition: imgupload.php:51
$rows
Definition: xhr_table.php:10
$cols
Definition: xhr_table.php:11

Field Documentation

◆ $compress

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. bool

Definition at line 33 of file ConfigForm.php.

Referenced by __construct().

◆ $docURL

HTMLPurifier_Printer_ConfigForm::$docURL
protected

Documentation URL, can have fragment tagged on end.

string

Definition at line 19 of file ConfigForm.php.

◆ $fields

HTMLPurifier_Printer_ConfigForm::$fields = array()
protected

Printers for specific fields.

HTMLPurifier_Printer[]

Definition at line 13 of file ConfigForm.php.

◆ $name

HTMLPurifier_Printer_ConfigForm::$name
protected

Name of form element to stuff config in.

string

Definition at line 25 of file ConfigForm.php.

Referenced by __construct(), and HTMLPurifier_Printer_ConfigForm_NullDecorator\render().


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