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