PagePositionMap.php 24.3 KB
Newer Older
1
<?php
2

3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
7
8
 * 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.
9
 *
10
11
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
14
 * The TYPO3 project - inspiring people to share!
 */
Nicole Cordes's avatar
Nicole Cordes committed
15

16
17
namespace TYPO3\CMS\Backend\Tree\View;

18
use TYPO3\CMS\Backend\Routing\UriBuilder;
Nicole Cordes's avatar
Nicole Cordes committed
19
use TYPO3\CMS\Backend\Utility\BackendUtility;
20
use TYPO3\CMS\Backend\View\BackendLayoutView;
21
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
22
use TYPO3\CMS\Core\Database\ConnectionPool;
23
24
25
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
26
use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction;
27
28
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
29
use TYPO3\CMS\Core\Localization\LanguageService;
Nicole Cordes's avatar
Nicole Cordes committed
30
use TYPO3\CMS\Core\Utility\GeneralUtility;
31
use TYPO3\CMS\Core\Utility\MathUtility;
Nicole Cordes's avatar
Nicole Cordes committed
32

33
34
35
/**
 * Position map class - generating a page tree / content element list which links for inserting (copy/move) of records.
 * Used for pages / tt_content element wizards of various kinds.
36
 * @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
37
 */
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class PagePositionMap
{
    // EXTERNAL, static:
    /**
     * @var string
     */
    public $moveOrCopy = 'move';

    /**
     * @var int
     */
    public $dontPrintPageInsertIcons = 0;

    // How deep the position page tree will go.
    /**
     * @var int
     */
    public $depth = 2;

    // Can be set to the sys_language uid to select content elements for.
    /**
59
     * @var int
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
     */
    public $cur_sys_language;

    // INTERNAL, dynamic:
    // Request uri
    /**
     * @var string
     */
    public $R_URI = '';

    // Element id.
    /**
     * @var string
     */
    public $elUid = '';

    // tt_content element uid to move.
    /**
     * @var string
     */
    public $moveUid = '';

    /**
     * @var array
     */
85
    public $checkNewPageCache = [];
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

    // Label keys:
    /**
     * @var string
     */
    public $l_insertNewPageHere = 'insertNewPageHere';

    /**
     * @var string
     */
    public $l_insertNewRecordHere = 'insertNewRecordHere';

    /**
     * Page tree implementation class name
     *
     * @var string
     */
    protected $pageTreeClassName = ElementBrowserPageTreeView::class;

105
106
107
108
109
    /**
     * @var IconFactory
     */
    protected $iconFactory;

110
111
112
113
114
    /**
     * @var string
     */
    protected $clientContext;

115
116
117
118
    /**
     * Constructor allowing to set pageTreeImplementation
     *
     * @param string $pageTreeClassName
119
     * @param string $clientContext JavaScript context of view client (either 'window' or 'list_frame')
120
     */
121
    public function __construct(string $pageTreeClassName = null, string $clientContext = 'window')
122
123
124
125
    {
        if ($pageTreeClassName !== null) {
            $this->pageTreeClassName = $pageTreeClassName;
        }
126
        $this->clientContext = $clientContext;
127
        $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
    }

    /*************************************
     *
     * Page position map:
     *
     **************************************/
    /**
     * Creates a "position tree" based on the page tree.
     *
     * @param int $id Current page id
     * @param array $pageinfo Current page record.
     * @param string $perms_clause Page selection permission clause.
     * @param string $R_URI Current REQUEST_URI
     * @return string HTML code for the tree.
     */
    public function positionTree($id, $pageinfo, $perms_clause, $R_URI)
    {
146
147
148
149
150
151
        // Make page tree object
        if ($this->pageTreeClassName === NewRecordPageTreeView::class) {
            $pageTree = GeneralUtility::makeInstance($this->pageTreeClassName, (int)$id);
        } else {
            $pageTree = GeneralUtility::makeInstance($this->pageTreeClassName);
        }
152
        /** @var PageTreeView $pageTree */
153
154
155
156
157
158
159
160
        $pageTree->init(' AND ' . $perms_clause);
        $pageTree->addField('pid');
        // Initialize variables:
        $this->R_URI = $R_URI;
        $this->elUid = $id;
        // Create page tree, in $this->depth levels.
        $pageTree->getTree($pageinfo['pid'], $this->depth);
        // Initialize variables:
161
        $saveLatestUid = [];
162
163
        $latestInvDepth = $this->depth;
        // Traverse the tree:
164
        $lines = [];
165
        foreach ($pageTree->tree as $cc => $dat) {
166
167
168
169
            if ($latestInvDepth > $dat['invertedDepth']) {
                $margin = 'style="margin-left: ' . ($dat['invertedDepth'] * 16 + 9) . 'px;"';
                $lines[] = '<ul class="list-tree" ' . $margin . '>';
            }
170
171
172
173
174
175
176
177
178
179
            // Make link + parameters.
            $latestInvDepth = $dat['invertedDepth'];
            $saveLatestUid[$latestInvDepth] = $dat;
            if (isset($pageTree->tree[$cc - 1])) {
                $prev_dat = $pageTree->tree[$cc - 1];
                // If current page, subpage?
                if ($prev_dat['row']['uid'] == $id) {
                    // 1) It must be allowed to create a new page and 2) If there are subpages there is no need to render a subpage icon here - it'll be done over the subpages...
                    if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth'])) {
                        end($lines);
180
                        $margin = 'style="margin-left: ' . (($dat['invertedDepth'] - 1) * 16 + 9) . 'px;"';
181
                        $lines[] = '<ul class="list-tree" ' . $margin . '><li><span class="text-nowrap"><a href="' . htmlspecialchars($this->getActionLink($id, $id)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>';
182
183
184
185
186
187
188
189
190
191
192
                    }
                }
                // If going down
                if ($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth']) {
                    $prevPid = $pageTree->tree[$cc]['row']['pid'];
                } elseif ($prev_dat['invertedDepth'] < $pageTree->tree[$cc]['invertedDepth']) {
                    // If going up
                    // First of all the previous level should have an icon:
                    if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($prev_dat['row']['pid'])) {
                        $prevPid = -$prev_dat['row']['uid'];
                        end($lines);
193
                        $lines[] = '<li><span class="text-nowrap"><a href="' . htmlspecialchars($this->getActionLink((int)$prevPid, $prev_dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li>';
194
195
196
                    }
                    // Then set the current prevPid
                    $prevPid = -$prev_dat['row']['pid'];
197
198
199
                    if ($prevPid !== $dat['row']['pid']) {
                        $lines[] = '</ul>';
                    }
200
201
202
203
204
205
206
207
208
209
                } else {
                    // In on the same level
                    $prevPid = -$prev_dat['row']['uid'];
                }
            } else {
                // First in the tree
                $prevPid = $dat['row']['pid'];
            }
            // print arrow on the same level
            if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) {
210
                $lines[] = '<span class="text-nowrap"><a href="' . htmlspecialchars($this->getActionLink($prevPid, $dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>';
211
212
            }
            // The line with the icon and title:
213
214
215
216
            $toolTip = BackendUtility::getRecordToolTip($dat['row'], 'pages');
            $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord('pages', $dat['row'], Icon::SIZE_SMALL)->render() . '</span>';

            $lines[] = '<span class="text-nowrap">' . $icon . $this->linkPageTitle($this->boldTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($dat['row']['title'], $this->getBackendUser()->uc['titleLen'])), $dat, $id), $dat['row']) . '</span>';
217
218
219
220
221
        }
        // If the current page was the last in the tree:
        $prev_dat = end($pageTree->tree);
        if ($prev_dat['row']['uid'] == $id) {
            if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id)) {
222
                $lines[] = '<ul class="list-tree" style="margin-left: 25px"><li><span class="text-nowrap"><a href="' . htmlspecialchars($this->getActionLink($id, $id)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>';
223
224
225
226
227
228
            }
        }
        for ($a = $latestInvDepth; $a <= $this->depth; $a++) {
            $dat = $saveLatestUid[$a];
            $prevPid = -$dat['row']['uid'];
            if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) {
229
230
231
                if ($latestInvDepth < $dat['invertedDepth']) {
                    $lines[] = '</ul>';
                }
232
                $lines[] = '<span class="text-nowrap"><a href="' . htmlspecialchars($this->getActionLink((int)$prevPid, $dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>';
233
234
235
236
237
238
            }
        }

        $code = '<ul class="list-tree">';

        foreach ($lines as $line) {
239
            if ((strpos($line, '<ul') === 0) || (strpos($line, '</ul') === 0)) {
240
241
242
243
                $code .= $line;
            } else {
                $code .= '<li>' . $line . '</li>';
            }
244
245
246
247
248
249
250
251
252
253
        }

        $code .= '</ul>';
        return $code;
    }

    /**
     * Wrap $t_code in bold IF the $dat uid matches $id
     *
     * @param string $t_code Title string
254
     * @param array $dat Information array with record array inside.
255
256
257
258
259
260
261
262
263
264
265
266
267
268
     * @param int $id The current id.
     * @return string The title string.
     */
    public function boldTitle($t_code, $dat, $id)
    {
        if ($dat['row']['uid'] == $id) {
            $t_code = '<strong>' . $t_code . '</strong>';
        }
        return $t_code;
    }

    /**
     * Creates the onclick event for the insert-icons.
     *
269
270
     * TSconfig mod.newPageWizard.override may contain an alternative module / route which can be
     * used instead of the normal create new page wizard.
271
272
273
274
275
     *
     * @param int $pid The pid.
     * @param int $newPagePID New page id.
     * @return string Onclick attribute content
     */
276
    public function getActionLink($pid, $newPagePID): string
277
    {
278
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
279
        $TSconfig = BackendUtility::getPagesTSconfig($newPagePID)['mod.']['newPageWizard.'] ?? [];
280
        if (isset($TSconfig['override']) && !empty($TSconfig['override'])) {
281
            $url = $uriBuilder->buildUriFromRoute(
282
283
                $TSconfig['override'],
                [
284
285
286
287
288
                    'positionPid' => $pid,
                    'newPageId'   => $newPagePID,
                    'cmd'         => 'crPage',
                    'returnUrl'   => GeneralUtility::getIndpEnv('REQUEST_URI')
                ]
289
            );
290
            return (string)$url;
291
        }
292
293
294
295
296
297
298
299
300
301

        return (string)$uriBuilder->buildUriFromRoute('record_edit', [
            'edit' => [
                'pages' => [
                    $pid => 'new',
                ],
            ],
            'returnNewPageId' => '1',
            'returnUrl' => $this->R_URI
        ]);
302
303
304
305
306
307
308
309
310
    }

    /**
     * Get label, htmlspecialchars()'ed
     *
     * @return string The localized label for "insert new page here
     */
    public function insertlabel()
    {
311
        return htmlspecialchars($this->getLanguageService()->getLL($this->l_insertNewPageHere));
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
    }

    /**
     * Wrapping page title.
     *
     * @param string $str Page title.
     * @param array $rec Page record (?)
     * @return string Wrapped title.
     */
    public function linkPageTitle($str, $rec)
    {
        return $str;
    }

    /**
     * Checks if the user has permission to created pages inside of the $pid page.
     * Uses caching so only one regular lookup is made - hence you can call the function multiple times without worrying about performance.
     *
     * @param int $pid Page id for which to test.
     * @return bool
     */
    public function checkNewPageInPid($pid)
    {
        if (!isset($this->checkNewPageCache[$pid])) {
            $pidInfo = BackendUtility::getRecord('pages', $pid);
337
            $this->checkNewPageCache[$pid] = $this->getBackendUser()->isAdmin() || $this->getBackendUser()->doesUserHaveAccess($pidInfo, 8);
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
        }
        return $this->checkNewPageCache[$pid];
    }

    /*************************************
     *
     * Content element positioning:
     *
     **************************************/
    /**
     * Creates HTML for inserting/moving content elements.
     *
     * @param int $pid page id onto which to insert content element.
     * @param int $moveUid Move-uid (tt_content element uid?)
     * @param string $colPosList List of columns to show
     * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out.
     * @param string $R_URI Request URI
     * @return string HTML
     */
    public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
    {
        $this->R_URI = $R_URI;
        $this->moveUid = $moveUid;
        $colPosArray = GeneralUtility::trimExplode(',', $colPosList, true);
362
        $lines = [];
363
        foreach ($colPosArray as $kk => $vv) {
364
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
365
            $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$this->getBackendUser()->workspace));
366
367
368
369
370
371
            if ($showHidden) {
                $queryBuilder->getRestrictions()
                    ->removeByType(HiddenRestriction::class)
                    ->removeByType(StartTimeRestriction::class)
                    ->removeByType(EndTimeRestriction::class);
            }
372
373
374
            $queryBuilder
                ->select('*')
                ->from('tt_content')
375
                ->where(
376
377
                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)),
                    $queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter($vv, \PDO::PARAM_INT))
