TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
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 
28 
33 {
39  protected $extNeedUpdate = false;
40 
46  protected $ext_forcePreview = false;
47 
51  protected $extJSCODE = '';
52 
56  protected $iconFactory;
57 
63  protected $extFeEditLoaded = false;
64 
68  public function __construct()
69  {
70  $this->initialize();
71  }
72 
78  public function initialize()
79  {
80  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
81  $this->saveConfigOptions();
82  $typoScriptFrontend = $this->getTypoScriptFrontendController();
83  // Setting some values based on the admin panel
84  $this->extFeEditLoaded = ExtensionManagementUtility::isLoaded('feedit');
85  $typoScriptFrontend->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
86  $typoScriptFrontend->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
87  $typoScriptFrontend->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
88  if (GeneralUtility::_GP('ADMCMD_editIcons')) {
89  $typoScriptFrontend->displayFieldEditIcons = 1;
90  }
91  if (GeneralUtility::_GP('ADMCMD_simUser')) {
92  $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] = (int)GeneralUtility::_GP('ADMCMD_simUser');
93  $this->ext_forcePreview = true;
94  }
95  if (GeneralUtility::_GP('ADMCMD_simTime')) {
96  $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateDate'] = (int)GeneralUtility::_GP('ADMCMD_simTime');
97  $this->ext_forcePreview = true;
98  }
99  if ($typoScriptFrontend->forceTemplateParsing) {
100  $typoScriptFrontend->set_no_cache('Admin Panel: Force template parsing', true);
101  } elseif ($this->extFeEditLoaded && $typoScriptFrontend->displayEditIcons) {
102  $typoScriptFrontend->set_no_cache('Admin Panel: Display edit icons', true);
103  } elseif ($this->extFeEditLoaded && $typoScriptFrontend->displayFieldEditIcons) {
104  $typoScriptFrontend->set_no_cache('Admin Panel: Display field edit icons', true);
105  } elseif (GeneralUtility::_GP('ADMCMD_view')) {
106  $typoScriptFrontend->set_no_cache('Admin Panel: Display preview', true);
107  }
108  }
109 
115  public function getAdminPanelHeaderData()
116  {
117  $result = '';
118  if (!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
119  $stylesheet = GeneralUtility::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel']);
120  $result = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($stylesheet) . '" />';
121  }
122  return $result;
123  }
124 
131  public function isAdminModuleEnabled($key)
132  {
133  $result = false;
134  // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
135  if ($key === 'preview' && $this->ext_forcePreview) {
136  $result = true;
137  } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.']['all'])) {
138  $result = true;
139  } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.'][$key])) {
140  $result = true;
141  }
142  return $result;
143  }
144 
151  public function saveConfigOptions()
152  {
153  $input = GeneralUtility::_GP('TSFE_ADMIN_PANEL');
154  $beUser = $this->getBackendUser();
155  if (is_array($input)) {
156  // Setting
157  $beUser->uc['TSFE_adminConfig'] = array_merge(!is_array($beUser->uc['TSFE_adminConfig']) ? [] : $beUser->uc['TSFE_adminConfig'], $input);
158  unset($beUser->uc['TSFE_adminConfig']['action']);
159  // Actions:
160  if (($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) || isset($input['preview_showFluidDebug'])) {
161  $beUser->extPageInTreeInfo = [];
162  $theStartId = (int)$input['cache_clearCacheId'];
163  $this->getTypoScriptFrontendController()->clearPageCacheContent_pidList($beUser->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $beUser->getPagePermsClause(1)) . $theStartId);
164  }
165  // Saving
166  $beUser->writeUC();
167  // Flush fluid template cache
168  $cacheManager = new CacheManager();
169  $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
170  $cacheManager->getCache('fluid_template')->flush();
171  }
172  $this->getTimeTracker()->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
173  if ($this->extGetFeAdminValue('cache', 'noCache')) {
174  $this->getTypoScriptFrontendController()->set_no_cache('Admin Panel: No Caching', true);
175  }
176  }
177 
185  public function extGetFeAdminValue($sectionName, $val = '')
186  {
187  if (!$this->isAdminModuleEnabled($sectionName)) {
188  return null;
189  }
190 
191  $beUser = $this->getBackendUser();
192  // Exceptions where the values can be overridden (forced) from backend:
193  // deprecated
194  if (
195  $sectionName === 'edit' && (
196  $val === 'displayIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayIcons'] ||
197  $val === 'displayFieldIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'] ||
198  $val === 'editNoPopup' && $beUser->extAdminConfig['module.']['edit.']['forceNoPopup']
199  )
200  ) {
201  return true;
202  }
203 
204  // Override all settings with user TSconfig
205  if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
206  return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
207  }
208  if (isset($beUser->extAdminConfig['override.'][$sectionName])) {
209  return $beUser->extAdminConfig['override.'][$sectionName];
210  }
211 
212  $returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
213 
214  // Exception for preview
215  if ($sectionName === 'preview' && $this->ext_forcePreview) {
216  return !$val ? true : $returnValue;
217  }
218 
219  // See if the menu is expanded!
220  return $this->isAdminModuleOpen($sectionName) ? $returnValue : null;
221  }
222 
228  public function forcePreview()
229  {
230  $this->ext_forcePreview = true;
231  }
232 
239  public function isAdminModuleOpen($key)
240  {
241  return $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] && $this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $key];
242  }
243 
250  public function display()
251  {
252  $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_tsfe.xlf');
253  $moduleContent = $updateButton = '';
254 
255  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
256  if ($this->isAdminModuleEnabled('preview')) {
257  $moduleContent .= $this->getPreviewModule();
258  }
259  if ($this->isAdminModuleEnabled('cache')) {
260  $moduleContent .= $this->getCacheModule();
261  }
262  if ($this->isAdminModuleEnabled('edit')) {
263  $moduleContent .= $this->getEditModule();
264  }
265  if ($this->isAdminModuleEnabled('tsdebug')) {
266  $moduleContent .= $this->getTSDebugModule();
267  }
268  if ($this->isAdminModuleEnabled('info')) {
269  $moduleContent .= $this->getInfoModule();
270  }
271  }
272  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
273  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
274  $hookObject = GeneralUtility::getUserObj($classRef);
275  if (!$hookObject instanceof AdminPanelViewHookInterface) {
276  throw new \UnexpectedValueException($classRef . ' must implement interface ' . AdminPanelViewHookInterface::class, 1311942539);
277  }
278  $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
279  }
280  }
281  $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' . htmlspecialchars($this->getBackendUser()->user['username']) . '</span>';
282  $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'];
283  $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
284  $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>';
285  if ($moduleContent && $this->extNeedUpdate) {
286  $updateButton = '<div class="typo3-adminPanel-itemRow updatebutton"><div class="typo3-adminPanel-section-content">
287  <input class="btn btn-default" type="submit" value="' . $this->extGetLL('update') . '" />
288  </div></div>';
289  }
290  $query = !GeneralUtility::_GET('id') ? '<input type="hidden" name="id" value="' . $this->getTypoScriptFrontendController()->id . '" />' : '';
291 
292  // The dummy field is needed for Firefox: to force a page reload on submit
293  // which must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
294  $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
295  foreach (GeneralUtility::_GET() as $key => $value) {
296  if ($key != 'TSFE_ADMIN_PANEL') {
297  if (is_array($value)) {
298  $query .= $this->getHiddenFields($key, $value);
299  } else {
300  $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
301  }
302  }
303  }
304  $out = '
305 <!--
306  TYPO3 Admin panel start
307 -->
308 <a id="TSFE_ADMIN_PANEL"></a>
309 <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 . $updateButton . $moduleContent . '</div></form>';
310  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
311  $out .= '<script type="text/javascript" src="' . htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix) . ExtensionManagementUtility::siteRelPath('backend') . 'Resources/Public/JavaScript/jsfunc.evalfield.js"></script>';
312  $out .= '<script type="text/javascript">/*<![CDATA[*/' . GeneralUtility::minifyJavaScript('
313  var evalFunc = new evalFunc();
314  // TSFEtypo3FormFieldSet()
315  function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
316  var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
317  var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
318  if (checkbox && theValue==checkboxValue) {
319  document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
320  alert(theField);
321  document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
322  } else {
323  document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
324  if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
325  document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
326  }
327  }
328  }
329  // TSFEtypo3FormFieldGet()
330  function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
331  var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
332  if (checkbox_off) {
333  document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
334  }else{
335  document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
336  }
337  TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
338  }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
339  }
340  $cssPath = htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix . ExtensionManagementUtility::siteRelPath('frontend')) . 'Resources/Public/Css/adminpanel.css';
341  $out .= '<script src="' . GeneralUtility::locationHeaderUrl(ExtensionManagementUtility::siteRelPath('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>
342 <link type="text/css" rel="stylesheet" href="' . $cssPath . '" media="all" />';
343  $out .= $this->getAdminPanelHeaderData();
344  $out .='
345 <!--
346  TYPO3 admin panel end
347 -->
348 ';
349 
350  return $out;
351  }
352 
362  protected function getHiddenFields($key, array $val)
363  {
364  $out = '';
365  foreach ($val as $k => $v) {
366  if (is_array($v)) {
367  $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
368  } else {
369  $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
370  }
371  }
372  return $out;
373  }
374 
375  /*****************************************************
376  * Creating sections of the Admin Panel
377  ****************************************************/
384  protected function getPreviewModule()
385  {
386  $out = $this->extGetHead('preview');
387  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_preview']) {
388  $this->extNeedUpdate = true;
389  $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"' : '') . ' />');
390  $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"' : '') . ' />');
391  $out .= $this->extGetItem('preview_showFluidDebug', '', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showFluidDebug]" value="0" /><input type="checkbox" id="preview_showFluidDebug" name="TSFE_ADMIN_PANEL[preview_showFluidDebug]" value="1"' . (!empty($this->getBackendUser()->uc['TSFE_adminConfig']['preview_showFluidDebug']) ? ' checked="checked"' : '') . ' />');
392 
393  // Simulate date
394  $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'] . '" />');
395  $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
396  // Simulate fe_user:
397 
398  $options = '';
399 
400  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
401  ->getQueryBuilderForTable('fe_groups');
402  $queryBuilder->getRestrictions()
403  ->removeAll()
404  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
405 
406  $result = $queryBuilder->select('fe_groups.uid', 'fe_groups.title')
407  ->from('fe_groups')
408  ->from('pages')
409  ->where(
410  $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid')),
411  $this->getBackendUser()->getPagePermsClause(1)
412  )
413  ->orderBy('fe_groups.title')
414  ->execute();
415 
416  while ($row = $result->fetch()) {
417  $options .= '<option value="' . $row['uid'] . '"'
418  . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '')
419  . '>' . htmlspecialchars(($row['title'] . ' [' . $row['uid'] . ']')) . '</option>';
420  }
421  if ($options) {
422  $options = '<option value="0">&nbsp;</option>' . $options;
423  $out .= $this->extGetItem(
424  'preview_simulateUserGroup',
425  '<select id="preview_simulateUserGroup" name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'
426  . $options . '</select>'
427  );
428  }
429  }
430  return $out;
431  }
432 
439  protected function getCacheModule()
440  {
441  $out = $this->extGetHead('cache');
442  $beUser = $this->getBackendUser();
443  if ($beUser->uc['TSFE_adminConfig']['display_cache']) {
444  $this->extNeedUpdate = true;
445  $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"' : '') . ' />');
446  $levels = $beUser->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
447  $options = '';
448  $options .= '<option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
449  $options .= '<option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
450  $options .= '<option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
451  $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') . '" />');
452  // Generating tree:
453  $depth = (int)$this->extGetFeAdminValue('cache', 'clearCacheLevels');
454  $outTable = '';
455  $tsfe = $this->getTypoScriptFrontendController();
456  $beUser->extPageInTreeInfo = [];
457  $beUser->extPageInTreeInfo[] = [$tsfe->page['uid'], htmlspecialchars($tsfe->page['title']), $depth + 1];
458  $beUser->extGetTreeList($tsfe->id, $depth, 0, $beUser->getPagePermsClause(1));
459  foreach ($beUser->extPageInTreeInfo as $key => $row) {
460  $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>';
461  }
462  $outTable = '<table class="typo3-adminPanel-table"><thead><tr><th colspan="2">' . $this->extGetLL('cache_cacheEntries') . '</th></tr></thead>' . $outTable . '</table>';
463  $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') . '" />';
464 
465  $out .= $this->extGetItem('', $outTable, '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper');
466  }
467  return $out;
468  }
469 
476  protected function getEditModule()
477  {
478  $out = $this->extGetHead('edit');
479  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_edit']) {
480  // If another page module was specified, replace the default Page module with the new one
481  $newPageModule = trim($this->getBackendUser()->getTSConfigVal('options.overridePageModule'));
482  $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
483  $this->extNeedUpdate = true;
484  if ($this->extFeEditLoaded) {
485  $out .= $this->extGetItem('edit_displayFieldIcons', '',
486  '<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"' : '') . ' />');
487  $out .= $this->extGetItem('edit_displayIcons', '',
488  '<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"' : '') . ' />');
489  }
490  $out .= $this->extGetItem('', $this->ext_makeToolBar());
491  if (!GeneralUtility::_GP('ADMCMD_view')) {
492  $out .= $this->extGetItem('', '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('
493  if (parent.opener && parent.opener.top && parent.opener.top.TS) {
494  parent.opener.top.fsMod.recentIds["web"]=' . (int)$this->getTypoScriptFrontendController()->page['uid'] . ';
495  if (parent.opener.top && parent.opener.top.nav_frame && parent.opener.top.nav_frame.refresh_nav) {
496  parent.opener.top.nav_frame.refresh_nav();
497  }
498  parent.opener.top.goToModule("' . $pageModule . '");
499  parent.opener.top.focus();
500  } else {
501  vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getBackendScript()) . ',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\');
502  vHWin.focus();
503  }
504  return false;
505  ')) . '">' . $this->extGetLL('edit_openAB') . '</a>');
506  }
507  }
508  return $out;
509  }
510 
517  protected function getTSDebugModule()
518  {
519  $out = $this->extGetHead('tsdebug');
520  $beuser = $this->getBackendUser();
521  if ($beuser->uc['TSFE_adminConfig']['display_tsdebug']) {
522  $this->extNeedUpdate = true;
523  $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"' : '') . ' />');
524  $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"' : '') . ' />');
525  $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"' : '') . ' />');
526  $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"' : '') . ' />');
527  $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"' : '') . ' />');
528  $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"' : '') . ' />');
529  $timeTracker = $this->getTimeTracker();
530  $timeTracker->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
531  $timeTracker->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
532  $timeTracker->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
533  $timeTracker->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
534  $out .= $this->extGetItem('', $timeTracker->printTSlog(), '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper scroll-table');
535  }
536  return $out;
537  }
538 
545  protected function getInfoModule()
546  {
547  $head = $this->extGetHead('info');
548  $out = '';
549  $tsfe = $this->getTypoScriptFrontendController();
550  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_info']) {
551  $tableArr = [];
552  if ($this->extGetFeAdminValue('cache', 'noCache')) {
553  $theBytes = 0;
554  $count = 0;
555  if (!empty($tsfe->imagesOnPage)) {
556  $tableArr[] = [$this->extGetLL('info_imagesOnPage'), count($tsfe->imagesOnPage), true];
557  foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
558  $fs = @filesize($file);
559  $tableArr[] = [TAB . $file, GeneralUtility::formatSize($fs)];
560  $theBytes += $fs;
561  $count++;
562  }
563  }
564  // Add an empty line
565  $tableArr[] = [$this->extGetLL('info_imagesSize'), GeneralUtility::formatSize($theBytes), true];
566  $tableArr[] = [$this->extGetLL('info_DocumentSize'), GeneralUtility::formatSize(strlen($tsfe->content)), true];
567  $tableArr[] = ['', ''];
568  }
569  $tableArr[] = [$this->extGetLL('info_id'), $tsfe->id];
570  $tableArr[] = [$this->extGetLL('info_type'), $tsfe->type];
571  $tableArr[] = [$this->extGetLL('info_groupList'), $tsfe->gr_list];
572  $tableArr[] = [$this->extGetLL('info_noCache'), $this->extGetLL('info_noCache_' . ($tsfe->no_cache ? 'no' : 'yes'))];
573  $tableArr[] = [$this->extGetLL('info_countUserInt'), count($tsfe->config['INTincScript'])];
574 
575  if (!empty($tsfe->fe_user->user['uid'])) {
576  $tableArr[] = [$this->extGetLL('info_feuserName'), htmlspecialchars($tsfe->fe_user->user['username'])];
577  $tableArr[] = [$this->extGetLL('info_feuserId'), htmlspecialchars($tsfe->fe_user->user['uid'])];
578  }
579  $tableArr[] = [$this->extGetLL('info_totalParsetime'), $tsfe->scriptParseTime . ' ms', true];
580  $table = '';
581  foreach ($tableArr as $key => $arr) {
582  $label = (isset($arr[2]) ? '<strong>' . $arr[0] . '</strong>' : $arr[0]);
583  $value = (string)$arr[1] !== '' ? $arr[1] : '';
584  $table .=
585  '<tr class="typo3-adminPanel-itemRow ' . ($key % 2 == 0 ? 'line-even' : 'line-odd') . '">
586  <td>' . $label . '</td>
587  <td>' . htmlspecialchars($value) . '</td>
588  </tr>';
589  }
590  $out .= $table;
591  $out = '<table class="typo3-adminPanel-table">' . $out . '</table>';
592  $out = $this->extGetItem('', $out, '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper');
593  }
594 
595  $out = $head . $out;
596  return $out;
597  }
598 
599  /*****************************************************
600  * Admin Panel Layout Helper functions
601  ****************************************************/
611  public function extGetHead($sectionSuffix)
612  {
613  $settingName = 'display_' . $sectionSuffix;
614  $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig'][$settingName];
615  $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ? 'open' : 'closed');
616  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>';
617  }
618 
628  public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '')
629  {
630  $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;';
631  $content = '<div class="typo3-adminPanel-label">
632  <a href="javascript:void(0)" onclick="' . htmlspecialchars($onclick) . '"' . ($className ? ' class="fa ' . htmlspecialchars($className) . '"' : '') . '>'
633  . $sectionTitle .
634  '</a>
635  </div>';
636  return $content;
637  }
638 
651  public function extGetItem($title, $content = '', $checkbox = '', $outerDivClass = null, $innerDivClass = null)
652  {
653  $title = $title ? '<label for="' . htmlspecialchars($title) . '">' . $this->extGetLL($title) . '</label>' : '';
654  $outerDivClass === null ? $out = '<div class="typo3-adminPanel-itemRow">' : $out = '<div class="' . $outerDivClass . '">';
655  $innerDivClass === null ? $out .= '<div class="typo3-adminPanel-section-content">' : $out .= '<div class="' . $innerDivClass . '">';
656  $out .= $checkbox . $title . $content . '</div>
657  </div>';
658  return $out;
659  }
660 
666  public function ext_makeToolBar()
667  {
668  $tsfe = $this->getTypoScriptFrontendController();
669  // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
670  $tsConfig = BackendUtility::getModTSconfig($tsfe->page['uid'], 'mod');
671  $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
672  ? $tsConfig['properties']['newContentElementWizard.']['override']
673  : 'new_content_element';
674  $newContentWizScriptPath = BackendUtility::getModuleUrl($moduleName);
675  $perms = $this->getBackendUser()->calcPerms($tsfe->page);
676  $langAllowed = $this->getBackendUser()->checkLanguageAccess($tsfe->sys_language_uid);
677  $id = $tsfe->id;
678  $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
679 
680  $icon = $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render();
681  $link = BackendUtility::getModuleUrl('record_history', ['element' => 'pages:' . $id, 'returnUrl' => $returnUrl]);
682  $toolBar = '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '#latest" title="' . $this->extGetLL('edit_recordHistory') . '">' . $icon . '</a>';
683  if ($perms & Permission::CONTENT_EDIT && $langAllowed) {
684  $params = '';
685  if ($tsfe->sys_language_uid) {
686  $params = '&sys_language_uid=' . $tsfe->sys_language_uid;
687  }
688  $icon = $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render();
689  $link = $newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . rawurlencode($returnUrl);
690  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '" title="' . $this->extGetLL('edit_newContentElement') . '"">' . $icon . '</a>';
691  }
692  if ($perms & Permission::PAGE_EDIT) {
693  $icon = $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)->render();
694  $link = BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl]);
695  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '" title="' . $this->extGetLL('edit_move_page') . '">' . $icon . '</a>';
696  }
697  if ($perms & Permission::PAGE_NEW) {
698  $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') . '">'
699  . $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render()
700  . '</a>';
701  }
702  if ($perms & Permission::PAGE_EDIT) {
703  $icon = $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render();
704  $url = BackendUtility::getModuleUrl('record_edit', [
705  'edit[pages][' . $id . ']' => 'edit',
706  'noView' => 1,
707  'returnUrl' => $returnUrl
708  ]);
709  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($url) . '">' . $icon . '</a>';
710  if ($tsfe->sys_language_uid && $langAllowed) {
711  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
712  ->getQueryBuilderForTable('pages_language_overlay');
713  $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
714  $row = $queryBuilder
715  ->select('uid', 'pid', 't3ver_state')
716  ->from('pages_language_overlay')
717  ->where(
718  $queryBuilder->expr()->eq(
719  'pid',
720  $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)
721  ),
722  $queryBuilder->expr()->eq(
723  'sys_language_uid',
724  $queryBuilder->createNamedParameter($tsfe->sys_language_uid, \PDO::PARAM_INT)
725  )
726  )
727  ->setMaxResults(1)
728  ->execute()
729  ->fetch();
730 
731  $tsfe->sys_page->versionOL('pages_language_overlay', $row);
732  if (is_array($row)) {
733  $icon = '<span title="' . $this->extGetLL('edit_editPageOverlay', true) . '">'
734  . $this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL)->render() . '</span>';
735  $url = BackendUtility::getModuleUrl('record_edit', [
736  'edit[pages_language_overlay][' . $row['uid'] . ']' => 'edit',
737  'noView' => 1,
738  'returnUrl' => $returnUrl
739  ]);
740  $toolBar .= '<a href="' . htmlspecialchars($url) . '">' . $icon . '</a>';
741  }
742  }
743  }
744  if ($this->getBackendUser()->check('modules', 'web_list')) {
745  $urlParams = [
746  'id' => $id,
747  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
748  ];
749  $icon = '<span title="' . $this->extGetLL('edit_db_list', false) . '">' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '</span>';
750  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_list', $urlParams)) . '">' . $icon . '</a>';
751  }
752 
753  $toolBar = '<div class="toolbar btn-group" role="group">' . $toolBar . '</div>';
754  return $toolBar;
755  }
756 
764  protected function extGetLL($key, $convertWithHtmlspecialchars = true)
765  {
766  $labelStr = $this->getLanguageService()->getLL($key);
767  if ($convertWithHtmlspecialchars) {
768  $labelStr = htmlspecialchars($labelStr);
769  }
770  return $labelStr;
771  }
772 
778  protected function getLanguageService()
779  {
780  return $GLOBALS['LANG'];
781  }
782 
788  protected function getBackendUser()
789  {
790  return $GLOBALS['BE_USER'];
791  }
792 
796  protected function getTypoScriptFrontendController()
797  {
798  return $GLOBALS['TSFE'];
799  }
800 
804  protected function getTimeTracker()
805  {
806  return GeneralUtility::makeInstance(TimeTracker::class);
807  }
808 }
linkSectionHeader($sectionSuffix, $sectionTitle, $className= '')
static minifyJavaScript($script, &$error= '')
extGetLL($key, $convertWithHtmlspecialchars=true)
extGetFeAdminValue($sectionName, $val= '')
extGetItem($title, $content= '', $checkbox= '', $outerDivClass=null, $innerDivClass=null)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)