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