378
                )
379
380
381
                ->orderBy('sorting');

            if ((string)$this->cur_sys_language !== '') {
382
383
384
385
386
387
                $queryBuilder->andWhere(
                    $queryBuilder->expr()->eq(
                        'sys_language_uid',
                        $queryBuilder->createNamedParameter($this->cur_sys_language, \PDO::PARAM_INT)
                    )
                );
388
389
390
            }

            $res = $queryBuilder->execute();
391
            $lines[$vv] = [];
392
            $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
393
394

            while ($row = $res->fetch()) {
395
396
                BackendUtility::workspaceOL('tt_content', $row);
                if (is_array($row)) {
397
                    $lines[$vv][] = $this->getRecordHeader($row);
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
                    $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
                }
            }
        }
        return $this->printRecordMap($lines, $colPosArray, $pid);
    }

    /**
     * Creates the table with the content columns
     *
     * @param array $lines Array with arrays of lines for each column
     * @param array $colPosArray Column position array
     * @param int $pid The id of the page
     * @return string HTML
     */
    public function printRecordMap($lines, $colPosArray, $pid = 0)
    {
415
        $count = MathUtility::forceIntegerInRange(count($colPosArray), 1);
416
417
        $backendLayoutProvider = GeneralUtility::makeInstance(BackendLayoutView::class);
        $backendLayout = $backendLayoutProvider->getSelectedBackendLayout($pid);
418
        if (isset($backendLayout['__config']['backend_layout.'])) {
419
            $this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
420
            $table = '<div class="table-fit"><table class="table table-sm table-bordered table-vertical-top">';
421
422
423
424
425
426
427
428
            $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
            $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
            $table .= '<colgroup>';
            for ($i = 0; $i < $colCount; $i++) {
                $table .= '<col style="width:' . 100 / $colCount . '%"></col>';
            }
            $table .= '</colgroup>';
            $table .= '<tbody>';
429
            $tcaItems = $backendLayoutProvider->getColPosListItemsParsed($pid);
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
            // Cycle through rows
            for ($row = 1; $row <= $rowCount; $row++) {
                $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
                if (!isset($rowConfig)) {
                    continue;
                }
                $table .= '<tr>';
                for ($col = 1; $col <= $colCount; $col++) {
                    $columnConfig = $rowConfig['columns.'][$col . '.'];
                    if (!isset($columnConfig)) {
                        continue;
                    }
                    // Which tt_content colPos should be displayed inside this cell
                    $columnKey = (int)$columnConfig['colPos'];
                    $head = '';
                    foreach ($tcaItems as $item) {
                        if ($item[1] == $columnKey) {
447
                            $head = htmlspecialchars($this->getLanguageService()->sL($item[0]));
448
449
450
451
452
453
454
455
456
457
458
459
                        }
                    }
                    // Render the grid cell
                    $table .= '<td'
                        . (isset($columnConfig['colspan']) ? ' colspan="' . $columnConfig['colspan'] . '"' : '')
                        . (isset($columnConfig['rowspan']) ? ' rowspan="' . $columnConfig['rowspan'] . '"' : '')
                        . ' class="col-nowrap col-min'
                        . (!isset($columnConfig['colPos']) ? ' warning' : '')
                        . (isset($columnConfig['colPos']) && !$head ? ' danger' : '') . '">';
                    // Render header
                    $table .= '<p>';
                    if (isset($columnConfig['colPos']) && $head) {
460
                        $table .= '<strong>' . $head . '</strong>';
461
                    } elseif ($columnConfig['colPos']) {
462
                        $table .= '<em>' . $this->getLanguageService()->getLL('noAccess') . '</em>';
463
                    } else {
464
                        $table .= '<em>' . ($this->getLanguageService()->sL($columnConfig['name']) ?: '') . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')' . '</em>';
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
                    }
                    $table .= '</p>';
                    // Render lines
                    if (isset($columnConfig['colPos']) && $head && !empty($lines[$columnKey])) {
                        $table .= '<ul class="list-unstyled">';
                        foreach ($lines[$columnKey] as $line) {
                            $table .= '<li>' . $line . '</li>';
                        }
                        $table .= '</ul>';
                    }
                    $table .= '</td>';
                }
                $table .= '</tr>';
            }
            $table .= '</tbody>';
            $table .= '</table></div>';
        } else {
            // Traverse the columns here:
            $row = '';
            foreach ($colPosArray as $kk => $vv) {
                $row .= '<td class="col-nowrap col-min" width="' . round(100 / $count) . '%">';
486
                $row .= '<p><strong>' . htmlspecialchars($this->getLanguageService()->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $vv))) . '</strong></p>';
487
488
489
490
491
492
493
494
495
496
                if (!empty($lines[$vv])) {
                    $row .= '<ul class="list-unstyled">';
                    foreach ($lines[$vv] as $line) {
                        $row .= '<li>' . $line . '</li>';
                    }
                    $row .= '</ul>';
                }
                $row .= '</td>';
            }
            $table = '
