[TASK] Sync CMS Fluid with Flow Fluid 1.1 (part1)
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Format / StripTagsViewHelper.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 /**
15 * Removes tags from the given string (applying PHPs strip_tags() function)
16 *
17 * @see http://www.php.net/manual/function.strip-tags.php
18 *
19 * = Examples =
20 *
21 * <code title="default notation">
22 * <f:format.stripTags>Some Text with <b>Tags</b> and an &Uuml;mlaut.</f:format.stripTags>
23 * </code>
24 * <output>
25 * Some Text with Tags and an &Uuml;mlaut. (strip_tags() applied. Note: encoded entities are not decoded)
26 * </output>
27 *
28 * <code title="inline notation">
29 * {text -> f:format.stripTags()}
30 * </code>
31 * <output>
32 * Text without tags (strip_tags() applied)
33 * </output>
34 *
35 * @api
36 */
37 class StripTagsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
38
39 /**
40 * Disable the escaping interceptor because otherwise the child nodes would be escaped before this view helper
41 * can decode the text's entities.
42 *
43 * @var boolean
44 */
45 protected $escapingInterceptorEnabled = FALSE;
46
47 /**
48 * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function.
49 *
50 * @param string $value string to format
51 * @return mixed
52 * @see http://www.php.net/manual/function.strip-tags.php
53 * @api
54 */
55 public function render($value = NULL) {
56 if ($value === NULL) {
57 $value = $this->renderChildren();
58 }
59 if (!is_string($value)) {
60 return $value;
61 }
62 return strip_tags($value);
63 }
64 }
65
66 ?>