PageLayoutController.php 55.2 KB
Newer Older
1
<?php
2
declare(strict_types = 1);
3
4
namespace TYPO3\CMS\Backend\Controller;

5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
9
10
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
11
 *
12
13
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
16
 * The TYPO3 project - inspiring people to share!
 */
17

18
19
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
20
use TYPO3\CMS\Backend\Module\ModuleLoader;
21
use TYPO3\CMS\Backend\Routing\UriBuilder;
22
23
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
Nicole Cordes's avatar
Nicole Cordes committed
24
use TYPO3\CMS\Backend\Utility\BackendUtility;
25
26
use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutView;
27
28
29
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait;
use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
30
use TYPO3\CMS\Core\Database\ConnectionPool;
31
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
32
33
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
34
use TYPO3\CMS\Core\DataHandling\DataHandler;
35
use TYPO3\CMS\Core\Http\HtmlResponse;
36
37
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
38
use TYPO3\CMS\Core\Localization\LanguageService;
39
use TYPO3\CMS\Core\Page\PageRenderer;
40
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
41
use TYPO3\CMS\Core\Type\Bitmask\Permission;
Nicole Cordes's avatar
Nicole Cordes committed
42
43
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
44
use TYPO3\CMS\Core\Versioning\VersionState;
45
use TYPO3\CMS\Fluid\View\StandaloneView;
46
use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
47
use TYPO3\CMS\Frontend\Page\PageRepository;
Nicole Cordes's avatar
Nicole Cordes committed
48

49
50
51
/**
 * Script Class for Web > Layout module
 */
52
53
class PageLayoutController
{
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    use PublicMethodDeprecationTrait;
    use PublicPropertyDeprecationTrait;

    /**
     * @var array
     */
    private $deprecatedPublicMethods = [
        'init' => 'Using PageLayoutController::init() is deprecated and will not be possible anymore in TYPO3 v10.',
        'main' => 'Using PageLayoutController::main() is deprecated and will not be possible anymore in TYPO3 v10.',
        'menuConfig' => 'Using PageLayoutController::menuConfig() is deprecated and will not be possible anymore in TYPO3 v10.',
        'renderContent' => 'Using PageLayoutController::renderContent() is deprecated and will not be possible anymore in TYPO3 v10.',
        'clearCache' => 'Using PageLayoutController::clearCache() is deprecated and will not be possible anymore in TYPO3 v10.',
        'getModuleTemplate' => 'Using PageLayoutController::getModuleTemplate() is deprecated and will not be possible anymore in TYPO3 v10.',
        'getLocalizedPageTitle' => 'Using PageLayoutController::getLocalizedPageTitle() is deprecated and will not be possible anymore in TYPO3 v10.',
        'getNumberOfHiddenElements' => 'Using PageLayoutController::getNumberOfHiddenElements() is deprecated and will not be possible anymore in TYPO3 v10.',
        'local_linkThisScript' => 'Using PageLayoutController::local_linkThisScript() is deprecated and will not be possible anymore in TYPO3 v10.',
        'pageIsNotLockedForEditors' => 'Using PageLayoutController::pageIsNotLockedForEditors() is deprecated and will not be possible anymore in TYPO3 v10.',
        'contentIsNotLockedForEditors' => 'Using PageLayoutController::contentIsNotLockedForEditors() is deprecated and will not be possible anymore in TYPO3 v10.',
    ];

    /**
     * @var array
     */
    private $deprecatedPublicProperties = [
        'pointer' => 'Using PageLayoutController::$pointer is deprecated and will not be possible anymore in TYPO3 v10.',
        'imagemode' => 'Using PageLayoutController::$imagemode is deprecated and will not be possible anymore in TYPO3 v10.',
        'search_field' => 'Using PageLayoutController::$search_field is deprecated and will not be possible anymore in TYPO3 v10.',
        'search_levels' => 'Using PageLayoutController::$search_levels is deprecated and will not be possible anymore in TYPO3 v10.',
        'showLimit' => 'Using PageLayoutController::$showLimit is deprecated and will not be possible anymore in TYPO3 v10.',
        'returnUrl' => 'Using PageLayoutController::$returnUrl is deprecated and will not be possible anymore in TYPO3 v10.',
        'clear_cache' => 'Using PageLayoutController::$clear_cache is deprecated and will not be possible anymore in TYPO3 v10.',
        'popView' => 'Using PageLayoutController::$popView is deprecated and will not be possible anymore in TYPO3 v10.',
        'perms_clause' => 'Using PageLayoutController::$perms_clause is deprecated and will not be possible anymore in TYPO3 v10.',
        'modTSconfig' => 'Using PageLayoutController::$modTSconfig is deprecated and will not be possible anymore in TYPO3 v10.',
        'modSharedTSconfig' => 'Using PageLayoutController::$modSharedTSconfig is deprecated and will not be possible anymore in TYPO3 v10.',
        'descrTable' => 'Using PageLayoutController::$descrTable is deprecated and will not be possible anymore in TYPO3 v10.',
        'colPosList' => 'Using PageLayoutController::$colPosList is deprecated and will not be possible anymore in TYPO3 v10.',
        'EDIT_CONTENT' => 'Using PageLayoutController::$EDIT_CONTENT is deprecated and will not be possible anymore in TYPO3 v10.',
        'CALC_PERMS' => 'Using PageLayoutController::$CALC_PERMS is deprecated and will not be possible anymore in TYPO3 v10.',
        'current_sys_language' => 'Using PageLayoutController::$current_sys_language is deprecated and will not be possible anymore in TYPO3 v10.',
        'MCONF' => 'Using PageLayoutController::$MCONF is deprecated and will not be possible anymore in TYPO3 v10.',
        'MOD_MENU' => 'Using PageLayoutController::$MOD_MENU is deprecated and will not be possible anymore in TYPO3 v10.',
        'content' => 'Using PageLayoutController::$content is deprecated and will not be possible anymore in TYPO3 v10.',
        'activeColPosList' => 'Using PageLayoutController::$activeColPosList is deprecated and will not be possible anymore in TYPO3 v10.',
    ];

100
101
102
103
    /**
     * Page Id for which to make the listing
     *
     * @var int
104
     * @internal
105
106
107
108
109
110
111
112
     */
    public $id;