497
498
499
500

			<!--
				Map of records in columns:
			-->
501
			<div class="table-fit">
502
				<table class="table table-sm table-bordered table-vertical-top">
503
504
505
					<tr>' . $row . '</tr>
				</table>
			</div>
506
507

			';
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
        }
        return $table;
    }

    /**
     * Creates a linked position icon.
     *
     * @param mixed $row Element row. If this is an array the link will cause an insert after this content element, otherwise
     * the link will insert at the first position in the column
     * @param string $vv Column position value.
     * @param int $kk Column key.
     * @param int $moveUid Move uid
     * @param int $pid PID value.
     * @return string
     */
    public function insertPositionIcon($row, $vv, $kk, $moveUid, $pid)
    {
        if (is_array($row) && !empty($row['uid'])) {
            // Use record uid for the hash when inserting after this content element
            $uid = $row['uid'];
        } else {
            // No uid means insert at first position in the column
            $uid = '';
        }
        $cc = hexdec(substr(md5($uid . '-' . $vv . '-' . $kk), 0, 4));
533
        return '<a href="#" onclick="' . htmlspecialchars($this->onClickInsertRecord($row, $vv, $moveUid, $pid, $this->cur_sys_language)) . '" data-bs-dismiss="modal"><i class="t3-icon fa fa-long-arrow-left" name="mImgEnd' . $cc . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($this->l_insertNewRecordHere)) . '"></i></a>';
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
    }

    /**
     * Create on-click event value.
     *
     * @param mixed $row The record. If this is not an array with the record data the insert will be for the first position
     * in the column
     * @param string $vv Column position value.
     * @param int $moveUid Move uid
     * @param int $pid PID value.
     * @param int $sys_lang System language (not used currently)
     * @return string
     */
    public function onClickInsertRecord($row, $vv, $moveUid, $pid, $sys_lang = 0)
    {
549
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
550
        if (is_array($row)) {
551
552
            $location = $uriBuilder->buildUriFromRoute('tce_db', [
                'cmd[tt_content][' . $moveUid . '][' . $this->moveOrCopy . ']' => '-' . $row['uid'],
553
                'redirect' => $this->R_URI,
554
            ]);
555
        } else {
556
557
558
            $location = $uriBuilder->buildUriFromRoute('tce_db', [
                'cmd[tt_content][' . $moveUid . '][' . $this->moveOrCopy . ']' => $pid,
                'data[tt_content][' . $moveUid . '][colPos]' => $vv,
559
                'redirect' => $this->R_URI,
560
            ]);
561
562
        }
        // returns to prev. page
563
        return $this->clientContext . '.location.href=' . GeneralUtility::quoteJSvalue((string)$location) . ';return false;';
564
565
566
    }

    /**
567
     * Create record header (includes the record icon, record title etc.)
568
569
570
571
572
573
574
     *
     * @param array $row Record row.
     * @return string HTML
     */
    public function getRecordHeader($row)
    {
        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
575
576
        $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
        $line = '<span ' . $toolTip . ' title="' . BackendUtility::getRecordIconAltText($row, 'tt_content') . '">' . $iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL)->render() . '</span>';
577
578
579
580
581
582
583
584
585
586
587
588
589
        $line .= BackendUtility::getRecordTitle('tt_content', $row, true);
        return $this->wrapRecordTitle($line, $row);
    }

    /**
     * Wrapping the title of the record.
     *
     * @param string $str The title value.
     * @param array $row The record row.
     * @return string Wrapped title string.
     */
    public function wrapRecordTitle($str, $row)
    {
590
        return '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(['uid' => (int)$row['uid'], 'moveUid' => ''])) . '">' . $str . '</a>';
591
    }
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611

    /**
     * Returns the BackendUser
     *
     * @return BackendUserAuthentication
     */
    protected function getBackendUser()
    {
        return $GLOBALS['BE_USER'];
    }

    /**
     * Returns the LanguageService
     *
     * @return LanguageService
     */
    protected function getLanguageService()
    {
        return $GLOBALS['LANG'];
    }
612
}