b39abe2399308f136b1257afed3cf4b895304bb7
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / Report / Status / Typo3Status.php
1 <?php
2 namespace TYPO3\CMS\Reports\Report\Status;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009-2013 Ingo Renner <ingo@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Performs basic checks about the TYPO3 install
29 *
30 * @author Ingo Renner <ingo@typo3.org>
31 */
32 class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface {
33
34 /**
35 * Returns the status for this report
36 *
37 * @return array List of statuses
38 */
39 public function getStatus() {
40 $statuses = array(
41 'Typo3Version' => $this->getTypo3VersionStatus(),
42 'oldXclassStatus' => $this->getOldXclassUsageStatus(),
43 'registeredXclass' => $this->getRegisteredXclassStatus(),
44 );
45 return $statuses;
46 }
47
48 /**
49 * Simply gets the current TYPO3 version.
50 *
51 * @return \TYPO3\CMS\Reports\Status
52 */
53 protected function getTypo3VersionStatus() {
54 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'TYPO3', TYPO3_version, '', \TYPO3\CMS\Reports\Status::NOTICE);
55 }
56
57 /**
58 * Check for usage of old way of implementing XCLASSes
59 *
60 * @return \TYPO3\CMS\Reports\Status
61 */
62 protected function getOldXclassUsageStatus() {
63 $message = '';
64 $value = $GLOBALS['LANG']->getLL('status_none');
65 $severity = \TYPO3\CMS\Reports\Status::OK;
66
67 $xclasses = array_merge(
68 (array) $GLOBALS['TYPO3_CONF_VARS']['BE']['XCLASS'],
69 (array) $GLOBALS['TYPO3_CONF_VARS']['FE']['XCLASS']
70 );
71
72 $numberOfXclasses = count($xclasses);
73 if ($numberOfXclasses > 0) {
74 $value = sprintf($GLOBALS['LANG']->getLL('status_oldXclassUsageFound'), $numberOfXclasses);
75 $message = $GLOBALS['LANG']->getLL('status_oldXclassUsageFound_message') . '<br />';
76 $message .= '<ol><li>' . implode('</li><li>', $xclasses) . '</li></ol>';
77 $severity = \TYPO3\CMS\Reports\Status::NOTICE;
78 }
79
80 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
81 'TYPO3\\CMS\\Reports\\Status',
82 $GLOBALS['LANG']->getLL('status_oldXclassUsage'),
83 $value,
84 $message,
85 $severity
86 );
87 }
88
89 /**
90 * List any Xclasses registered in the stystem
91 *
92 * @return \TYPO3\CMS\Reports\Status
93 */
94 protected function getRegisteredXclassStatus() {
95 $message = '';
96 $value = $GLOBALS['LANG']->getLL('status_none');
97 $severity = \TYPO3\CMS\Reports\Status::OK;
98
99 $xclassFoundArray = array();
100 if (array_key_exists('Objects', $GLOBALS['TYPO3_CONF_VARS']['SYS'])) {
101 foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'] as $originalClass => $override) {
102 if (array_key_exists('className', $override)) {
103 $xclassFoundArray[$originalClass] = $override['className'];
104 }
105 }
106 }
107 if (count($xclassFoundArray) > 0) {
108 $value = $GLOBALS['LANG']->getLL('status_xclassUsageFound');
109 $message = $GLOBALS['LANG']->getLL('status_xclassUsageFound_message') . '<br />';
110 $message .= '<ol>';
111 foreach ($xclassFoundArray as $originalClass => $xClassName) {
112 $messageDetail = sprintf(
113 $GLOBALS['LANG']->getLL('status_xclassUsageFound_message_detail'),
114 $originalClass,
115 $xClassName
116 );
117 $message .= '<li>' . $messageDetail . '</li>';
118 }
119 $message .= '</ol>';
120 $severity = \TYPO3\CMS\Reports\Status::NOTICE;
121 }
122
123 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
124 'TYPO3\\CMS\\Reports\\Status',
125 $GLOBALS['LANG']->getLL('status_xclassUsage'),
126 $value,
127 $message,
128 $severity
129 );
130 }
131
132 }