2 namespace TYPO3\CMS\Backend\View
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
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
;
29 * Child class for the Web > Page module
31 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 class PageLayoutView
extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList
{
36 * If TRUE, users/groups are shown in the page info box.
40 public $pI_showUser = 0;
43 * The number of successive records to edit when showing content elements.
47 public $nextThree = 3;
50 * If TRUE, disables the edit-column icon for tt_content elements
54 public $pages_noEditColumns = 0;
57 * If TRUE, shows big buttons for editing page properties, moving, creating elements etc. in the columns view.
61 public $option_showBigButtons = 1;
64 * If TRUE, new-wizards are linked to rather than the regular new-element list.
68 public $option_newWizard = 1;
71 * If set to "1", will link a big button to content element wizard.
75 public $ext_function = 0;
78 * If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
85 * Age prefixes for displaying times. May be set externally to localized values.
89 public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
92 * Array of tables to be listed by the Web > Page module in addition to the default tables.
96 public $externalTables = array();
99 * "Pseudo" Description -table name
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!
111 public $defLangBinding = FALSE;
114 * External, static: Configuration of tt_content element display:
118 public $tt_contentConfig = array(
120 // Boolean: Display info-marks or not
122 // Boolean: Display up/down arrows and edit icons for tt_content records
124 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown in the total width of the page
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)
131 'languageColsPointer' => 0,
133 // Displays hidden records as well
134 'sys_language_uid' => 0,
137 'activeCols' => '1,0,2,3'
138 // Which columns can be accessed by current BE user
142 * Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
146 public $activeTables = array();
151 public $tt_contentData = array(
152 'nextThree' => array(),
158 * Used to store labels for CTypes for tt_content elements
162 public $CType_labels = array();
165 * Used to store labels for the various fields in tt_content elements
169 public $itemLabels = array();
172 * Used to store the RTE setup of a particular page
176 protected $rteSetup = array();
179 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
181 protected $clipboard;
186 protected $plusPages = array();
193 public $ext_CALC_PERMS;
195 /*****************************************
199 *****************************************/
201 * Adds the code of a single table
203 * @param string $table Table name
204 * @param int $id Current page id
205 * @return string HTML for listing.
207 public function getTable($table, $id) {
208 if (isset($this->externalTables
[$table])) {
209 return $this->getExternalTables($id, $table);
211 // Branch out based on table name:
214 return $this->getTable_pages($id);
217 return $this->getTable_tt_content($id);
226 * Renders an external table from page id
228 * @param int $id Page id
229 * @param string $table Name of the table
230 * @return string HTML for the listing
232 public function getExternalTables($id, $table) {
233 $type = $this->getPageLayoutController()->MOD_SETTINGS
[$table];
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'];
244 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
249 * Renders records from the pages table from page id
250 * (Used to get information about the page tree content by "Web>Info"!)
252 * @param int $id Page id
253 * @return string HTML for the listing
255 public function getTable_pages($id) {
258 // Select clause for pages:
259 $delClause = BackendUtility
::deleteClause('pages') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1);
260 // Select current page:
262 // The root has a pseudo record in pageinfo...
263 $row = $this->getPageLayoutController()->pageinfo
;
265 $result = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'uid=' . (int)$id . $delClause);
266 $row = $this->getDatabase()->sql_fetch_assoc($result);
267 BackendUtility
::workspaceOL('pages', $row);
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'];
275 $this->fieldArray
= array('title','uid') +
array_keys($this->cleanTableNames());
278 $this->fieldArray
= array(
293 $this->fieldArray
= array(
306 // Getting select-depth:
307 $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS
['pages_levels'];
308 // Overriding a few things:
309 $this->no_noWrap
= 0;
311 $this->eCounter
= $this->firstElementNumber
;
312 // Creating elements:
313 list($flag, $code) = $this->fwd_rwd_nav();
319 $theRows = $this->pages_getTree($theRows, $row['uid'], $delClause . BackendUtility
::versioningPlaceholderClause('pages'), '', $depth);
320 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
321 $editUids[] = $row['uid'];
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'];
329 $out .= $this->pages_drawItem($sRow, $this->fieldArray
);
333 // Header line is drawn
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';
341 $this->getLanguageService()->getLL('editThisColumn'),
342 rtrim(trim($this->getLanguageService()->sL(BackendUtility
::getItemLabel('pages', $field))), ':')
344 $eI = '<a href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, $this->backPath
, ''))
345 . '" title="' . htmlspecialchars($iTitle) . '">' . IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
351 $theData[$field] = ' <strong>'
352 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
356 $theData[$field] = ' <strong>ID:</strong>';
359 if (substr($field, 0, 6) == 'table_') {
360 $f2 = substr($field, 6);
361 if ($GLOBALS['TCA'][$f2]) {
362 $theData[$field] = ' ' . IconUtility
::getSpriteIconForRecord($f2, array(), array(
363 'title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$f2]['ctrl']['title'], TRUE)
367 $theData[$field] = ' <strong>'
368 . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'], TRUE)
374 $out = BackendUtility
::cshItem($this->descrTable
, ('func_' . $pKey)) . '
375 <table class="t3-table typo3-page-pages">' .
377 $this->addelement(1, '', $theData) .
388 * Renders Content Elements from the tt_content table from page id
390 * @param int $id Page id
391 * @return string HTML for the listing
393 public function getTable_tt_content($id) {
394 $this->initializeLanguages();
395 $this->initializeClipboard();
397 $RTE = $this->getBackendUser()->isRTE();
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->loadExtJs();
404 $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . 'sysext/cms/layout/js/typo3pageModule.js');
405 // Get labels for CTypes and tt_content element fields in general:
406 $this->CType_labels
= array();
407 foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
408 $this->CType_labels
[$val[1]] = $this->getLanguageService()->sL($val[0]);
410 $this->itemLabels
= array();
411 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
412 $this->itemLabels
[$name] = $this->getLanguageService()->sL($val['label']);
414 $languageColumn = array();
416 // Select display mode:
417 // MULTIPLE column display mode, side by side:
418 if (!$this->tt_contentConfig
['single']) {
419 // Setting language list:
420 $langList = $this->tt_contentConfig
['sys_language_uid'];
421 if ($this->tt_contentConfig
['languageMode']) {
422 if ($this->tt_contentConfig
['languageColsPointer']) {
423 $langList = '0,' . $this->tt_contentConfig
['languageColsPointer'];
425 $langList = implode(',', array_keys($this->tt_contentConfig
['languageCols']));
427 $languageColumn = array();
429 $langListArr = GeneralUtility
::intExplode(',', $langList);
430 $defLanguageCount = array();
431 $defLangBinding = array();
432 // For each languages... :
433 // If not languageMode, then we'll only be through this once.
434 foreach ($langListArr as $lP) {
436 if (count($langListArr) === 1 ||
$lP === 0) {
437 $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
439 $showLanguage = ' AND sys_language_uid=' . $lP;
441 $cList = explode(',', $this->tt_contentConfig
['cols']);
445 // Select content records per column
446 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showHidden . $showLanguage);
447 // For each column, render the content into a variable:
448 foreach ($cList as $key) {
450 $defLanguageCount[$key] = array();
452 // Start wrapping div
453 $content[$key] .= '<div class="t3-page-ce-wrapper';
454 if (count($contentRecordsPerColumn[$key]) === 0) {
455 $content[$key] .= ' t3-page-ce-empty';
457 $content[$key] .= '">';
458 // Add new content at the top most position
460 <div class="t3-page-ce" id="' . str_replace('.', '', uniqid('', TRUE)) . '">
461 <div class="t3-page-ce-dropzone" id="colpos-' . $key . '-' . 'page-' . $id . '-' . uniqid('', TRUE) . '">
462 <div class="t3-page-ce-wrapper-new-ce">
463 <a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP))
464 . '" title="' . $this->getLanguageService()->getLL('newRecordHere', TRUE) . '">'
465 . IconUtility
::getSpriteIcon('actions-document-new') . '</a>
471 $rowArr = $contentRecordsPerColumn[$key];
472 $this->generateTtContentDataArray($rowArr);
473 foreach ((array)$rowArr as $rKey => $row) {
474 if ($this->tt_contentConfig
['languageMode']) {
475 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
476 if (!$this->defLangBinding
) {
477 $languageColumn[$key][$lP] .= $this->newLanguageButton(
478 $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
483 if (is_array($row) && !VersionState
::cast($row['t3ver_state'])->equals(VersionState
::DELETE_PLACEHOLDER
)) {
484 $singleElementHTML = '';
485 if (!$lP && ($this->defLangBinding ||
$row['sys_language_uid'] != -1)) {
486 $defLanguageCount[$key][] = $row['uid'];
488 $editUidList .= $row['uid'] . ',';
489 $disableMoveAndNewButtons = $this->defLangBinding
&& $lP > 0;
490 if (!$this->tt_contentConfig
['languageMode']) {
491 $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . str_replace('.', '', uniqid('', TRUE)) . '">';
493 $singleElementHTML .= $this->tt_content_drawHeader(
495 $this->tt_contentConfig
['showInfo'] ?
15 : 5,
496 $disableMoveAndNewButtons,
498 !$this->tt_contentConfig
['languageMode']
500 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
501 $innerContent = '<div ' . ($row['_ORIG_uid'] ?
' class="ver-element"' : '') . '>'
502 . $this->tt_content_drawItem($row, $isRTE) . '</div>';
503 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>'
504 . $this->tt_content_drawFooter($row);
505 // NOTE: this is the end tag for <div class="t3-page-ce-body">
506 // because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
507 $singleElementHTML .= '</div>';
508 $statusHidden = $this->isDisabled('tt_content', $row) ?
' t3-page-ce-hidden' : '';
509 $singleElementHTML = '<div class="t3-page-ce' . $statusHidden . '" id="element-tt_content-'
510 . $row['uid'] . '">' . $singleElementHTML . '</div>';
511 if ($this->tt_contentConfig
['languageMode']) {
512 $singleElementHTML .= '<div class="t3-page-ce">';
514 $singleElementHTML .= '<div class="t3-page-ce-dropzone" id="colpos-' . $key . '-' . 'page-' . $id .
515 '-' . str_replace('.', '', uniqid('', TRUE)) . '">';
516 // Add icon "new content element below"
517 if (!$disableMoveAndNewButtons) {
518 // New content element:
519 if ($this->option_newWizard
) {
520 $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $row['pid']
521 . '&sys_language_uid=' . $row['sys_language_uid'] . '&colPos=' . $row['colPos']
522 . '&uid_pid=' . -$row['uid'] .
523 '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\';';
525 $params = '&edit[tt_content][' . -$row['uid'] . ']=new';
526 $onClick = BackendUtility
::editOnClick($params, $this->backPath
);
528 $singleElementHTML .= '
529 <div class="t3-page-ce-wrapper-new-ce">
530 <a href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
531 . $this->getLanguageService()->getLL('newRecordHere', TRUE) . '">'
532 . IconUtility
::getSpriteIcon('actions-document-new') . '</a>
536 $singleElementHTML .= '</div></div>';
537 if ($this->defLangBinding
&& $this->tt_contentConfig
['languageMode']) {
538 $defLangBinding[$key][$lP][$row[$lP ?
'l18n_parent' : 'uid']] = $singleElementHTML;
540 $content[$key] .= $singleElementHTML;
543 unset($rowArr[$rKey]);
546 $content[$key] .= '</div>';
547 // Add new-icon link, header:
548 $newP = $this->newContentElementOnClick($id, $key, $lP);
549 $colTitle = BackendUtility
::getProcessedValue('tt_content', 'colPos', $key);
550 $tcaItems = GeneralUtility
::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $id, $this);
551 foreach ($tcaItems as $item) {
552 if ($item[1] == $key) {
553 $colTitle = $this->getLanguageService()->sL($item[0]);
557 $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
558 $editParam = $this->doEdit
&& count($rowArr)
559 ?
'&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
561 $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, $newP, $pasteP);
563 // For each column, fit the rendered content into a table cell:
565 if ($this->tt_contentConfig
['languageMode']) {
566 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
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),
577 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id
);
579 $grid = '<div class="t3-gridContainer"><table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%" class="t3-page-columns t3-gridTable">';
581 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
582 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
583 $grid .= '<colgroup>';
584 for ($i = 0; $i < $colCount; $i++
) {
585 $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
587 $grid .= '</colgroup>';
588 // Cycle through rows
589 for ($row = 1; $row <= $rowCount; $row++
) {
590 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
591 if (!isset($rowConfig)) {
595 for ($col = 1; $col <= $colCount; $col++
) {
596 $columnConfig = $rowConfig['columns.'][$col . '.'];
597 if (!isset($columnConfig)) {
600 // Which tt_content colPos should be displayed inside this cell
601 $columnKey = (int)$columnConfig['colPos'];
602 // Render the grid cell
603 $colSpan = (int)$columnConfig['colspan'];
604 $rowSpan = (int)$columnConfig['rowspan'];
605 $grid .= '<td valign="top"' .
606 ($colSpan > 0 ?
' colspan="' . $colSpan . '"' : '') .
607 ($rowSpan > 0 ?
' rowspan="' . $rowSpan . '"' : '') .
608 ' class="t3-gridCell t3-page-column t3-page-column-' . $columnKey .
609 ((!isset($columnConfig['colPos']) ||
$columnConfig['colPos'] === '') ?
' t3-gridCell-unassigned' : '') .
610 ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) ||
!GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos']) ?
' t3-gridCell-restricted' : '') .
611 ($colSpan > 0 ?
' t3-gridCell-width' . $colSpan : '') .
612 ($rowSpan > 0 ?
' t3-gridCell-height' . $rowSpan : '') . '">';
614 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
615 // If not, a new header without any buttons will be generated.
617 isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
618 && GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
620 $grid .= $head[$columnKey] . $content[$columnKey];
622 isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
623 && GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
625 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
627 isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
628 && !GeneralUtility
::inList($this->tt_contentConfig
['activeCols'], $columnConfig['colPos'])
630 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
631 ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
632 } elseif (isset($columnConfig['name']) && strlen($columnConfig['name']) > 0) {
633 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
634 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
636 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
643 $out .= $grid . '</table></div>';
646 $out .= BackendUtility
::cshItem($this->descrTable
, 'columns_multi');
648 // If language mode, then make another presentation:
649 // Notice that THIS presentation will override the value of $out!
650 // But it needs the code above to execute since $languageColumn is filled with content we need!
651 if ($this->tt_contentConfig
['languageMode']) {
652 // Get language selector:
653 $languageSelector = $this->languageSelector($id);
654 // Reset out - we will make new content here:
656 // Traverse languages found on the page and build up the table displaying them side by side:
659 foreach ($langListArr as $lP) {
663 <td valign="top" class="t3-page-lang-column">
664 <h3>' . htmlspecialchars($this->tt_contentConfig
['languageCols'][$lP]) . '</h3>
667 // "View page" icon is added:
668 $onClick = BackendUtility
::viewOnClick($this->id
, $this->backPath
, BackendUtility
::BEgetRootLine($this->id
), '', '', ('&L=' . $lP));
669 $viewLink = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . IconUtility
::getSpriteIcon('actions-document-view') . '</a>';
670 // Language overlay page header:
672 list($lpRecord) = BackendUtility
::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
673 BackendUtility
::workspaceOL('pages_language_overlay', $lpRecord);
674 $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
675 $lPLabel = $this->getPageLayoutController()->doc
->wrapClickMenuOnIcon(
676 IconUtility
::getSpriteIconForRecord('pages_language_overlay', $lpRecord),
677 'pages_language_overlay',
679 ) . $viewLink . ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
680 ?
'<a href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, $this->backPath
))
681 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">'
682 . IconUtility
::getSpriteIcon('actions-document-open') . '</a>'
684 ) . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($lpRecord['title'], 20));
686 $lPLabel = $viewLink;
689 <td nowrap="nowrap" class="t3-page-lang-column t3-page-lang-label">' . $lPLabel . '</td>';
692 $out .= '<tr>' . implode($cCont) . '</tr>';
693 $out .= '<tr>' . implode($sCont) . '</tr>';
694 // Traverse previously built content for the columns:
695 foreach ($languageColumn as $cKey => $cCont) {
698 <td valign="top" class="t3-gridCell t3-page-column t3-page-lang-column">' . implode(('</td>' . '
699 <td valign="top" class="t3-gridCell t3-page-column t3-page-lang-column">'), $cCont) . '</td>
701 if ($this->defLangBinding
) {
702 // "defLangBinding" mode
703 foreach ($defLanguageCount[$cKey] as $defUid) {
705 foreach ($langListArr as $lP) {
706 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
707 $this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP),
713 <td valign="top" class="t3-page-lang-column">' . implode(('</td>' . '
714 <td valign="top" class="t3-page-lang-column">'), $cCont) . '</td>
718 $cCont = array_fill(0, count($langListArr), ' ');
721 <td valign="top" class="t3-page-lang-column">' . implode(('</td>' . '
722 <td valign="top" class="t3-page-lang-column">'), $cCont) . '</td>
726 // Finally, wrap it all in a table and add the language selector on top of it:
727 $out = $languageSelector . '
728 <div class="t3-lang-gridContainer">
729 <table cellpadding="0" cellspacing="0" class="t3-page-langMode">
734 $out .= BackendUtility
::cshItem($this->descrTable
, 'language_list');
737 // SINGLE column mode (columns shown beneath each other):
738 if ($this->tt_contentConfig
['sys_language_uid'] == 0 ||
!$this->defLangBinding
) {
740 if ($this->defLangBinding
&& $this->tt_contentConfig
['sys_language_uid'] == 0) {
741 $showLanguage = ' AND sys_language_uid IN (0,-1)';
744 $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig
['sys_language_uid'];
745 $lP = $this->tt_contentConfig
['sys_language_uid'];
747 $cList = explode(',', $this->tt_contentConfig
['showSingleCol']);
749 // Expand the table to some preset dimensions:
752 <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>
753 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
754 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
755 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
758 // Select content records per column
759 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('tt_content', $id, array_values($cList), $showHidden . $showLanguage);
760 // Traverse columns to display top-on-top
761 foreach ($cList as $counter => $key) {
763 $rowArr = $contentRecordsPerColumn[$key];
764 $this->generateTtContentDataArray($rowArr);
765 $numberOfContentElementsInColumn = count($rowArr);
767 // 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:
768 if ($this->doEdit
&& $this->option_showBigButtons
&& !(int)$key && $numberOfContentElementsInColumn == 0) {
769 $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $id . '&colPos=' . (int)$key
770 . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl='
771 . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\';';
772 $theNewButton = $this->getPageLayoutController()->doc
->t3Button($onClick, $this->getLanguageService()->getLL('newPageContent'));
773 $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
778 // Traverse any selected elements:
779 foreach ($rowArr as $rKey => $row) {
780 if (is_array($row) && !VersionState
::cast($row['t3ver_state'])->equals(VersionState
::DELETE_PLACEHOLDER
)) {
782 $editUidList .= $row['uid'] . ',';
783 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
784 // Create row output:
788 <td valign="top">' . $this->tt_content_drawHeader($row) . '</td>
790 <td' . ($row['_ORIG_uid'] ?
' class="ver-element"' : '') . ' valign="top">'
791 . $this->tt_content_drawItem($row, $isRTE) . '</td>
793 // If the element was not the last element, add a divider line:
794 if ($c != $numberOfContentElementsInColumn) {
798 <td colspan="3"><img'
799 . IconUtility
::skinImg($this->backPath
, 'gfx/stiblet_medium2.gif', 'width="468" height="1"')
800 . ' class="c-divider" alt="" /></td>
804 unset($rowArr[$rKey]);
807 // Add spacer between sections in the vertical list
812 <td colspan="3"><br /><br /><br /><br /></td>
815 // Add section header:
816 $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig
['sys_language_uid']);
817 $pasteP = array('colPos' => $key, 'sys_language_uid' => $this->tt_contentConfig
['sys_language_uid']);
820 <!-- Column header: -->
823 <td valign="top" colspan="3">' . $this->tt_content_drawColHeader(
824 BackendUtility
::getProcessedValue('tt_content', 'colPos', $key),
825 $this->doEdit
&& count($rowArr) ?
'&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '',
828 ) . $theNewButton . '<br /></td>
830 // Finally, add the content from the records in this column:
833 // Finally, wrap all table rows in one, big table:
835 <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
839 $out .= BackendUtility
::cshItem($this->descrTable
, 'columns_single');
841 $out = '<br/><br/>' . $this->getPageLayoutController()->doc
->icons(1)
842 . 'Sorry, you cannot view a single language in this localization mode (Default Language Binding is enabled)<br/><br/>';
845 // Add the big buttons to page:
846 if ($this->option_showBigButtons
) {
848 if (!$this->getPageLayoutController()->current_sys_language
) {
849 if ($this->ext_CALC_PERMS
& 2) {
850 $bArray[0] = $this->getPageLayoutController()->doc
->t3Button(
851 BackendUtility
::editOnClick('&edit[pages][' . $id . ']=edit', $this->backPath
, ''),
852 $this->getLanguageService()->getLL('editPageProperties')
856 if ($this->doEdit
&& $this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
857 list($languageOverlayRecord) = BackendUtility
::getRecordsByField(
858 'pages_language_overlay',
861 'AND sys_language_uid=' . (int)$this->getPageLayoutController()->current_sys_language
863 $bArray[0] = $this->getPageLayoutController()->doc
->t3Button(
864 BackendUtility
::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . ']=edit',
865 $this->backPath
, ''),
866 $this->getLanguageService()->getLL('editPageProperties_curLang')
870 if ($this->ext_CALC_PERMS
& 4 ||
$this->ext_CALC_PERMS
& 2) {
871 $bArray[1] = $this->getPageLayoutController()->doc
->t3Button(
872 'window.location.href=\'' . $this->backPath
. 'move_el.php?table=pages&uid=' . $id
873 . '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\';',
874 $this->getLanguageService()->getLL('move_page')
877 if ($this->ext_CALC_PERMS
& 8) {
878 $bArray[2] = $this->getPageLayoutController()->doc
->t3Button(
879 'window.location.href=\'' . $this->backPath
. 'db_new.php?id=' . $id
880 . '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\';',
881 $this->getLanguageService()->getLL('newPage2')
884 if ($this->doEdit
&& $this->ext_function
== 1) {
885 $bArray[3] = $this->getPageLayoutController()->doc
->t3Button(
886 'window.location.href=\'db_new_content_el.php?id=' . $id
887 . '&sys_language_uid=' . $this->getPageLayoutController()->current_sys_language
888 . '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\';',
889 $this->getLanguageService()->getLL('newPageContent2')
893 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
895 <td>' . implode('</td>
896 <td>', $bArray) . '</td>
897 <td>' . BackendUtility
::cshItem($this->descrTable
, 'button_panel') . '</td>
908 * Get backend layout configuration
911 * @deprecated since TYPO3 CMS 6.2, will be removed two versions later
913 public function getBackendLayoutConfiguration() {
914 GeneralUtility
::logDeprecatedFunction();
915 return $this->getBackendLayoutView()->getSelectedBackendLayout($this->id
);
918 /**********************************
920 * Generic listing of items
922 **********************************/
924 * Creates a standard list of elements from a table.
926 * @param string $table Table name
927 * @param int $id Page id.
928 * @param string $fList Comma list of fields to display
929 * @param bool $icon If TRUE, icon is shown
930 * @param string $addWhere Additional WHERE-clauses.
931 * @return string HTML table
933 public function makeOrdinaryList($table, $id, $fList, $icon = FALSE, $addWhere = '') {
935 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
936 $this->setTotalItems($queryParts);
939 // Make query for records if there were any records found in the count operation
940 if ($this->totalItems
) {
941 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
942 // Will return FALSE, if $result is invalid
943 $dbCount = $this->getDatabase()->sql_num_rows($result);
945 // If records were found, render the list
951 $this->fieldArray
= GeneralUtility
::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', TRUE);
953 $theData = $this->headerFields($this->fieldArray
, $table, $theData);
955 $localizedTableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
956 $out .= '<tr class="t3-row-header">' . '<td nowrap="nowrap" class="col-icon"></td>'
957 . '<td nowrap="nowrap" colspan="' . (count($theData) - 2) . '"><span class="c-table">'
958 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td nowrap="nowrap" class="col-icon"></td>'
962 $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick(
963 '&edit[' . $table . '][' . $this->id
. ']=new',
965 )) . '" title="' . $this->getLanguageService()->getLL('new', TRUE) . '">'
966 . IconUtility
::getSpriteIcon('actions-document-new') . '</a>';
968 $out .= $this->addelement(1, '', $theData, ' class="c-headLine"', 15);
970 $this->eCounter
= $this->firstElementNumber
;
971 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
972 BackendUtility
::workspaceOL($table, $row);
973 if (is_array($row)) {
974 list($flag, $code) = $this->fwd_rwd_nav();
977 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
979 // Setting icons links
981 $Nrow['__cmds__'] = $this->getIcon($table, $row);
984 $Nrow = $this->dataFields($this->fieldArray
, $table, $row, $Nrow);
987 $Nrow['__editIconLink__'] = '<a href="#" onclick="' . htmlspecialchars(
988 BackendUtility
::editOnClick($params, $this->backPath
))
989 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">'
990 . IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
992 $Nrow['__editIconLink__'] = $this->noEditIcon();
994 $out .= $this->addelement(1, '', $Nrow);
999 // Wrap it all in a table:
1002 Standard list of table "' . $table . '"
1004 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
1011 * Adds content to all data fields in $out array
1013 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
1014 * Eg. "field1,field2;field3".
1015 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1017 * @param array $fieldArr Array of fields to display
1018 * @param string $table Table name
1019 * @param array $row Record array
1020 * @param array $out Array to which the data is added
1021 * @return array $out array returned after processing.
1022 * @see makeOrdinaryList()
1024 public function dataFields($fieldArr, $table, $row, $out = array()) {
1025 // Check table validity
1026 if (!isset($GLOBALS['TCA'][$table])) {
1030 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1032 foreach ($fieldArr as $fieldName) {
1033 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1034 // Each field has its own cell (if configured in TCA)
1035 // If the column is a thumbnail column:
1036 if ($fieldName == $thumbsCol) {
1037 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1039 // ... otherwise just render the output:
1040 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility
::fixed_lgd_cs(
1041 BackendUtility
::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1046 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1047 // the field name with ";" and check each value there as a TCA configured field)
1048 $theFields = explode(';', $fieldName);
1049 // Traverse fields, separated by ";" (displayed in a single cell).
1050 foreach ($theFields as $fName2) {
1051 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1052 $out[$fieldName] .= '<strong>' . $this->getLanguageService()->sL(
1053 $GLOBALS['TCA'][$table]['columns'][$fName2]['label'],
1055 ) . '</strong>' . ' ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs(
1056 BackendUtility
::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1062 // If no value, add a nbsp.
1063 if (!$out[$fieldName]) {
1064 $out[$fieldName] = ' ';
1066 // Wrap in dimmed-span tags if record is "disabled"
1067 if ($this->isDisabled($table, $row)) {
1068 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
1075 * Header fields made for the listing of records
1077 * @param array $fieldArr Field names
1078 * @param string $table The table name
1079 * @param array $out Array to which the headers are added.
1080 * @return array $out returned after addition of the header fields.
1081 * @see makeOrdinaryList()
1083 public function headerFields($fieldArr, $table, $out = array()) {
1084 foreach ($fieldArr as $fieldName) {
1085 $ll = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], TRUE);
1086 $out[$fieldName] = $ll ?
$ll : ' ';
1092 * Gets content records per column.
1093 * This is required for correct workspace overlays.
1095 * @param string $table UNUSED (will always be queried from tt_content)
1096 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1097 * @param array $columns colPos values to be considered to be shown
1098 * @param string $additionalWhereClause Additional where clause for database select
1099 * @return array Associative array for each column (colPos)
1101 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '') {
1102 $columns = array_map('intval', $columns);
1103 $contentRecordsPerColumn = array_fill_keys($columns, array());
1105 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos IN (' . implode(',', $columns) . ')' . $additionalWhereClause);
1106 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1107 // Traverse any selected elements and render their display code:
1108 $rowArr = $this->getResult($result);
1110 foreach ($rowArr as $record) {
1111 $columnValue = $record['colPos'];
1112 $contentRecordsPerColumn[$columnValue][] = $record;
1115 return $contentRecordsPerColumn;
1118 /**********************************
1120 * Additional functions; Pages
1122 **********************************/
1124 * Adds pages-rows to an array, selecting recursively in the page tree.
1126 * @param array $theRows Array which will accumulate page rows
1127 * @param int $pid Pid to select from
1128 * @param string $qWhere Query-where clause
1129 * @param string $treeIcons Prefixed icon code.
1130 * @param int $depth Depth (decreasing)
1131 * @return array $theRows, but with added rows.
1133 public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth) {
1136 $res = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'pid=' . (int)$pid . $qWhere, '', 'sorting');
1138 $rc = $this->getDatabase()->sql_num_rows($res);
1139 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1140 BackendUtility
::workspaceOL('pages', $row);
1141 if (is_array($row)) {
1143 $row['treeIcons'] = $treeIcons . '<img' . IconUtility
::skinImg(
1145 'gfx/ol/join' . ($rc == $c ?
'bottom' : '') . '.gif',
1146 'width="18" height="16"'
1150 $spaceOutIcons = '<img' . IconUtility
::skinImg(
1152 'gfx/ol/' . ($rc == $c ?
'blank.gif' : 'line.gif'),
1153 'width="18" height="16"'
1155 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ?
0 : $depth);
1159 $count = $this->getDatabase()->exec_SELECTcountRows('uid', 'pages', 'pid=' . (int)$pid . $qWhere);
1161 $this->plusPages
[$pid] = $count;
1168 * Adds a list item for the pages-rendering
1170 * @param array $row Record array
1171 * @param array $fieldArr Field list
1172 * @return string HTML for the item
1174 public function pages_drawItem($row, $fieldArr) {
1176 $theIcon = $this->getIcon('pages', $row);
1177 // Preparing and getting the data-array
1179 foreach ($fieldArr as $field) {
1182 $red = $this->plusPages
[$row['uid']] ?
'<font color="red"><strong>+ </strong></font>' : '';
1183 $pTitle = htmlspecialchars(BackendUtility
::getProcessedValue('pages', $field, $row[$field], 20));
1185 $pTitle = '<a href="'
1186 . htmlspecialchars($this->script
. ((strpos($this->script
, '?') !== FALSE) ?
'&' : '?')
1187 . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1189 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . ' ';
1191 case 'php_tree_stop':
1192 // Intended fall through
1194 $theData[$field] = $row[$field] ?
' <strong>x</strong>' : ' ';
1197 if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
1198 $params = '&edit[pages][' . $row['uid'] . ']=edit';
1199 $eI = '<a href="#" onclick="'
1200 . htmlspecialchars(BackendUtility
::editOnClick($params, $this->backPath
, ''))
1201 . '" title="' . $this->getLanguageService()->getLL('editThisPage', TRUE) . '">'
1202 . IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
1206 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1209 if (substr($field, 0, 6) == 'table_') {
1210 $f2 = substr($field, 6);
1211 if ($GLOBALS['TCA'][$f2]) {
1212 $c = $this->numberOfRecords($f2, $row['uid']);
1213 $theData[$field] = ' ' . ($c ?
$c : '');
1216 $theData[$field] = ' '
1217 . htmlspecialchars(BackendUtility
::getProcessedValue('pages', $field, $row[$field]));
1221 $this->addElement_tdParams
['title'] = $row['_CSSCLASS'] ?
' class="' . $row['_CSSCLASS'] . '"' : '';
1222 return $this->addelement(1, '', $theData);
1225 /**********************************
1227 * Additional functions; Content Elements
1229 **********************************/
1231 * Draw header for a content element column:
1233 * @param string $colName Column name
1234 * @param string $editParams Edit params (Syntax: &edit[...] for alt_doc.php)
1235 * @param string $newParams New element params (Syntax: &edit[...] for alt_doc.php) OBSOLETE
1236 * @param array|NULL $pasteParams Paste element params (i.e. array(colPos => 1, sys_language_uid => 2))
1237 * @return string HTML table
1239 public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = NULL) {
1240 $iconsArr = array();
1241 // Create command links:
1242 if ($this->tt_contentConfig
['showCommands']) {
1243 // Edit whole of column:
1245 $iconsArr['edit'] = '<a href="#" onclick="'
1246 . htmlspecialchars(BackendUtility
::editOnClick($editParams, $this->backPath
)) . '" title="'
1247 . $this->getLanguageService()->getLL('editColumn', TRUE) . '">'
1248 . IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
1251 $elFromTable = $this->clipboard
->elFromTable('tt_content');
1252 if (count($elFromTable)) {
1253 $iconsArr['paste'] = '<a href="'
1254 . htmlspecialchars($this->clipboard
->pasteUrl('tt_content', $this->id
, TRUE, $pasteParams))
1255 . '" onclick="' . htmlspecialchars(('return '
1256 . $this->clipboard
->confirmMsg('pages', $this->pageRecord
, 'into', $elFromTable, $colName)))
1257 . '" title="' . $this->getLanguageService()->getLL('clip_paste', TRUE) . '">'
1258 . IconUtility
::getSpriteIcon('actions-document-paste-into') . '</a>';
1263 if (count($iconsArr)) {
1264 $icons = '<div class="t3-page-colHeader-icons">' . implode('', $iconsArr) . '</div>';
1266 // Create header row:
1267 $out = '<div class="t3-page-colHeader t3-row-header">
1269 <div class="t3-page-colHeader-label">' . htmlspecialchars($colName) . '</div>
1275 * Draw the footer for a single tt_content element
1277 * @param array $row Record array
1278 * @return string HTML of the footer
1280 protected function tt_content_drawFooter(array $row) {
1282 // Get processed values:
1284 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1285 // Display info from records fields:
1287 $content = '<div class="t3-page-ce-info">
1288 ' . implode('<br />', $info) . '
1292 if (!empty($content)) {
1293 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1299 * Draw the header for a single tt_content element
1301 * @param array $row Record array
1302 * @param int $space Amount of pixel space above the header. UNUSED
1303 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1304 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1305 * @param bool $dragDropEnabled If set the move button must be hidden
1306 * @return string HTML table with the record header.
1308 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = FALSE, $langMode = FALSE, $dragDropEnabled = FALSE) {
1310 // If show info is set...;
1311 if ($this->tt_contentConfig
['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1312 // Render control panel for the element:
1313 if ($this->tt_contentConfig
['showCommands'] && $this->doEdit
) {
1314 // Edit content element:
1315 $params = '&edit[tt_content][' . $this->tt_contentData
['nextThree'][$row['uid']] . ']=edit';
1316 $out .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick(
1319 GeneralUtility
::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
1320 )) . '" title="' . htmlspecialchars($this->nextThree
> 1
1321 ?
sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree
)
1322 : $this->getLanguageService()->getLL('edit'))
1323 . '">' . IconUtility
::getSpriteIcon('actions-document-open') . '</a>';
1325 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1327 $hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1328 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1329 ||
$this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1331 if ($row[$hiddenField]) {
1338 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ?
$row['_ORIG_uid'] : $row['uid'])
1339 . '][' . $hiddenField . ']=' . $value;
1340 $out .= '<a href="' . htmlspecialchars($this->getPageLayoutController()->doc
->issueCommand($params))
1341 . '" title="' . $this->getLanguageService()->getLL($label, TRUE) . '">'
1342 . IconUtility
::getSpriteIcon('actions-edit-' . strtolower($label)) . '</a>';
1345 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1346 $confirm = GeneralUtility
::quoteJSvalue($this->getLanguageService()->getLL('deleteWarning')
1347 . BackendUtility
::translationCount('tt_content', $row['uid'], (' '
1348 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')))
1350 $out .= '<a href="' . htmlspecialchars($this->getPageLayoutController()->doc
->issueCommand($params))
1351 . '" onclick="' . htmlspecialchars(('return confirm(' . $confirm . ');')) . '" title="'
1352 . $this->getLanguageService()->getLL('deleteItem', TRUE) . '">'
1353 . IconUtility
::getSpriteIcon('actions-edit-delete') . '</a>';
1354 if (!$disableMoveAndNewButtons) {
1355 $moveButtonContent = '';
1356 $displayMoveButtons = FALSE;
1358 if ($this->tt_contentData
['prev'][$row['uid']]) {
1359 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData
['prev'][$row['uid']];
1360 $moveButtonContent .= '<a href="'
1361 . htmlspecialchars($this->getPageLayoutController()->doc
->issueCommand($params))
1362 . '" title="' . $this->getLanguageService()->getLL('moveUp', TRUE) . '">'
1363 . IconUtility
::getSpriteIcon('actions-move-up') . '</a>';
1364 if (!$dragDropEnabled) {
1365 $displayMoveButtons = TRUE;
1368 $moveButtonContent .= IconUtility
::getSpriteIcon('empty-empty');
1370 // Move element down:
1371 if ($this->tt_contentData
['next'][$row['uid']]) {
1372 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData
['next'][$row['uid']];
1373 $moveButtonContent .= '<a href="'
1374 . htmlspecialchars($this->getPageLayoutController()->doc
->issueCommand($params))
1375 . '" title="' . $this->getLanguageService()->getLL('moveDown', TRUE) . '">'
1376 . IconUtility
::getSpriteIcon('actions-move-down') . '</a>';
1377 if (!$dragDropEnabled) {
1378 $displayMoveButtons = TRUE;
1381 $moveButtonContent .= IconUtility
::getSpriteIcon('empty-empty');
1383 if ($displayMoveButtons) {
1384 $out .= '<span class="t3-page-ce-icons-move">' . $moveButtonContent . '</span>';
1389 $additionalIcons = array();
1390 $additionalIcons[] = $this->getIcon('tt_content', $row) . ' ';
1391 $additionalIcons[] = $langMode ?
$this->languageFlag($row['sys_language_uid'], FALSE) : '';
1392 // Get record locking status:
1393 if ($lockInfo = BackendUtility
::isRecordLocked('tt_content', $row['uid'])) {
1394 $additionalIcons[] = '<a href="#" onclick="alert(' . GeneralUtility
::quoteJSvalue($lockInfo['msg'])
1395 . ');return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">'
1396 . IconUtility
::getSpriteIcon('status-warning-in-use') . '</a>';
1398 // Call stats information hook
1399 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1400 $_params = array('tt_content', $row['uid'], &$row);
1401 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1402 $additionalIcons[] = GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1405 // Wrap the whole header
1406 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1407 return '<h4 class="t3-page-ce-header">
1408 <div class="t3-row-header">
1409 <span class="ce-icons-left">' . implode('', $additionalIcons) . '</span>
1410 <span class="ce-icons">
1414 <div class="t3-page-ce-body">';
1418 * Draws the preview content for a content element
1420 * @param string $row Content element
1421 * @param bool $isRTE Set if the RTE link can be created.
1422 * @return string HTML
1423 * @throws \UnexpectedValueException
1425 public function tt_content_drawItem($row, $isRTE = FALSE) {
1429 if ($row['header']) {
1431 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1432 $hiddenHeaderNote = '';
1433 // If header layout is set to 'hidden', display an accordant note:
1434 if ($row['header_layout'] == 100) {
1435 $hiddenHeaderNote = ' <em>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.hidden', TRUE) . ']</em>';
1437 $outHeader = $row['date']
1438 ?
htmlspecialchars($this->itemLabels
['date'] . ' ' . BackendUtility
::date($row['date'])) . '<br />'
1440 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1441 . $hiddenHeaderNote . '</strong><br />';
1446 // Hook: Render an own preview of a record
1447 $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1448 if (is_array($drawItemHooks)) {
1449 foreach ($drawItemHooks as $hookClass) {
1450 $hookObject = GeneralUtility
::getUserObj($hookClass);
1451 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface
) {
1452 throw new \
UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawItemHookInterface', 1218547409);
1454 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1457 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1459 switch ($row['CType']) {
1461 if ($row['subheader']) {
1462 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1470 if ($row['CType'] == 'text' ||
$row['CType'] == 'textpic') {
1471 if ($row['bodytext']) {
1472 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1475 if ($row['CType'] == 'textpic' ||
$row['CType'] == 'image') {
1476 if ($row['image']) {
1477 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1478 if ($row['imagecaption']) {
1479 $out .= $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1489 if ($row['bodytext']) {
1490 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1494 if ($row['media']) {
1495 $out .= $this->thumbCode($row, 'tt_content', 'media') . '<br />';
1499 if ($row['multimedia']) {
1500 $out .= $this->renderText($row['multimedia']) . '<br />';
1501 $out .= $this->renderText($row['parameters']) . '<br />';
1505 if ($row['pages']) {
1506 $out .= $this->linkEditContent($row['pages'], $row) . '<br />';
1510 if (!empty($row['records'])) {
1511 $shortcutContent = array();
1512 $recordList = explode(',', $row['records']);
1513 foreach ($recordList as $recordIdentifier) {
1514 $split = BackendUtility
::splitTable_Uid($recordIdentifier);
1515 $tableName = empty($split[0]) ?
'tt_content' : $split[0];
1516 $shortcutRecord = BackendUtility
::getRecord($tableName, $split[1]);
1517 if (is_array($shortcutRecord)) {
1518 $icon = IconUtility
::getSpriteIconForRecord($tableName, $shortcutRecord);
1519 $icon = $this->getPageLayoutController()->doc
->wrapClickMenuOnIcon($icon, $tableName,
1520 $shortcutRecord['uid'], 1, '', '+copy,info,edit,view');
1521 $shortcutContent[] = $icon
1522 . htmlspecialchars(BackendUtility
::getRecordTitle($tableName, $shortcutRecord));
1525 $out .= implode('<br />', $shortcutContent) . '<br />';
1531 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1532 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1533 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1534 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1536 if (count($hookArr) > 0) {
1537 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1538 foreach ($hookArr as $_funcRef) {
1539 $hookOut .= GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1542 if ((string)$hookOut !== '') {
1544 } elseif (!empty($row['list_type'])) {
1545 $label = BackendUtility
::getLabelFromItemlist('tt_content', 'list_type', $row['list_type']);
1546 if (!empty($label)) {
1547 $out .= '<strong>' . $this->getLanguageService()->sL($label, TRUE) . '</strong><br />';
1549 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1550 $out .= GeneralUtility
::makeInstance(
1551 FlashMessage
::class,
1552 htmlspecialchars($message),
1554 FlashMessage
::WARNING
1557 } elseif (!empty($row['select_key'])) {
1558 $out .= $this->getLanguageService()->sL(BackendUtility
::getItemLabel('tt_content', 'select_key'), TRUE)
1559 . ' ' . $row['select_key'] . '<br />';
1561 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1563 $out .= $this->getLanguageService()->sL(
1564 BackendUtility
::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1569 $out .= $this->getLanguageService()->sL(BackendUtility
::getItemLabel('tt_content', 'select_key'), TRUE)
1570 . ' ' . $row['select_key'] . '<br />';
1571 $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1572 $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1575 $contentType = $this->CType_labels
[$row['CType']];
1577 if (isset($contentType)) {
1578 $out .= '<strong>' . htmlspecialchars($contentType) . '</strong><br />';
1579 if ($row['bodytext']) {
1580 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1582 if ($row['image']) {
1583 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1587 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1590 $out .= GeneralUtility
::makeInstance(
1591 FlashMessage
::class,
1592 htmlspecialchars($message),
1594 FlashMessage
::WARNING
1601 <span class="exampleContent">' . $out . '</span>';
1603 $out = $outHeader . $out;
1606 $out .= $this->linkRTEbutton($row);
1609 if ($this->isDisabled('tt_content', $row)) {
1610 return '<span class="text-muted">' . $out . '</span>';
1617 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1618 * Selects across columns, but within in the same PID. Columns are expect to be the same
1619 * for translations and original but this may be a conceptual error (?)
1621 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1622 * @param int $id Page pid
1623 * @param int $lP Sys language UID
1624 * @return array Modified $defLanguageCount
1626 public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) {
1627 if ($lP && count($defLanguageCount)) {
1628 // Select all translations here:
1629 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . (int)$lP
1630 . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')');
1631 $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1633 $defLanguageCount = array_flip($defLanguageCount);
1634 // Traverse any selected elements and unset original UID if any:
1635 $rowArr = $this->getResult($result);
1636 foreach ($rowArr as $row) {
1637 unset($defLanguageCount[$row['l18n_parent']]);
1640 $defLanguageCount = array_keys($defLanguageCount);
1642 return $defLanguageCount;
1646 * Creates button which is used to create copies of records..
1648 * @param array $defLanguageCount Numeric array with uids of tt_content elements in the default language
1649 * @param int $lP Sys language UID
1650 * @return string "Copy languages" button, if available.
1652 public function newLanguageButton($defLanguageCount, $lP) {
1653 if (!$this->doEdit ||
count($defLanguageCount) === 0 ||
!$lP) {
1657 foreach ($defLanguageCount as $uidVal) {
1658 $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP;
1660 // Copy for language:
1661 $onClick = 'window.location.href=\'' . $this->getPageLayoutController()->doc
->issueCommand($params) . '\'; return false;';
1662 $theNewButton = '<div class="t3-page-lang-copyce">' .
1663 $this->getPageLayoutController()->doc
->t3Button(
1665 $this->getLanguageService()->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']'
1667 return $theNewButton;
1671 * Creates onclick-attribute content for a new content element
1673 * @param int $id Page id where to create the element.
1674 * @param int $colPos Preset: Column position value
1675 * @param int $sys_language Preset: Sys langauge value
1676 * @return string String for onclick attribute.
1677 * @see getTable_tt_content()
1679 public function newContentElementOnClick($id, $colPos, $sys_language) {
1680 if ($this->option_newWizard
) {
1681 $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $id . '&colPos=' . $colPos
1682 . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1683 . '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\';';
1685 $onClick = BackendUtility
::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1686 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language, $this->backPath
);
1692 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
1693 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1695 * @param string $str String to link. Must be prepared for HTML output.
1696 * @param array $row The row.
1697 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1698 * @see getTable_tt_content()
1700 public function linkEditContent($str, $row) {
1703 if ($this->doEdit
&& $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1704 // Setting onclick action for content link:
1705 $onClick = BackendUtility
::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit', $this->backPath
);
1708 return $onClick ?
'<a href="#" onclick="' . htmlspecialchars($onClick)
1709 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">' . $str . '</a>' . $addButton : $str;
1713 * Adds a button to edit the row in RTE wizard
1715 * @param array $row The row of tt_content element
1716 * @return string Button to click if you want to edit in RTE wizard.
1718 public function linkRTEbutton($row) {
1720 $params['table'] = 'tt_content';
1721 $params['uid'] = $row['uid'];
1722 $params['pid'] = $row['pid'];
1723 $params['field'] = 'bodytext';
1724 $params['returnUrl'] = GeneralUtility
::linkThisScript();
1725 $RTEonClick = 'window.location.href=' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('wizard_rte', array('P' => $params))) . ';return false;';
1726 $addButton = $this->option_showBigButtons
&& $this->doEdit
1727 ?
$this->getPageLayoutController()->doc
->t3Button($RTEonClick, $this->getLanguageService()->getLL('editInRTE'))
1733 * Make selector box for creating new translation in a language
1734 * Displays only languages which are not yet present for the current page and
1735 * that are not disabled with page TS.
1737 * @param int $id Page id for which to create a new language (pages_language_overlay record)
1738 * @return string <select> HTML element (if there were items for the box anyways...)
1739 * @see getTable_tt_content()
1741 public function languageSelector($id) {
1742 if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1743 // First, select all
1744 $res = $this->getPageLayoutController()->exec_languageQuery(0);
1745 $langSelItems = array();
1746 $langSelItems[0] = '
1747 <option value="0"></option>';
1748 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1749 if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1750 $langSelItems[$row['uid']] = '
1751 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1754 // Then, subtract the languages which are already on the page:
1755 $res = $this->getPageLayoutController()->exec_languageQuery($id);
1756 while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1757 unset($langSelItems[$row['uid']]);
1759 // Remove disallowed languages
1760 if (count($langSelItems) > 1
1761 && !$this->getBackendUser()->user
['admin']
1762 && strlen($this->getBackendUser()->groupData
['allowed_languages'])
1764 $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData
['allowed_languages']));
1765 if (count($allowed_languages)) {
1766 foreach ($langSelItems as $key => $value) {
1767 if (!isset($allowed_languages[$key]) && $key != 0) {
1768 unset($langSelItems[$key]);
1773 // Remove disabled languages
1774 $modSharedTSconfig = BackendUtility
::getModTSconfig($id, 'mod.SHARED');
1775 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1776 ? GeneralUtility
::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], TRUE)
1778 if (count($langSelItems) && count($disableLanguages)) {
1779 foreach ($disableLanguages as $language) {
1780 if ($language != 0 && isset($langSelItems[$language])) {
1781 unset($langSelItems[$language]);
1785 // If any languages are left, make selector:
1786 if (count($langSelItems) > 1) {
1787 $onChangeContent = 'window.location.href=\'' . $this->backPath
. 'alt_doc.php?&edit[pages_language_overlay]['
1788 . $id . ']=new&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRecord
['doktype']
1789 . '&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='
1790 . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI')) . '\'';
1791 return $this->getLanguageService()->getLL('new_language', TRUE)
1792 . ': <select name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">
1793 ' . implode('', $langSelItems) . '
1794 </select><br /><br />';
1801 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1803 * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
1804 * @param string $table Table name defaulting to tt_content
1805 * @return array The selected rows returned in this array.
1807 public function getResult($result, $table = 'tt_content') {
1809 // Traverse the result:
1810 while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1811 BackendUtility
::workspaceOL($table, $row, -99, TRUE);
1813 // Add the row to the array:
1817 $this->generateTtContentDataArray($output);
1818 // Return selected records
1822 /********************************
1824 * Various helper functions
1826 ********************************/
1829 * Initializes the clipboard for generating paste links
1833 * @see \TYPO3\CMS\Recordlist\RecordList::main()
1834 * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
1835 * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
1837 protected function initializeClipboard() {
1839 $this->clipboard
= GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard
::class);
1841 // Initialize - reads the clipboard content from the user session
1842 $this->clipboard
->initializeClipboard();
1844 // This locks the clipboard to the Normal for this request.
1845 $this->clipboard
->lockToNormal();
1848 $this->clipboard
->cleanCurrent();
1850 // Save the clipboard content
1851 $this->clipboard
->endClipboard();
1855 * Generates the data for previous and next elements which is needed for movements.
1857 * @param array $rowArray
1860 protected function generateTtContentDataArray(array $rowArray) {
1861 if (empty($this->tt_contentData
)) {
1862 $this->tt_contentData
= array(
1863 'nextThree' => array(),
1868 foreach ($rowArray as $key => $value) {
1869 // Create the list of the next three ids (for editing links...)
1870 for ($i = 0; $i < $this->nextThree
; $i++
) {
1871 if (isset($rowArray[$key - $i])
1872 && !GeneralUtility
::inList($this->tt_contentData
['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
1874 $this->tt_contentData
['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
1878 // Create information for next and previous content elements
1879 if (isset($rowArray[$key - 1])) {
1880 if (isset($rowArray[$key - 2])) {
1881 $this->tt_contentData
['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
1883 $this->tt_contentData
['prev'][$value['uid']] = $value['pid'];
1885 $this->tt_contentData
['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
1891 * Counts and returns the number of records on the page with $pid
1893 * @param string $table Table name
1894 * @param int $pid Page id
1895 * @return int Number of records.
1897 public function numberOfRecords($table, $pid) {
1899 if ($GLOBALS['TCA'][$table]) {
1900 $where = 'pid=' . (int)$pid . BackendUtility
::deleteClause($table) . BackendUtility
::versioningPlaceholderClause($table);
1901 $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
1907 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1909 * @param string $input Input string
1910 * @return string Output string
1912 public function renderText($input) {
1913 $input = strip_tags($input);
1914 $input = GeneralUtility
::fixed_lgd_cs($input, 1500);
1915 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES
, 'UTF-8', FALSE));
1919 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1921 * @param string $table Table name
1922 * @param array $row Record array
1923 * @return string HTML for the icon
1925 public function getIcon($table, $row) {
1927 $altText = BackendUtility
::getRecordIconAltText($row, $table);
1928 $icon = IconUtility
::getSpriteIconForRecord($table, $row, array('title' => $altText));
1930 // The icon with link
1931 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
1932 $icon = $this->getPageLayoutController()->doc
->wrapClickMenuOnIcon($icon, $table, $row['uid']);
1938 * Creates processed values for all field names in $fieldList based on values from $row array.
1939 * The result is 'returned' through $info which is passed as a reference
1941 * @param string $table Table name
1942 * @param string $fieldList Comma separated list of fields.
1943 * @param array $row Record from which to take values for processing.
1944 * @param array $info Array to which the processed values are added.
1947 public function getProcessedValue($table, $fieldList, array $row, array &$info) {
1948 // Splitting values from $fieldList
1949 $fieldArr = explode(',', $fieldList);
1950 // Traverse fields from $fieldList
1951 foreach ($fieldArr as $field) {
1953 $info[] = '<strong>' . htmlspecialchars($this->itemLabels
[$field]) . '</strong> '
1954 . htmlspecialchars(BackendUtility
::getProcessedValue($table, $field, $row[$field]));
1960 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
1962 * @param string $table Tablename of table to test
1963 * @param array $row Record row.
1964 * @return bool Returns TRUE, if disabled.
1966 public function isDisabled($table, $row) {
1967 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
1968 return $enableCols['disabled'] && $row[$enableCols['disabled']]
1969 ||
$enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
1970 ||
$enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
1974 * Will perform "word-wrapping" on the input string. What it does is to split by space or line break,
1975 * then find any word longer than $max and if found, a hyphen is inserted.
1976 * Works well on normal texts, little less well when HTML is involved (since much HTML will have
1977 * long strings that will be broken).
1979 * @param string $content Content to word-wrap.
1980 * @param int $max Max number of chars in a word before it will be wrapped.
1981 * @param string $char Character to insert when wrapping.
1982 * @return string Processed output.
1983 * @deprecated since 6.2 - will be removed two versions later; use CSS instead (word-break: break-all;)
1985 public function wordWrapper($content, $max = 50, $char = ' -') {
1986 GeneralUtility
::logDeprecatedFunction();
1987 $array = preg_split('/[ ' . LF
. ']/', $content);
1988 foreach ($array as $val) {
1989 if (strlen($val) > $max) {
1990 $content = str_replace($val, substr(chunk_split($val, $max, $char), 0, -1), $content);
1997 * Returns icon for "no-edit" of a record.
1998 * Basically, the point is to signal that this record could have had an edit link if
1999 * the circumstances were right. A placeholder for the regular edit icon...
2001 * @param string $label Label key from LOCAL_LANG
2002 * @return string IMG tag for icon.
2004 public function noEditIcon($label = 'noEditItems') {
2005 return IconUtility
::getSpriteIcon(
2006 'status-edit-read-only',
2007 array('title' => $this->getLanguageService()->getLL($label, TRUE))
2012 * Function, which fills in the internal array, $this->allowedTableNames with all tables to
2013 * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...)
2014 * are filtered out. So what is left is basically all tables which makes sense to list content from.
2018 protected function cleanTableNames() {
2019 // Get all table names:
2020 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2021 // Unset common names:
2022 unset($tableNames['pages']);
2023 unset($tableNames['static_template']);
2024 unset($tableNames['sys_filemounts']);
2025 unset($tableNames['sys_action']);
2026 unset($tableNames['sys_workflows']);
2027 unset($tableNames['be_users']);
2028 unset($tableNames['be_groups']);
2029 $allowedTableNames = array();
2030 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2031 if (is_array($tableNames)) {
2032 foreach ($tableNames as $k => $v) {
2033 if ($this->getBackendUser()->check('tables_select', $k)) {
2034 $allowedTableNames['table_' . $k] = $k;
2038 return $allowedTableNames;
2042 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns TRUE.
2043 * Used to determine if the RTE button should be displayed.
2045 * @param string $table Table name
2046 * @param array $row Record row (needed, if there are RTE dependencies based on other fields in the record)
2047 * @param string $field Field name
2048 * @return bool Returns TRUE if the rich text editor would be enabled/available for the field name specified.
2050 public function isRTEforField($table, $row, $field) {
2051 $specConf = $this->getSpecConfForField($table, $row, $field);
2052 if (!count($specConf)) {
2055 $p = BackendUtility
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2056 if (isset($specConf['richtext']) && (!$p['flag'] ||
!$row[$p['flag']])) {
2057 BackendUtility
::fixVersioningPid($table, $row);
2058 list($tscPID, $thePidValue) = BackendUtility
::getTSCpid($table, $row['uid'], $row['pid']);
2059 // If the pid-value is not negative (that is, a pid could NOT be fetched)
2060 if ($thePidValue >= 0) {
2061 if (!isset($this->rteSetup
[$tscPID])) {
2062 $this->rteSetup
[$tscPID] = $this->getBackendUser()->getTSConfig('RTE', BackendUtility
::getPagesTSconfig($tscPID));
2064 $RTEtypeVal = BackendUtility
::getTCAtypeValue($table, $row);
2065 $thisConfig = BackendUtility
::RTEsetup($this->rteSetup
[$tscPID]['properties'], $table, $field, $RTEtypeVal);
2066 if (!$thisConfig['disabled']) {
2075 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
2076 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
2078 * @param string $table Table name
2079 * @param array $row Record array
2080 * @param string $field Field name
2081 * @return array Spec. conf (if available)
2083 * @see isRTEforField()
2085 public function getSpecConfForField($table, $row, $field) {
2086 // Get types-configuration for the record:
2087 $types_fieldConfig = BackendUtility
::getTCAtypes($table, $row);
2088 // Find the given field and return the spec key value if found:
2089 if (is_array($types_fieldConfig)) {
2090 foreach ($types_fieldConfig as $vConf) {
2091 if ($vConf['field'] == $field) {
2092 return $vConf['spec'];
2099 /*****************************************
2101 * External renderings
2103 *****************************************/
2106 * Creates a menu of the tables that can be listed by this function
2107 * Only tables which has records on the page will be included.
2108 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2110 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2111 * @return string HTML output.
2113 public function getTableMenu($id) {
2115 $this->activeTables
= array();
2116 $theTables = array('tt_content');
2118 if (is_array($this->externalTables
)) {
2119 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables
)));
2122 // Traverse tables to check:
2123 foreach ($theTables as $tName) {
2124 // Check access and whether the proper extensions are loaded:
2125 if ($this->getBackendUser()->check('tables_select', $tName)
2126 && (isset($this->externalTables
[$tName])
2127 || GeneralUtility
::inList('fe_users,tt_content', $tName)
2128 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::isLoaded($tName)
2131 // Make query to count records from page:
2132 $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2133 . BackendUtility
::deleteClause($tName) . BackendUtility
::versioningPlaceholderClause($tName));
2134 // If records were found (or if "tt_content" is the table...):
2135 if ($c || GeneralUtility
::inList('tt_content', $tName)) {
2138 <td><a href="#' . $tName . '"></a>' . IconUtility
::getSpriteIconForRecord(
2141 array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE))
2143 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2144 $this->activeTables
[$tName] = IconUtility
::getSpriteIconForRecord(
2147 array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE)
2148 . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', TRUE))
2149 ) . ' ' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE);
2153 // Wrap cells in table tags:
2156 Menu of tables on the page (table menu)
2158 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2162 // Return the content:
2167 * @return BackendLayoutView
2169 protected function getBackendLayoutView() {
2170 return GeneralUtility
::makeInstance(BackendLayoutView
::class);
2174 * @return BackendUserAuthentication
2176 protected function getBackendUser() {
2177 return $GLOBALS['BE_USER'];
2181 * @return DatabaseConnection
2183 protected function getDatabase() {
2184 return $GLOBALS['TYPO3_DB'];
2188 * @return LanguageService
2190 protected function getLanguageService() {
2191 return $GLOBALS['LANG'];
2195 * @return PageLayoutController
2197 protected function getPageLayoutController() {
2198 return $GLOBALS['SOBE'];
2202 * @return DocumentTemplate
2204 protected function getDocumentTemplate() {
2205 return $GLOBALS['TBE_TEMPLATE'];