TYPO3 CMS  TYPO3_8-7
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 
19 
25 {
29  protected $escapeOutput = false;
30 
34  protected $escapeChildren = false;
35 
41  public function render()
42  {
43  return static::renderStatic(
44  [],
45  $this->buildRenderChildrenClosure(),
46  $this->renderingContext
47  );
48  }
49 
57  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
58  {
59  return self::removeAllHtmlOutsideBody(
60  self::changeHtmlToHtml5(
61  self::getPhpInfo()
62  )
63  );
64  }
65 
71  protected static function getPhpInfo()
72  {
73  ob_start();
74  phpinfo();
75 
76  return ob_get_clean();
77  }
78 
85  protected static function removeAllHtmlOutsideBody($html)
86  {
87  // Delete anything outside of the body tag and the body tag itself
88  $html = preg_replace('/^.*?<body.*?>/is', '', $html);
89  $html = preg_replace('/<\/body>.*?$/is', '', $html);
90 
91  return $html;
92  }
93 
100  protected static function changeHtmlToHtml5($html)
101  {
102  // Delete obsolete attributes
103  $html = preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
104 
105  // Replace font tag with span
106  return str_replace(['<font', '</font>'], ['<span', '</span>'], $html);
107  }
108 }
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)