TYPO3 CMS  TYPO3_6-2
PageLayoutView.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\View;
3 
27 
33 class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList {
34 
35  // External, static: Flags of various kinds:
36  // If TRUE, users/groups are shown in the page info box.
40  public $pI_showUser = 0;
41 
42  // The number of successive records to edit when showing content elements.
46  public $nextThree = 3;
47 
48  // If TRUE, disables the edit-column icon for tt_content elements
53 
54  // If TRUE, shows big buttons for editing page properties, moving, creating elements etc. in the columns view.
59 
60  // If TRUE, new-wizards are linked to rather than the regular new-element list.
64  public $option_newWizard = 1;
65 
66  // If set to "1", will link a big button to content element wizard.
70  public $ext_function = 0;
71 
72  // If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
76  public $doEdit = 1;
77 
78  // Age prefixes for displaying times. May be set externally to localized values.
82  public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
83 
84  // Array of tables to be listed by the Web > Page module in addition to the default tables.
88  public $externalTables = array();
89 
90  // "Pseudo" Description -table name
94  public $descrTable;
95 
96  // If set TRUE, the language mode of tt_content elements will be rendered with hard binding between
97  // default language content elements and their translations!
101  public $defLangBinding = FALSE;
102 
103  // External, static: Configuration of tt_content element display:
107  public $tt_contentConfig = array(
108  'showInfo' => 1,
109  // Boolean: Display info-marks or not
110  'showCommands' => 1,
111  // Boolean: Display up/down arrows and edit icons for tt_content records
112  'single' => 1,
113  // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown in the total width of the page
114  'showAsGrid' => 0,
115  // Boolean: If set, the content of columns is shown in grid
116  'showSingleCol' => 0,
117  // The column(s) to show if single mode (under each other)
118  'languageCols' => 0,
119  'languageMode' => 0,
120  'languageColsPointer' => 0,
121  'showHidden' => 1,
122  // Displays hidden records as well
123  'sys_language_uid' => 0,
124  // Which language
125  'cols' => '1,0,2,3',
126  'activeCols' => '1,0,2,3'
127  // Which columns can be accessed by current BE user
128  );
129 
130  // Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
134  public $activeTables = array();
135 
139  public $tt_contentData = array(
140  'nextThree' => array(),
141  'prev' => array(),
142  'next' => array()
143  );
144 
145  // Used to store labels for CTypes for tt_content elements
149  public $CType_labels = array();
150 
151  // Used to store labels for the various fields in tt_content elements
155  public $itemLabels = array();
156 
162  protected $rteSetup = array();
163 
167  protected $clipboard;
168 
172  protected $plusPages = array();
173 
180 
181  /*****************************************
182  *
183  * Renderings
184  *
185  *****************************************/
194  public function getTable($table, $id) {
195  if (isset($this->externalTables[$table])) {
196  return $this->getExternalTables($id, $table);
197  } else {
198  // Branch out based on table name:
199  switch ($table) {
200  case 'pages':
201  return $this->getTable_pages($id);
202  break;
203  case 'tt_content':
204  return $this->getTable_tt_content($id);
205  break;
206  default:
207  return '';
208  }
209  }
210  }
211 
220  public function getExternalTables($id, $table) {
221  $type = $this->getPageLayoutController()->MOD_SETTINGS[$table];
222  if (!isset($type)) {
223  $type = 0;
224  }
225  // eg. "name;title;email;company,image"
226  $fList = $this->externalTables[$table][$type]['fList'];
227  // The columns are separeted by comma ','.
228  // Values separated by semicolon ';' are shown in the same column.
229  $icon = $this->externalTables[$table][$type]['icon'];
230  $addWhere = $this->externalTables[$table][$type]['addWhere'];
231  // Create listing
232  $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
233  return $out;
234  }
235 
244  public function getTable_pages($id) {
245  // Initializing:
246  $out = '';
247  // Select clause for pages:
248  $delClause = BackendUtility::deleteClause('pages') . ' AND ' . $this->getBackendUser()->getPagePermsClause(1);
249  // Select current page:
250  if (!$id) {
251  // The root has a pseudo record in pageinfo...
252  $row = $this->getPageLayoutController()->pageinfo;
253  } else {
254  $result = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'uid=' . (int)$id . $delClause);
255  $row = $this->getDatabase()->sql_fetch_assoc($result);
256  BackendUtility::workspaceOL('pages', $row);
257  }
258  // If there was found a page:
259  if (is_array($row)) {
260  // Select which fields to show:
261  $pKey = $this->getPageLayoutController()->MOD_SETTINGS['pages'];
262  switch ($pKey) {
263  case 1:
264  $this->fieldArray = array('title','uid') + array_keys($this->cleanTableNames());
265  break;
266  case 2:
267  $this->fieldArray = array(
268  'title',
269  'uid',
270  'lastUpdated',
271  'newUntil',
272  'no_cache',
273  'cache_timeout',
274  'php_tree_stop',
275  'TSconfig',
276  'storage_pid',
277  'is_siteroot',
278  'fe_login_mode'
279  );
280  break;
281  default:
282  $this->fieldArray = array(
283  'title',
284  'uid',
285  'alias',
286  'starttime',
287  'endtime',
288  'fe_group',
289  'target',
290  'url',
291  'shortcut',
292  'shortcut_mode'
293  );
294  }
295  // Getting select-depth:
296  $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS['pages_levels'];
297  // Half line is drawn
298  $theData = array();
299  $theData['subject'] = $this->widthGif;
300  $out .= $this->addelement(0, '', $theData);
301  // Overriding a few things:
302  $this->no_noWrap = 0;
303  $this->oddColumnsCssClass = 'bgColor3-20';
304  // Items
305  $this->eCounter = $this->firstElementNumber;
306  // Creating elements:
307  list($flag, $code) = $this->fwd_rwd_nav();
308  $out .= $code;
309  $editUids = array();
310  if ($flag) {
311  // Getting children:
312  $theRows = array();
313  $theRows = $this->pages_getTree($theRows, $row['uid'], $delClause . BackendUtility::versioningPlaceholderClause('pages'), '', $depth);
314  if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
315  $editUids[] = $row['uid'];
316  }
317  $out .= $this->pages_drawItem($row, $this->fieldArray);
318  // Traverse all pages selected:
319  foreach ($theRows as $sRow) {
320  if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
321  $editUids[] = $sRow['uid'];
322  }
323  $out .= $this->pages_drawItem($sRow, $this->fieldArray);
324  }
325  $this->eCounter++;
326  }
327  // Header line is drawn
328  $theData = array();
329  $editIdList = implode(',', $editUids);
330  // Traverse fields (as set above) in order to create header values:
331  foreach ($this->fieldArray as $field) {
332  if ($editIdList && isset($GLOBALS['TCA']['pages']['columns'][$field]) && $field != 'uid' && !$this->pages_noEditColumns) {
333  $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=' . $field . '&disHelp=1';
334  $iTitle = sprintf(
335  $this->getLanguageService()->getLL('editThisColumn'),
336  rtrim(trim($this->getLanguageService()->sL(BackendUtility::getItemLabel('pages', $field))), ':')
337  );
338  $eI = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, ''))
339  . '" title="' . htmlspecialchars($iTitle) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
340  } else {
341  $eI = '';
342  }
343  switch ($field) {
344  case 'title':
345  $theData[$field] = '&nbsp;<strong>'
346  . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
347  . '</strong>' . $eI;
348  break;
349  case 'uid':
350  $theData[$field] = '&nbsp;<strong>ID:</strong>';
351  break;
352  default:
353  if (substr($field, 0, 6) == 'table_') {
354  $f2 = substr($field, 6);
355  if ($GLOBALS['TCA'][$f2]) {
356  $theData[$field] = '&nbsp;' . IconUtility::getSpriteIconForRecord($f2, array(), array(
357  'title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$f2]['ctrl']['title'], TRUE)
358  ));
359  }
360  } else {
361  $theData[$field] = '&nbsp;&nbsp;<strong>'
362  . $this->getLanguageService()->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'], TRUE)
363  . '</strong>' . $eI;
364  }
365  }
366  }
367  // Start table:
368  $this->oddColumnsCssClass = '';
369  // CSH:
370  $out = BackendUtility::cshItem($this->descrTable, ('func_' . $pKey), $GLOBALS['BACK_PATH']) . '
371  <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-pages">
372  ' . $this->addelement(1, '', $theData, ' class="t3-row-header"', 20) . $out . '
373  </table>';
374  }
375  $this->oddColumnsCssClass = '';
376  return $out;
377  }
378 
386  public function getSelectedBackendLayoutUid($id) {
388  return $this->getBackendLayoutView()->getSelectedCombinedIdentifier($id);
389  }
390 
398  public function getTable_tt_content($id) {
399  $this->initializeLanguages();
400  $this->initializeClipboard();
401  // Initialize:
402  $RTE = $this->getBackendUser()->isRTE();
403  $lMarg = 1;
404  $showHidden = $this->tt_contentConfig['showHidden'] ? '' : BackendUtility::BEenableFields('tt_content');
405  $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), TRUE));
407  $pageRenderer = $this->getPageLayoutController()->doc->getPageRenderer();
408  $pageRenderer->loadExtJs();
409  $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . 'sysext/cms/layout/js/typo3pageModule.js');
410  // Get labels for CTypes and tt_content element fields in general:
411  $this->CType_labels = array();
412  foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
413  $this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
414  }
415  $this->itemLabels = array();
416  foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
417  $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
418  }
419  $languageColumn = array();
420  $out = '';
421  // Select display mode:
422  // MULTIPLE column display mode, side by side:
423  if (!$this->tt_contentConfig['single']) {
424  // Setting language list:
425  $langList = $this->tt_contentConfig['sys_language_uid'];
426  if ($this->tt_contentConfig['languageMode']) {
427  if ($this->tt_contentConfig['languageColsPointer']) {
428  $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
429  } else {
430  $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
431  }
432  $languageColumn = array();
433  }
434  $langListArr = GeneralUtility::intExplode(',', $langList);
435  $defLanguageCount = array();
436  $defLangBinding = array();
437  // For each languages... :
438  // If not languageMode, then we'll only be through this once.
439  foreach ($langListArr as $lP) {
440  $lP = (int)$lP;
441  if (count($langListArr) === 1 || $lP === 0) {
442  $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
443  } else {
444  $showLanguage = ' AND sys_language_uid=' . $lP;
445  }
446  $cList = GeneralUtility::trimExplode(',', $this->tt_contentConfig['cols'], TRUE);
447  $content = array();
448  $head = array();
449 
450  if (!empty($cList)) {
451  // Select content records per column
452  $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showHidden . $showLanguage);
453  // For each column, render the content into a variable:
454  foreach ($cList as $key) {
455  if (!$lP) {
456  $defLanguageCount[$key] = array();
457  }
458  // Start wrapping div
459  $content[$key] .= '<div class="t3-page-ce-wrapper';
460  if (count($contentRecordsPerColumn[$key]) === 0) {
461  $content[$key] .= ' t3-page-ce-empty';
462  }
463  $content[$key] .= '">';
464  // Add new content at the top most position
465  $content[$key] .= '
466  <div class="t3-page-ce" id="' . str_replace('.', '', uniqid('', TRUE)) . '">
467  <div class="t3-page-ce-dropzone" id="colpos-' . $key . '-' . 'page-' . $id . '-' . uniqid('', TRUE) . '">
468  <div class="t3-page-ce-wrapper-new-ce">
469  <a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP))
470  . '" title="' . $this->getLanguageService()->getLL('newRecordHere', TRUE) . '">'
471  . IconUtility::getSpriteIcon('actions-document-new') . '</a>
472  </div>
473  </div>
474  </div>
475  ';
476  $editUidList = '';
477  $rowArr = $contentRecordsPerColumn[$key];
478  $this->generateTtContentDataArray($rowArr);
479  foreach ((array)$rowArr as $rKey => $row) {
480  if ($this->tt_contentConfig['languageMode']) {
481  $languageColumn[$key][$lP] = $head[$key] . $content[$key];
482  if (!$this->defLangBinding) {
483  $languageColumn[$key][$lP] .= $this->newLanguageButton(
484  $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
485  $lP
486  );
487  }
488  }
489  if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
490  $singleElementHTML = '';
491  if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
492  $defLanguageCount[$key][] = $row['uid'];
493  }
494  $editUidList .= $row['uid'] . ',';
495  $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0;
496  if (!$this->tt_contentConfig['languageMode']) {
497  $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . str_replace('.', '', uniqid('', TRUE)) . '">';
498  }
499  $singleElementHTML .= $this->tt_content_drawHeader(
500  $row,
501  $this->tt_contentConfig['showInfo'] ? 15 : 5,
502  $disableMoveAndNewButtons,
503  TRUE,
504  !$this->tt_contentConfig['languageMode']
505  );
506  $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
507  $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>'
508  . $this->tt_content_drawItem($row, $isRTE) . '</div>';
509  $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>'
510  . $this->tt_content_drawFooter($row);
511  // NOTE: this is the end tag for <div class="t3-page-ce-body">
512  // because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
513  $singleElementHTML .= '</div>';
514  $statusHidden = $this->isDisabled('tt_content', $row) ? ' t3-page-ce-hidden' : '';
515  $singleElementHTML = '<div class="t3-page-ce' . $statusHidden . '" id="element-tt_content-'
516  . $row['uid'] . '">' . $singleElementHTML . '</div>';
517  if ($this->tt_contentConfig['languageMode']) {
518  $singleElementHTML .= '<div class="t3-page-ce">';
519  }
520  $singleElementHTML .= '<div class="t3-page-ce-dropzone" id="colpos-' . $key . '-' . 'page-' . $id .
521  '-' . str_replace('.', '', uniqid('', TRUE)) . '">';
522  // Add icon "new content element below"
523  if (!$disableMoveAndNewButtons) {
524  // New content element:
525  if ($this->option_newWizard) {
526  $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $row['pid']
527  . '&sys_language_uid=' . $row['sys_language_uid'] . '&colPos=' . $row['colPos']
528  . '&uid_pid=' . -$row['uid'] .
529  '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';';
530  } else {
531  $params = '&edit[tt_content][' . -$row['uid'] . ']=new';
532  $onClick = BackendUtility::editOnClick($params, $this->backPath);
533  }
534  $singleElementHTML .= '
535  <div class="t3-page-ce-wrapper-new-ce">
536  <a href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
537  . $this->getLanguageService()->getLL('newRecordHere', TRUE) . '">'
538  . IconUtility::getSpriteIcon('actions-document-new') . '</a>
539  </div>
540  ';
541  }
542  $singleElementHTML .= '</div></div>';
543  if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
544  $defLangBinding[$key][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML;
545  } else {
546  $content[$key] .= $singleElementHTML;
547  }
548  } else {
549  unset($rowArr[$rKey]);
550  }
551  }
552  $content[$key] .= '</div>';
553  // Add new-icon link, header:
554  $newP = $this->newContentElementOnClick($id, $key, $lP);
555  $colTitle = BackendUtility::getProcessedValue('tt_content', 'colPos', $key);
556  $tcaItems = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $id, $this);
557  foreach ($tcaItems as $item) {
558  if ($item[1] == $key) {
559  $colTitle = $this->getLanguageService()->sL($item[0]);
560  }
561  }
562 
563  $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
564  $editParam = $this->doEdit && count($rowArr)
565  ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
566  : '';
567  $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, $newP, $pasteP);
568  }
569  }
570  // For each column, fit the rendered content into a table cell:
571  $out = '';
572  if ($this->tt_contentConfig['languageMode']) {
573  // in language mode process the content elements, but only fill $languageColumn. output will be generated later
574  $sortedLanguageColumn = array();
575  foreach ($cList as $key) {
576  $languageColumn[$key][$lP] = $head[$key] . $content[$key];
577  if (!$this->defLangBinding) {
578  $languageColumn[$key][$lP] .= $this->newLanguageButton(
579  $this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP),
580  $lP
581  );
582  }
583  // We sort $languageColumn again according to $cList as it may contain data already from above.
584  $sortedLanguageColumn[$key] = $languageColumn[$key];
585  }
586  $languageColumn = $sortedLanguageColumn;
587  } else {
588  $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
589  // GRID VIEW:
590  $grid = '<div class="t3-gridContainer"><table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%" class="t3-page-columns t3-gridTable">';
591  // Add colgroups
592  $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
593  $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
594  $grid .= '<colgroup>';
595  for ($i = 0; $i < $colCount; $i++) {
596  $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
597  }
598  $grid .= '</colgroup>';
599  // Cycle through rows
600  for ($row = 1; $row <= $rowCount; $row++) {
601  $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
602  if (!isset($rowConfig)) {
603  continue;
604  }
605  $grid .= '<tr>';
606  for ($col = 1; $col <= $colCount; $col++) {
607  $columnConfig = $rowConfig['columns.'][$col . '.'];
608  if (!isset($columnConfig)) {
609  continue;
610  }
611  // Which tt_content colPos should be displayed inside this cell
612  $columnKey = (int)$columnConfig['colPos'];
613  // Render the grid cell
614  $colSpan = (int)$columnConfig['colspan'];
615  $rowSpan = (int)$columnConfig['rowspan'];
616  $grid .= '<td valign="top"' .
617  ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
618  ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
619  ' class="t3-gridCell t3-page-column t3-page-column-' . $columnKey .
620  ((!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '') ? ' t3-gridCell-unassigned' : '') .
621  ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) || !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos']) ? ' t3-gridCell-restricted' : '') .
622  ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') .
623  ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
624 
625  // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
626  // If not, a new header without any buttons will be generated.
627  if (
628  isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
629  && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
630  ) {
631  $grid .= $head[$columnKey] . $content[$columnKey];
632  } elseif (
633  isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
634  && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
635  ) {
636  $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
637  } elseif (
638  isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
639  && !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
640  ) {
641  $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
642  ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
643  } elseif (isset($columnConfig['name']) && strlen($columnConfig['name']) > 0) {
644  $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
645  . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
646  } else {
647  $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
648  }
649 
650  $grid .= '</td>';
651  }
652  $grid .= '</tr>';
653  }
654  $out .= $grid . '</table></div>';
655  }
656  // CSH:
657  $out .= BackendUtility::cshItem($this->descrTable, 'columns_multi', $GLOBALS['BACK_PATH']);
658  }
659  // If language mode, then make another presentation:
660  // Notice that THIS presentation will override the value of $out!
661  // But it needs the code above to execute since $languageColumn is filled with content we need!
662  if ($this->tt_contentConfig['languageMode']) {
663  // Get language selector:
664  $languageSelector = $this->languageSelector($id);
665  // Reset out - we will make new content here:
666  $out = '';
667  // Traverse languages found on the page and build up the table displaying them side by side:
668  $cCont = array();
669  $sCont = array();
670  foreach ($langListArr as $lP) {
671  // Header:
672  $lP = (int)$lP;
673  $cCont[$lP] = '
674  <td valign="top" class="t3-page-lang-column">
675  <h3>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</h3>
676  </td>';
677 
678  // "View page" icon is added:
679  if (!VersionState::cast($this->getPageLayoutController()->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
680  $onClick = BackendUtility::viewOnClick($this->id, $this->backPath, BackendUtility::BEgetRootLine($this->id), '', '', ('&L=' . $lP));
681  $viewLink = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
682  }
683  // Language overlay page header:
684  if ($lP) {
685  list($lpRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
686  BackendUtility::workspaceOL('pages_language_overlay', $lpRecord);
687  $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
688  $lPLabel = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon(
689  IconUtility::getSpriteIconForRecord('pages_language_overlay', $lpRecord),
690  'pages_language_overlay',
691  $lpRecord['uid']
692  ) . $viewLink . ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')
693  ? '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath))
694  . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">'
695  . IconUtility::getSpriteIcon('actions-document-open') . '</a>'
696  : ''
697  ) . htmlspecialchars(GeneralUtility::fixed_lgd_cs($lpRecord['title'], 20));
698  } else {
699  $lPLabel = $viewLink;
700  }
701  $sCont[$lP] = '
702  <td nowrap="nowrap" class="t3-page-lang-column t3-page-lang-label">' . $lPLabel . '</td>';
703  }
704  // Add headers:
705  $out .= '<tr>' . implode($cCont) . '</tr>';
706  $out .= '<tr>' . implode($sCont) . '</tr>';
707  // Traverse previously built content for the columns:
708  foreach ($languageColumn as $cKey => $cCont) {
709  $out .= '
710  <tr>
711  <td valign="top" class="t3-gridCell t3-page-column t3-page-lang-column">' . implode(('</td>' . '
712  <td valign="top" class="t3-gridCell t3-page-column t3-page-lang-column">'), $cCont) . '</td>
713  </tr>';
714  if ($this->defLangBinding) {
715  // "defLangBinding" mode
716  foreach ($defLanguageCount[$cKey] as $defUid) {
717  $cCont = array();
718  foreach ($langListArr as $lP) {
719  $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton(
720  $this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP),
721  $lP
722  );
723  }
724  $out .= '
725  <tr>
726  <td valign="top" class="t3-page-lang-column">' . implode(('</td>' . '
727  <td valign="top" class="t3-page-lang-column">'), $cCont) . '</td>
728  </tr>';
729  }
730  // Create spacer:
731  $cCont = array_fill(0, count($langListArr), '&nbsp;');
732  $out .= '
733  <tr>
734  <td valign="top" class="t3-page-lang-column">' . implode(('</td>' . '
735  <td valign="top" class="t3-page-lang-column">'), $cCont) . '</td>
736  </tr>';
737  }
738  }
739  // Finally, wrap it all in a table and add the language selector on top of it:
740  $out = $languageSelector . '
741  <div class="t3-lang-gridContainer">
742  <table cellpadding="0" cellspacing="0" class="t3-page-langMode">
743  ' . $out . '
744  </table>
745  </div>';
746  // CSH:
747  $out .= BackendUtility::cshItem($this->descrTable, 'language_list', $GLOBALS['BACK_PATH']);
748  }
749  } else {
750  // SINGLE column mode (columns shown beneath each other):
751  if ($this->tt_contentConfig['sys_language_uid'] == 0 || !$this->defLangBinding) {
752  // Initialize:
753  if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid'] == 0) {
754  $showLanguage = ' AND sys_language_uid IN (0,-1)';
755  $lP = 0;
756  } else {
757  $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig['sys_language_uid'];
758  $lP = $this->tt_contentConfig['sys_language_uid'];
759  }
760  $cList = explode(',', $this->tt_contentConfig['showSingleCol']);
761  $out = '';
762  // Expand the table to some preset dimensions:
763  $out .= '
764  <tr>
765  <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>
766  <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
767  <td><img src="clear.gif" width="10" height="1" alt="" /></td>
768  <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
769  </tr>';
770 
771  // Select content records per column
772  $contentRecordsPerColumn = $this->getContentRecordsPerColumn('tt_content', $id, array_values($cList), $showHidden . $showLanguage);
773  // Traverse columns to display top-on-top
774  foreach ($cList as $counter => $key) {
775  $c = 0;
776  $rowArr = $contentRecordsPerColumn[$key];
777  $this->generateTtContentDataArray($rowArr);
778  $numberOfContentElementsInColumn = count($rowArr);
779  $rowOut = '';
780  // 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:
781  if ($this->doEdit && $this->option_showBigButtons && !(int)$key && $numberOfContentElementsInColumn == 0) {
782  $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $id . '&colPos=' . (int)$key
783  . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl='
784  . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';';
785  $theNewButton = $this->getPageLayoutController()->doc->t3Button($onClick, $this->getLanguageService()->getLL('newPageContent'));
786  $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
787  } else {
788  $theNewButton = '';
789  }
790  $editUidList = '';
791  // Traverse any selected elements:
792  foreach ($rowArr as $rKey => $row) {
793  if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
794  $c++;
795  $editUidList .= $row['uid'] . ',';
796  $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
797  // Create row output:
798  $rowOut .= '
799  <tr>
800  <td></td>
801  <td valign="top">' . $this->tt_content_drawHeader($row) . '</td>
802  <td>&nbsp;</td>
803  <td' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . ' valign="top">'
804  . $this->tt_content_drawItem($row, $isRTE) . '</td>
805  </tr>';
806  // If the element was not the last element, add a divider line:
807  if ($c != $numberOfContentElementsInColumn) {
808  $rowOut .= '
809  <tr>
810  <td></td>
811  <td colspan="3"><img'
812  . IconUtility::skinImg($this->backPath, 'gfx/stiblet_medium2.gif', 'width="468" height="1"')
813  . ' class="c-divider" alt="" /></td>
814  </tr>';
815  }
816  } else {
817  unset($rowArr[$rKey]);
818  }
819  }
820  // Add spacer between sections in the vertical list
821  if ($counter) {
822  $out .= '
823  <tr>
824  <td></td>
825  <td colspan="3"><br /><br /><br /><br /></td>
826  </tr>';
827  }
828  // Add section header:
829  $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig['sys_language_uid']);
830  $pasteP = array('colPos' => $key, 'sys_language_uid' => $this->tt_contentConfig['sys_language_uid']);
831  $out .= '
832 
833  <!-- Column header: -->
834  <tr>
835  <td></td>
836  <td valign="top" colspan="3">' . $this->tt_content_drawColHeader(
837  BackendUtility::getProcessedValue('tt_content', 'colPos', $key),
838  $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '',
839  $newP,
840  $pasteP
841  ) . $theNewButton . '<br /></td>
842  </tr>';
843  // Finally, add the content from the records in this column:
844  $out .= $rowOut;
845  }
846  // Finally, wrap all table rows in one, big table:
847  $out = '
848  <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
849  ' . $out . '
850  </table>';
851  // CSH:
852  $out .= BackendUtility::cshItem($this->descrTable, 'columns_single', $GLOBALS['BACK_PATH']);
853  } else {
854  $out = '<br/><br/>' . $this->getPageLayoutController()->doc->icons(1)
855  . 'Sorry, you cannot view a single language in this localization mode (Default Language Binding is enabled)<br/><br/>';
856  }
857  }
858  // Add the big buttons to page:
859  if ($this->option_showBigButtons) {
860  $bArray = array();
861  if (!$this->getPageLayoutController()->current_sys_language) {
862  if ($this->ext_CALC_PERMS & 2) {
863  $bArray[0] = $this->getPageLayoutController()->doc->t3Button(
864  BackendUtility::editOnClick('&edit[pages][' . $id . ']=edit', $this->backPath, ''),
865  $this->getLanguageService()->getLL('editPageProperties')
866  );
867  }
868  } else {
869  if ($this->doEdit && $this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
870  list($languageOverlayRecord) = BackendUtility::getRecordsByField(
871  'pages_language_overlay',
872  'pid',
873  $id,
874  'AND sys_language_uid=' . (int)$this->getPageLayoutController()->current_sys_language
875  );
876  $bArray[0] = $this->getPageLayoutController()->doc->t3Button(
877  BackendUtility::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . ']=edit',
878  $this->backPath, ''),
879  $this->getLanguageService()->getLL('editPageProperties_curLang')
880  );
881  }
882  }
883  if ($this->ext_CALC_PERMS & 4 || $this->ext_CALC_PERMS & 2) {
884  $bArray[1] = $this->getPageLayoutController()->doc->t3Button(
885  'window.location.href=\'' . $this->backPath . 'move_el.php?table=pages&uid=' . $id
886  . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';',
887  $this->getLanguageService()->getLL('move_page')
888  );
889  }
890  if ($this->ext_CALC_PERMS & 8) {
891  $bArray[2] = $this->getPageLayoutController()->doc->t3Button(
892  'window.location.href=\'' . $this->backPath . 'db_new.php?id=' . $id
893  . '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';',
894  $this->getLanguageService()->getLL('newPage2')
895  );
896  }
897  if ($this->doEdit && $this->ext_function == 1) {
898  $bArray[3] = $this->getPageLayoutController()->doc->t3Button(
899  'window.location.href=\'db_new_content_el.php?id=' . $id
900  . '&sys_language_uid=' . $this->getPageLayoutController()->current_sys_language
901  . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';',
902  $this->getLanguageService()->getLL('newPageContent2')
903  );
904  }
905  $out = '
906  <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
907  <tr>
908  <td>' . implode('</td>
909  <td>', $bArray) . '</td>
910  <td>' . BackendUtility::cshItem($this->descrTable, 'button_panel', $GLOBALS['BACK_PATH']) . '</td>
911  </tr>
912  </table>
913  <br />
914  ' . $out;
915  }
916  // Return content:
917  return $out;
918  }
919 
926  public function getBackendLayoutConfiguration() {
927  GeneralUtility::logDeprecatedFunction();
928  return $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
929  }
930 
931  /**********************************
932  *
933  * Generic listing of items
934  *
935  **********************************/
947  public function makeOrdinaryList($table, $id, $fList, $icon = FALSE, $addWhere = '') {
948  // Initialize
949  $queryParts = $this->makeQueryArray($table, $id, $addWhere);
950  $this->setTotalItems($queryParts);
951  $dbCount = 0;
952  $result = FALSE;
953  // Make query for records if there were any records found in the count operation
954  if ($this->totalItems) {
955  $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
956  // Will return FALSE, if $result is invalid
957  $dbCount = $this->getDatabase()->sql_num_rows($result);
958  }
959  // If records were found, render the list
960  if (!$dbCount) {
961  return '';
962  }
963  // Set fields
964  $out = '';
965  $this->fieldArray = GeneralUtility::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', TRUE);
966  $theData = array();
967  $theData = $this->headerFields($this->fieldArray, $table, $theData);
968  // Title row
969  $localizedTableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
970  $out .= '<tr class="t3-row-header">' . '<td nowrap="nowrap" class="col-icon"></td>'
971  . '<td nowrap="nowrap" colspan="' . (count($theData) - 2) . '"><span class="c-table">'
972  . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td nowrap="nowrap" class="col-icon"></td>'
973  . '</tr>';
974  // Column's titles
975  if ($this->doEdit) {
976  $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
977  '&edit[' . $table . '][' . $this->id . ']=new',
978  $this->backPath
979  )) . '" title="' . $this->getLanguageService()->getLL('new', TRUE) . '">'
980  . IconUtility::getSpriteIcon('actions-document-new') . '</a>';
981  }
982  $out .= $this->addelement(1, '', $theData, ' class="c-headLine"', 15);
983  // Render Items
984  $this->eCounter = $this->firstElementNumber;
985  while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
987  if (is_array($row)) {
988  list($flag, $code) = $this->fwd_rwd_nav();
989  $out .= $code;
990  if ($flag) {
991  $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
992  $Nrow = array();
993  // Setting icons links
994  if ($icon) {
995  $Nrow['__cmds__'] = $this->getIcon($table, $row);
996  }
997  // Get values:
998  $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
999  // Attach edit icon
1000  if ($this->doEdit) {
1001  $Nrow['__editIconLink__'] = '<a href="#" onclick="' . htmlspecialchars(
1002  BackendUtility::editOnClick($params, $this->backPath))
1003  . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">'
1004  . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1005  } else {
1006  $Nrow['__editIconLink__'] = $this->noEditIcon();
1007  }
1008  $out .= $this->addelement(1, '', $Nrow, 'class="db_list_normal"');
1009  }
1010  $this->eCounter++;
1011  }
1012  }
1013  // Wrap it all in a table:
1014  $out = '
1015  <!--
1016  Standard list of table "' . $table . '"
1017  -->
1018  <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
1019  ' . $out . '
1020  </table>';
1021  return $out;
1022  }
1023 
1039  public function dataFields($fieldArr, $table, $row, $out = array()) {
1040  // Check table validity
1041  if (!isset($GLOBALS['TCA'][$table])) {
1042  return $out;
1043  }
1044 
1045  $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1046  // Traverse fields
1047  foreach ($fieldArr as $fieldName) {
1048  if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1049  // Each field has its own cell (if configured in TCA)
1050  // If the column is a thumbnail column:
1051  if ($fieldName == $thumbsCol) {
1052  $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1053  } else {
1054  // ... otherwise just render the output:
1055  $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(
1056  BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1057  250)
1058  )));
1059  }
1060  } else {
1061  // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1062  // the field name with ";" and check each value there as a TCA configured field)
1063  $theFields = explode(';', $fieldName);
1064  // Traverse fields, separated by ";" (displayed in a single cell).
1065  foreach ($theFields as $fName2) {
1066  if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1067  $out[$fieldName] .= '<strong>' . $this->getLanguageService()->sL(
1068  $GLOBALS['TCA'][$table]['columns'][$fName2]['label'],
1069  TRUE
1070  ) . '</strong>' . '&nbsp;&nbsp;' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
1071  BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1072  25
1073  )) . '<br />';
1074  }
1075  }
1076  }
1077  // If no value, add a nbsp.
1078  if (!$out[$fieldName]) {
1079  $out[$fieldName] = '&nbsp;';
1080  }
1081  // Wrap in dimmed-span tags if record is "disabled"
1082  if ($this->isDisabled($table, $row)) {
1083  $out[$fieldName] = $this->getDocumentTemplate()->dfw($out[$fieldName]);
1084  }
1085  }
1086  return $out;
1087  }
1088 
1099  public function headerFields($fieldArr, $table, $out = array()) {
1100  foreach ($fieldArr as $fieldName) {
1101  $ll = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], TRUE);
1102  $out[$fieldName] = $ll ? $ll : '&nbsp;';
1103  }
1104  return $out;
1105  }
1106 
1117  protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '') {
1118  $columns = array_map('intval', $columns);
1119  $contentRecordsPerColumn = array_fill_keys($columns, array());
1120 
1121  $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos IN (' . implode(',', $columns) . ')' . $additionalWhereClause);
1122  $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1123  // Traverse any selected elements and render their display code:
1124  $rowArr = $this->getResult($result);
1125 
1126  foreach ($rowArr as $record) {
1127  $columnValue = $record['colPos'];
1128  $contentRecordsPerColumn[$columnValue][] = $record;
1129  }
1130 
1131  return $contentRecordsPerColumn;
1132  }
1133 
1134  /**********************************
1135  *
1136  * Additional functions; Pages
1137  *
1138  **********************************/
1150  public function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth) {
1151  $depth--;
1152  if ($depth >= 0) {
1153  $res = $this->getDatabase()->exec_SELECTquery('*', 'pages', 'pid=' . (int)$pid . $qWhere, '', 'sorting');
1154  $c = 0;
1155  $rc = $this->getDatabase()->sql_num_rows($res);
1156  while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1157  BackendUtility::workspaceOL('pages', $row);
1158  if (is_array($row)) {
1159  $c++;
1160  $row['treeIcons'] = $treeIcons . '<img' . IconUtility::skinImg(
1161  $this->backPath,
1162  'gfx/ol/join' . ($rc == $c ? 'bottom' : '') . '.gif',
1163  'width="18" height="16"'
1164  ) . ' alt="" />';
1165  $theRows[] = $row;
1166  // Get the branch
1167  $spaceOutIcons = '<img' . IconUtility::skinImg(
1168  $this->backPath,
1169  'gfx/ol/' . ($rc == $c ? 'blank.gif' : 'line.gif'),
1170  'width="18" height="16"'
1171  ) . ' alt="" />';
1172  $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ? 0 : $depth);
1173  }
1174  }
1175  } else {
1176  $count = $this->getDatabase()->exec_SELECTcountRows('uid', 'pages', 'pid=' . (int)$pid . $qWhere);
1177  if ($count) {
1178  $this->plusPages[$pid] = $count;
1179  }
1180  }
1181  return $theRows;
1182  }
1183 
1192  public function pages_drawItem($row, $fieldArr) {
1193  // Initialization
1194  $theIcon = $this->getIcon('pages', $row);
1195  // Preparing and getting the data-array
1196  $theData = array();
1197  foreach ($fieldArr as $field) {
1198  switch ($field) {
1199  case 'title':
1200  $red = $this->plusPages[$row['uid']] ? '<font color="red"><strong>+&nbsp;</strong></font>' : '';
1201  $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
1202  if ($red) {
1203  $pTitle = '<a href="'
1204  . htmlspecialchars($this->script . ((strpos($this->script, '?') !== FALSE) ? '&' : '?')
1205  . 'id=' . $row['uid']) . '">' . $pTitle . '</a>';
1206  }
1207  $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . '&nbsp;&nbsp;';
1208  break;
1209  case 'php_tree_stop':
1210  // Intended fall through
1211  case 'TSconfig':
1212  $theData[$field] = $row[$field] ? '&nbsp;<strong>x</strong>' : '&nbsp;';
1213  break;
1214  case 'uid':
1215  if ($this->getBackendUser()->doesUserHaveAccess($row, 2)) {
1216  $params = '&edit[pages][' . $row['uid'] . ']=edit';
1217  $eI = '<a href="#" onclick="'
1218  . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, ''))
1219  . '" title="' . $this->getLanguageService()->getLL('editThisPage', TRUE) . '">'
1220  . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1221  } else {
1222  $eI = '';
1223  }
1224  $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1225  break;
1226  default:
1227  if (substr($field, 0, 6) == 'table_') {
1228  $f2 = substr($field, 6);
1229  if ($GLOBALS['TCA'][$f2]) {
1230  $c = $this->numberOfRecords($f2, $row['uid']);
1231  $theData[$field] = '&nbsp;&nbsp;' . ($c ? $c : '');
1232  }
1233  } else {
1234  $theData[$field] = '&nbsp;&nbsp;'
1235  . htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
1236  }
1237  }
1238  }
1239  $this->addElement_tdParams['title'] = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '';
1240  return $this->addelement(1, '', $theData);
1241  }
1242 
1243  /**********************************
1244  *
1245  * Additional functions; Content Elements
1246  *
1247  **********************************/
1258  public function tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams = NULL) {
1259  $iconsArr = array();
1260  // Create command links:
1261  if ($this->tt_contentConfig['showCommands']) {
1262  // Edit whole of column:
1263  if ($editParams) {
1264  $iconsArr['edit'] = '<a href="#" onclick="'
1265  . htmlspecialchars(BackendUtility::editOnClick($editParams, $this->backPath)) . '" title="'
1266  . $this->getLanguageService()->getLL('editColumn', TRUE) . '">'
1267  . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1268  }
1269  if ($pasteParams) {
1270  $elFromTable = $this->clipboard->elFromTable('tt_content');
1271  if (count($elFromTable)) {
1272  $iconsArr['paste'] = '<a href="'
1273  . htmlspecialchars($this->clipboard->pasteUrl('tt_content', $this->id, TRUE, $pasteParams))
1274  . '" onclick="' . htmlspecialchars(('return '
1275  . $this->clipboard->confirmMsg('pages', $this->pageRecord, 'into', $elFromTable, $colName)))
1276  . '" title="' . $this->getLanguageService()->getLL('pasteIntoColumn', TRUE) . '">'
1277  . IconUtility::getSpriteIcon('actions-document-paste-into') . '</a>';
1278  }
1279  }
1280  }
1281  $icons = '';
1282  if (count($iconsArr)) {
1283  $icons = '<div class="t3-page-colHeader-icons">' . implode('', $iconsArr) . '</div>';
1284  }
1285  // Create header row:
1286  $out = '<div class="t3-page-colHeader t3-row-header">
1287  ' . $icons . '
1288  <div class="t3-page-colHeader-label">' . htmlspecialchars($colName) . '</div>
1289  </div>';
1290  return $out;
1291  }
1292 
1299  protected function tt_content_drawFooter(array $row) {
1300  $content = '';
1301  // Get processed values:
1302  $info = array();
1303  $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1304  // Display info from records fields:
1305  if (count($info)) {
1306  $content = '<div class="t3-page-ce-info">
1307  ' . implode('<br />', $info) . '
1308  </div>';
1309  }
1310  // Wrap it
1311  if (!empty($content)) {
1312  $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1313  }
1314  return $content;
1315  }
1316 
1328  public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = FALSE, $langMode = FALSE, $dragDropEnabled = FALSE) {
1329  $out = '';
1330  // If show info is set...;
1331  if ($this->tt_contentConfig['showInfo'] && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1332  // Render control panel for the element:
1333  if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1334  // Edit content element:
1335  $params = '&edit[tt_content][' . $this->tt_contentData['nextThree'][$row['uid']] . ']=edit';
1336  $out .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
1337  $params,
1338  $this->backPath,
1339  GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
1340  )) . '" title="' . htmlspecialchars($this->nextThree > 1
1341  ? sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree)
1342  : $this->getLanguageService()->getLL('edit'))
1343  . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1344  // Hide element:
1345  $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1346  if (
1347  $hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1348  && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1349  || $this->getBackendUser()->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1350  ) {
1351  if ($row[$hiddenField]) {
1352  $value = 0;
1353  $label = 'unHide';
1354  } else {
1355  $value = 1;
1356  $label = 'hide';
1357  }
1358  $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
1359  . '][' . $hiddenField . ']=' . $value;
1360  $out .= '<a href="' . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1361  . '" title="' . $this->getLanguageService()->getLL($label, TRUE) . '">'
1362  . IconUtility::getSpriteIcon('actions-edit-' . strtolower($label)) . '</a>';
1363  }
1364  // Delete
1365  $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1366  $confirm = GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('deleteWarning')
1367  . BackendUtility::translationCount('tt_content', $row['uid'], (' '
1368  . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')))
1369  );
1370  $out .= '<a href="' . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1371  . '" onclick="' . htmlspecialchars(('return confirm(' . $confirm . ');')) . '" title="'
1372  . $this->getLanguageService()->getLL('deleteItem', TRUE) . '">'
1373  . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
1374  if (!$disableMoveAndNewButtons) {
1375  $moveButtonContent = '';
1376  $displayMoveButtons = FALSE;
1377  // Move element up:
1378  if ($this->tt_contentData['prev'][$row['uid']]) {
1379  $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
1380  $moveButtonContent .= '<a href="'
1381  . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1382  . '" title="' . $this->getLanguageService()->getLL('moveUp', TRUE) . '">'
1383  . IconUtility::getSpriteIcon('actions-move-up') . '</a>';
1384  if (!$dragDropEnabled) {
1385  $displayMoveButtons = TRUE;
1386  }
1387  } else {
1388  $moveButtonContent .= IconUtility::getSpriteIcon('empty-empty');
1389  }
1390  // Move element down:
1391  if ($this->tt_contentData['next'][$row['uid']]) {
1392  $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
1393  $moveButtonContent .= '<a href="'
1394  . htmlspecialchars($this->getPageLayoutController()->doc->issueCommand($params))
1395  . '" title="' . $this->getLanguageService()->getLL('moveDown', TRUE) . '">'
1396  . IconUtility::getSpriteIcon('actions-move-down') . '</a>';
1397  if (!$dragDropEnabled) {
1398  $displayMoveButtons = TRUE;
1399  }
1400  } else {
1401  $moveButtonContent .= IconUtility::getSpriteIcon('empty-empty');
1402  }
1403  if ($displayMoveButtons) {
1404  $out .= '<span class="t3-page-ce-icons-move">' . $moveButtonContent . '</span>';
1405  }
1406  }
1407  }
1408  }
1409  $additionalIcons = array();
1410  $additionalIcons[] = $this->getIcon('tt_content', $row) . ' ';
1411  $additionalIcons[] = $langMode ? $this->languageFlag($row['sys_language_uid'], FALSE) : '';
1412  // Get record locking status:
1413  if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) {
1414  $additionalIcons[] = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg'])
1415  . ');return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">'
1416  . IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
1417  }
1418  // Call stats information hook
1419  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1420  $_params = array('tt_content', $row['uid'], &$row);
1421  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1422  $additionalIcons[] = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1423  }
1424  }
1425  // Wrap the whole header
1426  // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1427  return '<h4 class="t3-page-ce-header">
1428  <div class="t3-row-header">
1429  <span class="ce-icons-left">' . implode('', $additionalIcons) . '</span>
1430  <span class="ce-icons">
1431  ' . $out . '
1432  </span></div>
1433  </h4>
1434  <div class="t3-page-ce-body">';
1435  }
1436 
1446  public function tt_content_drawItem($row, $isRTE = FALSE) {
1447  $out = '';
1448  $outHeader = '';
1449  // Make header:
1450  if ($row['header']) {
1451  $infoArr = array();
1452  $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1453  $hiddenHeaderNote = '';
1454  // If header layout is set to 'hidden', display an accordant note:
1455  if ($row['header_layout'] == 100) {
1456  $hiddenHeaderNote = ' <em>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.hidden', TRUE) . ']</em>';
1457  }
1458  $outHeader = $row['date']
1459  ? htmlspecialchars($this->itemLabels['date'] . ' ' . BackendUtility::date($row['date'])) . '<br />'
1460  : '';
1461  $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
1462  . $hiddenHeaderNote . '</strong><br />';
1463  }
1464  // Make content:
1465  $infoArr = array();
1466  $drawItem = TRUE;
1467  // Hook: Render an own preview of a record
1468  $drawItemHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1469  if (is_array($drawItemHooks)) {
1470  foreach ($drawItemHooks as $hookClass) {
1471  $hookObject = GeneralUtility::getUserObj($hookClass);
1472  if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
1473  throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawItemHookInterface', 1218547409);
1474  }
1475  $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1476  }
1477  }
1478  // Draw preview of the item depending on its CType (if not disabled by previous hook):
1479  if ($drawItem) {
1480  switch ($row['CType']) {
1481  case 'header':
1482  if ($row['subheader']) {
1483  $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1484  }
1485  break;
1486  case 'text':
1487 
1488  case 'textpic':
1489 
1490  case 'image':
1491  if ($row['CType'] == 'text' || $row['CType'] == 'textpic') {
1492  if ($row['bodytext']) {
1493  $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1494  }
1495  }
1496  if ($row['CType'] == 'textpic' || $row['CType'] == 'image') {
1497  if ($row['image']) {
1498  $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1499  $fileReferences = BackendUtility::resolveFileReferences('tt_content', 'image', $row);
1500  if (!empty($fileReferences)) {
1501  $linkedContent = '';
1502  foreach ($fileReferences as $fileReference) {
1503  $linkedContent .= htmlspecialchars($fileReference->getDescription()) . '<br />';
1504  }
1505  $out .= $this->linkEditContent($linkedContent, $row);
1506  unset($linkedContent);
1507  }
1508  }
1509  }
1510  break;
1511  case 'bullets':
1512 
1513  case 'table':
1514 
1515  case 'mailform':
1516  if ($row['bodytext']) {
1517  $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1518  }
1519  break;
1520  case 'uploads':
1521  if ($row['media']) {
1522  $out .= $this->thumbCode($row, 'tt_content', 'media') . '<br />';
1523  }
1524  break;
1525  case 'multimedia':
1526  if ($row['multimedia']) {
1527  $out .= $this->renderText($row['multimedia']) . '<br />';
1528  $out .= $this->renderText($row['parameters']) . '<br />';
1529  }
1530  break;
1531  case 'menu':
1532  if ($row['pages']) {
1533  $out .= $this->linkEditContent($row['pages'], $row) . '<br />';
1534  }
1535  break;
1536  case 'shortcut':
1537  if (!empty($row['records'])) {
1538  $shortcutContent = array();
1539  $recordList = explode(',', $row['records']);
1540  foreach ($recordList as $recordIdentifier) {
1541  $split = BackendUtility::splitTable_Uid($recordIdentifier);
1542  $tableName = empty($split[0]) ? 'tt_content' : $split[0];
1543  $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
1544  if (is_array($shortcutRecord)) {
1545  $icon = IconUtility::getSpriteIconForRecord($tableName, $shortcutRecord);
1546  $onClick = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon($icon, $tableName,
1547  $shortcutRecord['uid'], 1, '', '+copy,info,edit,view', TRUE);
1548  $shortcutContent[] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $icon . '</a>'
1549  . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
1550  }
1551  }
1552  $out .= implode('<br />', $shortcutContent) . '<br />';
1553  }
1554  break;
1555  case 'list':
1556  $hookArr = array();
1557  $hookOut = '';
1558  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1559  $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1560  } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1561  $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1562  }
1563  if (count($hookArr) > 0) {
1564  $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1565  foreach ($hookArr as $_funcRef) {
1566  $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1567  }
1568  }
1569  if ((string)$hookOut !== '') {
1570  $out .= $hookOut;
1571  } elseif (!empty($row['list_type'])) {
1572  $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
1573  if (!empty($label)) {
1574  $out .= '<strong>' . $this->getLanguageService()->sL($label, TRUE) . '</strong><br />';
1575  } else {
1576  $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
1578  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1579  htmlspecialchars($message),
1580  '',
1582  )->render();
1583  }
1584  } elseif (!empty($row['select_key'])) {
1585  $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), TRUE)
1586  . ' ' . htmlspecialchars($row['select_key']) . '<br />';
1587  } else {
1588  $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
1589  }
1590  $out .= $this->getLanguageService()->sL(
1591  BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages']),
1592  TRUE
1593  ) . '<br />';
1594  break;
1595  case 'script':
1596  $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), TRUE)
1597  . ' ' . htmlspecialchars($row['select_key']) . '<br />';
1598  $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1599  $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1600  break;
1601  default:
1602  $contentType = $this->CType_labels[$row['CType']];
1603 
1604  if (isset($contentType)) {
1605  $out .= '<strong>' . htmlspecialchars($contentType) . '</strong><br />';
1606  if ($row['bodytext']) {
1607  $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1608  }
1609  if ($row['image']) {
1610  $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1611  }
1612  } else {
1613  $message = sprintf(
1614  $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue'),
1615  $row['CType']
1616  );
1618  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1619  htmlspecialchars($message),
1620  '',
1622  )->render();
1623  }
1624  }
1625  }
1626  // Wrap span-tags:
1627  $out = '
1628  <span class="exampleContent">' . $out . '</span>';
1629  // Add header:
1630  $out = $outHeader . $out;
1631  // Add RTE button:
1632  if ($isRTE) {
1633  $out .= $this->linkRTEbutton($row);
1634  }
1635  // Return values:
1636  if ($this->isDisabled('tt_content', $row)) {
1637  return $this->getDocumentTemplate()->dfw($out);
1638  } else {
1639  return $out;
1640  }
1641  }
1642 
1654  public function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) {
1655  if ($lP && count($defLanguageCount)) {
1656  // Select all translations here:
1657  $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . (int)$lP
1658  . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')');
1659  $result = $this->getDatabase()->exec_SELECT_queryArray($queryParts);
1660  // Flip uids:
1661  $defLanguageCount = array_flip($defLanguageCount);
1662  // Traverse any selected elements and unset original UID if any:
1663  $rowArr = $this->getResult($result);
1664  foreach ($rowArr as $row) {
1665  unset($defLanguageCount[$row['l18n_parent']]);
1666  }
1667  // Flip again:
1668  $defLanguageCount = array_keys($defLanguageCount);
1669  }
1670  return $defLanguageCount;
1671  }
1672 
1681  public function newLanguageButton($defLanguageCount, $lP) {
1682  if (!$this->doEdit || count($defLanguageCount) === 0 || !$lP) {
1683  return '';
1684  }
1685  $params = '';
1686  foreach ($defLanguageCount as $uidVal) {
1687  $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP;
1688  }
1689  // Copy for language:
1690  $onClick = 'window.location.href=\'' . $this->getPageLayoutController()->doc->issueCommand($params) . '\'; return false;';
1691  $theNewButton = '<div class="t3-page-lang-copyce">' .
1692  $this->getPageLayoutController()->doc->t3Button(
1693  $onClick,
1694  $this->getLanguageService()->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']'
1695  ) . '</div>';
1696  return $theNewButton;
1697  }
1698 
1709  public function newContentElementOnClick($id, $colPos, $sys_language) {
1710  if ($this->option_newWizard) {
1711  $onClick = 'window.location.href=\'db_new_content_el.php?id=' . $id . '&colPos=' . $colPos
1712  . '&sys_language_uid=' . $sys_language . '&uid_pid=' . $id
1713  . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';';
1714  } else {
1715  $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
1716  . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language, $this->backPath);
1717  }
1718  return $onClick;
1719  }
1720 
1731  public function linkEditContent($str, $row) {
1732  $addButton = '';
1733  $onClick = '';
1734  if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
1735  // Setting onclick action for content link:
1736  $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit', $this->backPath);
1737  }
1738  // Return link
1739  return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick)
1740  . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">' . $str . '</a>' . $addButton : $str;
1741  }
1742 
1750  public function linkRTEbutton($row) {
1751  $params = array();
1752  $params['table'] = 'tt_content';
1753  $params['uid'] = $row['uid'];
1754  $params['pid'] = $row['pid'];
1755  $params['field'] = 'bodytext';
1756  $params['returnUrl'] = GeneralUtility::linkThisScript();
1757  $RTEonClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_rte', array('P' => $params))) . ';return false;';
1758  $addButton = $this->option_showBigButtons && $this->doEdit
1759  ? $this->getPageLayoutController()->doc->t3Button($RTEonClick, $this->getLanguageService()->getLL('editInRTE'))
1760  : '';
1761  return $addButton;
1762  }
1763 
1774  public function languageSelector($id) {
1775  if ($this->getBackendUser()->check('tables_modify', 'pages_language_overlay')) {
1776  // First, select all
1777  $res = $this->getPageLayoutController()->exec_languageQuery(0);
1778  $langSelItems = array();
1779  $langSelItems[0] = '
1780  <option value="0"></option>';
1781  while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1782  if ($this->getBackendUser()->checkLanguageAccess($row['uid'])) {
1783  $langSelItems[$row['uid']] = '
1784  <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1785  }
1786  }
1787  // Then, subtract the languages which are already on the page:
1788  $res = $this->getPageLayoutController()->exec_languageQuery($id);
1789  while ($row = $this->getDatabase()->sql_fetch_assoc($res)) {
1790  unset($langSelItems[$row['uid']]);
1791  }
1792  // Remove disallowed languages
1793  if (count($langSelItems) > 1
1794  && !$this->getBackendUser()->user['admin']
1795  && strlen($this->getBackendUser()->groupData['allowed_languages'])
1796  ) {
1797  $allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
1798  if (count($allowed_languages)) {
1799  foreach ($langSelItems as $key => $value) {
1800  if (!isset($allowed_languages[$key]) && $key != 0) {
1801  unset($langSelItems[$key]);
1802  }
1803  }
1804  }
1805  }
1806  // Remove disabled languages
1807  $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1808  $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages'])
1809  ? GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], TRUE)
1810  : array();
1811  if (count($langSelItems) && count($disableLanguages)) {
1812  foreach ($disableLanguages as $language) {
1813  if ($language != 0 && isset($langSelItems[$language])) {
1814  unset($langSelItems[$language]);
1815  }
1816  }
1817  }
1818  // If any languages are left, make selector:
1819  if (count($langSelItems) > 1) {
1820  $onChangeContent = 'window.location.href=\'' . $this->backPath . 'alt_doc.php?&edit[pages_language_overlay]['
1821  . $id . ']=new&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRecord['doktype']
1822  . '&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='
1823  . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\'';
1824  return $this->getLanguageService()->getLL('new_language', TRUE)
1825  . ': <select name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">
1826  ' . implode('', $langSelItems) . '
1827  </select><br /><br />';
1828  }
1829  }
1830  return '';
1831  }
1832 
1841  public function getResult($result, $table = 'tt_content') {
1842  $output = array();
1843  // Traverse the result:
1844  while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
1845  BackendUtility::workspaceOL($table, $row, -99, TRUE);
1846  if ($row) {
1847  // Add the row to the array:
1848  $output[] = $row;
1849  }
1850  }
1851  $this->generateTtContentDataArray($output);
1852  // Return selected records
1853  return $output;
1854  }
1855 
1856  /********************************
1857  *
1858  * Various helper functions
1859  *
1860  ********************************/
1861 
1871  protected function initializeClipboard() {
1872  // Start clipboard
1873  $this->clipboard = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
1874 
1875  // Initialize - reads the clipboard content from the user session
1876  $this->clipboard->initializeClipboard();
1877 
1878  // This locks the clipboard to the Normal for this request.
1879  $this->clipboard->lockToNormal();
1880 
1881  // Clean up pad
1882  $this->clipboard->cleanCurrent();
1883 
1884  // Save the clipboard content
1885  $this->clipboard->endClipboard();
1886  }
1887 
1894  protected function generateTtContentDataArray(array $rowArray) {
1895  if (empty($this->tt_contentData)) {
1896  $this->tt_contentData = array(
1897  'nextThree' => array(),
1898  'next' => array(),
1899  'prev' => array(),
1900  );
1901  }
1902  foreach ($rowArray as $key => $value) {
1903  // Create the list of the next three ids (for editing links...)
1904  for ($i = 0; $i < $this->nextThree; $i++) {
1905  if (isset($rowArray[$key - $i])
1906  && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
1907  ) {
1908  $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
1909  }
1910  }
1911 
1912  // Create information for next and previous content elements
1913  if (isset($rowArray[$key - 1])) {
1914  if (isset($rowArray[$key - 2])) {
1915  $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
1916  } else {
1917  $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
1918  }
1919  $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
1920  }
1921  }
1922  }
1923 
1932  public function numberOfRecords($table, $pid) {
1933  $count = 0;
1934  if ($GLOBALS['TCA'][$table]) {
1935  $where = 'pid=' . (int)$pid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table);
1936  $count = $this->getDatabase()->exec_SELECTcountRows('uid', $table, $where);
1937  }
1938  return (int)$count;
1939  }
1940 
1948  public function renderText($input) {
1949  $input = strip_tags($input);
1950  $input = GeneralUtility::fixed_lgd_cs($input, 1500);
1951  return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', FALSE));
1952  }
1953 
1962  public function getIcon($table, $row) {
1963  // Initialization
1964  $altText = BackendUtility::getRecordIconAltText($row, $table);
1965  $icon = IconUtility::getSpriteIconForRecord($table, $row, array('title' => $altText));
1966  $this->counter++;
1967  // The icon with link
1968  if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
1969  $icon = $this->getPageLayoutController()->doc->wrapClickMenuOnIcon($icon, $table, $row['uid']);
1970  }
1971  return $icon;
1972  }
1973 
1985  public function getProcessedValue($table, $fieldList, array $row, array &$info) {
1986  // Splitting values from $fieldList
1987  $fieldArr = explode(',', $fieldList);
1988  // Traverse fields from $fieldList
1989  foreach ($fieldArr as $field) {
1990  if ($row[$field]) {
1991  $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
1992  . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
1993  }
1994  }
1995  }
1996 
2005  public function isDisabled($table, $row) {
2006  $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2007  return $enableCols['disabled'] && $row[$enableCols['disabled']]
2008  || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2009  || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2010  }
2011 
2024  public function wordWrapper($content, $max = 50, $char = ' -') {
2026  $array = preg_split('/[ ' . LF . ']/', $content);
2027  foreach ($array as $val) {
2028  if (strlen($val) > $max) {
2029  $content = str_replace($val, substr(chunk_split($val, $max, $char), 0, -1), $content);
2030  }
2031  }
2032  return $content;
2033  }
2034 
2044  public function noEditIcon($label = 'noEditItems') {
2046  'status-edit-read-only',
2047  array('title' => $this->getLanguageService()->getLL($label, TRUE))
2048  );
2049  }
2050 
2058  protected function cleanTableNames() {
2059  // Get all table names:
2060  $tableNames = array_flip(array_keys($GLOBALS['TCA']));
2061  // Unset common names:
2062  unset($tableNames['pages']);
2063  unset($tableNames['static_template']);
2064  unset($tableNames['sys_filemounts']);
2065  unset($tableNames['sys_action']);
2066  unset($tableNames['sys_workflows']);
2067  unset($tableNames['be_users']);
2068  unset($tableNames['be_groups']);
2069  $allowedTableNames = array();
2070  // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2071  if (is_array($tableNames)) {
2072  foreach ($tableNames as $k => $v) {
2073  if ($this->getBackendUser()->check('tables_select', $k)) {
2074  $allowedTableNames['table_' . $k] = $k;
2075  }
2076  }
2077  }
2078  return $allowedTableNames;
2079  }
2080 
2091  public function isRTEforField($table, $row, $field) {
2092  $specConf = $this->getSpecConfForField($table, $row, $field);
2093  if (!count($specConf)) {
2094  return FALSE;
2095  }
2096  $p = BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2097  if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
2099  list($tscPID, $thePidValue) = BackendUtility::getTSCpid($table, $row['uid'], $row['pid']);
2100  // If the pid-value is not negative (that is, a pid could NOT be fetched)
2101  if ($thePidValue >= 0) {
2102  if (!isset($this->rteSetup[$tscPID])) {
2103  $this->rteSetup[$tscPID] = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
2104  }
2105  $RTEtypeVal = BackendUtility::getTCAtypeValue($table, $row);
2106  $thisConfig = BackendUtility::RTEsetup($this->rteSetup[$tscPID]['properties'], $table, $field, $RTEtypeVal);
2107  if (!$thisConfig['disabled']) {
2108  return TRUE;
2109  }
2110  }
2111  }
2112  return FALSE;
2113  }
2114 
2127  public function getSpecConfForField($table, $row, $field) {
2128  // Get types-configuration for the record:
2129  $types_fieldConfig = BackendUtility::getTCAtypes($table, $row);
2130  // Find the given field and return the spec key value if found:
2131  if (is_array($types_fieldConfig)) {
2132  foreach ($types_fieldConfig as $vConf) {
2133  if ($vConf['field'] == $field) {
2134  return $vConf['spec'];
2135  }
2136  }
2137  }
2138  return array();
2139  }
2140 
2141  /*****************************************
2142  *
2143  * External renderings
2144  *
2145  *****************************************/
2146 
2156  public function getTableMenu($id) {
2157  // Initialize:
2158  $this->activeTables = array();
2159  $theTables = array('tt_content');
2160  // External tables:
2161  if (is_array($this->externalTables)) {
2162  $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2163  }
2164  $out = '';
2165  // Traverse tables to check:
2166  foreach ($theTables as $tName) {
2167  // Check access and whether the proper extensions are loaded:
2168  if ($this->getBackendUser()->check('tables_select', $tName)
2169  && (isset($this->externalTables[$tName])
2170  || GeneralUtility::inList('fe_users,tt_content', $tName)
2171  || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2172  )
2173  ) {
2174  // Make query to count records from page:
2175  $c = $this->getDatabase()->exec_SELECTcountRows('uid', $tName, 'pid=' . (int)$id
2177  // If records were found (or if "tt_content" is the table...):
2178  if ($c || GeneralUtility::inList('tt_content', $tName)) {
2179  // Add row to menu:
2180  $out .= '
2181  <td><a href="#' . $tName . '"></a>' . IconUtility::getSpriteIconForRecord(
2182  $tName,
2183  array(),
2184  array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE))
2185  ) . '</td>';
2186  // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2187  $this->activeTables[$tName] = IconUtility::getSpriteIconForRecord(
2188  $tName,
2189  array(),
2190  array('title' => $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE)
2191  . ': ' . $c . ' ' . $this->getLanguageService()->getLL('records', TRUE))
2192  ) . '&nbsp;' . $this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], TRUE);
2193  }
2194  }
2195  }
2196  // Wrap cells in table tags:
2197  $out = '
2198  <!--
2199  Menu of tables on the page (table menu)
2200  -->
2201  <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2202  <tr>' . $out . '
2203  </tr>
2204  </table>';
2205  // Return the content:
2206  return $out;
2207  }
2208 
2212  protected function getBackendLayoutView() {
2214  'TYPO3\\CMS\\Backend\\View\\BackendLayoutView'
2215  );
2216  }
2217 
2221  protected function getBackendUser() {
2222  return $GLOBALS['BE_USER'];
2223  }
2224 
2228  protected function getDatabase() {
2229  return $GLOBALS['TYPO3_DB'];
2230  }
2231 
2235  protected function getLanguageService() {
2236  return $GLOBALS['LANG'];
2237  }
2238 
2242  protected function getPageLayoutController() {
2243  return $GLOBALS['SOBE'];
2244  }
2245 
2249  protected function getDocumentTemplate() {
2250  return $GLOBALS['TBE_TEMPLATE'];
2251  }
2252 
2253 }
pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth)
static translationCount($table, $ref, $msg='')
wordWrapper($content, $max=50, $char=' -')
static skinImg($backPath, $src, $wHattribs='', $outputMode=0)
getResult($result, $table='tt_content')
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
static editOnClick($params, $backPath='', $requestUri='')
static getItemLabel($table, $col, $printAllWrap='')
getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP)
getProcessedValue($table, $fieldList, array $row, array &$info)
languageFlag($sys_language_uid, $addAsAdditionalText=TRUE)
tt_content_drawHeader($row, $space=0, $disableMoveAndNewButtons=FALSE, $langMode=FALSE, $dragDropEnabled=FALSE)
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=FALSE)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
dataFields($fieldArr, $table, $row, $out=array())
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause='')
newContentElementOnClick($id, $colPos, $sys_language)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
newLanguageButton($defLanguageCount, $lP)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
static getSpriteIconForRecord($table, array $row, array $options=array())
if(!defined('TYPO3_MODE')) if(TYPO3_MODE=='BE' &&!(TYPO3_REQUESTTYPE &TYPO3_REQUESTTYPE_INSTALL)) $icons
Definition: ext_tables.php:52
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
static getTCAtypes($table, $rec, $useFieldNameAsKey=0)
static RTEsetup($RTEprop, $table, $field, $type='')
tt_content_drawColHeader($colName, $editParams, $newParams, array $pasteParams=NULL)
static getRecordIconAltText($row, $table='pages')
static fixed_lgd_cs($string, $chars, $appendString='...')
static fixVersioningPid($table, &$rr, $ignoreWorkspaceMatch=FALSE)
static getLabelFromItemListMerged($pageId, $table, $column, $key)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getPagesTSconfig($id, $rootLine=NULL, $returnPartArray=FALSE)
makeOrdinaryList($table, $id, $fList, $icon=FALSE, $addWhere='')
static deleteClause($table, $tableAlias='')
static getLabelFromItemlist($table, $col, $key)
headerFields($fieldArr, $table, $out=array())