e73ad707cf5282e6709b89ed889862afeb7ec225
[Packages/TYPO3.CMS.git] / typo3 / sysext / info_pagetsconfig / Classes / Controller / InfoPageTyposcriptConfigController.php
1 <?php
2 namespace TYPO3\CMS\InfoPagetsconfig\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Backend\Utility\BackendUtility;
31
32 /**
33 * Page TSconfig viewer
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 class InfoPageTyposcriptConfigController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
38
39 /**
40 * Function menu initialization
41 *
42 * @return array Menu array
43 * @todo Define visibility
44 */
45 public function modMenu() {
46 global $LANG;
47 $modMenuAdd = array(
48 'tsconf_parts' => array(
49 0 => $LANG->getLL('tsconf_parts_0'),
50 1 => $LANG->getLL('tsconf_parts_1'),
51 '1a' => $LANG->getLL('tsconf_parts_1a'),
52 '1b' => $LANG->getLL('tsconf_parts_1b'),
53 '1c' => $LANG->getLL('tsconf_parts_1c'),
54 '1d' => $LANG->getLL('tsconf_parts_1d'),
55 '1e' => $LANG->getLL('tsconf_parts_1e'),
56 '1f' => $LANG->getLL('tsconf_parts_1f'),
57 '1g' => $LANG->getLL('tsconf_parts_1g'),
58 2 => 'RTE.',
59 5 => 'TCEFORM.',
60 6 => 'TCEMAIN.',
61 3 => 'TSFE.',
62 4 => 'user.',
63 99 => $LANG->getLL('tsconf_configFields')
64 ),
65 'tsconf_alphaSort' => '1'
66 );
67 if (!$GLOBALS['BE_USER']->isAdmin()) {
68 unset($modMenuAdd['tsconf_parts'][99]);
69 }
70 return $modMenuAdd;
71 }
72
73 /**
74 * Main function of class
75 *
76 * @return string HTML output
77 */
78 public function main() {
79 global $LANG;
80 $menu = BackendUtility::getFuncMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
81 $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"');
82 $menu .= '<br /><br />';
83 $theOutput = $this->pObj->doc->header($LANG->getLL('tsconf_title'));
84
85 if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
86 $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, '', 1);
87 $lines = array();
88 $pUids = array();
89 foreach ($TSparts as $k => $v) {
90 if ($k != 'uid_0') {
91 if ($k == 'defaultPageTSconfig') {
92 $pTitle = '<strong>' . $GLOBALS['LANG']->getLL('editTSconfig_default', 1) . '</strong>';
93 $editIcon = '';
94 } else {
95 $pUids[] = substr($k, 4);
96 $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
97 $pTitle = $this->pObj->doc->getHeader('pages', $row, '', 0);
98 $editIdList = substr($k, 4);
99 $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=TSconfig';
100 $onclickUrl = BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'], '');
101 $editIcon = '<a href="#" onclick="' . htmlspecialchars($onclickUrl) . '" title="' . $GLOBALS['LANG']->getLL('editTSconfig', 1) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open') . '</a>';
102 }
103 $TScontent = nl2br(htmlspecialchars(trim($v) . chr(10)));
104 $tsparser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
105 $tsparser->lineNumberOffset = 0;
106 $TScontent = $tsparser->doSyntaxHighlight(trim($v) . LF, '', 0);
107 $lines[] = '
108 <tr><td nowrap="nowrap" class="bgColor5">' . $pTitle . '</td></tr>
109 <tr><td nowrap="nowrap" class="bgColor4">' . $TScontent . $editIcon . '</td></tr>
110 <tr><td>&nbsp;</td></tr>
111 ';
112 }
113 }
114 if (count($pUids)) {
115 $params = '&edit[pages][' . implode(',', $pUids) . ']=edit&columnsOnly=TSconfig';
116 $onclickUrl = BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'], '');
117 $editIcon = '<a href="#" onclick="' . htmlspecialchars($onclickUrl) . '" title="' . $GLOBALS['LANG']->getLL('editTSconfig_all', 1) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open') . '<strong>' . $GLOBALS['LANG']->getLL('editTSconfig_all', 1) . '</strong>' . '</a>';
118 } else {
119 $editIcon = '';
120 }
121 $theOutput .= $this->pObj->doc->section('', BackendUtility::cshItem(('_MOD_' . $GLOBALS['MCONF']['name']), 'tsconfig_edit', $GLOBALS['BACK_PATH'], '|<br />') . $menu . '
122 <br /><br />
123
124 <!-- Edit fields: -->
125 <table border="0" cellpadding="0" cellspacing="1">' . implode('', $lines) . '</table><br />' . $editIcon, 0, 1);
126
127 } else {
128 // Defined global here!
129 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
130
131 // Do not log time-performance information
132 $tmpl->tt_track = 0;
133 $tmpl->fixedLgd = 0;
134 $tmpl->linkObjects = 0;
135 $tmpl->bType = '';
136 $tmpl->ext_expandAllNotes = 1;
137 $tmpl->ext_noPMicons = 1;
138
139 switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
140 case '1':
141 $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
142 break;
143 case '1a':
144 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
145 break;
146 case '1b':
147 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
148 break;
149 case '1c':
150 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
151 break;
152 case '1d':
153 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
154 break;
155 case '1e':
156 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
157 break;
158 case '1f':
159 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
160 break;
161 case '1g':
162 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
163 break;
164 case '2':
165 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
166 break;
167 case '5':
168 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
169 break;
170 case '6':
171 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
172 break;
173 case '3':
174 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
175 break;
176 case '4':
177 $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
178 break;
179 default:
180 $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
181 }
182
183 $modTSconfig = $modTSconfig['properties'];
184 if (!is_array($modTSconfig)) {
185 $modTSconfig = array();
186 }
187
188 $csh = BackendUtility::cshItem('_MOD_' . $GLOBALS['MCONF']['name'], 'tsconfig_hierarchy', $GLOBALS['BACK_PATH'], '|<br />');
189 $tree = $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']);
190
191 $theOutput .= $this->pObj->doc->section(
192 '',
193 $csh .
194 $menu .
195 '<div class="nowrap">' . $tree . '</div>',
196 0,
197 1
198 );
199 }
200
201 return $theOutput;
202 }
203
204 }
205
206
207 ?>