![]() |
Pfw_XH
|
Generation of properly escaped HTML. More...
Public Member Functions | |
__construct ($pluginname) | |
Initialize the instance. More... | |
template ($name) | |
Assign a view template. More... | |
data (array $data) | |
Assign view data. More... | |
render () | |
Render the view template. More... | |
escape ($value) | |
Escapes HTML. More... | |
Protected Member Functions | |
text ($key) | |
Return a properly escaped localized language text. More... | |
plural ($key, $count) | |
Return a properly escaped pluralized localized language text. More... | |
Generation of properly escaped HTML.
Example:
(new View($pluginname)) ->template('foo') // assign a template ->data(['bar' => 'baz']) // assign view data ->render(); // render the view
Pfw\View\View::__construct | ( | $pluginname | ) |
Initialize the instance.
$pluginname
is the name of the instantiating plugin, and is used to look up the template
and any language texts.
string | $pluginname |
Pfw\View\View::data | ( | array | $data | ) |
Assign view data.
$data
is an associative array, and its elements are available as local variables in the view template. All values, except booleans, are encapsulated as ViewValue
s to ensure proper HTML escaping which is supposed to happen automagically.
Pfw\View\View::escape | ( | $value | ) |
Escapes HTML.
This method is supposed to be called automagically when needed, but never explicitly.
mixed | $value |
|
protected |
Return a properly escaped pluralized localized language text.
The $key
is suffixed with the appropriate number suffix according to the current language's rules, which works basically the same as gettext's plurals. The suffixed key is then looked up in the active language file of the plugin the view is associated with, and if it is not there it is looked up in Pfw_XH's language file. Additional arguments may be passed to substitute printf-style placeholders in the language text.
string | $key | |
int | $count |
Pfw\View\View::render | ( | ) |
Pfw\View\View::template | ( | $name | ) |
Assign a view template.
The view template is looked up in the views/
folder of the calling plugin with the basename $name.php
.
string | $name |
|
protected |
Return a properly escaped localized language text.
The $key
is looked up in the active language file of the plugin the view is associated with, and if it is not there it is looked up in Pfw_XH's language file. Additional arguments may be passed to substitute printf-style placeholders in the language text.
string | $key |