[TASK] Make show_rechis.php mod.php dispatched
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / PageLayoutController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Backend\Utility\BackendUtility;
31 use TYPO3\CMS\Backend\Utility\IconUtility;
32 use TYPO3\CMS\Core\Messaging\FlashMessage;
33 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
34 use TYPO3\CMS\Core\Utility\GeneralUtility;
35 use TYPO3\CMS\Core\Utility\MathUtility;
36
37 /**
38 * Script Class for Web > Layout module
39 *
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 */
42 class PageLayoutController {
43
44 // Internal, GPvars:
45 // Page Id for which to make the listing
46 /**
47 * @todo Define visibility
48 */
49 public $id;
50
51 // Pointer - for browsing list of records.
52 /**
53 * @todo Define visibility
54 */
55 public $pointer;
56
57 // Thumbnails or not
58 /**
59 * @todo Define visibility
60 */
61 public $imagemode;
62
63 // Search-fields
64 /**
65 * @todo Define visibility
66 */
67 public $search_field;
68
69 // Search-levels
70 /**
71 * @todo Define visibility
72 */
73 public $search_levels;
74
75 // Show-limit
76 /**
77 * @todo Define visibility
78 */
79 public $showLimit;
80
81 // Return URL
82 /**
83 * @todo Define visibility
84 */
85 public $returnUrl;
86
87 // Clear-cache flag - if set, clears page cache for current id.
88 /**
89 * @todo Define visibility
90 */
91 public $clear_cache;
92
93 // PopView id - for opening a window with the page
94 /**
95 * @todo Define visibility
96 */
97 public $popView;
98
99 // 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).
100 /**
101 * @todo Define visibility
102 */
103 public $edit_record;
104
105 // 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.
106 /**
107 * @todo Define visibility
108 */
109 public $new_unique_uid;
110
111 // Internal, static:
112 // Page select perms clause
113 /**
114 * @todo Define visibility
115 */
116 public $perms_clause;
117
118 // Module TSconfig
119 /**
120 * @todo Define visibility
121 */
122 public $modTSconfig;
123
124 // Current ids page record
125 /**
126 * @todo Define visibility
127 */
128 public $pageinfo;
129
130 /**
131 * Document template object
132 *
133 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
134 * @todo Define visibility
135 */
136 public $doc;
137
138 // Back path of the module
139 /**
140 * @todo Define visibility
141 */
142 public $backPath;
143
144 // "Pseudo" Description -table name
145 /**
146 * @todo Define visibility
147 */
148 public $descrTable;
149
150 // List of column-integers to edit. Is set from TSconfig, default is "1,0,2,3"
151 /**
152 * @todo Define visibility
153 */
154 public $colPosList;
155
156 // Flag: If content can be edited or not.
157 /**
158 * @todo Define visibility
159 */
160 public $EDIT_CONTENT;
161
162 // Users permissions integer for this page.
163 /**
164 * @todo Define visibility
165 */
166 public $CALC_PERMS;
167
168 // Currently selected language for editing content elements
169 /**
170 * @todo Define visibility
171 */
172 public $current_sys_language;
173
174 // Module configuration
175 /**
176 * @todo Define visibility
177 */
178 public $MCONF = array();
179
180 // Menu configuration
181 /**
182 * @todo Define visibility
183 */
184 public $MOD_MENU = array();
185
186 // Module settings (session variable)
187 /**
188 * @todo Define visibility
189 */
190 public $MOD_SETTINGS = array();
191
192 // Array, where files to include is accumulated in the init() function
193 /**
194 * @todo Define visibility
195 */
196 public $include_once = array();
197
198 // Array of tables to be listed by the Web > Page module in addition to the default tables
199 /**
200 * @todo Define visibility
201 */
202 public $externalTables = array();
203
204 // Internal, dynamic:
205 // Module output accumulation
206 /**
207 * @todo Define visibility
208 */
209 public $content;
210
211 // Function menu temporary storage
212 /**
213 * @todo Define visibility
214 */
215 public $topFuncMenu;
216
217 // Temporary storage for page edit icon
218 /**
219 * @todo Define visibility
220 */
221 public $editIcon;
222
223 /**
224 * Initializing the module
225 *
226 * @return void
227 * @todo Define visibility
228 */
229 public function init() {
230 // Setting module configuration / page select clause
231 $this->MCONF = $GLOBALS['MCONF'];
232 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
233 $this->backPath = $GLOBALS['BACK_PATH'];
234 // GPvars:
235 $this->id = (int)GeneralUtility::_GP('id');
236 $this->pointer = GeneralUtility::_GP('pointer');
237 $this->imagemode = GeneralUtility::_GP('imagemode');
238 $this->clear_cache = GeneralUtility::_GP('clear_cache');
239 $this->popView = GeneralUtility::_GP('popView');
240 $this->edit_record = GeneralUtility::_GP('edit_record');
241 $this->new_unique_uid = GeneralUtility::_GP('new_unique_uid');
242 $this->search_field = GeneralUtility::_GP('search_field');
243 $this->search_levels = GeneralUtility::_GP('search_levels');
244 $this->showLimit = GeneralUtility::_GP('showLimit');
245 $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
246 $this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
247 // Load page info array:
248 $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
249 // Initialize menu
250 $this->menuConfig();
251 // Setting sys language from session var:
252 $this->current_sys_language = (int)$this->MOD_SETTINGS['language'];
253 // CSH / Descriptions:
254 $this->descrTable = '_MOD_' . $this->MCONF['name'];
255 }
256
257 /**
258 * Initialize menu array
259 *
260 * @return void
261 * @todo Define visibility
262 */
263 public function menuConfig() {
264 // MENU-ITEMS:
265 $this->MOD_MENU = array(
266 'tt_content_showHidden' => '',
267 'showPalettes' => '',
268 'showDescriptions' => '',
269 'disableRTE' => '',
270 'function' => array(
271 0 => $GLOBALS['LANG']->getLL('m_function_0'),
272 1 => $GLOBALS['LANG']->getLL('m_function_1'),
273 2 => $GLOBALS['LANG']->getLL('m_function_2')
274 ),
275 'language' => array(
276 0 => $GLOBALS['LANG']->getLL('m_default')
277 )
278 );
279 // example settings:
280 // $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tx_myext'] =
281 // array ('default' => array(
282 // 'MENU' => 'LLL:EXT:tx_myext/locallang_db.xlf:menuDefault',
283 // 'fList' => 'title,description,image',
284 // 'icon' => TRUE));
285 if (is_array($this->externalTables)) {
286 foreach ($this->externalTables as $table => $tableSettings) {
287 // delete the default settings from above
288 if (is_array($this->MOD_MENU[$table])) {
289 unset($this->MOD_MENU[$table]);
290 }
291 if (is_array($tableSettings) && count($tableSettings) > 1) {
292 foreach ($tableSettings as $key => $settings) {
293 $this->MOD_MENU[$table][$key] = $GLOBALS['LANG']->sL($settings['MENU']);
294 }
295 }
296 }
297 }
298 // 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.
299 $res = $this->exec_languageQuery($this->id);
300 while ($lrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
301 if ($GLOBALS['BE_USER']->checkLanguageAccess($lrow['uid'])) {
302 $this->MOD_MENU['language'][$lrow['uid']] = $lrow['hidden'] ? '(' . $lrow['title'] . ')' : $lrow['title'];
303 }
304 }
305 // Find if there are ANY languages at all (and if not, remove the language option from function menu).
306 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'sys_language', $GLOBALS['BE_USER']->isAdmin() ? '' : 'hidden=0');
307 if (!$count) {
308 unset($this->MOD_MENU['function']['2']);
309 }
310 // page/be_user TSconfig settings and blinding of menu-items
311 $this->modSharedTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.SHARED');
312 $this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
313 if ($this->modTSconfig['properties']['QEisDefault']) {
314 ksort($this->MOD_MENU['function']);
315 }
316 $this->MOD_MENU['function'] = BackendUtility::unsetMenuItems($this->modTSconfig['properties'], $this->MOD_MENU['function'], 'menu.function');
317 // Remove QuickEdit as option if page type is not...
318 if (!GeneralUtility::inList(($GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'] . ',6'), $this->pageinfo['doktype'])) {
319 unset($this->MOD_MENU['function'][0]);
320 }
321 // Setting alternative default label:
322 if (($this->modSharedTSconfig['properties']['defaultLanguageLabel'] || $this->modTSconfig['properties']['defaultLanguageLabel']) && isset($this->MOD_MENU['language'][0])) {
323 $this->MOD_MENU['language'][0] = $this->modTSconfig['properties']['defaultLanguageLabel'] ? $this->modSharedTSconfig['properties']['defaultLanguageLabel'] : $this->modSharedTSconfig['properties']['defaultLanguageLabel'];
324 }
325 // Clean up settings
326 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']);
327 // For all elements to be shown in draft workspaces & to also show hidden elements by default if user hasn't disabled the option
328 if ($GLOBALS['BE_USER']->workspace != 0 || $this->MOD_SETTINGS['tt_content_showHidden'] !== '0') {
329 $this->MOD_SETTINGS['tt_content_showHidden'] = 1;
330 }
331 }
332
333 /**
334 * Clears page cache for the current id, $this->id
335 *
336 * @return void
337 * @todo Define visibility
338 */
339 public function clearCache() {
340 if ($this->clear_cache) {
341 $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
342 $tce->stripslashes_values = 0;
343 $tce->start(array(), array());
344 $tce->clear_cacheCmd($this->id);
345 }
346 }
347
348 /**
349 * Generate the flashmessages for current pid
350 *
351 * @return string HTML content with flashmessages
352 */
353 protected function getHeaderFlashMessagesForCurrentPid() {
354 $content = '';
355 // If page is a folder
356 if ($this->pageinfo['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER) {
357 // Access to list module
358 $moduleLoader = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
359 $moduleLoader->load($GLOBALS['TBE_MODULES']);
360 $modules = $moduleLoader->modules;
361 if (is_array($modules['web']['sub']['list'])) {
362 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '<p>' . $GLOBALS['LANG']->getLL('goToListModuleMessage') . '</p>
363 <br />
364 <p>' . IconUtility::getSpriteIcon('actions-system-list-open') . '<a href="javascript:top.goToModule( \'web_list\',1);">' . $GLOBALS['LANG']->getLL('goToListModule') . '
365 </a>
366 </p>', '', FlashMessage::INFO);
367 $content .= $flashMessage->render();
368 }
369 }
370 // If content from different pid is displayed
371 if ($this->pageinfo['content_from_pid']) {
372 $contentPage = BackendUtility::getRecord('pages', (int)$this->pageinfo['content_from_pid']);
373 $title = BackendUtility::getRecordTitle('pages', $contentPage);
374 $linkToPid = $this->local_linkThisScript(array('id' => $this->pageinfo['content_from_pid']));
375 $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . (int)$this->pageinfo['content_from_pid'] . ')</a>';
376 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('content_from_pid_title'), $link), '', FlashMessage::INFO);
377 $content .= $flashMessage->render();
378 }
379 return $content;
380 }
381
382 /**
383 *
384 * @return string $title
385 */
386 protected function getLocalizedPageTitle() {
387 if ($this->current_sys_language > 0) {
388 $overlayRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
389 'title',
390 'pages_language_overlay',
391 'pid = ' . (int)$this->id .
392 ' AND sys_language_uid = ' . (int)$this->current_sys_language .
393 BackendUtility::deleteClause('pages_language_overlay') .
394 BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
395 '',
396 '',
397 '',
398 'sys_language_uid'
399 );
400 return $overlayRecord['title'];
401 } else {
402 return $this->pageinfo['title'];
403 }
404 }
405
406 /**
407 * Main function.
408 * Creates some general objects and calls other functions for the main rendering of module content.
409 *
410 * @return void
411 * @todo Define visibility
412 */
413 public function main() {
414 // Access check...
415 // The page will show only if there is a valid page and if this page may be viewed by the user
416 $access = is_array($this->pageinfo) ? 1 : 0;
417 if ($this->id && $access) {
418 // Initialize permission settings:
419 $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
420 $this->EDIT_CONTENT = $this->CALC_PERMS & 16 ? 1 : 0;
421 // Start document template object:
422 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
423 $this->doc->backPath = $GLOBALS['BACK_PATH'];
424 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
425 // JavaScript:
426 $this->doc->JScode = '<script type="text/javascript" ' . 'src="' . GeneralUtility::createVersionNumberedFilename(($GLOBALS['BACK_PATH'] . 'js/jsfunc.updateform.js')) . '">' . '</script>';
427
428 // override the default jumpToUrl
429 $this->doc->JScodeArray['jumpToUrl'] = '
430 function jumpToUrl(URL,formEl) {
431 if (document.editform && TBE_EDITOR.isFormChanged) { // Check if the function exists... (works in all browsers?)
432 if (!TBE_EDITOR.isFormChanged()) {
433 window.location.href = URL;
434 } else if (formEl) {
435 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
436 }
437 } else {
438 window.location.href = URL;
439 }
440 }
441 ';
442
443 $this->doc->JScode .= $this->doc->wrapScriptTags('
444 if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
445 if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages' . (int)$this->id . '_"+top.fsMod.currentBank; ' . (int)$this->id . ';
446 ' . ($this->popView ? BackendUtility::viewOnClick($this->id, $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->id)) : '') . '
447
448 function deleteRecord(table,id,url) { //
449 if (confirm(' . GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL('deleteWarning')) . ')) {
450 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";
451 }
452 return false;
453 }
454 ');
455 $this->doc->JScode .= $this->doc->wrapScriptTags('
456 var DTM_array = new Array();
457 var DTM_origClass = new String();
458
459 // if tabs are used in a popup window the array might not exists
460 if(!top.DTM_currentTabs) {
461 top.DTM_currentTabs = new Array();
462 }
463
464 function DTM_activate(idBase,index,doToogle) { //
465 // Hiding all:
466 if (DTM_array[idBase]) {
467 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
468 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
469 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
470 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
471 }
472 }
473 }
474
475 // Showing one:
476 if (document.getElementById(idBase+"-"+index+"-DIV")) {
477 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
478 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
479 if(DTM_origClass=="") {
480 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
481 } else {
482 DTM_origClass = "tab";
483 }
484 top.DTM_currentTabs[idBase] = -1;
485 } else {
486 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
487 if(DTM_origClass=="") {
488 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
489 } else {
490 DTM_origClass = "tabact";
491 }
492 top.DTM_currentTabs[idBase] = index;
493 }
494 }
495 }
496 function DTM_toggle(idBase,index,isInit) { //
497 // Showing one:
498 if (document.getElementById(idBase+"-"+index+"-DIV")) {
499 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
500 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
501 if(isInit) {
502 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
503 } else {
504 DTM_origClass = "tab";
505 }
506 top.DTM_currentTabs[idBase+"-"+index] = 0;
507 } else {
508 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
509 if(isInit) {
510 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
511 } else {
512 DTM_origClass = "tabact";
513 }
514 top.DTM_currentTabs[idBase+"-"+index] = 1;
515 }
516 }
517 }
518
519 function DTM_mouseOver(obj) { //
520 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
521 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
522 }
523
524 function DTM_mouseOut(obj) { //
525 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
526 DTM_origClass = "";
527 }
528 ');
529 // Setting doc-header
530 $this->doc->form = '<form action="' . htmlspecialchars(('db_layout.php?id=' . $this->id . '&imagemode=' . $this->imagemode)) . '" method="post">';
531 // Creating the top function menu:
532 $this->topFuncMenu = BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function'], 'db_layout.php', '');
533 $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', '') : '';
534 // Find backend layout / coumns
535 $backendLayout = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', $this->id, $this);
536 if (count($backendLayout['__colPosList'])) {
537 $this->colPosList = implode(',', $backendLayout['__colPosList']);
538 }
539 // Removing duplicates, if any
540 $this->colPosList = implode(',', array_unique(GeneralUtility::intExplode(',', $this->colPosList)));
541 // Page title
542 $body = $this->doc->header($this->getLocalizedPageTitle());
543 $body .= $this->getHeaderFlashMessagesForCurrentPid();
544 // Render the primary module content:
545 if ($this->MOD_SETTINGS['function'] == 0) {
546 // QuickEdit
547 $body .= $this->renderQuickEdit();
548 } else {
549 // All other listings
550 $body .= $this->renderListContent();
551 }
552 // Setting up the buttons and markers for docheader
553 $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function'] == 0 ? 'quickEdit' : '');
554 $markers = array(
555 'CSH' => $docHeaderButtons['csh'],
556 'TOP_FUNCTION_MENU' => $this->topFuncMenu . $this->editSelect,
557 'LANGSELECTOR' => $this->languageMenu,
558 'CONTENT' => $body
559 );
560 // Build the <body> for the module
561 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
562 // Renders the module page
563 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
564 } else {
565 // If no access or id value, create empty document:
566 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
567 $this->doc->backPath = $GLOBALS['BACK_PATH'];
568 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
569 $this->doc->JScode = $this->doc->wrapScriptTags('
570 if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
571 ');
572 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('clickAPage_content'), $GLOBALS['LANG']->getLL('clickAPage_header'), FlashMessage::INFO);
573 $body = $flashMessage->render();
574 // Setting up the buttons and markers for docheader
575 $docHeaderButtons = array(
576 'view' => '',
577 'history_page' => '',
578 'new_content' => '',
579 'move_page' => '',
580 'move_record' => '',
581 'new_page' => '',
582 'edit_page' => '',
583 'csh' => '',
584 'shortcut' => '',
585 'cache' => '',
586 'savedok' => '',
587 'savedokshow' => '',
588 'closedok' => '',
589 'deletedok' => '',
590 'undo' => '',
591 'history_record' => '',
592 'edit_language' => ''
593 );
594 $markers = array(
595 'CSH' => BackendUtility::cshItem($this->descrTable, '', $GLOBALS['BACK_PATH'], '', TRUE),
596 'TOP_FUNCTION_MENU' => '',
597 'LANGSELECTOR' => '',
598 'CONTENT' => $body
599 );
600 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
601 // Renders the module page
602 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
603 }
604 }
605
606 /**
607 * Rendering the quick-edit view.
608 *
609 * @return void
610 * @todo Define visibility
611 */
612 public function renderQuickEdit() {
613 // Alternative template
614 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout_quickedit.html');
615 // Alternative form tag; Quick Edit submits its content to tce_db.php.
616 $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);">';
617 // Setting up the context sensitive menu:
618 $this->doc->getContextMenuCode();
619 // Set the edit_record value for internal use in this function:
620 $edit_record = $this->edit_record;
621 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
622 if (substr($edit_record, 0, 9) == '_EDIT_COL') {
623 $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');
624 $idListA = array();
625 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
626 $idListA[] = $cRow['uid'];
627 }
628 $url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
629 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
630 }
631 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
632 if ($this->new_unique_uid) {
633 $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'));
634 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
635 if (is_array($sys_log_row)) {
636 $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
637 }
638 }
639 // Creating the selector box, allowing the user to select which element to edit:
640 $opt = array();
641 $is_selected = 0;
642 $languageOverlayRecord = '';
643 if ($this->current_sys_language) {
644 list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int)$this->current_sys_language);
645 }
646 if (is_array($languageOverlayRecord)) {
647 $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
648 $is_selected += (int)$edit_record == $inValue;
649 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', TRUE) . ' ]</option>';
650 } else {
651 $inValue = 'pages:' . $this->id;
652 $is_selected += (int)$edit_record == $inValue;
653 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . ' ]</option>';
654 }
655 // Selecting all content elements from this language and allowed colPos:
656 $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');
657 $colPos = NULL;
658 $first = 1;
659 // Page is the pid if no record to put this after.
660 $prev = $this->id;
661 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
662 BackendUtility::workspaceOL('tt_content', $cRow);
663 if (is_array($cRow)) {
664 if ($first) {
665 if (!$edit_record) {
666 $edit_record = 'tt_content:' . $cRow['uid'];
667 }
668 $first = 0;
669 }
670 if (!isset($colPos) || $cRow['colPos'] !== $colPos) {
671 $colPos = $cRow['colPos'];
672 $opt[] = '<option value=""></option>';
673 $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), TRUE) . ':__</option>';
674 }
675 $inValue = 'tt_content:' . $cRow['uid'];
676 $is_selected += (int)$edit_record == $inValue;
677 $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>';
678 $prev = -$cRow['uid'];
679 }
680 }
681 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
682 if (!$edit_record) {
683 $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
684 $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
685 $is_selected += (int)$edit_record == $inValue;
686 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
687 }
688 // If none is yet selected...
689 if (!$is_selected) {
690 $opt[] = '<option value=""></option>';
691 $opt[] = '<option value="' . $edit_record . '" selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', TRUE) . ' ]</option>';
692 }
693 // Splitting the edit-record cmd value into table/uid:
694 $this->eRParts = explode(':', $edit_record);
695 // Delete-button flag?
696 $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
697 // If undo-button should be rendered (depends on available items in sys_history)
698 $this->undoButton = 0;
699 $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');
700 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
701 $this->undoButton = 1;
702 }
703 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
704 $R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
705 $R_URL_getvars = GeneralUtility::_GET();
706 unset($R_URL_getvars['popView']);
707 unset($R_URL_getvars['new_unique_uid']);
708 $R_URL_getvars['edit_record'] = $edit_record;
709 $this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
710 // Setting close url/return url for exiting this script:
711 // Goes to 'Columns' view if close is pressed (default)
712 $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
713 if ($this->returnUrl) {
714 $this->closeUrl = $this->returnUrl;
715 }
716 // Return-url for JavaScript:
717 $retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
718 // Drawing the edit record selectbox
719 $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>';
720 // Creating editing form:
721 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)) {
722 // Splitting uid parts for special features, if new:
723 list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
724 // Convert $uidVal to workspace version if any:
725 if ($uidVal != 'new') {
726 if ($draftRecord = BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
727 $uidVal = $draftRecord['uid'];
728 }
729 }
730 // Initializing transfer-data object:
731 $trData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
732 $trData->addRawData = TRUE;
733 $trData->defVals[$this->eRParts[0]] = array(
734 'colPos' => (int)$ex_colPos,
735 'sys_language_uid' => (int)$this->current_sys_language
736 );
737 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
738 $trData->lockRecords = 1;
739 // 'new'
740 $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
741 // Getting/Making the record:
742 reset($trData->regTableItems_data);
743 $rec = current($trData->regTableItems_data);
744 if ($uidVal == 'new') {
745 $new_unique_uid = uniqid('NEW');
746 $rec['uid'] = $new_unique_uid;
747 $rec['pid'] = (int)$ex_pid ?: $this->id;
748 $recordAccess = TRUE;
749 } else {
750 $rec['uid'] = $uidVal;
751 // Checking internals access:
752 $recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
753 }
754 if (!$recordAccess) {
755 // If no edit access, print error message:
756 $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);
757 } elseif (is_array($rec)) {
758 // If the record is an array (which it will always be... :-)
759 // Create instance of TCEforms, setting defaults:
760 $tceforms = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
761 $tceforms->backPath = $GLOBALS['BACK_PATH'];
762 $tceforms->initDefaultBEMode();
763 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
764 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
765 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
766 $tceforms->enableClickMenu = TRUE;
767 // Clipboard is initialized:
768 // Start clipboard
769 $tceforms->clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
770 // Initialize - reads the clipboard content from the user session
771 $tceforms->clipObj->initializeClipboard();
772 // Render form, wrap it:
773 $panel = '';
774 $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
775 $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
776 // Add hidden fields:
777 $theCode = $panel;
778 if ($uidVal == 'new') {
779 $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
780 }
781 $theCode .= '
782 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
783 <input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
784 <input type="hidden" name="edit_record" value="' . $edit_record . '" />
785 <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)) . '" />
786 ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
787 // Add JavaScript as needed around the form:
788 $theCode = $tceforms->printNeededJSFunctions_top() . $theCode . $tceforms->printNeededJSFunctions();
789 // Add warning sign if record was "locked":
790 if ($lockInfo = BackendUtility::isRecordLocked($this->eRParts[0], $rec['uid'])) {
791 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
792 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
793 $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
794 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
795 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
796 $defaultFlashMessageQueue->enqueue($flashMessage);
797 }
798 // Add whole form as a document section:
799 $content = $this->doc->section('', $theCode);
800 }
801 } else {
802 // If no edit access, print error message:
803 $content = $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />', 0, 1);
804 }
805 // Bottom controls (function menus):
806 $q_count = $this->getNumberOfHiddenElements();
807 $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>';
808 $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>';
809 if (ExtensionManagementUtility::isLoaded('context_help')) {
810 $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>';
811 }
812 if ($GLOBALS['BE_USER']->isRTE()) {
813 $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>';
814 }
815 // Add the function menus to bottom:
816 $content .= $this->doc->section('', $h_func_b, 0, 0);
817 $content .= $this->doc->spacer(10);
818 // Select element matrix:
819 if ($this->eRParts[0] == 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
820 $posMap = GeneralUtility::makeInstance('ext_posMap');
821 $posMap->backPath = $GLOBALS['BACK_PATH'];
822 $posMap->cur_sys_language = $this->current_sys_language;
823 $HTMLcode = '';
824 // CSH:
825 $HTMLcode .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', $GLOBALS['BACK_PATH'], '|<br />');
826 $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
827 $content .= $this->doc->spacer(20);
828 $content .= $this->doc->section($GLOBALS['LANG']->getLL('CEonThisPage'), $HTMLcode, 0, 1);
829 $content .= $this->doc->spacer(20);
830 }
831 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
832 if (count($tceforms->commentMessages)) {
833 $content .= '
834 <!-- TCEFORM messages
835 ' . htmlspecialchars(implode(LF, $tceforms->commentMessages)) . '
836 -->
837 ';
838 }
839 return $content;
840 }
841
842 /**
843 * Rendering all other listings than QuickEdit
844 *
845 * @return void
846 * @todo Define visibility
847 */
848 public function renderListContent() {
849 // Initialize list object (see "class.db_layout.inc"):
850 /** @var $dblist \TYPO3\CMS\Backend\View\PageLayoutView */
851 $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView');
852 $dblist->backPath = $GLOBALS['BACK_PATH'];
853 $dblist->thumbs = $this->imagemode;
854 $dblist->no_noWrap = 1;
855 $dblist->descrTable = $this->descrTable;
856 $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
857 $dblist->script = 'db_layout.php';
858 $dblist->showIcon = 0;
859 $dblist->setLMargin = 0;
860 $dblist->doEdit = $this->EDIT_CONTENT;
861 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
862 $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
863 $dblist->id = $this->id;
864 $dblist->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
865 $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] === '0';
866 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
867 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
868 if (!$dblist->nextThree) {
869 $dblist->nextThree = 1;
870 }
871 $dblist->externalTables = $this->externalTables;
872 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
873 $h_menu = $dblist->getTableMenu($this->id);
874 // Initialize other variables:
875 $h_func = '';
876 $tableOutput = array();
877 $tableJSOutput = array();
878 $CMcounter = 0;
879 // Traverse the list of table names which has records on this page (that array is populated
880 // by the $dblist object during the function getTableMenu()):
881 foreach ($dblist->activeTables as $table => $value) {
882 if (!isset($dblist->externalTables[$table])) {
883 $q_count = $this->getNumberOfHiddenElements();
884 $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>';
885 // Boolean: Display up/down arrows and edit icons for tt_content records
886 $dblist->tt_contentConfig['showCommands'] = 1;
887 // Boolean: Display info-marks or not
888 $dblist->tt_contentConfig['showInfo'] = 1;
889 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown
890 // in the total width of the page
891 $dblist->tt_contentConfig['single'] = 0;
892 if ($this->MOD_SETTINGS['function'] == 4) {
893 // Grid view
894 $dblist->tt_contentConfig['showAsGrid'] = 1;
895 }
896 // Setting up the tt_content columns to show:
897 if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
898 $colList = array();
899 $tcaItems = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $this->id, $this);
900 foreach ($tcaItems as $temp) {
901 $colList[] = $temp[1];
902 }
903 } else {
904 // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
905 $colList = array('1', '0', '2', '3');
906 }
907 if ($this->colPosList !== '') {
908 $colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
909 }
910 // If only one column found, display the single-column view.
911 if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) {
912 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol']
913 // is shown in the total width of the page
914 $dblist->tt_contentConfig['single'] = 1;
915 // The column(s) to show if single mode (under each other)
916 $dblist->tt_contentConfig['showSingleCol'] = current($colList);
917 }
918 // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
919 $dblist->tt_contentConfig['cols'] = implode(',', $colList);
920 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
921 $dblist->tt_contentConfig['sys_language_uid'] = (int)$this->current_sys_language;
922 // If the function menu is set to "Language":
923 if ($this->MOD_SETTINGS['function'] == 2) {
924 $dblist->tt_contentConfig['single'] = 0;
925 $dblist->tt_contentConfig['languageMode'] = 1;
926 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
927 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
928 }
929 } else {
930 if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
931 $h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
932 } else {
933 $h_func = '';
934 }
935 }
936 // Start the dblist object:
937 $dblist->itemsLimitSingleTable = 1000;
938 $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
939 $dblist->counter = $CMcounter;
940 $dblist->ext_function = $this->MOD_SETTINGS['function'];
941 // Render versioning selector:
942 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
943 // Generate the list of elements here:
944 $dblist->generateList();
945 // Adding the list content to the tableOutput variable:
946 $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 : '');
947 // ... and any accumulated JavaScript goes the same way!
948 $tableJSOutput[$table] = $dblist->JScode;
949 // Increase global counter:
950 $CMcounter += $dblist->counter;
951 // Reset variables after operation:
952 $dblist->HTMLcode = '';
953 $dblist->JScode = '';
954 $h_func = '';
955 $h_func_b = '';
956 }
957 // END: traverse tables
958 // For Context Sensitive Menus:
959 $this->doc->getContextMenuCode();
960 // Init the content
961 $content = '';
962 // Additional header content
963 $headerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'];
964 if (is_array($headerContentHook)) {
965 foreach ($headerContentHook as $hook) {
966 $params = array();
967 $content .= GeneralUtility::callUserFunction($hook, $params, $this);
968 }
969 }
970 // Add the content for each table we have rendered (traversing $tableOutput variable)
971 foreach ($tableOutput as $table => $output) {
972 $content .= $this->doc->section('', $output, TRUE, TRUE, 0, TRUE);
973 $content .= $this->doc->spacer(15);
974 $content .= $this->doc->sectionEnd();
975 }
976 // Making search form:
977 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
978 $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
979 $content .= $this->doc->section($sectionTitle, $dblist->getSearchBox(0), FALSE, TRUE, FALSE, TRUE);
980 }
981 // Additional footer content
982 $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'];
983 if (is_array($footerContentHook)) {
984 foreach ($footerContentHook as $hook) {
985 $params = array();
986 $content .= GeneralUtility::callUserFunction($hook, $params, $this);
987 }
988 }
989 return $content;
990 }
991
992 /**
993 * Print accumulated content of module
994 *
995 * @return void
996 * @todo Define visibility
997 */
998 public function printContent() {
999 echo $this->content;
1000 }
1001
1002 /***************************
1003 *
1004 * Sub-content functions, rendering specific parts of the module content.
1005 *
1006 ***************************/
1007 /**
1008 * Create the panel of buttons for submitting the form or otherwise perform operations.
1009 *
1010 * @param string $function Identifier for function of module
1011 * @return array all available buttons as an assoc. array
1012 */
1013 protected function getButtons($function = '') {
1014 $buttons = array(
1015 'view' => '',
1016 'history_page' => '',
1017 'new_content' => '',
1018 'move_page' => '',
1019 'move_record' => '',
1020 'new_page' => '',
1021 'edit_page' => '',
1022 'edit_language' => '',
1023 'csh' => '',
1024 'shortcut' => '',
1025 'cache' => '',
1026 'savedok' => '',
1027 'save_close' => '',
1028 'savedokshow' => '',
1029 'closedok' => '',
1030 'deletedok' => '',
1031 'undo' => '',
1032 'history_record' => ''
1033 );
1034 // View page
1035 $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>';
1036 // Shortcut
1037 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1038 $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']);
1039 }
1040 // Cache
1041 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1042 $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>';
1043 }
1044 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1045 // Move record
1046 if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
1047 $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>';
1048 }
1049
1050 // Edit page properties and page language overlay icons
1051 if ($this->CALC_PERMS & 2) {
1052
1053 // Edit localized page_language_overlay only when one specific language is selected
1054 if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
1055 $overlayRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
1056 'uid',
1057 'pages_language_overlay',
1058 'pid = ' . (int)$this->id . ' ' .
1059 'AND sys_language_uid = ' . (int)$this->current_sys_language .
1060 BackendUtility::deleteClause('pages_language_overlay') .
1061 BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1062 '',
1063 '',
1064 '',
1065 'sys_language_uid'
1066 );
1067
1068 $editLanguageOnClick = htmlspecialchars(
1069 BackendUtility::editOnClick(
1070 '&edit[pages_language_overlay][' . $overlayRecord['uid'] . ']=edit',
1071 $GLOBALS['BACK_PATH'])
1072 );
1073 $buttons['edit_language'] = '<a href="#" ' .
1074 'onclick="' . $editLanguageOnClick . '"' .
1075 'title="' . $GLOBALS['LANG']->getLL('editPageLanguageOverlayProperties', TRUE) . '">' .
1076 \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay') .
1077 '</a>';
1078 }
1079
1080
1081 // Edit page properties
1082 $editPageOnClick = htmlspecialchars(
1083 BackendUtility::editOnClick('&edit[pages][' . $this->id . ']=edit', $GLOBALS['BACK_PATH'])
1084 );
1085 $buttons['edit_page'] = '<a href="#" ' .
1086 'onclick="' . $editPageOnClick . '"' .
1087 'title="' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . '">' .
1088 \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-page-open') .
1089 '</a>';
1090 }
1091
1092 // Add CSH (Context Sensitive Help) icon to tool bar
1093 if ($function == 'quickEdit') {
1094 $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'quickEdit', $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1095 } else {
1096 $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1097 }
1098 if ($function == 'quickEdit') {
1099 // Save record
1100 $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) . '" />'));
1101 // Save and close
1102 $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) . '" />'));
1103 // Save record and show page
1104 $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>';
1105 // Close record
1106 $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>';
1107 // Delete record
1108 if ($this->deleteButton) {
1109 $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>';
1110 }
1111 if ($this->undoButton) {
1112 // Undo button
1113 $buttons['undo'] = '<a href="#"
1114 onclick="' . htmlspecialchars('window.location.href=' .
1115 GeneralUtility::quoteJSvalue(
1116 $GLOBALS['BACK_PATH'] .
1117 BackendUtility::getModuleUrl(
1118 'record_history',
1119 array(
1120 'element' => $this->eRParts[0] . ':' . $this->eRParts[1],
1121 'revert' => 'ALL_FIELDS',
1122 'sumUp' => -1,
1123 'returnUrl' => $this->R_URI,
1124 )
1125 )
1126 ) . '; return false;') . '"
1127 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>';
1128 // History button
1129 $buttons['history_record'] = '<a href="#"
1130 onclick="' . htmlspecialchars('jumpToUrl(' .
1131 GeneralUtility::quoteJSvalue(
1132 $GLOBALS['BACK_PATH'] .
1133 BackendUtility::getModuleUrl(
1134 'record_history',
1135 array(
1136 'element' => $this->eRParts[0] . ':' . $this->eRParts[1],
1137 'returnUrl' => $this->R_URI,
1138 )
1139 ) . '#latest'
1140 ) . ');return false;') . '"
1141 title="' . $GLOBALS['LANG']->getLL('recordHistory', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
1142 }
1143 }
1144 }
1145 return $buttons;
1146 }
1147
1148 /*******************************
1149 *
1150 * Other functions
1151 *
1152 ******************************/
1153 /**
1154 * Returns the number of hidden elements (including those hidden by start/end times)
1155 * on the current page (for the current sys_language)
1156 *
1157 * @return int
1158 * @todo Define visibility
1159 */
1160 public function getNumberOfHiddenElements() {
1161 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1162 'uid',
1163 'tt_content',
1164 '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')
1165 );
1166 }
1167
1168 /**
1169 * Returns URL to the current script.
1170 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1171 *
1172 * @param array $params Parameters array, merged with global GET vars.
1173 * @return string URL
1174 * @todo Define visibility
1175 */
1176 public function local_linkThisScript($params) {
1177 $params['popView'] = '';
1178 $params['new_unique_uid'] = '';
1179 return GeneralUtility::linkThisScript($params);
1180 }
1181
1182 /**
1183 * Returns a SQL query for selecting sys_language records.
1184 *
1185 * @param integer $id Page id: If zero, the query will select all sys_language records from root level which are NOT hidden. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user)
1186 * @return string Return query string.
1187 * @todo Define visibility
1188 */
1189 public function exec_languageQuery($id) {
1190 if ($id) {
1191 $exQ = BackendUtility::deleteClause('pages_language_overlay') .
1192 ($GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0');
1193 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1194 'sys_language.*',
1195 'pages_language_overlay,sys_language',
1196 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . (int)$id . $exQ .
1197 BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1198 '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',
1199 'sys_language.title'
1200 );
1201 } else {
1202 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1203 'sys_language.*',
1204 'sys_language',
1205 'sys_language.hidden=0',
1206 '',
1207 'sys_language.title'
1208 );
1209 }
1210 }
1211
1212 }