Fluid:
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Format / HtmlViewHelper.php
1 <?php
2
3 /* *
4 * This script is part of the TYPO3 project - inspiring people to share! *
5 * *
6 * TYPO3 is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU General Public License version 2 as published by *
8 * the Free Software Foundation. *
9 * *
10 * This script is distributed in the hope that it will be useful, but *
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
13 * Public License for more details. *
14 * */
15
16 /**
17 * @package Fluid
18 * @subpackage ViewHelpers
19 * @version $Id$
20 */
21
22 /**
23 * Renders a string by passing it to a TYPO3 parseFunc.
24 * You can either specify a path to the TypoScript setting or set the parseFunc options directly.
25 * By default lib.parseFunc_RTE is used to parse the string.
26 *
27 * Example:
28 *
29 * (1) default parameters:
30 * <f:html>foo <b>bar</b>. Some <LINK 1>link</LINK>.</f:html>
31 *
32 * Result:
33 * <p class="bodytext">foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.</p>
34 * (depending on your TYPO3 setup)
35 *
36 * (2) custom parseFunc
37 * <f:html parseFuncTSPath="lib.parseFunc">foo <b>bar</b>. Some <LINK 1>link</LINK>.</f:html>
38 *
39 * Output:
40 * foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.
41 *
42 * @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4198758
43 *
44 * @package
45 * @subpackage
46 * @version $Id$
47 */
48 class Tx_Fluid_ViewHelpers_Format_HtmlViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
49
50 /**
51 * @var tslib_cObj
52 */
53 protected $contentObject;
54
55 /**
56 * If the ObjectAccessorPostProcessor should be disabled inside this ViewHelper, then set this value to FALSE.
57 * This is internal and NO part of the API. It is very likely to change.
58 *
59 * @var boolean
60 * @internal
61 */
62 protected $objectAccessorPostProcessorEnabled = FALSE;
63
64 /**
65 * Constructor. Used to create an instance of tslib_cObj used by the render() method.
66 * @param tslib_cObj $contentObject injector for tslib_cObj (optional)
67 * @return void
68 */
69 public function __construct($contentObject = NULL) {
70 $this->contentObject = $contentObject !== NULL ? $contentObject : $GLOBALS['TSFE']->cObj;
71 }
72
73 /**
74 * @param string $parseFuncTSPath path to TypoScript parseFunc setup.
75 * @return the parsed string.
76 * @author Bastian Waidelich <bastian@typo3.org>
77 * @author Niels Pardon <mail@niels-pardon.de>
78 */
79 public function render($parseFuncTSPath = 'lib.parseFunc_RTE') {
80 $value = $this->renderChildren();
81 return $this->contentObject->parseFunc($value, array(), '< ' . $parseFuncTSPath);
82 }
83 }
84
85 ?>