[BUGFIX] NewContentElementWizardController to NewContentElementController
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / PagePositionMap.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tree\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\Routing\UriBuilder;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
20 use TYPO3\CMS\Core\Database\ConnectionPool;
21 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
22 use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
23 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
24 use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
25 use TYPO3\CMS\Core\Imaging\Icon;
26 use TYPO3\CMS\Core\Imaging\IconFactory;
27 use TYPO3\CMS\Core\Localization\LanguageService;
28 use TYPO3\CMS\Core\Utility\GeneralUtility;
29
30 /**
31 * Position map class - generating a page tree / content element list which links for inserting (copy/move) of records.
32 * Used for pages / tt_content element wizards of various kinds.
33 */
34 class PagePositionMap
35 {
36 // EXTERNAL, static:
37 /**
38 * @var string
39 */
40 public $moveOrCopy = 'move';
41
42 /**
43 * @var int
44 */
45 public $dontPrintPageInsertIcons = 0;
46
47 // How deep the position page tree will go.
48 /**
49 * @var int
50 */
51 public $depth = 2;
52
53 // Can be set to the sys_language uid to select content elements for.
54 /**
55 * @var string
56 */
57 public $cur_sys_language;
58
59 // INTERNAL, dynamic:
60 // Request uri
61 /**
62 * @var string
63 */
64 public $R_URI = '';
65
66 // Element id.
67 /**
68 * @var string
69 */
70 public $elUid = '';
71
72 // tt_content element uid to move.
73 /**
74 * @var string
75 */
76 public $moveUid = '';
77
78 // Caching arrays:
79 /**
80 * @var array
81 */
82 public $getModConfigCache = [];
83
84 /**
85 * @var array
86 */
87 public $checkNewPageCache = [];
88
89 // Label keys:
90 /**
91 * @var string
92 */
93 public $l_insertNewPageHere = 'insertNewPageHere';
94
95 /**
96 * @var string
97 */
98 public $l_insertNewRecordHere = 'insertNewRecordHere';
99
100 /**
101 * @var string
102 */
103 public $modConfigStr = 'mod.web_list.newPageWiz';
104
105 /**
106 * Page tree implementation class name
107 *
108 * @var string
109 */
110 protected $pageTreeClassName = ElementBrowserPageTreeView::class;
111
112 /**
113 * @var IconFactory
114 */
115 protected $iconFactory;
116
117 /**
118 * @var string
119 */
120 protected $clientContext;
121
122 /**
123 * Constructor allowing to set pageTreeImplementation
124 *
125 * @param string $pageTreeClassName
126 * @param string $clientContext JavaScript context of view client (either 'window' or 'list_frame')
127 */
128 public function __construct(string $pageTreeClassName = null, string $clientContext = 'window')
129 {
130 if ($pageTreeClassName !== null) {
131 $this->pageTreeClassName = $pageTreeClassName;
132 }
133 $this->clientContext = $clientContext;
134 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
135 }
136
137 /*************************************
138 *
139 * Page position map:
140 *
141 **************************************/
142 /**
143 * Creates a "position tree" based on the page tree.
144 *
145 * @param int $id Current page id
146 * @param array $pageinfo Current page record.
147 * @param string $perms_clause Page selection permission clause.
148 * @param string $R_URI Current REQUEST_URI
149 * @return string HTML code for the tree.
150 */
151 public function positionTree($id, $pageinfo, $perms_clause, $R_URI)
152 {
153 // Make page tree object:
154 /** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView $pageTree */
155 $pageTree = GeneralUtility::makeInstance($this->pageTreeClassName);
156 $pageTree->init(' AND ' . $perms_clause);
157 $pageTree->addField('pid');
158 // Initialize variables:
159 $this->R_URI = $R_URI;
160 $this->elUid = $id;
161 // Create page tree, in $this->depth levels.
162 $pageTree->getTree($pageinfo['pid'], $this->depth);
163 // Initialize variables:
164 $saveLatestUid = [];
165 $latestInvDepth = $this->depth;
166 // Traverse the tree:
167 $lines = [];
168 foreach ($pageTree->tree as $cc => $dat) {
169 if ($latestInvDepth > $dat['invertedDepth']) {
170 $margin = 'style="margin-left: ' . ($dat['invertedDepth'] * 16 + 9) . 'px;"';
171 $lines[] = '<ul class="list-tree" ' . $margin . '>';
172 }
173 // Make link + parameters.
174 $latestInvDepth = $dat['invertedDepth'];
175 $saveLatestUid[$latestInvDepth] = $dat;
176 if (isset($pageTree->tree[$cc - 1])) {
177 $prev_dat = $pageTree->tree[$cc - 1];
178 // If current page, subpage?
179 if ($prev_dat['row']['uid'] == $id) {
180 // 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...
181 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth'])) {
182 end($lines);
183 $margin = 'style="margin-left: ' . (($dat['invertedDepth'] - 1) * 16 + 9) . 'px;"';
184 $lines[] = '<ul class="list-tree" ' . $margin . '><li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>';
185 }
186 }
187 // If going down
188 if ($prev_dat['invertedDepth'] > $pageTree->tree[$cc]['invertedDepth']) {
189 $prevPid = $pageTree->tree[$cc]['row']['pid'];
190 } elseif ($prev_dat['invertedDepth'] < $pageTree->tree[$cc]['invertedDepth']) {
191 // If going up
192 // First of all the previous level should have an icon:
193 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($prev_dat['row']['pid'])) {
194 $prevPid = -$prev_dat['row']['uid'];
195 end($lines);
196 $lines[] = '<li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $prev_dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li>';
197 }
198 // Then set the current prevPid
199 $prevPid = -$prev_dat['row']['pid'];
200 if ($prevPid !== $dat['row']['pid']) {
201 $lines[] = '</ul>';
202 }
203 } else {
204 // In on the same level
205 $prevPid = -$prev_dat['row']['uid'];
206 }
207 } else {
208 // First in the tree
209 $prevPid = $dat['row']['pid'];
210 }
211 // print arrow on the same level
212 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) {
213 $lines[] = '<span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>';
214 }
215 // The line with the icon and title:
216 $toolTip = BackendUtility::getRecordToolTip($dat['row'], 'pages');
217 $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord('pages', $dat['row'], Icon::SIZE_SMALL)->render() . '</span>';
218
219 $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>';
220 }
221 // If the current page was the last in the tree:
222 $prev_dat = end($pageTree->tree);
223 if ($prev_dat['row']['uid'] == $id) {
224 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id)) {
225 $lines[] = '<ul class="list-tree" style="margin-left: 25px"><li><span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id)) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span></li></ul>';
226 }
227 }
228 for ($a = $latestInvDepth; $a <= $this->depth; $a++) {
229 $dat = $saveLatestUid[$a];
230 $prevPid = -$dat['row']['uid'];
231 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) {
232 if ($latestInvDepth < $dat['invertedDepth']) {
233 $lines[] = '</ul>';
234 }
235 $lines[] = '<span class="text-nowrap"><a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'])) . '"><i class="t3-icon fa fa-long-arrow-left" title="' . $this->insertlabel() . '"></i></a></span>';
236 }
237 }
238
239 $code = '<ul class="list-tree">';
240
241 foreach ($lines as $line) {
242 if ((substr($line, 0, 3) === '<ul') || (substr($line, 0, 4) === '</ul')) {
243 $code .= $line;
244 } else {
245 $code .= '<li>' . $line . '</li>';
246 }
247 }
248
249 $code .= '</ul>';
250 return $code;
251 }
252
253 /**
254 * Wrap $t_code in bold IF the $dat uid matches $id
255 *
256 * @param string $t_code Title string
257 * @param array $dat Information array with record array inside.
258 * @param int $id The current id.
259 * @return string The title string.
260 */
261 public function boldTitle($t_code, $dat, $id)
262 {
263 if ($dat['row']['uid'] == $id) {
264 $t_code = '<strong>' . $t_code . '</strong>';
265 }
266 return $t_code;
267 }
268
269 /**
270 * Creates the onclick event for the insert-icons.
271 *
272 * TSconfig mod.newPageWizard.override may contain an alternative module / route which can be
273 * used instead of the normal create new page wizard.
274 *
275 * @param int $pid The pid.
276 * @param int $newPagePID New page id.
277 * @return string Onclick attribute content
278 */
279 public function onClickEvent($pid, $newPagePID)
280 {
281 $TSconfig = BackendUtility::getModTSconfig($newPagePID, 'mod.newPageWizard');
282 $TSconfig = $TSconfig['properties'];
283 if (isset($TSconfig['override']) && !empty($TSconfig['override'])) {
284 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
285 $url = $uriBuilder->buildUriFromRoute(
286 $TSconfig['override'],
287 [
288 'positionPid' => $pid,
289 'newPageId' => $newPagePID,
290 'cmd' => 'crPage',
291 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
292 ]
293 );
294 return $this->clientContext . '.location.href=' . GeneralUtility::quoteJSvalue((string)$url) . ';';
295 }
296 $params = '&edit[pages][' . $pid . ']=new&returnNewPageId=1';
297 return BackendUtility::editOnClick($params, '', $this->R_URI);
298 }
299
300 /**
301 * Get label, htmlspecialchars()'ed
302 *
303 * @return string The localized label for "insert new page here
304 */
305 public function insertlabel()
306 {
307 return htmlspecialchars($this->getLanguageService()->getLL($this->l_insertNewPageHere));
308 }
309
310 /**
311 * Wrapping page title.
312 *
313 * @param string $str Page title.
314 * @param array $rec Page record (?)
315 * @return string Wrapped title.
316 */
317 public function linkPageTitle($str, $rec)
318 {
319 return $str;
320 }
321
322 /**
323 * Checks if the user has permission to created pages inside of the $pid page.
324 * Uses caching so only one regular lookup is made - hence you can call the function multiple times without worrying about performance.
325 *
326 * @param int $pid Page id for which to test.
327 * @return bool
328 */
329 public function checkNewPageInPid($pid)
330 {
331 if (!isset($this->checkNewPageCache[$pid])) {
332 $pidInfo = BackendUtility::getRecord('pages', $pid);
333 $this->checkNewPageCache[$pid] = $this->getBackendUser()->isAdmin() || $this->getBackendUser()->doesUserHaveAccess($pidInfo, 8);
334 }
335 return $this->checkNewPageCache[$pid];
336 }
337
338 /**
339 * Returns module configuration for a pid.
340 *
341 * @param int $pid Page id for which to get the module configuration.
342 * @return array The properties of the module configuration for the page id.
343 * @see onClickEvent()
344 */
345 public function getModConfig($pid)
346 {
347 if (!isset($this->getModConfigCache[$pid])) {
348 // Acquiring TSconfig for this PID:
349 $this->getModConfigCache[$pid] = BackendUtility::getModTSconfig($pid, $this->modConfigStr);
350 }
351 return $this->getModConfigCache[$pid]['properties'];
352 }
353
354 /*************************************
355 *
356 * Content element positioning:
357 *
358 **************************************/
359 /**
360 * Creates HTML for inserting/moving content elements.
361 *
362 * @param int $pid page id onto which to insert content element.
363 * @param int $moveUid Move-uid (tt_content element uid?)
364 * @param string $colPosList List of columns to show
365 * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out.
366 * @param string $R_URI Request URI
367 * @return string HTML
368 */
369 public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
370 {
371 $this->R_URI = $R_URI;
372 $this->moveUid = $moveUid;
373 $colPosArray = GeneralUtility::trimExplode(',', $colPosList, true);
374 $lines = [];
375 foreach ($colPosArray as $kk => $vv) {
376 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
377 $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
378 if ($showHidden) {
379 $queryBuilder->getRestrictions()
380 ->removeByType(HiddenRestriction::class)
381 ->removeByType(StartTimeRestriction::class)
382 ->removeByType(EndTimeRestriction::class);
383 }
384 $queryBuilder
385 ->select('*')
386 ->from('tt_content')
387 ->where(
388 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)),
389 $queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter($vv, \PDO::PARAM_INT))
390 )
391 ->orderBy('sorting');
392
393 if ((string)$this->cur_sys_language !== '') {
394 $queryBuilder->andWhere(
395 $queryBuilder->expr()->eq(
396 'sys_language_uid',
397 $queryBuilder->createNamedParameter($this->cur_sys_language, \PDO::PARAM_INT)
398 )
399 );
400 }
401
402 $res = $queryBuilder->execute();
403 $lines[$vv] = [];
404 $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
405
406 while ($row = $res->fetch()) {
407 BackendUtility::workspaceOL('tt_content', $row);
408 if (is_array($row)) {
409 $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
410 $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
411 }
412 }
413 }
414 return $this->printRecordMap($lines, $colPosArray, $pid);
415 }
416
417 /**
418 * Creates the table with the content columns
419 *
420 * @param array $lines Array with arrays of lines for each column
421 * @param array $colPosArray Column position array
422 * @param int $pid The id of the page
423 * @return string HTML
424 */
425 public function printRecordMap($lines, $colPosArray, $pid = 0)
426 {
427 $count = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($colPosArray), 1);
428 $backendLayout = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getSelectedBackendLayout', $pid, $this);
429 if (isset($backendLayout['__config']['backend_layout.'])) {
430 $this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
431 $table = '<div class="table-fit"><table class="table table-condensed table-bordered table-vertical-top">';
432 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
433 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
434 $table .= '<colgroup>';
435 for ($i = 0; $i < $colCount; $i++) {
436 $table .= '<col style="width:' . 100 / $colCount . '%"></col>';
437 }
438 $table .= '</colgroup>';
439 $table .= '<tbody>';
440 $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $pid, $this);
441 // Cycle through rows
442 for ($row = 1; $row <= $rowCount; $row++) {
443 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
444 if (!isset($rowConfig)) {
445 continue;
446 }
447 $table .= '<tr>';
448 for ($col = 1; $col <= $colCount; $col++) {
449 $columnConfig = $rowConfig['columns.'][$col . '.'];
450 if (!isset($columnConfig)) {
451 continue;
452 }
453 // Which tt_content colPos should be displayed inside this cell
454 $columnKey = (int)$columnConfig['colPos'];
455 $head = '';
456 foreach ($tcaItems as $item) {
457 if ($item[1] == $columnKey) {
458 $head = htmlspecialchars($this->getLanguageService()->sL($item[0]));
459 }
460 }
461 // Render the grid cell
462 $table .= '<td'
463 . (isset($columnConfig['colspan']) ? ' colspan="' . $columnConfig['colspan'] . '"' : '')
464 . (isset($columnConfig['rowspan']) ? ' rowspan="' . $columnConfig['rowspan'] . '"' : '')
465 . ' class="col-nowrap col-min'
466 . (!isset($columnConfig['colPos']) ? ' warning' : '')
467 . (isset($columnConfig['colPos']) && !$head ? ' danger' : '') . '">';
468 // Render header
469 $table .= '<p>';
470 if (isset($columnConfig['colPos']) && $head) {
471 $table .= '<strong>' . $this->wrapColumnHeader($head, '', '') . '</strong>';
472 } elseif ($columnConfig['colPos']) {
473 $table .= '<em>' . $this->wrapColumnHeader($this->getLanguageService()->getLL('noAccess'), '', '') . '</em>';
474 } else {
475 $table .= '<em>' . $this->wrapColumnHeader(($this->getLanguageService()->sL($columnConfig['name']) ?: '') . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '') . '</em>';
476 }
477 $table .= '</p>';
478 // Render lines
479 if (isset($columnConfig['colPos']) && $head && !empty($lines[$columnKey])) {
480 $table .= '<ul class="list-unstyled">';
481 foreach ($lines[$columnKey] as $line) {
482 $table .= '<li>' . $line . '</li>';
483 }
484 $table .= '</ul>';
485 }
486 $table .= '</td>';
487 }
488 $table .= '</tr>';
489 }
490 $table .= '</tbody>';
491 $table .= '</table></div>';
492 } else {
493 // Traverse the columns here:
494 $row = '';
495 foreach ($colPosArray as $kk => $vv) {
496 $row .= '<td class="col-nowrap col-min" width="' . round(100 / $count) . '%">';
497 $row .= '<p><strong>' . $this->wrapColumnHeader(htmlspecialchars($this->getLanguageService()->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $vv))), $vv) . '</strong></p>';
498 if (!empty($lines[$vv])) {
499 $row .= '<ul class="list-unstyled">';
500 foreach ($lines[$vv] as $line) {
501 $row .= '<li>' . $line . '</li>';
502 }
503 $row .= '</ul>';
504 }
505 $row .= '</td>';
506 }
507 $table = '
508
509 <!--
510 Map of records in columns:
511 -->
512 <div class="table-fit">
513 <table class="table table-condensed table-bordered table-vertical-top">
514 <tr>' . $row . '</tr>
515 </table>
516 </div>
517
518 ';
519 }
520 return $table;
521 }
522
523 /**
524 * Wrapping the column header
525 *
526 * @param string $str Header value
527 * @param string $vv Column info.
528 * @return string
529 * @see printRecordMap()
530 */
531 public function wrapColumnHeader($str, $vv)
532 {
533 return $str;
534 }
535
536 /**
537 * Creates a linked position icon.
538 *
539 * @param mixed $row Element row. If this is an array the link will cause an insert after this content element, otherwise
540 * the link will insert at the first position in the column
541 * @param string $vv Column position value.
542 * @param int $kk Column key.
543 * @param int $moveUid Move uid
544 * @param int $pid PID value.
545 * @return string
546 */
547 public function insertPositionIcon($row, $vv, $kk, $moveUid, $pid)
548 {
549 if (is_array($row) && !empty($row['uid'])) {
550 // Use record uid for the hash when inserting after this content element
551 $uid = $row['uid'];
552 } else {
553 // No uid means insert at first position in the column
554 $uid = '';
555 }
556 $cc = hexdec(substr(md5($uid . '-' . $vv . '-' . $kk), 0, 4));
557 return '<a href="#" onclick="' . htmlspecialchars($this->onClickInsertRecord($row, $vv, $moveUid, $pid, $this->cur_sys_language)) . '" data-dismiss="modal">' . '<i class="t3-icon fa fa-long-arrow-left" name="mImgEnd' . $cc . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($this->l_insertNewRecordHere)) . '"></i></a>';
558 }
559
560 /**
561 * Create on-click event value.
562 *
563 * @param mixed $row The record. If this is not an array with the record data the insert will be for the first position
564 * in the column
565 * @param string $vv Column position value.
566 * @param int $moveUid Move uid
567 * @param int $pid PID value.
568 * @param int $sys_lang System language (not used currently)
569 * @return string
570 */
571 public function onClickInsertRecord($row, $vv, $moveUid, $pid, $sys_lang = 0)
572 {
573 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
574 if (is_array($row)) {
575 $location = $uriBuilder->buildUriFromRoute('tce_db', [
576 'cmd[tt_content][' . $moveUid . '][' . $this->moveOrCopy . ']' => '-' . $row['uid'],
577 'redirect' => rawurlencode($this->R_URI)
578 ]);
579 } else {
580 $location = $uriBuilder->buildUriFromRoute('tce_db', [
581 'cmd[tt_content][' . $moveUid . '][' . $this->moveOrCopy . ']' => $pid,
582 'data[tt_content][' . $moveUid . '][colPos]' => $vv,
583 'redirect' => rawurlencode($this->R_URI)
584 ]);
585 }
586 // returns to prev. page
587 return $this->clientContext . '.location.href=' . GeneralUtility::quoteJSvalue((string)$location) . ';return false;';
588 }
589
590 /**
591 * Wrapping the record header (from getRecordHeader())
592 *
593 * @param string $str HTML content
594 * @param string $row Record array.
595 * @return string HTML content
596 */
597 public function wrapRecordHeader($str, $row)
598 {
599 return $str;
600 }
601
602 /**
603 * Create record header (includes the record icon, record title etc.)
604 *
605 * @param array $row Record row.
606 * @return string HTML
607 */
608 public function getRecordHeader($row)
609 {
610 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
611 $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
612 $line = '<span ' . $toolTip . ' title="' . BackendUtility::getRecordIconAltText($row, 'tt_content') . '">' . $iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL)->render() . '</span>';
613 $line .= BackendUtility::getRecordTitle('tt_content', $row, true);
614 return $this->wrapRecordTitle($line, $row);
615 }
616
617 /**
618 * Wrapping the title of the record.
619 *
620 * @param string $str The title value.
621 * @param array $row The record row.
622 * @return string Wrapped title string.
623 */
624 public function wrapRecordTitle($str, $row)
625 {
626 return '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(['uid' => (int)$row['uid'], 'moveUid' => ''])) . '">' . $str . '</a>';
627 }
628
629 /**
630 * Returns the BackendUser
631 *
632 * @return BackendUserAuthentication
633 */
634 protected function getBackendUser()
635 {
636 return $GLOBALS['BE_USER'];
637 }
638
639 /**
640 * Returns the LanguageService
641 *
642 * @return LanguageService
643 */
644 protected function getLanguageService()
645 {
646 return $GLOBALS['LANG'];
647 }
648 }