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