TYPO3  7.6
AdminPanelView.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Frontend\View;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
22 
27 {
33  protected $extNeedUpdate = false;
34 
40  protected $ext_forcePreview = false;
41 
45  protected $extJSCODE = '';
46 
50  protected $iconFactory;
51 
55  public function __construct()
56  {
57  $this->initialize();
58  }
59 
65  public function initialize()
66  {
67  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
68  $this->saveConfigOptions();
69  $typoScriptFrontend = $this->getTypoScriptFrontendController();
70  // Setting some values based on the admin panel
71  $typoScriptFrontend->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
72  $typoScriptFrontend->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
73  $typoScriptFrontend->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
74  if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
75  // Do not override if the value is already set in \TYPO3\CMS\Core\Database\DatabaseConnection
76  if ($this->getDatabaseConnection()->explainOutput == 0) {
77  // Enable execution of EXPLAIN SELECT queries
78  $this->getDatabaseConnection()->explainOutput = 3;
79  }
80  }
81  if (GeneralUtility::_GP('ADMCMD_editIcons')) {
82  $typoScriptFrontend->displayFieldEditIcons = 1;
83  }
84  if (GeneralUtility::_GP('ADMCMD_simUser')) {
85  $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] = (int)GeneralUtility::_GP('ADMCMD_simUser');
86  $this->ext_forcePreview = true;
87  }
88  if (GeneralUtility::_GP('ADMCMD_simTime')) {
89  $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateDate'] = (int)GeneralUtility::_GP('ADMCMD_simTime');
90  $this->ext_forcePreview = true;
91  }
92  if ($typoScriptFrontend->forceTemplateParsing) {
93  $typoScriptFrontend->set_no_cache('Admin Panel: Force template parsing', true);
94  } elseif ($typoScriptFrontend->displayEditIcons) {
95  $typoScriptFrontend->set_no_cache('Admin Panel: Display edit icons', true);
96  } elseif ($typoScriptFrontend->displayFieldEditIcons) {
97  $typoScriptFrontend->set_no_cache('Admin Panel: Display field edit icons', true);
98  } elseif (GeneralUtility::_GP('ADMCMD_view')) {
99  $typoScriptFrontend->set_no_cache('Admin Panel: Display preview', true);
100  }
101  }
102 
108  public function getAdminPanelHeaderData()
109  {
110  $result = '';
111  if (!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
112  $stylesheet = GeneralUtility::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel']);
113  $result = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($stylesheet) . '" />';
114  }
115  return $result;
116  }
117 
124  public function isAdminModuleEnabled($key)
125  {
126  $result = false;
127  // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
128  if ($key === 'preview' && $this->ext_forcePreview) {
129  $result = true;
130  } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.']['all'])) {
131  $result = true;
132  } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.'][$key])) {
133  $result = true;
134  }
135  return $result;
136  }
137 
144  public function saveConfigOptions()
145  {
146  $input = GeneralUtility::_GP('TSFE_ADMIN_PANEL');
147  $beUser = $this->getBackendUser();
148  if (is_array($input)) {
149  // Setting
150  $beUser->uc['TSFE_adminConfig'] = array_merge(!is_array($beUser->uc['TSFE_adminConfig']) ? array() : $beUser->uc['TSFE_adminConfig'], $input);
151  unset($beUser->uc['TSFE_adminConfig']['action']);
152  // Actions:
153  if ($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) {
154  $beUser->extPageInTreeInfo = array();
155  $theStartId = (int)$input['cache_clearCacheId'];
156  $this->getTypoScriptFrontendController()->clearPageCacheContent_pidList($beUser->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $beUser->getPagePermsClause(1)) . $theStartId);
157  }
158  // Saving
159  $beUser->writeUC();
160  }
161  $this->getTimeTracker()->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
162  if ($this->extGetFeAdminValue('cache', 'noCache')) {
163  $this->getTypoScriptFrontendController()->set_no_cache('Admin Panel: No Caching', true);
164  }
165  }
166 
174  public function extGetFeAdminValue($sectionName, $val = '')
175  {
176  if (!$this->isAdminModuleEnabled($sectionName)) {
177  return null;
178  }
179 
180  $beUser = $this->getBackendUser();
181  // Exceptions where the values can be overridden (forced) from backend:
182  // deprecated
183  if (
184  $sectionName === 'edit' && (
185  $val === 'displayIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayIcons'] ||
186  $val === 'displayFieldIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'] ||
187  $val === 'editNoPopup' && $beUser->extAdminConfig['module.']['edit.']['forceNoPopup']
188  )
189  ) {
190  return true;
191  }
192 
193  // Override all settings with user TSconfig
194  if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
195  return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
196  }
197  if (isset($beUser->extAdminConfig['override.'][$sectionName])) {
198  return $beUser->extAdminConfig['override.'][$sectionName];
199  }
200 
201  $returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
202 
203  // Exception for preview
204  if ($sectionName === 'preview' && $this->ext_forcePreview) {
205  return !$val ? true : $returnValue;
206  }
207 
208  // See if the menu is expanded!
209  return $this->isAdminModuleOpen($sectionName) ? $returnValue : null;
210  }
211 
217  public function forcePreview()
218  {
219  $this->ext_forcePreview = true;
220  }
221 
228  public function isAdminModuleOpen($key)
229  {
230  return $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] && $this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $key];
231  }
232 
239  public function display()
240  {
241  $this->getLanguageService()->includeLLFile('EXT:lang/locallang_tsfe.xlf');
242  $moduleContent = $footer = '';
243 
244  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
245  if ($this->isAdminModuleEnabled('preview')) {
246  $moduleContent .= $this->getPreviewModule();
247  }
248  if ($this->isAdminModuleEnabled('cache')) {
249  $moduleContent .= $this->getCacheModule();
250  }
251  if ($this->isAdminModuleEnabled('edit')) {
252  $moduleContent .= $this->getEditModule();
253  }
254  if ($this->isAdminModuleEnabled('tsdebug')) {
255  $moduleContent .= $this->getTSDebugModule();
256  }
257  if ($this->isAdminModuleEnabled('info')) {
258  $moduleContent .= $this->getInfoModule();
259  }
260  }
261  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
262  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
263  $hookObject = GeneralUtility::getUserObj($classRef);
264  if (!$hookObject instanceof AdminPanelViewHookInterface) {
265  throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Frontend\\View\\AdminPanelViewHookInterface', 1311942539);
266  }
267  $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
268  }
269  }
270  $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' . htmlspecialchars($this->getBackendUser()->user['username']) . '</span>';
271  $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'];
272  $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
273  $header = '<div class="typo3-adminPanel-header">' . '<div id="typo3-adminPanel-header" class="' . $cssClassName . '">' . '<span class="typo3-adminPanel-header-title">' . $row . '</span>' . $this->linkSectionHeader('top', '<span class="typo3-adminPanel-header-button fa"></span>', 'typo3-adminPanel-header-buttonWrapper') . '<input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] . '" /></div>' . '</div>';
274  if ($moduleContent && $this->extNeedUpdate) {
275  $footer = '<div id="typo3-adminPanel-footer">
276  <input class="typo3-adminPanel-update btn btn-default" type="submit" value="' . $this->extGetLL('update') . '" />
277  </div>';
278  }
279  $query = !GeneralUtility::_GET('id') ? '<input type="hidden" name="id" value="' . $this->getTypoScriptFrontendController()->id . '" />' : '';
280 
281  // The dummy field is needed for Firefox: to force a page reload on submit
282  // which must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
283  $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
284  foreach (GeneralUtility::_GET() as $key => $value) {
285  if ($key != 'TSFE_ADMIN_PANEL') {
286  if (is_array($value)) {
287  $query .= $this->getHiddenFields($key, $value);
288  } else {
289  $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
290  }
291  }
292  }
293  $out = '
294 <!--
295  TYPO3 Admin panel start
296 -->
297 <a id="TSFE_ADMIN_PANEL"></a>
298 <form id="TSFE_ADMIN_PANEL_FORM" name="TSFE_ADMIN_PANEL_FORM" action="' . htmlspecialchars(GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')) . '#TSFE_ADMIN_PANEL" method="get" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">' . $query . '<div class="typo3-adminPanel">' . $header . $moduleContent . $footer . '</div></form>';
299  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
300  $out .= '<script type="text/javascript" src="' . htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix) . 'typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.evalfield.js"></script>';
301  $out .= '<script type="text/javascript">/*<![CDATA[*/' . GeneralUtility::minifyJavaScript('
302  var evalFunc = new evalFunc();
303  // TSFEtypo3FormFieldSet()
304  function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
305  var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
306  var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
307  if (checkbox && theValue==checkboxValue) {
308  document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
309  alert(theField);
310  document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
311  } else {
312  document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
313  if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
314  document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
315  }
316  }
317  }
318  // TSFEtypo3FormFieldGet()
319  function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
320  var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
321  if (checkbox_off) {
322  document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
323  }else{
324  document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
325  }
326  TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
327  }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
328  }
329  $out .= '<script src="' . GeneralUtility::locationHeaderUrl('typo3/sysext/frontend/Resources/Public/JavaScript/AdminPanel.js') . '" type="text/javascript"></script><script type="text/javascript">/*<![CDATA[*/' . 'typo3AdminPanel = new TYPO3AdminPanel();typo3AdminPanel.init("typo3-adminPanel-header", "TSFE_ADMIN_PANEL_FORM");' . '/*]]>*/</script>
330 <!--
331  TYPO3 admin panel end
332 -->
333 ';
334  return $out;
335  }
336 
346  protected function getHiddenFields($key, array $val)
347  {
348  $out = '';
349  foreach ($val as $k => $v) {
350  if (is_array($v)) {
351  $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
352  } else {
353  $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
354  }
355  }
356  return $out;
357  }
358 
359  /*****************************************************
360  * Creating sections of the Admin Panel
361  ****************************************************/
368  protected function getPreviewModule()
369  {
370  $out = $this->extGetHead('preview');
371  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_preview']) {
372  $this->extNeedUpdate = true;
373  $out .= $this->extGetItem('preview_showHiddenPages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" /><input type="checkbox" id="preview_showHiddenPages" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_showHiddenPages'] ? ' checked="checked"' : '') . ' />');
374  $out .= $this->extGetItem('preview_showHiddenRecords', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" /><input type="checkbox" id="preview_showHiddenRecords" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_showHiddenRecords'] ? ' checked="checked"' : '') . ' />');
375  // Simulate date
376  $out .= $this->extGetItem('preview_simulateDate', '<input type="text" id="preview_simulateDate" 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="' . $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateDate'] . '" />');
377  $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
378  // Simulate fe_user:
379 
380  $options = '';
381 
382  $res = $this->getDatabaseConnection()->exec_SELECTquery(
383  'fe_groups.uid, fe_groups.title',
384  'fe_groups,pages',
385  'pages.uid=fe_groups.pid AND pages.deleted=0 ' . BackendUtility::deleteClause('fe_groups') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1),
386  '',
387  'fe_groups.title ASC'
388  );
389  while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
390  $options .= '<option value="' . $row['uid'] . '"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(($row['title'] . ' [' . $row['uid'] . ']')) . '</option>';
391  }
392  $this->getDatabaseConnection()->sql_free_result($res);
393  if ($options) {
394  $options = '<option value="0">&nbsp;</option>' . $options;
395  $out .= $this->extGetItem('preview_simulateUserGroup', '<select id="preview_simulateUserGroup" name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
396  }
397  }
398  return $out;
399  }
400 
407  protected function getCacheModule()
408  {
409  $out = $this->extGetHead('cache');
410  $beUser = $this->getBackendUser();
411  if ($beUser->uc['TSFE_adminConfig']['display_cache']) {
412  $this->extNeedUpdate = true;
413  $out .= $this->extGetItem('cache_noCache', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" /><input id="cache_noCache" type="checkbox" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"' . ($beUser->uc['TSFE_adminConfig']['cache_noCache'] ? ' checked="checked"' : '') . ' />');
414  $levels = $beUser->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
415  $options = '';
416  $options .= '<option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
417  $options .= '<option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
418  $options .= '<option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
419  $out .= $this->extGetItem('cache_clearLevels', '<select id="cache_clearLevels" name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' . '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" /> <input class="btn btn-default" type="submit" value="' . $this->extGetLL('update') . '" />');
420  // Generating tree:
421  $depth = (int)$this->extGetFeAdminValue('cache', 'clearCacheLevels');
422  $outTable = '';
423  $tsfe = $this->getTypoScriptFrontendController();
424  $beUser->extPageInTreeInfo = array();
425  $beUser->extPageInTreeInfo[] = array($tsfe->page['uid'], htmlspecialchars($tsfe->page['title']), $depth + 1);
426  $beUser->extGetTreeList($tsfe->id, $depth, 0, $beUser->getPagePermsClause(1));
427  foreach ($beUser->extPageInTreeInfo as $key => $row) {
428  $outTable .= '<tr class="typo3-adminPanel-itemRow ' . ($key % 2 == 0 ? 'line-even' : 'line-odd') . '">' . '<td><span style="width: ' . ($depth + 1 - $row[2]) * 18 . 'px; height: 1px; display: inline-block;"></span>' . $this->iconFactory->getIcon('apps-pagetree-page-default', Icon::SIZE_SMALL)->render() . htmlspecialchars($row[1]) . '</td><td>' . $beUser->extGetNumberOfCachedPages($row[0]) . '</td></tr>';
429  }
430  $outTable = '<table class="typo3-adminPanel-table"><thead><tr><th colspan="2">' . $this->extGetLL('cache_cacheEntries') . '</th></tr></thead>' . $outTable . '</table>';
431  $outTable .= '<span class="fa fa-bolt clear-cache-icon"><!-- --></span><input class="btn btn-default clear-cache" type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
432 
433  $out .= $this->extGetItem('', $outTable, '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper');
434  }
435  return $out;
436  }
437 
444  protected function getEditModule()
445  {
446  $out = $this->extGetHead('edit');
447  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_edit']) {
448  // If another page module was specified, replace the default Page module with the new one
449  $newPageModule = trim($this->getBackendUser()->getTSConfigVal('options.overridePageModule'));
450  $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
451  $this->extNeedUpdate = true;
452  $out .= $this->extGetItem('edit_displayFieldIcons', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" /><input type="checkbox" id="edit_displayFieldIcons" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['edit_displayFieldIcons'] ? ' checked="checked"' : '') . ' />');
453  $out .= $this->extGetItem('edit_displayIcons', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" /><input type="checkbox" id="edit_displayIcons" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['edit_displayIcons'] ? ' checked="checked"' : '') . ' />');
454  $out .= $this->extGetItem('', $this->ext_makeToolBar());
455  if (!GeneralUtility::_GP('ADMCMD_view')) {
456  $out .= $this->extGetItem('', '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('
457  if (parent.opener && parent.opener.top && parent.opener.top.TS) {
458  parent.opener.top.fsMod.recentIds["web"]=' . (int)$this->getTypoScriptFrontendController()->page['uid'] . ';
459  if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
460  parent.opener.top.content.nav_frame.refresh_nav();
461  }
462  parent.opener.top.goToModule("' . $pageModule . '");
463  parent.opener.top.focus();
464  } else {
465  vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getBackendScript()) . ',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\');
466  vHWin.focus();
467  }
468  return false;
469  ')) . '">' . $this->extGetLL('edit_openAB') . '</a>');
470  }
471  }
472  return $out;
473  }
474 
481  protected function getTSDebugModule()
482  {
483  $out = $this->extGetHead('tsdebug');
484  $beuser = $this->getBackendUser();
485  if ($beuser->uc['TSFE_adminConfig']['display_tsdebug']) {
486  $this->extNeedUpdate = true;
487  $out .= $this->extGetItem('tsdebug_tree', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" /><input type="checkbox" id="tsdebug_tree" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') . ' />');
488  $out .= $this->extGetItem('tsdebug_displayTimes', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" /><input id="tsdebug_displayTimes" type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') . ' />');
489  $out .= $this->extGetItem('tsdebug_displayMessages', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" id="tsdebug_displayMessages" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"' : '') . ' />');
490  $out .= $this->extGetItem('tsdebug_LR', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" id="tsdebug_LR" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />');
491  $out .= $this->extGetItem('tsdebug_displayContent', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" id="tsdebug_displayContent" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />');
492  $out .= $this->extGetItem('tsdebug_displayQueries', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" id="tsdebug_displayQueries" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_displayQueries'] ? ' checked="checked"' : '') . ' />');
493  $out .= $this->extGetItem('tsdebug_forceTemplateParsing', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" id="tsdebug_forceTemplateParsing" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"' . ($beuser->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />');
494  $timeTracker = $this->getTimeTracker();
495  $timeTracker->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
496  $timeTracker->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
497  $timeTracker->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
498  $timeTracker->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
499  $timeTracker->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
500  $out .= $this->extGetItem('', $timeTracker->printTSlog(), '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper scroll-table');
501  }
502  return $out;
503  }
504 
511  protected function getInfoModule()
512  {
513  $head = $this->extGetHead('info');
514  $out = '';
515  $tsfe = $this->getTypoScriptFrontendController();
516  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_info']) {
517  $tableArr = array();
518  if ($this->extGetFeAdminValue('cache', 'noCache')) {
519  $theBytes = 0;
520  $count = 0;
521  if (!empty($tsfe->imagesOnPage)) {
522  $tableArr[] = array($this->extGetLL('info_imagesOnPage'), count($tsfe->imagesOnPage), true);
523  foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
524  $fs = @filesize($file);
525  $tableArr[] = array(TAB . $file, GeneralUtility::formatSize($fs));
526  $theBytes += $fs;
527  $count++;
528  }
529  }
530  // Add an empty line
531  $tableArr[] = array($this->extGetLL('info_imagesSize'), GeneralUtility::formatSize($theBytes), true);
532  $tableArr[] = array($this->extGetLL('info_DocumentSize'), GeneralUtility::formatSize(strlen($tsfe->content)), true);
533  $tableArr[] = array('', '');
534  }
535  $tableArr[] = array($this->extGetLL('info_id'), $tsfe->id);
536  $tableArr[] = array($this->extGetLL('info_type'), $tsfe->type);
537  $tableArr[] = array($this->extGetLL('info_groupList'), $tsfe->gr_list);
538  $tableArr[] = array($this->extGetLL('info_noCache'), $this->extGetLL('info_noCache_' . ($tsfe->no_cache ? 'no' : 'yes')));
539  $tableArr[] = array($this->extGetLL('info_countUserInt'), count($tsfe->config['INTincScript']));
540 
541  if (!empty($tsfe->fe_user->user['uid'])) {
542  $tableArr[] = array($this->extGetLL('info_feuserName'), htmlspecialchars($tsfe->fe_user->user['username']));
543  $tableArr[] = array($this->extGetLL('info_feuserId'), htmlspecialchars($tsfe->fe_user->user['uid']));
544  }
545  $tableArr[] = array($this->extGetLL('info_totalParsetime'), $tsfe->scriptParseTime . ' ms', true);
546  $table = '';
547  foreach ($tableArr as $key => $arr) {
548  $label = (isset($arr[2]) ? '<strong>' . $arr[0] . '</strong>' : $arr[0]);
549  $value = (string)$arr[1] !== '' ? $arr[1] : '';
550  $table .=
551  '<tr class="typo3-adminPanel-itemRow ' . ($key % 2 == 0 ? 'line-even' : 'line-odd') . '">
552  <td>' . $label . '</td>
553  <td>' . htmlspecialchars($value) . '</td>
554  </tr>';
555  }
556  $out .= $table;
557  $out = '<table class="typo3-adminPanel-table">' . $out . '</table>';
558  $out = $this->extGetItem('', $out, '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper');
559  }
560 
561  $out = $head . $out;
562  return $out;
563  }
564 
565  /*****************************************************
566  * Admin Panel Layout Helper functions
567  ****************************************************/
577  public function extGetHead($sectionSuffix)
578  {
579  $settingName = 'display_' . $sectionSuffix;
580  $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig'][$settingName];
581  $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ? 'open' : 'closed');
582  return '<div class="typo3-adminPanel-section-title"><div class="wrapper">' . $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix), $cssClassName) . '<input type="hidden" name="TSFE_ADMIN_PANEL[' . $settingName . ']" value="' . $isVisible . '" /></div></div>';
583  }
584 
594  public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '')
595  {
596  $onclick = 'document.TSFE_ADMIN_PANEL_FORM[' . GeneralUtility::quoteJSvalue('TSFE_ADMIN_PANEL[display_' . $sectionSuffix . ']') . '].value=' . ($this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $sectionSuffix] ? '0' : '1') . ';document.TSFE_ADMIN_PANEL_FORM.submit();return false;';
597  $content = '<div class="typo3-adminPanel-label">
598  <a href="javascript:void(0)" onclick="' . htmlspecialchars($onclick) . '"' . ($className ? ' class="fa ' . htmlspecialchars($className) . '"' : '') . '>'
599  . $sectionTitle .
600  '</a>
601  </div>';
602  return $content;
603  }
604 
617  public function extGetItem($title, $content = '', $checkbox = '', $outerDivClass = null, $innerDivClass = null)
618  {
619  $title = $title ? '<label for="' . htmlspecialchars($title) . '">' . $this->extGetLL($title) . '</label>' : '';
620  $outerDivClass === null ? $out = '<div class="typo3-adminPanel-itemRow">' : $out = '<div class="' . $outerDivClass . '">';
621  $innerDivClass === null ? $out .= '<div class="typo3-adminPanel-section-content">' : $out .= '<div class="' . $innerDivClass . '">';
622  $out .= $checkbox . $title . $content . '</div>
623  </div>';
624  return $out;
625  }
626 
632  public function ext_makeToolBar()
633  {
634  $tsfe = $this->getTypoScriptFrontendController();
635  // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
636  $tsConfig = BackendUtility::getModTSconfig($tsfe->page['uid'], 'mod');
637  $moduleName = $tsConfig['properties']['newContentElementWizard.']['override'] ?: 'new_content_element';
638  $newContentWizScriptPath = BackendUtility::getModuleUrl($moduleName);
639  $perms = $this->getBackendUser()->calcPerms($tsfe->page);
640  $langAllowed = $this->getBackendUser()->checkLanguageAccess($tsfe->sys_language_uid);
641  $id = $tsfe->id;
642  $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
643 
644  $icon = $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render();
645  $link = BackendUtility::getModuleUrl('record_history', array('element' => 'pages:' . $id, 'returnUrl' => $returnUrl));
646  $toolBar = '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '#latest" title="' . $this->extGetLL('edit_recordHistory') . '">' . $icon . '</a>';
647  if ($perms & Permission::CONTENT_EDIT && $langAllowed) {
648  $params = '';
649  if ($tsfe->sys_language_uid) {
650  $params = '&sys_language_uid=' . $tsfe->sys_language_uid;
651  }
652  $icon = $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render();
653  $link = $newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . rawurlencode($returnUrl);
654  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '" title="' . $this->extGetLL('edit_newContentElement') . '"">' . $icon . '</a>';
655  }
656  if ($perms & Permission::PAGE_EDIT) {
657  $icon = $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)->render();
658  $link = BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl]);
659  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '" title="' . $this->extGetLL('edit_move_page') . '">' . $icon . '</a>';
660  }
661  if ($perms & Permission::PAGE_NEW) {
662  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars(BackendUtility::getModuleUrl('db_new', ['id' => $id, 'pagesOnly' => 1, 'returnUrl' => $returnUrl])) . '" title="' . $this->extGetLL('edit_newPage') . '">'
663  . $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render()
664  . '</a>';
665  }
666  if ($perms & Permission::PAGE_EDIT) {
667  $icon = $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render();
668  $url = BackendUtility::getModuleUrl('record_edit', array(
669  'edit[pages][' . $id . ']' => 'edit',
670  'noView' => 1,
671  'returnUrl' => $returnUrl
672  ));
673  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($url) . '">' . $icon . '</a>';
674  if ($tsfe->sys_language_uid && $langAllowed) {
675  $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
676  'uid,pid,t3ver_state',
677  'pages_language_overlay',
678  'pid=' . (int)$id .
679  ' AND sys_language_uid=' . $tsfe->sys_language_uid .
680  $tsfe->sys_page->enableFields('pages_language_overlay')
681  );
682  $tsfe->sys_page->versionOL('pages_language_overlay', $row);
683  if (is_array($row)) {
684  $icon = '<span title="' . $this->extGetLL('edit_editPageOverlay', true) . '">'
685  . $this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL)->render() . '</span>';
686  $url = BackendUtility::getModuleUrl('record_edit', array(
687  'edit[pages_language_overlay][' . $row['uid'] . ']' => 'edit',
688  'noView' => 1,
689  'returnUrl' => $returnUrl
690  ));
691  $toolBar .= '<a href="' . htmlspecialchars($url) . '">' . $icon . '</a>';
692  }
693  }
694  }
695  if ($this->getBackendUser()->check('modules', 'web_list')) {
696  $urlParams = array(
697  'id' => $id,
698  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
699  );
700  $icon = '<span title="' . $this->extGetLL('edit_db_list', false) . '">' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '</span>';
701  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_list', $urlParams)) . '">' . $icon . '</a>';
702  }
703 
704  $toolBar = '<div class="toolbar btn-group" role="group">' . $toolBar . '</div>';
705  return $toolBar;
706  }
707 
715  protected function extGetLL($key, $convertWithHtmlspecialchars = true)
716  {
717  $labelStr = $this->getLanguageService()->getLL($key);
718  if ($convertWithHtmlspecialchars) {
719  $labelStr = htmlspecialchars($labelStr);
720  }
721  return $labelStr;
722  }
723 
729  protected function getLanguageService()
730  {
731  return $GLOBALS['LANG'];
732  }
733 
739  protected function getBackendUser()
740  {
741  return $GLOBALS['BE_USER'];
742  }
743 
749  protected function getDatabaseConnection()
750  {
751  return $GLOBALS['TYPO3_DB'];
752  }
753 
757  protected function getTypoScriptFrontendController()
758  {
759  return $GLOBALS['TSFE'];
760  }
761 
765  protected function getTimeTracker()
766  {
767  return $GLOBALS['TT'];
768  }
769 }