[BUGFIX] Disable restricted users to edit page properties
[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 $editLink = '';
769 $recordIcon = '';
770 if ($this->getBackendUser()->checkLanguageAccess(0)) {
771 $params = '&edit[pages][' . $this->id . ']=edit';
772
773 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
774 $this->iconFactory->getIconForRecord('pages', $this->pageRecord,
775 Icon::SIZE_SMALL)->render(),
776 'pages',
777 $this->id
778 );
779 $editLink = ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
780 ? '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
781 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">'
782 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
783 : ''
784 );
785 }
786
787 $lPLabel =
788 '<div class="btn-group">'
789 . $viewLink
790 . $editLink
791 . '</div>'
792 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20));
793 }
794 $sCont[$lP] = '
795 <td nowrap="nowrap" class="t3-page-column t3-page-lang-label">' . $lPLabel . '</td>';
796 }
797 // Add headers:
798 $out .= '<tr>' . implode($cCont) . '</tr>';
799 $out .= '<tr>' . implode($sCont) . '</tr>';
800 unset($cCont, $sCont);
801
802 // Traverse previously built content for the columns:
803 foreach ($languageColumn as $cKey => $cCont) {
804 $out .= '<tr>';
805 foreach ($cCont as $languageId => $columnContent) {
806 $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>';
807 }
808 $out .= '</tr>';
809 if ($this->defLangBinding) {
810 // "defLangBinding" mode
811 foreach ($defLanguageCount[$cKey] as $defUid) {
812 $cCont = array();
813 foreach ($langListArr as $lP) {
814 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
815 $this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP),
816 $lP,
817 $cKey
818 );
819 }
820 $out .= '
821 <tr>
822 <td valign="top" class="t3-grid-cell">' . implode(('</td>' . '
823 <td valign="top" class="t3-grid-cell">'), $cCont) . '</td>
824 </tr>';
825 }
826 }
827 }
828 // Finally, wrap it all in a table and add the language selector on top of it:
829 $out = $languageSelector . '
830 <div class="t3-grid-container">
831 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
832 ' . $out . '
833 </table>
834 </div>';
835 // CSH:
836 $out .= BackendUtility::cshItem($this->descrTable, 'language_list');
837 }
838
839 return $out;
840 }
841
842 /**********************************
843 *
844 * Generic listing of items
845 *
846 **********************************/
847 /**
848 * Creates a standard list of elements from a table.
849 *
850 * @param string $table Table name
851 * @param int $id Page id.
852 * @param string $fList Comma list of fields to display
853 * @param bool $icon If TRUE, icon is shown
854 * @param string $addWhere Additional WHERE-clauses.
855 * @return string HTML table
856 */
857 public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = '')
858 {
859 // Initialize
860 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
861 $this->setTotalItems($queryParts);
862 $dbCount = 0;
863 $result = false;
864 // Make query for records if there were any records found in the count operation
865 if ($this->totalItems) {
866 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
867 // Will return FALSE, if $result is invalid
868 $dbCount = $this->getDatabase()->sql_num_rows($result);
869 }
870 // If records were found, render the list
871 if (!$dbCount) {
872 return '';
873 }
874 // Set fields
875 $out = '';
876 $this->fieldArray = GeneralUtility::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', true);
877 $theData = array();
878 $theData = $this->headerFields($this->fieldArray, $table, $theData);
879 // Title row
880 $localizedTableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'], true);
881 $out .= '<tr class="t3-row-header">' . '<th class="col-icon"></th>'
882 . '<th colspan="' . (count($theData) - 2) . '"><span class="c-table">'
883 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td class="col-icon"></td>'
884 . '</tr>';
885 // Column's titles
886 if ($this->doEdit) {
887 $onClick = BackendUtility::editOnClick('&edit[' . $table . '][' . $this->id . ']=new');
888 $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" '
889 . 'title="' . $this->getLanguageService()->getLL('new', true) . '">'
890 . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . '</a>';
891 }
892 $out .= $this->addElement(1, '', $theData, ' class="c-headLine"', 15, '', 'th');
893 // Render Items
894 $this->eCounter = $this->firstElementNumber;
895 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
896 BackendUtility::workspaceOL($table, $row);
897 if (is_array($row)) {
898 list($flag, $code) = $this->fwd_rwd_nav();
899 $out .= $code;
900 if ($flag) {
901 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
902 $Nrow = array();
903 // Setting icons links
904 if ($icon) {
905 $Nrow['__cmds__'] = $this->getIcon($table, $row);
906 }
907 // Get values:
908 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
909 // Attach edit icon
910 if ($this->doEdit && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
911 $Nrow['__editIconLink__'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params))
912 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">'
913 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
914 } else {
915 $Nrow['__editIconLink__'] = $this->noEditIcon();
916 }
917 $out .= $this->addElement(1, '', $Nrow);
918 }
919 $this->eCounter++;
920 }
921 }
922 $this->getDatabase()->sql_free_result($result);
923 // Wrap it all in a table:
924 $out = '
925 <!--
926 Standard list of table "' . $table . '"
927 -->
928 <div class="table-fit"><table class="table table-striped">
929 ' . $out . '
930 </table></div>';
931 return $out;
932 }
933
934 /**
935 * Adds content to all data fields in $out array
936 *
937 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
938 * Eg. "field1,field2;field3".
939 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
940 *
941 * @param array $fieldArr Array of fields to display
942 * @param string $table Table name
943 * @param array $row Record array
944 * @param array $out Array to which the data is added
945 * @return array $out array returned after processing.
946 * @see makeOrdinaryList()
947 */
948 public function dataFields($fieldArr, $table, $row, $out = array())
949 {
950 // Check table validity
951 if (!isset($GLOBALS['TCA'][$table])) {
952 return $out;
953 }
954
955 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
956 // Traverse fields
957 foreach ($fieldArr as $fieldName) {
958 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
959 // Each field has its own cell (if configured in TCA)
960 // If the column is a thumbnail column:
961 if ($fieldName == $thumbsCol) {
962 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
963 } else {
964 // ... otherwise just render the output:
965 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(
966 BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
967 250
968 ))));
969 }
970 } else {
971 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
972 // the field name with ";" and check each value there as a TCA configured field)
973 $theFields = explode(';', $fieldName);
974 // Traverse fields, separated by ";" (displayed in a single cell).
975 foreach ($theFields as $fName2) {
976 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
977 $out[$fieldName] .= '<strong>' . $this->getLanguageService()->sL(
978 $GLOBALS['TCA'][$table]['columns'][$fName2]['label'],
979 true
980 ) . '</strong>' . '&nbsp;&nbsp;' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
981 BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
982 25
983 )) . '<br />';
984 }
985 }
986 }
987 // If no value, add a nbsp.
988 if (!$out[$fieldName]) {
989 $out[$fieldName] = '&nbsp;';
990 }
991 // Wrap in dimmed-span tags if record is "disabled"
992 if ($this->isDisabled($table, $row)) {
993 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
994 }
995 }
996 return $out;
997 }
998
999 /**
1000 * Header fields made for the listing of records
1001 *
1002 * @param array $fieldArr Field names
1003 * @param string $table The table name
1004 * @param array $out Array to which the headers are added.
1005 * @return array $out returned after addition of the header fields.
1006 * @see makeOrdinaryList()
1007 */
1008 public function headerFields($fieldArr, $table, $out = array())
1009 {
1010 foreach ($fieldArr as $fieldName) {
1011 $ll = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], true);
1012 $out[$fieldName] = $ll ? $ll : '&nbsp;';
1013 }
1014 return $out;
1015 }
1016
1017 /**
1018 * Gets content records per column.
1019 * This is required for correct workspace overlays.
1020 *
1021 * @param string $table UNUSED (will always be queried from tt_content)
1022 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1023 * @param array $columns colPos values to be considered to be shown
1024 * @param string $additionalWhereClause Additional where clause for database select
1025 * @return array Associative array for each column (colPos)
1026 */
1027 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '')
1028 {
1029 $columns = array_map('intval', $columns);
1030 $contentRecordsPerColumn = array_fill_keys($columns, array());
1031
1032 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos IN (' . implode(',', $columns) . ')' . $additionalWhereClause);
1033 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1034 // Traverse any selected elements and render their display code:
1035 $rowArr = $this->getResult($result);
1036
1037 foreach ($rowArr as $record) {
1038 $columnValue = $record['colPos'];
1039 $contentRecordsPerColumn[$columnValue][] = $record;
1040 }
1041
1042 return $contentRecordsPerColumn;
1043 }
1044
1045 /**********************************
1046 *
1047 * Additional functions; Pages
1048 *
1049 **********************************/
1050 /**
1051 * Adds pages-rows to an array, selecting recursively in the page tree.
1052 *
1053 * @param array $theRows Array which will accumulate page rows
1054 * @param int $pid Pid to select from
1055 * @param string $qWhere Query-where clause
1056 * @param string $treeIcons Prefixed icon code.
1057 * @param int $depth Depth (decreasing)
1058 * @return array $theRows, but with added rows.
1059 */
1060 public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth)
1061 {
1062 $depth--;
1063 if ($depth >= 0) {
1064 $res = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'pid=' . (int)$pid . $qWhere, '', 'sorting');
1065 $c = 0;
1066 $rc = $this->getDatabase()->sql_num_rows($res);
1067 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1068 BackendUtility::workspaceOL('pages', $row);
1069 if (is_array($row)) {
1070 $c++;
1071 $row['treeIcons'] = $treeIcons . '<span class="treeline-icon treeline-icon-join' . ($rc === $c ? 'bottom' : '') . '"></span>';
1072 $theRows[] = $row;
1073 // Get the branch
1074 $spaceOutIcons = '<span class="treeline-icon treeline-icon-' . ($rc === $c ? 'clear' : 'line') . '"></span>';
1075 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ? 0 : $depth);
1076 }
1077 }
1078 } else {
1079 $count = $this->getDatabase()->exec_SELECTcountRows('uid', 'pages', 'pid=' . (int)$pid . $qWhere);
1080 if ($count) {
1081 $this->plusPages[$pid] = $count;
1082 }
1083 }
1084 return $theRows;
1085 }
1086
1087 /**
1088 * Adds a list item for the pages-rendering
1089 *
1090 * @param array $row Record array
1091 * @param array $fieldArr Field list
1092 * @return string HTML for the item
1093 */
1094 public function pages_drawItem($row, $fieldArr)
1095 {
1096 // Initialization
1097 $theIcon = $this->getIcon('pages', $row);
1098 // Preparing and getting the data-array
1099 $theData = array();
1100 foreach ($fieldArr as $field) {
1101 switch ($field) {
1102 case 'title':
1103 $red = $this->plusPages[$row['uid']] ? '<span class="text-danger"><strong>+</strong></span>' : '';
1104 $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
1105 if ($red) {
1106 $pTitle = '<a href="'
1107 . htmlspecialchars($this->script . ((strpos($this->script, '?') !== false) ? '&' : '?')
1108 . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1109 }
1110 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . '&nbsp;&nbsp;';
1111 break;
1112 case 'php_tree_stop':
1113 // Intended fall through
1114 case 'TSconfig':
1115 $theData[$field] = $row[$field] ? '&nbsp;<strong>x</strong>' : '&nbsp;';
1116 break;
1117 case 'uid':
1118 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
1119 $params = '&edit[pages][' . $row['uid'] . ']=edit';
1120 $eI = '<a href="#" onclick="'
1121 . htmlspecialchars(BackendUtility::editOnClick($params))
1122 . '" title="' . $this->getLanguageService()->getLL('editThisPage', true) . '">'
1123 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1124 } else {
1125 $eI = '';
1126 }
1127 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1128 break;
1129 case 'shortcut':
1130 case 'shortcut_mode':
1131 if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
1132 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1133 }
1134 break;
1135 default:
1136 if (substr($field, 0, 6) == 'table_') {
1137 $f2 = substr($field, 6);
1138 if ($GLOBALS['TCA'][$f2]) {
1139 $c = $this->numberOfRecords($f2, $row['uid']);
1140 $theData[$field] = '&nbsp;&nbsp;' . ($c ? $c : '');
1141 }
1142 } else {
1143 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1144 }
1145 }
1146 }
1147 $this->addElement_tdParams['title'] = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '';
1148 return $this->addElement(1, '', $theData);
1149 }
1150
1151 /**
1152 * Returns the HTML code for rendering a field in the pages table.
1153 * The row value is processed to a human readable form and the result is parsed through htmlspecialchars().
1154 *
1155 * @param string $field The name of the field of which the value should be rendered.
1156 * @param array $row The pages table row as an associative array.
1157 * @return string The rendered table field value.
1158 */
1159 protected function getPagesTableFieldValue($field, array $row)
1160 {
1161 return '&nbsp;&nbsp;' . htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
1162 }
1163
1164 /**********************************
1165 *
1166 * Additional functions; Content Elements
1167 *
1168 **********************************/
1169 /**
1170 * Draw header for a content element column:
1171 *
1172 * @param string $colName Column name
1173 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1174 * @param string $newParams New element params (Syntax: &edit[...] for FormEngine) OBSOLETE
1175 * @param array|NULL $pasteParams Paste element params (i.e. array(colPos => 1, sys_language_uid => 2))
1176 * @return string HTML table
1177 */
1178 public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = null)
1179 {
1180 $iconsArr = array();
1181 // Create command links:
1182 if ($this->tt_contentConfig['showCommands']) {
1183 // Edit whole of column:
1184 if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT) && $this->getBackendUser()->checkLanguageAccess(0)) {
1185 $iconsArr['edit'] = '<a href="#" onclick="'
1186 . htmlspecialchars(BackendUtility::editOnClick($editParams)) . '" title="'
1187 . $this->getLanguageService()->getLL('editColumn', true) . '">'
1188 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1189 }
1190 if ($pasteParams) {
1191 $elFromTable = $this->clipboard->elFromTable('tt_content');
1192 if (!empty($elFromTable) && $this->getPageLayoutController()->pageIsNotLockedForEditors()) {
1193 $iconsArr['paste'] = '<a href="'
1194 . htmlspecialchars($this->clipboard->pasteUrl('tt_content', $this->id, true, $pasteParams))
1195 . '" onclick="' . htmlspecialchars(('return '
1196 . $this->clipboard->confirmMsg('pages', $this->pageRecord, 'into', $elFromTable, $colName)))
1197 . '" title="' . $this->getLanguageService()->getLL('pasteIntoColumn', true) . '">'
1198 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
1199 }
1200 }
1201 }
1202 $icons = '';
1203 if (!empty($iconsArr)) {
1204 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1205 }
1206 // Create header row:
1207 $out = '<div class="t3-page-column-header">
1208 ' . $icons . '
1209 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1210 </div>';
1211 return $out;
1212 }
1213
1214 /**
1215 * Draw the footer for a single tt_content element
1216 *
1217 * @param array $row Record array
1218 * @return string HTML of the footer
1219 * @throws \UnexpectedValueException
1220 */
1221 protected function tt_content_drawFooter(array $row)
1222 {
1223 $content = '';
1224 // Get processed values:
1225 $info = array();
1226 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1227
1228 // Content element annotation
1229 if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn'])) {
1230 $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
1231 }
1232
1233 // Call drawFooter hooks
1234 $drawFooterHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'];
1235 if (is_array($drawFooterHooks)) {
1236 foreach ($drawFooterHooks as $hookClass) {
1237 $hookObject = GeneralUtility::getUserObj($hookClass);
1238 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
1239 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawFooterHookInterface', 1404378171);
1240 }
1241 $hookObject->preProcess($this, $info, $row);
1242 }
1243 }
1244
1245 // Display info from records fields:
1246 if (!empty($info)) {
1247 $content = '<div class="t3-page-ce-info">
1248 ' . implode('<br>', $info) . '
1249 </div>';
1250 }
1251 // Wrap it
1252 if (!empty($content)) {
1253 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1254 }
1255 return $content;
1256 }
1257
1258 /**
1259 * Draw the header for a single tt_content element
1260 *
1261 * @param array $row Record array
1262 * @param int $space Amount of pixel space above the header. UNUSED
1263 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1264 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1265 * @param bool $dragDropEnabled If set the move button must be hidden
1266 * @return string HTML table with the record header.
1267 */
1268 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false)
1269 {
1270 $out = '';
1271 // If show info is set...;
1272 if ($this->tt_contentConfig['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1273 // Render control panel for the element:
1274 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1275 // Edit content element:
1276 $params = '&edit[tt_content][' . $this->tt_contentData['nextThree'][$row['uid']] . ']=edit';
1277 $out .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
1278 $params,
1279 '',
1280 GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
1281 )) . '" title="' . htmlspecialchars($this->nextThree > 1
1282 ? sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree)
1283 : $this->getLanguageService()->getLL('edit'))
1284 . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1285 // Hide element:
1286 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1287 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1288 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1289 || $this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1290 ) {
1291 if ($row[$hiddenField]) {
1292 $value = 0;
1293 $label = 'unHide';
1294 } else {
1295 $value = 1;
1296 $label = 'hide';
1297 }
1298 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
1299 . '][' . $hiddenField . ']=' . $value;
1300 $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1301 . '" title="' . $this->getLanguageService()->getLL($label, true) . '">'
1302 . $this->iconFactory->getIcon('actions-edit-' . strtolower($label), Icon::SIZE_SMALL)->render() . '</a>';
1303 }
1304 // Delete
1305 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1306 $confirm = $this->getLanguageService()->getLL('deleteWarning')
1307 . BackendUtility::translationCount('tt_content', $row['uid'], (' '
1308 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')));
1309 $out .= '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params)) . '"'
1310 . ' data-severity="warning"'
1311 . ' data-title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_alt_doc.xlf:label.confirm.delete_record.title')) . '"'
1312 . ' data-content="' . htmlspecialchars($confirm) . '" '
1313 . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel')) . '"'
1314 . ' title="' . $this->getLanguageService()->getLL('deleteItem', true) . '">'
1315 . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
1316 if ($out && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
1317 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
1318 } else {
1319 $out = '';
1320 }
1321 if (!$disableMoveAndNewButtons) {
1322 $moveButtonContent = '';
1323 $displayMoveButtons = false;
1324 // Move element up:
1325 if ($this->tt_contentData['prev'][$row['uid']]) {
1326 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
1327 $moveButtonContent .= '<a class="btn btn-default" href="'
1328 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1329 . '" title="' . $this->getLanguageService()->getLL('moveUp', true) . '">'
1330 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
1331 if (!$dragDropEnabled) {
1332 $displayMoveButtons = true;
1333 }
1334 } else {
1335 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
1336 }
1337 // Move element down:
1338 if ($this->tt_contentData['next'][$row['uid']]) {
1339 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
1340 $moveButtonContent .= '<a class="btn btn-default" href="'
1341 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1342 . '" title="' . $this->getLanguageService()->getLL('moveDown', true) . '">'
1343 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
1344 if (!$dragDropEnabled) {
1345 $displayMoveButtons = true;
1346 }
1347 } else {
1348 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
1349 }
1350 if ($displayMoveButtons) {
1351 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
1352 }
1353 }
1354 }
1355 }
1356 $allowDragAndDrop = $this->isDragAndDropAllowed($row);
1357 $additionalIcons = array();
1358 if ($row['sys_language_uid'] > 0 && $this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid'])) {
1359 $disabledClickMenuItems = 'new,move';
1360 $allowDragAndDrop = false;
1361 }
1362 $additionalIcons[] = $this->getIcon('tt_content', $row, $disabledClickMenuItems) . ' ';
1363 $additionalIcons[] = $langMode ? $this->languageFlag($row['sys_language_uid'], false) : '';
1364 // Get record locking status:
1365 if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) {
1366 $additionalIcons[] = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg'])
1367 . ');return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">'
1368 . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
1369 }
1370 // Call stats information hook
1371 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1372 $_params = array('tt_content', $row['uid'], &$row);
1373 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1374 $additionalIcons[] = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1375 }
1376 }
1377 // Wrap the whole header
1378 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1379 return '<div class="t3-page-ce-header ' . ($allowDragAndDrop ? 't3-page-ce-header-draggable t3js-page-ce-draghandle' : '') . '">
1380 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
1381 <div class="t3-page-ce-header-icons-right">' . ($out ? '<div class="btn-toolbar">' . $out . '</div>' : '') . '</div>
1382 </div>
1383 <div class="t3-page-ce-body">';
1384 }
1385
1386 /**
1387 * Determine whether Drag & Drop should be allowed
1388 *
1389 * @param array $row
1390 * @return bool
1391 */
1392 protected function isDragAndDropAllowed(array $row)
1393 {
1394 if ($this->getBackendUser()->user['admin']
1395 || ((int)$row['editlock'] === 0 && (int)$this->pageinfo['editlock'] === 0)
1396 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
1397 ) {
1398 return true;
1399 }
1400 return false;
1401 }
1402
1403 /**
1404 * Draws the preview content for a content element
1405 *
1406 * @param array $row Content element
1407 * @return string HTML
1408 * @throws \UnexpectedValueException
1409 */
1410 public function tt_content_drawItem($row)
1411 {
1412 $out = '';
1413 $outHeader = '';
1414 // Make header:
1415
1416 if ($row['header']) {
1417 $infoArr = array();
1418 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1419 $hiddenHeaderNote = '';
1420 // If header layout is set to 'hidden', display an accordant note:
1421 if ($row['header_layout'] == 100) {
1422 $hiddenHeaderNote = ' <em>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.hidden', true) . ']</em>';
1423 }
1424 $outHeader = $row['date']
1425 ? htmlspecialchars($this->itemLabels['date'] . ' ' . BackendUtility::date($row['date'])) . '<br />'
1426 : '';
1427 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1428 . $hiddenHeaderNote . '</strong><br />';
1429 }
1430 // Make content:
1431 $infoArr = array();
1432 $drawItem = true;
1433 // Hook: Render an own preview of a record
1434 $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1435 if (is_array($drawItemHooks)) {
1436 foreach ($drawItemHooks as $hookClass) {
1437 $hookObject = GeneralUtility::getUserObj($hookClass);
1438 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
1439 throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface::class, 1218547409);
1440 }
1441 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1442 }
1443 }
1444
1445 // If the previous hook did not render something,
1446 // then check if a Fluid-based preview template was defined for this CType
1447 // and render it via Fluid. Possible option:
1448 // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html
1449 if ($drawItem) {
1450 $tsConfig = BackendUtility::getModTSconfig($row['pid'], 'mod.web_layout.tt_content.preview');
1451 if (!empty($tsConfig['properties'][$row['CType']])) {
1452 $fluidTemplateFile = $tsConfig['properties'][$row['CType']];
1453 $fluidTemplateFile = GeneralUtility::getFileAbsFileName($fluidTemplateFile);
1454 if ($fluidTemplateFile) {
1455 try {
1456 /** @var StandaloneView $view */
1457 $view = GeneralUtility::makeInstance(StandaloneView::class);
1458 $view->setTemplatePathAndFilename($fluidTemplateFile);
1459 $view->assignMultiple($row);
1460 if (!empty($row['pi_flexform'])) {
1461 /** @var FlexFormService $flexFormService */
1462 $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
1463 $view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
1464 }
1465 $out = $view->render();
1466 $drawItem = false;
1467 } catch (\Exception $e) {
1468 // Catch any exception to avoid breaking the view
1469 }
1470 }
1471 }
1472 }
1473
1474 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1475 if ($drawItem) {
1476 switch ($row['CType']) {
1477 case 'header':
1478 if ($row['subheader']) {
1479 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1480 }
1481 break;
1482 case 'bullets':
1483 case 'table':
1484 if ($row['bodytext']) {
1485 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1486 }
1487 break;
1488 case 'uploads':
1489 if ($row['media']) {
1490 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
1491 }
1492 break;
1493 case 'menu':
1494 $contentType = $this->CType_labels[$row['CType']];
1495 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1496 // Add Menu Type
1497 $menuTypeLabel = $this->getLanguageService()->sL(
1498 BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
1499 );
1500 $menuTypeLabel = $menuTypeLabel ?: 'invalid menu type';
1501 $out .= $this->linkEditContent($menuTypeLabel, $row);
1502 if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
1503 // Show pages if menu type is not "Sitemap"
1504 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
1505 }
1506 break;
1507 case 'shortcut':
1508 if (!empty($row['records'])) {
1509 $shortcutContent = array();
1510 $recordList = explode(',', $row['records']);
1511 foreach ($recordList as $recordIdentifier) {
1512 $split = BackendUtility::splitTable_Uid($recordIdentifier);
1513 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
1514 $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
1515 if (is_array($shortcutRecord)) {
1516 $icon = $this->iconFactory->getIconForRecord($tableName, $shortcutRecord, Icon::SIZE_SMALL)->render();
1517 $icon = BackendUtility::wrapClickMenuOnIcon(
1518 $icon,
1519 $tableName,
1520 $shortcutRecord['uid'],
1521 1,
1522 '',
1523 '+copy,info,edit,view'
1524 );
1525 $shortcutContent[] = $icon
1526 . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
1527 }
1528 }
1529 $out .= implode('<br />', $shortcutContent) . '<br />';
1530 }
1531 break;
1532 case 'list':
1533 $hookArr = array();
1534 $hookOut = '';
1535 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1536 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1537 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1538 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1539 }
1540 if (!empty($hookArr)) {
1541 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1542 foreach ($hookArr as $_funcRef) {
1543 $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1544 }
1545 }
1546 if ((string)$hookOut !== '') {
1547 $out .= $hookOut;
1548 } elseif (!empty($row['list_type'])) {
1549 $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1550 if (!empty($label)) {
1551 $out .= $this->linkEditContent('<strong>' . $this->getLanguageService()->sL($label, true) . '</strong>', $row) . '<br />';
1552 } else {
1553 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1554 $out .= GeneralUtility::makeInstance(
1555 FlashMessage::class,
1556 htmlspecialchars($message),
1557 '',
1558 FlashMessage::WARNING
1559 )->render();
1560 }
1561 } elseif (!empty($row['select_key'])) {
1562 $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), true)
1563 . ' ' . $row['select_key'] . '<br />';
1564 } else {
1565 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1566 }
1567 $out .= $this->getLanguageService()->sL(
1568 BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1569 true
1570 ) . '<br />';
1571 break;
1572 default:
1573 $contentType = $this->CType_labels[$row['CType']];
1574
1575 if (isset($contentType)) {
1576 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
1577 if ($row['bodytext']) {
1578 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1579 }
1580 if ($row['image']) {
1581 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
1582 }
1583 } else {
1584 $message = sprintf(
1585 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1586 $row['CType']
1587 );
1588 $out .= GeneralUtility::makeInstance(
1589 FlashMessage::class,
1590 htmlspecialchars($message),
1591 '',
1592 FlashMessage::WARNING
1593 )->render();
1594 }
1595 }
1596 }
1597 // Wrap span-tags:
1598 $out = '
1599 <span class="exampleContent">' . $out . '</span>';
1600 // Add header:
1601 $out = $outHeader . $out;
1602 // Return values:
1603 if ($this->isDisabled('tt_content', $row)) {
1604 return '<span class="text-muted">' . $out . '</span>';
1605 } else {
1606 return $out;
1607 }
1608 }
1609
1610 /**
1611 * Generates a list of selected pages or categories for the CType menu
1612 *
1613 * @param array $row row from pages
1614 * @return string
1615 */
1616 protected function generateListForCTypeMenu(array $row)
1617 {
1618 $table = 'pages';
1619 $field = 'pages';
1620 // get categories instead of pages
1621 if (strpos($row['menu_type'], 'categorized_') !== false) {
1622 $table = 'sys_category';
1623 $field = 'selected_categories';
1624 }
1625 if (trim($row[$field]) === '') {
1626 return '';
1627 }
1628 $content = '';
1629 $uidList = explode(',', $row[$field]);
1630 foreach ($uidList as $uid) {
1631 $uid = (int)$uid;
1632 $record = BackendUtility::getRecord($table, $uid, 'title');
1633 $content .= '<br>' . $record['title'] . ' (' . $uid . ')';
1634 }
1635 return $content;
1636 }
1637
1638 /**
1639 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1640 * Selects across columns, but within in the same PID. Columns are expect to be the same
1641 * for translations and original but this may be a conceptual error (?)
1642 *
1643 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1644 * @param int $id Page pid
1645 * @param int $lP Sys language UID
1646 * @return array Modified $defLanguageCount
1647 */
1648 public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP)
1649 {
1650 if ($lP && !empty($defLanguageCount)) {
1651 // Select all translations here:
1652 $where = 'sys_language_uid=' . intval($lP) . ' AND l18n_parent IN ('
1653 . implode(',', $defLanguageCount) . ')'
1654 . BackendUtility::deleteClause('tt_content');
1655 $rowArr = $this->getDatabase()->exec_SELECTgetRows('*', 'tt_content', $where);
1656
1657 // Flip uids:
1658 $defLanguageCount = array_flip($defLanguageCount);
1659 // Traverse any selected elements and unset original UID if any:
1660 foreach ($rowArr as $row) {
1661 BackendUtility::workspaceOL('tt_content', $row);
1662 unset($defLanguageCount[$row['l18n_parent']]);
1663 }
1664 // Flip again:
1665 $defLanguageCount = array_keys($defLanguageCount);
1666 }
1667 return $defLanguageCount;
1668 }
1669
1670 /**
1671 * Creates button which is used to create copies of records..
1672 *
1673 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1674 * @param int $lP Sys language UID
1675 * @param int $colPos Column position
1676 * @return string "Copy languages" button, if available.
1677 */
1678 public function newLanguageButton($defLanguageCount, $lP, $colPos = 0)
1679 {
1680 $lP = (int)$lP;
1681 if (!$this->doEdit || !$lP) {
1682 return '';
1683 }
1684 $theNewButton = '';
1685
1686 if (!empty($defLanguageCount)) {
1687 $theNewButton =
1688 '<input'
1689 . ' class="btn btn-default t3js-localize"'
1690 . ' type="button"'
1691 . ' disabled'
1692 . ' value="' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate', true)) . '"'
1693 . ' data-has-elements="' . (int)!empty($this->contentElementCache[$lP][$colPos]) . '"'
1694 . ' data-table="tt_content"'
1695 . ' data-page-id="' . (int)GeneralUtility::_GP('id') . '"'
1696 . ' data-language-id="' . $lP . '"'
1697 . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '"'
1698 . ' data-colpos-id="' . $colPos . '"'
1699 . ' data-colpos-name="' . BackendUtility::getProcessedValue('tt_content', 'colPos', $colPos) . '"'
1700 . '/>';
1701 }
1702
1703 return '<div class="t3-page-lang-copyce">' . $theNewButton . '</div>';
1704 }
1705
1706 /**
1707 * Creates onclick-attribute content for a new content element
1708 *
1709 * @param int $id Page id where to create the element.
1710 * @param int $colPos Preset: Column position value
1711 * @param int $sys_language Preset: Sys langauge value
1712 * @return string String for onclick attribute.
1713 * @see getTable_tt_content()
1714 */
1715 public function newContentElementOnClick($id, $colPos, $sys_language)
1716 {
1717 if ($this->option_newWizard) {
1718 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $id . '&colPos=' . $colPos
1719 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1720 . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
1721 } else {
1722 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1723 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language);
1724 }
1725 return $onClick;
1726 }
1727
1728 /**
1729 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
1730 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1731 *
1732 * @param string $str String to link. Must be prepared for HTML output.
1733 * @param array $row The row.
1734 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1735 * @see getTable_tt_content()
1736 */
1737 public function linkEditContent($str, $row)
1738 {
1739 $addButton = '';
1740 $onClick = '';
1741 if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1742 // Setting onclick action for content link:
1743 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit');
1744 }
1745 // Return link
1746 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick)
1747 . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">' . $str . '</a>' . $addButton : $str;
1748 }
1749
1750 /**
1751 * Make selector box for creating new translation in a language
1752 * Displays only languages which are not yet present for the current page and
1753 * that are not disabled with page TS.
1754 *
1755 * @param int $id Page id for which to create a new language (pages_language_overlay record)
1756 * @return string <select> HTML element (if there were items for the box anyways...)
1757 * @see getTable_tt_content()
1758 */
1759 public function languageSelector($id)
1760 {
1761 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1762 // First, select all
1763 $res = $this->getPageLayoutController()->exec_languageQuery(0);
1764 $langSelItems = array();
1765 $langSelItems[0] = '
1766 <option value="0"></option>';
1767 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1768 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1769 $langSelItems[$row['uid']] = '
1770 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1771 }
1772 }
1773 // Then, subtract the languages which are already on the page:
1774 $res = $this->getPageLayoutController()->exec_languageQuery($id);
1775 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1776 unset($langSelItems[$row['uid']]);
1777 }
1778 // Remove disallowed languages
1779 if (count($langSelItems) > 1
1780 && !$this->getBackendUser()->user['admin']
1781 && $this->getBackendUser()->groupData['allowed_languages'] !== ''
1782 ) {
1783 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
1784 if (!empty($allowed_languages)) {
1785 foreach ($langSelItems as $key => $value) {
1786 if (!isset($allowed_languages[$key]) && $key != 0) {
1787 unset($langSelItems[$key]);
1788 }
1789 }
1790 }
1791 }
1792 // Remove disabled languages
1793 $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1794 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1795 ? GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], true)
1796 : array();
1797 if (!empty($langSelItems) && !empty($disableLanguages)) {
1798 foreach ($disableLanguages as $language) {
1799 if ($language != 0 && isset($langSelItems[$language])) {
1800 unset($langSelItems[$language]);
1801 }
1802 }
1803 }
1804 // If any languages are left, make selector:
1805 if (count($langSelItems) > 1) {
1806 $url = BackendUtility::getModuleUrl('record_edit', array(
1807 'edit[pages_language_overlay][' . $id . ']' => 'new',
1808 'overrideVals[pages_language_overlay][doktype]' => (int)$this->pageRecord['doktype'],
1809 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1810 ));
1811 $onChangeContent = 'window.location.href=' . GeneralUtility::quoteJSvalue($url . '&overrideVals[pages_language_overlay][sys_language_uid]=') . '+this.options[this.selectedIndex].value';
1812 return '<div class="form-inline form-inline-spaced">'
1813 . '<div class="form-group">'
1814 . '<label for="createNewLanguage">'
1815 . $this->getLanguageService()->getLL('new_language', true)
1816 . '</label>'
1817 . '<select class="form-control input-sm" name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">'
1818 . implode('', $langSelItems)
1819 . '</select></div></div>';
1820 }
1821 }
1822 return '';
1823 }
1824
1825 /**
1826 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1827 *
1828 * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
1829 * @param string $table Table name defaulting to tt_content
1830 * @return array The selected rows returned in this array.
1831 */
1832 public function getResult($result, $table = 'tt_content')
1833 {
1834 $output = array();
1835 // Traverse the result:
1836 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1837 BackendUtility::workspaceOL($table, $row, -99, true);
1838 if ($row) {
1839 // Add the row to the array:
1840 $output[] = $row;
1841 }
1842 }
1843 $this->generateTtContentDataArray($output);
1844 // Return selected records
1845 return $output;
1846 }
1847
1848 /********************************
1849 *
1850 * Various helper functions
1851 *
1852 ********************************/
1853
1854 /**
1855 * Initializes the clipboard for generating paste links
1856 *
1857 * @return void
1858 *
1859 * @see \TYPO3\CMS\Recordlist\RecordList::main()
1860 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
1861 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
1862 */
1863 protected function initializeClipboard()
1864 {
1865 // Start clipboard
1866 $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
1867
1868 // Initialize - reads the clipboard content from the user session
1869 $this->clipboard->initializeClipboard();
1870
1871 // This locks the clipboard to the Normal for this request.
1872 $this->clipboard->lockToNormal();
1873
1874 // Clean up pad
1875 $this->clipboard->cleanCurrent();
1876
1877 // Save the clipboard content
1878 $this->clipboard->endClipboard();
1879 }
1880
1881 /**
1882 * Generates the data for previous and next elements which is needed for movements.
1883 *
1884 * @param array $rowArray
1885 * @return void
1886 */
1887 protected function generateTtContentDataArray(array $rowArray)
1888 {
1889 if (empty($this->tt_contentData)) {
1890 $this->tt_contentData = array(
1891 'nextThree' => array(),
1892 'next' => array(),
1893 'prev' => array(),
1894 );
1895 }
1896 foreach ($rowArray as $key => $value) {
1897 // Create the list of the next three ids (for editing links...)
1898 for ($i = 0; $i < $this->nextThree; $i++) {
1899 if (isset($rowArray[$key - $i])
1900 && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
1901 ) {
1902 $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
1903 }
1904 }
1905
1906 // Create information for next and previous content elements
1907 if (isset($rowArray[$key - 1])) {
1908 if (isset($rowArray[$key - 2])) {
1909 $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
1910 } else {
1911 $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
1912 }
1913 $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
1914 }
1915 }
1916 }
1917
1918 /**
1919 * Counts and returns the number of records on the page with $pid
1920 *
1921 * @param string $table Table name
1922 * @param int $pid Page id
1923 * @return int Number of records.
1924 */
1925 public function numberOfRecords($table, $pid)
1926 {
1927 $count = 0;
1928 if ($GLOBALS['TCA'][$table]) {
1929 $where = 'pid=' . (int)$pid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table);
1930 $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
1931 }
1932 return (int)$count;
1933 }
1934
1935 /**
1936 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1937 *
1938 * @param string $input Input string
1939 * @return string Output string
1940 */
1941 public function renderText($input)
1942 {
1943 $input = strip_tags($input);
1944 $input = GeneralUtility::fixed_lgd_cs($input, 1500);
1945 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', false));
1946 }
1947
1948 /**
1949 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1950 *
1951 * @param string $table Table name
1952 * @param array $row Record array
1953 * @param string $enabledClickMenuItems Passthrough to wrapClickMenuOnIcon
1954 * @return string HTML for the icon
1955 */
1956 public function getIcon($table, $row, $enabledClickMenuItems = '')
1957 {
1958 // Initialization
1959 $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
1960 $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
1961 $this->counter++;
1962 // The icon with link
1963 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
1964 $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid'], true, '', $enabledClickMenuItems);
1965 }
1966 return $icon;
1967 }
1968
1969 /**
1970 * Creates processed values for all field names in $fieldList based on values from $row array.
1971 * The result is 'returned' through $info which is passed as a reference
1972 *
1973 * @param string $table Table name
1974 * @param string $fieldList Comma separated list of fields.
1975 * @param array $row Record from which to take values for processing.
1976 * @param array $info Array to which the processed values are added.
1977 * @return void
1978 */
1979 public function getProcessedValue($table, $fieldList, array $row, array &$info)
1980 {
1981 // Splitting values from $fieldList
1982 $fieldArr = explode(',', $fieldList);
1983 // Traverse fields from $fieldList
1984 foreach ($fieldArr as $field) {
1985 if ($row[$field]) {
1986 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
1987 . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
1988 }
1989 }
1990 }
1991
1992 /**
1993 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
1994 *
1995 * @param string $table Tablename of table to test
1996 * @param array $row Record row.
1997 * @return bool Returns TRUE, if disabled.
1998 */
1999 public function isDisabled($table, $row)
2000 {
2001 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2002 return $enableCols['disabled'] && $row[$enableCols['disabled']]
2003 || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2004 || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2005 }
2006
2007 /**
2008 * Returns icon for "no-edit" of a record.
2009 * Basically, the point is to signal that this record could have had an edit link if
2010 * the circumstances were right. A placeholder for the regular edit icon...
2011 *
2012 * @param string $label Label key from LOCAL_LANG
2013 * @return string IMG tag for icon.
2014 */
2015 public function noEditIcon($label = 'noEditItems')
2016 {
2017 $title = $this->getLanguageService()->getLL($label, true);
2018 return '<span title="' . $title . '">' . $this->iconFactory->getIcon('status-status-edit-read-only', Icon::SIZE_SMALL)->render() . '</span>';
2019 }
2020
2021 /**
2022 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
2023 * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...)
2024 * are filtered out. So what is left is basically all tables which makes sense to list content from.
2025 *
2026 * @return array
2027 */
2028 protected function cleanTableNames()
2029 {
2030 // Get all table names:
2031 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2032 // Unset common names:
2033 unset($tableNames['pages']);
2034 unset($tableNames['static_template']);
2035 unset($tableNames['sys_filemounts']);
2036 unset($tableNames['sys_action']);
2037 unset($tableNames['sys_workflows']);
2038 unset($tableNames['be_users']);
2039 unset($tableNames['be_groups']);
2040 $allowedTableNames = array();
2041 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2042 if (is_array($tableNames)) {
2043 foreach ($tableNames as $k => $v) {
2044 if (!$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->getBackendUser()->check('tables_select', $k)) {
2045 $allowedTableNames['table_' . $k] = $k;
2046 }
2047 }
2048 }
2049 return $allowedTableNames;
2050 }
2051
2052 /*****************************************
2053 *
2054 * External renderings
2055 *
2056 *****************************************/
2057
2058 /**
2059 * Creates a menu of the tables that can be listed by this function
2060 * Only tables which has records on the page will be included.
2061 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2062 *
2063 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2064 * @return string HTML output.
2065 */
2066 public function getTableMenu($id)
2067 {
2068 // Initialize:
2069 $this->activeTables = array();
2070 $theTables = array('tt_content');
2071 // External tables:
2072 if (is_array($this->externalTables)) {
2073 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2074 }
2075 $out = '';
2076 // Traverse tables to check:
2077 foreach ($theTables as $tName) {
2078 // Check access and whether the proper extensions are loaded:
2079 if ($this->getBackendUser()->check('tables_select', $tName)
2080 && (isset($this->externalTables[$tName])
2081 || GeneralUtility::inList('fe_users,tt_content', $tName)
2082 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2083 )
2084 ) {
2085 // Make query to count records from page:
2086 $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2087 . BackendUtility::deleteClause($tName) . BackendUtility::versioningPlaceholderClause($tName));
2088 // If records were found (or if "tt_content" is the table...):
2089 if ($c || GeneralUtility::inList('tt_content', $tName)) {
2090 // Add row to menu:
2091 $out .= '
2092 <td><a href="#' . $tName . '" title="' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true) . '"></a>'
2093 . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render()
2094 . '</td>';
2095 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2096 $title = $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true)
2097 . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', true);
2098 $this->activeTables[$tName] = '<span title="' . $title . '">'
2099 . $this->iconFactory->getIconForRecord($tName, array(), Icon::SIZE_SMALL)->render()
2100 . '</span>'
2101 . '&nbsp;' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], true);
2102 }
2103 }
2104 }
2105 // Wrap cells in table tags:
2106 $out = '
2107 <!--
2108 Menu of tables on the page (table menu)
2109 -->
2110 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2111 <tr>' . $out . '
2112 </tr>
2113 </table>';
2114 // Return the content:
2115 return $out;
2116 }
2117
2118 /**
2119 * Create thumbnail code for record/field but not linked
2120 *
2121 * @param mixed[] $row Record array
2122 * @param string $table Table (record is from)
2123 * @param string $field Field name for which thumbnail are to be rendered.
2124 * @return string HTML for thumbnails, if any.
2125 */
2126 public function getThumbCodeUnlinked($row, $table, $field)
2127 {
2128 return BackendUtility::thumbCode($row, $table, $field, '', '', null, 0, '', '', false);
2129 }
2130
2131 /**
2132 * Checks whether translated Content Elements exist in the desired language
2133 * If so, deny creating new ones via the UI
2134 *
2135 * @param array $contentElements
2136 * @param int $language
2137 * @return bool
2138 */
2139 protected function checkIfTranslationsExistInLanguage(array $contentElements, $language)
2140 {
2141 // If in default language, you may always create new entries
2142 // Also, you may override this strict behavior via user TS Config
2143 // If you do so, you're on your own and cannot rely on any support by the TYPO3 core
2144 // We jump out here since we don't need to do the expensive loop operations
2145 $allowInconsistentLanguageHandling = BackendUtility::getModTSconfig($this->id, 'mod.web_layout.allowInconsistentLanguageHandling');
2146 if ($language === 0 || $allowInconsistentLanguageHandling['value'] === '1') {
2147 return false;
2148 }
2149 /**
2150 * Build up caches
2151 */
2152 if (!isset($this->languageHasTranslationsCache[$language])) {
2153 foreach ($contentElements as $columns) {
2154 foreach ($columns as $contentElement) {
2155 if ((int)$contentElement['l18n_parent'] === 0) {
2156 $this->languageHasTranslationsCache[$language]['hasStandAloneContent'] = true;
2157 }
2158 if ((int)$contentElement['l18n_parent'] > 0) {
2159 $this->languageHasTranslationsCache[$language]['hasTranslations'] = true;
2160 }
2161 }
2162 }
2163 // Check whether we have a mix of both
2164 if ($this->languageHasTranslationsCache[$language]['hasStandAloneContent']
2165 && $this->languageHasTranslationsCache[$language]['hasTranslations']
2166 ) {
2167 $message = GeneralUtility::makeInstance(
2168 FlashMessage::class,
2169 sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $this->languageIconTitles[$language]['title']),
2170 sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), $this->languageIconTitles[$language]['title']),
2171 FlashMessage::WARNING
2172 );
2173 $service = GeneralUtility::makeInstance(FlashMessageService::class);
2174 $queue = $service->getMessageQueueByIdentifier();
2175 $queue->addMessage($message);
2176 }
2177 }
2178 if ($this->languageHasTranslationsCache[$language]['hasTranslations']) {
2179 return true;
2180 }
2181 return false;
2182 }
2183
2184 /**
2185 * @return BackendLayoutView
2186 */
2187 protected function getBackendLayoutView()
2188 {
2189 return GeneralUtility::makeInstance(BackendLayoutView::class);
2190 }
2191
2192 /**
2193 * @return BackendUserAuthentication
2194 */
2195 protected function getBackendUser()
2196 {
2197 return $GLOBALS['BE_USER'];
2198 }
2199
2200 /**
2201 * @return DatabaseConnection
2202 */
2203 protected function getDatabase()
2204 {
2205 return $GLOBALS['TYPO3_DB'];
2206 }
2207
2208 /**
2209 * @return PageLayoutController
2210 */
2211 protected function getPageLayoutController()
2212 {
2213 return $GLOBALS['SOBE'];
2214 }
2215 }