101c1cdd1b8dc362f8389dd5f3469ba78dc2225d
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Format / UrlencodeViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13 /**
14 * Encodes the given string according to http://www.faqs.org/rfcs/rfc3986.html (applying PHPs rawurlencode() function)
15 *
16 * @see http://www.php.net/manual/function.rawurlencode.php
17 * @api
18 */
19 class UrlencodeViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
20
21 /**
22 * Disable the escaping interceptor because otherwise the child nodes would be escaped before this view helper
23 * can decode the text's entities.
24 *
25 * @var boolean
26 */
27 protected $escapingInterceptorEnabled = FALSE;
28
29 /**
30 * Escapes special characters with their escaped counterparts as needed using PHPs rawurlencode() function.
31 *
32 * @param string $value string to format
33 * @see http://www.php.net/manual/function.rawurlencode.php
34 * @api
35 */
36 public function render($value = NULL) {
37 if ($value === NULL) {
38 $value = $this->renderChildren();
39 }
40 if (!is_string($value)) {
41 return $value;
42 }
43 return rawurlencode($value);
44 }
45 }
46
47 ?>