[TASK] Remove deprecated cObj HTML
[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 TRUE if admin panel module is open
228 *
229 * @param string Module key
230 * @return boolean TRUE, if the admin panel is open for the specified admin panel module key.
231 */
232 public function isAdminModuleOpen($pre) {
233 return $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] && $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre];
234 }
235
236 /*****************************************************
237 *
238 * Admin Panel Rendering
239 *
240 ****************************************************/
241
242 /**
243 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
244 *
245 * @return string HTML for the Admin Panel
246 */
247 public function display() {
248 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
249
250 $moduleContent = '';
251
252 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
253 if ($this->isAdminModuleEnabled('preview')) {
254 $moduleContent .= $this->getPreviewModule();
255 }
256 if ($this->isAdminModuleEnabled('cache')) {
257 $moduleContent .= $this->getCacheModule();
258 }
259 if ($this->isAdminModuleEnabled('edit')) {
260 $moduleContent .= $this->getEditModule();
261 }
262 if ($this->isAdminModuleEnabled('tsdebug')) {
263 $moduleContent .= $this->getTSDebugModule();
264 }
265 if ($this->isAdminModuleEnabled('info')) {
266 $moduleContent .= $this->getInfoModule();
267 }
268 }
269
270 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
271 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
272 $hookObject = t3lib_div::getUserObj($classRef);
273
274 if (!($hookObject instanceof tslib_adminPanelHook)) {
275 throw new UnexpectedValueException('$hookObject must implement interface tslib_adminPanelHook', 1311942539);
276 }
277
278 $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
279 }
280 }
281
282 $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' .
283 htmlspecialchars($GLOBALS['BE_USER']->user['username']) . '</span>';
284
285 $isVisible = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'];
286 $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
287 $header = '<tr class="typo3-adminPanel-hRow">' .
288 '<td colspan="2" id="typo3-adminPanel-header" class="' . $cssClassName . '">' .
289 '<span class="typo3-adminPanel-header-title">' . $row . '</span>' .
290 $this->linkSectionHeader('top', '<span class="typo3-adminPanel-header-button"></span>', 'typo3-adminPanel-header-buttonWrapper') .
291 '<input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] . '" /></td>' .
292 '</tr>';
293
294 if ($moduleContent) {
295 $footer = '<tr class="typo3-adminPanel-fRow">' .
296 '<td colspan="2" id="typo3-adminPanel-footer">' .
297 ($this->extNeedUpdate ? ' <input class="typo3-adminPanel-update" type="submit" value="' . $this->extGetLL('update') . '" />' : '') . '</td>' .
298 '</tr>';
299 } else {
300 $footer = '';
301 }
302
303 $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id . '" />') : '';
304 // 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")
305 $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
306 foreach (t3lib_div::_GET() as $key => $value) {
307 if ($key != 'TSFE_ADMIN_PANEL') {
308 if (is_array($value)) {
309 $query .= $this->getHiddenFields($key, $value);
310 } else {
311 $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
312 }
313 }
314 }
315
316 $out = '
317 <!--
318 TYPO3 admin panel start
319 -->
320 <a id="TSFE_ADMIN"></a>
321 <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)">' .
322 $query . '<table class="typo3-adminPanel">' .
323 $header . $moduleContent . $footer . '</table></form>';
324
325 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
326 $out .= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
327 $out .= '<script type="text/javascript">/*<![CDATA[*/' . t3lib_div::minifyJavaScript('
328 var evalFunc = new evalFunc();
329 // TSFEtypo3FormFieldSet()
330 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
331 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
332 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
333 if (checkbox && theValue==checkboxValue) {
334 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
335 alert(theField);
336 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
337 } else {
338 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
339 if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
340 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
341 }
342 }
343 }
344 // TSFEtypo3FormFieldGet()
345 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
346 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
347 if (checkbox_off) {
348 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
349 }else{
350 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
351 }
352 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
353 }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' .
354 $this->extJSCODE . '</script>';
355 }
356
357 $out .= '<script src="' . t3lib_div::locationHeaderUrl('t3lib/js/adminpanel.js') . '" type="text/javascript"></script><script type="text/javascript">/*<![CDATA[*/' .
358 'typo3AdminPanel = new TYPO3AdminPanel();typo3AdminPanel.init("typo3-adminPanel-header", "TSFE_ADMIN_PANEL_FORM");' .
359 '/*]]>*/</script>
360 <!--
361 TYPO3 admin panel end
362 -->
363 ';
364
365 return $out;
366 }
367
368 /**
369 * Fetches recursively all GET parameters as hidden fields.
370 * Called from display()
371 *
372 * @param string current key
373 * @param mixed current value
374 * @return string hidden fields
375 * @see display()
376 */
377 protected function getHiddenFields($key, array $val) {
378 $out = '';
379 foreach ($val as $k => $v) {
380 if (is_array($v)) {
381 $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
382 } else {
383 $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
384 }
385 }
386 return $out;
387 }
388
389 /*****************************************************
390 *
391 * Creating sections of the Admin Panel
392 *
393 ****************************************************/
394
395 /**
396 * Creates the content for the "preview" section ("module") of the Admin Panel
397 *
398 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
399 * @see display()
400 */
401 protected function getPreviewModule() {
402 $out = $this->extGetHead('preview');
403 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_preview']) {
404 $this->extNeedUpdate = TRUE;
405 $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"' : '') . ' />');
406 $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"' : '') . ' />');
407
408 // Simulate date
409 $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'] . '" />');
410 $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
411
412 // Simulate fe_user:
413 $options = '<option value="0">&nbsp;</option>';
414 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
415 'fe_groups.uid, fe_groups.title',
416 'fe_groups,pages',
417 'pages.uid=fe_groups.pid AND pages.deleted=0 ' . t3lib_BEfunc::deleteClause('fe_groups') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1)
418 );
419 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
420 $options .= '<option value="' . $row['uid'] . '"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars('[' . $row['uid'] . '] ' . $row['title']) . '</option>';
421 }
422 $out .= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
423 }
424
425 return $out;
426 }
427
428 /**
429 * Creates the content for the "cache" section ("module") of the Admin Panel
430 *
431 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
432 * @see display()
433 */
434 protected function getCacheModule() {
435 $out = $this->extGetHead('cache');
436 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_cache']) {
437 $this->extNeedUpdate = TRUE;
438 $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"' : '') . ' />');
439 $levels = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
440 $options = '';
441 $options .= '<option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
442 $options .= '<option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
443 $options .= '<option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
444 $out .= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' .
445 '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" /> <input type="submit" value="' . $this->extGetLL('update') . '" />');
446
447 // Generating tree:
448 $depth = $this->extGetFeAdminValue('cache', 'clearCacheLevels');
449 $outTable = '';
450 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
451 $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth+1);
452 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
453 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
454 $outTable .= '<tr>' .
455 '<td><img src="typo3/gfx/clear.gif" width="' . (($depth+1-$row[2])*18) . '" height="1" alt="" /><img ' .
456 t3lib_iconWorks::skinImg(TYPO3_mainDir, 'gfx/i/pages.gif', 'width="18" height="16"') . ' align="top" alt="" /> ' . htmlspecialchars($row[1]) .
457 '</td><td>' . $GLOBALS['BE_USER']->extGetNumberOfCachedPages($row[0]) . '</td></tr>';
458 }
459
460 $outTable = '<br /><table>' . $outTable . '</table>';
461 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
462
463 $out .= $this->extGetItem('cache_cacheEntries', $outTable);
464 }
465
466 return $out;
467 }
468
469 /**
470 * Creates the content for the "edit" section ("module") of the Admin Panel
471 *
472 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
473 * @see display()
474 */
475 protected function getEditModule() {
476 $out = $this->extGetHead('edit');
477 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_edit']) {
478
479 // If another page module was specified, replace the default Page module with the new one
480 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
481 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
482
483 $this->extNeedUpdate = TRUE;
484 $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"' : '') . ' />');
485 $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"' : '') . ' />');
486 $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"':'') . ' />');
487 $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"' : '') . ' />');
488 $out .= $this->extGetItem('', $this->ext_makeToolBar());
489
490 if (!t3lib_div::_GP('ADMCMD_view')) {
491 $out .= $this->extGetItem('', '<a href="#" onclick="' .
492 htmlspecialchars('
493 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
494 parent.opener.top.fsMod.recentIds["web"]=' . intval($GLOBALS['TSFE']->page['uid']) . ';
495 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
496 parent.opener.top.content.nav_frame.refresh_nav();
497 }
498 parent.opener.top.goToModule("' . $pageModule . '");
499 parent.opener.top.focus();
500 } else {
501 vHWin=window.open(\'' . TYPO3_mainDir.t3lib_BEfunc::getBackendScript() . '\',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
502 vHWin.focus();
503 }
504 return false;
505 ').
506 '">' . $this->extGetLL('edit_openAB') . '</a>');
507 }
508 }
509
510 return $out;
511 }
512
513 /**
514 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
515 *
516 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
517 * @see display()
518 */
519 protected function getTSDebugModule() {
520 $out = $this->extGetHead('tsdebug');
521 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_tsdebug']) {
522 $this->extNeedUpdate = TRUE;
523
524 $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"' : '') . ' />');
525 $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"' : '') . ' />');
526 $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"':'') . ' />');
527 $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"' : '') . ' />');
528 $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"' : '') . ' />');
529 $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"' : '') . ' />');
530 $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"' : '') . ' />');
531
532 $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
533 $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
534 $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
535 $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
536 $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
537
538 $out.= '<tr><td colspan="2">' . $GLOBALS['TT']->printTSlog() . '</td></tr>';
539 }
540
541 return $out;
542 }
543
544 /**
545 * Creates the content for the "info" section ("module") of the Admin Panel
546 *
547 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
548 * @see display()
549 */
550 protected function getInfoModule() {
551 $out = $this->extGetHead('info');
552 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_info']) {
553 $tableArr = array();
554
555 if ($this->extGetFeAdminValue('cache', 'noCache')) {
556 $theBytes = 0;
557 $count = 0;
558
559 if (count($GLOBALS['TSFE']->imagesOnPage)) {
560 $tableArr[] = array('*Images on this page:*', '');
561 foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
562 $fs = @filesize($file);
563 $tableArr[] = array('&ndash; ' . $file, t3lib_div::formatSize($fs));
564 $theBytes+= $fs;
565 $count++;
566 }
567 }
568 $tableArr[] = array('', ''); // Add an empty line
569
570 $tableArr[] = array('*Total number of images:*', $count);
571 $tableArr[] = array('*Total image file sizes:*', t3lib_div::formatSize($theBytes));
572 $tableArr[] = array('*Document size:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)));
573 $tableArr[] = array('*Total page load:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes));
574 $tableArr[] = array('', '');
575 }
576
577 $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
578 $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
579 $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
580 $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache ? 1 : 0);
581 $tableArr[] = array('USER_INT objects:', count($GLOBALS['TSFE']->config['INTincScript']));
582 $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
583 $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
584 $tableArr[] = array('', ''); // Add an empty line
585
586 // parsetime:
587 $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime . ' ms');
588
589 $table = '';
590 foreach ($tableArr as $arr) {
591 if (strlen($arr[0])) { // Put text wrapped by "*" between <strong> tags
592 $value1 = preg_replace('/^\*(.*)\*$/', '$1', $arr[0], -1, $count);
593 $value1 = ($count?'<strong>':'') . $value1 . ($count?'</strong>':'');
594 } else {
595 $value1 = '&nbsp;';
596 }
597
598 $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
599 $value2 = $value2;
600
601 $table .= '<tr class="typo3-adminPanel-itemRow">' .
602 '<td class="typo3-adminPanel-section-content-title">' . $value1 . '</td>' .
603 '<td class="typo3-adminPanel-section-content">' . $value2 . '</td>' .
604 '</tr>';
605 }
606
607 $out .= $table;
608 }
609
610 return $out;
611 }
612
613 /*****************************************************
614 *
615 * Admin Panel Layout Helper functions
616 *
617 ****************************************************/
618
619 /**
620 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
621 * 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
622 * See the functions get*Module
623 *
624 * @param string The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
625 * @return string HTML table row.
626 * @see extGetItem()
627 */
628 public function extGetHead($sectionSuffix) {
629 $settingName = 'display_' . $sectionSuffix;
630 $isVisible = $GLOBALS['BE_USER']->uc['TSFE_adminConfig'][$settingName];
631 $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ? 'open' : 'closed');
632
633 return '<tr class="typo3-adminPanel-section-title"><td colspan="2">' .
634 $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix), $cssClassName) .
635 '<input type="hidden" name="TSFE_ADMIN_PANEL[' . $settingName .
636 ']" value="' . $isVisible . '" /></td></tr>';
637 }
638
639 /**
640 * Wraps a string in a link which will open/close a certain part of the Admin Panel
641 *
642 * @param string The code for the display_ label/key
643 * @param string Input string
644 * @return string Linked input string
645 * @see extGetHead()
646 */
647 public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '') {
648 return '<div class="typo3-adminPanel-label"><a href="javascript:void(0)" onclick="' .
649 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;') .
650 '"' . ($className ? ' class="' . $className . '"' : '') . '>' . $sectionTitle . '</a></div>';
651 }
652
653 /**
654 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
655 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
656 *
657 * @param string Key to label
658 * @param string The HTML content for the forth table cell.
659 * @return string HTML table row.
660 * @see extGetHead()
661 */
662 public function extGetItem($title, $content = '', $checkboxContent = '') {
663 $out = '<tr class="typo3-adminPanel-itemRow">' .
664 '<td class="typo3-adminPanel-section-content">' . $checkboxContent . ($title ? $this->extGetLL($title) : '&nbsp;') . $content . '</td></tr>';
665
666 return $out;
667 }
668
669 /**
670 * Creates the tool bar links for the "edit" section of the Admin Panel.
671 *
672 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
673 */
674 public function ext_makeToolBar() {
675 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
676 $tsConfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
677 $tsConfig = $tsConfig['properties']['newContentWiz.']['overrideWithExtension'];
678 $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');
679
680 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
681 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
682
683 $id = $GLOBALS['TSFE']->id;
684 $toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir . 'show_rechis.php?element=' . rawurlencode('pages:' . $id) . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '#latest">' .
685 '<img ' . t3lib_iconWorks::skinImg(TYPO3_mainDir, 'gfx/history2.gif', 'width="13" height="12"') .
686 ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_recordHistory') . '" alt="" /></a>';
687
688 if (($perms & 16) && $langAllowed) {
689 $params = '';
690 if ($GLOBALS['TSFE']->sys_language_uid) {
691 $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
692 }
693 $toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . '?id=' . $id . $params . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
694 '<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>';
695 }
696 if (($perms & 2)) {
697 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'move_el.php?table=pages&uid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
698 '<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>';
699 }
700 if (($perms & 8)) {
701 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
702 '<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>';
703 }
704 if (($perms & 2)) {
705 $params = '&edit[pages][' . $id . ']=edit';
706 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
707 '<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>';
708
709 if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
710 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
711 'uid,pid,t3ver_state', 'pages_language_overlay',
712 'pid=' . intval($id) . ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid . $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
713 '', '', '1');
714 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
715 $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay',$row);
716 if (is_array($row)) {
717 $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
718 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
719 '<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>';
720 }
721 }
722 }
723 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
724 $urlParams = array();
725 $urlParams['id'] = $id;
726 $urlParams['returnUrl'] = t3lib_div::getIndpEnv('REQUEST_URI');
727 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . t3lib_BEfunc::getModuleUrl('web_list', $urlParams)) . '">' .
728 '<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>';
729 }
730
731 return $toolBar;
732 }
733
734 /**
735 * 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.
736 * 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
737 *
738 * FIXME The function should onvert to $TSFE->renderCharset, not to UTF8!
739 *
740 * @param string Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
741 * @return string The value for the $key
742 */
743 public function extGetLL($key) {
744 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key)); // Label string in the default backend output charset.
745 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
746
747 return $labelStr;
748 }
749 }
750
751 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/cms/tslib/class.tslib_adminpanel.php'])) {
752 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/cms/tslib/class.tslib_adminpanel.php']);
753 }
754
755 ?>