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