    /**
     * Pointer - for browsing list of records.
     *
     * @var int
     */
113
    protected $pointer;
114
115
116
117
118
119

    /**
     * Thumbnails or not
     *
     * @var string
     */
120
    protected $imagemode;
121
122
123
124
125
126

    /**
     * Search-fields
     *
     * @var string
     */
127
    protected $search_field;
128
129
130
131
132
133

    /**
     * Search-levels
     *
     * @var int
     */
134
    protected $search_levels;
135
136
137
138
139
140

    /**
     * Show-limit
     *
     * @var int
     */
141
    protected $showLimit;
142
143
144
145
146
147

    /**
     * Return URL
     *
     * @var string
     */
148
    protected $returnUrl;
149
150
151
152
153
154

    /**
     * Clear-cache flag - if set, clears page cache for current id.
     *
     * @var bool
     */
155
    protected $clear_cache;
156
157
158
159
160
161

    /**
     * PopView id - for opening a window with the page
     *
     * @var bool
     */
162
    protected $popView;
163
164
165
166
167
168

    /**
     * Page select perms clause
     *
     * @var string
     */
169
    protected $perms_clause;
170
171
172
173
174
175

    /**
     * Module TSconfig
     *
     * @var array
     */
176
    protected $modTSconfig = [];
177
178
179
180
181
182

    /**
     * Module shared TSconfig
     *
     * @var array
     */
183
    protected $modSharedTSconfig = [];
184
185
186
187
188

    /**
     * Current ids page record
     *
     * @var array
189
     * @internal
190
191
192
193
194
195
196
197
     */
    public $pageinfo;

    /**
     * "Pseudo" Description -table name
     *
     * @var string
     */
198
    protected $descrTable;
199
200
201
202
203
204

    /**
     * List of column-integers to edit. Is set from TSconfig, default is "1,0,2,3"
     *
     * @var string
     */
205
    protected $colPosList;
206
207
208
209
210
211

    /**
     * Flag: If content can be edited or not.
     *
     * @var bool
     */
212
    protected $EDIT_CONTENT;
213
214
215
216
217
218

    /**
     * Users permissions integer for this page.
     *
     * @var int
     */
219
    protected $CALC_PERMS;
220
221
222
223
224
225

    /**
     * Currently selected language for editing content elements
     *
     * @var int
     */
226
    protected $current_sys_language;
227
228
229
230
231
232

    /**
     * Module configuration
     *
     * @var array
     */
233
    protected $MCONF = [];
234
235
236
237
238
239

    /**
     * Menu configuration
     *
     * @var array
     */
240
    protected $MOD_MENU = [];
241
242
243
244
245

    /**
     * Module settings (session variable)
     *
     * @var array
246
     * @internal
247
     */
248
    public $MOD_SETTINGS = [];
249
250
251
252
253
254

    /**
     * Module output accumulation
     *
     * @var string
     */
255
    protected $content;
256
257
258
259
260
261
262

    /**
     * List of column-integers accessible to the current BE user.
     * Is set from TSconfig, default is $colPosList
     *
     * @var string
     */
263
    protected $activeColPosList;
264
265
266
267
268
269

    /**
     * @var string
     */
    protected $editSelect;

270
271
272
273
274
    /**
     * Caches the available languages in a colPos
     *
     * @var array
     */
275
    protected $languagesInColumnCache = [];
276

277
278
279
280
281
282
283
284
285
286
287
288
    /**
     * @var IconFactory
     */
    protected $iconFactory;

    /**
     * The name of the module
     *
     * @var string
     */
    protected $moduleName = 'web_layout';

289
290
291
292
293
294
295
296
297
298
    /**
     * @var ModuleTemplate
     */
    protected $moduleTemplate;

