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