1a1e7c82f0667e564a0d0224f59c8f5cc32d8765
[Packages/TYPO3.CMS.git] / typo3 / sysext / info_pagetsconfig / Classes / Controller / InfoPageTyposcriptConfigController.php
1 <?php
2 namespace TYPO3\CMS\InfoPagetsconfig\Controller;
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 use TYPO3\CMS\Backend\Utility\BackendUtility;
18
19 /**
20 * Page TSconfig viewer
21 *
22 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
23 */
24 class InfoPageTyposcriptConfigController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
25
26 /**
27 * Constructor
28 */
29 public function __construct() {
30 $GLOBALS['LANG']->includeLLFile('EXT:info_pagetsconfig/locallang.xlf');
31 }
32
33 /**
34 * Function menu initialization
35 *
36 * @return array Menu array
37 */
38 public function modMenu() {
39 $modMenuAdd = array(
40 'tsconf_parts' => array(
41 0 => $GLOBALS['LANG']->getLL('tsconf_parts_0'),
42 1 => $GLOBALS['LANG']->getLL('tsconf_parts_1'),
43 '1a' => $GLOBALS['LANG']->getLL('tsconf_parts_1a'),
44 '1b' => $GLOBALS['LANG']->getLL('tsconf_parts_1b'),
45 '1c' => $GLOBALS['LANG']->getLL('tsconf_parts_1c'),
46 '1d' => $GLOBALS['LANG']->getLL('tsconf_parts_1d'),
47 '1e' => $GLOBALS['LANG']->getLL('tsconf_parts_1e'),
48 '1f' => $GLOBALS['LANG']->getLL('tsconf_parts_1f'),
49 '1g' => $GLOBALS['LANG']->getLL('tsconf_parts_1g'),
50 2 => 'RTE.',
51 5 => 'TCEFORM.',
52 6 => 'TCEMAIN.',
53 3 => 'TSFE.',
54 4 => 'user.',
55 99 => $GLOBALS['LANG']->getLL('tsconf_configFields')
56 ),
57 'tsconf_alphaSort' => '1'
58 );
59 if (!$GLOBALS['BE_USER']->isAdmin()) {
60 unset($modMenuAdd['tsconf_parts'][99]);
61 }
62 return $modMenuAdd;
63 }
64
65 /**
66 * Main function of class
67 *
68 * @return string HTML output
69 */
70 public function main() {
71 $menu = BackendUtility::getFuncMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
72 $menu .= '<div class="checkbox"><label for="checkTsconf_alphaSort">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"') . $GLOBALS['LANG']->getLL('sort_alphabetic', TRUE) . '</label></div>';
73 $menu .= '<br /><br />';
74 $theOutput = $this->pObj->doc->header($GLOBALS['LANG']->getLL('tsconf_title'));
75
76 if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
77 $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, NULL, TRUE);
78 $lines = array();
79 $pUids = array();
80 foreach ($TSparts as $k => $v) {
81 if ($k != 'uid_0') {
82 if ($k == 'defaultPageTSconfig') {
83 $pTitle = '<strong>' . $GLOBALS['LANG']->getLL('editTSconfig_default', TRUE) . '</strong>';
84 $editIcon = '';
85 } else {
86 $pUids[] = substr($k, 4);
87 $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
88 $pTitle = $this->pObj->doc->getHeader('pages', $row, '', FALSE);
89 $editIdList = substr($k, 4);
90 $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=TSconfig';
91 $onclickUrl = BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'], '');
92 $editIcon = '<a href="#" onclick="' . htmlspecialchars($onclickUrl) . '" title="' . $GLOBALS['LANG']->getLL('editTSconfig', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open') . '</a>';
93 }
94 $TScontent = nl2br(htmlspecialchars(trim($v) . chr(10)));
95 $tsparser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
96 $tsparser->lineNumberOffset = 0;
97 $TScontent = $tsparser->doSyntaxHighlight(trim($v) . LF);
98 $lines[] = '
99 <tr><td nowrap="nowrap" class="bgColor5">' . $pTitle . '</td></tr>
100 <tr><td nowrap="nowrap" class="bgColor4">' . $TScontent . $editIcon . '</td></tr>
101 <tr><td>&nbsp;</td></tr>
102 ';
103 }
104 }
105 if (count($pUids)) {
106 $params = '&edit[pages][' . implode(',', $pUids) . ']=edit&columnsOnly=TSconfig';
107 $onclickUrl = BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'], '');
108 $editIcon = '<a href="#" onclick="' . htmlspecialchars($onclickUrl) . '" title="' . $GLOBALS['LANG']->getLL('editTSconfig_all', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open') . '<strong>' . $GLOBALS['LANG']->getLL('editTSconfig_all', TRUE) . '</strong>' . '</a>';
109 } else {
110 $editIcon = '';
111 }
112 $theOutput .= $this->pObj->doc->section('', BackendUtility::cshItem(('_MOD_' . $GLOBALS['MCONF']['name']), 'tsconfig_edit', $GLOBALS['BACK_PATH'], '|<br />') . $menu . '
113 <br /><br />
114
115 <!-- Edit fields: -->
116 <table border="0" cellpadding="0" cellspacing="1">' . implode('', $lines) . '</table><br />' . $editIcon, 0, 1);
117
118 } else {
119 // Defined global here!
120 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
121
122 // Do not log time-performance information
123 $tmpl->tt_track = 0;
124 $tmpl->fixedLgd = 0;
125 $tmpl->linkObjects = 0;
126 $tmpl->bType = '';
127 $tmpl->ext_expandAllNotes = 1;
128 $tmpl->ext_noPMicons = 1;
129
130 switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
131 case '1':
132 $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
133 break;
134 case '1a':
135 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
136 break;
137 case '1b':
138 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
139 break;
140 case '1c':
141 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
142 break;
143 case '1d':
144 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
145 break;
146 case '1e':
147 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
148 break;
149 case '1f':
150 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
151 break;
152 case '1g':
153 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
154 break;
155 case '2':
156 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
157 break;
158 case '5':
159 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
160 break;
161 case '6':
162 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
163 break;
164 case '3':
165 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
166 break;
167 case '4':
168 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
169 break;
170 default:
171 $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
172 }
173
174 $modTSconfig = $modTSconfig['properties'];
175 if (!is_array($modTSconfig)) {
176 $modTSconfig = array();
177 }
178
179 $csh = BackendUtility::cshItem('_MOD_' . $GLOBALS['MCONF']['name'], 'tsconfig_hierarchy', $GLOBALS['BACK_PATH'], '|<br />');
180 $tree = $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']);
181
182 $theOutput .= $this->pObj->doc->section(
183 '',
184 $csh .
185 $menu .
186 '<div class="nowrap">' . $tree . '</div>',
187 0,
188 1
189 );
190 }
191
192 return $theOutput;
193 }
194
195 }