    /**
     * @var ButtonBar
     */
    protected $buttonBar;

299
300
301
302
303
    /**
     * @var string
     */
    protected $searchContent;

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
    /**
     * Injects the request object for the current request or subrequest
     * As this controller goes only through the main() method, it is rather simple for now
     *
     * @param ServerRequestInterface $request the current request
     * @return ResponseInterface the response with the content
     */
    public function mainAction(ServerRequestInterface $request): ResponseInterface
    {
        $GLOBALS['SOBE'] = $this;
        $this->init($request);
        $this->clearCache();
        $this->main($request);
        return new HtmlResponse($this->moduleTemplate->renderContent());
    }

320
321
    /**
     * Initializing the module
322
     * @param ServerRequestInterface $request
323
     */
324
    protected function init(ServerRequestInterface $request = null): void
325
    {
326
327
328
329
330
        $request = $request ?: $GLOBALS['TYPO3_REQUEST'];
        // Set the GPvars from outside
        $parsedBody = $request->getParsedBody();
        $queryParams = $request->getQueryParams();

331
        $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
332
        $this->iconFactory = $this->moduleTemplate->getIconFactory();
333
        $this->buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
334
335
336
        $this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
        // Setting module configuration / page select clause
        $this->MCONF['name'] = $this->moduleName;
337
        $this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
338
        // Get session data
339
        $sessionData = $this->getBackendUser()->getSessionData(__CLASS__);
340
        $this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : '';
341
342
343
344
345
346
347
348
349
350
351
352

        $this->id = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0);
        $this->pointer = $parsedBody['pointer'] ?? $queryParams['pointer'] ?? null;
        $this->imagemode = $parsedBody['imagemode'] ?? $queryParams['imagemode'] ?? null;
        $this->clear_cache = $parsedBody['clear_cache'] ?? $queryParams['clear_cache'] ?? null;
        $this->popView = $parsedBody['popView'] ?? $queryParams['popView'] ?? null;
        $this->search_field = $parsedBody['search_field'] ?? $queryParams['search_field'] ?? null;
        $this->search_levels = $parsedBody['search_levels'] ?? $queryParams['search_levels'] ?? null;
        $this->showLimit = $parsedBody['showLimit'] ?? $queryParams['showLimit'] ?? null;
        $returnUrl = $parsedBody['returnUrl'] ?? $queryParams['returnUrl'] ?? null;
        $this->returnUrl = GeneralUtility::sanitizeLocalUrl($returnUrl);

353
354
        $sessionData['search_field'] = $this->search_field;
        // Store session data
355
        $this->getBackendUser()->setAndSaveSessionData(__CLASS__, $sessionData);
356
357
358
        // Load page info array:
        $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
        // Initialize menu
359
        $this->menuConfig($request);
360
361
362
363
364
365
366
367
        // Setting sys language from session var:
        $this->current_sys_language = (int)$this->MOD_SETTINGS['language'];
        // CSH / Descriptions:
        $this->descrTable = '_MOD_' . $this->moduleName;
    }

    /**
     * Initialize menu array
368
     * @param ServerRequestInterface $request
369
     */
370
    protected function menuConfig(ServerRequestInterface $request = null): void
371
    {
372
373
374
375
376
        $request = $request ?: $GLOBALS['TYPO3_REQUEST'];
        // Set the GPvars from outside
        $parsedBody = $request->getParsedBody();
        $queryParams = $request->getQueryParams();

377
378
379
380
        /** @var SiteInterface $currentSite */
        $currentSite = $request->getAttribute('site');
        $availableLanguages = $currentSite->getAvailableLanguages($this->getBackendUser(), false, $this->id);

381
382
        $lang = $this->getLanguageService();
        // MENU-ITEMS:
383
        $this->MOD_MENU = [
384
            'tt_content_showHidden' => '',
385
            'function' => [
386
387
                1 => $lang->getLL('m_function_1'),
                2 => $lang->getLL('m_function_2')
388
389
            ],
            'language' => [
390
                0 => $lang->getLL('m_default')
391
392
            ]
        ];
393
        // initialize page/be_user TSconfig settings
394
395
396
        $pageTsConfig = BackendUtility::getPagesTSconfig($this->id);
        $this->modSharedTSconfig['properties'] = $pageTsConfig['mod.']['SHARED.'] ?? [];
        $this->modTSconfig['properties'] = $pageTsConfig['mod.']['web_layout.'] ?? [];
397

398
399
        // First, select all localized page records on the current page.
        // Each represents a possibility for a language on the page. Add these to language selector.
400
        if ($this->id) {
401
402
403
404
405
406
407
408
            // Compile language data for pid != 0 only. The language drop-down is not shown on pid 0
            // since pid 0 can't be localized.
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
            $queryBuilder->getRestrictions()->removeAll()
                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
                ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
            $statement = $queryBuilder->select('uid', $GLOBALS['TCA']['pages']['ctrl']['languageField'])
                ->from('pages')
409
                ->where(
410
                    $queryBuilder->expr()->eq(
411
                        $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
412
                        $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
413
                    )
414
415
416
417
418
419
                )->execute();
            while ($pageTranslation = $statement->fetch()) {
                $languageId = $pageTranslation[$GLOBALS['TCA']['pages']['ctrl']['languageField']];
                if (isset($availableLanguages[$languageId])) {
                    $this->MOD_MENU['language'][$languageId] = $availableLanguages[$languageId]->getTitle();
                }
420
            }
421
422
423
            // Override the label
            if (isset($availableLanguages[0])) {
                $this->MOD_MENU['language'][0] = $availableLanguages[0]->getTitle();
424
425
            }
        }
426
        // Initialize the available actions
427
        $actions = $this->initActions();
428
        // Clean up settings
429
        $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, $parsedBody['SET'] ?? $queryParams['SET'] ?? [], $this->moduleName);
