TYPO3 CMS  TYPO3_6-2
PageLayoutController.php
Go to the documentation of this file.
1 <?php
3 
24 
31 
32  // Internal, GPvars:
33  // Page Id for which to make the listing
37  public $id;
38 
39  // Pointer - for browsing list of records.
43  public $pointer;
44 
45  // Thumbnails or not
49  public $imagemode;
50 
51  // Search-fields
55  public $search_field;
56 
57  // Search-levels
62 
63  // Show-limit
67  public $showLimit;
68 
69  // Return URL
73  public $returnUrl;
74 
75  // Clear-cache flag - if set, clears page cache for current id.
79  public $clear_cache;
80 
81  // PopView id - for opening a window with the page
85  public $popView;
86 
87  // QuickEdit: Variable, that tells quick edit what to show/edit etc. Format is [tablename]:[uid] with some exceptional values for both parameters (with special meanings).
91  public $edit_record;
92 
93  // QuickEdit: If set, this variable tells quick edit that the last edited record had this value as UID and we should look up the new, real uid value in sys_log.
98 
99  // Internal, static:
100  // Page select perms clause
105 
106  // Module TSconfig
110  public $modTSconfig;
111 
118 
119  // Current ids page record
123  public $pageinfo;
124 
131  public $doc;
132 
133  // Back path of the module
137  public $backPath;
138 
139  // "Pseudo" Description -table name
143  public $descrTable;
144 
145  // List of column-integers to edit. Is set from TSconfig, default is "1,0,2,3"
149  public $colPosList;
150 
151  // Flag: If content can be edited or not.
156 
157  // Users permissions integer for this page.
161  public $CALC_PERMS;
162 
163  // Currently selected language for editing content elements
168 
169  // Module configuration
173  public $MCONF = array();
174 
175  // Menu configuration
179  public $MOD_MENU = array();
180 
181  // Module settings (session variable)
185  public $MOD_SETTINGS = array();
186 
187  // Array, where files to include is accumulated in the init() function
191  public $include_once = array();
192 
193  // Array of tables to be listed by the Web > Page module in addition to the default tables
197  public $externalTables = array();
198 
199  // Internal, dynamic:
200  // Module output accumulation
204  public $content;
205 
206  // Function menu temporary storage
210  public $topFuncMenu;
211 
212  // Temporary storage for page edit icon
216  public $editIcon;
217 
225 
232  public function init() {
233  // Setting module configuration / page select clause
234  $this->MCONF = $GLOBALS['MCONF'];
235  $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
236  $this->backPath = $GLOBALS['BACK_PATH'];
237  // GPvars:
238  $this->id = (int)GeneralUtility::_GP('id');
239  $this->pointer = GeneralUtility::_GP('pointer');
240  $this->imagemode = GeneralUtility::_GP('imagemode');
241  $this->clear_cache = GeneralUtility::_GP('clear_cache');
242  $this->popView = GeneralUtility::_GP('popView');
243  $this->edit_record = GeneralUtility::_GP('edit_record');
244  $this->new_unique_uid = GeneralUtility::_GP('new_unique_uid');
245  $this->search_field = GeneralUtility::_GP('search_field');
246  $this->search_levels = GeneralUtility::_GP('search_levels');
247  $this->showLimit = GeneralUtility::_GP('showLimit');
248  $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
249  $this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
250  // Load page info array:
251  $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
252  // Initialize menu
253  $this->menuConfig();
254  // Setting sys language from session var:
255  $this->current_sys_language = (int)$this->MOD_SETTINGS['language'];
256  // CSH / Descriptions:
257  $this->descrTable = '_MOD_' . $this->MCONF['name'];
258  }
259 
266  public function menuConfig() {
267  // MENU-ITEMS:
268  $this->MOD_MENU = array(
269  'tt_content_showHidden' => '',
270  'showPalettes' => '',
271  'showDescriptions' => '',
272  'disableRTE' => '',
273  'function' => array(
274  0 => $GLOBALS['LANG']->getLL('m_function_0'),
275  1 => $GLOBALS['LANG']->getLL('m_function_1'),
276  2 => $GLOBALS['LANG']->getLL('m_function_2')
277  ),
278  'language' => array(
279  0 => $GLOBALS['LANG']->getLL('m_default')
280  )
281  );
282  // example settings:
283  // $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tx_myext'] =
284  // array ('default' => array(
285  // 'MENU' => 'LLL:EXT:tx_myext/locallang_db.xlf:menuDefault',
286  // 'fList' => 'title,description,image',
287  // 'icon' => TRUE));
288  if (is_array($this->externalTables)) {
289  foreach ($this->externalTables as $table => $tableSettings) {
290  // delete the default settings from above
291  if (is_array($this->MOD_MENU[$table])) {
292  unset($this->MOD_MENU[$table]);
293  }
294  if (is_array($tableSettings) && count($tableSettings) > 1) {
295  foreach ($tableSettings as $key => $settings) {
296  $this->MOD_MENU[$table][$key] = $GLOBALS['LANG']->sL($settings['MENU']);
297  }
298  }
299  }
300  }
301  // First, select all pages_language_overlay records on the current page. Each represents a possibility for a language on the page. Add these to language selector.
302  $res = $this->exec_languageQuery($this->id);
303  while ($lrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
304  if ($GLOBALS['BE_USER']->checkLanguageAccess($lrow['uid'])) {
305  $this->MOD_MENU['language'][$lrow['uid']] = $lrow['hidden'] ? '(' . $lrow['title'] . ')' : $lrow['title'];
306  }
307  }
308  // Find if there are ANY languages at all (and if not, remove the language option from function menu).
309  $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'sys_language', $GLOBALS['BE_USER']->isAdmin() ? '' : 'hidden=0');
310  if (!$count) {
311  unset($this->MOD_MENU['function']['2']);
312  }
313  // page/be_user TSconfig settings and blinding of menu-items
314  $this->modSharedTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.SHARED');
315  $this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
316  if ($this->modTSconfig['properties']['QEisDefault']) {
317  ksort($this->MOD_MENU['function']);
318  }
319  $this->MOD_MENU['function'] = BackendUtility::unsetMenuItems($this->modTSconfig['properties'], $this->MOD_MENU['function'], 'menu.function');
320  // Remove QuickEdit as option if page type is not...
321  if (!GeneralUtility::inList(($GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'] . ',6'), $this->pageinfo['doktype'])) {
322  unset($this->MOD_MENU['function'][0]);
323  }
324  // Setting alternative default label:
325  if (($this->modSharedTSconfig['properties']['defaultLanguageLabel'] || $this->modTSconfig['properties']['defaultLanguageLabel']) && isset($this->MOD_MENU['language'][0])) {
326  $this->MOD_MENU['language'][0] = $this->modTSconfig['properties']['defaultLanguageLabel'] ? $this->modTSconfig['properties']['defaultLanguageLabel'] : $this->modSharedTSconfig['properties']['defaultLanguageLabel'];
327  }
328  // Clean up settings
329  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']);
330  // For all elements to be shown in draft workspaces & to also show hidden elements by default if user hasn't disabled the option
331  if ($GLOBALS['BE_USER']->workspace != 0 || $this->MOD_SETTINGS['tt_content_showHidden'] !== '0') {
332  $this->MOD_SETTINGS['tt_content_showHidden'] = 1;
333  }
334  }
335 
342  public function clearCache() {
343  if ($this->clear_cache) {
344  $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
345  $tce->stripslashes_values = 0;
346  $tce->start(array(), array());
347  $tce->clear_cacheCmd($this->id);
348  }
349  }
350 
356  protected function getHeaderFlashMessagesForCurrentPid() {
357  $content = '';
358  // If page is a folder
359  if ($this->pageinfo['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER) {
360  // Access to list module
361  $moduleLoader = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
362  $moduleLoader->load($GLOBALS['TBE_MODULES']);
363  $modules = $moduleLoader->modules;
364  if (is_array($modules['web']['sub']['list'])) {
365  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '<p>' . $GLOBALS['LANG']->getLL('goToListModuleMessage') . '</p>
366  <p>' . IconUtility::getSpriteIcon('actions-system-list-open') . '<a href="javascript:top.goToModule( \'web_list\',1);">' . $GLOBALS['LANG']->getLL('goToListModule') . '
367  </a>
368  </p>', '', FlashMessage::INFO);
369  $content .= $flashMessage->render();
370  }
371  }
372  // If content from different pid is displayed
373  if ($this->pageinfo['content_from_pid']) {
374  $contentPage = BackendUtility::getRecord('pages', (int)$this->pageinfo['content_from_pid']);
375  $title = BackendUtility::getRecordTitle('pages', $contentPage);
376  $linkToPid = $this->local_linkThisScript(array('id' => $this->pageinfo['content_from_pid']));
377  $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . (int)$this->pageinfo['content_from_pid'] . ')</a>';
378  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('content_from_pid_title'), $link), '', FlashMessage::INFO);
379  $content .= $flashMessage->render();
380  }
381  return $content;
382  }
383 
388  protected function getLocalizedPageTitle() {
389  if ($this->current_sys_language > 0) {
390  $overlayRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
391  'title',
392  'pages_language_overlay',
393  'pid = ' . (int)$this->id .
394  ' AND sys_language_uid = ' . (int)$this->current_sys_language .
395  BackendUtility::deleteClause('pages_language_overlay') .
396  BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
397  '',
398  '',
399  '',
400  'sys_language_uid'
401  );
402  return $overlayRecord['title'];
403  } else {
404  return $this->pageinfo['title'];
405  }
406  }
407 
415  public function main() {
416  // Access check...
417  // The page will show only if there is a valid page and if this page may be viewed by the user
418  $access = is_array($this->pageinfo) ? 1 : 0;
419  if ($this->id && $access) {
420  // Initialize permission settings:
421  $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
422  $this->EDIT_CONTENT = $this->CALC_PERMS & 16 ? 1 : 0;
423  // Start document template object:
424  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
425  $this->doc->backPath = $GLOBALS['BACK_PATH'];
426  $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
427  // JavaScript:
428  $this->doc->JScode = '<script type="text/javascript" ' . 'src="' . GeneralUtility::createVersionNumberedFilename(($GLOBALS['BACK_PATH'] . 'js/jsfunc.updateform.js')) . '">' . '</script>';
429 
430  // override the default jumpToUrl
431  $this->doc->JScodeArray['jumpToUrl'] = '
432  function jumpToUrl(URL,formEl) {
433  if (document.editform && TBE_EDITOR.isFormChanged) { // Check if the function exists... (works in all browsers?)
434  if (!TBE_EDITOR.isFormChanged()) {
435  window.location.href = URL;
436  } else if (formEl) {
437  if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
438  }
439  } else {
440  window.location.href = URL;
441  }
442  }
443 ';
444 
445  $this->doc->JScode .= $this->doc->wrapScriptTags('
446  if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
447  if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages' . (int)$this->id . '_"+top.fsMod.currentBank; ' . (int)$this->id . ';
448  ' . ($this->popView ? BackendUtility::viewOnClick($this->id, $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->id)) : '') . '
449 
450  function deleteRecord(table,id,url) { //
451  if (confirm(' . GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL('deleteWarning')) . ')) {
452  window.location.href = "' . $GLOBALS['BACK_PATH'] . 'tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility::getUrlToken('tceAction') . '&prErr=1&uPT=1";
453  }
454  return false;
455  }
456  ');
457  $this->doc->JScode .= $this->doc->wrapScriptTags('
458  var DTM_array = [];
459  var DTM_origClass = "";
460 
461  // if tabs are used in a popup window the array might not exists
462  if(!top.DTM_currentTabs) {
463  top.DTM_currentTabs = [];
464  }
465 
466  function DTM_activate(idBase,index,doToogle) { //
467  // Hiding all:
468  if (DTM_array[idBase]) {
469  for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
470  if (DTM_array[idBase][cnt] != idBase+"-"+index) {
471  document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
472  document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
473  }
474  }
475  }
476 
477  // Showing one:
478  if (document.getElementById(idBase+"-"+index+"-DIV")) {
479  if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
480  document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
481  if(DTM_origClass=="") {
482  document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
483  } else {
484  DTM_origClass = "tab";
485  }
486  top.DTM_currentTabs[idBase] = -1;
487  } else {
488  document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
489  if(DTM_origClass=="") {
490  document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
491  } else {
492  DTM_origClass = "tabact";
493  }
494  top.DTM_currentTabs[idBase] = index;
495  }
496  }
497  }
498  function DTM_toggle(idBase,index,isInit) { //
499  // Showing one:
500  if (document.getElementById(idBase+"-"+index+"-DIV")) {
501  if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
502  document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
503  if(isInit) {
504  document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
505  } else {
506  DTM_origClass = "tab";
507  }
508  top.DTM_currentTabs[idBase+"-"+index] = 0;
509  } else {
510  document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
511  if(isInit) {
512  document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
513  } else {
514  DTM_origClass = "tabact";
515  }
516  top.DTM_currentTabs[idBase+"-"+index] = 1;
517  }
518  }
519  }
520 
521  function DTM_mouseOver(obj) { //
522  DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
523  obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
524  }
525 
526  function DTM_mouseOut(obj) { //
527  obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
528  DTM_origClass = "";
529  }
530  ');
531  // Setting doc-header
532  $this->doc->form = '<form action="' . htmlspecialchars(('db_layout.php?id=' . $this->id . '&imagemode=' . $this->imagemode)) . '" method="post">';
533  // Creating the top function menu:
534  $this->topFuncMenu = BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function'], 'db_layout.php', '');
535  $this->languageMenu = count($this->MOD_MENU['language']) > 1 ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE) . BackendUtility::getFuncMenu($this->id, 'SET[language]', $this->current_sys_language, $this->MOD_MENU['language'], 'db_layout.php', '') : '';
536  // Find backend layout / coumns
537  $backendLayout = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', $this->id, $this);
538  if (count($backendLayout['__colPosList'])) {
539  $this->colPosList = implode(',', $backendLayout['__colPosList']);
540  }
541  // Removing duplicates, if any
542  $this->colPosList = array_unique(GeneralUtility::intExplode(',', $this->colPosList));
543  // Accessible columns
544  if (isset($this->modSharedTSconfig['properties']['colPos_list']) && trim($this->modSharedTSconfig['properties']['colPos_list']) !== '') {
545  $this->activeColPosList = array_unique(GeneralUtility::intExplode(',', trim($this->modSharedTSconfig['properties']['colPos_list'])));
546  // Match with the list which is present in the colPosList for the current page
547  if (!empty($this->colPosList) && !empty($this->activeColPosList)) {
548  $this->activeColPosList = array_unique(array_intersect(
549  $this->activeColPosList,
550  $this->colPosList
551  ));
552  }
553  } else {
554  $this->activeColPosList = $this->colPosList;
555  }
556  $this->activeColPosList = implode(',', $this->activeColPosList);
557  $this->colPosList = implode(',', $this->colPosList);
558 
559  // Page title
560  $body = $this->doc->header($this->getLocalizedPageTitle());
561  $body .= $this->getHeaderFlashMessagesForCurrentPid();
562  // Render the primary module content:
563  if ($this->MOD_SETTINGS['function'] == 0) {
564  // QuickEdit
565  $body .= $this->renderQuickEdit();
566  } else {
567  // All other listings
568  $body .= $this->renderListContent();
569  }
570  // Setting up the buttons and markers for docheader
571  $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function'] == 0 ? 'quickEdit' : '');
572  $markers = array(
573  'CSH' => $docHeaderButtons['csh'],
574  'TOP_FUNCTION_MENU' => $this->topFuncMenu . $this->editSelect,
575  'LANGSELECTOR' => $this->languageMenu,
576  'CONTENT' => $body
577  );
578  // Build the <body> for the module
579  $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
580  // Renders the module page
581  $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
582  } else {
583  // If no access or id value, create empty document:
584  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
585  $this->doc->backPath = $GLOBALS['BACK_PATH'];
586  $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
587  $this->doc->JScode = $this->doc->wrapScriptTags('
588  if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
589  ');
590  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('clickAPage_content'), $GLOBALS['LANG']->getLL('clickAPage_header'), FlashMessage::INFO);
591  $body = $flashMessage->render();
592  // Setting up the buttons and markers for docheader
593  $docHeaderButtons = array(
594  'view' => '',
595  'history_page' => '',
596  'new_content' => '',
597  'move_page' => '',
598  'move_record' => '',
599  'new_page' => '',
600  'edit_page' => '',
601  'csh' => '',
602  'shortcut' => '',
603  'cache' => '',
604  'savedok' => '',
605  'savedokshow' => '',
606  'closedok' => '',
607  'deletedok' => '',
608  'undo' => '',
609  'history_record' => '',
610  'edit_language' => ''
611  );
612  $markers = array(
613  'CSH' => BackendUtility::cshItem($this->descrTable, '', $GLOBALS['BACK_PATH'], '', TRUE),
614  'TOP_FUNCTION_MENU' => '',
615  'LANGSELECTOR' => '',
616  'CONTENT' => $body
617  );
618  $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
619  // Renders the module page
620  $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
621  }
622  }
623 
630  public function renderQuickEdit() {
631  // Alternative template
632  $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout_quickedit.html');
633  // Alternative form tag; Quick Edit submits its content to tce_db.php.
634  $this->doc->form = '<form action="' . htmlspecialchars(($GLOBALS['BACK_PATH'] . 'tce_db.php?&prErr=1&uPT=1')) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
635  // Setting up the context sensitive menu:
636  $this->doc->getContextMenuCode();
637  // Set the edit_record value for internal use in this function:
639  // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
640  if (substr($edit_record, 0, 9) == '_EDIT_COL') {
641  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . (int)$this->id . ' AND colPos=' . (int)substr($edit_record, 10) . ' AND sys_language_uid=' . (int)$this->current_sys_language . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
642  $idListA = array();
643  while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
644  $idListA[] = $cRow['uid'];
645  }
646  $url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
648  }
649  // If the former record edited was the creation of a NEW record, this will look up the created records uid:
650  if ($this->new_unique_uid) {
651  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'userid=' . (int)$GLOBALS['BE_USER']->user['uid'] . ' AND NEWid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->new_unique_uid, 'sys_log'));
652  $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
653  if (is_array($sys_log_row)) {
654  $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
655  }
656  }
657  // Creating the selector box, allowing the user to select which element to edit:
658  $opt = array();
659  $is_selected = 0;
660  $languageOverlayRecord = '';
661  if ($this->current_sys_language) {
662  list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int)$this->current_sys_language);
663  }
664  if (is_array($languageOverlayRecord)) {
665  $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
666  $is_selected += (int)$edit_record == $inValue;
667  $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', TRUE) . ' ]</option>';
668  } else {
669  $inValue = 'pages:' . $this->id;
670  $is_selected += (int)$edit_record == $inValue;
671  $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . ' ]</option>';
672  }
673  // Selecting all content elements from this language and allowed colPos:
674  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . (int)$this->id . ' AND sys_language_uid=' . (int)$this->current_sys_language . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
675  $colPos = NULL;
676  $first = 1;
677  // Page is the pid if no record to put this after.
678  $prev = $this->id;
679  while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
680  BackendUtility::workspaceOL('tt_content', $cRow);
681  if (is_array($cRow)) {
682  if ($first) {
683  if (!$edit_record) {
684  $edit_record = 'tt_content:' . $cRow['uid'];
685  }
686  $first = 0;
687  }
688  if (!isset($colPos) || $cRow['colPos'] !== $colPos) {
689  $colPos = $cRow['colPos'];
690  $opt[] = '<option value=""></option>';
691  $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), TRUE) . ':__</option>';
692  }
693  $inValue = 'tt_content:' . $cRow['uid'];
694  $is_selected += (int)$edit_record == $inValue;
695  $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(($cRow['header'] ? $cRow['header'] : '[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title') . '] ' . strip_tags($cRow['bodytext'])), $GLOBALS['BE_USER']->uc['titleLen'])) . '</option>';
696  $prev = -$cRow['uid'];
697  }
698  }
699  // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
700  if (!$edit_record) {
701  $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
702  $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
703  $is_selected += (int)$edit_record == $inValue;
704  $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
705  }
706  // If none is yet selected...
707  if (!$is_selected) {
708  $opt[] = '<option value=""></option>';
709  $opt[] = '<option value="' . $edit_record . '" selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', TRUE) . ' ]</option>';
710  }
711  // Splitting the edit-record cmd value into table/uid:
712  $this->eRParts = explode(':', $edit_record);
713  // Delete-button flag?
714  $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
715  // If undo-button should be rendered (depends on available items in sys_history)
716  $this->undoButton = 0;
717  // if there is no content on a page
718  // the parameter $this->eRParts[1] will be set to e.g. /new/1
719  // which is not an integer value and it will throw an exception here on certain dbms
720  // thus let's check that before as there cannot be a history for a new record
721  $this->undoButtonR = false;
722  if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
723  $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . (int)$this->eRParts[1], '', 'tstamp DESC', '1');
724  $this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes);
725  }
726  if ($this->undoButtonR) {
727  $this->undoButton = 1;
728  }
729  // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
730  $R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
731  $R_URL_getvars = GeneralUtility::_GET();
732  unset($R_URL_getvars['popView']);
733  unset($R_URL_getvars['new_unique_uid']);
734  $R_URL_getvars['edit_record'] = $edit_record;
735  $this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
736  // Setting close url/return url for exiting this script:
737  // Goes to 'Columns' view if close is pressed (default)
738  $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
739  if ($this->returnUrl) {
740  $this->closeUrl = $this->returnUrl;
741  }
742  // Return-url for JavaScript:
743  $retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
744  // Drawing the edit record selectbox
745  $this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars(('jumpToUrl(' . GeneralUtility::quoteJSvalue('db_layout.php?id=' . $this->id . '&edit_record=') . '+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);')) . '">' . implode('', $opt) . '</select>';
746  // Creating editing form:
747  if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & 1)) {
748  // Splitting uid parts for special features, if new:
749  list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
750  // Convert $uidVal to workspace version if any:
751  if ($uidVal != 'new') {
752  if ($draftRecord = BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
753  $uidVal = $draftRecord['uid'];
754  }
755  }
756  // Initializing transfer-data object:
757  $trData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
758  $trData->addRawData = TRUE;
759  $trData->defVals[$this->eRParts[0]] = array(
760  'colPos' => (int)$ex_colPos,
761  'sys_language_uid' => (int)$this->current_sys_language
762  );
763  $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
764  $trData->lockRecords = 1;
765  // 'new'
766  $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
767  // Getting/Making the record:
768  reset($trData->regTableItems_data);
769  $rec = current($trData->regTableItems_data);
770  if ($uidVal == 'new') {
771  $new_unique_uid = uniqid('NEW', TRUE);
772  $rec['uid'] = $new_unique_uid;
773  $rec['pid'] = (int)$ex_pid ?: $this->id;
774  $recordAccess = TRUE;
775  } else {
776  $rec['uid'] = $uidVal;
777  // Checking internals access:
778  $recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
779  }
780  if (!$recordAccess) {
781  // If no edit access, print error message:
782  $content = $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />' . ($GLOBALS['BE_USER']->errorMsg ? 'Reason: ' . $GLOBALS['BE_USER']->errorMsg . '<br /><br />' : ''), 0, 1);
783  } elseif (is_array($rec)) {
784  // If the record is an array (which it will always be... :-)
785  // Create instance of TCEforms, setting defaults:
786  $tceforms = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
787  $tceforms->backPath = $GLOBALS['BACK_PATH'];
788  $tceforms->initDefaultBEMode();
789  $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
790  $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
791  $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
792  $tceforms->enableClickMenu = TRUE;
793  // Clipboard is initialized:
794  // Start clipboard
795  $tceforms->clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
796  // Initialize - reads the clipboard content from the user session
797  $tceforms->clipObj->initializeClipboard();
798  // Render form, wrap it:
799  $panel = '';
800  $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
801  $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
802  // Add hidden fields:
803  $theCode = $panel;
804  if ($uidVal == 'new') {
805  $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
806  }
807  $theCode .= '
808  <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
809  <input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
810  <input type="hidden" name="edit_record" value="' . $edit_record . '" />
811  <input type="hidden" name="redirect" value="' . htmlspecialchars(($uidVal == 'new' ? ExtensionManagementUtility::extRelPath('cms') . 'layout/db_layout.php?id=' . $this->id . '&new_unique_uid=' . $new_unique_uid . '&returnUrl=' . rawurlencode($this->returnUrl) : $this->R_URI)) . '" />
813  // Add JavaScript as needed around the form:
814  $theCode = $tceforms->printNeededJSFunctions_top() . $theCode . $tceforms->printNeededJSFunctions();
815  // Add warning sign if record was "locked":
816  if ($lockInfo = BackendUtility::isRecordLocked($this->eRParts[0], $rec['uid'])) {
817  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
819  $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
821  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
822  $defaultFlashMessageQueue->enqueue($flashMessage);
823  }
824  // Add whole form as a document section:
825  $content = $this->doc->section('', $theCode);
826  }
827  } else {
828  // If no edit access, print error message:
829  $content = $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />', 0, 1);
830  }
831  // Bottom controls (function menus):
832  $q_count = $this->getNumberOfHiddenElements();
833  $h_func_b = BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], 'db_layout.php', '', 'id="checkTt_content_showHidden"') . '<label for="checkTt_content_showHidden">' . (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('hiddenCE', TRUE)) : $GLOBALS['LANG']->getLL('hiddenCE', TRUE) . ' (' . $q_count . ')') . '</label>';
834  $h_func_b .= '<br />' . BackendUtility::getFuncCheck($this->id, 'SET[showPalettes]', $this->MOD_SETTINGS['showPalettes'], 'db_layout.php', '', 'id="checkShowPalettes"') . '<label for="checkShowPalettes">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPalettes', TRUE) . '</label>';
835  if (ExtensionManagementUtility::isLoaded('context_help')) {
836  $h_func_b .= '<br />' . BackendUtility::getFuncCheck($this->id, 'SET[showDescriptions]', $this->MOD_SETTINGS['showDescriptions'], 'db_layout.php', '', 'id="checkShowDescriptions"') . '<label for="checkShowDescriptions">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showDescriptions', TRUE) . '</label>';
837  }
838  if ($GLOBALS['BE_USER']->isRTE()) {
839  $h_func_b .= '<br />' . BackendUtility::getFuncCheck($this->id, 'SET[disableRTE]', $this->MOD_SETTINGS['disableRTE'], 'db_layout.php', '', 'id="checkDisableRTE"') . '<label for="checkDisableRTE">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.disableRTE', TRUE) . '</label>';
840  }
841  // Add the function menus to bottom:
842  $content .= $this->doc->section('', $h_func_b, 0, 0);
843  $content .= $this->doc->spacer(10);
844  // Select element matrix:
845  if ($this->eRParts[0] == 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
846  $posMap = GeneralUtility::makeInstance('ext_posMap');
847  $posMap->backPath = $GLOBALS['BACK_PATH'];
848  $posMap->cur_sys_language = $this->current_sys_language;
849  $HTMLcode = '';
850  // CSH:
851  $HTMLcode .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', $GLOBALS['BACK_PATH'], '|<br />');
852  $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
853  $content .= $this->doc->spacer(20);
854  $content .= $this->doc->section($GLOBALS['LANG']->getLL('CEonThisPage'), $HTMLcode, 0, 1);
855  $content .= $this->doc->spacer(20);
856  }
857  // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
858  if (count($tceforms->commentMessages)) {
859  $content .= '
860  <!-- TCEFORM messages
861  ' . htmlspecialchars(implode(LF, $tceforms->commentMessages)) . '
862  -->
863  ';
864  }
865  return $content;
866  }
867 
874  public function renderListContent() {
875  // Initialize list object (see "class.db_layout.inc"):
877  $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView');
878  $dblist->backPath = $GLOBALS['BACK_PATH'];
879  $dblist->thumbs = $this->imagemode;
880  $dblist->no_noWrap = 1;
881  $dblist->descrTable = $this->descrTable;
882  $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
883  $dblist->script = 'db_layout.php';
884  $dblist->showIcon = 0;
885  $dblist->setLMargin = 0;
886  $dblist->doEdit = $this->EDIT_CONTENT;
887  $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
888  $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
889  $dblist->id = $this->id;
890  $dblist->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
891  $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] === '0';
892  $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
893  $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
894  if (!$dblist->nextThree) {
895  $dblist->nextThree = 1;
896  }
897  $dblist->externalTables = $this->externalTables;
898  // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
899  $h_menu = $dblist->getTableMenu($this->id);
900  // Initialize other variables:
901  $h_func = '';
902  $tableOutput = array();
903  $tableJSOutput = array();
904  $CMcounter = 0;
905  // Traverse the list of table names which has records on this page (that array is populated
906  // by the $dblist object during the function getTableMenu()):
907  foreach ($dblist->activeTables as $table => $value) {
908  if (!isset($dblist->externalTables[$table])) {
909  $q_count = $this->getNumberOfHiddenElements();
910  $h_func_b = BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], 'db_layout.php', '', 'id="checkTt_content_showHidden"') . '<label for="checkTt_content_showHidden">' . (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('hiddenCE')) : $GLOBALS['LANG']->getLL('hiddenCE') . ' (' . $q_count . ')') . '</label>';
911  // Boolean: Display up/down arrows and edit icons for tt_content records
912  $dblist->tt_contentConfig['showCommands'] = 1;
913  // Boolean: Display info-marks or not
914  $dblist->tt_contentConfig['showInfo'] = 1;
915  // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown
916  // in the total width of the page
917  $dblist->tt_contentConfig['single'] = 0;
918  if ($this->MOD_SETTINGS['function'] == 4) {
919  // Grid view
920  $dblist->tt_contentConfig['showAsGrid'] = 1;
921  }
922  // Setting up the tt_content columns to show:
923  if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
924  $colList = array();
925  $tcaItems = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $this->id, $this);
926  foreach ($tcaItems as $temp) {
927  $colList[] = $temp[1];
928  }
929  } else {
930  // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
931  $colList = array('1', '0', '2', '3');
932  }
933  if ($this->colPosList !== '') {
934  $colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
935  }
936  // If only one column found, display the single-column view.
937  if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) {
938  // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol']
939  // is shown in the total width of the page
940  $dblist->tt_contentConfig['single'] = 1;
941  // The column(s) to show if single mode (under each other)
942  $dblist->tt_contentConfig['showSingleCol'] = current($colList);
943  }
944  // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
945  $dblist->tt_contentConfig['cols'] = implode(',', $colList);
946  $dblist->tt_contentConfig['activeCols'] = $this->activeColPosList;
947  $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
948  $dblist->tt_contentConfig['sys_language_uid'] = (int)$this->current_sys_language;
949  // If the function menu is set to "Language":
950  if ($this->MOD_SETTINGS['function'] == 2) {
951  $dblist->tt_contentConfig['single'] = 0;
952  $dblist->tt_contentConfig['languageMode'] = 1;
953  $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
954  $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
955  }
956  } else {
957  if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
958  $h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
959  } else {
960  $h_func = '';
961  }
962  }
963  // Start the dblist object:
964  $dblist->itemsLimitSingleTable = 1000;
965  $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
966  $dblist->counter = $CMcounter;
967  $dblist->ext_function = $this->MOD_SETTINGS['function'];
968  // Render versioning selector:
969  $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
970  // Generate the list of elements here:
971  $dblist->generateList();
972  // Adding the list content to the tableOutput variable:
973  $tableOutput[$table] = ($h_func ? $h_func . '<br /><img src="clear.gif" width="1" height="4" alt="" /><br />' : '') . $dblist->HTMLcode . ($h_func_b ? '<img src="clear.gif" width="1" height="10" alt="" /><br />' . $h_func_b : '');
974  // ... and any accumulated JavaScript goes the same way!
975  $tableJSOutput[$table] = $dblist->JScode;
976  // Increase global counter:
977  $CMcounter += $dblist->counter;
978  // Reset variables after operation:
979  $dblist->HTMLcode = '';
980  $dblist->JScode = '';
981  $h_func = '';
982  $h_func_b = '';
983  }
984  // END: traverse tables
985  // For Context Sensitive Menus:
986  $this->doc->getContextMenuCode();
987  // Init the content
988  $content = '';
989  // Additional header content
990  $headerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'];
991  if (is_array($headerContentHook)) {
992  foreach ($headerContentHook as $hook) {
993  $params = array();
994  $content .= GeneralUtility::callUserFunction($hook, $params, $this);
995  }
996  }
997  // Add the content for each table we have rendered (traversing $tableOutput variable)
998  foreach ($tableOutput as $table => $output) {
999  $content .= $this->doc->section('', $output, TRUE, TRUE, 0, TRUE);
1000  $content .= $this->doc->spacer(15);
1001  $content .= $this->doc->sectionEnd();
1002  }
1003  // Making search form:
1004  if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
1005  $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
1006  $content .= $this->doc->section($sectionTitle, $dblist->getSearchBox(0), FALSE, TRUE, FALSE, TRUE);
1007  }
1008  // Additional footer content
1009  $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'];
1010  if (is_array($footerContentHook)) {
1011  foreach ($footerContentHook as $hook) {
1012  $params = array();
1013  $content .= GeneralUtility::callUserFunction($hook, $params, $this);
1014  }
1015  }
1016  return $content;
1017  }
1018 
1025  public function printContent() {
1026  echo $this->content;
1027  }
1028 
1029  /***************************
1030  *
1031  * Sub-content functions, rendering specific parts of the module content.
1032  *
1033  ***************************/
1040  protected function getButtons($function = '') {
1041  $buttons = array(
1042  'view' => '',
1043  'history_page' => '',
1044  'new_content' => '',
1045  'move_page' => '',
1046  'move_record' => '',
1047  'new_page' => '',
1048  'edit_page' => '',
1049  'edit_language' => '',
1050  'csh' => '',
1051  'shortcut' => '',
1052  'cache' => '',
1053  'savedok' => '',
1054  'save_close' => '',
1055  'savedokshow' => '',
1056  'closedok' => '',
1057  'deletedok' => '',
1058  'undo' => '',
1059  'history_record' => ''
1060  );
1061  // View page
1062  if (!VersionState::cast($this->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
1063  $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
1064  }
1065  // Shortcut
1066  if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1067  $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
1068  }
1069  // Cache
1070  if (!$this->modTSconfig['properties']['disableAdvanced']) {
1071  $buttons['cache'] = '<a href="' . htmlspecialchars(('db_layout.php?id=' . $this->pageinfo['uid'] . '&clear_cache=1')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-cache-clear') . '</a>';
1072  }
1073  if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1074  // Move record
1075  if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
1076  $buttons['move_record'] = '<a href="' . htmlspecialchars(($GLOBALS['BACK_PATH'] . 'move_el.php?table=' . $this->eRParts[0] . '&uid=' . $this->eRParts[1] . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')))) . '">' . IconUtility::getSpriteIcon(('actions-' . ($this->eRParts[0] == 'tt_content' ? 'document' : 'page') . '-move'), array('class' => 'c-inputButton', 'title' => $GLOBALS['LANG']->getLL(('move_' . ($this->eRParts[0] == 'tt_content' ? 'record' : 'page')), TRUE))) . '</a>';
1077  }
1078 
1079  // Edit page properties and page language overlay icons
1080  if ($this->CALC_PERMS & 2) {
1081 
1082  // Edit localized page_language_overlay only when one specific language is selected
1083  if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
1084  $overlayRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
1085  'uid',
1086  'pages_language_overlay',
1087  'pid = ' . (int)$this->id . ' ' .
1088  'AND sys_language_uid = ' . (int)$this->current_sys_language .
1089  BackendUtility::deleteClause('pages_language_overlay') .
1090  BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1091  '',
1092  '',
1093  '',
1094  'sys_language_uid'
1095  );
1096 
1097  $editLanguageOnClick = htmlspecialchars(
1099  '&edit[pages_language_overlay][' . $overlayRecord['uid'] . ']=edit',
1100  $GLOBALS['BACK_PATH'])
1101  );
1102  $buttons['edit_language'] = '<a href="#" ' .
1103  'onclick="' . $editLanguageOnClick . '"' .
1104  'title="' . $GLOBALS['LANG']->getLL('editPageLanguageOverlayProperties', TRUE) . '">' .
1105  \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay') .
1106  '</a>';
1107  }
1108 
1109 
1110  // Edit page properties
1111  $editPageOnClick = htmlspecialchars(
1112  BackendUtility::editOnClick('&edit[pages][' . $this->id . ']=edit', $GLOBALS['BACK_PATH'])
1113  );
1114  $buttons['edit_page'] = '<a href="#" ' .
1115  'onclick="' . $editPageOnClick . '"' .
1116  'title="' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . '">' .
1118  '</a>';
1119  }
1120 
1121  // Add CSH (Context Sensitive Help) icon to tool bar
1122  if ($function == 'quickEdit') {
1123  $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'quickEdit', $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1124  } else {
1125  $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1126  }
1127  if ($function == 'quickEdit') {
1128  // Save record
1129  $buttons['savedok'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="image" name="_savedok" class="c-inputButton" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" />'));
1130  // Save and close
1131  $buttons['save_close'] = IconUtility::getSpriteIcon('actions-document-save-close', array('html' => '<input type="image" class="c-inputButton" name="_saveandclosedok" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" />'));
1132  // Save record and show page
1133  $buttons['savedokshow'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDocShow', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-save-view') . '</a>';
1134  // Close record
1135  $buttons['closedok'] = '<a href="#" onclick="' . htmlspecialchars(('jumpToUrl(unescape(\'' . rawurlencode($this->closeUrl) . '\')); return false;')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
1136  // Delete record
1137  if ($this->deleteButton) {
1138  $buttons['deletedok'] = '<a href="#" onclick="' . htmlspecialchars(('return deleteRecord(\'' . $this->eRParts[0] . '\',\'' . $this->eRParts[1] . '\',\'' . GeneralUtility::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id . '\');')) . '" title="' . $GLOBALS['LANG']->getLL('deleteItem', TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
1139  }
1140  if ($this->undoButton) {
1141  // Undo button
1142  $buttons['undo'] = '<a href="#"
1143  onclick="' . htmlspecialchars('window.location.href=' .
1144  GeneralUtility::quoteJSvalue(
1145  $GLOBALS['BACK_PATH'] .
1146  BackendUtility::getModuleUrl(
1147  'record_history',
1148  array(
1149  'element' => $this->eRParts[0] . ':' . $this->eRParts[1],
1150  'revert' => 'ALL_FIELDS',
1151  'sumUp' => -1,
1152  'returnUrl' => $this->R_URI,
1153  )
1154  )
1155  ) . '; return false;') . '"
1156  title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('undoLastChange'), BackendUtility::calcAge(($GLOBALS['EXEC_TIME'] - $this->undoButtonR['tstamp']), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')))) . '">' . IconUtility::getSpriteIcon('actions-edit-undo') . '</a>';
1157  // History button
1158  $buttons['history_record'] = '<a href="#"
1159  onclick="' . htmlspecialchars('jumpToUrl(' .
1160  GeneralUtility::quoteJSvalue(
1161  $GLOBALS['BACK_PATH'] .
1162  BackendUtility::getModuleUrl(
1163  'record_history',
1164  array(
1165  'element' => $this->eRParts[0] . ':' . $this->eRParts[1],
1166  'returnUrl' => $this->R_URI,
1167  )
1168  ) . '#latest'
1169  ) . ');return false;') . '"
1170  title="' . $GLOBALS['LANG']->getLL('recordHistory', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
1171  }
1172  }
1173  }
1174  return $buttons;
1175  }
1176 
1177  /*******************************
1178  *
1179  * Other functions
1180  *
1181  ******************************/
1189  public function getNumberOfHiddenElements() {
1190  return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1191  'uid',
1192  'tt_content',
1193  'pid=' . (int)$this->id . ' AND sys_language_uid=' . (int)$this->current_sys_language . BackendUtility::BEenableFields('tt_content', 1) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content')
1194  );
1195  }
1196 
1205  public function local_linkThisScript($params) {
1206  $params['popView'] = '';
1207  $params['new_unique_uid'] = '';
1208  return GeneralUtility::linkThisScript($params);
1209  }
1210 
1218  public function exec_languageQuery($id) {
1219  if ($id) {
1220  $exQ = BackendUtility::deleteClause('pages_language_overlay') .
1221  ($GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0');
1222  return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1223  'sys_language.*',
1224  'pages_language_overlay,sys_language',
1225  'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . (int)$id . $exQ .
1226  BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1227  'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.static_lang_isocode,sys_language.flag',
1228  'sys_language.title'
1229  );
1230  } else {
1231  return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1232  'sys_language.*',
1233  'sys_language',
1234  'sys_language.hidden=0',
1235  '',
1236  'sys_language.title'
1237  );
1238  }
1239  }
1240 
1241 }
static getFuncCheck($mainParams, $elementName, $currentValue, $script='', $addParams='', $tagParams='')
static readPageAccess($id, $perms_clause)
static getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields=' *')
static editOnClick($params, $backPath='', $requestUri='')
static getRecordsByField($theTable, $theField, $theValue, $whereClause='', $groupBy='', $orderBy='', $limit='', $useDeleteClause=TRUE)
static BEgetRootLine($uid, $clause='', $workspaceOL=FALSE)
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=FALSE)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static getUrlToken($formName='securityToken', $tokenName='formToken')
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static viewOnClick($pageUid, $backPath='', $rootLine='', $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=TRUE)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
static wrapInHelp($table, $field, $text='', array $overloadHelpText=array())
static createVersionNumberedFilename($file, $forceQueryString=FALSE)
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static getHiddenTokenField($formName='securityToken', $tokenName='formToken')
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
static getFuncMenu($mainParams, $elementName, $currentValue, $menuItems, $script='', $addparams='')
static unsetMenuItems($modTSconfig, $itemArray, $TSref)
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=FALSE, $rawurlencodeParamName=FALSE)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:76
static fixed_lgd_cs($string, $chars, $appendString='...')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static deleteClause($table, $tableAlias='')
static getLabelFromItemlist($table, $col, $key)