[TASK] Reduce severity for set_no_cache() from core
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / View / AdminPanelView.php
1 <?php
2 namespace TYPO3\CMS\Frontend\View;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2008-2013 Jeff Segars <jeff@webempoweredchurch.org>
8 * (c) 2008-2013 David Slayback <dave@webempoweredchurch.org>
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 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the scri.pt!
29 ***************************************************************/
30 /**
31 * View class for the admin panel in frontend editing.
32 *
33 * @author Jeff Segars <jeff@webempoweredchurch.org>
34 * @author David Slayback <dave@webempoweredchurch.org>
35 * @author Dmitry Dulepov <dmitry@typo3.org>
36 */
37 class AdminPanelView {
38
39 /**
40 * Determines whether the update button should be shown.
41 *
42 * @var boolean
43 */
44 protected $extNeedUpdate = FALSE;
45
46 /**
47 * Force preview?
48 *
49 * @var boolean
50 */
51 protected $ext_forcePreview = FALSE;
52
53 /**
54 * Constructor
55 */
56 public function __construct() {
57 $this->initialize();
58 }
59
60 /*****************************************************
61 *
62 * Admin Panel Configuration/Initialization
63 *
64 ****************************************************/
65 /**
66 * Initializes settings for the admin panel.
67 *
68 * @return void
69 */
70 public function initialize() {
71 $this->saveConfigOptions();
72 // Setting some values based on the admin panel
73 $GLOBALS['TSFE']->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
74 $GLOBALS['TSFE']->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
75 $GLOBALS['TSFE']->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
76 if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
77 // Do not override if the value is already set in \TYPO3\CMS\Core\Database\DatabaseConnection
78 if ($GLOBALS['TYPO3_DB']->explainOutput == 0) {
79 // Enable execution of EXPLAIN SELECT queries
80 $GLOBALS['TYPO3_DB']->explainOutput = 3;
81 }
82 }
83 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_editIcons')) {
84 $GLOBALS['TSFE']->displayFieldEditIcons = 1;
85 $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] = 1;
86 }
87 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simUser')) {
88 $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simUser'));
89 $this->ext_forcePreview = TRUE;
90 }
91 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simTime')) {
92 $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate'] = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_simTime'));
93 $this->ext_forcePreview = TRUE;
94 }
95 if ($GLOBALS['TSFE']->forceTemplateParsing) {
96 $GLOBALS['TSFE']->set_no_cache('Admin Panel: Force template parsing', TRUE);
97 } elseif ($GLOBALS['TSFE']->displayEditIcons) {
98 $GLOBALS['TSFE']->set_no_cache('Admin Panel: Display edit icons', TRUE);
99 } elseif ($GLOBALS['TSFE']->displayFieldEditIcons) {
100 $GLOBALS['TSFE']->set_no_cache('Admin Panel: Display field edit icons', TRUE);
101 }
102 }
103
104 /**
105 * Obtains header data for the admin panel.
106 *
107 * @return string
108 */
109 public function getAdminPanelHeaderData() {
110 $result = '';
111 // Include BE styles
112 if (!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
113 $result = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) . '" />';
114 }
115 return $result;
116 }
117
118 /**
119 * Checks if a Admin Panel section ("module") is available for the user. If so, TRUE is returned.
120 *
121 * @param string $key The module key, eg. "edit", "preview", "info" etc.
122 * @return boolean
123 */
124 public function isAdminModuleEnabled($key) {
125 $result = FALSE;
126 // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
127 if ($key == 'preview' && $this->ext_forcePreview) {
128 $result = TRUE;
129 }
130 // If key is not set, only "all" is checked
131 if ($GLOBALS['BE_USER']->extAdminConfig['enable.']['all']) {
132 $result = TRUE;
133 }
134 if ($GLOBALS['BE_USER']->extAdminConfig['enable.'][$key]) {
135 $result = TRUE;
136 }
137 return $result;
138 }
139
140 /**
141 * Saves any change in settings made in the Admin Panel.
142 * Called from index_ts.php right after access check for the Admin Panel
143 *
144 * @return void
145 */
146 public function saveConfigOptions() {
147 $input = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('TSFE_ADMIN_PANEL');
148 if (is_array($input)) {
149 // Setting
150 $GLOBALS['BE_USER']->uc['TSFE_adminConfig'] = array_merge(!is_array($GLOBALS['BE_USER']->uc['TSFE_adminConfig']) ? array() : $GLOBALS['BE_USER']->uc['TSFE_adminConfig'], $input);
151 // Candidate for \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge() if integer-keys will some day make trouble...
152 unset($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['action']);
153 // Actions:
154 if ($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) {
155 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
156 $theStartId = intval($input['cache_clearCacheId']);
157 $GLOBALS['TSFE']->clearPageCacheContent_pidList($GLOBALS['BE_USER']->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $GLOBALS['BE_USER']->getPagePermsClause(1)) . $theStartId);
158 }
159 // Saving
160 $GLOBALS['BE_USER']->writeUC();
161 }
162 $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
163 if ($this->extGetFeAdminValue('cache', 'noCache')) {
164 $GLOBALS['TSFE']->set_no_cache('Admin Panel: No Caching', TRUE);
165 }
166 }
167
168 /**
169 * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
170 *
171 * @param string $sectionName Module key
172 * @param string $val Setting key
173 * @return string The setting value
174 */
175 public function extGetFeAdminValue($sectionName, $val = '') {
176 // Check if module is enabled.
177 if ($this->isAdminModuleEnabled($sectionName)) {
178 // Exceptions where the values can be overridden from backend:
179 // deprecated
180 if ($sectionName . '_' . $val == 'edit_displayIcons' && $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
181 return TRUE;
182 }
183 if ($sectionName . '_' . $val == 'edit_displayFieldIcons' && $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
184 return TRUE;
185 }
186 // Override all settings with user TSconfig
187 if ($val && $GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName . '.'][$val]) {
188 return $GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName . '.'][$val];
189 }
190 if ($GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName]) {
191 return $GLOBALS['BE_USER']->extAdminConfig['override.'][$sectionName];
192 }
193 $retVal = $val ? $GLOBALS['BE_USER']->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
194 if ($sectionName == 'preview' && $this->ext_forcePreview) {
195 return !$val ? TRUE : $retVal;
196 }
197 // Regular check:
198 // See if the menu is expanded!
199 if ($this->isAdminModuleOpen($sectionName)) {
200 return $retVal;
201 }
202 }
203 }
204
205 /**
206 * Enables the force preview option.
207 *
208 * @return void
209 */
210 public function forcePreview() {
211 $this->ext_forcePreview = TRUE;
212 }
213
214 /**
215 * Returns TRUE if admin panel module is open
216 *
217 * @param string $pre Module key
218 * @return boolean TRUE, if the admin panel is open for the specified admin panel module key.
219 */
220 public function isAdminModuleOpen($pre) {
221 return $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] && $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre];
222 }
223
224 /*****************************************************
225 *
226 * Admin Panel Rendering
227 *
228 ****************************************************/
229 /**
230 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
231 *
232 * @return string HTML for the Admin Panel
233 */
234 public function display() {
235 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.xlf');
236 $moduleContent = '';
237 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
238 if ($this->isAdminModuleEnabled('preview')) {
239 $moduleContent .= $this->getPreviewModule();
240 }
241 if ($this->isAdminModuleEnabled('cache')) {
242 $moduleContent .= $this->getCacheModule();
243 }
244 if ($this->isAdminModuleEnabled('edit')) {
245 $moduleContent .= $this->getEditModule();
246 }
247 if ($this->isAdminModuleEnabled('tsdebug')) {
248 $moduleContent .= $this->getTSDebugModule();
249 }
250 if ($this->isAdminModuleEnabled('info')) {
251 $moduleContent .= $this->getInfoModule();
252 }
253 }
254 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
255 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
256 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
257 if (!$hookObject instanceof \TYPO3\CMS\Frontend\View\AdminPanelViewHookInterface) {
258 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Frontend\\View\\AdminPanelViewHookInterface', 1311942539);
259 }
260 $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
261 }
262 }
263 $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' . htmlspecialchars($GLOBALS['BE_USER']->user['username']) . '</span>';
264 $isVisible = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'];
265 $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
266 $header = '<tr class="typo3-adminPanel-hRow">' . '<td colspan="2" id="typo3-adminPanel-header" class="' . $cssClassName . '">' . '<span class="typo3-adminPanel-header-title">' . $row . '</span>' . $this->linkSectionHeader('top', '<span class="typo3-adminPanel-header-button"></span>', 'typo3-adminPanel-header-buttonWrapper') . '<input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] . '" /></td>' . '</tr>';
267 if ($moduleContent) {
268 $footer = '<tr class="typo3-adminPanel-fRow">' . '<td colspan="2" id="typo3-adminPanel-footer">' . ($this->extNeedUpdate ? ' <input class="typo3-adminPanel-update" type="submit" value="' . $this->extGetLL('update') . '" />' : '') . '</td>' . '</tr>';
269 } else {
270 $footer = '';
271 }
272 $query = !\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id') ? '<input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id . '" />' : '';
273 // The dummy field is needed for Firefox: to force a page reload on submit
274 // with must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
275 $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
276 foreach (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET() as $key => $value) {
277 if ($key != 'TSFE_ADMIN_PANEL') {
278 if (is_array($value)) {
279 $query .= $this->getHiddenFields($key, $value);
280 } else {
281 $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
282 }
283 }
284 }
285 $out = '
286 <!--
287 TYPO3 admin panel start
288 -->
289 <a id="TSFE_ADMIN"></a>
290 <form id="TSFE_ADMIN_PANEL_FORM" name="TSFE_ADMIN_PANEL_FORM" action="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')) . '#TSFE_ADMIN" method="get" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">' . $query . '<table class="typo3-adminPanel">' . $header . $moduleContent . $footer . '</table></form>';
291 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
292 $out .= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
293 $out .= '<script type="text/javascript">/*<![CDATA[*/' . \TYPO3\CMS\Core\Utility\GeneralUtility::minifyJavaScript('
294 var evalFunc = new evalFunc();
295 // TSFEtypo3FormFieldSet()
296 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
297 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
298 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
299 if (checkbox && theValue==checkboxValue) {
300 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
301 alert(theField);
302 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
303 } else {
304 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
305 if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
306 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
307 }
308 }
309 }
310 // TSFEtypo3FormFieldGet()
311 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
312 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
313 if (checkbox_off) {
314 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
315 }else{
316 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
317 }
318 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
319 }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
320 }
321 $out .= '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl('t3lib/js/adminpanel.js') . '" type="text/javascript"></script><script type="text/javascript">/*<![CDATA[*/' . 'typo3AdminPanel = new TYPO3AdminPanel();typo3AdminPanel.init("typo3-adminPanel-header", "TSFE_ADMIN_PANEL_FORM");' . '/*]]>*/</script>
322 <!--
323 TYPO3 admin panel end
324 -->
325 ';
326 return $out;
327 }
328
329 /**
330 * Fetches recursively all GET parameters as hidden fields.
331 * Called from display()
332 *
333 * @param string $key Current key
334 * @param array $val Current value
335 * @return string Hidden fields
336 * @see display()
337 */
338 protected function getHiddenFields($key, array $val) {
339 $out = '';
340 foreach ($val as $k => $v) {
341 if (is_array($v)) {
342 $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
343 } else {
344 $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
345 }
346 }
347 return $out;
348 }
349
350 /*****************************************************
351 *
352 * Creating sections of the Admin Panel
353 *
354 ****************************************************/
355 /**
356 * Creates the content for the "preview" section ("module") of the Admin Panel
357 *
358 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
359 * @see display()
360 */
361 protected function getPreviewModule() {
362 $out = $this->extGetHead('preview');
363 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_preview']) {
364 $this->extNeedUpdate = TRUE;
365 $out .= $this->extGetItem('preview_showHiddenPages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenPages'] ? ' checked="checked"' : '') . ' />');
366 $out .= $this->extGetItem('preview_showHiddenRecords', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenRecords'] ? ' checked="checked"' : '') . ' />');
367 // Simulate date
368 $out .= $this->extGetItem('preview_simulateDate', '<input type="text" name="TSFE_ADMIN_PANEL[preview_simulateDate]_hr" onchange="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\', 1,0);" /><input type="hidden" name="TSFE_ADMIN_PANEL[preview_simulateDate]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate'] . '" />');
369 $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
370 // Simulate fe_user:
371 $options = '<option value="0">&nbsp;</option>';
372 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('fe_groups.uid, fe_groups.title', 'fe_groups,pages', 'pages.uid=fe_groups.pid AND pages.deleted=0 ' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('fe_groups') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
373 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
374 $options .= '<option value="' . $row['uid'] . '"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(('[' . $row['uid'] . '] ' . $row['title'])) . '</option>';
375 }
376 $out .= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
377 }
378 return $out;
379 }
380
381 /**
382 * Creates the content for the "cache" section ("module") of the Admin Panel
383 *
384 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
385 * @see display()
386 */
387 protected function getCacheModule() {
388 $out = $this->extGetHead('cache');
389 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_cache']) {
390 $this->extNeedUpdate = TRUE;
391 $out .= $this->extGetItem('cache_noCache', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_noCache'] ? ' checked="checked"' : '') . ' />');
392 $levels = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
393 $options = '';
394 $options .= '<option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
395 $options .= '<option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
396 $options .= '<option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
397 $out .= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' . '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" /> <input type="submit" value="' . $this->extGetLL('update') . '" />');
398 // Generating tree:
399 $depth = $this->extGetFeAdminValue('cache', 'clearCacheLevels');
400 $outTable = '';
401 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
402 $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth + 1);
403 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
404 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
405 $outTable .= '<tr>' . '<td><img src="typo3/gfx/clear.gif" width="' . ($depth + 1 - $row[2]) * 18 . '" height="1" alt="" /><img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/i/pages.gif', 'width="18" height="16"') . ' align="top" alt="" /> ' . htmlspecialchars($row[1]) . '</td><td>' . $GLOBALS['BE_USER']->extGetNumberOfCachedPages($row[0]) . '</td></tr>';
406 }
407 $outTable = '<br /><table>' . $outTable . '</table>';
408 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
409 $out .= $this->extGetItem('cache_cacheEntries', $outTable);
410 }
411 return $out;
412 }
413
414 /**
415 * Creates the content for the "edit" section ("module") of the Admin Panel
416 *
417 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
418 * @see display()
419 */
420 protected function getEditModule() {
421 $out = $this->extGetHead('edit');
422 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_edit']) {
423 // If another page module was specified, replace the default Page module with the new one
424 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
425 $pageModule = \TYPO3\CMS\Backend\Utility\BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
426 $this->extNeedUpdate = TRUE;
427 $out .= $this->extGetItem('edit_displayFieldIcons', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayFieldIcons'] ? ' checked="checked"' : '') . ' />');
428 $out .= $this->extGetItem('edit_displayIcons', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayIcons'] ? ' checked="checked"' : '') . ' />');
429 $out .= $this->extGetItem('edit_editFormsOnPage', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] ? ' checked="checked"' : '') . ' />');
430 $out .= $this->extGetItem('edit_editNoPopup', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] ? ' checked="checked"' : '') . ' />');
431 $out .= $this->extGetItem('', $this->ext_makeToolBar());
432 if (!\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_view')) {
433 $out .= $this->extGetItem('', '<a href="#" onclick="' . htmlspecialchars(('
434 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
435 parent.opener.top.fsMod.recentIds["web"]=' . intval($GLOBALS['TSFE']->page['uid']) . ';
436 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
437 parent.opener.top.content.nav_frame.refresh_nav();
438 }
439 parent.opener.top.goToModule("' . $pageModule . '");
440 parent.opener.top.focus();
441 } else {
442 vHWin=window.open(\'' . TYPO3_mainDir . \TYPO3\CMS\Backend\Utility\BackendUtility::getBackendScript() . '\',\'' . md5(('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])) . '\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
443 vHWin.focus();
444 }
445 return false;
446 ')) . '">' . $this->extGetLL('edit_openAB') . '</a>');
447 }
448 }
449 return $out;
450 }
451
452 /**
453 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
454 *
455 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
456 * @see display()
457 */
458 protected function getTSDebugModule() {
459 $out = $this->extGetHead('tsdebug');
460 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_tsdebug']) {
461 $this->extNeedUpdate = TRUE;
462 $out .= $this->extGetItem('tsdebug_tree', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') . ' />');
463 $out .= $this->extGetItem('tsdebug_displayTimes', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') . ' />');
464 $out .= $this->extGetItem('tsdebug_displayMessages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"' : '') . ' />');
465 $out .= $this->extGetItem('tsdebug_LR', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />');
466 $out .= $this->extGetItem('tsdebug_displayContent', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />');
467 $out .= $this->extGetItem('tsdebug_displayQueries', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayQueries'] ? ' checked="checked"' : '') . ' />');
468 $out .= $this->extGetItem('tsdebug_forceTemplateParsing', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />');
469 $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
470 $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
471 $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
472 $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
473 $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
474 $out .= '<tr><td colspan="2">' . $GLOBALS['TT']->printTSlog() . '</td></tr>';
475 }
476 return $out;
477 }
478
479 /**
480 * Creates the content for the "info" section ("module") of the Admin Panel
481 *
482 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
483 * @see display()
484 */
485 protected function getInfoModule() {
486 $out = $this->extGetHead('info');
487 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_info']) {
488 $tableArr = array();
489 if ($this->extGetFeAdminValue('cache', 'noCache')) {
490 $theBytes = 0;
491 $count = 0;
492 if (count($GLOBALS['TSFE']->imagesOnPage)) {
493 $tableArr[] = array('*Images on this page:*', '');
494 foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
495 $fs = @filesize($file);
496 $tableArr[] = array('&ndash; ' . $file, \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fs));
497 $theBytes += $fs;
498 $count++;
499 }
500 }
501 // Add an empty line
502 $tableArr[] = array('', '');
503 $tableArr[] = array('*Total number of images:*', $count);
504 $tableArr[] = array('*Total image file sizes:*', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($theBytes));
505 $tableArr[] = array('*Document size:*', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(strlen($GLOBALS['TSFE']->content)));
506 $tableArr[] = array('*Total page load:*', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(strlen($GLOBALS['TSFE']->content) + $theBytes));
507 $tableArr[] = array('', '');
508 }
509 $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
510 $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
511 $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
512 $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache ? 1 : 0);
513 $tableArr[] = array('USER_INT objects:', count($GLOBALS['TSFE']->config['INTincScript']));
514 $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
515 $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
516 // Add an empty line
517 $tableArr[] = array('', '');
518 // Parsetime:
519 $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime . ' ms');
520 $table = '';
521 foreach ($tableArr as $arr) {
522 // Put text wrapped by "*" between <strong> tags
523 if (strlen($arr[0])) {
524 $value1 = preg_replace('/^\\*(.*)\\*$/', '$1', $arr[0], -1, $count);
525 $value1 = ($count ? '<strong>' : '') . $value1 . ($count ? '</strong>' : '');
526 } else {
527 $value1 = '&nbsp;';
528 }
529 $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
530 $value2 = $value2;
531 $table .= '<tr class="typo3-adminPanel-itemRow">' . '<td class="typo3-adminPanel-section-content-title">' . $value1 . '</td>' . '<td class="typo3-adminPanel-section-content">' . $value2 . '</td>' . '</tr>';
532 }
533 $out .= $table;
534 }
535 return $out;
536 }
537
538 /*****************************************************
539 *
540 * Admin Panel Layout Helper functions
541 *
542 ****************************************************/
543 /**
544 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
545 * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_' . $pre . '] value
546 * See the functions get*Module
547 *
548 * @param string $sectionSuffix The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
549 * @return string HTML table row.
550 * @see extGetItem()
551 */
552 public function extGetHead($sectionSuffix) {
553 $settingName = 'display_' . $sectionSuffix;
554 $isVisible = $GLOBALS['BE_USER']->uc['TSFE_adminConfig'][$settingName];
555 $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ? 'open' : 'closed');
556 return '<tr class="typo3-adminPanel-section-title"><td colspan="2">' . $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix), $cssClassName) . '<input type="hidden" name="TSFE_ADMIN_PANEL[' . $settingName . ']" value="' . $isVisible . '" /></td></tr>';
557 }
558
559 /**
560 * Wraps a string in a link which will open/close a certain part of the Admin Panel
561 *
562 * @param string $sectionSuffix The code for the display_ label/key
563 * @param string $sectionTitle Input string
564 * @param string $className The classname for the <a> tag
565 * @return string $className Linked input string
566 * @see extGetHead()
567 */
568 public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '') {
569 return '<div class="typo3-adminPanel-label"><a href="javascript:void(0)" onclick="' . htmlspecialchars(('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_' . $sectionSuffix . ']\'].value=' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $sectionSuffix] ? '0' : '1') . ';document.TSFE_ADMIN_PANEL_FORM.submit();return false;')) . '"' . ($className ? ' class="' . $className . '"' : '') . '>' . $sectionTitle . '</a></div>';
570 }
571
572 /**
573 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
574 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
575 *
576 * @param string $title Key to label
577 * @param string $content The HTML content for the forth table cell.
578 * @param string $checkboxContent The HTML for a checkbox or hidden fields
579 * @return string HTML table row.
580 * @see extGetHead()
581 */
582 public function extGetItem($title, $content = '', $checkboxContent = '') {
583 $out = '<tr class="typo3-adminPanel-itemRow">' . '<td class="typo3-adminPanel-section-content">' . $checkboxContent . ($title ? $this->extGetLL($title) : '&nbsp;') . $content . '</td></tr>';
584 return $out;
585 }
586
587 /**
588 * Creates the tool bar links for the "edit" section of the Admin Panel.
589 *
590 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
591 */
592 public function ext_makeToolBar() {
593 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
594 $tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
595 $tsConfig = $tsConfig['properties']['newContentWiz.']['overrideWithExtension'];
596 $newContentWizScriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tsConfig) ? \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($tsConfig) . 'mod1/db_new_content_el.php' : TYPO3_mainDir . 'sysext/cms/layout/db_new_content_el.php';
597 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
598 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
599 $id = $GLOBALS['TSFE']->id;
600 $toolBar = '<a href="' . htmlspecialchars((TYPO3_mainDir . 'show_rechis.php?element=' . rawurlencode(('pages:' . $id)) . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '#latest">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/history2.gif', 'width="13" height="12"') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_recordHistory') . '" alt="" /></a>';
601 if ($perms & 16 && $langAllowed) {
602 $params = '';
603 if ($GLOBALS['TSFE']->sys_language_uid) {
604 $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
605 }
606 $toolBar .= '<a href="' . htmlspecialchars(($newContentWizScriptPath . '?id=' . $id . $params . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/new_record.gif', 'width="16" height="12"') . ' hspace="1" border="0" align="top" title="' . $this->extGetLL('edit_newContentElement') . '" alt="" /></a>';
607 }
608 if ($perms & 2) {
609 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'move_el.php?table=pages&uid=' . $id . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/move_page.gif', 'width="11" height="12') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_move_page') . '" alt="" /></a>';
610 }
611 if ($perms & 8) {
612 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/new_page.gif', 'width="13" height="12"') . ' hspace="0" border="0" align="top" title="' . $this->extGetLL('edit_newPage') . '" alt="" /></a>';
613 }
614 if ($perms & 2) {
615 $params = '&edit[pages][' . $id . ']=edit';
616 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/edit2.gif', 'width="11" height="12"') . 'hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageProperties') . '" alt="" /></a>';
617 if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
618 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
619 'uid,pid,t3ver_state',
620 'pages_language_overlay',
621 'pid=' . intval($id) .
622 ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid .
623 $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
624 '',
625 '',
626 '1'
627 );
628 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
629 $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay', $row);
630 if (is_array($row)) {
631 $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
632 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/edit3.gif', 'width="11" height="12"') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageOverlay') . '" alt="" /></a>';
633 }
634 }
635 }
636 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
637 $urlParams = array();
638 $urlParams['id'] = $id;
639 $urlParams['returnUrl'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI');
640 $toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_list', $urlParams))) . '">' . '<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/list.gif', 'width="11" height="11"') . ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_db_list') . '" alt="" /></a>';
641 }
642 return $toolBar;
643 }
644
645 /**
646 * Returns the label for key, $key. If a translation for the language set in $GLOBALS['BE_USER']->uc['lang'] is found that is returned, otherwise the default value.
647 * IF the global variable $LOCAL_LANG is NOT an array (yet) then this function loads the global $LOCAL_LANG array with the content of "sysext/lang/locallang_tsfe.xlf" so that the values therein can be used for labels in the Admin Panel
648 *
649 * FIXME The function should convert to $TSFE->renderCharset, not to UTF8!
650 *
651 * @param string $key Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.xlf
652 * @return string The value for the $key
653 */
654 public function extGetLL($key) {
655 // Label string in the default backend output charset.
656 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key));
657 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
658 return $labelStr;
659 }
660
661 }
662
663
664 ?>