430
        // For all elements to be shown in draft workspaces & to also show hidden elements by default if user hasn't disabled the option
431
432
433
        if ($this->getBackendUser()->workspace != 0
            || !isset($this->MOD_SETTINGS['tt_content_showHidden'])
            || $this->MOD_SETTINGS['tt_content_showHidden'] !== '0'
Pawel Cieslik's avatar
Pawel Cieslik committed
434
        ) {
435
436
            $this->MOD_SETTINGS['tt_content_showHidden'] = 1;
        }
437
438
        // Make action menu from available actions
        $this->makeActionMenu($actions);
439
440
441
    }

    /**
442
     * Initializes the available actions this module provides
443
     *
444
     * @return array the available actions
445
     */
446
    protected function initActions(): array
447
    {
448
        $actions = [
449
450
            1 => $this->getLanguageService()->getLL('m_function_1'),
            2 => $this->getLanguageService()->getLL('m_function_2')
451
        ];
452
        // Find if there are ANY languages at all (and if not, remove the language option from function menu).
453
454
455
456
457
458
459
460
461
462
463
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language');
        if ($this->getBackendUser()->isAdmin()) {
            $queryBuilder->getRestrictions()->removeAll();
        }

        $count = $queryBuilder
            ->count('uid')
            ->from('sys_language')
            ->execute()
            ->fetchColumn(0);

464
        if (!$count) {
465
            unset($actions['2']);
466
        }
467
468
469
470
471
472
473
        // Page / user TSconfig blinding of menu-items
        $blindActions = $this->modTSconfig['properties']['menu.']['functions.'] ?? [];
        foreach ($blindActions as $key => $value) {
            if (!$value && array_key_exists($key, $actions)) {
                unset($actions[$key]);
            }
        }
474
475
476
477
478
479
480
481
482
483

        return $actions;
    }

    /**
     * This creates the dropdown menu with the different actions this module is able to provide.
     * For now they are Columns, Quick Edit and Languages.
     *
     * @param array $actions array with the available actions
     */
484
    protected function makeActionMenu(array $actions): void
485
    {
486
487
488
489
        $actionMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
        $actionMenu->setIdentifier('actionMenu');
        $actionMenu->setLabel('');

490
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
491

492
        $defaultKey = null;
493
        $foundDefaultKey = false;
494
        foreach ($actions as $key => $action) {
495
496
497
            $menuItem = $actionMenu
                ->makeMenuItem()
                ->setTitle($action)
498
                ->setHref((string)$uriBuilder->buildUriFromRoute($this->moduleName) . '&id=' . $this->id . '&SET[function]=' . $key);
499

500
            if (!$foundDefaultKey) {
501
                $defaultKey = $key;
502
                $foundDefaultKey = true;
503
            }
504
505
            if ((int)$this->MOD_SETTINGS['function'] === $key) {
                $menuItem->setActive(true);
506
                $defaultKey = null;
507
508
            }
            $actionMenu->addMenuItem($menuItem);
509
        }
510
511
512
        if (isset($defaultKey)) {
            $this->MOD_SETTINGS['function'] = $defaultKey;
        }
513
        $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($actionMenu);
514
515
516
517
518
    }

    /**
     * Clears page cache for the current id, $this->id
     */
519
    protected function clearCache(): void
520
    {
521
522
        if ($this->clear_cache && !empty($this->pageinfo)) {
            $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
523
            $dataHandler->start([], []);
524
            $dataHandler->clear_cacheCmd($this->id);
525
526
527
528
529
530
531
532
        }
    }

    /**
     * Generate the flashmessages for current pid
     *
     * @return string HTML content with flashmessages
     */
533
    protected function getHeaderFlashMessagesForCurrentPid(): string
