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