[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / Report / Status / Typo3Status.php
1 <?php
2 namespace TYPO3\CMS\Reports\Report\Status;
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 /**
18 * Performs basic checks about the TYPO3 install
19 *
20 * @author Ingo Renner <ingo@typo3.org>
21 */
22 class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface {
23
24 /**
25 * Returns the status for this report
26 *
27 * @return array List of statuses
28 */
29 public function getStatus() {
30 $statuses = array(
31 'Typo3Version' => $this->getTypo3VersionStatus(),
32 'oldXclassStatus' => $this->getOldXclassUsageStatus(),
33 'registeredXclass' => $this->getRegisteredXclassStatus(),
34 );
35 return $statuses;
36 }
37
38 /**
39 * Simply gets the current TYPO3 version.
40 *
41 * @return \TYPO3\CMS\Reports\Status
42 */
43 protected function getTypo3VersionStatus() {
44 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'TYPO3', TYPO3_version, '', \TYPO3\CMS\Reports\Status::NOTICE);
45 }
46
47 /**
48 * Check for usage of old way of implementing XCLASSes
49 *
50 * @return \TYPO3\CMS\Reports\Status
51 */
52 protected function getOldXclassUsageStatus() {
53 $message = '';
54 $value = $GLOBALS['LANG']->getLL('status_none');
55 $severity = \TYPO3\CMS\Reports\Status::OK;
56
57 $xclasses = array_merge(
58 (array) $GLOBALS['TYPO3_CONF_VARS']['BE']['XCLASS'],
59 (array) $GLOBALS['TYPO3_CONF_VARS']['FE']['XCLASS']
60 );
61
62 $numberOfXclasses = count($xclasses);
63 if ($numberOfXclasses > 0) {
64 $value = sprintf($GLOBALS['LANG']->getLL('status_oldXclassUsageFound'), $numberOfXclasses);
65 $message = $GLOBALS['LANG']->getLL('status_oldXclassUsageFound_message') . '<br />';
66 $message .= '<ol><li>' . implode('</li><li>', $xclasses) . '</li></ol>';
67 $severity = \TYPO3\CMS\Reports\Status::NOTICE;
68 }
69
70 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
71 'TYPO3\\CMS\\Reports\\Status',
72 $GLOBALS['LANG']->getLL('status_oldXclassUsage'),
73 $value,
74 $message,
75 $severity
76 );
77 }
78
79 /**
80 * List any Xclasses registered in the stystem
81 *
82 * @return \TYPO3\CMS\Reports\Status
83 */
84 protected function getRegisteredXclassStatus() {
85 $message = '';
86 $value = $GLOBALS['LANG']->getLL('status_none');
87 $severity = \TYPO3\CMS\Reports\Status::OK;
88
89 $xclassFoundArray = array();
90 if (array_key_exists('Objects', $GLOBALS['TYPO3_CONF_VARS']['SYS'])) {
91 foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'] as $originalClass => $override) {
92 if (array_key_exists('className', $override)) {
93 $xclassFoundArray[$originalClass] = $override['className'];
94 }
95 }
96 }
97 if (count($xclassFoundArray) > 0) {
98 $value = $GLOBALS['LANG']->getLL('status_xclassUsageFound');
99 $message = $GLOBALS['LANG']->getLL('status_xclassUsageFound_message') . '<br />';
100 $message .= '<ol>';
101 foreach ($xclassFoundArray as $originalClass => $xClassName) {
102 $messageDetail = sprintf(
103 $GLOBALS['LANG']->getLL('status_xclassUsageFound_message_detail'),
104 $originalClass,
105 $xClassName
106 );
107 $message .= '<li>' . $messageDetail . '</li>';
108 }
109 $message .= '</ol>';
110 $severity = \TYPO3\CMS\Reports\Status::NOTICE;
111 }
112
113 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
114 'TYPO3\\CMS\\Reports\\Status',
115 $GLOBALS['LANG']->getLL('status_xclassUsage'),
116 $value,
117 $message,
118 $severity
119 );
120 }
121
122 }