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