1 | <?php |
||
17 | class TemplateHelper |
||
18 | { |
||
19 | /** |
||
20 | * An array of variables to be passed to all templates |
||
21 | * @var array |
||
22 | */ |
||
23 | private $variables = array(); |
||
24 | |||
25 | /** |
||
26 | * Escapes a string for output in an HTML document |
||
27 | * |
||
28 | * @param string $raw |
||
29 | * @return string |
||
30 | */ |
||
31 | 2 | public function escape($raw) |
|
49 | |||
50 | /** |
||
51 | * Escapes a string for output in an HTML document, but preserves |
||
52 | * URIs within it, and converts them to clickable anchor elements. |
||
53 | * |
||
54 | * @param string $raw |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | public function escapeButPreserveUris($raw) |
|
65 | |||
66 | private function getDumper() { |
||
92 | |||
93 | /** |
||
94 | * Format the given value into a human readable string. |
||
95 | * |
||
96 | * @param mixed $value |
||
97 | * @return string |
||
98 | */ |
||
99 | public function dump($value) |
||
118 | |||
119 | /** |
||
120 | * Format the args of the given Frame as a human readable html string |
||
121 | * |
||
122 | * @param Frame $frame |
||
123 | * @return string the rendered html |
||
124 | */ |
||
125 | public function dumpArgs(Frame $frame) { |
||
148 | |||
149 | /** |
||
150 | * Convert a string to a slug version of itself |
||
151 | * |
||
152 | * @param string $original |
||
153 | * @return string |
||
154 | */ |
||
155 | 1 | public function slug($original) |
|
161 | |||
162 | /** |
||
163 | * Given a template path, render it within its own scope. This |
||
164 | * method also accepts an array of additional variables to be |
||
165 | * passed to the template. |
||
166 | * |
||
167 | * @param string $template |
||
168 | * @param array $additionalVariables |
||
169 | */ |
||
170 | 1 | public function render($template, array $additionalVariables = null) |
|
186 | |||
187 | /** |
||
188 | * Sets the variables to be passed to all templates rendered |
||
189 | * by this template helper. |
||
190 | * |
||
191 | * @param array $variables |
||
192 | */ |
||
193 | 1 | public function setVariables(array $variables) |
|
197 | |||
198 | /** |
||
199 | * Sets a single template variable, by its name: |
||
200 | * |
||
201 | * @param string $variableName |
||
202 | * @param mixd $variableValue |
||
203 | */ |
||
204 | 1 | public function setVariable($variableName, $variableValue) |
|
208 | |||
209 | /** |
||
210 | * Gets a single template variable, by its name, or |
||
211 | * $defaultValue if the variable does not exist |
||
212 | * |
||
213 | * @param string $variableName |
||
214 | * @param mixed $defaultValue |
||
215 | * @return mixed |
||
216 | */ |
||
217 | 1 | public function getVariable($variableName, $defaultValue = null) |
|
222 | |||
223 | /** |
||
224 | * Unsets a single template variable, by its name |
||
225 | * |
||
226 | * @param string $variableName |
||
227 | */ |
||
228 | 1 | public function delVariable($variableName) |
|
232 | |||
233 | /** |
||
234 | * Returns all variables for this helper |
||
235 | * |
||
236 | * @return array |
||
237 | */ |
||
238 | 1 | public function getVariables() |
|
242 | } |
||
243 |