HtmlViewHelper.php 2.96 KB
Newer Older
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */

/**
 * @package Fluid
 * @subpackage ViewHelpers
 * @version $Id$
 */

/**
 * Renders a string by passing it to a TYPO3 parseFunc.
 * You can either specify a path to the TypoScript setting or set the parseFunc options directly.
 * By default lib.parseFunc_RTE is used to parse the string.
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
26
 *
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
27
 * Example:
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
28
 *
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
29
 * (1) default parameters:
30
 * <f:format.html>foo <b>bar</b>. Some <LINK 1>link</LINK>.</f:format.html>
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
31
32
33
34
 *
 * Result:
 * <p class="bodytext">foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.</p>
 * (depending on your TYPO3 setup)
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
35
 *
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
36
 * (2) custom parseFunc
37
 * <f:format.html parseFuncTSPath="lib.parseFunc">foo <b>bar</b>. Some <LINK 1>link</LINK>.</f:format.html>
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
38
 *
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
39
40
 * Output:
 * foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
41
 *
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
42
43
44
45
46
47
 * @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4198758
 *
 * @package
 * @subpackage
 * @version $Id$
 */
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
48
class Tx_Fluid_ViewHelpers_Format_HtmlViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
49
50
51
52
53
54

	/**
	 * @var	tslib_cObj
	 */
	protected $contentObject;

Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
55
	/**
56
	 * If the escaping interceptor should be disabled inside this ViewHelper, then set this value to FALSE.
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
57
58
59
60
61
	 * This is internal and NO part of the API. It is very likely to change.
	 *
	 * @var boolean
	 * @internal
	 */
62
	protected $escapingInterceptorEnabled = FALSE;
Sebastian Kurfürst's avatar
Fluid:    
Sebastian Kurfürst committed
63

Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
64
65
66
67
68
69
	/**
	 * Constructor. Used to create an instance of tslib_cObj used by the render() method.
	 * @param tslib_cObj $contentObject injector for tslib_cObj (optional)
	 * @return void
	 */
	public function __construct($contentObject = NULL) {
70
		$this->contentObject = $contentObject !== NULL ? $contentObject : t3lib_div::makeInstance('tslib_cObj');
Bastian Waidelich's avatar
Fluid:  
Bastian Waidelich committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	}

	/**
	 * @param string $parseFuncTSPath path to TypoScript parseFunc setup.
	 * @return the parsed string.
	 * @author Bastian Waidelich <bastian@typo3.org>
	 * @author Niels Pardon <mail@niels-pardon.de>
	 */
	public function render($parseFuncTSPath = 'lib.parseFunc_RTE') {
		$value = $this->renderChildren();
		return $this->contentObject->parseFunc($value, array(), '< ' . $parseFuncTSPath);
	}
}

?>