[TASK] Drop XCLASS registration from DefaultConfiguration
[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 'registeredXclass' => $this->getRegisteredXclassStatus(),
36 'compatibility6' => $this->getCompatibility6Status(),
37 );
38 return $statuses;
39 }
40
41 /**
42 * List any Xclasses registered in the system
43 *
44 * @return \TYPO3\CMS\Reports\Status
45 */
46 protected function getRegisteredXclassStatus()
47 {
48 $message = '';
49 $value = $this->getLanguageService()->getLL('status_none');
50 $severity = ReportStatus::OK;
51
52 $xclassFoundArray = array();
53 if (array_key_exists('Objects', $GLOBALS['TYPO3_CONF_VARS']['SYS'])) {
54 foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'] as $originalClass => $override) {
55 if (array_key_exists('className', $override)) {
56 $xclassFoundArray[$originalClass] = $override['className'];
57 }
58 }
59 }
60 if (!empty($xclassFoundArray)) {
61 $value = $this->getLanguageService()->getLL('status_xclassUsageFound');
62 $message = $this->getLanguageService()->getLL('status_xclassUsageFound_message') . '<br />';
63 $message .= '<ol>';
64 foreach ($xclassFoundArray as $originalClass => $xClassName) {
65 $messageDetail = sprintf(
66 $this->getLanguageService()->getLL('status_xclassUsageFound_message_detail'),
67 $originalClass,
68 $xClassName
69 );
70 $message .= '<li>' . $messageDetail . '</li>';
71 }
72 $message .= '</ol>';
73 $severity = ReportStatus::NOTICE;
74 }
75
76 return GeneralUtility::makeInstance(
77 ReportStatus::class,
78 $this->getLanguageService()->getLL('status_xclassUsage'),
79 $value,
80 $message,
81 $severity
82 );
83 }
84
85 /**
86 * Check for usage of EXT:compatibility6
87 *
88 * @return \TYPO3\CMS\Reports\Status
89 */
90 protected function getCompatibility6Status()
91 {
92 $message = '';
93 $value = $this->getLanguageService()->getLL('status_disabled');
94 $severity = ReportStatus::OK;
95
96 if (ExtensionManagementUtility::isLoaded('compatibility6')) {
97 $value = $this->getLanguageService()->getLL('status_enabled');
98 $message = $this->getLanguageService()->getLL('status_compatibility6Usage_message');
99 $severity = ReportStatus::WARNING;
100 }
101
102 return GeneralUtility::makeInstance(
103 ReportStatus::class,
104 $this->getLanguageService()->getLL('status_compatibility6Usage'),
105 $value,
106 $message,
107 $severity
108 );
109 }
110
111 /**
112 * @return LanguageService
113 */
114 protected function getLanguageService()
115 {
116 return $GLOBALS['LANG'];
117 }
118 }