e01c1ab94531f4a00eef1c4c80e4b2e7554ebee0
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / PageLayoutView.php
1 <?php
2 namespace TYPO3\CMS\Backend\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\Controller\PageLayoutController;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
20 use TYPO3\CMS\Core\Database\DatabaseConnection;
21 use TYPO3\CMS\Core\Imaging\Icon;
22 use TYPO3\CMS\Core\Imaging\IconFactory;
23 use TYPO3\CMS\Core\Messaging\FlashMessage;
24 use TYPO3\CMS\Core\Messaging\FlashMessageService;
25 use TYPO3\CMS\Core\Page\PageRenderer;
26 use TYPO3\CMS\Core\Type\Bitmask\Permission;
27 use TYPO3\CMS\Core\Utility\GeneralUtility;
28 use TYPO3\CMS\Core\Utility\StringUtility;
29 use TYPO3\CMS\Core\Versioning\VersionState;
30 use TYPO3\CMS\Extbase\Service\FlexFormService;
31 use TYPO3\CMS\Fluid\View\StandaloneView;
32
33 /**
34 * Child class for the Web > Page module
35 */
36 class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList
37 {
38 /**
39 * If TRUE, users/groups are shown in the page info box.
40 *
41 * @var int
42 */
43 public $pI_showUser = 0;
44
45 /**
46 * The number of successive records to edit when showing content elements.
47 *
48 * @var int
49 */
50 public $nextThree = 3;
51
52 /**
53 * If TRUE, disables the edit-column icon for tt_content elements
54 *
55 * @var int
56 */
57 public $pages_noEditColumns = 0;
58
59 /**
60 * If TRUE, new-wizards are linked to rather than the regular new-element list.
61 *
62 * @var int
63 */
64 public $option_newWizard = 1;
65
66 /**
67 * If set to "1", will link a big button to content element wizard.
68 *
69 * @var int
70 */
71 public $ext_function = 0;
72
73 /**
74 * If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
75 *
76 * @var int
77 */
78 public $doEdit = 1;
79
80 /**
81 * Age prefixes for displaying times. May be set externally to localized values.
82 *
83 * @var string
84 */
85 public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
86
87 /**
88 * Array of tables to be listed by the Web > Page module in addition to the default tables.
89 *
90 * @var array
91 */
92 public $externalTables = array();
93
94 /**
95 * "Pseudo" Description -table name
96 *
97 * @var string
98 */
99 public $descrTable;
100
101 /**
102 * If set TRUE, the language mode of tt_content elements will be rendered with hard binding between
103 * default language content elements and their translations!
104 *
105 * @var bool
106 */
107 public $defLangBinding = false;
108
109 /**
110 * External, static: Configuration of tt_content element display:
111 *
112 * @var array
113 */
114 public $tt_contentConfig = array(
115 // Boolean: Display info-marks or not
116 'showInfo' => 1,
117 // Boolean: Display up/down arrows and edit icons for tt_content records
118 'showCommands' => 1,
119 'languageCols' => 0,
120 'languageMode' => 0,
121 'languageColsPointer' => 0,
122 'showHidden' => 1,
123 // Displays hidden records as well
124 'sys_language_uid' => 0,
125 // Which language
126 'cols' => '1,0,2,3',
127 'activeCols' => '1,0,2,3'
128 // Which columns can be accessed by current BE user
129 );
130
131 /**
132 * Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
133 *
134 * @var array
135 */
136 public $activeTables = array();
137
138 /**
139 * @var array
140 */
141 public $tt_contentData = array(
142 'nextThree' => array(),
143 'prev' => array(),
144 'next' => array()
145 );
146
147 /**
148 * Used to store labels for CTypes for tt_content elements
149 *
150 * @var array
151 */
152 public $CType_labels = array();
153
154 /**
155 * Used to store labels for the various fields in tt_content elements
156 *
157 * @var array
158 */
159 public $itemLabels = array();
160
161 /**
162 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
163 */
164 protected $clipboard;
165
166 /**
167 * @var array
168 */
169 protected $plusPages = array();
170
171 /**
172 * User permissions
173 *
174 * @var int
175 */
176 public $ext_CALC_PERMS;
177
178 /**
179 * Current ids page record
180 *
181 * @var array
182 */
183 protected $pageinfo;
184
185 /**
186 * Caches the available languages in a colPos
187 *
188 * @var array
189 */
190 protected $languagesInColumnCache = array();
191
192 /**
193 * Caches the amount of content elements as a matrix
194 *
195 * @var array
196 * @internal
197 */
198 protected $contentElementCache = array();
199
200 /**
201 * @var IconFactory
202 */
203 protected $iconFactory;
204
205 /**
206 * Stores whether a certain language has translations in it
207 *
208 * @var array
209 */
210 protected $languageHasTranslationsCache = array();
211
212 /**
213 * Construct to initialize class variables.
214 */
215 public function __construct()
216 {
217 parent::__construct();
218 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
219 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
220 $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
221 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
222 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Localization');
223 }
224
225 /*****************************************
226 *
227 * Renderings
228 *
229 *****************************************/
230 /**
231 * Adds the code of a single table
232 *
233 * @param string $table Table name
234 * @param int $id Current page id
235 * @param string $fields
236 * @return string HTML for listing.
237 */
238 public function getTable($table, $id, $fields = '')
239 {
240 if (isset($this->externalTables[$table])) {
241 return $this->getExternalTables($id, $table);
242 } else {
243 // Branch out based on table name:
244 switch ($table) {
245 case 'pages':
246 return $this->getTable_pages($id);
247 break;
248 case 'tt_content':
249 return $this->getTable_tt_content($id);
250 break;
251 default:
252 return '';
253 }
254 }
255 }
256
257 /**
258 * Renders an external table from page id
259 *
260 * @param int $id Page id
261 * @param string $table Name of the table
262 * @return string HTML for the listing
263 */
264 public function getExternalTables($id, $table)
265 {
266 $type = $this->getPageLayoutController()->MOD_SETTINGS[$table];
267 if (!isset($type)) {
268 $type = 0;
269 }
270 // eg. "name;title;email;company,image"
271 $fList = $this->externalTables[$table][$type]['fList'];
272 // The columns are separeted by comma ','.
273 // Values separated by semicolon ';' are shown in the same column.
274 $icon = $this->externalTables[$table][$type]['icon'];
275 $addWhere = $this->externalTables[$table][$type]['addWhere'];
276 // Create listing
277 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
278 return $out;
279 }
280
281 /**
282 * Renders records from the pages table from page id
283 * (Used to get information about the page tree content by "Web>Info"!)
284 *
285 * @param int $id Page id
286 * @return string HTML for the listing
287 */
288 public function getTable_pages($id)
289 {
290 // Initializing:
291 $out = '';
292 // Select clause for pages:
293 $delClause = BackendUtility::deleteClause('pages') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1);
294 // Select current page:
295 if (!$id) {
296 // The root has a pseudo record in pageinfo...
297 $row = $this->getPageLayoutController()->pageinfo;
298 } else {
299 $result = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'uid=' . (int)$id . $delClause);
300 $row = $this->getDatabase()->sql_fetch_assoc($result);
301 BackendUtility::workspaceOL('pages', $row);
302 }
303 // If there was found a page:
304 if (is_array($row)) {
305 // Select which fields to show:
306 $pKey = $this->getPageLayoutController()->MOD_SETTINGS['pages'];
307 switch ($pKey) {
308 case 1:
309 $this->fieldArray = array('title','uid') + array_keys($this->cleanTableNames());
310 break;
311 case 2:
312 $this->fieldArray = array(
313 'title',
314 'uid',
315 'lastUpdated',
316 'newUntil',
317 'no_cache',
318 'cache_timeout',
319 'php_tree_stop',
320 'TSconfig',
321 'is_siteroot',
322 'fe_login_mode'
323 );
324 break;
325 default:
326 $this->fieldArray = array(
327 'title',
328 'uid',
329 'alias',
330 'starttime',
331 'endtime',
332 'fe_group',
333 'target',
334 'url',
335 'shortcut',
336 'shortcut_mode'
337 );
338 }
339 // Getting select-depth:
340 $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS['pages_levels'];
341 // Overriding a few things:
342 $this->no_noWrap = 0;
343 // Items
344 $this->eCounter = $this->firstElementNumber;
345 // Creating elements:
346 list($flag, $code) = $this->fwd_rwd_nav();
347 $out .= $code;
348 $editUids = array();
349 if ($flag) {
350 // Getting children:
351 $theRows = array();
352 $theRows = $this->pages_getTree($theRows, $row['uid'], $delClause . BackendUtility::versioningPlaceholderClause('pages'), '', $depth);
353 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
354 $editUids[] = $row['uid'];
355 }
356 $out .= $this->pages_drawItem($row, $this->fieldArray);
357 // Traverse all pages selected:
358 foreach ($theRows as $sRow) {
359 if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
360 $editUids[] = $sRow['uid'];
361 }
362 $out .= $this->pages_drawItem($sRow, $this->fieldArray);
363 }
364 $this->eCounter++;
365 }
366 // Header line is drawn
367 $theData = array();
368 $editIdList = implode(',', $editUids);
369 // Traverse fields (as set above) in order to create header values:
370 foreach ($this->fieldArray as $field) {
371 if ($editIdList && isset($GLOBALS['TCA']['pages']['columns'][$field]) && $field != 'uid' && !$this->pages_noEditColumns) {
372 $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=' . $field;
373 $iTitle = sprintf(
374 $this->getLanguageService()->getLL('editThisColumn'),
375 rtrim(trim($this->getLanguageService()->sL(BackendUtility::getItemLabel('pages', $field))), ':')
376 );
377 $eI = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
378 . '" title="' . htmlspecialchars($iTitle) . '">'
379 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
380 } else {
381 $eI = '';
382 }
383 switch ($field) {
384 case 'title':
385 $theData[$field] = '&nbsp;<strong>'
386 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
387 . '</strong>' . $eI;
388 break;
389 case 'uid':
390 $theData[$field] = '&nbsp;<strong>ID:</strong>';
391 break;
392 default:
393 if (substr($field, 0, 6) == 'table_') {
394 $f2 = substr($field, 6);
395 if ($GLOBALS['TCA'][$f2]) {
396 $theData[$field] = '&nbsp;' . '<span title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$f2]['ctrl']['title'], true) . '">' . $this->iconFactory->getIconForRecord($f2, array(), Icon::SIZE_SMALL)->render() . '</span>';
397 }
398 } else {
399 $theData[$field] = '&nbsp;&nbsp;<strong>'
400 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'], true)
401 . '</strong>' . $eI;
402 }
403 }
404 }
405 // CSH:
406 $out = BackendUtility::cshItem($this->descrTable, ('func_' . $pKey)) . '
407 <div class="table-fit">
408 <table class="table table-striped table-hover typo3-page-pages">' .
409 '<thead>' .
410 $this->addElement(1, '', $theData) .
411 '</thead>' .
412 '<tbody>' .
413 $out .
414 '</tbody>' .
415 '</table>
416 </div>';
417 }
418 return $out;
419 }
420
421 /**
422 * Renders Content Elements from the tt_content table from page id
423 *
424 * @param int $id Page id
425 * @return string HTML for the listing
426 */
427 public function getTable_tt_content($id)
428 {
429 $backendUser = $this->getBackendUser();
430 $this->pageinfo = BackendUtility::readPageAccess($this->id, '');
431 $this->initializeLanguages();
432 $this->initializeClipboard();
433 $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), true));
434 /** @var $pageRenderer PageRenderer */
435 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
436 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
437 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
438 $userCanEditPage = $this->ext_CALC_PERMS & Permission::PAGE_EDIT && !empty($this->id) && ($backendUser->isAdmin() || (int)$this->pageinfo['editlock'] === 0);
439 if ($this->tt_contentConfig['languageColsPointer'] > 0) {
440 $userCanEditPage = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay');
441 }
442 if ($userCanEditPage) {
443 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
444 PageActions.setPageId(' . (int)$this->id . ');
445 PageActions.setLanguageOverlayId(' . $this->tt_contentConfig['languageColsPointer'] . ');
446 PageActions.initializePageTitleRenaming();
447 }');
448 }
449 // Get labels for CTypes and tt_content element fields in general:
450 $this->CType_labels = array();
451 foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
452 $this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
453 }
454 $this->itemLabels = array();
455 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
456 $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
457 }
458 $languageColumn = array();
459 $out = '';
460
461 // Setting language list:
462 $langList = $this->tt_contentConfig['sys_language_uid'];
463 if ($this->tt_contentConfig['languageMode']) {
464 if ($this->tt_contentConfig['languageColsPointer']) {
465 $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
466 } else {
467 $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
468 }
469 $languageColumn = array();
470 }
471 $langListArr = GeneralUtility::intExplode(',', $langList);
472 $defLanguageCount = array();
473 $defLangBinding = array();
474 // For each languages... :
475 // If not languageMode, then we'll only be through this once.
476 foreach ($langListArr as $lP) {
477 $lP = (int)$lP;
478
479 if (!isset($this->contentElementCache[$lP])) {
480 $this->contentElementCache[$lP] = array();
481 }
482
483 if (count($langListArr) === 1 || $lP === 0) {
484 $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
485 } else {
486 $showLanguage = ' AND sys_language_uid=' . $lP;
487 }
488 $cList = explode(',', $this->tt_contentConfig['cols']);
489 $content = array();
490 $head = array();
491
492 // Select content records per column
493 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showLanguage);
494 // For each column, render the content into a variable:
495 foreach ($cList as $key) {
496 if (!isset($this->contentElementCache[$lP][$key])) {
497 $this->contentElementCache[$lP][$key] = array();
498 }
499
500 if (!$lP) {
501 $defLanguageCount[$key] = array();
502 }
503 // Start wrapping div
504 $content[$key] .= '<div data-colpos="' . $key . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
505 if (empty($contentRecordsPerColumn[$key])) {
506 $content[$key] .= ' t3-page-ce-empty';
507 }
508 $content[$key] .= '">';
509 // Add new content at the top most position
510 $link = '';
511 if ($this->getPageLayoutController()->pageIsNotLockedForEditors()
512 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
513 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
514 ) {
515 $link = '<a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP))
516 . '" title="' . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">'
517 . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render()
518 . ' '
519 . $this->getLanguageService()->getLL('content', true) . '</a>';
520 }
521 $content[$key] .= '
522 <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility::getUniqueId() . '">
523 <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">'
524 . $link
525 . '</div>
526 <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
527 </div>
528 ';
529 $editUidList = '';
530 $rowArr = $contentRecordsPerColumn[$key];
531 $this->generateTtContentDataArray($rowArr);
532
533 foreach ((array)$rowArr as $rKey => $row) {
534 $this->contentElementCache[$lP][$key][$row['uid']] = $row;
535 if ($this->tt_contentConfig['languageMode']) {
536 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
537 if (!$this->defLangBinding) {
538 $languageColumn[$key][$lP] .= $this->newLanguageButton(
539 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
540 $lP,
541 $key
542 );
543 }
544 }
545 if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
546 $singleElementHTML = '';
547 if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
548 $defLanguageCount[$key][] = (isset($row['_ORIG_uid']) ? $row['_ORIG_uid'] : $row['uid']);
549 }
550 $editUidList .= $row['uid'] . ',';
551 $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0;
552 if (!$this->tt_contentConfig['languageMode']) {
553 $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
554 }
555 $singleElementHTML .= $this->tt_content_drawHeader(
556 $row,
557 $this->tt_contentConfig['showInfo'] ? 15 : 5,
558 $disableMoveAndNewButtons,
559 !$this->tt_contentConfig['languageMode'],
560 $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
561 );
562 $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>'
563 . $this->tt_content_drawItem($row) . '</div>';
564 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>'
565 . $this->tt_content_drawFooter($row);
566 $isDisabled = $this->isDisabled('tt_content', $row);
567 $statusHidden = $isDisabled ? ' t3-page-ce-hidden t3js-hidden-record' : '';
568 $displayNone = !$this->tt_contentConfig['showHidden'] && $isDisabled ? ' style="display: none;"' : '';
569 $highlightHeader = false;
570 if ($this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid']) && (int)$row['l18n_parent'] === 0) {
571 $highlightHeader = true;
572 }
573 $singleElementHTML = '<div class="t3-page-ce ' . ($highlightHeader ? 't3-page-ce-danger' : '') . ' t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-'
574 . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '"' . $displayNone . '>' . $singleElementHTML . '</div>';
575
576 if ($this->tt_contentConfig['languageMode']) {
577 $singleElementHTML .= '<div class="t3-page-ce t3js-page-ce">';
578 }
579 $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id .
580 '-' . StringUtility::getUniqueId() . '">';
581 // Add icon "new content element below"
582 if (!$disableMoveAndNewButtons
583 && $this->getPageLayoutController()->pageIsNotLockedForEditors()
584 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
585 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
586 ) {
587 // New content element:
588 if ($this->option_newWizard) {
589 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $row['pid']
590 . '&sys_language_uid=' . $row['sys_language_uid'] . '&colPos=' . $row['colPos']
591 . '&uid_pid=' . -$row['uid'] .
592 '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
593 } else {
594 $params = '&edit[tt_content][' . -$row['uid'] . ']=new';
595 $onClick = BackendUtility::editOnClick($params);
596 }
597 $singleElementHTML .= '
598 <a href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
599 . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">'
600 . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render()
601 . ' '
602 . $this->getLanguageService()->getLL('content', true) . '</a>
603 ';
604 }
605 $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
606 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
607 $defLangBinding[$key][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML;
608 } else {
609 $content[$key] .= $singleElementHTML;
610 }
611 } else {
612 unset($rowArr[$rKey]);
613 }
614 }
615 $content[$key] .= '</div>';
616 // Add new-icon link, header:
617 $newP = $this->newContentElementOnClick($id, $key, $lP);
618 $colTitle = BackendUtility::getProcessedValue('tt_content', 'colPos', $key);
619 $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this);
620 foreach ($tcaItems as $item) {
621 if ($item[1] == $key) {
622 $colTitle = $this->getLanguageService()->sL($item[0]);
623 }
624 }
625
626 $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
627 $editParam = $this->doEdit && !empty($rowArr)
628 ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
629 : '';
630 $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, $newP, $pasteP);
631 }
632 // For each column, fit the rendered content into a table cell:
633 $out = '';
634 if ($this->tt_contentConfig['languageMode']) {
635 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
636 $sortedLanguageColumn = array();
637 foreach ($cList as $key) {
638 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
639 if (!$this->defLangBinding) {
640 $languageColumn[$key][$lP] .= $this->newLanguageButton(
641 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
642 $lP,
643 $key
644 );
645 }
646 // We sort $languageColumn again according to $cList as it may contain data already from above.
647 $sortedLanguageColumn[$key] = $languageColumn[$key];
648 }
649 $languageColumn = $sortedLanguageColumn;
650 } else {
651 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
652 // GRID VIEW:
653 $grid = '<div class="t3-grid-container"><table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table t3js-page-columns">';
654 // Add colgroups
655 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
656 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
657 $grid .= '<colgroup>';
658 for ($i = 0; $i < $colCount; $i++) {
659 $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
660 }
661 $grid .= '</colgroup>';
662 // Cycle through rows
663 for ($row = 1; $row <= $rowCount; $row++) {
664 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
665 if (!isset($rowConfig)) {
666 continue;
667 }
668 $grid .= '<tr>';
669 for ($col = 1; $col <= $colCount; $col++) {
670 $columnConfig = $rowConfig['columns.'][$col . '.'];
671 if (!isset($columnConfig)) {
672 continue;
673 }
674 // Which tt_content colPos should be displayed inside this cell
675 $columnKey = (int)$columnConfig['colPos'];
676 // Render the grid cell
677 $colSpan = (int)$columnConfig['colspan'];
678 $rowSpan = (int)$columnConfig['rowspan'];
679 $grid .= '<td valign="top"' .
680 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
681 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
682 ' data-colpos="' . (int)$columnConfig['colPos'] . '" data-language-uid="' . $lP . '" class="t3js-page-lang-column-' . $lP . ' t3js-page-column t3-grid-cell t3-page-column t3-page-column-' . $columnKey .
683 ((!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '') ? ' t3-grid-cell-unassigned' : '') .
684 ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) || !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos']) ? ' t3-grid-cell-restricted' : '') .
685 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') .
686 ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
687
688 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
689 // If not, a new header without any buttons will be generated.
690 if (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
691 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
692 ) {
693 $grid .= $head[$columnKey] . $content[$columnKey];
694 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
695 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
696 ) {
697 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
698 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
699 && !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
700 ) {
701 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
702 ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
703 } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
704 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
705 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
706 } else {
707 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
708 }
709
710 $grid .= '</td>';
711 }
712 $grid .= '</tr>';
713 }
714 $out .= $grid . '</table></div>';
715 }
716 // CSH:
717 $out .= BackendUtility::cshItem($this->descrTable, 'columns_multi');
718 }
719 // If language mode, then make another presentation:
720 // Notice that THIS presentation will override the value of $out!
721 // But it needs the code above to execute since $languageColumn is filled with content we need!
722 if ($this->tt_contentConfig['languageMode']) {
723 // Get language selector:
724 $languageSelector = $this->languageSelector($id);
725 // Reset out - we will make new content here:
726 $out = '';
727 // Traverse languages found on the page and build up the table displaying them side by side:
728 $cCont = array();
729 $sCont = array();
730 foreach ($langListArr as $lP) {
731 // Header:
732 $lP = (int)$lP;
733 $cCont[$lP] = '
734 <td valign="top" class="t3-page-column" data-language-uid="' . $lP . '">
735 <h2>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</h2>
736 </td>';
737
738 // "View page" icon is added:
739 $viewLink = '';
740 if (!VersionState::cast($this->getPageLayoutController()->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
741 $onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id), '', '', ('&L=' . $lP));
742 $viewLink = '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true) . '">' . $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>';
743 }
744 // Language overlay page header:
745 if ($lP) {
746 list($lpRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
747 BackendUtility::workspaceOL('pages_language_overlay', $lpRecord);
748 $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
749 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
750 $this->iconFactory->getIconForRecord('pages_language_overlay', $lpRecord, Icon::SIZE_SMALL)->render(),
751 'pages_language_overlay',
752 $lpRecord['uid']
753 );
754 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
755 ? '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
756 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">'
757 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
758 : ''
759 );
760
761 $lPLabel =
762 '<div class="btn-group">'
763 . $viewLink
764 . $editLink
765 . '</div>'
766 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($lpRecord['title'], 20));
767 } else {
768 $params = '&edit[pages][' . $this->id . ']=edit';
769
770 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
771 $this->iconFactory->getIconForRecord('pages', $this->pageRecord, Icon::SIZE_SMALL)->render(),
772 'pages',
773 $this->id
774 );
775 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
776 ? '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
777 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">'
778 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
779 : ''
780 );
781
782 $lPLabel =
783 '<div class="btn-group">'
784 . $viewLink
785 . $editLink
786 . '</div>'
787 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20));
788 }
789 $sCont[$lP] = '
790 <td nowrap="nowrap" class="t3-page-column t3-page-lang-label">' . $lPLabel . '</td>';
791 }
792 // Add headers:
793 $out .= '<tr>' . implode($cCont) . '</tr>';
794 $out .= '<tr>' . implode($sCont) . '</tr>';
795 unset($cCont, $sCont);
796
797 // Traverse previously built content for the columns:
798 foreach ($languageColumn as $cKey => $cCont) {
799 $out .= '<tr>';
800 foreach ($cCont as $languageId => $columnContent) {
801 $out .= '<td valign="top" class="t3-grid-cell t3-page-column t3js-page-column t3js-page-lang-column t3js-page-lang-column-' . $languageId . '">' . $columnContent . '</td>';
802 }
803 $out .= '</tr>';
804 if ($this->defLangBinding) {
805 // "defLangBinding" mode
806 foreach ($defLanguageCount[$cKey] as $defUid) {
807 $cCont = array();
808 foreach ($langListArr as $lP) {
809 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
810 $this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP),
811 $lP,
812 $cKey
813 );
814 }
815 $out .= '
816 <tr>
817 <td valign="top" class="t3-grid-cell">' . implode(('</td>' . '
818 <td valign="top" class="t3-grid-cell">'), $cCont) . '</td>
819 </tr>';
820 }
821 }
822 }
823 // Finally, wrap it all in a table and add the language selector on top of it:
824 $out = $languageSelector . '
825 <div class="t3-grid-container">
826 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
827 ' . $out . '
828 </table>
829 </div>';
830 // CSH:
831 $out .= BackendUtility::cshItem($this->descrTable, 'language_list');
832 }
833
834 return $out;
835 }
836
837 /**********************************
838 *
839 * Generic listing of items
840 *
841 **********************************/
842 /**
843 * Creates a standard list of elements from a table.
844 *
845 * @param string $table Table name
846 * @param int $id Page id.
847 * @param string $fList Comma list of fields to display
848 * @param bool $icon If TRUE, icon is shown
849 * @param string $addWhere Additional WHERE-clauses.
850 * @return string HTML table
851 */
852 public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = '')
853 {
854 // Initialize
855 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
856 $this->setTotalItems($queryParts);
857 $dbCount = 0;
858 $result = false;
859 // Make query for records if there were any records found in the count operation
860 if ($this->totalItems) {
861 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
862 // Will return FALSE, if $result is invalid
863 $dbCount = $this->getDatabase()->sql_num_rows($result);
864 }
865 // If records were found, render the list
866 if (!$dbCount) {
867 return '';
868 }
869 // Set fields
870 $out = '';
871 $this->fieldArray = GeneralUtility::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', true);
872 $theData = array();
873 $theData = $this->headerFields($this->fieldArray, $table, $theData);
874 // Title row
875 $localizedTableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'], true);
876 $out .= '<tr class="t3-row-header">' . '<th class="col-icon"></th>'
877 . '<th colspan="' . (count($theData) - 2) . '"><span class="c-table">'
878 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td class="col-icon"></td>'
879 . '</tr>';
880 // Column's titles
881 if ($this->doEdit) {
882 $onClick = BackendUtility::editOnClick('&edit[' . $table . '][' . $this->id . ']=new');
883 $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" '
884 . 'title="' . $this->getLanguageService()->getLL('new', true) . '">'
885 . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . '</a>';
886 }
887 $out .= $this->addElement(1, '', $theData, ' class="c-headLine"', 15, '', 'th');
888 // Render Items
889 $this->eCounter = $this->firstElementNumber;
890 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
891 BackendUtility::workspaceOL($table, $row);
892 if (is_array($row)) {
893 list($flag, $code) = $this->fwd_rwd_nav();
894 $out .= $code;
895 if ($flag) {
896 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
897 $Nrow = array();
898 // Setting icons links
899 if ($icon) {
900 $Nrow['__cmds__'] = $this->getIcon($table, $row);
901 }
902 // Get values:
903 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
904 // Attach edit icon
905 if ($this->doEdit && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
906 $Nrow['__editIconLink__'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
907 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">'
908 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
909 } else {
910 $Nrow['__editIconLink__'] = $this->noEditIcon();
911 }
912 $out .= $this->addElement(1, '', $Nrow);
913 }
914 $this->eCounter++;
915 }
916 }
917 $this->getDatabase()->sql_free_result($result);
918 // Wrap it all in a table:
919 $out = '
920 <!--
921 Standard list of table "' . $table . '"
922 -->
923 <div class="table-fit"><table class="table table-striped">
924 ' . $out . '
925 </table></div>';
926 return $out;
927 }
928
929 /**
930 * Adds content to all data fields in $out array
931 *
932 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
933 * Eg. "field1,field2;field3".
934 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
935 *
936 * @param array $fieldArr Array of fields to display
937 * @param string $table Table name
938 * @param array $row Record array
939 * @param array $out Array to which the data is added
940 * @return array $out array returned after processing.
941 * @see makeOrdinaryList()
942 */
943 public function dataFields($fieldArr, $table, $row, $out = array())
944 {
945 // Check table validity
946 if (!isset($GLOBALS['TCA'][$table])) {
947 return $out;
948 }
949
950 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
951 // Traverse fields
952 foreach ($fieldArr as $fieldName) {
953 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
954 // Each field has its own cell (if configured in TCA)
955 // If the column is a thumbnail column:
956 if ($fieldName == $thumbsCol) {
957 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
958 } else {
959 // ... otherwise just render the output:
960 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(
961 BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
962 250
963 ))));
964 }
965 } else {
966 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
967 // the field name with ";" and check each value there as a TCA configured field)
968 $theFields = explode(';', $fieldName);
969 // Traverse fields, separated by ";" (displayed in a single cell).
970 foreach ($theFields as $fName2) {
971 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
972 $out[$fieldName] .= '<strong>' . $this->getLanguageService()->sL(
973 $GLOBALS['TCA'][$table]['columns'][$fName2]['label'],
974 true
975 ) . '</strong>' . '&nbsp;&nbsp;' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
976 BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
977 25
978 )) . '<br />';
979 }
980 }
981 }
982 // If no value, add a nbsp.
983 if (!$out[$fieldName]) {
984 $out[$fieldName] = '&nbsp;';
985 }
986 // Wrap in dimmed-span tags if record is "disabled"
987 if ($this->isDisabled($table, $row)) {
988 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
989 }
990 }
991 return $out;
992 }
993
994 /**
995 * Header fields made for the listing of records
996 *
997 * @param array $fieldArr Field names
998 * @param string $table The table name
999 * @param array $out Array to which the headers are added.
1000 * @return array $out returned after addition of the header fields.
1001 * @see makeOrdinaryList()
1002 */
1003 public function headerFields($fieldArr, $table, $out = array())
1004 {
1005 foreach ($fieldArr as $fieldName) {
1006 $ll = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], true);
1007 $out[$fieldName] = $ll ? $ll : '&nbsp;';
1008 }
1009 return $out;
1010 }
1011
1012 /**
1013 * Gets content records per column.
1014 * This is required for correct workspace overlays.
1015 *
1016 * @param string $table UNUSED (will always be queried from tt_content)
1017 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1018 * @param array $columns colPos values to be considered to be shown
1019 * @param string $additionalWhereClause Additional where clause for database select
1020 * @return array Associative array for each column (colPos)
1021 */
1022 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '')
1023 {
1024 $columns = array_map('intval', $columns);
1025 $contentRecordsPerColumn = array_fill_keys($columns, array());
1026
1027 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos IN (' . implode(',', $columns) . ')' . $additionalWhereClause);
1028 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1029 // Traverse any selected elements and render their display code:
1030 $rowArr = $this->getResult($result);
1031
1032 foreach ($rowArr as $record) {
1033 $columnValue = $record['colPos'];
1034 $contentRecordsPerColumn[$columnValue][] = $record;
1035 }
1036
1037 return $contentRecordsPerColumn;
1038 }
1039
1040 /**********************************
1041 *
1042 * Additional functions; Pages
1043 *
1044 **********************************/
1045 /**
1046 * Adds pages-rows to an array, selecting recursively in the page tree.
1047 *
1048 * @param array $theRows Array which will accumulate page rows
1049 * @param int $pid Pid to select from
1050 * @param string $qWhere Query-where clause
1051 * @param string $treeIcons Prefixed icon code.
1052 * @param int $depth Depth (decreasing)
1053 * @return array $theRows, but with added rows.
1054 */
1055 public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth)
1056 {
1057 $depth--;
1058 if ($depth >= 0) {
1059 $res = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'pid=' . (int)$pid . $qWhere, '', 'sorting');
1060 $c = 0;
1061 $rc = $this->getDatabase()->sql_num_rows($res);
1062 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1063 BackendUtility::workspaceOL('pages', $row);
1064 if (is_array($row)) {
1065 $c++;
1066 $row['treeIcons'] = $treeIcons . '<span class="treeline-icon treeline-icon-join' . ($rc === $c ? 'bottom' : '') . '"></span>';
1067 $theRows[] = $row;
1068 // Get the branch
1069 $spaceOutIcons = '<span class="treeline-icon treeline-icon-' . ($rc === $c ? 'clear' : 'line') . '"></span>';
1070 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ? 0 : $depth);
1071 }
1072 }
1073 } else {
1074 $count = $this->getDatabase()->exec_SELECTcountRows('uid', 'pages', 'pid=' . (int)$pid . $qWhere);
1075 if ($count) {
1076 $this->plusPages[$pid] = $count;
1077 }
1078 }
1079 return $theRows;
1080 }
1081
1082 /**
1083 * Adds a list item for the pages-rendering
1084 *
1085 * @param array $row Record array
1086 * @param array $fieldArr Field list
1087 * @return string HTML for the item
1088 */
1089 public function pages_drawItem($row, $fieldArr)
1090 {
1091 // Initialization
1092 $theIcon = $this->getIcon('pages', $row);
1093 // Preparing and getting the data-array
1094 $theData = array();
1095 foreach ($fieldArr as $field) {
1096 switch ($field) {
1097 case 'title':
1098 $red = $this->plusPages[$row['uid']] ? '<span class="text-danger"><strong>+</strong></span>' : '';
1099 $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
1100 if ($red) {
1101 $pTitle = '<a href="'
1102 . htmlspecialchars($this->script . ((strpos($this->script, '?') !== false) ? '&' : '?')
1103 . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1104 }
1105 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . '&nbsp;&nbsp;';
1106 break;
1107 case 'php_tree_stop':
1108 // Intended fall through
1109 case 'TSconfig':
1110 $theData[$field] = $row[$field] ? '&nbsp;<strong>x</strong>' : '&nbsp;';
1111 break;
1112 case 'uid':
1113 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
1114 $params = '&edit[pages][' . $row['uid'] . ']=edit';
1115 $eI = '<a href="#" onclick="'
1116 . htmlspecialchars(BackendUtility::editOnClick($params))
1117 . '" title="' . $this->getLanguageService()->getLL('editThisPage', true) . '">'
1118 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1119 } else {
1120 $eI = '';
1121 }
1122 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1123 break;
1124 case 'shortcut':
1125 case 'shortcut_mode':
1126 if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
1127 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1128 }
1129 break;
1130 default:
1131 if (substr($field, 0, 6) == 'table_') {
1132 $f2 = substr($field, 6);
1133 if ($GLOBALS['TCA'][$f2]) {
1134 $c = $this->numberOfRecords($f2, $row['uid']);
1135 $theData[$field] = '&nbsp;&nbsp;' . ($c ? $c : '');
1136 }
1137 } else {
1138 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1139 }
1140 }
1141 }
1142 $this->addElement_tdParams['title'] = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '';
1143 return $this->addElement(1, '', $theData);
1144 }
1145
1146 /**
1147 * Returns the HTML code for rendering a field in the pages table.
1148 * The row value is processed to a human readable form and the result is parsed through htmlspecialchars().
1149 *
1150 * @param string $field The name of the field of which the value should be rendered.
1151 * @param array $row The pages table row as an associative array.
1152 * @return string The rendered table field value.
1153 */
1154 protected function getPagesTableFieldValue($field, array $row)
1155 {
1156 return '&nbsp;&nbsp;' . htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
1157 }
1158
1159 /**********************************
1160 *
1161 * Additional functions; Content Elements
1162 *
1163 **********************************/
1164 /**
1165 * Draw header for a content element column:
1166 *
1167 * @param string $colName Column name
1168 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1169 * @param string $newParams New element params (Syntax: &edit[...] for FormEngine) OBSOLETE
1170 * @param array|NULL $pasteParams Paste element params (i.e. array(colPos => 1, sys_language_uid => 2))
1171 * @return string HTML table
1172 */
1173 public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = null)
1174 {
1175 $iconsArr = array();
1176 // Create command links:
1177 if ($this->tt_contentConfig['showCommands']) {
1178 // Edit whole of column:
1179 if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
1180 $iconsArr['edit'] = '<a href="#" onclick="'
1181 . htmlspecialchars(BackendUtility::editOnClick($editParams)) . '" title="'
1182 . $this->getLanguageService()->getLL('editColumn', true) . '">'
1183 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1184 }
1185 if ($pasteParams) {
1186 $elFromTable = $this->clipboard->elFromTable('tt_content');
1187 if (!empty($elFromTable) && $this->getPageLayoutController()->pageIsNotLockedForEditors()) {
1188 $iconsArr['paste'] = '<a href="'
1189 . htmlspecialchars($this->clipboard->pasteUrl('tt_content', $this->id, true, $pasteParams))
1190 . '" onclick="' . htmlspecialchars(('return '
1191 . $this->clipboard->confirmMsg('pages', $this->pageRecord, 'into', $elFromTable, $colName)))
1192 . '" title="' . $this->getLanguageService()->getLL('pasteIntoColumn', true) . '">'
1193 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
1194 }
1195 }
1196 }
1197 $icons = '';
1198 if (!empty($iconsArr)) {
1199 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1200 }
1201 // Create header row:
1202 $out = '<div class="t3-page-column-header">
1203 ' . $icons . '
1204 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1205 </div>';
1206 return $out;
1207 }
1208
1209 /**
1210 * Draw the footer for a single tt_content element
1211 *
1212 * @param array $row Record array
1213 * @return string HTML of the footer
1214 * @throws \UnexpectedValueException
1215 */
1216 protected function tt_content_drawFooter(array $row)
1217 {
1218 $content = '';
1219 // Get processed values:
1220 $info = array();
1221 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1222
1223 // Content element annotation
1224 if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn'])) {
1225 $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
1226 }
1227
1228 // Call drawFooter hooks
1229 $drawFooterHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'];
1230 if (is_array($drawFooterHooks)) {
1231 foreach ($drawFooterHooks as $hookClass) {
1232 $hookObject = GeneralUtility::getUserObj($hookClass);
1233 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
1234 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawFooterHookInterface', 1404378171);
1235 }
1236 $hookObject->preProcess($this, $info, $row);
1237 }
1238 }
1239
1240 // Display info from records fields:
1241 if (!empty($info)) {
1242 $content = '<div class="t3-page-ce-info">
1243 ' . implode('<br>', $info) . '
1244 </div>';
1245 }
1246 // Wrap it
1247 if (!empty($content)) {
1248 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1249 }
1250 return $content;
1251 }
1252
1253 /**
1254 * Draw the header for a single tt_content element
1255 *
1256 * @param array $row Record array
1257 * @param int $space Amount of pixel space above the header. UNUSED
1258 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1259 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1260 * @param bool $dragDropEnabled If set the move button must be hidden
1261 * @return string HTML table with the record header.
1262 */
1263 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false)
1264 {
1265 $out = '';
1266 // If show info is set...;
1267 if ($this->tt_contentConfig['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1268 // Render control panel for the element:
1269 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1270 // Edit content element:
1271 $params = '&edit[tt_content][' . $this->tt_contentData['nextThree'][$row['uid']] . ']=edit';
1272 $out .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
1273 $params,
1274 '',
1275 GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
1276 )) . '" title="' . htmlspecialchars($this->nextThree > 1
1277 ? sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree)
1278 : $this->getLanguageService()->getLL('edit'))
1279 . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1280 // Hide element:
1281 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1282 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1283 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1284 || $this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1285 ) {
1286 if ($row[$hiddenField]) {
1287 $value = 0;
1288 $label = 'unHide';
1289 } else {
1290 $value = 1;
1291 $label = 'hide';
1292 }
1293 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
1294 . '][' . $hiddenField . ']=' . $value;
1295 $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1296 . '" title="' . $this->getLanguageService()->getLL($label, true) . '">'
1297 . $this->iconFactory->getIcon('actions-edit-' . strtolower($label), Icon::SIZE_SMALL)->render() . '</a>';
1298 }
1299 // Delete
1300 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1301 $confirm = $this->getLanguageService()->getLL('deleteWarning')
1302 . BackendUtility::translationCount('tt_content', $row['uid'], (' '
1303 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')));
1304 $out .= '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params)) . '"'
1305 . ' data-severity="warning"'
1306 . ' data-title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_alt_doc.xlf:label.confirm.delete_record.title')) . '"'
1307 . ' data-content="' . htmlspecialchars($confirm) . '" '
1308 . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel')) . '"'
1309 . ' title="' . $this->getLanguageService()->getLL('deleteItem', true) . '">'
1310 . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
1311 if ($out && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
1312 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
1313 } else {
1314 $out = '';
1315 }
1316 if (!$disableMoveAndNewButtons) {
1317 $moveButtonContent = '';
1318 $displayMoveButtons = false;
1319 // Move element up:
1320 if ($this->tt_contentData['prev'][$row['uid']]) {
1321 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
1322 $moveButtonContent .= '<a class="btn btn-default" href="'
1323 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1324 . '" title="' . $this->getLanguageService()->getLL('moveUp', true) . '">'
1325 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
1326 if (!$dragDropEnabled) {
1327 $displayMoveButtons = true;
1328 }
1329 } else {
1330 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
1331 }
1332 // Move element down:
1333 if ($this->tt_contentData['next'][$row['uid']]) {
1334 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
1335 $moveButtonContent .= '<a class="btn btn-default" href="'
1336 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1337 . '" title="' . $this->getLanguageService()->getLL('moveDown', true) . '">'
1338 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
1339 if (!$dragDropEnabled) {
1340 $displayMoveButtons = true;
1341 }
1342 } else {
1343 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
1344 }
1345 if ($displayMoveButtons) {
1346 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
1347 }
1348 }
1349 }
1350 }
1351 $allowDragAndDrop = $this->isDragAndDropAllowed($row);
1352 $additionalIcons = array();
1353 if ($row['sys_language_uid'] > 0 && $this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid'])) {
1354 $disabledClickMenuItems = 'new,move';
1355 $allowDragAndDrop = false;
1356 }
1357 $additionalIcons[] = $this->getIcon('tt_content', $row, $disabledClickMenuItems) . ' ';
1358 $additionalIcons[] = $langMode ? $this->languageFlag($row['sys_language_uid'], false) : '';
1359 // Get record locking status:
1360 if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) {
1361 $additionalIcons[] = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg'])
1362 . ');return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">'
1363 . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
1364 }
1365 // Call stats information hook
1366 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1367 $_params = array('tt_content', $row['uid'], &$row);
1368 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1369 $additionalIcons[] = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1370 }
1371 }
1372 // Wrap the whole header
1373 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1374 return '<div class="t3-page-ce-header ' . ($allowDragAndDrop ? 't3-page-ce-header-draggable t3js-page-ce-draghandle' : '') . '">
1375 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
1376 <div class="t3-page-ce-header-icons-right">' . ($out ? '<div class="btn-toolbar">' . $out . '</div>' : '') . '</div>
1377 </div>
1378 <div class="t3-page-ce-body">';
1379 }
1380
1381 /**
1382 * Determine whether Drag & Drop should be allowed
1383 *
1384 * @param array $row
1385 * @return bool
1386 */
1387 protected function isDragAndDropAllowed(array $row)
1388 {
1389 if ($this->getBackendUser()->user['admin']
1390 || ((int)$row['editlock'] === 0 && (int)$this->pageinfo['editlock'] === 0)
1391 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
1392 ) {
1393 return true;
1394 }
1395 return false;
1396 }
1397
1398 /**
1399 * Draws the preview content for a content element
1400 *
1401 * @param array $row Content element
1402 * @return string HTML
1403 * @throws \UnexpectedValueException
1404 */
1405 public function tt_content_drawItem($row)
1406 {
1407 $out = '';
1408 $outHeader = '';
1409 // Make header:
1410
1411 if ($row['header']) {
1412 $infoArr = array();
1413 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1414 $hiddenHeaderNote = '';
1415 // If header layout is set to 'hidden', display an accordant note:
1416 if ($row['header_layout'] == 100) {
1417 $hiddenHeaderNote = ' <em>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.hidden', true) . ']</em>';
1418 }
1419 $outHeader = $row['date']
1420 ? htmlspecialchars($this->itemLabels['date'] . ' ' . BackendUtility::date($row['date'])) . '<br />'
1421 : '';
1422 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1423 . $hiddenHeaderNote . '</strong><br />';
1424 }
1425 // Make content:
1426 $infoArr = array();
1427 $drawItem = true;
1428 // Hook: Render an own preview of a record
1429 $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1430 if (is_array($drawItemHooks)) {
1431 foreach ($drawItemHooks as $hookClass) {
1432 $hookObject = GeneralUtility::getUserObj($hookClass);
1433 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
1434 throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface::class, 1218547409);
1435 }
1436 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1437 }
1438 }
1439
1440 // If the previous hook did not render something,
1441 // then check if a Fluid-based preview template was defined for this CType
1442 // and render it via Fluid. Possible option:
1443 // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html
1444 if ($drawItem) {
1445 $tsConfig = BackendUtility::getModTSconfig($row['pid'], 'mod.web_layout.tt_content.preview');
1446 if (!empty($tsConfig['properties'][$row['CType']])) {
1447 $fluidTemplateFile = $tsConfig['properties'][$row['CType']];
1448 $fluidTemplateFile = GeneralUtility::getFileAbsFileName($fluidTemplateFile);
1449 if ($fluidTemplateFile) {
1450 try {
1451 /** @var StandaloneView $view */
1452 $view = GeneralUtility::makeInstance(StandaloneView::class);
1453 $view->setTemplatePathAndFilename($fluidTemplateFile);
1454 $view->assignMultiple($row);
1455 if (!empty($row['pi_flexform'])) {
1456 /** @var FlexFormService $flexFormService */
1457 $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
1458 $view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
1459 }
1460 $out = $view->render();
1461 $drawItem = false;
1462 } catch (\Exception $e) {
1463 // Catch any exception to avoid breaking the view
1464 }
1465 }
1466 }
1467 }
1468
1469 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1470 if ($drawItem) {
1471 switch ($row['CType']) {
1472 case 'header':
1473 if ($row['subheader']) {
1474 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1475 }
1476 break;
1477 case 'bullets':
1478 case 'table':
1479 if ($row['bodytext']) {
1480 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1481 }
1482 break;
1483 case 'uploads':
1484 if ($row['media']) {
1485 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
1486 }
1487 break;
1488 case 'menu':
1489 $contentType = $this->CType_labels[$row['CType']];
1490 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1491 // Add Menu Type
1492 $menuTypeLabel = $this->getLanguageService()->sL(
1493 BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
1494 );
1495 $menuTypeLabel = $menuTypeLabel ?: 'invalid menu type';
1496 $out .= $this->linkEditContent($menuTypeLabel, $row);
1497 if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
1498 // Show pages if menu type is not "Sitemap"
1499 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
1500 }
1501 break;
1502 case 'shortcut':
1503 if (!empty($row['records'])) {
1504 $shortcutContent = array();
1505 $recordList = explode(',', $row['records']);
1506 foreach ($recordList as $recordIdentifier) {
1507 $split = BackendUtility::splitTable_Uid($recordIdentifier);
1508 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
1509 $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
1510 if (is_array($shortcutRecord)) {
1511 $icon = $this->iconFactory->getIconForRecord($tableName, $shortcutRecord, Icon::SIZE_SMALL)->render();
1512 $icon = BackendUtility::wrapClickMenuOnIcon(
1513 $icon,
1514 $tableName,
1515 $shortcutRecord['uid'],
1516 1,
1517 '',
1518 '+copy,info,edit,view'
1519 );
1520 $shortcutContent[] = $icon
1521 . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
1522 }
1523 }
1524 $out .= implode('<br />', $shortcutContent) . '<br />';
1525 }
1526 break;
1527 case 'list':
1528 $hookArr = array();
1529 $hookOut = '';
1530 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1531 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1532 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1533 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1534 }
1535 if (!empty($hookArr)) {
1536 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1537 foreach ($hookArr as $_funcRef) {
1538 $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1539 }
1540 }
1541 if ((string)$hookOut !== '') {
1542 $out .= $hookOut;
1543 } elseif (!empty($row['list_type'])) {
1544 $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1545 if (!empty($label)) {
1546 $out .= $this->linkEditContent('<strong>' . $this->getLanguageService()->sL($label, true) . '</strong>', $row) . '<br />';
1547 } else {
1548 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1549 $out .= GeneralUtility::makeInstance(
1550 FlashMessage::class,
1551 htmlspecialchars($message),
1552 '',
1553 FlashMessage::WARNING
1554 )->render();
1555 }
1556 } elseif (!empty($row['select_key'])) {
1557 $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), true)
1558 . ' ' . $row['select_key'] . '<br />';
1559 } else {
1560 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1561 }
1562 $out .= $this->getLanguageService()->sL(
1563 BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1564 true
1565 ) . '<br />';
1566 break;
1567 default:
1568 $contentType = $this->CType_labels[$row['CType']];
1569
1570 if (isset($contentType)) {
1571 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1572 if ($row['bodytext']) {
1573 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1574 }
1575 if ($row['image']) {
1576 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
1577 }
1578 } else {
1579 $message = sprintf(
1580 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1581 $row['CType']
1582 );
1583 $out .= GeneralUtility::makeInstance(
1584 FlashMessage::class,
1585 htmlspecialchars($message),
1586 '',
1587 FlashMessage::WARNING
1588 )->render();
1589 }
1590 }
1591 }
1592 // Wrap span-tags:
1593 $out = '
1594 <span class="exampleContent">' . $out . '</span>';
1595 // Add header:
1596 $out = $outHeader . $out;
1597 // Return values:
1598 if ($this->isDisabled('tt_content', $row)) {
1599 return '<span class="text-muted">' . $out . '</span>';
1600 } else {
1601 return $out;
1602 }
1603 }
1604
1605 /**
1606 * Generates a list of selected pages or categories for the CType menu
1607 *
1608 * @param array $row row from pages
1609 * @return string
1610 */
1611 protected function generateListForCTypeMenu(array $row)
1612 {
1613 $table = 'pages';
1614 $field = 'pages';
1615 // get categories instead of pages
1616 if (strpos($row['menu_type'], 'categorized_') !== false) {
1617 $table = 'sys_category';
1618 $field = 'selected_categories';
1619 }
1620 if (trim($row[$field]) === '') {
1621 return '';
1622 }
1623 $content = '';
1624 $uidList = explode(',', $row[$field]);
1625 foreach ($uidList as $uid) {
1626 $uid = (int)$uid;
1627 $record = BackendUtility::getRecord($table, $uid, 'title');
1628 $content .= '<br>' . $record['title'] . ' (' . $uid . ')';
1629 }
1630 return $content;
1631 }
1632
1633 /**
1634 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1635 * Selects across columns, but within in the same PID. Columns are expect to be the same
1636 * for translations and original but this may be a conceptual error (?)
1637 *
1638 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1639 * @param int $id Page pid
1640 * @param int $lP Sys language UID
1641 * @return array Modified $defLanguageCount
1642 */
1643 public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP)
1644 {
1645 if ($lP && !empty($defLanguageCount)) {
1646 // Select all translations here:
1647 $where = 'sys_language_uid=' . intval($lP) . ' AND l18n_parent IN ('
1648 . implode(',', $defLanguageCount) . ')'
1649 . BackendUtility::deleteClause('tt_content');
1650 $rowArr = $this->getDatabase()->exec_SELECTgetRows('*', 'tt_content', $where);
1651
1652 // Flip uids:
1653 $defLanguageCount = array_flip($defLanguageCount);
1654 // Traverse any selected elements and unset original UID if any:
1655 foreach ($rowArr as $row) {
1656 BackendUtility::workspaceOL('tt_content', $row);
1657 unset($defLanguageCount[$row['l18n_parent']]);
1658 }
1659 // Flip again:
1660 $defLanguageCount = array_keys($defLanguageCount);
1661 }
1662 return $defLanguageCount;
1663 }
1664
1665 /**
1666 * Creates button which is used to create copies of records..
1667 *
1668 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1669 * @param int $lP Sys language UID
1670 * @param int $colPos Column position
1671 * @return string "Copy languages" button, if available.
1672 */
1673 public function newLanguageButton($defLanguageCount, $lP, $colPos = 0)
1674 {
1675 $lP = (int)$lP;
1676 if (!$this->doEdit || !$lP) {
1677 return '';
1678 }
1679 $theNewButton = '';
1680
1681 if (!empty($defLanguageCount)) {
1682 $theNewButton =
1683 '<input'
1684 . ' class="btn btn-default t3js-localize"'
1685 . ' type="button"'
1686 . ' disabled'
1687 . ' value="' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate', true)) . '"'
1688 . ' data-has-elements="' . (int)!empty($this->contentElementCache[$lP][$colPos]) . '"'
1689 . ' data-table="tt_content"'
1690 . ' data-page-id="' . (int)GeneralUtility::_GP('id') . '"'
1691 . ' data-language-id="' . $lP . '"'
1692 . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '"'
1693 . ' data-colpos-id="' . $colPos . '"'
1694 . ' data-colpos-name="' . BackendUtility::getProcessedValue('tt_content', 'colPos', $colPos) . '"'
1695 . '/>';
1696 }
1697
1698 return '<div class="t3-page-lang-copyce">' . $theNewButton . '</div>';
1699 }
1700
1701 /**
1702 * Creates onclick-attribute content for a new content element
1703 *
1704 * @param int $id Page id where to create the element.
1705 * @param int $colPos Preset: Column position value
1706 * @param int $sys_language Preset: Sys langauge value
1707 * @return string String for onclick attribute.
1708 * @see getTable_tt_content()
1709 */
1710 public function newContentElementOnClick($id, $colPos, $sys_language)
1711 {
1712 if ($this->option_newWizard) {
1713 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $id . '&colPos=' . $colPos
1714 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1715 . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
1716 } else {
1717 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1718 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language);
1719 }
1720 return $onClick;
1721 }
1722
1723 /**
1724 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
1725 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1726 *
1727 * @param string $str String to link. Must be prepared for HTML output.
1728 * @param array $row The row.
1729 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1730 * @see getTable_tt_content()
1731 */
1732 public function linkEditContent($str, $row)
1733 {
1734 $addButton = '';
1735 $onClick = '';
1736 if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1737 // Setting onclick action for content link:
1738 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit');
1739 }
1740 // Return link
1741 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick)
1742 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">' . $str . '</a>' . $addButton : $str;
1743 }
1744
1745 /**
1746 * Make selector box for creating new translation in a language
1747 * Displays only languages which are not yet present for the current page and
1748 * that are not disabled with page TS.
1749 *
1750 * @param int $id Page id for which to create a new language (pages_language_overlay record)
1751 * @return string <select> HTML element (if there were items for the box anyways...)
1752 * @see getTable_tt_content()
1753 */
1754 public function languageSelector($id)
1755 {
1756 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1757 // First, select all
1758 $res = $this->getPageLayoutController()->exec_languageQuery(0);
1759 $langSelItems = array();
1760 $langSelItems[0] = '
1761 <option value="0"></option>';
1762 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1763 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1764 $langSelItems[$row['uid']] = '
1765 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1766 }
1767 }
1768 // Then, subtract the languages which are already on the page:
1769 $res = $this->getPageLayoutController()->exec_languageQuery($id);
1770 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1771 unset($langSelItems[$row['uid']]);
1772 }
1773 // Remove disallowed languages
1774 if (count($langSelItems) > 1
1775 && !$this->getBackendUser()->user['admin']
1776 && $this->getBackendUser()->groupData['allowed_languages'] !== ''
1777 ) {
1778 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
1779 if (!empty($allowed_languages)) {
1780 foreach ($langSelItems as $key => $value) {
1781 if (!isset($allowed_languages[$key]) && $key != 0) {
1782 unset($langSelItems[$key]);
1783 }
1784 }
1785 }
1786 }
1787 // Remove disabled languages
1788 $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1789 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1790 ? GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], true)
1791 : array();
1792 if (!empty($langSelItems) && !empty($disableLanguages)) {
1793 foreach ($disableLanguages as $language) {
1794 if ($language != 0 && isset($langSelItems[$language])) {
1795 unset($langSelItems[$language]);
1796 }
1797 }
1798 }
1799 // If any languages are left, make selector:
1800 if (count($langSelItems) > 1) {
1801 $url = BackendUtility::getModuleUrl('record_edit', array(
1802 'edit[pages_language_overlay][' . $id . ']' => 'new',
1803 'overrideVals[pages_language_overlay][doktype]' => (int)$this->pageRecord['doktype'],
1804 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1805 ));
1806 $onChangeContent = 'window.location.href=' . GeneralUtility::quoteJSvalue($url . '&overrideVals[pages_language_overlay][sys_language_uid]=') . '+this.options[this.selectedIndex].value';
1807 return '<div class="form-inline form-inline-spaced">'
1808 . '<div class="form-group">'
1809 . '<label for="createNewLanguage">'
1810 . $this->getLanguageService()->getLL('new_language', true)
1811 . '</label>'
1812 . '<select class="form-control input-sm" name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">'
1813 . implode('', $langSelItems)
1814 . '</select></div></div>';
1815 }
1816 }
1817 return '';
1818 }
1819
1820 /**
1821 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1822 *
1823 * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
1824 * @param string $table Table name defaulting to tt_content
1825 * @return array The selected rows returned in this array.
1826 */
1827 public function getResult($result, $table = 'tt_content')
1828 {
1829 $output = array();
1830 // Traverse the result:
1831 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1832 BackendUtility::workspaceOL($table, $row, -99, true);
1833 if ($row) {
1834 // Add the row to the array:
1835 $output[] = $row;
1836 }
1837 }
1838 $this->generateTtContentDataArray($output);
1839 // Return selected records
1840 return $output;
1841 }
1842
1843 /********************************
1844 *
1845 * Various helper functions
1846 *
1847 ********************************/
1848
1849 /**
1850 * Initializes the clipboard for generating paste links
1851 *
1852 * @return void
1853 *
1854 * @see \TYPO3\CMS\Recordlist\RecordList::main()
1855 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
1856 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
1857 */
1858 protected function initializeClipboard()
1859 {
1860 // Start clipboard
1861 $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
1862
1863 // Initialize - reads the clipboard content from the user session
1864 $this->clipboard->initializeClipboard();
1865
1866 // This locks the clipboard to the Normal for this request.
1867 $this->clipboard->lockToNormal();
1868
1869 // Clean up pad
1870 $this->clipboard->cleanCurrent();
1871
1872 // Save the clipboard content
1873 $this->clipboard->endClipboard();
1874 }
1875
1876 /**
1877 * Generates the data for previous and next elements which is needed for movements.
1878 *
1879 * @param array $rowArray
1880 * @return void
1881 */
1882 protected function generateTtContentDataArray(array $rowArray)
1883 {
1884 if (empty($this->tt_contentData)) {
1885 $this->tt_contentData = array(
1886 'nextThree' => array(),
1887 'next' => array(),
1888 'prev' => array(),
1889 );
1890 }
1891 foreach ($rowArray as $key => $value) {
1892 // Create the list of the next three ids (for editing links...)
1893 for ($i = 0; $i < $this->nextThree; $i++) {
1894 if (isset($rowArray[$key - $i])
1895 && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
1896 ) {
1897 $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
1898 }
1899 }
1900
1901 // Create information for next and previous content elements
1902 if (isset($rowArray[$key - 1])) {
1903 if (isset($rowArray[$key - 2])) {
1904 $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
1905 } else {
1906 $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
1907 }
1908 $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
1909 }
1910 }
1911 }
1912
1913 /**
1914 * Counts and returns the number of records on the page with $pid
1915 *
1916 * @param string $table Table name
1917 * @param int $pid Page id
1918 * @return int Number of records.
1919 */
1920 public function numberOfRecords($table, $pid)
1921 {
1922 $count = 0;
1923 if ($GLOBALS['TCA'][$table]) {
1924 $where = 'pid=' . (int)$pid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table);
1925 $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
1926 }
1927 return (int)$count;
1928 }
1929
1930 /**
1931 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1932 *
1933 * @param string $input Input string
1934 * @return string Output string
1935 */
1936 public function renderText($input)
1937 {
1938 $input = strip_tags($input);
1939 $input = GeneralUtility::fixed_lgd_cs($input, 1500);
1940 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', false));
1941 }
1942
1943 /**
1944 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1945 *
1946 * @param string $table Table name
1947 * @param array $row Record array
1948 * @param string $enabledClickMenuItems Passthrough to wrapClickMenuOnIcon
1949 * @return string HTML for the icon
1950 */
1951 public function getIcon($table, $row, $enabledClickMenuItems = '')
1952 {
1953 // Initialization
1954 $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
1955 $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
1956 $this->counter++;
1957 // The icon with link
1958 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
1959 $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid'], true, '', $enabledClickMenuItems);
1960 }
1961 return $icon;
1962 }
1963
1964 /**
1965 * Creates processed values for all field names in $fieldList based on values from $row array.
1966 * The result is 'returned' through $info which is passed as a reference
1967 *
1968 * @param string $table Table name
1969 * @param string $fieldList Comma separated list of fields.
1970 * @param array $row Record from which to take values for processing.
1971 * @param array $info Array to which the processed values are added.
1972 * @return void
1973 */
1974 public function getProcessedValue($table, $fieldList, array $row, array &$info)
1975 {
1976 // Splitting values from $fieldList
1977 $fieldArr = explode(',', $fieldList);
1978 // Traverse fields from $fieldList
1979 foreach ($fieldArr as $field) {
1980 if ($row[$field]) {
1981 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
1982 . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
1983 }
1984 }
1985 }
1986
1987 /**
1988 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
1989 *
1990 * @param string $table Tablename of table to test
1991 * @param array $row Record row.
1992 * @return bool Returns TRUE, if disabled.
1993 */
1994 public function isDisabled($table, $row)
1995 {
1996 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
1997 return $enableCols['disabled'] && $row[$enableCols['disabled']]
1998 || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
1999 || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2000 }
2001
2002 /**
2003 * Returns icon for "no-edit" of a record.
2004 * Basically, the point is to signal that this record could have had an edit link if
2005 * the circumstances were right. A placeholder for the regular edit icon...
2006 *
2007 * @param string $label Label key from LOCAL_LANG
2008 * @return string IMG tag for icon.
2009 */
2010 public function noEditIcon($label = 'noEditItems')
2011 {
2012 $title = $this->getLanguageService()->getLL($label, true);
2013 return '<span title="' . $title . '">' . $this->iconFactory->getIcon('status-status-edit-read-only', Icon::SIZE_SMALL)->render() . '</span>';
2014 }
2015
2016 /**
2017 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
2018 * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...)
2019 * are filtered out. So what is left is basically all tables which makes sense to list content from.
2020 *
2021 * @return array
2022 */
2023 protected function cleanTableNames()
2024 {
2025 // Get all table names:
2026 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2027 // Unset common names:
2028 unset($tableNames['pages']);
2029 unset($tableNames['static_template']);
2030 unset($tableNames['sys_filemounts']);
2031 unset($tableNames['sys_action']);
2032 unset($tableNames['sys_workflows']);
2033 unset($tableNames['be_users']);
2034 unset($tableNames['be_groups']);
2035 $allowedTableNames = array();
2036 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2037 if (is_array($tableNames)) {
2038 foreach ($tableNames as $k => $v) {
2039 if (!$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->getBackendUser()->check('tables_select', $k)) {
2040 $allowedTableNames['table_' . $k] = $k;
2041 }
2042 }
2043 }
2044 return $allowedTableNames;
2045 }
2046
2047 /*****************************************
2048 *
2049 * External renderings
2050 *
2051 *****************************************/
2052
2053 /**
2054 * Creates a menu of the tables that can be listed by this function
2055 * Only tables which has records on the page will be included.
2056 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2057 *
2058 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2059 * @return string HTML output.
2060 */
2061 public function getTableMenu($id)
2062 {
2063 // Initialize:
2064 $this->activeTables = array();
2065 $theTables = array('tt_content');
2066 // External tables:
2067 if (is_array($this->externalTables)) {
2068 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2069 }
2070 $out = '';
2071 // Traverse tables to check:
2072 foreach ($theTables as $tName) {
2073 // Check access and whether the proper extensions are loaded:
2074 if ($this->getBackendUser()->check('tables_select', $tName)
2075 && (isset($this->externalTables[$tName])
2076 || GeneralUtility::inList('fe_users,tt_content', $tName)
2077 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2078 )
2079 ) {
2080 // Make query to count records from page:
2081 $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2082 . BackendUtility::deleteClause($tName) . BackendUtility::versioningPlaceholderClause($tName));
2083 // If records were found (or if "tt_content" is the table...):
2084 if ($c || GeneralUtility::inList('tt_content', $tName)) {
2085 // Add row to menu:
2086 $out .= '
2087 <td><a href="#' . $tName . '" title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . '"></a>'
2088 . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render()
2089 . '</td>';
2090 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2091 $title = $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true)
2092 . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', true);
2093 $this->activeTables[$tName] = '<span title="' . $title . '">'
2094 . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render()
2095 . '</span>'
2096 . '&nbsp;' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true);
2097 }
2098 }
2099 }
2100 // Wrap cells in table tags:
2101 $out = '
2102 <!--
2103 Menu of tables on the page (table menu)
2104 -->
2105 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2106 <tr>' . $out . '
2107 </tr>
2108 </table>';
2109 // Return the content:
2110 return $out;
2111 }
2112
2113 /**
2114 * Create thumbnail code for record/field but not linked
2115 *
2116 * @param mixed[] $row Record array
2117 * @param string $table Table (record is from)
2118 * @param string $field Field name for which thumbnail are to be rendered.
2119 * @return string HTML for thumbnails, if any.
2120 */
2121 public function getThumbCodeUnlinked($row, $table, $field)
2122 {
2123 return BackendUtility::thumbCode($row, $table, $field, '', '', null, 0, '', '', false);
2124 }
2125
2126 /**
2127 * Checks whether translated Content Elements exist in the desired language
2128 * If so, deny creating new ones via the UI
2129 *
2130 * @param array $contentElements
2131 * @param int $language
2132 * @return bool
2133 */
2134 protected function checkIfTranslationsExistInLanguage(array $contentElements, $language)
2135 {
2136 // If in default language, you may always create new entries
2137 // Also, you may override this strict behavior via user TS Config
2138 // If you do so, you're on your own and cannot rely on any support by the TYPO3 core
2139 // We jump out here since we don't need to do the expensive loop operations
2140 $allowInconsistentLanguageHandling = BackendUtility::getModTSconfig($this->id, 'mod.web_layout.allowInconsistentLanguageHandling');
2141 if ($language === 0 || $allowInconsistentLanguageHandling['value'] === '1') {
2142 return false;
2143 }
2144 /**
2145 * Build up caches
2146 */
2147 if (!isset($this->languageHasTranslationsCache[$language])) {
2148 foreach ($contentElements as $columns) {
2149 foreach ($columns as $contentElement) {
2150 if ((int)$contentElement['l18n_parent'] === 0) {
2151 $this->languageHasTranslationsCache[$language]['hasStandAloneContent'] = true;
2152 }
2153 if ((int)$contentElement['l18n_parent'] > 0) {
2154 $this->languageHasTranslationsCache[$language]['hasTranslations'] = true;
2155 }
2156 }
2157 }
2158 // Check whether we have a mix of both
2159 if ($this->languageHasTranslationsCache[$language]['hasStandAloneContent']
2160 && $this->languageHasTranslationsCache[$language]['hasTranslations']
2161 ) {
2162 $message = GeneralUtility::makeInstance(
2163 FlashMessage::class,
2164 sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $this->languageIconTitles[$language]['title']),
2165 sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), $this->languageIconTitles[$language]['title']),
2166 FlashMessage::WARNING
2167 );
2168 $service = GeneralUtility::makeInstance(FlashMessageService::class);
2169 $queue = $service->getMessageQueueByIdentifier();
2170 $queue->addMessage($message);
2171 }
2172 }
2173 if ($this->languageHasTranslationsCache[$language]['hasTranslations']) {
2174 return true;
2175 }
2176 return false;
2177 }
2178
2179 /**
2180 * @return BackendLayoutView
2181 */
2182 protected function getBackendLayoutView()
2183 {
2184 return GeneralUtility::makeInstance(BackendLayoutView::class);
2185 }
2186
2187 /**
2188 * @return BackendUserAuthentication
2189 */
2190 protected function getBackendUser()
2191 {
2192 return $GLOBALS['BE_USER'];
2193 }
2194
2195 /**
2196 * @return DatabaseConnection
2197 */
2198 protected function getDatabase()
2199 {
2200 return $GLOBALS['TYPO3_DB'];
2201 }
2202
2203 /**
2204 * @return PageLayoutController
2205 */
2206 protected function getPageLayoutController()
2207 {
2208 return $GLOBALS['SOBE'];
2209 }
2210 }