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