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