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