[BUGFIX] Add missing "Display messages" checkbox to admin panel
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / View / AdminPanelView.php
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
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Cache\CacheManager;
19 use TYPO3\CMS\Core\Database\ConnectionPool;
20 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
21 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
22 use TYPO3\CMS\Core\Imaging\Icon;
23 use TYPO3\CMS\Core\Imaging\IconFactory;
24 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
25 use TYPO3\CMS\Core\Type\Bitmask\Permission;
26 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
27 use TYPO3\CMS\Core\Utility\GeneralUtility;
28
29 /**
30 * View class for the admin panel in frontend editing.
31 */
32 class AdminPanelView
33 {
34 /**
35 * Determines whether the update button should be shown.
36 *
37 * @var bool
38 */
39 protected $extNeedUpdate = false;
40
41 /**
42 * Force preview
43 *
44 * @var bool
45 */
46 protected $ext_forcePreview = false;
47
48 /**
49 * @var string
50 */
51 protected $extJSCODE = '';
52
53 /**
54 * @var IconFactory
55 */
56 protected $iconFactory;
57
58 /**
59 * Determines whether EXT:feedit is loaded
60 *
61 * @var bool
62 */
63 protected $extFeEditLoaded = false;
64
65 /**
66 * Constructor
67 */
68 public function __construct()
69 {
70 $this->initialize();
71 }
72
73 /**
74 * Initializes settings for the admin panel.
75 */
76 public function initialize()
77 {
78 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
79 $this->saveConfigOptions();
80 $typoScriptFrontend = $this->getTypoScriptFrontendController();
81 // Setting some values based on the admin panel
82 $this->extFeEditLoaded = ExtensionManagementUtility::isLoaded('feedit');
83 $typoScriptFrontend->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
84 $typoScriptFrontend->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
85 $typoScriptFrontend->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
86 if (GeneralUtility::_GP('ADMCMD_editIcons')) {
87 $typoScriptFrontend->displayFieldEditIcons = 1;
88 }
89 if (GeneralUtility::_GP('ADMCMD_simUser')) {
90 $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] = (int)GeneralUtility::_GP('ADMCMD_simUser');
91 $this->ext_forcePreview = true;
92 }
93 if (GeneralUtility::_GP('ADMCMD_simTime')) {
94 $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateDate'] = (int)GeneralUtility::_GP('ADMCMD_simTime');
95 $this->ext_forcePreview = true;
96 }
97 if ($typoScriptFrontend->forceTemplateParsing) {
98 $typoScriptFrontend->set_no_cache('Admin Panel: Force template parsing', true);
99 } elseif ($this->extFeEditLoaded && $typoScriptFrontend->displayEditIcons) {
100 $typoScriptFrontend->set_no_cache('Admin Panel: Display edit icons', true);
101 } elseif ($this->extFeEditLoaded && $typoScriptFrontend->displayFieldEditIcons) {
102 $typoScriptFrontend->set_no_cache('Admin Panel: Display field edit icons', true);
103 } elseif (GeneralUtility::_GP('ADMCMD_view')) {
104 $typoScriptFrontend->set_no_cache('Admin Panel: Display preview', true);
105 }
106 }
107
108 /**
109 * Add an additional stylesheet
110 *
111 * @return string
112 */
113 public function getAdminPanelHeaderData()
114 {
115 $result = '';
116 if (!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
117 $stylesheet = GeneralUtility::locationHeaderUrl($GLOBALS['TBE_STYLES']['stylesheets']['admPanel']);
118 $result = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($stylesheet) . '" />';
119 }
120 return $result;
121 }
122
123 /**
124 * Checks if an Admin Panel section ("module") is available for the user. If so, TRUE is returned.
125 *
126 * @param string $key The module key, eg. "edit", "preview", "info" etc.
127 * @return bool
128 */
129 public function isAdminModuleEnabled($key)
130 {
131 $result = false;
132 // Returns TRUE if the module checked is "preview" and the forcePreview flag is set.
133 if ($key === 'preview' && $this->ext_forcePreview) {
134 $result = true;
135 } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.']['all'])) {
136 $result = true;
137 } elseif (!empty($this->getBackendUser()->extAdminConfig['enable.'][$key])) {
138 $result = true;
139 }
140 return $result;
141 }
142
143 /**
144 * Saves any change in settings made in the Admin Panel.
145 * Called from \TYPO3\CMS\Frontend\Http\RequestHandler right after access check for the Admin Panel
146 */
147 public function saveConfigOptions()
148 {
149 $input = GeneralUtility::_GP('TSFE_ADMIN_PANEL');
150 $beUser = $this->getBackendUser();
151 if (is_array($input)) {
152 // Setting
153 $beUser->uc['TSFE_adminConfig'] = array_merge(!is_array($beUser->uc['TSFE_adminConfig']) ? [] : $beUser->uc['TSFE_adminConfig'], $input);
154 unset($beUser->uc['TSFE_adminConfig']['action']);
155 // Actions:
156 if (($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) || isset($input['preview_showFluidDebug'])) {
157 $beUser->extPageInTreeInfo = [];
158 $theStartId = (int)$input['cache_clearCacheId'];
159 $this->getTypoScriptFrontendController()
160 ->clearPageCacheContent_pidList(
161 $beUser->extGetTreeList(
162 $theStartId,
163 $this->extGetFeAdminValue(
164 'cache',
165 'clearCacheLevels'
166 ),
167 0,
168 $beUser->getPagePermsClause(1)
169 ) . $theStartId
170 );
171 }
172 // Saving
173 $beUser->writeUC();
174 // Flush fluid template cache
175 $cacheManager = new CacheManager();
176 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
177 $cacheManager->getCache('fluid_template')->flush();
178 }
179 $this->getTimeTracker()->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
180 if ($this->extGetFeAdminValue('cache', 'noCache')) {
181 $this->getTypoScriptFrontendController()->set_no_cache('Admin Panel: No Caching', true);
182 }
183 }
184
185 /**
186 * Returns the value for an Admin Panel setting.
187 *
188 * @param string $sectionName Module key
189 * @param string $val Setting key
190 * @return mixed The setting value
191 */
192 public function extGetFeAdminValue($sectionName, $val = '')
193 {
194 if (!$this->isAdminModuleEnabled($sectionName)) {
195 return null;
196 }
197
198 $beUser = $this->getBackendUser();
199 // Exceptions where the values can be overridden (forced) from backend:
200 // deprecated
201 if (
202 $sectionName === 'edit' && (
203 $val === 'displayIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayIcons'] ||
204 $val === 'displayFieldIcons' && $beUser->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'] ||
205 $val === 'editNoPopup' && $beUser->extAdminConfig['module.']['edit.']['forceNoPopup']
206 )
207 ) {
208 return true;
209 }
210
211 // Override all settings with user TSconfig
212 if ($val && isset($beUser->extAdminConfig['override.'][$sectionName . '.'][$val])) {
213 return $beUser->extAdminConfig['override.'][$sectionName . '.'][$val];
214 }
215 if (isset($beUser->extAdminConfig['override.'][$sectionName])) {
216 return $beUser->extAdminConfig['override.'][$sectionName];
217 }
218
219 $returnValue = $val ? $beUser->uc['TSFE_adminConfig'][$sectionName . '_' . $val] : 1;
220
221 // Exception for preview
222 if ($sectionName === 'preview' && $this->ext_forcePreview) {
223 return !$val ? true : $returnValue;
224 }
225
226 // See if the menu is expanded!
227 return $this->isAdminModuleOpen($sectionName) ? $returnValue : null;
228 }
229
230 /**
231 * Enables the force preview option.
232 */
233 public function forcePreview()
234 {
235 $this->ext_forcePreview = true;
236 }
237
238 /**
239 * Returns TRUE if admin panel module is open
240 *
241 * @param string $key Module key
242 * @return bool TRUE, if the admin panel is open for the specified admin panel module key.
243 */
244 public function isAdminModuleOpen($key)
245 {
246 return $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] && $this->getBackendUser()->uc['TSFE_adminConfig']['display_' . $key];
247 }
248
249 /**
250 * @param string $key
251 * @param string $content
252 *
253 * @return string
254 */
255 protected function getModule($key, $content)
256 {
257 $output = [];
258
259 if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] && $this->isAdminModuleEnabled($key)) {
260 $output[] = '<div class="typo3-adminPanel-section typo3-adminPanel-section-' . ($this->isAdminModuleOpen($key) ? 'open' : 'closed') . '">';
261 $output[] = ' <div class="typo3-adminPanel-section-title">';
262 $output[] = ' ' . $this->linkSectionHeader($key, $this->extGetLL($key));
263 $output[] = ' </div>';
264 if ($this->isAdminModuleOpen($key)) {
265 $output[] = '<div class="typo3-adminPanel-section-body">';
266 $output[] = ' ' . $content;
267 $output[] = '</div>';
268 }
269 $output[] = '</div>';
270 }
271
272 return implode('', $output);
273 }
274
275 /**
276 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
277 *
278 * @throws \UnexpectedValueException
279 * @return string HTML for the Admin Panel
280 */
281 public function display()
282 {
283 $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_tsfe.xlf');
284
285 $moduleContent = '';
286 $moduleContent .= $this->getModule('preview', $this->getPreviewModule());
287 $moduleContent .= $this->getModule('cache', $this->getCacheModule());
288 $moduleContent .= $this->getModule('edit', $this->getEditModule());
289 $moduleContent .= $this->getModule('tsdebug', $this->getTSDebugModule());
290 $moduleContent .= $this->getModule('info', $this->getInfoModule());
291
292 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
293 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $className) {
294 $hookObject = GeneralUtility::makeInstance($className);
295 if (!$hookObject instanceof AdminPanelViewHookInterface) {
296 throw new \UnexpectedValueException($className . ' must implement interface ' . AdminPanelViewHookInterface::class, 1311942539);
297 }
298 $content = $hookObject->extendAdminPanel($moduleContent, $this);
299 if ($content) {
300 $moduleContent .= '<div class="typo3-adminPanel-section typo3-adminPanel-section-open">';
301 $moduleContent .= ' <div class="typo3-adminPanel-section-body">';
302 $moduleContent .= ' ' . $content;
303 $moduleContent .= ' </div>';
304 $moduleContent .= '</div>';
305 }
306 }
307 }
308
309 $output = [];
310 $output[] = '<!-- TYPO3 Admin panel start -->';
311 $output[] = '<a id="TSFE_ADMIN_PANEL"></a>';
312 $output[] = '<form id="TSFE_ADMIN_PANEL_FORM" name="TSFE_ADMIN_PANEL_FORM" style="display: none;" 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)">';
313 if (!GeneralUtility::_GET('id')) {
314 $output[] = '<input type="hidden" name="id" value="' . $this->getTypoScriptFrontendController()->id . '" />';
315 }
316 // The dummy field is needed for Firefox: to force a page reload on submit
317 // which must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
318 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
319 foreach (GeneralUtility::_GET() as $key => $value) {
320 if ($key !== 'TSFE_ADMIN_PANEL') {
321 if (is_array($value)) {
322 $output[] = $this->getHiddenFields($key, $value);
323 } else {
324 $output[] = '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
325 }
326 }
327 }
328 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="0" />';
329 $output[] = ' <input id="typo3AdminPanelEnable" type="checkbox" onchange="document.TSFE_ADMIN_PANEL_FORM.submit();" name="TSFE_ADMIN_PANEL[display_top]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] ? ' checked="checked"' : '') . '/>';
330 $output[] = ' <input id="typo3AdminPanelCollapse" type="checkbox" value="1" />';
331 $output[] = ' <div class="typo3-adminPanel typo3-adminPanel-state-' . ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] ? 'open' : 'closed') . '">';
332 $output[] = ' <div class="typo3-adminPanel-header">';
333 $output[] = ' <span class="typo3-adminPanel-header-title">' . $this->extGetLL('adminPanelTitle') . '</span>';
334 $output[] = ' <span class="typo3-adminPanel-header-user">' . htmlspecialchars($this->getBackendUser()->user['username']) . '</span>';
335 $output[] = ' <label for="typo3AdminPanelEnable" class="typo3-adminPanel-header-enable">';
336 $output[] = ' <span class="typo3-adminPanel-header-enable-enabled">';
337 $output[] = ' ' . $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render('inline');
338 $output[] = ' </span>';
339 $output[] = ' <span class="typo3-adminPanel-header-enable-disabled">';
340 $output[] = ' ' . $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render('inline');
341 $output[] = ' </span>';
342 $output[] = ' </label>';
343 $output[] = ' <label for="typo3AdminPanelCollapse" class="typo3-adminPanel-header-collapse">';
344 $output[] = ' <span class="typo3-adminPanel-header-collapse-enabled">';
345 $output[] = ' ' . $this->iconFactory->getIcon('actions-view-list-collapse', Icon::SIZE_SMALL)->render('inline');
346 $output[] = ' </span>';
347 $output[] = ' <span class="typo3-adminPanel-header-collapse-disabled">';
348 $output[] = ' ' . $this->iconFactory->getIcon('actions-view-list-expand', Icon::SIZE_SMALL)->render('inline');
349 $output[] = ' </span>';
350 $output[] = ' </label>';
351 $output[] = ' </div>';
352 if ($moduleContent && $this->extNeedUpdate) {
353 $output[] = '<div class="typo3-adminPanel-actions">';
354 $output[] = ' <input class="typo3-adminPanel-btn typo3-adminPanel-btn-dark" type="submit" value="' . $this->extGetLL('update') . '" />';
355 $output[] = '</div>';
356 }
357 $output[] = ' <div class="typo3-adminPanel-body">';
358 $output[] = ' ' . $moduleContent;
359 $output[] = ' </div>';
360 $output[] = ' </div>';
361 $output[] = '</form>';
362 if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
363 $frontendPathExtBackend = htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix) . ExtensionManagementUtility::siteRelPath('backend');
364 $output[] = '<script type="text/javascript" src="' . $frontendPathExtBackend . 'Resources/Public/JavaScript/jsfunc.evalfield.js"></script>';
365 $output[] = '<script type="text/javascript">/*<![CDATA[*/' . GeneralUtility::minifyJavaScript('
366 var evalFunc = new evalFunc();
367 // TSFEtypo3FormFieldSet()
368 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
369 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
370 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
371 if (checkbox && theValue==checkboxValue) {
372 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
373 alert(theField);
374 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
375 } else {
376 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
377 if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
378 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
379 }
380 }
381 }
382 // TSFEtypo3FormFieldGet()
383 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
384 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
385 if (checkbox_off) {
386 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
387 }else{
388 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
389 }
390 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
391 }') . '/*]]>*/</script>';
392 $output[] = '<script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
393 }
394 $frontendPathExtFrontend = htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix) . ExtensionManagementUtility::siteRelPath('frontend');
395 $output[] = '<link type="text/css" rel="stylesheet" href="' . $frontendPathExtFrontend . 'Resources/Public/Css/adminpanel.css" media="all" />';
396 $output[] = $this->getAdminPanelHeaderData();
397 $output[] = '<!-- TYPO3 admin panel end -->';
398
399 return implode('', $output);
400 }
401
402 /**
403 * Fetches recursively all GET parameters as hidden fields.
404 * Called from display()
405 *
406 * @param string $key Current key
407 * @param array $val Current value
408 * @return string Hidden fields
409 * @see display()
410 */
411 protected function getHiddenFields($key, array $val)
412 {
413 $out = '';
414 foreach ($val as $k => $v) {
415 if (is_array($v)) {
416 $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
417 } else {
418 $out .= '<input type="hidden" name="' . htmlspecialchars($key) . '[' . htmlspecialchars($k) . ']" value="' . htmlspecialchars($v) . '">' . LF;
419 }
420 }
421 return $out;
422 }
423
424 /*****************************************************
425 * Creating sections of the Admin Panel
426 ****************************************************/
427 /**
428 * Creates the content for the "preview" section ("module") of the Admin Panel
429 *
430 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
431 * @see display()
432 */
433 protected function getPreviewModule()
434 {
435 $output = [];
436 if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_preview']) {
437 $this->extNeedUpdate = true;
438
439 $output[] = '<div class="typo3-adminPanel-form-group">';
440 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
441 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" />';
442 $output[] = ' <label for="' . htmlspecialchars('preview_showHiddenPages') . '">';
443 $output[] = ' <input type="checkbox" id="preview_showHiddenPages" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_showHiddenPages'] ? ' checked="checked"' : '') . ' />';
444 $output[] = ' ' . $this->extGetLL('preview_showHiddenPages');
445 $output[] = ' </label>';
446 $output[] = ' </div>';
447 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
448 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" />';
449 $output[] = ' <label for="' . htmlspecialchars('preview_showHiddenRecords') . '">';
450 $output[] = ' <input type="checkbox" id="preview_showHiddenRecords" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_showHiddenRecords'] ? ' checked="checked"' : '') . ' />';
451 $output[] = ' ' . $this->extGetLL('preview_showHiddenRecords');
452 $output[] = ' </label>';
453 $output[] = ' </div>';
454 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
455 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[preview_showFluidDebug]" value="0" />';
456 $output[] = ' <label for="' . htmlspecialchars('preview_showFluidDebug') . '">';
457 $output[] = ' <input type="checkbox" id="preview_showFluidDebug" name="TSFE_ADMIN_PANEL[preview_showFluidDebug]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_showFluidDebug'] ? ' checked="checked"' : '') . ' />';
458 $output[] = ' ' . $this->extGetLL('preview_showFluidDebug');
459 $output[] = ' </label>';
460 $output[] = ' </div>';
461 $output[] = '</div>';
462
463 // Simulate date
464 $output[] = '<div class="typo3-adminPanel-form-group">';
465 $output[] = ' <label for="' . htmlspecialchars('preview_simulateDate') . '">';
466 $output[] = ' ' . $this->extGetLL('preview_simulateDate');
467 $output[] = ' </label>';
468 $output[] = ' <input type="text" id="preview_simulateDate" name="TSFE_ADMIN_PANEL[preview_simulateDate]_hr" onchange="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\', 1,0);" />';
469 // the hidden field must be placed after the _hr field to avoid the timestamp being overridden by the date string
470 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[preview_simulateDate]" value="' . $this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateDate'] . '" />';
471 $output[] = '</div>';
472 $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 0, 0);';
473
474 // Frontend Usergroups
475 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
476 ->getQueryBuilderForTable('fe_groups');
477 $queryBuilder->getRestrictions()
478 ->removeAll()
479 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
480 $optionCount = $queryBuilder->count('fe_groups.uid')
481 ->from('fe_groups')
482 ->from('pages')
483 ->where(
484 $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid')),
485 $this->getBackendUser()->getPagePermsClause(1)
486 )
487 ->execute()
488 ->fetchColumn(0);
489 if ($optionCount > 0) {
490 $result = $queryBuilder->select('fe_groups.uid', 'fe_groups.title')
491 ->from('fe_groups')
492 ->from('pages')
493 ->where(
494 $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid')),
495 $this->getBackendUser()->getPagePermsClause(1)
496 )
497 ->orderBy('fe_groups.title')
498 ->execute();
499 $output[] = '<div class="typo3-adminPanel-form-group">';
500 $output[] = ' <label for="' . htmlspecialchars('preview_simulateUserGroup') . '">';
501 $output[] = ' ' . $this->extGetLL('preview_simulateUserGroup');
502 $output[] = ' </label>';
503 $output[] = ' <select id="preview_simulateUserGroup" name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">';
504 $output[] = ' <option value="0">&nbsp;</option>';
505 while ($row = $result->fetch()) {
506 $output[] = '<option value="' . $row['uid'] . '" ' . ($this->getBackendUser()->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>';
507 $output[] = htmlspecialchars(($row['title'] . ' [' . $row['uid'] . ']'));
508 $output[] = '</option>';
509 }
510 $output[] = ' </select>';
511 $output[] = '</div>';
512 }
513 }
514 return implode('', $output);
515 }
516
517 /**
518 * Creates the content for the "cache" section ("module") of the Admin Panel
519 *
520 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
521 * @see display()
522 */
523 protected function getCacheModule()
524 {
525 $output = [];
526 $beUser = $this->getBackendUser();
527 if ($beUser->uc['TSFE_adminConfig']['display_cache']) {
528 $this->extNeedUpdate = true;
529
530 $output[] = '<div class="typo3-adminPanel-form-group">';
531 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
532 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" />';
533 $output[] = ' <label for="' . htmlspecialchars('cache_noCache') . '">';
534 $output[] = ' <input type="checkbox" id="cache_noCache" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['cache_noCache'] ? ' checked="checked"' : '') . ' />';
535 $output[] = ' ' . $this->extGetLL('cache_noCache');
536 $output[] = ' </label>';
537 $output[] = ' </div>';
538 $output[] = '</div>';
539
540 $levels = $beUser->uc['TSFE_adminConfig']['cache_clearCacheLevels'];
541 $output[] = '<div class="typo3-adminPanel-form-group">';
542 $output[] = ' <label for="' . htmlspecialchars('cache_clearCacheLevels') . '">';
543 $output[] = ' ' . $this->extGetLL('cache_clearLevels');
544 $output[] = ' </label>';
545 $output[] = ' <select id="cache_clearCacheLevels" name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">';
546 $output[] = ' <option value="0"' . ($levels == 0 ? ' selected="selected"' : '') . '>';
547 $output[] = ' ' . $this->extGetLL('div_Levels_0');
548 $output[] = ' </option>';
549 $output[] = ' <option value="1"' . ($levels == 1 ? ' selected="selected"' : '') . '>';
550 $output[] = ' ' . $this->extGetLL('div_Levels_1');
551 $output[] = ' </option>';
552 $output[] = ' <option value="2"' . ($levels == 2 ? ' selected="selected"' : '') . '>';
553 $output[] = ' ' . $this->extGetLL('div_Levels_2');
554 $output[] = ' </option>';
555 $output[] = ' </select>';
556 $output[] = '</div>';
557
558 $output[] = '<div class="typo3-adminPanel-form-group">';
559 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" />';
560 $output[] = ' <input class="typo3-adminPanel-btn typo3-adminPanel-btn-default" type="submit" value="' . $this->extGetLL('update') . '" />';
561 $output[] = '</div>';
562
563 // Generating tree:
564 $depth = (int)$this->extGetFeAdminValue('cache', 'clearCacheLevels');
565 $outTable = '';
566 $tsfe = $this->getTypoScriptFrontendController();
567 $beUser->extPageInTreeInfo = [];
568 $beUser->extPageInTreeInfo[] = [
569 $tsfe->page['uid'],
570 htmlspecialchars($tsfe->page['title']),
571 $depth + 1
572 ];
573 $beUser->extGetTreeList(
574 $tsfe->id,
575 $depth,
576 0,
577 $beUser->getPagePermsClause(1)
578 );
579 $output[] = '<div class="typo3-adminPanel-table-overflow">';
580 $output[] = '<table class="typo3-adminPanel-table">';
581 $output[] = ' <thead>';
582 $output[] = ' <tr>';
583 $output[] = ' <th colspan="2">' . $this->extGetLL('cache_cacheEntries') . '</th>';
584 $output[] = ' </tr>';
585 $output[] = ' </thead>';
586 $output[] = ' <tbody>';
587 foreach ($beUser->extPageInTreeInfo as $key => $row) {
588 $output[] = '<tr>';
589 $output[] = ' <td>';
590 $output[] = ' <span style="width: ' . ($depth + 1 - $row[2]) * 5 . 'px; height: 1px; display: inline-block;"></span>';
591 $output[] = ' ' . $this->iconFactory->getIcon('apps-pagetree-page-default', Icon::SIZE_SMALL)->render() . htmlspecialchars($row[1]);
592 $output[] = ' </td>';
593 $output[] = ' <td>' . $beUser->extGetNumberOfCachedPages($row[0]) . '</td>';
594 $output[] = '</tr>';
595 }
596 $output[] = ' <tbody>';
597 $output[] = '</table>';
598 $output[] = '</div>';
599
600 $output[] = '<div class="typo3-adminPanel-form-group">';
601 $output[] = ' <input class="typo3-adminPanel-btn typo3-adminPanel-btn-default" type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
602 $output[] = '</div>';
603 }
604 return implode('', $output);
605 }
606
607 /**
608 * Creates the content for the "edit" section ("module") of the Admin Panel
609 *
610 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
611 * @see display()
612 */
613 protected function getEditModule()
614 {
615 $output = [];
616 if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_edit']) {
617 $this->extNeedUpdate = true;
618
619 // If another page module was specified, replace the default Page module with the new one
620 $newPageModule = trim($this->getBackendUser()->getTSConfigVal('options.overridePageModule'));
621 $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
622
623 if ($this->extFeEditLoaded) {
624 $output[] = '<div class="typo3-adminPanel-form-group">';
625 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
626 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" />';
627 $output[] = ' <label for="' . htmlspecialchars('edit_displayFieldIcons') . '">';
628 $output[] = ' <input type="checkbox" id="edit_displayFieldIcons" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['edit_displayFieldIcons'] ? ' checked="checked"' : '') . ' />';
629 $output[] = ' ' . $this->extGetLL('edit_displayFieldIcons');
630 $output[] = ' </label>';
631 $output[] = ' </div>';
632 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
633 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" />';
634 $output[] = ' <label for="' . htmlspecialchars('edit_displayIcons') . '">';
635 $output[] = ' <input type="checkbox" id="edit_displayIcons" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['edit_displayIcons'] ? ' checked="checked"' : '') . ' />';
636 $output[] = ' ' . $this->extGetLL('edit_displayIcons');
637 $output[] = ' </label>';
638 $output[] = ' </div>';
639 $output[] = '</div>';
640 }
641
642 $output[] = $this->ext_makeToolBar();
643
644 if (!GeneralUtility::_GP('ADMCMD_view')) {
645 $onClick = '
646 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
647 parent.opener.top.fsMod.recentIds["web"]=' . (int)$this->getTypoScriptFrontendController()->page['uid'] . ';
648 if (parent.opener.top && parent.opener.top.nav_frame && parent.opener.top.nav_frame.refresh_nav) {
649 parent.opener.top.nav_frame.refresh_nav();
650 }
651 parent.opener.top.goToModule("' . $pageModule . '");
652 parent.opener.top.focus();
653 } else {
654 vHWin=window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getBackendScript()) . ',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\');
655 vHWin.focus();
656 }
657 return false;
658 ';
659 $output[] = '<div class="typo3-adminPanel-form-group">';
660 $output[] = ' <a class="typo3-adminPanel-btn typo3-adminPanel-btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '">';
661 $output[] = ' ' . $this->extGetLL('edit_openAB');
662 $output[] = ' </a>';
663 $output[] = '</div>';
664 }
665 }
666 return implode('', $output);
667 }
668
669 /**
670 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
671 *
672 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
673 * @see display()
674 */
675 protected function getTSDebugModule()
676 {
677 $output = [];
678 $beuser = $this->getBackendUser();
679 if ($beuser->uc['TSFE_adminConfig']['display_tsdebug']) {
680 $this->extNeedUpdate = true;
681
682 $output[] = '<div class="typo3-adminPanel-form-group">';
683 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
684 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" />';
685 $output[] = ' <label for="' . htmlspecialchars('tsdebug_tree') . '">';
686 $output[] = ' <input type="checkbox" id="tsdebug_tree" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') . ' />';
687 $output[] = ' ' . $this->extGetLL('tsdebug_tree');
688 $output[] = ' </label>';
689 $output[] = ' </div>';
690 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
691 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" />';
692 $output[] = ' <label for="' . htmlspecialchars('tsdebug_displayTimes') . '">';
693 $output[] = ' <input type="checkbox" id="tsdebug_displayTimes" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') . ' />';
694 $output[] = ' ' . $this->extGetLL('tsdebug_displayTimes');
695 $output[] = ' </label>';
696 $output[] = ' </div>';
697 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
698 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" />';
699 $output[] = ' <label for="' . htmlspecialchars('tsdebug_displayMessages') . '">';
700 $output[] = ' <input type="checkbox" id="tsdebug_displayMessages" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"' : '') . ' />';
701 $output[] = ' ' . $this->extGetLL('tsdebug_displayMessages');
702 $output[] = ' </label>';
703 $output[] = ' </div>';
704 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
705 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" />';
706 $output[] = ' <label for="' . htmlspecialchars('tsdebug_LR') . '">';
707 $output[] = ' <input type="checkbox" id="tsdebug_LR" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />';
708 $output[] = ' ' . $this->extGetLL('tsdebug_LR');
709 $output[] = ' </label>';
710 $output[] = ' </div>';
711 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
712 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" />';
713 $output[] = ' <label for="' . htmlspecialchars('tsdebug_displayContent') . '">';
714 $output[] = ' <input type="checkbox" id="tsdebug_displayContent" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />';
715 $output[] = ' ' . $this->extGetLL('tsdebug_displayContent');
716 $output[] = ' </label>';
717 $output[] = ' </div>';
718 $output[] = ' <div class="typo3-adminPanel-form-group-checkbox">';
719 $output[] = ' <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" />';
720 $output[] = ' <label for="' . htmlspecialchars('tsdebug_forceTemplateParsing') . '">';
721 $output[] = ' <input type="checkbox" id="tsdebug_forceTemplateParsing" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"' . ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />';
722 $output[] = ' ' . $this->extGetLL('tsdebug_forceTemplateParsing');
723 $output[] = ' </label>';
724 $output[] = ' </div>';
725 $output[] = '</div>';
726
727 $timeTracker = $this->getTimeTracker();
728 $timeTracker->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug', 'tree');
729 $timeTracker->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug', 'displayTimes');
730 $timeTracker->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug', 'displayMessages');
731 $timeTracker->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug', 'displayContent');
732 $output[] = $timeTracker->printTSlog();
733 }
734 return implode('', $output);
735 }
736
737 /**
738 * Creates the content for the "info" section ("module") of the Admin Panel
739 *
740 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
741 * @see display()
742 */
743 protected function getInfoModule()
744 {
745 $output = [];
746 $tsfe = $this->getTypoScriptFrontendController();
747 if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_info']) {
748 $tableArr = [];
749 if ($this->extGetFeAdminValue('cache', 'noCache')) {
750 $theBytes = 0;
751 $count = 0;
752 if (!empty($tsfe->imagesOnPage)) {
753 $tableArr[] = [$this->extGetLL('info_imagesOnPage'), count($tsfe->imagesOnPage), true];
754 foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
755 $fs = @filesize($file);
756 $tableArr[] = [TAB . $file, GeneralUtility::formatSize($fs)];
757 $theBytes += $fs;
758 $count++;
759 }
760 }
761 // Add an empty line
762 $tableArr[] = [$this->extGetLL('info_imagesSize'), GeneralUtility::formatSize($theBytes), true];
763 $tableArr[] = [$this->extGetLL('info_DocumentSize'), GeneralUtility::formatSize(strlen($tsfe->content)), true];
764 $tableArr[] = ['', ''];
765 }
766 $tableArr[] = [$this->extGetLL('info_id'), $tsfe->id];
767 $tableArr[] = [$this->extGetLL('info_type'), $tsfe->type];
768 $tableArr[] = [$this->extGetLL('info_groupList'), $tsfe->gr_list];
769 $tableArr[] = [$this->extGetLL('info_noCache'), $this->extGetLL('info_noCache_' . ($tsfe->no_cache ? 'no' : 'yes'))];
770 $tableArr[] = [$this->extGetLL('info_countUserInt'), count($tsfe->config['INTincScript'])];
771
772 if (!empty($tsfe->fe_user->user['uid'])) {
773 $tableArr[] = [$this->extGetLL('info_feuserName'), htmlspecialchars($tsfe->fe_user->user['username'])];
774 $tableArr[] = [$this->extGetLL('info_feuserId'), htmlspecialchars($tsfe->fe_user->user['uid'])];
775 }
776
777 $tableArr[] = [$this->extGetLL('info_totalParsetime'), $this->getTimeTracker()->getParseTime() . ' ms', true];
778 $table = '';
779 foreach ($tableArr as $key => $arr) {
780 $label = (isset($arr[2]) ? '<strong>' . $arr[0] . '</strong>' : $arr[0]);
781 $value = (string)$arr[1] !== '' ? $arr[1] : '';
782 $table .= '
783 <tr>
784 <td>' . $label . '</td>
785 <td>' . htmlspecialchars($value) . '</td>
786 </tr>';
787 }
788
789 $output[] = '<div class="typo3-adminPanel-table-overflow">';
790 $output[] = ' <table class="typo3-adminPanel-table">';
791 $output[] = ' ' . $table;
792 $output[] = ' </table>';
793 $output[] = '</div>';
794 }
795
796 return implode('', $output);
797 }
798
799 /*****************************************************
800 * Admin Panel Layout Helper functions
801 ****************************************************/
802 /**
803 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
804 * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_' . $pre . '] value
805 * See the functions get*Module
806 *
807 * @param string $sectionSuffix The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
808 * @return string HTML table row.
809 * @see extGetItem()
810 */
811 public function extGetHead($sectionSuffix)
812 {
813 return $this->linkSectionHeader($sectionSuffix, $this->extGetLL($sectionSuffix));
814 }
815
816 /**
817 * Wraps a string in a link which will open/close a certain part of the Admin Panel
818 *
819 * @param string $sectionSuffix The code for the display_ label/key
820 * @param string $sectionTitle Title (in HTML-format)
821 * @param string $className The classname for the <a> tag
822 * @return string $className Linked input string
823 * @see extGetHead()
824 */
825 public function linkSectionHeader($sectionSuffix, $sectionTitle, $className = '')
826 {
827 $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;';
828
829 $output = [];
830 $output[] = '<span class="typo3-adminPanel-section-title-identifier"></span>';
831 $output[] = '<a href="javascript:void(0)" onclick="' . htmlspecialchars($onclick) . '">';
832 $output[] = ' ' . $sectionTitle;
833 $output[] = '</a>';
834 $output[] = '<input type="hidden" name="TSFE_ADMIN_PANEL[display_' . $sectionSuffix . ']" value="' . $this->isAdminModuleOpen($sectionSuffix) . '" />';
835
836 return implode('', $output);
837 }
838
839 /**
840 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
841 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
842 *
843 * @param string $title Key to label
844 * @param string $content The HTML content for the forth table cell.
845 * @param string $checkbox The HTML for a checkbox or hidden fields.
846 * @param string $innerDivClass The Class attribute for the td element.
847 * @param string $outerDivClass The Class attribute for the tr element.
848 * @return string HTML table row.
849 * @see extGetHead()
850 */
851 public function extGetItem($title, $content = '', $checkbox = '', $outerDivClass = null, $innerDivClass = null)
852 {
853 $title = $title ? '<label for="' . htmlspecialchars($title) . '">' . $this->extGetLL($title) . '</label>' : '';
854 $outerDivClass === null ? $out = '<div>' : $out = '<div class="' . $outerDivClass . '">';
855 $innerDivClass === null ? $out .= '<div>' : $out .= '<div class="' . $innerDivClass . '">';
856 $out .= $checkbox . $title . $content . '</div>
857 </div>';
858 return $out;
859 }
860
861 /**
862 * Creates the tool bar links for the "edit" section of the Admin Panel.
863 *
864 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
865 */
866 public function ext_makeToolBar()
867 {
868 $tsfe = $this->getTypoScriptFrontendController();
869 // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
870 $tsConfig = BackendUtility::getModTSconfig($tsfe->page['uid'], 'mod');
871 $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
872 ? $tsConfig['properties']['newContentElementWizard.']['override']
873 : 'new_content_element';
874 $newContentWizScriptPath = BackendUtility::getModuleUrl($moduleName);
875 $perms = $this->getBackendUser()->calcPerms($tsfe->page);
876 $langAllowed = $this->getBackendUser()->checkLanguageAccess($tsfe->sys_language_uid);
877 $id = $tsfe->id;
878 $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
879 $classes = 'typo3-adminPanel-btn typo3-adminPanel-btn-default';
880 $output = [];
881 $output[] = '<div class="typo3-adminPanel-form-group">';
882 $output[] = ' <div class="typo3-adminPanel-btn-group" role="group">';
883
884 // History
885 $link = BackendUtility::getModuleUrl(
886 'record_history',
887 [
888 'element' => 'pages:' . $id,
889 'returnUrl' => $returnUrl
890 ]
891 );
892 $title = $this->extGetLL('edit_recordHistory');
893 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '#latest" title="' . $title . '">';
894 $output[] = ' ' . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render();
895 $output[] = '</a>';
896
897 // New Content
898 if ($perms & Permission::CONTENT_EDIT && $langAllowed) {
899 $params = '';
900 if ($tsfe->sys_language_uid) {
901 $params = '&sys_language_uid=' . $tsfe->sys_language_uid;
902 }
903 $link = $newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . rawurlencode($returnUrl);
904 $icon = $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render();
905 $title = $this->extGetLL('edit_newContentElement');
906 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '" title="' . $title . '">';
907 $output[] = ' ' . $icon;
908 $output[] = '</a>';
909 }
910
911 // Move Page
912 if ($perms & Permission::PAGE_EDIT) {
913 $link = BackendUtility::getModuleUrl(
914 'move_element',
915 [
916 'table' => 'pages',
917 'uid' => $id,
918 'returnUrl' => $returnUrl
919 ]
920 );
921 $icon = $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)->render();
922 $title = $this->extGetLL('edit_move_page');
923 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '" title="' . $title . '">';
924 $output[] = ' ' . $icon;
925 $output[] = '</a>';
926 }
927
928 // New Page
929 if ($perms & Permission::PAGE_NEW) {
930 $link = BackendUtility::getModuleUrl(
931 'db_new',
932 [
933 'id' => $id,
934 'pagesOnly' => 1,
935 'returnUrl' => $returnUrl
936 ]
937 );
938 $icon = $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render();
939 $title = $this->extGetLL('edit_newPage');
940 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '" title="' . $title . '">';
941 $output[] = ' ' . $icon;
942 $output[] = '</a>';
943 }
944
945 // Edit Page
946 if ($perms & Permission::PAGE_EDIT) {
947 $link = BackendUtility::getModuleUrl(
948 'record_edit',
949 [
950 'edit[pages][' . $id . ']' => 'edit',
951 'noView' => 1,
952 'returnUrl' => $returnUrl
953 ]
954 );
955 $icon = $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render();
956 $title = $this->extGetLL('edit_editPageProperties');
957 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '" title="' . $title . '">';
958 $output[] = ' ' . $icon;
959 $output[] = '</a>';
960 }
961
962 // Edit Page Overlay
963 if ($perms & Permission::PAGE_EDIT && $tsfe->sys_language_uid && $langAllowed) {
964 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
965 ->getQueryBuilderForTable('pages_language_overlay');
966 $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
967 $row = $queryBuilder
968 ->select('uid', 'pid', 't3ver_state')
969 ->from('pages_language_overlay')
970 ->where(
971 $queryBuilder->expr()->eq(
972 'pid',
973 $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)
974 ),
975 $queryBuilder->expr()->eq(
976 'sys_language_uid',
977 $queryBuilder->createNamedParameter($tsfe->sys_language_uid, \PDO::PARAM_INT)
978 )
979 )
980 ->setMaxResults(1)
981 ->execute()
982 ->fetch();
983 $tsfe->sys_page->versionOL('pages_language_overlay', $row);
984 if (is_array($row)) {
985 $link = BackendUtility::getModuleUrl(
986 'record_edit',
987 [
988 'edit[pages_language_overlay][' . $row['uid'] . ']' => 'edit',
989 'noView' => 1,
990 'returnUrl' => $returnUrl
991 ]
992 );
993 $icon = $this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL)->render();
994 $title = $this->extGetLL('edit_editPageOverlay');
995 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '" title="' . $title . '">';
996 $output[] = ' ' . $icon;
997 $output[] = '</a>';
998 }
999 }
1000
1001 // Open list view
1002 if ($this->getBackendUser()->check('modules', 'web_list')) {
1003 $link = BackendUtility::getModuleUrl(
1004 'web_list',
1005 [
1006 'id' => $id,
1007 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1008 ]
1009 );
1010 $icon = $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render();
1011 $title = $this->extGetLL('edit_db_list');
1012 $output[] = '<a class="' . $classes . '" href="' . htmlspecialchars($link) . '" title="' . $title . '">';
1013 $output[] = ' ' . $icon;
1014 $output[] = '</a>';
1015 }
1016
1017 $output[] = ' </div>';
1018 $output[] = '</div>';
1019 return implode('', $output);
1020 }
1021
1022 /**
1023 * Translate given key
1024 *
1025 * @param string $key Key for a label in the $LOCAL_LANG array of "sysext/lang/Resources/Private/Language/locallang_tsfe.xlf
1026 * @param bool $convertWithHtmlspecialchars If TRUE the language-label will be sent through htmlspecialchars
1027 * @return string The value for the $key
1028 */
1029 protected function extGetLL($key, $convertWithHtmlspecialchars = true)
1030 {
1031 $labelStr = $this->getLanguageService()->getLL($key);
1032 if ($convertWithHtmlspecialchars) {
1033 $labelStr = htmlspecialchars($labelStr);
1034 }
1035 return $labelStr;
1036 }
1037
1038 /**
1039 * Returns LanguageService
1040 *
1041 * @return \TYPO3\CMS\Core\Localization\LanguageService
1042 */
1043 protected function getLanguageService()
1044 {
1045 return $GLOBALS['LANG'];
1046 }
1047
1048 /**
1049 * Returns the current BE user.
1050 *
1051 * @return \TYPO3\CMS\Backend\FrontendBackendUserAuthentication
1052 */
1053 protected function getBackendUser()
1054 {
1055 return $GLOBALS['BE_USER'];
1056 }
1057
1058 /**
1059 * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
1060 */
1061 protected function getTypoScriptFrontendController()
1062 {
1063 return $GLOBALS['TSFE'];
1064 }
1065
1066 /**
1067 * @return TimeTracker
1068 */
1069 protected function getTimeTracker()
1070 {
1071 return GeneralUtility::makeInstance(TimeTracker::class);
1072 }
1073 }