[BUGFIX] Inconsistent visual appearance Install Tool 25/28225/5
authorPatrick Broens <patrick@patrickbroens.nl>
Mon, 10 Mar 2014 14:41:01 +0000 (15:41 +0100)
committerFrans Saris <franssaris@gmail.com>
Tue, 11 Mar 2014 17:16:46 +0000 (18:16 +0100)
The install tool function System Environment is not according to the
style sheet of the install tool. This is due to the fact phpinfo() is
called on this page which comes with its own CSS styles. These styles
are influencing the visual appearence of the rest of the page.

This patch adds a new utility class to cleanup the output of phpinfo()
before assigning it to the view. It also comes with our own CSS for
phpinfo().

Change-Id: Ib0b087cae4bf5db723b0e9c3481619c984ef674f
Resolves: #55116
Releases: 6.2
Reviewed-on: https://review.typo3.org/28225
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Frans Saris
Tested-by: Frans Saris
typo3/sysext/install/Classes/Controller/Action/Tool/SystemEnvironment.php
typo3/sysext/install/Classes/Utility/PhpInfo.php [new file with mode: 0644]
typo3/sysext/install/Resources/Public/Stylesheets/Action/Common/Install.css

index 8900adf..ae8cbc2 100644 (file)
@@ -46,11 +46,11 @@ class SystemEnvironment extends Action\AbstractAction {
                $sortedStatusObjects = $statusUtility->sortBySeverity($statusObjects);
                $this->view->assign('statusObjectsBySeverity', $sortedStatusObjects);
 
-               ob_start();
-               phpinfo();
-               $phpInfo = ob_get_clean();
-               $this->view->assign('phpInfo', $phpInfo);
+               /** @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
new file mode 100644 (file)
index 0000000..7b07e2b
--- /dev/null
@@ -0,0 +1,88 @@
+<?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
index 140122d..33057a5 100644 (file)
@@ -856,8 +856,14 @@ button.btn-save:hover {
 .phpinfo hr, .phpinfo table {
        width: 500px;
 }
+.phpinfo table {
+       border-collapse: collapse;
+}
 .phpinfo td, .phpinfo th {
+       border: 1px solid #000000;
        font-size: 11px;
+       vertical-align: baseline;
+       padding: 2px 4px;
 }
 .phpinfo td.v {
        word-break: break-all;
@@ -865,5 +871,55 @@ button.btn-save:hover {
 }
 .phpinfo .toggleDataContent {
        margin: 1em 0;
-       overflow: scroll;
+}
+.phpinfo pre {
+       font-family: monospace;
+       margin: 0;
+}
+.phpinfo .center,
+.phpinfo .center th {
+       text-align: center;
+}
+.phpinfo .center table {
+       margin-left: auto;
+       margin-right: auto;
+}
+.phpinfo .center table,
+.phpinfo .p {
+       text-align: left;
+}
+.phpinfo .e,
+.phpinfo .h,
+.phpinfo .v,
+.phpinfo .vr,
+.phpinfo hr {
+       color: #000000;
+}
+.phpinfo .e,
+.phpinfo .h {
+       font-weight: bold;
+}
+.phpinfo .e {
+       background-color: #ccccff;
+}
+.phpinfo .h {
+       background-color: #9999cc;
+}
+.phpinfo .v,
+.phpinfo .vr,
+.phpinfo hr {
+       background-color: #cccccc;
+}
+.phpinfo .vr {
+       text-align: right;
+}
+.phpinfo img,
+.phpinfo hr {
+       border: 0;
+}
+.phpinfo img {
+       float: right;
+}
+.phpinfo hr {
+       height: 1px;
 }