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