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