[BUGFIX] Web->Page now respects labels set by TSConfig for plugins
[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']) && $columnConfig['name'] !== '') {
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 $fileReferences = BackendUtility::resolveFileReferences('tt_content', 'image', $row);
1498 if (!empty($fileReferences)) {
1499 $linkedContent = '';
1500 foreach ($fileReferences as $fileReference) {
1501 $linkedContent .= htmlspecialchars($fileReference->getDescription()) . '<br />';
1502 }
1503 $out .= $this->linkEditContent($linkedContent, $row);
1504 unset($linkedContent);
1505 }
1506 }
1507 }
1508 break;
1509 case 'bullets':
1510
1511 case 'table':
1512
1513 case 'mailform':
1514 if ($row['bodytext']) {
1515 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1516 }
1517 break;
1518 case 'uploads':
1519 if ($row['media']) {
1520 $out .= $this->thumbCode($row, 'tt_content', 'media') . '<br />';
1521 }
1522 break;
1523 case 'multimedia':
1524 if ($row['multimedia']) {
1525 $out .= $this->renderText($row['multimedia']) . '<br />';
1526 $out .= $this->renderText($row['parameters']) . '<br />';
1527 }
1528 break;
1529 case 'menu':
1530 $contentType = $this->CType_labels[$row['CType']];
1531 $out .= '<strong>' . htmlspecialchars($contentType) . '</strong><br />';
1532 // Add Menu Type
1533 $menuTypeLabel = $this->getLanguageService()->sL(
1534 BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
1535 );
1536 $out .= $menuTypeLabel !== '' ? $menuTypeLabel : 'invalid menu type';
1537 if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
1538 // Show pages if menu type is not "Sitemap"
1539 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
1540 }
1541 break;
1542 case 'shortcut':
1543 if (!empty($row['records'])) {
1544 $shortcutContent = array();
1545 $recordList = explode(',', $row['records']);
1546 foreach ($recordList as $recordIdentifier) {
1547 $split = BackendUtility::splitTable_Uid($recordIdentifier);
1548 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
1549 $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
1550 if (is_array($shortcutRecord)) {
1551 $icon = IconUtility::getSpriteIconForRecord($tableName, $shortcutRecord);
1552 $icon = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon($icon, $tableName,
1553 $shortcutRecord['uid'], 1, '', '+copy,info,edit,view');
1554 $shortcutContent[] = $icon
1555 . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
1556 }
1557 }
1558 $out .= implode('<br />', $shortcutContent) . '<br />';
1559 }
1560 break;
1561 case 'list':
1562 $hookArr = array();
1563 $hookOut = '';
1564 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1565 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1566 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1567 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1568 }
1569 if (count($hookArr) > 0) {
1570 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1571 foreach ($hookArr as $_funcRef) {
1572 $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1573 }
1574 }
1575 if ((string)$hookOut !== '') {
1576 $out .= $hookOut;
1577 } elseif (!empty($row['list_type'])) {
1578 $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1579 if (!empty($label)) {
1580 $out .= '<strong>' . $this->getLanguageService()->sL($label, TRUE) . '</strong><br />';
1581 } else {
1582 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1583 $out .= GeneralUtility::makeInstance(
1584 FlashMessage::class,
1585 htmlspecialchars($message),
1586 '',
1587 FlashMessage::WARNING
1588 )->render();
1589 }
1590 } elseif (!empty($row['select_key'])) {
1591 $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), TRUE)
1592 . ' ' . $row['select_key'] . '<br />';
1593 } else {
1594 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1595 }
1596 $out .= $this->getLanguageService()->sL(
1597 BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1598 TRUE
1599 ) . '<br />';
1600 break;
1601 case 'script':
1602 $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), TRUE)
1603 . ' ' . $row['select_key'] . '<br />';
1604 $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1605 $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1606 break;
1607 default:
1608 $contentType = $this->CType_labels[$row['CType']];
1609
1610 if (isset($contentType)) {
1611 $out .= '<strong>' . htmlspecialchars($contentType) . '</strong><br />';
1612 if ($row['bodytext']) {
1613 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1614 }
1615 if ($row['image']) {
1616 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1617 }
1618 } else {
1619 $message = sprintf(
1620 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1621 $row['CType']
1622 );
1623 $out .= GeneralUtility::makeInstance(
1624 FlashMessage::class,
1625 htmlspecialchars($message),
1626 '',
1627 FlashMessage::WARNING
1628 )->render();
1629 }
1630 }
1631 }
1632 // Wrap span-tags:
1633 $out = '
1634 <span class="exampleContent">' . $out . '</span>';
1635 // Add header:
1636 $out = $outHeader . $out;
1637 // Add RTE button:
1638 if ($isRTE) {
1639 $out .= $this->linkRTEbutton($row);
1640 }
1641 // Return values:
1642 if ($this->isDisabled('tt_content', $row)) {
1643 return '<span class="text-muted">' . $out . '</span>';
1644 } else {
1645 return $out;
1646 }
1647 }
1648
1649 /**
1650 * Generates a list of selected pages or categories for the CType menu
1651 *
1652 * @param array $row row from pages
1653 * @return string
1654 */
1655 protected function generateListForCTypeMenu(array $row) {
1656 $table = 'pages';
1657 $field = 'pages';
1658 // get categories instead of pages
1659 if (strpos($row['menu_type'], 'categorized_') !== FALSE) {
1660 $table = 'sys_category';
1661 $field = 'selected_categories';
1662 }
1663 if (trim($row[$field]) === '') {
1664 return '';
1665 }
1666 $content = '';
1667 $uidList = explode(',', $row[$field]);
1668 foreach ($uidList as $uid) {
1669 $uid = (int)$uid;
1670 $record = BackendUtility::getRecord($table, $uid, 'title');
1671 $content .= '<br>' . $record['title'] . ' (' .$uid. ')';
1672 }
1673 return $content;
1674 }
1675
1676 /**
1677 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1678 * Selects across columns, but within in the same PID. Columns are expect to be the same
1679 * for translations and original but this may be a conceptual error (?)
1680 *
1681 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1682 * @param int $id Page pid
1683 * @param int $lP Sys language UID
1684 * @return array Modified $defLanguageCount
1685 */
1686 public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) {
1687 if ($lP && count($defLanguageCount)) {
1688 // Select all translations here:
1689 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . (int)$lP
1690 . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')');
1691 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1692 // Flip uids:
1693 $defLanguageCount = array_flip($defLanguageCount);
1694 // Traverse any selected elements and unset original UID if any:
1695 $rowArr = $this->getResult($result);
1696 foreach ($rowArr as $row) {
1697 unset($defLanguageCount[$row['l18n_parent']]);
1698 }
1699 // Flip again:
1700 $defLanguageCount = array_keys($defLanguageCount);
1701 }
1702 return $defLanguageCount;
1703 }
1704
1705 /**
1706 * Creates button which is used to create copies of records..
1707 *
1708 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1709 * @param int $lP Sys language UID
1710 * @return string "Copy languages" button, if available.
1711 */
1712 public function newLanguageButton($defLanguageCount, $lP) {
1713 if (!$this->doEdit || count($defLanguageCount) === 0 || !$lP) {
1714 return '';
1715 }
1716 $params = '';
1717 foreach ($defLanguageCount as $uidVal) {
1718 $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP;
1719 }
1720 // Copy for language:
1721 $onClick = 'window.location.href=\'' . $this->getPageLayoutController()->doc->issueCommand($params) . '\'; return false;';
1722 $theNewButton = '<div class="t3-page-lang-copyce">' .
1723 $this->getPageLayoutController()->doc->t3Button(
1724 $onClick,
1725 $this->getLanguageService()->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']'
1726 ) . '</div>';
1727 return $theNewButton;
1728 }
1729
1730 /**
1731 * Creates onclick-attribute content for a new content element
1732 *
1733 * @param int $id Page id where to create the element.
1734 * @param int $colPos Preset: Column position value
1735 * @param int $sys_language Preset: Sys langauge value
1736 * @return string String for onclick attribute.
1737 * @see getTable_tt_content()
1738 */
1739 public function newContentElementOnClick($id, $colPos, $sys_language) {
1740 if ($this->option_newWizard) {
1741 $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $id . '&colPos=' . $colPos
1742 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1743 . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';';
1744 } else {
1745 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1746 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language, $this->backPath);
1747 }
1748 return $onClick;
1749 }
1750
1751 /**
1752 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
1753 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1754 *
1755 * @param string $str String to link. Must be prepared for HTML output.
1756 * @param array $row The row.
1757 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1758 * @see getTable_tt_content()
1759 */
1760 public function linkEditContent($str, $row) {
1761 $addButton = '';
1762 $onClick = '';
1763 if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1764 // Setting onclick action for content link:
1765 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit', $this->backPath);
1766 }
1767 // Return link
1768 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick)
1769 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">' . $str . '</a>' . $addButton : $str;
1770 }
1771
1772 /**
1773 * Adds a button to edit the row in RTE wizard
1774 *
1775 * @param array $row The row of tt_content element
1776 * @return string Button to click if you want to edit in RTE wizard.
1777 */
1778 public function linkRTEbutton($row) {
1779 $params = array();
1780 $params['table'] = 'tt_content';
1781 $params['uid'] = $row['uid'];
1782 $params['pid'] = $row['pid'];
1783 $params['field'] = 'bodytext';
1784 $params['returnUrl'] = GeneralUtility::linkThisScript();
1785 $RTEonClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_rte', array('P' => $params))) . ';return false;';
1786 $addButton = $this->option_showBigButtons && $this->doEdit
1787 ? $this->getPageLayoutController()->doc->t3Button($RTEonClick, $this->getLanguageService()->getLL('editInRTE'))
1788 : '';
1789 return $addButton;
1790 }
1791
1792 /**
1793 * Make selector box for creating new translation in a language
1794 * Displays only languages which are not yet present for the current page and
1795 * that are not disabled with page TS.
1796 *
1797 * @param int $id Page id for which to create a new language (pages_language_overlay record)
1798 * @return string <select> HTML element (if there were items for the box anyways...)
1799 * @see getTable_tt_content()
1800 */
1801 public function languageSelector($id) {
1802 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1803 // First, select all
1804 $res = $this->getPageLayoutController()->exec_languageQuery(0);
1805 $langSelItems = array();
1806 $langSelItems[0] = '
1807 <option value="0"></option>';
1808 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1809 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1810 $langSelItems[$row['uid']] = '
1811 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1812 }
1813 }
1814 // Then, subtract the languages which are already on the page:
1815 $res = $this->getPageLayoutController()->exec_languageQuery($id);
1816 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1817 unset($langSelItems[$row['uid']]);
1818 }
1819 // Remove disallowed languages
1820 if (count($langSelItems) > 1
1821 && !$this->getBackendUser()->user['admin']
1822 && $this->getBackendUser()->groupData['allowed_languages'] !== ''
1823 ) {
1824 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
1825 if (count($allowed_languages)) {
1826 foreach ($langSelItems as $key => $value) {
1827 if (!isset($allowed_languages[$key]) && $key != 0) {
1828 unset($langSelItems[$key]);
1829 }
1830 }
1831 }
1832 }
1833 // Remove disabled languages
1834 $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1835 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1836 ? GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], TRUE)
1837 : array();
1838 if (count($langSelItems) && count($disableLanguages)) {
1839 foreach ($disableLanguages as $language) {
1840 if ($language != 0 && isset($langSelItems[$language])) {
1841 unset($langSelItems[$language]);
1842 }
1843 }
1844 }
1845 // If any languages are left, make selector:
1846 if (count($langSelItems) > 1) {
1847 $onChangeContent = 'window.location.href=\'' . $this->backPath . 'alt_doc.php?&edit[pages_language_overlay]['
1848 . $id . ']=new&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRecord['doktype']
1849 . '&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='
1850 . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\'';
1851 return $this->getLanguageService()->getLL('new_language', TRUE)
1852 . ': <select name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">
1853 ' . implode('', $langSelItems) . '
1854 </select><br /><br />';
1855 }
1856 }
1857 return '';
1858 }
1859
1860 /**
1861 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1862 *
1863 * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
1864 * @param string $table Table name defaulting to tt_content
1865 * @return array The selected rows returned in this array.
1866 */
1867 public function getResult($result, $table = 'tt_content') {
1868 $output = array();
1869 // Traverse the result:
1870 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1871 BackendUtility::workspaceOL($table, $row, -99, TRUE);
1872 if ($row) {
1873 // Add the row to the array:
1874 $output[] = $row;
1875 }
1876 }
1877 $this->generateTtContentDataArray($output);
1878 // Return selected records
1879 return $output;
1880 }
1881
1882 /********************************
1883 *
1884 * Various helper functions
1885 *
1886 ********************************/
1887
1888 /**
1889 * Initializes the clipboard for generating paste links
1890 *
1891 * @return void
1892 *
1893 * @see \TYPO3\CMS\Recordlist\RecordList::main()
1894 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
1895 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
1896 */
1897 protected function initializeClipboard() {
1898 // Start clipboard
1899 $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
1900
1901 // Initialize - reads the clipboard content from the user session
1902 $this->clipboard->initializeClipboard();
1903
1904 // This locks the clipboard to the Normal for this request.
1905 $this->clipboard->lockToNormal();
1906
1907 // Clean up pad
1908 $this->clipboard->cleanCurrent();
1909
1910 // Save the clipboard content
1911 $this->clipboard->endClipboard();
1912 }
1913
1914 /**
1915 * Generates the data for previous and next elements which is needed for movements.
1916 *
1917 * @param array $rowArray
1918 * @return void
1919 */
1920 protected function generateTtContentDataArray(array $rowArray) {
1921 if (empty($this->tt_contentData)) {
1922 $this->tt_contentData = array(
1923 'nextThree' => array(),
1924 'next' => array(),
1925 'prev' => array(),
1926 );
1927 }
1928 foreach ($rowArray as $key => $value) {
1929 // Create the list of the next three ids (for editing links...)
1930 for ($i = 0; $i < $this->nextThree; $i++) {
1931 if (isset($rowArray[$key - $i])
1932 && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
1933 ) {
1934 $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
1935 }
1936 }
1937
1938 // Create information for next and previous content elements
1939 if (isset($rowArray[$key - 1])) {
1940 if (isset($rowArray[$key - 2])) {
1941 $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
1942 } else {
1943 $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
1944 }
1945 $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
1946 }
1947 }
1948 }
1949
1950 /**
1951 * Counts and returns the number of records on the page with $pid
1952 *
1953 * @param string $table Table name
1954 * @param int $pid Page id
1955 * @return int Number of records.
1956 */
1957 public function numberOfRecords($table, $pid) {
1958 $count = 0;
1959 if ($GLOBALS['TCA'][$table]) {
1960 $where = 'pid=' . (int)$pid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table);
1961 $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
1962 }
1963 return (int)$count;
1964 }
1965
1966 /**
1967 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1968 *
1969 * @param string $input Input string
1970 * @return string Output string
1971 */
1972 public function renderText($input) {
1973 $input = strip_tags($input);
1974 $input = GeneralUtility::fixed_lgd_cs($input, 1500);
1975 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', FALSE));
1976 }
1977
1978 /**
1979 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1980 *
1981 * @param string $table Table name
1982 * @param array $row Record array
1983 * @return string HTML for the icon
1984 */
1985 public function getIcon($table, $row) {
1986 // Initialization
1987 $altText = BackendUtility::getRecordIconAltText($row, $table);
1988 $icon = IconUtility::getSpriteIconForRecord($table, $row, array('title' => $altText));
1989 $this->counter++;
1990 // The icon with link
1991 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
1992 $icon = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon($icon, $table, $row['uid']);
1993 }
1994 return $icon;
1995 }
1996
1997 /**
1998 * Creates processed values for all field names in $fieldList based on values from $row array.
1999 * The result is 'returned' through $info which is passed as a reference
2000 *
2001 * @param string $table Table name
2002 * @param string $fieldList Comma separated list of fields.
2003 * @param array $row Record from which to take values for processing.
2004 * @param array $info Array to which the processed values are added.
2005 * @return void
2006 */
2007 public function getProcessedValue($table, $fieldList, array $row, array &$info) {
2008 // Splitting values from $fieldList
2009 $fieldArr = explode(',', $fieldList);
2010 // Traverse fields from $fieldList
2011 foreach ($fieldArr as $field) {
2012 if ($row[$field]) {
2013 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
2014 . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
2015 }
2016 }
2017 }
2018
2019 /**
2020 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2021 *
2022 * @param string $table Tablename of table to test
2023 * @param array $row Record row.
2024 * @return bool Returns TRUE, if disabled.
2025 */
2026 public function isDisabled($table, $row) {
2027 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2028 return $enableCols['disabled'] && $row[$enableCols['disabled']]
2029 || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2030 || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2031 }
2032
2033 /**
2034 * Will perform "word-wrapping" on the input string. What it does is to split by space or line break,
2035 * then find any word longer than $max and if found, a hyphen is inserted.
2036 * Works well on normal texts, little less well when HTML is involved (since much HTML will have
2037 * long strings that will be broken).
2038 *
2039 * @param string $content Content to word-wrap.
2040 * @param int $max Max number of chars in a word before it will be wrapped.
2041 * @param string $char Character to insert when wrapping.
2042 * @return string Processed output.
2043 * @deprecated since 6.2 - will be removed two versions later; use CSS instead (word-break: break-all;)
2044 */
2045 public function wordWrapper($content, $max = 50, $char = ' -') {
2046 GeneralUtility::logDeprecatedFunction();
2047 $array = preg_split('/[ ' . LF . ']/', $content);
2048 foreach ($array as $val) {
2049 if (strlen($val) > $max) {
2050 $content = str_replace($val, substr(chunk_split($val, $max, $char), 0, -1), $content);
2051 }
2052 }
2053 return $content;
2054 }
2055
2056 /**
2057 * Returns icon for "no-edit" of a record.
2058 * Basically, the point is to signal that this record could have had an edit link if
2059 * the circumstances were right. A placeholder for the regular edit icon...
2060 *
2061 * @param string $label Label key from LOCAL_LANG
2062 * @return string IMG tag for icon.
2063 */
2064 public function noEditIcon($label = 'noEditItems') {
2065 return IconUtility::getSpriteIcon(
2066 'status-edit-read-only',
2067 array('title' => $this->getLanguageService()->getLL($label, TRUE))
2068 );
2069 }
2070
2071 /**
2072 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
2073 * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...)
2074 * are filtered out. So what is left is basically all tables which makes sense to list content from.
2075 *
2076 * @return array
2077 */
2078 protected function cleanTableNames() {
2079 // Get all table names:
2080 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2081 // Unset common names:
2082 unset($tableNames['pages']);
2083 unset($tableNames['static_template']);
2084 unset($tableNames['sys_filemounts']);
2085 unset($tableNames['sys_action']);
2086 unset($tableNames['sys_workflows']);
2087 unset($tableNames['be_users']);
2088 unset($tableNames['be_groups']);
2089 $allowedTableNames = array();
2090 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2091 if (is_array($tableNames)) {
2092 foreach ($tableNames as $k => $v) {
2093 if ($this->getBackendUser()->check('tables_select', $k)) {
2094 $allowedTableNames['table_' . $k] = $k;
2095 }
2096 }
2097 }
2098 return $allowedTableNames;
2099 }
2100
2101 /**
2102 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns TRUE.
2103 * Used to determine if the RTE button should be displayed.
2104 *
2105 * @param string $table Table name
2106 * @param array $row Record row (needed, if there are RTE dependencies based on other fields in the record)
2107 * @param string $field Field name
2108 * @return bool Returns TRUE if the rich text editor would be enabled/available for the field name specified.
2109 */
2110 public function isRTEforField($table, $row, $field) {
2111 $specConf = $this->getSpecConfForField($table, $row, $field);
2112 if (!count($specConf)) {
2113 return FALSE;
2114 }
2115 $p = BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2116 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
2117 BackendUtility::fixVersioningPid($table, $row);
2118 list($tscPID, $thePidValue) = BackendUtility::getTSCpid($table, $row['uid'], $row['pid']);
2119 // If the pid-value is not negative (that is, a pid could NOT be fetched)
2120 if ($thePidValue >= 0) {
2121 if (!isset($this->rteSetup[$tscPID])) {
2122 $this->rteSetup[$tscPID] = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
2123 }
2124 $RTEtypeVal = BackendUtility::getTCAtypeValue($table, $row);
2125 $thisConfig = BackendUtility::RTEsetup($this->rteSetup[$tscPID]['properties'], $table, $field, $RTEtypeVal);
2126 if (!$thisConfig['disabled']) {
2127 return TRUE;
2128 }
2129 }
2130 }
2131 return FALSE;
2132 }
2133
2134 /**
2135 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
2136 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
2137 *
2138 * @param string $table Table name
2139 * @param array $row Record array
2140 * @param string $field Field name
2141 * @return array Spec. conf (if available)
2142 * @access private
2143 * @see isRTEforField()
2144 */
2145 public function getSpecConfForField($table, $row, $field) {
2146 // Get types-configuration for the record:
2147 $types_fieldConfig = BackendUtility::getTCAtypes($table, $row);
2148 // Find the given field and return the spec key value if found:
2149 if (is_array($types_fieldConfig)) {
2150 foreach ($types_fieldConfig as $vConf) {
2151 if ($vConf['field'] == $field) {
2152 return $vConf['spec'];
2153 }
2154 }
2155 }
2156 return array();
2157 }
2158
2159 /*****************************************
2160 *
2161 * External renderings
2162 *
2163 *****************************************/
2164
2165 /**
2166 * Creates a menu of the tables that can be listed by this function
2167 * Only tables which has records on the page will be included.
2168 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2169 *
2170 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2171 * @return string HTML output.
2172 */
2173 public function getTableMenu($id) {
2174 // Initialize:
2175 $this->activeTables = array();
2176 $theTables = array('tt_content');
2177 // External tables:
2178 if (is_array($this->externalTables)) {
2179 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2180 }
2181 $out = '';
2182 // Traverse tables to check:
2183 foreach ($theTables as $tName) {
2184 // Check access and whether the proper extensions are loaded:
2185 if ($this->getBackendUser()->check('tables_select', $tName)
2186 && (isset($this->externalTables[$tName])
2187 || GeneralUtility::inList('fe_users,tt_content', $tName)
2188 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2189 )
2190 ) {
2191 // Make query to count records from page:
2192 $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2193 . BackendUtility::deleteClause($tName) . BackendUtility::versioningPlaceholderClause($tName));
2194 // If records were found (or if "tt_content" is the table...):
2195 if ($c || GeneralUtility::inList('tt_content', $tName)) {
2196 // Add row to menu:
2197 $out .= '
2198 <td><a href="#' . $tName . '"></a>' . IconUtility::getSpriteIconForRecord(
2199 $tName,
2200 array(),
2201 array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE))
2202 ) . '</td>';
2203 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2204 $this->activeTables[$tName] = IconUtility::getSpriteIconForRecord(
2205 $tName,
2206 array(),
2207 array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE)
2208 . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', TRUE))
2209 ) . '&nbsp;' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE);
2210 }
2211 }
2212 }
2213 // Wrap cells in table tags:
2214 $out = '
2215 <!--
2216 Menu of tables on the page (table menu)
2217 -->
2218 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2219 <tr>' . $out . '
2220 </tr>
2221 </table>';
2222 // Return the content:
2223 return $out;
2224 }
2225
2226 /**
2227 * @return BackendLayoutView
2228 */
2229 protected function getBackendLayoutView() {
2230 return GeneralUtility::makeInstance(BackendLayoutView::class);
2231 }
2232
2233 /**
2234 * @return BackendUserAuthentication
2235 */
2236 protected function getBackendUser() {
2237 return $GLOBALS['BE_USER'];
2238 }
2239
2240 /**
2241 * @return DatabaseConnection
2242 */
2243 protected function getDatabase() {
2244 return $GLOBALS['TYPO3_DB'];
2245 }
2246
2247 /**
2248 * @return LanguageService
2249 */
2250 protected function getLanguageService() {
2251 return $GLOBALS['LANG'];
2252 }
2253
2254 /**
2255 * @return PageLayoutController
2256 */
2257 protected function getPageLayoutController() {
2258 return $GLOBALS['SOBE'];
2259 }
2260
2261 /**
2262 * @return DocumentTemplate
2263 */
2264 protected function getDocumentTemplate() {
2265 return $GLOBALS['TBE_TEMPLATE'];
2266 }
2267
2268 }