45c6e38065ade4fa1cc348a9d2fbd78e57a01e54
[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 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Lang\LanguageService;
19 use TYPO3\CMS\Reports\Status as ReportStatus;
20 use TYPO3\CMS\Reports\StatusProviderInterface;
21
22 /**
23 * Performs basic checks about the TYPO3 install
24 */
25 class Typo3Status implements StatusProviderInterface
26 {
27 /**
28 * Returns the status for this report
29 *
30 * @return array List of statuses
31 */
32 public function getStatus()
33 {
34 $statuses = array(
35 'oldXclassStatus' => $this->getOldXclassUsageStatus(),
36 'registeredXclass' => $this->getRegisteredXclassStatus(),
37 'compatibility6' => $this->getCompatibility6Status(),
38 );
39 return $statuses;
40 }
41
42 /**
43 * Check for usage of old way of implementing XCLASSes
44 *
45 * @return \TYPO3\CMS\Reports\Status
46 */
47 protected function getOldXclassUsageStatus()
48 {
49 $message = '';
50 $value = $this->getLanguageService()->getLL('status_none');
51 $severity = ReportStatus::OK;
52
53 $xclasses = array_merge(
54 (array)$GLOBALS['TYPO3_CONF_VARS']['BE']['XCLASS'],
55 (array)$GLOBALS['TYPO3_CONF_VARS']['FE']['XCLASS']
56 );
57
58 $numberOfXclasses = count($xclasses);
59 if ($numberOfXclasses > 0) {
60 $value = sprintf($this->getLanguageService()->getLL('status_oldXclassUsageFound'), $numberOfXclasses);
61 $message = $this->getLanguageService()->getLL('status_oldXclassUsageFound_message') . '<br />';
62 $message .= '<ol><li>' . implode('</li><li>', $xclasses) . '</li></ol>';
63 $severity = ReportStatus::NOTICE;
64 }
65
66 return GeneralUtility::makeInstance(
67 ReportStatus::class,
68 $this->getLanguageService()->getLL('status_oldXclassUsage'),
69 $value,
70 $message,
71 $severity
72 );
73 }
74
75 /**
76 * List any Xclasses registered in the system
77 *
78 * @return \TYPO3\CMS\Reports\Status
79 */
80 protected function getRegisteredXclassStatus()
81 {
82 $message = '';
83 $value = $this->getLanguageService()->getLL('status_none');
84 $severity = ReportStatus::OK;
85
86 $xclassFoundArray = array();
87 if (array_key_exists('Objects', $GLOBALS['TYPO3_CONF_VARS']['SYS'])) {
88 foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'] as $originalClass => $override) {
89 if (array_key_exists('className', $override)) {
90 $xclassFoundArray[$originalClass] = $override['className'];
91 }
92 }
93 }
94 if (!empty($xclassFoundArray)) {
95 $value = $this->getLanguageService()->getLL('status_xclassUsageFound');
96 $message = $this->getLanguageService()->getLL('status_xclassUsageFound_message') . '<br />';
97 $message .= '<ol>';
98 foreach ($xclassFoundArray as $originalClass => $xClassName) {
99 $messageDetail = sprintf(
100 $this->getLanguageService()->getLL('status_xclassUsageFound_message_detail'),
101 $originalClass,
102 $xClassName
103 );
104 $message .= '<li>' . $messageDetail . '</li>';
105 }
106 $message .= '</ol>';
107 $severity = ReportStatus::NOTICE;
108 }
109
110 return GeneralUtility::makeInstance(
111 ReportStatus::class,
112 $this->getLanguageService()->getLL('status_xclassUsage'),
113 $value,
114 $message,
115 $severity
116 );
117 }
118
119 /**
120 * Check for usage of EXT:compatibility6
121 *
122 * @return \TYPO3\CMS\Reports\Status
123 */
124 protected function getCompatibility6Status()
125 {
126 $message = '';
127 $value = $this->getLanguageService()->getLL('status_disabled');
128 $severity = ReportStatus::OK;
129
130 if (ExtensionManagementUtility::isLoaded('compatibility6')) {
131 $value = $this->getLanguageService()->getLL('status_enabled');
132 $message = $this->getLanguageService()->getLL('status_compatibility6Usage_message');
133 $severity = ReportStatus::WARNING;
134 }
135
136 return GeneralUtility::makeInstance(
137 ReportStatus::class,
138 $this->getLanguageService()->getLL('status_compatibility6Usage'),
139 $value,
140 $message,
141 $severity
142 );
143 }
144
145 /**
146 * @return LanguageService
147 */
148 protected function getLanguageService()
149 {
150 return $GLOBALS['LANG'];
151 }
152 }