[CLEANUP] Rework/simplify copyright header and remove @package
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Format / HtmlViewHelper.php
index 192092f..9d8c431 100644 (file)
@@ -1,19 +1,17 @@
 <?php
+namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
 
-/*                                                                        *
- * 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.                                       *
- *                                                                        */
-
-/**
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
  */
 
 /**
  * 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.
  *
- * Example:
+ * == Examples ==
  *
- * (1) default parameters:
+ * <code title="Default parameters">
  * <f:format.html>foo <b>bar</b>. Some <LINK 1>link</LINK>.</f:format.html>
- *
- * Result:
+ * </code>
+ * <output>
  * <p class="bodytext">foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.</p>
  * (depending on your TYPO3 setup)
+ * </output>
  *
- * (2) custom parseFunc
+ * <code title="Custom parseFunc">
  * <f:format.html parseFuncTSPath="lib.parseFunc">foo <b>bar</b>. Some <LINK 1>link</LINK>.</f:format.html>
+ * </code>
+ * <output>
+ * foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.
+ * </output>
  *
- * Output:
+ * <code title="Inline notation">
+ * {someText -> f:format.html(parseFuncTSPath: 'lib.parseFunc')}
+ * </code>
+ * <output>
  * foo <b>bar</b>. Some <a href="index.php?id=1" >link</a>.
+ * </output>
  *
  * @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4198758
- *
  */
-class Tx_Fluid_ViewHelpers_Format_HtmlViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+class HtmlViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
 
        /**
-        * @var tslib_cObj
+        * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
         */
        protected $contentObject;
 
        /**
-        * @var t3lib_fe contains a backup of the current $GLOBALS['TSFE'] if used in BE mode
+        * @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController contains a backup of the current $GLOBALS['TSFE'] if used in BE mode
         */
        protected $tsfeBackup;
 
@@ -61,28 +67,29 @@ class Tx_Fluid_ViewHelpers_Format_HtmlViewHelper extends Tx_Fluid_Core_ViewHelpe
        protected $escapingInterceptorEnabled = FALSE;
 
        /**
-        * Constructor. Used to create an instance of tslib_cObj used by the render() method.
-        * @param tslib_cObj $contentObject injector for tslib_cObj (optional)
+        * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
+        */
+       protected $configurationManager;
+
+       /**
+        * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
         * @return void
         */
-       public function __construct($contentObject = NULL) {
-               $this->contentObject = $contentObject !== NULL ? $contentObject : t3lib_div::makeInstance('tslib_cObj');
+       public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager) {
+               $this->configurationManager = $configurationManager;
+               $this->contentObject = $this->configurationManager->getContentObject();
        }
 
        /**
         * @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>
+        * @return string the parsed string.
         */
        public function render($parseFuncTSPath = 'lib.parseFunc_RTE') {
                if (TYPO3_MODE === 'BE') {
                        $this->simulateFrontendEnvironment();
                }
-
                $value = $this->renderChildren();
                $content = $this->contentObject->parseFunc($value, array(), '< ' . $parseFuncTSPath);
-
                if (TYPO3_MODE === 'BE') {
                        $this->resetFrontendEnvironment();
                }
@@ -91,28 +98,24 @@ class Tx_Fluid_ViewHelpers_Format_HtmlViewHelper extends Tx_Fluid_Core_ViewHelpe
 
        /**
         * Copies the specified parseFunc configuration to $GLOBALS['TSFE']->tmpl->setup in Backend mode
-        * This somewhat hacky work around is currently needed because the parseFunc() function of tslib_cObj relies on those variables to be set
+        * This somewhat hacky work around is currently needed because the parseFunc() function of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer relies on those variables to be set
         *
         * @return void
-        * @author Bastian Waidelich <bastian@typo3.org>
         */
        protected function simulateFrontendEnvironment() {
                $this->tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : NULL;
-               $configurationManager = Tx_Extbase_Dispatcher::getConfigurationManager();
-               $GLOBALS['TSFE'] = new stdClass();
-               $GLOBALS['TSFE']->tmpl->setup = $configurationManager->loadTypoScriptSetup();
+               $GLOBALS['TSFE'] = new \stdClass();
+               $GLOBALS['TSFE']->tmpl = new \stdClass();
+               $GLOBALS['TSFE']->tmpl->setup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
        }
 
        /**
         * Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
         *
         * @return void
-        * @author Bastian Waidelich <bastian@typo3.org>
         * @see simulateFrontendEnvironment()
         */
        protected function resetFrontendEnvironment() {
                $GLOBALS['TSFE'] = $this->tsfeBackup;
        }
 }
-
-?>
\ No newline at end of file