TYPO3 CMS  TYPO3_7-6
AdminPanelView.php
Go to the documentation of this file.
1 <?php
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 
23 
28 {
34  protected $extNeedUpdate = false;
35 
41  protected $ext_forcePreview = false;
42 
46  protected $extJSCODE = '';
47 
51  protected $iconFactory;
52 
58  protected $extFeEditLoaded = false;
59 
63  public function __construct()
64  {
65  $this->initialize();
66  }
67 
73  public function initialize()
74  {
75  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
76  $this->saveConfigOptions();
77  $typoScriptFrontend = $this->getTypoScriptFrontendController();
78  // Setting some values based on the admin panel
79  $this->extFeEditLoaded = ExtensionManagementUtility::isLoaded('feedit');
80  $typoScriptFrontend->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
81  $typoScriptFrontend->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
82  $typoScriptFrontend->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
83  if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
84  // Do not override if the value is already set in \TYPO3\CMS\Core\Database\DatabaseConnection
85  if ($this->getDatabaseConnection()->explainOutput == 0) {
86  // Enable execution of EXPLAIN SELECT queries
87  $this->getDatabaseConnection()->explainOutput = 3;
88  }
89  }
90  if (GeneralUtility::_GP('ADMCMD_editIcons')) {
91  $typoScriptFrontend->displayFieldEditIcons = 1;
92  }
93  if (GeneralUtility::_GP('ADMCMD_simUser')) {
94  $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] = (int)GeneralUtility::_GP('ADMCMD_simUser');
95  $this->ext_forcePreview = true;
96  }
97  if (GeneralUtility::_GP('ADMCMD_simTime')) {
98  $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateDate'] = (int)GeneralUtility::_GP('ADMCMD_simTime');
99  $this->ext_forcePreview = true;
100  }
101  if ($typoScriptFrontend->forceTemplateParsing) {
102  $typoScriptFrontend->set_no_cache('Admin Panel: Force template parsing', true);
103  } elseif ($this->extFeEditLoaded && $typoScriptFrontend->displayEditIcons) {
104  $typoScriptFrontend->set_no_cache('Admin Panel: Display edit icons', true);
105  } elseif ($this->extFeEditLoaded && $typoScriptFrontend->displayFieldEditIcons) {
106  $typoScriptFrontend->set_no_cache('Admin Panel: Display field edit icons', true);
107  } elseif (GeneralUtility::_GP('ADMCMD_view')) {
108  $typoScriptFrontend->set_no_cache('Admin Panel: Display preview', true);
109  }
110  }
111 
117  public function getAdminPanelHeaderData()
118  {
119  $result = '';
120  if (!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
121  $stylesheet = GeneralUtility::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel']);
122  $result = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($stylesheet) . '" />';
123  }
124  return $result;
125  }
126 
133  public function isAdminModuleEnabled($key)
134  {
135  $result = false;
136  // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
137  if ($key === 'preview' && $this->ext_forcePreview) {
138  $result = true;
139  } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.']['all'])) {
140  $result = true;
141  } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.'][$key])) {
142  $result = true;
143  }
144  return $result;
145  }
146 
153  public function saveConfigOptions()
154  {
155  $input = GeneralUtility::_GP('TSFE_ADMIN_PANEL');
156  $beUser = $this->getBackendUser();
157  if (is_array($input)) {
158  // Setting
159  $beUser->uc['TSFE_adminConfig'] = array_merge(!is_array($beUser->uc['TSFE_adminConfig']) ? [] : $beUser->uc['TSFE_adminConfig'], $input);
160  unset($beUser->uc['TSFE_adminConfig']['action']);
161  // Actions:
162  if ($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) {
163  $beUser->extPageInTreeInfo = [];
164  $theStartId = (int)$input['cache_clearCacheId'];
165  $this->getTypoScriptFrontendController()->clearPageCacheContent_pidList($beUser->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $beUser->getPagePermsClause(1)) . $theStartId);
166  }
167  // Saving
168  $beUser->writeUC();
169  }
170  $this->getTimeTracker()->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
171  if ($this->extGetFeAdminValue('cache', 'noCache')) {
172  $this->getTypoScriptFrontendController()->set_no_cache('Admin Panel: No Caching', true);
173  }
174  }
175 
183  public function extGetFeAdminValue($sectionName, $val = '')
184  {
185  if (!$this->isAdminModuleEnabled($sectionName)) {
186  return null;
187  }
188 
189  $beUser = $this->getBackendUser();
190  // Exceptions where the values can be overridden (forced) from backend:
191  // deprecated
192  if (
193  $sectionName === 'edit' && (
194  $val === 'displayIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayIcons'] ||
195  $val === 'displayFieldIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'] ||
196  $val === 'editNoPopup' && $beUser->extAdminConfig['module.']['edit.']['forceNoPopup']
197  )
198  ) {
199  return true;
200  }
201 
202  // Override all settings with user TSconfig
203  if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
204  return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
205  }
206  if (isset($beUser->extAdminConfig['override.'][$sectionName])) {
207  return $beUser->extAdminConfig['override.'][$sectionName];
208  }
209 
210  $returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
211 
212  // Exception for preview
213  if ($sectionName === 'preview' && $this->ext_forcePreview) {
214  return !$val ? true : $returnValue;
215  }
216 
217  // See if the menu is expanded!
218  return $this->isAdminModuleOpen($sectionName) ? $returnValue : null;
219  }
220 
226  public function forcePreview()
227  {
228  $this->ext_forcePreview = true;
229  }
230 
237  public function isAdminModuleOpen($key)
238  {
239  return $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] && $this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $key];
240  }
241 
248  public function display()
249  {
250  $this->getLanguageService()->includeLLFile('EXT:lang/locallang_tsfe.xlf');
251  $moduleContent = $updateButton = '';
252 
253  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
254  if ($this->isAdminModuleEnabled('preview')) {
255  $moduleContent .= $this->getPreviewModule();
256  }
257  if ($this->isAdminModuleEnabled('cache')) {
258  $moduleContent .= $this->getCacheModule();
259  }
260  if ($this->isAdminModuleEnabled('edit')) {
261  $moduleContent .= $this->getEditModule();
262  }
263  if ($this->isAdminModuleEnabled('tsdebug')) {
264  $moduleContent .= $this->getTSDebugModule();
265  }
266  if ($this->isAdminModuleEnabled('info')) {
267  $moduleContent .= $this->getInfoModule();
268  }
269  }
270  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
271  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
272  $hookObject = GeneralUtility::getUserObj($classRef);
273  if (!$hookObject instanceof AdminPanelViewHookInterface) {
274  throw new \UnexpectedValueException($classRef . ' must implement interface ' . AdminPanelViewHookInterface::class, 1311942539);
275  }
276  $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
277  }
278  }
279  $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' . htmlspecialchars($this->getBackendUser()->user['username']) . '</span>';
280  $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'];
281  $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
282  $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>';
283  if ($moduleContent && $this->extNeedUpdate) {
284  $updateButton = '<div class="typo3-adminPanel-itemRow updatebutton"><div class="typo3-adminPanel-section-content">
285  <input class="btn btn-default" type="submit" value="' . $this->extGetLL('update') . '" />
286  </div></div>';
287  }
288  $query = !GeneralUtility::_GET('id') ? '<input type="hidden" name="id" value="' . $this->getTypoScriptFrontendController()->id . '" />' : '';
289 
290  // The dummy field is needed for Firefox: to force a page reload on submit
291  // which must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
292  $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
293  foreach (GeneralUtility::_GET() as $key => $value) {
294  if ($key != 'TSFE_ADMIN_PANEL') {
295  if (is_array($value)) {
296  $query .= $this->getHiddenFields($key, $value);
297  } else {
298  $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
299  }
300  }
301  }
302  $out = '
303 <!--
304  TYPO3 Admin panel start
305 -->
306 <a id="TSFE_ADMIN_PANEL"></a>
307 <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>';
308  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
309  $out .= '<script type="text/javascript" src="' . htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix) . ExtensionManagementUtility::siteRelPath('backend') . 'Resources/Public/JavaScript/jsfunc.evalfield.js"></script>';
310  $out .= '<script type="text/javascript">/*<![CDATA[*/' . GeneralUtility::minifyJavaScript('
311  var evalFunc = new evalFunc();
312  // TSFEtypo3FormFieldSet()
313  function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
314  var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
315  var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
316  if (checkbox && theValue==checkboxValue) {
317  document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
318  alert(theField);
319  document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
320  } else {
321  document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
322  if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
323  document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
324  }
325  }
326  }
327  // TSFEtypo3FormFieldGet()
328  function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
329  var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
330  if (checkbox_off) {
331  document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
332  }else{
333  document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
334  }
335  TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
336  }') . '/*]]>*/</script><script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
337  }
338  $cssPath = htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix . ExtensionManagementUtility::siteRelPath('t3skin')) . 'stylesheets/standalone/admin_panel.css';
339  $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>
340 <link type="text/css" rel="stylesheet" href="' . $cssPath . '" media="all" />';
341  $out .= $this->getAdminPanelHeaderData();
342  $out .='
343 <!--
344  TYPO3 admin panel end
345 -->
346 ';
347 
348  return $out;
349  }
350 
360  protected function getHiddenFields($key, array $val)
361  {
362  $out = '';
363  foreach ($val as $k => $v) {
364  if (is_array($v)) {
365  $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
366  } else {
367  $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
368  }
369  }
370  return $out;
371  }
372 
373  /*****************************************************
374  * Creating sections of the Admin Panel
375  ****************************************************/
382  protected function getPreviewModule()
383  {
384  $out = $this->extGetHead('preview');
385  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_preview']) {
386  $this->extNeedUpdate = true;
387  $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"' : '') . ' />');
388  $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"' : '') . ' />');
389  // Simulate date
390  $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'] . '" />');
391  $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
392  // Simulate fe_user:
393 
394  $options = '';
395 
396  $res = $this->getDatabaseConnection()->exec_SELECTquery(
397  'fe_groups.uid, fe_groups.title',
398  'fe_groups,pages',
399  'pages.uid=fe_groups.pid AND pages.deleted=0 ' . BackendUtility::deleteClause('fe_groups') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1),
400  '',
401  'fe_groups.title ASC'
402  );
403  while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
404  $options .= '<option value="' . $row['uid'] . '"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(($row['title'] . ' [' . $row['uid'] . ']')) . '</option>';
405  }
406  $this->getDatabaseConnection()->sql_free_result($res);
407  if ($options) {
408  $options = '<option value="0">&nbsp;</option>' . $options;
409  $out .= $this->extGetItem('preview_simulateUserGroup', '<select id="preview_simulateUserGroup" name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
410  }
411  }
412  return $out;
413  }
414 
421  protected function getCacheModule()
422  {
423  $out = $this->extGetHead('cache');
424  $beUser = $this->getBackendUser();
425  if ($beUser->uc['TSFE_adminConfig']['display_cache']) {
426  $this->extNeedUpdate = true;
427  $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"' : '') . ' />');
428  $levels = $beUser->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
429  $options = '';
430  $options .= '<option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
431  $options .= '<option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
432  $options .= '<option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
433  $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') . '" />');
434  // Generating tree:
435  $depth = (int)$this->extGetFeAdminValue('cache', 'clearCacheLevels');
436  $outTable = '';
437  $tsfe = $this->getTypoScriptFrontendController();
438  $beUser->extPageInTreeInfo = [];
439  $beUser->extPageInTreeInfo[] = [$tsfe->page['uid'], htmlspecialchars($tsfe->page['title']), $depth + 1];
440  $beUser->extGetTreeList($tsfe->id, $depth, 0, $beUser->getPagePermsClause(1));
441  foreach ($beUser->extPageInTreeInfo as $key => $row) {
442  $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>';
443  }
444  $outTable = '<table class="typo3-adminPanel-table"><thead><tr><th colspan="2">' . $this->extGetLL('cache_cacheEntries') . '</th></tr></thead>' . $outTable . '</table>';
445  $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') . '" />';
446 
447  $out .= $this->extGetItem('', $outTable, '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper');
448  }
449  return $out;
450  }
451 
458  protected function getEditModule()
459  {
460  $out = $this->extGetHead('edit');
461  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_edit']) {
462  // If another page module was specified, replace the default Page module with the new one
463  $newPageModule = trim($this->getBackendUser()->getTSConfigVal('options.overridePageModule'));
464  $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
465  $this->extNeedUpdate = true;
466  if ($this->extFeEditLoaded) {
467  $out .= $this->extGetItem('edit_displayFieldIcons', '',
468  '<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"' : '') . ' />');
469  $out .= $this->extGetItem('edit_displayIcons', '',
470  '<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"' : '') . ' />');
471  }
472  $out .= $this->extGetItem('', $this->ext_makeToolBar());
473  if (!GeneralUtility::_GP('ADMCMD_view')) {
474  $out .= $this->extGetItem('', '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('
475  if (parent.opener && parent.opener.top && parent.opener.top.TS) {
476  parent.opener.top.fsMod.recentIds["web"]=' . (int)$this->getTypoScriptFrontendController()->page['uid'] . ';
477  if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
478  parent.opener.top.content.nav_frame.refresh_nav();
479  }
480  parent.opener.top.goToModule("' . $pageModule . '");
481  parent.opener.top.focus();
482  } else {
483  vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getBackendScript()) . ',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\');
484  vHWin.focus();
485  }
486  return false;
487  ')) . '">' . $this->extGetLL('edit_openAB') . '</a>');
488  }
489  }
490  return $out;
491  }
492 
499  protected function getTSDebugModule()
500  {
501  $out = $this->extGetHead('tsdebug');
502  $beuser = $this->getBackendUser();
503  if ($beuser->uc['TSFE_adminConfig']['display_tsdebug']) {
504  $this->extNeedUpdate = true;
505  $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"' : '') . ' />');
506  $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"' : '') . ' />');
507  $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"' : '') . ' />');
508  $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"' : '') . ' />');
509  $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"' : '') . ' />');
510  $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"' : '') . ' />');
511  $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"' : '') . ' />');
512  $timeTracker = $this->getTimeTracker();
513  $timeTracker->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
514  $timeTracker->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
515  $timeTracker->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
516  $timeTracker->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
517  $timeTracker->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug', 'displayQueries');
518  $out .= $this->extGetItem('', $timeTracker->printTSlog(), '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper scroll-table');
519  }
520  return $out;
521  }
522 
529  protected function getInfoModule()
530  {
531  $head = $this->extGetHead('info');
532  $out = '';
533  $tsfe = $this->getTypoScriptFrontendController();
534  if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_info']) {
535  $tableArr = [];
536  if ($this->extGetFeAdminValue('cache', 'noCache')) {
537  $theBytes = 0;
538  $count = 0;
539  if (!empty($tsfe->imagesOnPage)) {
540  $tableArr[] = [$this->extGetLL('info_imagesOnPage'), count($tsfe->imagesOnPage), true];
541  foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
542  $fs = @filesize($file);
543  $tableArr[] = [TAB . $file, GeneralUtility::formatSize($fs)];
544  $theBytes += $fs;
545  $count++;
546  }
547  }
548  // Add an empty line
549  $tableArr[] = [$this->extGetLL('info_imagesSize'), GeneralUtility::formatSize($theBytes), true];
550  $tableArr[] = [$this->extGetLL('info_DocumentSize'), GeneralUtility::formatSize(strlen($tsfe->content)), true];
551  $tableArr[] = ['', ''];
552  }
553  $tableArr[] = [$this->extGetLL('info_id'), $tsfe->id];
554  $tableArr[] = [$this->extGetLL('info_type'), $tsfe->type];
555  $tableArr[] = [$this->extGetLL('info_groupList'), $tsfe->gr_list];
556  $tableArr[] = [$this->extGetLL('info_noCache'), $this->extGetLL('info_noCache_' . ($tsfe->no_cache ? 'no' : 'yes'))];
557  $tableArr[] = [$this->extGetLL('info_countUserInt'), isset($tsfe->config['INTincScript']) && is_array($tsfe->config['INTincScript']) ? count($tsfe->config['INTincScript']) : 0];
558 
559  if (!empty($tsfe->fe_user->user['uid'])) {
560  $tableArr[] = [$this->extGetLL('info_feuserName'), htmlspecialchars($tsfe->fe_user->user['username'])];
561  $tableArr[] = [$this->extGetLL('info_feuserId'), htmlspecialchars($tsfe->fe_user->user['uid'])];
562  }
563  $tableArr[] = [$this->extGetLL('info_totalParsetime'), $tsfe->scriptParseTime . ' ms', true];
564  $table = '';
565  foreach ($tableArr as $key => $arr) {
566  $label = (isset($arr[2]) ? '<strong>' . $arr[0] . '</strong>' : $arr[0]);
567  $value = (string)$arr[1] !== '' ? $arr[1] : '';
568  $table .=
569  '<tr class="typo3-adminPanel-itemRow ' . ($key % 2 == 0 ? 'line-even' : 'line-odd') . '">
570  <td>' . $label . '</td>
571  <td>' . htmlspecialchars($value) . '</td>
572  </tr>';
573  }
574  $out .= $table;
575  $out = '<table class="typo3-adminPanel-table">' . $out . '</table>';
576  $out = $this->extGetItem('', $out, '', 'typo3-adminPanel-tableRow', 'typo3-adminPanel-table-wrapper');
577  }
578 
579  $out = $head . $out;
580  return $out;
581  }
582 
583  /*****************************************************
584  * Admin Panel Layout Helper functions
585  ****************************************************/
595  public function extGetHead($sectionSuffix)
596  {
597  $settingName = 'display_' . $sectionSuffix;
598  $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig'][$settingName];
599  $cssClassName = 'typo3-adminPanel-section-' . ($isVisible ? 'open' : 'closed');
600  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>';
601  }
602 
612  public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '')
613  {
614  $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;';
615  $content = '<div class="typo3-adminPanel-label">
616  <a href="javascript:void(0)" onclick="' . htmlspecialchars($onclick) . '"' . ($className ? ' class="fa ' . htmlspecialchars($className) . '"' : '') . '>'
617  . $sectionTitle .
618  '</a>
619  </div>';
620  return $content;
621  }
622 
635  public function extGetItem($title, $content = '', $checkbox = '', $outerDivClass = null, $innerDivClass = null)
636  {
637  $title = $title ? '<label for="' . htmlspecialchars($title) . '">' . $this->extGetLL($title) . '</label>' : '';
638  $outerDivClass === null ? $out = '<div class="typo3-adminPanel-itemRow">' : $out = '<div class="' . $outerDivClass . '">';
639  $innerDivClass === null ? $out .= '<div class="typo3-adminPanel-section-content">' : $out .= '<div class="' . $innerDivClass . '">';
640  $out .= $checkbox . $title . $content . '</div>
641  </div>';
642  return $out;
643  }
644 
650  public function ext_makeToolBar()
651  {
652  $tsfe = $this->getTypoScriptFrontendController();
653  // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
654  $tsConfig = BackendUtility::getModTSconfig($tsfe->page['uid'], 'mod');
655  $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
656  ? $tsConfig['properties']['newContentElementWizard.']['override']
657  : 'new_content_element';
658  $perms = $this->getBackendUser()->calcPerms($tsfe->page);
659  $langAllowed = $this->getBackendUser()->checkLanguageAccess($tsfe->sys_language_uid);
660  $id = $tsfe->id;
661  $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
662 
663  $icon = $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render();
664  $link = BackendUtility::getModuleUrl('record_history', ['element' => 'pages:' . $id, 'returnUrl' => $returnUrl]);
665  $toolBar = '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '#latest" title="' . $this->extGetLL('edit_recordHistory') . '">' . $icon . '</a>';
666  if ($perms & Permission::CONTENT_EDIT && $langAllowed) {
667  $linkParameters = [
668  'id' => $id,
669  'returnUrl' => $returnUrl,
670  ];
671  if (!empty($tsfe->sys_language_uid)) {
672  $linkParameters['sys_language_uid'] = $tsfe->sys_language_uid;
673  }
674  $link = BackendUtility::getModuleUrl($moduleName, $linkParameters);
675  $icon = $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render();
676  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '" title="' . $this->extGetLL('edit_newContentElement') . '"">' . $icon . '</a>';
677  }
678  if ($perms & Permission::PAGE_EDIT) {
679  $icon = $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)->render();
680  $link = BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl]);
681  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($link) . '" title="' . $this->extGetLL('edit_move_page') . '">' . $icon . '</a>';
682  }
683  if ($perms & Permission::PAGE_NEW) {
684  $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') . '">'
685  . $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render()
686  . '</a>';
687  }
688  if ($perms & Permission::PAGE_EDIT) {
689  $icon = $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render();
690  $url = BackendUtility::getModuleUrl('record_edit', [
691  'edit[pages][' . $id . ']' => 'edit',
692  'noView' => 1,
693  'returnUrl' => $returnUrl
694  ]);
695  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars($url) . '">' . $icon . '</a>';
696  if ($tsfe->sys_language_uid && $langAllowed) {
697  $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
698  'uid,pid,t3ver_state',
699  'pages_language_overlay',
700  'pid=' . (int)$id .
701  ' AND sys_language_uid=' . $tsfe->sys_language_uid .
702  $tsfe->sys_page->enableFields('pages_language_overlay')
703  );
704  $tsfe->sys_page->versionOL('pages_language_overlay', $row);
705  if (is_array($row)) {
706  $icon = '<span title="' . $this->extGetLL('edit_editPageOverlay', true) . '">'
707  . $this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL)->render() . '</span>';
708  $url = BackendUtility::getModuleUrl('record_edit', [
709  'edit[pages_language_overlay][' . $row['uid'] . ']' => 'edit',
710  'noView' => 1,
711  'returnUrl' => $returnUrl
712  ]);
713  $toolBar .= '<a href="' . htmlspecialchars($url) . '">' . $icon . '</a>';
714  }
715  }
716  }
717  if ($this->getBackendUser()->check('modules', 'web_list')) {
718  $urlParams = [
719  'id' => $id,
720  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
721  ];
722  $icon = '<span title="' . $this->extGetLL('edit_db_list', false) . '">' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '</span>';
723  $toolBar .= '<a class="t3-icon btn btn-default" href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_list', $urlParams)) . '">' . $icon . '</a>';
724  }
725 
726  $toolBar = '<div class="toolbar btn-group" role="group">' . $toolBar . '</div>';
727  return $toolBar;
728  }
729 
737  protected function extGetLL($key, $convertWithHtmlspecialchars = true)
738  {
739  $labelStr = $this->getLanguageService()->getLL($key);
740  if ($convertWithHtmlspecialchars) {
741  $labelStr = htmlspecialchars($labelStr);
742  }
743  return $labelStr;
744  }
745 
751  protected function getLanguageService()
752  {
753  return $GLOBALS['LANG'];
754  }
755 
761  protected function getBackendUser()
762  {
763  return $GLOBALS['BE_USER'];
764  }
765 
771  protected function getDatabaseConnection()
772  {
773  return $GLOBALS['TYPO3_DB'];
774  }
775 
779  protected function getTypoScriptFrontendController()
780  {
781  return $GLOBALS['TSFE'];
782  }
783 
787  protected function getTimeTracker()
788  {
789  return $GLOBALS['TT'];
790  }
791 }
extGetItem($title, $content='', $checkbox='', $outerDivClass=null, $innerDivClass=null)
static minifyJavaScript($script, &$error='')
linkSectionHeader($sectionSuffix, $sectionTitle, $className='')
extGetFeAdminValue($sectionName, $val='')
extGetLL($key, $convertWithHtmlspecialchars=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static deleteClause($table, $tableAlias='')