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