534
535
536
    {
        $content = '';
        $lang = $this->getLanguageService();
537

538
539
540
        $view = GeneralUtility::makeInstance(StandaloneView::class);
        $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html'));

541
542
543
544
545
546
547
548
549
        // If page is a folder
        if ($this->pageinfo['doktype'] == PageRepository::DOKTYPE_SYSFOLDER) {
            $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
            $moduleLoader->load($GLOBALS['TBE_MODULES']);
            $modules = $moduleLoader->modules;
            if (is_array($modules['web']['sub']['list'])) {
                $title = $lang->getLL('goToListModule');
                $message = '<p>' . $lang->getLL('goToListModuleMessage') . '</p>';
                $message .= '<a class="btn btn-info" href="javascript:top.goToModule(\'web_list\',1);">' . $lang->getLL('goToListModule') . '</a>';
550
                $view->assignMultiple([
551
552
553
                    'title' => $title,
                    'message' => $message,
                    'state' => InfoboxViewHelper::STATE_INFO
554
                ]);
555
556
                $content .= $view->render();
            }
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
        } elseif ($this->pageinfo['doktype'] === PageRepository::DOKTYPE_SHORTCUT) {
            $shortcutMode = (int)$this->pageinfo['shortcut_mode'];
            $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
            $targetPage = [];

            if ($this->pageinfo['shortcut'] || $shortcutMode) {
                switch ($shortcutMode) {
                    case PageRepository::SHORTCUT_MODE_NONE:
                        $targetPage = $pageRepository->getPage($this->pageinfo['shortcut']);
                        break;
                    case PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE:
                        $targetPage = reset($pageRepository->getMenu($this->pageinfo['shortcut'] ?: $this->pageinfo['uid']));
                        break;
                    case PageRepository::SHORTCUT_MODE_PARENT_PAGE:
                        $targetPage = $pageRepository->getPage($this->pageinfo['pid']);
                        break;
                }

                $message = '';
                if ($shortcutMode === PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
                    $message .= sprintf($lang->getLL('pageIsRandomInternalLinkMessage'));
                } else {
                    $linkToPid = $this->local_linkThisScript(['id' => $targetPage['uid']]);
                    $path = BackendUtility::getRecordPath($targetPage['uid'], $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW), 1000);
581
                    $linkedPath = '<a href="' . htmlspecialchars($linkToPid) . '">' . htmlspecialchars($path) . '</a>';
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
                    $message .= sprintf($lang->getLL('pageIsInternalLinkMessage'), $linkedPath);
                }

                $message .= ' (' . htmlspecialchars($lang->sL(BackendUtility::getLabelFromItemlist('pages', 'shortcut_mode', $shortcutMode))) . ')';

                $view->assignMultiple([
                    'title' => $this->pageinfo['title'],
                    'message' => $message,
                    'state' => InfoboxViewHelper::STATE_INFO
                ]);
                $content .= $view->render();
            } else {
                if (empty($targetPage) && $shortcutMode !== PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
                    $view->assignMultiple([
                        'title' => $this->pageinfo['title'],
                        'message' => $lang->getLL('pageIsMisconfiguredInternalLinkMessage'),
                        'state' => InfoboxViewHelper::STATE_ERROR
                    ]);
                    $content .= $view->render();
                }
            }
        } elseif ($this->pageinfo['doktype'] === PageRepository::DOKTYPE_LINK) {
            if (empty($this->pageinfo['url'])) {
                $view->assignMultiple([
                    'title' => $this->pageinfo['title'],
                    'message' => $lang->getLL('pageIsMisconfiguredExternalLinkMessage'),
                    'state' => InfoboxViewHelper::STATE_ERROR
                ]);
                $content .= $view->render();
            } else {
                $externalUrl = htmlspecialchars(GeneralUtility::makeInstance(PageRepository::class)->getExtURL($this->pageinfo));
                if ($externalUrl !== false) {
                    $externalUrlHtml = '<a href="' . $externalUrl . '" target="_blank" rel="noopener">' . $externalUrl . '</a>';
                    $view->assignMultiple([
                        'title' => $this->pageinfo['title'],
                        'message' => sprintf($lang->getLL('pageIsExternalLinkMessage'), $externalUrlHtml),
                        'state' => InfoboxViewHelper::STATE_INFO
                    ]);
                    $content .= $view->render();
                }
            }
623
624
625
626
        }
        // If content from different pid is displayed
        if ($this->pageinfo['content_from_pid']) {
            $contentPage = BackendUtility::getRecord('pages', (int)$this->pageinfo['content_from_pid']);
627
            $linkToPid = $this->local_linkThisScript(['id' => $this->pageinfo['content_from_pid']]);
628
            $title = BackendUtility::getRecordTitle('pages', $contentPage);
629
            $link = '<a href="' . htmlspecialchars($linkToPid) . '">' . htmlspecialchars($title) . ' (PID ' . (int)$this->pageinfo['content_from_pid'] . ')</a>';
630
            $message = sprintf($lang->getLL('content_from_pid_title'), $link);
631
            $view->assignMultiple([
632
633
634
                'title' => $title,
                'message' => $message,
                'state' => InfoboxViewHelper::STATE_INFO
635
            ]);
636
            $content .= $view->render();
637
638
639
640
641
642
643
644
645
646
647
        } else {
            $links = $this->getPageLinksWhereContentIsAlsoShownOn($this->pageinfo['uid']);
            if (!empty($links)) {
                $message = sprintf($lang->getLL('content_on_pid_title'), $links);
                $view->assignMultiple([
                    'title' => '',
                    'message' => $message,
                    'state' => InfoboxViewHelper::STATE_INFO
                ]);
                $content .= $view->render();
            }
648
649
650
651
        }
        return $content;
    }

652
653
654
655
656
657
    /**
     * Get all pages with links where the content of a page $pageId is also shown on
     *
     * @param int $pageId
     * @return string
     */
658
    protected function getPageLinksWhereContentIsAlsoShownOn($pageId): string
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
    {
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
        $queryBuilder->getRestrictions()->removeAll();
        $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
        $queryBuilder
            ->select('*')
            ->from('pages')
            ->where($queryBuilder->expr()->eq('content_from_pid', $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)));

        $links = [];
        $rows = $queryBuilder->execute()->fetchAll();
        if (!empty($rows)) {
            foreach ($rows as $row) {
                $linkToPid = $this->local_linkThisScript(['id' => $row['uid']]);
                $title = BackendUtility::getRecordTitle('pages', $row);
                $link = '<a href="' . htmlspecialchars($linkToPid) . '">' . htmlspecialchars($title) . ' (PID ' . (int)$row['uid'] . ')</a>';
                $links[] = $link;
            }
        }
        return implode(', ', $links);
    }

