‪TYPO3CMS  10.4
PhpInfoViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
21 
26 class ‪PhpInfoViewHelper extends AbstractViewHelper
27 {
28  use CompileWithRenderStatic;
29 
33  protected ‪$escapeOutput = false;
34 
38  protected ‪$escapeChildren = false;
39 
47  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
48  {
50  self::changeHtmlToHtml5(
51  self::getPhpInfo()
52  )
53  );
54  }
55 
61  protected static function ‪getPhpInfo()
62  {
63  ob_start();
64  phpinfo();
65 
66  return ob_get_clean();
67  }
68 
75  protected static function ‪removeAllHtmlOutsideBody($html)
76  {
77  // Delete anything outside of the body tag and the body tag itself
78  $html = (string)preg_replace('/^.*?<body.*?>/is', '', $html);
79  $html = (string)preg_replace('/<\/body>.*?$/is', '', $html);
80 
81  return $html;
82  }
83 
90  protected static function ‪changeHtmlToHtml5($html)
91  {
92  // Delete obsolete attributes
93  $html = (string)preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
94 
95  // Replace font tag with span
96  return str_replace(['<font', '</font>'], ['<span', '</span>'], $html);
97  }
98 }
‪TYPO3\CMS\Install\ViewHelpers
Definition: Exception.php:16
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper
Definition: PhpInfoViewHelper.php:27
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper\$escapeChildren
‪bool $escapeChildren
Definition: PhpInfoViewHelper.php:35
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PhpInfoViewHelper.php:44
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper\changeHtmlToHtml5
‪static string changeHtmlToHtml5($html)
Definition: PhpInfoViewHelper.php:87
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper\getPhpInfo
‪static string getPhpInfo()
Definition: PhpInfoViewHelper.php:58
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: PhpInfoViewHelper.php:31
‪TYPO3\CMS\Install\ViewHelpers\PhpInfoViewHelper\removeAllHtmlOutsideBody
‪static string removeAllHtmlOutsideBody($html)
Definition: PhpInfoViewHelper.php:72