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