681
682
683
    /**
     * @return string $title
     */
684
    protected function getLocalizedPageTitle(): string
685
686
    {
        if ($this->current_sys_language > 0) {
687
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
688
                ->getQueryBuilderForTable('pages');
689
690
691
692
            $queryBuilder->getRestrictions()
                ->removeAll()
                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
                ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
693
            $localizedPage = $queryBuilder
694
                ->select('*')
695
                ->from('pages')
696
                ->where(
697
                    $queryBuilder->expr()->eq(
698
                        $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
699
700
                        $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
                    ),
701
                    $queryBuilder->expr()->eq(
702
                        $GLOBALS['TCA']['pages']['ctrl']['languageField'],
703
704
                        $queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
                    )
705
706
707
708
                )
                ->setMaxResults(1)
                ->execute()
                ->fetch();
709
710
            BackendUtility::workspaceOL('pages', $localizedPage);
            return $localizedPage['title'];
711
        }
712
        return $this->pageinfo['title'];
713
714
715
716
717
    }

    /**
     * Main function.
     * Creates some general objects and calls other functions for the main rendering of module content.
718
719
     *
     * @param ServerRequestInterface $request
720
     */
721
    protected function main(ServerRequestInterface $request = null): void
722
    {
723
        $request = $request ?: $GLOBALS['TYPO3_REQUEST'];
724
725
726
        $lang = $this->getLanguageService();
        // Access check...
        // The page will show only if there is a valid page and if this page may be viewed by the user
727
        $access = is_array($this->pageinfo);
728
729
        // Content
        $content = '';
730
731
732
        if ($this->id && $access) {
            // Initialize permission settings:
            $this->CALC_PERMS = $this->getBackendUser()->calcPerms($this->pageinfo);
733
            $this->EDIT_CONTENT = $this->isContentEditable();
734

735
736
            $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);

737
            $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
738

739
740
741
            $this->moduleTemplate->addJavaScriptCode('mainJsFunctions', '
                if (top.fsMod) {
                    top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
742
                    top.fsMod.navFrameHighlightedID["web"] = top.fsMod.currentBank + "_" + ' . (int)$this->id . ';
743
744
745
                }
                ' . ($this->popView ? BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id)) : '') . '
                function deleteRecord(table,id,url) {   //
746
                    window.location.href = ' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('tce_db') . '&cmd[')
747
                                            . ' + table + "][" + id + "][delete]=1&redirect=" + encodeURIComponent(url);
748
749
750
751
                    return false;
                }
            ');

752
            // Find backend layout / columns
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
            $backendLayout = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getSelectedBackendLayout', $this->id, $this);
            if (!empty($backendLayout['__colPosList'])) {
                $this->colPosList = implode(',', $backendLayout['__colPosList']);
            }
            // Removing duplicates, if any
            $this->colPosList = array_unique(GeneralUtility::intExplode(',', $this->colPosList));
            // Accessible columns
            if (isset($this->modSharedTSconfig['properties']['colPos_list']) && trim($this->modSharedTSconfig['properties']['colPos_list']) !== '') {
                $this->activeColPosList = array_unique(GeneralUtility::intExplode(',', trim($this->modSharedTSconfig['properties']['colPos_list'])));
                // Match with the list which is present in the colPosList for the current page
                if (!empty($this->colPosList) && !empty($this->activeColPosList)) {
                    $this->activeColPosList = array_unique(array_intersect(
                        $this->activeColPosList,
                        $this->colPosList
                    ));
                }
            } else {
                $this->activeColPosList = $this->colPosList;
            }
            $this->activeColPosList = implode(',', $this->activeColPosList);
            $this->colPosList = implode(',', $this->colPosList);

775
776
            $content .= $this->getHeaderFlashMessagesForCurrentPid();

777
            // Render the primary module content:
778
            if ($this->MOD_SETTINGS['function'] == 1 || $this->MOD_SETTINGS['function'] == 2) {
779
                $content .= '<form action="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->id, 'imagemode' =>  $this->imagemode])) . '" id="PageLayoutController" method="post">';
780
                // Page title
781
                $content .= '<h1 class="t3js-title-inlineedit">' . htmlspecialchars($this->getLocalizedPageTitle()) . '</h1>';
782
                // All other listings
783
                $content .= $this->renderContent();
784
            }
785
786
            $content .= '</form>';
            $content .= $this->searchContent;
787
            // Setting up the buttons for the docheader
788
789
            $this->makeButtons($request);

790
791
792
793
794
795
796
            // Create LanguageMenu
            $this->makeLanguageMenu();
        } else {
            $this->moduleTemplate->addJavaScriptCode(
                'mainJsFunctions',
                'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';'
            );
797
            $content .= '<h1>' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '</h1>';
798
799
            $view = GeneralUtility::makeInstance(StandaloneView::class);
            $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html'));
800
            $view->assignMultiple([
801
802
                'title' => $lang->getLL('clickAPage_header'),
                'message' => $lang->getLL('clickAPage_content'),
803
                'state' => InfoboxViewHelper::STATE_INFO
804
            ]);
805
            $content .= $view->render();
806
        }
807
808
        // Set content
        $this->moduleTemplate->setContent($content);
809
810
811
    }

    /**
812
     * Rendering content
813
814
815
     *
     * @return string
     */
816
    protected function renderContent(): string
817
    {
818
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
819

820
        $this->moduleTemplate->getPageRenderer()->loadJquery();
821
        $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
822
823
824
825
826
        $dbList = GeneralUtility::makeInstance(PageLayoutView::class);
        $dbList->thumbs = $this->imagemode;
        $dbList->no_noWrap = 1;
        $dbList->descrTable = $this->descrTable;
        $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
827
        $dbList->script = (string)$uriBuilder->buildUriFromRoute($this->moduleName);
828
829
830
831
        $dbList->showIcon = 0;
        $dbList->setLMargin = 0;
        $dbList->doEdit = $this->EDIT_CONTENT;
        $dbList->ext_CALC_PERMS = $this->CALC_PERMS;
832
        $dbList->agePrefixes = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
833
834
        $dbList->id = $this->id;
        $dbList->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
835
836
        $dbList->option_newWizard = empty($this->modTSconfig['properties']['disableNewContentElementWizard']);
        $dbList->defLangBinding = !empty($this->modTSconfig['properties']['defLangBinding']);
837
838
839
840
841
842
843
        if (!$dbList->nextThree) {
            $dbList->nextThree = 1;
        }
        // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
        // also fills $dbList->activeTables
        $dbList->getTableMenu($this->id);
        // Initialize other variables:
844
845
        $tableOutput = [];
        $tableJSOutput = [];
846
847
848
849
        $CMcounter = 0;
        // Traverse the list of table names which has records on this page (that array is populated
        // by the $dblist object during the function getTableMenu()):
        foreach ($dbList->activeTables as $table => $value) {
850
            $h_func = '';
851
852
853
854
855
856
857
858
            $h_func_b = '';
            if (!isset($dbList->externalTables[$table])) {
                // Boolean: Display up/down arrows and edit icons for tt_content records
                $dbList->tt_contentConfig['showCommands'] = 1;
                // Boolean: Display info-marks or not
                $dbList->tt_contentConfig['showInfo'] = 1;
                // Setting up the tt_content columns to show:
                if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
859
                    $colList = [];
860
861
862
863
864
865
                    $tcaItems = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getColPosListItemsParsed', $this->id, $this);
                    foreach ($tcaItems as $temp) {
                        $colList[] = $temp[1];
                    }
                } else {
                    // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
866
                    $colList = ['1', '0', '2', '3'];
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
                }
                if ($this->colPosList !== '') {
                    $colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
                }
                // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
                $dbList->tt_contentConfig['cols'] = implode(',', $colList);
                $dbList->tt_contentConfig['activeCols'] = $this->activeColPosList;
                $dbList->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
                $dbList->tt_contentConfig['sys_language_uid'] = (int)$this->current_sys_language;
                // If the function menu is set to "Language":
                if ($this->MOD_SETTINGS['function'] == 2) {
                    $dbList->tt_contentConfig['languageMode'] = 1;
                    $dbList->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
                    $dbList->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
                }
882
883
884
885
886
887
888
889
890
891
892
                // Toggle hidden ContentElements
                $numberOfHiddenElements = $this->getNumberOfHiddenElements($dbList->tt_contentConfig);
                if ($numberOfHiddenElements > 0) {
                    $h_func_b = '
                        <div class="checkbox">
                            <label for="checkTt_content_showHidden">
                                <input type="checkbox" id="checkTt_content_showHidden" class="checkbox" name="SET[tt_content_showHidden]" value="1" ' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? 'checked="checked"' : '') . ' />
                                ' . htmlspecialchars($this->getLanguageService()->getLL('hiddenCE')) . ' (<span class="t3js-hidden-counter">' . $numberOfHiddenElements . '</span>)
                            </label>
                        </div>';
                }
893
894
895
896
897
898
899
900
901
902
903
904
905
            } else {
                if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
                    $h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], '', '');
                }
            }
            // Start the dblist object:
            $dbList->itemsLimitSingleTable = 1000;
            $dbList->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
            $dbList->counter = $CMcounter;
            $dbList->ext_function = $this->MOD_SETTINGS['function'];
            // Generate the list of elements here:
            $dbList->generateList();
            // Adding the list content to the tableOutput variable:
