[TASK] Move PhpInfo utility to a ViewHelper 83/28583/5
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 20 Mar 2014 21:49:53 +0000 (22:49 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 20 Mar 2014 22:01:06 +0000 (23:01 +0100)
Resolves: #57124
Related: #55116
Releases: 6.2
Change-Id: I26ce6a340c06f6dfccf255b9b6c9424d9bd70efb
Reviewed-on: https://review.typo3.org/28583
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
Reviewed-by: Helmut Hummel
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/install/Classes/Controller/Action/Tool/SystemEnvironment.php
typo3/sysext/install/Classes/Utility/PhpInfo.php [deleted file]
typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php [new file with mode: 0644]
typo3/sysext/install/Resources/Private/Templates/Action/Tool/SystemEnvironment.html

index ae8cbc2..23bfbe1 100644 (file)
@@ -46,10 +46,6 @@ class SystemEnvironment extends Action\AbstractAction {
                $sortedStatusObjects = $statusUtility->sortBySeverity($statusObjects);
                $this->view->assign('statusObjectsBySeverity', $sortedStatusObjects);
 
-               /** @var $statusUtility \TYPO3\CMS\Install\Utility\PhpInfo */
-               $phpInfoUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Utility\\PhpInfo');
-               $this->view->assign('phpInfo', $phpInfoUtility->getBodyContent());
-
                return $this->view->render();
        }
 
diff --git a/typo3/sysext/install/Classes/Utility/PhpInfo.php b/typo3/sysext/install/Classes/Utility/PhpInfo.php
deleted file mode 100644 (file)
index 7b07e2b..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\Utility;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2014 Patrick Broens <patrick@patrickbroens.nl>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Utility class for phpinfo()
- *
- * @author Patrick Broens <patrick@patrickbroens.nl>
- */
-class PhpInfo {
-
-       /**
-        * Get the content of the body tag of phpinfo()
-        *
-        * @return string
-        */
-       public function getBodyContent() {
-               return $this->removeAllHtmlOutsideBody(
-                       $this->changeHtmlToHtml5(
-                               $this->getPhpInfo()
-                       )
-               );
-       }
-
-       /**
-        * Get information about PHP's configuration
-        *
-        * @return string HTML page with the configuration options
-        */
-       public function getPhpInfo() {
-               ob_start();
-               phpinfo();
-
-               return ob_get_clean();
-       }
-
-       /**
-        * Remove all HTML outside the body tag from HTML string
-        *
-        * @param string $html Complete HTML markup for page
-        * @return string Content of the body tag
-        */
-       protected function removeAllHtmlOutsideBody($html) {
-                       // Delete anything outside of the body tag and the body tag itself
-               $html = preg_replace('/^.*?<body.*?>/is', '', $html);
-               $html = preg_replace('/<\/body>.*?$/is', '', $html);
-
-               return $html;
-       }
-
-       /**
-        * Change HTML markup to HTML5
-        *
-        * @param string $html HTML markup to be cleaned
-        * @return string
-        */
-       protected function changeHtmlToHtml5($html) {
-                       // Delete obsolete attributes
-               $html = preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
-
-                       // Replace font tag with span
-               $html = str_replace(array('<font', '</font>'), array('<span', '</span>'), $html);
-
-               return $html;
-       }
-}
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php
new file mode 100644 (file)
index 0000000..8b631c7
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+namespace TYPO3\CMS\Install\ViewHelpers;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2014 Patrick Broens <patrick@patrickbroens.nl>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Utility class for phpinfo()
+ *
+ * @author Patrick Broens <patrick@patrickbroens.nl>
+ */
+class PhpInfoViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+
+       /**
+        * Disable the escaping interceptor because otherwise the child nodes would be escaped before this view helper
+        * can decode the text's entities.
+        *
+        * @var boolean
+        */
+       protected $escapingInterceptorEnabled = FALSE;
+
+       /**
+        * Render PHP info
+        *
+        * @return string
+        */
+       public function render() {
+               return $this->removeAllHtmlOutsideBody(
+                       $this->changeHtmlToHtml5(
+                               $this->getPhpInfo()
+                       )
+               );
+       }
+
+       /**
+        * Get information about PHP's configuration
+        *
+        * @return string HTML page with the configuration options
+        */
+       public function getPhpInfo() {
+               ob_start();
+               phpinfo();
+
+               return ob_get_clean();
+       }
+
+       /**
+        * Remove all HTML outside the body tag from HTML string
+        *
+        * @param string $html Complete HTML markup for page
+        * @return string Content of the body tag
+        */
+       protected function removeAllHtmlOutsideBody($html) {
+               // Delete anything outside of the body tag and the body tag itself
+               $html = preg_replace('/^.*?<body.*?>/is', '', $html);
+               $html = preg_replace('/<\/body>.*?$/is', '', $html);
+
+               return $html;
+       }
+
+       /**
+        * Change HTML markup to HTML5
+        *
+        * @param string $html HTML markup to be cleaned
+        * @return string
+        */
+       protected function changeHtmlToHtml5($html) {
+               // Delete obsolete attributes
+               $html = preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
+
+               // Replace font tag with span
+               return str_replace(array('<font', '</font>'), array('<span', '</span>'), $html);
+       }
+}
\ No newline at end of file
index 1ea9ad1..fcc8298 100644 (file)
@@ -18,7 +18,7 @@
 
                <div class="toggleData" style="display:none">
                        <div class="toggleDataContent">
-                               <f:format.raw>{phpInfo}</f:format.raw>
+                               <i:phpInfo />
                        </div>
                </div>
        </div>