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