2 /***************************************************************
5 * (c) 2008-2011 Jeff Segars <jeff@webempoweredchurch.org>
6 * (c) 2008-2011 David Slayback <dave@webempoweredchurch.org>
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.
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.
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.
26 * This copyright notice MUST APPEAR in all copies of the scri.pt!
27 ***************************************************************/
29 * View class for the admin panel in frontend editing.
33 * @author Jeff Segars <jeff@webempoweredchurch.org>
34 * @author David Slayback <dave@webempoweredchurch.org>
35 * @author Dmitry Dulepov <dmitry@typo3.org>
39 class tslib_AdminPanel
{
42 * Determines whether the update button should be shown.
46 protected $extNeedUpdate = false;
53 protected $ext_forcePreview = false;
56 * Comma separated list of page UIDs to be published.
60 protected $extPublishList = '';
62 public function __construct() {
66 /*****************************************************
68 * Admin Panel Configuration/Initialization
70 ****************************************************/
73 * Initializes settings for the admin panel.
77 public function initialize() {
78 $this->saveConfigOptions();
80 // Setting some values based on the admin panel
81 $GLOBALS['TSFE']->forceTemplateParsing
= $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
82 $GLOBALS['TSFE']->displayEditIcons
= $this->extGetFeAdminValue('edit', 'displayIcons');
83 $GLOBALS['TSFE']->displayFieldEditIcons
= $this->extGetFeAdminValue('edit', 'displayFieldIcons');
85 if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
86 if ($GLOBALS['TYPO3_DB']->explainOutput
== 0) { // do not override if the value is already set in t3lib_db
87 // Enable execution of EXPLAIN SELECT queries
88 $GLOBALS['TYPO3_DB']->explainOutput
= 3;
92 if (t3lib_div
::_GP('ADMCMD_editIcons')) {
93 $GLOBALS['TSFE']->displayFieldEditIcons
=1;
94 $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['edit_editNoPopup'] = 1;
97 if (t3lib_div
::_GP('ADMCMD_simUser')) {
98 $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['preview_simulateUserGroup']=intval(t3lib_div
::_GP('ADMCMD_simUser'));
99 $this->ext_forcePreview
= true;
102 if (t3lib_div
::_GP('ADMCMD_simTime')) {
103 $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['preview_simulateDate']=intval(t3lib_div
::_GP('ADMCMD_simTime'));
104 $this->ext_forcePreview
= true;
107 if ($GLOBALS['TSFE']->forceTemplateParsing ||
$GLOBALS['TSFE']->displayEditIcons ||
$GLOBALS['TSFE']->displayFieldEditIcons
) {
108 $GLOBALS['TSFE']->set_no_cache();
113 * Obtains header data for the admin panel.
117 public function getAdminPanelHeaderData() {
121 $GLOBALS['TSFE']->includeTCA();
123 if(!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
124 $result = '<link rel="stylesheet" type="text/css" href="' .
125 htmlspecialchars(t3lib_div
::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) .
132 * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
134 * @param string The module key, eg. "edit", "preview", "info" etc.
137 public function isAdminModuleEnabled($key) {
140 // Returns true if the module checked is "preview" and the forcePreview flag is set.
141 if ($key == 'preview' && $this->ext_forcePreview
) {
145 // If key is not set, only "all" is checked
146 if ($GLOBALS['BE_USER']->extAdminConfig
['enable.']['all']) {
150 if ($GLOBALS['BE_USER']->extAdminConfig
['enable.'][$key]) {
158 * Saves any change in settings made in the Admin Panel.
159 * Called from index_ts.php right after access check for the Admin Panel
163 public function saveConfigOptions() {
164 $input = t3lib_div
::_GP('TSFE_ADMIN_PANEL');
165 if (is_array($input)) {
167 $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...
168 unset($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['action']);
171 if ($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) {
172 $GLOBALS['BE_USER']->extPageInTreeInfo
=array();
173 $theStartId = intval($input['cache_clearCacheId']);
174 $GLOBALS['TSFE']->clearPageCacheContent_pidList($GLOBALS['BE_USER']->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $GLOBALS['BE_USER']->getPagePermsClause(1)) . $theStartId);
176 if ($input['action']['publish'] && $this->isAdminModuleEnabled('publish')) {
177 $theStartId = intval($input['publish_id']);
178 $this->extPublishList
= $GLOBALS['BE_USER']->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish', 'levels'), 0, $GLOBALS['BE_USER']->getPagePermsClause(1)) . $theStartId;
182 $GLOBALS['BE_USER']->writeUC();
184 $GLOBALS['TT']->LR
= $this->extGetFeAdminValue('tsdebug', 'LR');
186 if ($this->extGetFeAdminValue('cache', 'noCache')) {
187 $GLOBALS['TSFE']->set_no_cache();
190 // Hook for post processing the frontend admin configuration. Added with TYPO3 4.2, so naming is now incorrect but preserves compatibility.
191 // @deprecated since TYPO3 4.3
192 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'])) {
193 t3lib_div
::deprecationLog('Frontend admin post processing hook extSaveFeAdminConfig-postProc is deprecated since TYPO3 4.3.');
194 $_params = array('input' => &$input, 'pObj' => &$this);
195 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'] as $_funcRef) {
196 t3lib_div
::callUserFunction($_funcRef, $_params, $this);
202 * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
204 * @param string Module key
205 * @param string Setting key
206 * @return string The setting value
208 public function extGetFeAdminValue($sectionName, $val = '') {
209 // Check if module is enabled.
210 if ($this->isAdminModuleEnabled($sectionName)) {
211 // Exceptions where the values can be overridden from backend:
213 if ($sectionName . '_' . $val == 'edit_displayIcons' && $GLOBALS['BE_USER']->extAdminConfig
['module.']['edit.']['forceDisplayIcons']) {
216 if ($sectionName . '_' . $val == 'edit_displayFieldIcons' && $GLOBALS['BE_USER']->extAdminConfig
['module.']['edit.']['forceDisplayFieldIcons']) {
220 // override all settings with user TSconfig
221 if ($val && $GLOBALS['BE_USER']->extAdminConfig
['override.'][$sectionName . '.'][$val]) {
222 return $GLOBALS['BE_USER']->extAdminConfig
['override.'][$sectionName . '.'][$val];
224 if ($GLOBALS['BE_USER']->extAdminConfig
['override.'][$sectionName]) {
225 return $GLOBALS['BE_USER']->extAdminConfig
['override.'][$sectionName];
228 $retVal = $val ?
$GLOBALS['BE_USER']->uc
['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
230 if ($sectionName == 'preview' && $this->ext_forcePreview
) {
231 return (!$val ?
true : $retVal);
234 if ($this->isAdminModuleOpen($sectionName)) { // See if the menu is expanded!
238 // Hook for post processing the frontend admin configuration. Added with TYPO3 4.2, so naming is now incorrect but preserves compatibility.
239 // @deprecated since TYPO3 4.3
240 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'])) {
241 t3lib_div
::deprecationLog('Frontend admin post processing hook extEditAction-postProc is deprecated since TYPO3 4.3.');
242 $params = array('cmd' => &$cmd, 'tce' => &$this->tce
, 'pObj' => &$this);
243 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'] as $funcRef) {
244 t3lib_div
::callUserFunction($funcRef, $params, $this);
251 * Enables the force preview option.
255 public function forcePreview() {
256 $this->ext_forcePreview
= true;
260 * Returns the comma-separated list of page UIDs to be published.
264 public function getExtPublishList() {
265 return $this->extPublishList
;
269 * Returns true if admin panel module is open
271 * @param string Module key
272 * @return boolean True, if the admin panel is open for the specified admin panel module key.
274 public function isAdminModuleOpen($pre) {
275 return $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_top'] && $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_' . $pre];
278 /*****************************************************
280 * Admin Panel Rendering
282 ****************************************************/
285 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
287 * @return string HTML for the Admin Panel
289 public function display() {
290 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
294 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_top']) {
295 if ($this->isAdminModuleEnabled('preview')) {
296 $moduleContent .= $this->getPreviewModule();
298 if ($this->isAdminModuleEnabled('cache')) {
299 $moduleContent .= $this->getCacheModule();
301 if ($this->isAdminModuleEnabled('publish')) {
302 $moduleContent .= $this->getPublishModule();
304 if ($this->isAdminModuleEnabled('edit')) {
305 $moduleContent .= $this->getEditModule();
307 if ($this->isAdminModuleEnabled('tsdebug')) {
308 $moduleContent .= $this->getTSDebugModule();
310 if ($this->isAdminModuleEnabled('info')) {
311 $moduleContent .= $this->getInfoModule();
315 $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' .
316 htmlspecialchars($GLOBALS['BE_USER']->user
['username']) . '</span>';
318 $isVisible = $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_top'];
319 $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ?
'open' : 'closed');
320 $header = '<tr class="typo3-adminPanel-hRow">' .
321 '<td colspan="2" id="typo3-adminPanel-header" class="' . $cssClassName . '">' .
322 '<span class="typo3-adminPanel-header-title">' . $row . '</span>' .
323 $this->linkSectionHeader('top', '<span class="typo3-adminPanel-header-button"></span>', 'typo3-adminPanel-header-buttonWrapper') .
324 '<input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_top'] . '" /><div></td>' .
327 if ($moduleContent) {
328 $footer = '<tr class="typo3-adminPanel-fRow">' .
329 '<td colspan="2" id="typo3-adminPanel-header">' .
330 ($this->extNeedUpdate ?
' <input class="typo3-adminPanel-update" type="submit" value="' . $this->extGetLL('update') . '" />' : '') . '</td>' .
336 $query = !t3lib_div
::_GET('id') ?
('<input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id
. '" />') : '';
337 // 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")
338 $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
339 foreach (t3lib_div
::_GET() as $key => $value) {
340 if ($key != 'TSFE_ADMIN_PANEL') {
341 if (is_array($value)) {
342 $query .= $this->getHiddenFields($key, $value);
344 $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
351 TYPO3 admin panel start
353 <a id="TSFE_ADMIN"></a>
354 <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)">' .
355 $query . '<table class="typo3-adminPanel">' .
356 $header . $moduleContent . $footer . '</table></form>';
358 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_top']) {
359 $out .= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
360 $out .= '<script type="text/javascript">/*<![CDATA[*/' . t3lib_div
::minifyJavaScript('
361 var evalFunc = new evalFunc();
362 // TSFEtypo3FormFieldSet()
363 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
364 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
365 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
366 if (checkbox && theValue==checkboxValue) {
367 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
369 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
371 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
372 if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
373 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
377 // TSFEtypo3FormFieldGet()
378 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
379 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
381 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
383 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
385 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
386 }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' .
387 $this->extJSCODE
. '</script>';
390 $out .= '<script src="' . t3lib_div
::locationHeaderUrl('t3lib/js/adminpanel.js') . '" type="text/javascript"></script><script type="text/javascript">/*<![CDATA[*/' .
391 'typo3AdminPanel = new TYPO3AdminPanel();typo3AdminPanel.init("typo3-adminPanel-header", "TSFE_ADMIN_PANEL_FORM");' .
394 TYPO3 admin panel end
402 * Fetches recursively all GET parameters as hidden fields.
403 * Called from display()
405 * @param string current key
406 * @param mixed current value
407 * @return string hidden fields
410 protected function getHiddenFields($key, array $val) {
412 foreach ($val as $k => $v) {
414 $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
416 $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF
;
422 /*****************************************************
424 * Creating sections of the Admin Panel
426 ****************************************************/
429 * Creates the content for the "preview" section ("module") of the Admin Panel
431 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
434 protected function getPreviewModule() {
435 $out = $this->extGetHead('preview');
436 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_preview']) {
437 $this->extNeedUpdate
= true;
438 $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"' : '') . ' />');
439 $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"' : '') . ' />');
442 $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'] . '" />');
443 $this->extJSCODE
.= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
446 $options = '<option value="0"> </option>';
447 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
448 'fe_groups.uid, fe_groups.title',
450 'pages.uid=fe_groups.pid AND pages.deleted=0 ' . t3lib_BEfunc
::deleteClause('fe_groups') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1)
452 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
453 $options .= '<option value="' . $row['uid'] . '"' . ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ?
' selected="selected"' : '') . '>' . htmlspecialchars('[' . $row['uid'] . '] ' . $row['title']) . '</option>';
455 $out .= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
462 * Creates the content for the "cache" section ("module") of the Admin Panel
464 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
467 protected function getCacheModule() {
468 $out = $this->extGetHead('cache');
469 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_cache']) {
470 $this->extNeedUpdate
= true;
471 $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"' : '') . ' />');
472 $levels = $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['cache_clearCacheLevels'];
474 $options .= '<option value="0"' . ($levels == 0 ?
' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
475 $options .= '<option value="1"' . ($levels == 1 ?
' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
476 $options .= '<option value="2"' . ($levels == 2 ?
' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
477 $out .= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' .
478 '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id
. '" /> <input type="submit" value="' . $this->extGetLL('update') . '" />');
481 $depth = $this->extGetFeAdminValue('cache', 'clearCacheLevels');
483 $GLOBALS['BE_USER']->extPageInTreeInfo
= array();
484 $GLOBALS['BE_USER']->extPageInTreeInfo
[] = array($GLOBALS['TSFE']->page
['uid'], htmlspecialchars($GLOBALS['TSFE']->page
['title']), $depth+
1);
485 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id
, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
486 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo
as $row) {
487 $outTable .= '<tr>' .
488 '<td><img src="typo3/gfx/clear.gif" width="' . (($depth+
1-$row[2])*18) . '" height="1" alt="" /><img ' .
489 t3lib_iconWorks
::skinImg(TYPO3_mainDir
, 'gfx/i/pages.gif', 'width="18" height="16"') . ' align="top" alt="" /> ' . htmlspecialchars($row[1]) .
490 '</td><td>' . $GLOBALS['BE_USER']->extGetNumberOfCachedPages($row[0]) . '</td></tr>';
493 $outTable = '<br /><table>' . $outTable . '</table>';
494 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
496 $out .= $this->extGetItem('cache_cacheEntries', $outTable);
503 * Creates the content for the "publish" section ("module") of the Admin Panel
505 * @param string Optional start-value; The generated content is added to this variable.
506 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
509 protected function getPublishModule() {
510 $out = $this->extGetHead('publish');
511 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_publish']) {
512 $this->extNeedUpdate
= true;
513 $levels = $GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['publish_levels'];
515 $options .= '<option value="0"' . ($levels == 0 ?
' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
516 $options .= '<option value="1"' . ($levels ?
' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
517 $options .= '<option value="2"' . ($levels == 2 ?
' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
518 $out .= $this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">' . $options . '</select>' .
519 '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="' . $GLOBALS['TSFE']->id
. '" /> <input type="submit" value="' . $this->extGetLL('update') . '" />');
522 $depth = $this->extGetFeAdminValue('publish', 'levels');
524 $GLOBALS['BE_USER']->extPageInTreeInfo
= array();
525 $GLOBALS['BE_USER']->extPageInTreeInfo
[] = array($GLOBALS['TSFE']->page
['uid'], htmlspecialchars($GLOBALS['TSFE']->page
['title']), $depth+
1);
526 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id
, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
527 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo
as $row) {
529 '<td style="white-space:nowrap;"><img src="typo3/gfx/clear.gif" width="' . (($depth +
1 - $row[2]) * 18) . '" height="1" alt="" /><img ' .
530 t3lib_iconWorks
::skinImg(TYPO3_mainDir
, 'gfx/i/pages.gif', 'width="18" height="16"') . ' align="top" border="0" alt="" />' . $row[1] .
531 '</td><td><img src="typo3/gfx/clear.gif" width="10" height="1" alt="" /></td><td>...</td></tr>';
533 $outTable = '<br /><table>' . $outTable . '</table>';
534 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="' . $this->extGetLL('publish_doit') . '" />';
536 $out .= $this->extGetItem('publish_tree', $outTable);
543 * Creates the content for the "edit" section ("module") of the Admin Panel
545 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
548 protected function getEditModule() {
549 $out = $this->extGetHead('edit');
550 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_edit']) {
552 // If another page module was specified, replace the default Page module with the new one
553 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
554 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
556 $this->extNeedUpdate
= true;
557 $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"' : '') . ' />');
558 $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"' : '') . ' />');
559 $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"':'') . ' />');
560 $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"' : '') . ' />');
561 $out .= $this->extGetItem('', $this->ext_makeToolBar());
563 if (!t3lib_div
::_GP('ADMCMD_view')) {
564 $out .= $this->extGetItem('', '<a href="#" onclick="' .
566 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
567 parent.opener.top.fsMod.recentIds["web"]=' . intval($GLOBALS['TSFE']->page
['uid']) . ';
568 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
569 parent.opener.top.content.nav_frame.refresh_nav();
571 parent.opener.top.goToModule("' . $pageModule . '");
572 parent.opener.top.focus();
574 vHWin=window.open(\'' . TYPO3_mainDir
.t3lib_BEfunc
::getBackendScript() . '\',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
579 '">' . $this->extGetLL('edit_openAB') . '</a>');
587 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
589 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
592 protected function getTSDebugModule() {
593 $out = $this->extGetHead('tsdebug');
594 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_tsdebug']) {
595 $this->extNeedUpdate
= true;
597 $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"' : '') . ' />');
598 $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"' : '') . ' />');
599 $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"':'') . ' />');
600 $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"' : '') . ' />');
601 $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"' : '') . ' />');
602 $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"' : '') . ' />');
603 $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"' : '') . ' />');
605 $GLOBALS['TT']->printConf
['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
606 $GLOBALS['TT']->printConf
['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
607 $GLOBALS['TT']->printConf
['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
608 $GLOBALS['TT']->printConf
['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
609 $GLOBALS['TT']->printConf
['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
611 $out.= '<tr><td colspan="2">' . $GLOBALS['TT']->printTSlog() . '</td></tr>';
618 * Creates the content for the "info" section ("module") of the Admin Panel
620 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
623 protected function getInfoModule() {
624 $out = $this->extGetHead('info');
625 if ($GLOBALS['BE_USER']->uc
['TSFE_adminConfig']['display_info']) {
628 if ($this->extGetFeAdminValue('cache', 'noCache')) {
632 if (count($GLOBALS['TSFE']->imagesOnPage
)) {
633 $tableArr[] = array('*Images on this page:*', '');
634 foreach ($GLOBALS['TSFE']->imagesOnPage
as $file) {
635 $fs = @filesize
($file);
636 $tableArr[] = array('– ' . $file, t3lib_div
::formatSize($fs));
641 $tableArr[] = array('', ''); // Add an empty line
643 $tableArr[] = array('*Total number of images:*', $count);
644 $tableArr[] = array('*Total image file sizes:*', t3lib_div
::formatSize($theBytes));
645 $tableArr[] = array('*Document size:*', t3lib_div
::formatSize(strlen($GLOBALS['TSFE']->content
)));
646 $tableArr[] = array('*Total page load:*', t3lib_div
::formatSize(strlen($GLOBALS['TSFE']->content
)+
$theBytes));
647 $tableArr[] = array('', '');
650 $tableArr[] = array('id:', $GLOBALS['TSFE']->id
);
651 $tableArr[] = array('type:', $GLOBALS['TSFE']->type
);
652 $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list
);
653 $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache ?
1 : 0);
654 $tableArr[] = array('USER_INT objects:', count($GLOBALS['TSFE']->config
['INTincScript']));
655 $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user
->user
['username']);
656 $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user
->user
['uid']);
657 $tableArr[] = array('', ''); // Add an empty line
660 $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime
. ' ms');
663 foreach ($tableArr as $arr) {
664 if (strlen($arr[0])) { // Put text wrapped by "*" between <strong> tags
665 $value1 = preg_replace('/^\*(.*)\*$/', '$1', $arr[0], -1, $count);
666 $value1 = ($count?
'<strong>':'') . $value1 . ($count?
'</strong>':'');
671 $value2 = strlen($arr[1]) ?
$arr[1] : ' ';
674 $table .= '<tr class="typo3-adminPanel-itemRow">' .
675 '<td class="typo3-adminPanel-section-content-title">' . $value1 . '</td>' .
676 '<td class="typo3-adminPanel-section-content">' . $value2 . '</td>' .
686 /*****************************************************
688 * Admin Panel Layout Helper functions
690 ****************************************************/
693 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
694 * 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
695 * See the functions get*Module
697 * @param string The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
698 * @return string HTML table row.
702 protected function extGetHead($sectionSuffix) {
703 $settingName = 'display_' . $sectionSuffix;
704 $isVisible = $GLOBALS['BE_USER']->uc
['TSFE_adminConfig'][$settingName];
705 $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ?
'open' : 'closed');
707 return '<tr class="typo3-adminPanel-section-title"><td colspan="2">' .
708 $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix), $cssClassName) .
709 '<input type="hidden" name="TSFE_ADMIN_PANEL[' . $settingName .
710 ']" value="' . $isVisible . '" /></td></tr>';
714 * Wraps a string in a link which will open/close a certain part of the Admin Panel
716 * @param string The code for the display_ label/key
717 * @param string Input string
718 * @return string Linked input string
722 protected function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '') {
723 return '<a href="javascript:void(0)" onclick="' .
724 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;') .
725 '"' . ($className ?
' class="' . $className . '"' : '') . '><div class="typo3-adminPanel-label">' . $sectionTitle . '</div></a>';
729 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
730 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
732 * @param string Key to label
733 * @param string The HTML content for the forth table cell.
734 * @return string HTML table row.
738 protected function extGetItem($title, $content = '', $checkboxContent = '') {
739 $out = '<tr class="typo3-adminPanel-itemRow">' .
740 '<td class="typo3-adminPanel-section-content">' . $checkboxContent . ($title ?
$this->extGetLL($title) : ' ') . $content . '</td></tr>';
746 * Creates the tool bar links for the "edit" section of the Admin Panel.
748 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
750 public function ext_makeToolBar() {
751 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
752 $tsConfig = t3lib_BEfunc
::getModTSconfig($this->pageinfo
['uid'],'mod.web_list');
753 $tsConfig = $tsConfig ['properties']['newContentWiz.']['overrideWithExtension'];
754 $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');
756 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page
);
757 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid
);
759 $id = $GLOBALS['TSFE']->id
;
760 $toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir
. 'show_rechis.php?element=' . rawurlencode('pages:' . $id) . '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))) . '#latest">' .
761 '<img ' . t3lib_iconWorks
::skinImg(TYPO3_mainDir
, 'gfx/history2.gif', 'width="13" height="12"') .
762 ' hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_recordHistory') . '" alt="" /></a>';
764 if (($perms & 16) && $langAllowed) {
766 if ($GLOBALS['TSFE']->sys_language_uid
) {
767 $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid
;
769 $toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . '?id=' . $id . $params . '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))) . '">' .
770 '<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>';
773 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir
. 'move_el.php?table=pages&uid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))) . '">' .
774 '<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>';
777 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir
. 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))) . '">' .
778 '<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>';
781 $params = '&edit[pages][' . $id . ']=edit';
782 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir
. 'alt_document.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))) . '">' .
783 '<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>';
785 if ($GLOBALS['TSFE']->sys_language_uid
&& $langAllowed) {
786 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
787 'uid,pid,t3ver_state', 'pages_language_overlay',
788 'pid=' . intval($id) . ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid
. $GLOBALS['TSFE']->sys_page
->enableFields('pages_language_overlay'),
790 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
791 $GLOBALS['TSFE']->sys_page
->versionOL('pages_language_overlay',$row);
792 if (is_array($row)) {
793 $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
794 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir
. 'alt_document.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))) . '">' .
795 '<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>';
799 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
800 $urlParams = array();
801 $urlParams['id'] = $id;
802 $urlParams['returnUrl'] = t3lib_div
::getIndpEnv('REQUEST_URI');
803 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir
. t3lib_BEfunc
::getModuleUrl('web_list', $urlParams)) . '">' .
804 '<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>';
811 * 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.
812 * 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
814 * FIXME The function should onvert to $TSFE->renderCharset, not to UTF8!
816 * @param string Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
817 * @return string The value for the $key
819 protected function extGetLL($key) {
820 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key)); // Label string in the default backend output charset.
822 // Convert to utf-8, then to entities:
823 if ($GLOBALS['LANG']->charSet
!= 'utf-8') {
824 $labelStr = $GLOBALS['LANG']->csConvObj
->utf8_encode($labelStr,$GLOBALS['LANG']->charSet
);
826 $labelStr = $GLOBALS['LANG']->csConvObj
->utf8_to_entities($labelStr);
828 // Return the result:
833 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/sysext/cms/tslib/class.tslib_adminpanel.php'])) {
834 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/sysext/cms/tslib/class.tslib_adminpanel.php']);