906
            $tableOutput[$table] = $h_func . $dbList->HTMLcode . $h_func_b;
907
908
909
910
911
912
913
914
915
916
917
918
919
            // ... and any accumulated JavaScript goes the same way!
            $tableJSOutput[$table] = $dbList->JScode;
            // Increase global counter:
            $CMcounter += $dbList->counter;
            // Reset variables after operation:
            $dbList->HTMLcode = '';
            $dbList->JScode = '';
        }
        // END: traverse tables
        // For Context Sensitive Menus:
        // Init the content
        $content = '';
        // Additional header content
920
921
922
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'] ?? [] as $hook) {
            $params = [];
            $content .= GeneralUtility::callUserFunction($hook, $params, $this);
923
924
925
        }
        // Add the content for each table we have rendered (traversing $tableOutput variable)
        foreach ($tableOutput as $table => $output) {
926
            $content .= $output;
927
928
        }
        // Making search form:
929
        if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dbList->counter > 0 || $this->currentPageHasSubPages())) {
930
            $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
931
932
            $toggleSearchFormButton = $this->buttonBar->makeLinkButton()
                ->setClasses('t3js-toggle-search-toolbox')
933
                ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon'))
934
935
936
                ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL))
                ->setHref('#');
            $this->buttonBar->addButton($toggleSearchFormButton, ButtonBar::BUTTON_POSITION_LEFT, 4);
