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