Completed
Pull Request — master (#51)
by
unknown
25:32 queued 02:38
created

ReportsConfigurationStatus   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 68
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AOE\Languagevisibility;
4
5
/***************************************************************
6
*  Copyright notice
7
*
8
*  (c) 2010 AOE Dev <[email protected]>
9
*  All rights reserved
10
*
11
*  This script is part of the TYPO3 project. The TYPO3 project is
12
*  free software; you can redistribute it and/or modify
13
*  it under the terms of the GNU General Public License as published by
14
*  the Free Software Foundation; either version 2 of the License, or
15
*  (at your option) any later version.
16
*
17
*  The GNU General Public License can be found at
18
*  http://www.gnu.org/copyleft/gpl.html.
19
*
20
*  This script is distributed in the hope that it will be useful,
21
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
*  GNU General Public License for more details.
24
*
25
*  This copyright notice MUST APPEAR in all copies of the script!
26
***************************************************************/
27
28
use TYPO3\CMS\Core\Utility\GeneralUtility;
29
30
/**
31
 * Class tx_languagevisibility_reports_ConfigurationStatus
32
 *
33
 * @package AOE\Languagevisibility\Reports
34
 */
35
class ReportsConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface {
36
37
	/**
38
	 * Determines the Install Tool's status, mainly concerning its protection.
39
	 *
40
	 * @return	array	List of statuses
41
	 * @see typo3/sysext/reports/interfaces/tx_reports_StatusProvider::getStatus()
42
	 */
43
	public function getStatus() {
44
		$statuses = array(
45
			'LangMode' => $this->getLangModes(),
46
		);
47
48
		return $statuses;
49
	}
50
51
	/**
52
	 * Check all "root" sys_templates and try to find the value for config.sys_language_mode
53
	 */
54
	public function getLangModes() {
55
		$message  = '';
56
		$checked = array(
57
			'ok' => array(),
58
			'fail' => array(),
59
		);
60
		$value = $GLOBALS['LANG']->sL('LLL:EXT:languagevisibility/locallang_db.xml:reports.ok.value');
61
		$severity = \TYPO3\CMS\Reports\Status::OK;
62
63
		$rootTpls = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('sys_template', 'root', '1', '');
64
65
		foreach ($rootTpls as $tpl) {
66
			/**
67
			 * @var \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService
68
			 */
69
			$tmpl = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
70
			$tmpl->tt_track = 0;
71
			$tmpl->init();
72
73
			// Gets the rootLine
74
			$sys_page = GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Page\PageRepository');
75
			$rootLine = $sys_page->getRootLine($tpl['pid']);
76
			$tmpl->runThroughTemplates($rootLine, $tpl['uid']);
77
78
			$tplRow = $tmpl->ext_getFirstTemplate($tpl['pid'], $tpl['uid']);
79
			$tmpl->generateConfig();
80
81
			if (!isset($tmpl->setup['config.']['sys_language_mode']) || $tmpl->setup['config.']['sys_language_mode'] != 'ignore') {
82
				$checked['fail'][] = array($tpl['pid'], $tpl['uid'], $tmpl->setup['config.']['sys_language_mode']);
83
			}
84
		}
85
86
		if (count($checked['fail'])) {
87
			$severity = \TYPO3\CMS\Reports\Status::WARNING;
88
			$value = $GLOBALS['LANG']->sL('LLL:EXT:languagevisibility/locallang_db.xml:reports.fail.value');
89
			$message .= $GLOBALS['LANG']->sL('LLL:EXT:languagevisibility/locallang_db.xml:reports.fail.message') . '<br/>';
90
			foreach ($checked['fail'] as $fail) {
91
				$message .= vsprintf($GLOBALS['LANG']->sL('LLL:EXT:languagevisibility/locallang_db.xml:reports.fail.message.detail'), $fail) . '<br />';
92
			}
93
		}
94
95
		return GeneralUtility::makeInstance('TYPO3\CMS\Reports\Status'',
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ')'
Loading history...
96
			'EXT:languagevisibility config.sys_language_mode',
97
			$value,
98
			$message,
99
			$severity
100
		);
101
	}
102
}
103
104
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/languagevisibility/classes/class.tx_languagevisibility_reports_ConfigurationStatus.php'])	{
105
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/languagevisibility/classes/class.tx_languagevisibility_reports_ConfigurationStatus.php']);
106
}
107