937
            $this->searchContent = $dbList->getSearchBox();
938
939
        }
        // Additional footer content
940
941
942
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'] ?? [] as $hook) {
            $params = [];
            $content .= GeneralUtility::callUserFunction($hook, $params, $this);
943
944
945
946
        }
        return $content;
    }

947
948
949
    /**
     * @return ModuleTemplate
     */
950
    protected function getModuleTemplate(): ModuleTemplate
951
952
953
954
    {
        return $this->moduleTemplate;
    }

955
956
957
958
959
960
    /***************************
     *
     * Sub-content functions, rendering specific parts of the module content.
     *
     ***************************/
    /**
961
     * This creates the buttons for the modules
962
     * @param ServerRequestInterface $request
963
     */
964
    protected function makeButtons(ServerRequestInterface $request): void
965
    {
966
967
968
969
        if ($this->MOD_SETTINGS['function'] == 1 || $this->MOD_SETTINGS['function'] == 2) {
            // Add CSH (Context Sensitive Help) icon to tool bar
            $contextSensitiveHelpButton = $this->buttonBar->makeHelpButton()
                ->setModuleName($this->descrTable)
970
                ->setFieldName('columns_' . $this->MOD_SETTINGS['function']);
971
972
            $this->buttonBar->addButton($contextSensitiveHelpButton);
        }
973
974
975
        $lang = $this->getLanguageService();
        // View page
        if (!VersionState::cast($this->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
976
            $viewButton = $this->buttonBar->makeLinkButton()
977
                ->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))
978
                ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
979
                ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL))
980
981
982
                ->setHref('#');

            $this->buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
983
984
        }
        // Shortcut
985
986
987
988
        $shortcutButton = $this->buttonBar->makeShortcutButton()
            ->setModuleName($this->moduleName)
            ->setGetVariables([
                'id',
989
                'route',
990
991
992
993
994
995
996
997
998
999
                'edit_record',
                'pointer',
                'new_unique_uid',
                'search_field',
                'search_levels',
                'showLimit'
            ])
            ->setSetVariables(array_keys($this->MOD_MENU));
        $this->buttonBar->addButton($shortcutButton);

1000
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1001
        // Cache
1002
        if (empty($this->modTSconfig['properties']['disableAdvanced'])) {
1003
            $clearCacheButton = $this->buttonBar->makeLinkButton()
1004
                ->setHref((string)$uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->pageinfo['uid'], 'clear_cache' => '1']))
1005
                ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
1006
                ->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
1007
            $this->buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
1008
        }
1009
        if (empty($this->modTSconfig['properties']['disableIconToolbar'])) {
1010
            // Edit page properties and page language overlay icons
1011
1012
1013
            if ($this->isPageEditable() && $this->getBackendUser()->checkLanguageAccess(0)) {
                /** @var \TYPO3\CMS\Core\Http\NormalizedParams */
                $normalizedParams = $request->getAttribute('normalizedParams');
1014
                // Edit localized pages only when one specific language is selected
1015
                if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
1016
1017
                    $localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
                    $languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
1018
                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
1019
                        ->getQueryBuilderForTable('pages');
1020
1021
1022
1023
1024
1025
                    $queryBuilder->getRestrictions()
                        ->removeAll()
                        ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
                        ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
                    $overlayRecord = $queryBuilder
                        ->select('uid')
1026
                        ->from('pages')
1027
                        ->where(
1028
                            $queryBuilder->expr()->eq(
1029
                                $localizationParentField,
1030
1031
1032
                                $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
                            ),
                            $queryBuilder->expr()->eq(
1033
                                $languageField,
1034
1035
                                $queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
                            )
1036
1037
1038
1039
                        )
                        ->setMaxResults(1)
                        ->execute()
                        ->fetch();
1040
1041
1042
                    // Edit button
                    $urlParameters = [
                        'edit' => [
1043
                            'pages' => [
1044
1045
1046
                                $overlayRecord['uid'] => 'edit'
                            ]
                        ],
1047
                        'returnUrl' => $normalizedParams->getRequestUri(),
1048
                    ];
1049
1050

                    $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1051
                    $editLanguageButton = $this->buttonBar->makeLinkButton()
1052
                        ->setHref($url)
1053
                        ->setTitle($lang->getLL('editPageLanguageOverlayProperties'))
1054
1055
                        ->setIcon($this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL