bc5024463a3ba6e503f5e56ca373496987b13faa
[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 textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Backend\Utility\BackendUtility;
31 use TYPO3\CMS\Backend\Utility\IconUtility;
32 use TYPO3\CMS\Core\Messaging\FlashMessage;
33 use TYPO3\CMS\Core\Utility\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 = intval(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 = intval($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', intval($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 ' . intval($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 = ' . intval($this->id) .
392 ' AND sys_language_uid = ' . intval($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 $this->doc->JScode .= $this->doc->wrapScriptTags('
428 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
429 if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages' . intval($this->id) . '_"+top.fsMod.currentBank; ' . intval($this->id) . ';
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 window.location.href = URL;
438 }
439 ' . ($this->popView ? BackendUtility::viewOnClick($this->id, $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->id)) : '') . '
440
441 function deleteRecord(table,id,url) { //
442 if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')) . ')) {
443 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";
444 }
445 return false;
446 }
447 ');
448 $this->doc->JScode .= $this->doc->wrapScriptTags('
449 var DTM_array = new Array();
450 var DTM_origClass = new String();
451
452 // if tabs are used in a popup window the array might not exists
453 if(!top.DTM_currentTabs) {
454 top.DTM_currentTabs = new Array();
455 }
456
457 function DTM_activate(idBase,index,doToogle) { //
458 // Hiding all:
459 if (DTM_array[idBase]) {
460 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
461 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
462 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
463 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
464 }
465 }
466 }
467
468 // Showing one:
469 if (document.getElementById(idBase+"-"+index+"-DIV")) {
470 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
471 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
472 if(DTM_origClass=="") {
473 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
474 } else {
475 DTM_origClass = "tab";
476 }
477 top.DTM_currentTabs[idBase] = -1;
478 } else {
479 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
480 if(DTM_origClass=="") {
481 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
482 } else {
483 DTM_origClass = "tabact";
484 }
485 top.DTM_currentTabs[idBase] = index;
486 }
487 }
488 }
489 function DTM_toggle(idBase,index,isInit) { //
490 // Showing one:
491 if (document.getElementById(idBase+"-"+index+"-DIV")) {
492 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
493 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
494 if(isInit) {
495 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
496 } else {
497 DTM_origClass = "tab";
498 }
499 top.DTM_currentTabs[idBase+"-"+index] = 0;
500 } else {
501 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
502 if(isInit) {
503 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
504 } else {
505 DTM_origClass = "tabact";
506 }
507 top.DTM_currentTabs[idBase+"-"+index] = 1;
508 }
509 }
510 }
511
512 function DTM_mouseOver(obj) { //
513 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
514 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
515 }
516
517 function DTM_mouseOut(obj) { //
518 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
519 DTM_origClass = "";
520 }
521 ');
522 // Setting doc-header
523 $this->doc->form = '<form action="' . htmlspecialchars(('db_layout.php?id=' . $this->id . '&imagemode=' . $this->imagemode)) . '" method="post">';
524 // Creating the top function menu:
525 $this->topFuncMenu = BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function'], 'db_layout.php', '');
526 $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', '') : '';
527 // Find backend layout / coumns
528 $backendLayout = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', $this->id, $this);
529 if (count($backendLayout['__colPosList'])) {
530 $this->colPosList = implode(',', $backendLayout['__colPosList']);
531 }
532 // Removing duplicates, if any
533 $this->colPosList = implode(',', array_unique(GeneralUtility::intExplode(',', $this->colPosList)));
534 // Page title
535 $body = $this->doc->header($this->getLocalizedPageTitle());
536 $body .= $this->getHeaderFlashMessagesForCurrentPid();
537 // Render the primary module content:
538 if ($this->MOD_SETTINGS['function'] == 0) {
539 // QuickEdit
540 $body .= $this->renderQuickEdit();
541 } else {
542 // All other listings
543 $body .= $this->renderListContent();
544 }
545 // Setting up the buttons and markers for docheader
546 $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function'] == 0 ? 'quickEdit' : '');
547 $markers = array(
548 'CSH' => $docHeaderButtons['csh'],
549 'TOP_FUNCTION_MENU' => $this->topFuncMenu . $this->editSelect,
550 'LANGSELECTOR' => $this->languageMenu,
551 'CONTENT' => $body
552 );
553 // Build the <body> for the module
554 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
555 // Renders the module page
556 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
557 } else {
558 // If no access or id value, create empty document:
559 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
560 $this->doc->backPath = $GLOBALS['BACK_PATH'];
561 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout.html');
562 $this->doc->JScode = $this->doc->wrapScriptTags('
563 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
564 ');
565 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('clickAPage_content'), $GLOBALS['LANG']->getLL('clickAPage_header'), FlashMessage::INFO);
566 $body = $flashMessage->render();
567 // Setting up the buttons and markers for docheader
568 $docHeaderButtons = array(
569 'view' => '',
570 'history_page' => '',
571 'new_content' => '',
572 'move_page' => '',
573 'move_record' => '',
574 'new_page' => '',
575 'edit_page' => '',
576 'csh' => '',
577 'shortcut' => '',
578 'cache' => '',
579 'savedok' => '',
580 'savedokshow' => '',
581 'closedok' => '',
582 'deletedok' => '',
583 'undo' => '',
584 'history_record' => '',
585 'edit_language' => ''
586 );
587 $markers = array(
588 'CSH' => BackendUtility::cshItem($this->descrTable, '', $GLOBALS['BACK_PATH'], '', TRUE),
589 'TOP_FUNCTION_MENU' => '',
590 'LANGSELECTOR' => '',
591 'CONTENT' => $body
592 );
593 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
594 // Renders the module page
595 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
596 }
597 }
598
599 /**
600 * Rendering the quick-edit view.
601 *
602 * @return void
603 * @todo Define visibility
604 */
605 public function renderQuickEdit() {
606 // Alternative template
607 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout_quickedit.html');
608 // Alternative form tag; Quick Edit submits its content to tce_db.php.
609 $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);">';
610 // Setting up the context sensitive menu:
611 $this->doc->getContextMenuCode();
612 // Set the edit_record value for internal use in this function:
613 $edit_record = $this->edit_record;
614 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
615 if (substr($edit_record, 0, 9) == '_EDIT_COL') {
616 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND colPos=' . intval(substr($edit_record, 10)) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
617 $idListA = array();
618 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
619 $idListA[] = $cRow['uid'];
620 }
621 $url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
622 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
623 }
624 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
625 if ($this->new_unique_uid) {
626 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'userid=' . intval($GLOBALS['BE_USER']->user['uid']) . ' AND NEWid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->new_unique_uid, 'sys_log'));
627 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
628 if (is_array($sys_log_row)) {
629 $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
630 }
631 }
632 // Creating the selector box, allowing the user to select which element to edit:
633 $opt = array();
634 $is_selected = 0;
635 $languageOverlayRecord = '';
636 if ($this->current_sys_language) {
637 list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . intval($this->current_sys_language));
638 }
639 if (is_array($languageOverlayRecord)) {
640 $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
641 $is_selected += intval($edit_record == $inValue);
642 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', TRUE) . ' ]</option>';
643 } else {
644 $inValue = 'pages:' . $this->id;
645 $is_selected += intval($edit_record == $inValue);
646 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . ' ]</option>';
647 }
648 // Selecting all content elements from this language and allowed colPos:
649 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . intval($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');
650 $colPos = '';
651 $first = 1;
652 // Page is the pid if no record to put this after.
653 $prev = $this->id;
654 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
655 BackendUtility::workspaceOL('tt_content', $cRow);
656 if (is_array($cRow)) {
657 if ($first) {
658 if (!$edit_record) {
659 $edit_record = 'tt_content:' . $cRow['uid'];
660 }
661 $first = 0;
662 }
663 if (strcmp($cRow['colPos'], $colPos)) {
664 $colPos = $cRow['colPos'];
665 $opt[] = '<option value=""></option>';
666 $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), TRUE) . ':__</option>';
667 }
668 $inValue = 'tt_content:' . $cRow['uid'];
669 $is_selected += intval($edit_record == $inValue);
670 $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>';
671 $prev = -$cRow['uid'];
672 }
673 }
674 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
675 if (!$edit_record) {
676 $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
677 $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
678 $is_selected += intval($edit_record == $inValue);
679 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
680 }
681 // If none is yet selected...
682 if (!$is_selected) {
683 $opt[] = '<option value=""></option>';
684 $opt[] = '<option value="' . $edit_record . '" selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', TRUE) . ' ]</option>';
685 }
686 // Splitting the edit-record cmd value into table/uid:
687 $this->eRParts = explode(':', $edit_record);
688 // Delete-button flag?
689 $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
690 // If undo-button should be rendered (depends on available items in sys_history)
691 $this->undoButton = 0;
692 $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . intval($this->eRParts[1]), '', 'tstamp DESC', '1');
693 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
694 $this->undoButton = 1;
695 }
696 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
697 $R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
698 $R_URL_getvars = GeneralUtility::_GET();
699 unset($R_URL_getvars['popView']);
700 unset($R_URL_getvars['new_unique_uid']);
701 $R_URL_getvars['edit_record'] = $edit_record;
702 $this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
703 // Setting close url/return url for exiting this script:
704 // Goes to 'Columns' view if close is pressed (default)
705 $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
706 if ($GLOBALS['BE_USER']->uc['condensedMode']) {
707 $this->closeUrl = $GLOBALS['BACK_PATH'] . 'alt_db_navframe.php';
708 }
709 if ($this->returnUrl) {
710 $this->closeUrl = $this->returnUrl;
711 }
712 // Return-url for JavaScript:
713 $retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
714 // Drawing the edit record selectbox
715 $this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars(('jumpToUrl(\'db_layout.php?id=' . $this->id . '&edit_record=\'+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);')) . '">' . implode('', $opt) . '</select>';
716 // Creating editing form:
717 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)) {
718 // Splitting uid parts for special features, if new:
719 list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
720 // Convert $uidVal to workspace version if any:
721 if ($uidVal != 'new') {
722 if ($draftRecord = BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
723 $uidVal = $draftRecord['uid'];
724 }
725 }
726 // Initializing transfer-data object:
727 $trData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
728 $trData->addRawData = TRUE;
729 $trData->defVals[$this->eRParts[0]] = array(
730 'colPos' => intval($ex_colPos),
731 'sys_language_uid' => intval($this->current_sys_language)
732 );
733 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
734 $trData->lockRecords = 1;
735 // 'new'
736 $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
737 // Getting/Making the record:
738 reset($trData->regTableItems_data);
739 $rec = current($trData->regTableItems_data);
740 if ($uidVal == 'new') {
741 $new_unique_uid = uniqid('NEW');
742 $rec['uid'] = $new_unique_uid;
743 $rec['pid'] = intval($ex_pid) ? intval($ex_pid) : $this->id;
744 $recordAccess = TRUE;
745 } else {
746 $rec['uid'] = $uidVal;
747 // Checking internals access:
748 $recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
749 }
750 if (!$recordAccess) {
751 // If no edit access, print error message:
752 $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);
753 } elseif (is_array($rec)) {
754 // If the record is an array (which it will always be... :-)
755 // Create instance of TCEforms, setting defaults:
756 $tceforms = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
757 $tceforms->backPath = $GLOBALS['BACK_PATH'];
758 $tceforms->initDefaultBEMode();
759 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
760 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
761 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
762 $tceforms->enableClickMenu = TRUE;
763 // Clipboard is initialized:
764 // Start clipboard
765 $tceforms->clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
766 // Initialize - reads the clipboard content from the user session
767 $tceforms->clipObj->initializeClipboard();
768 // Render form, wrap it:
769 $panel = '';
770 $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
771 $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
772 // Add hidden fields:
773 $theCode = $panel;
774 if ($uidVal == 'new') {
775 $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
776 }
777 $theCode .= '
778 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
779 <input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
780 <input type="hidden" name="edit_record" value="' . $edit_record . '" />
781 <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)) . '" />
782 ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
783 // Add JavaScript as needed around the form:
784 $theCode = $tceforms->printNeededJSFunctions_top() . $theCode . $tceforms->printNeededJSFunctions();
785 // Add warning sign if record was "locked":
786 if ($lockInfo = BackendUtility::isRecordLocked($this->eRParts[0], $rec['uid'])) {
787 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
788 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
789 $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
790 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
791 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
792 $defaultFlashMessageQueue->enqueue($flashMessage);
793 }
794 // Add whole form as a document section:
795 $content .= $this->doc->section('', $theCode);
796 }
797 } else {
798 // If no edit access, print error message:
799 $content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />', 0, 1);
800 }
801 // Bottom controls (function menus):
802 $q_count = $this->getNumberOfHiddenElements();
803 $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>';
804 $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>';
805 if (ExtensionManagementUtility::isLoaded('context_help')) {
806 $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>';
807 }
808 if ($GLOBALS['BE_USER']->isRTE()) {
809 $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>';
810 }
811 // Add the function menus to bottom:
812 $content .= $this->doc->section('', $h_func_b, 0, 0);
813 $content .= $this->doc->spacer(10);
814 // Select element matrix:
815 if ($this->eRParts[0] == 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
816 $posMap = GeneralUtility::makeInstance('ext_posMap');
817 $posMap->backPath = $GLOBALS['BACK_PATH'];
818 $posMap->cur_sys_language = $this->current_sys_language;
819 $HTMLcode = '';
820 // CSH:
821 $HTMLcode .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', $GLOBALS['BACK_PATH'], '|<br />');
822 $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
823 $content .= $this->doc->spacer(20);
824 $content .= $this->doc->section($GLOBALS['LANG']->getLL('CEonThisPage'), $HTMLcode, 0, 1);
825 $content .= $this->doc->spacer(20);
826 }
827 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
828 if (count($tceforms->commentMessages)) {
829 $content .= '
830 <!-- TCEFORM messages
831 ' . htmlspecialchars(implode(LF, $tceforms->commentMessages)) . '
832 -->
833 ';
834 }
835 return $content;
836 }
837
838 /**
839 * Rendering all other listings than QuickEdit
840 *
841 * @return void
842 * @todo Define visibility
843 */
844 public function renderListContent() {
845 // Initialize list object (see "class.db_layout.inc"):
846 /** @var $dblist \TYPO3\CMS\Backend\View\PageLayoutView */
847 $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView');
848 $dblist->backPath = $GLOBALS['BACK_PATH'];
849 $dblist->thumbs = $this->imagemode;
850 $dblist->no_noWrap = 1;
851 $dblist->descrTable = $this->descrTable;
852 $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
853 $dblist->script = 'db_layout.php';
854 $dblist->showIcon = 0;
855 $dblist->setLMargin = 0;
856 $dblist->doEdit = $this->EDIT_CONTENT;
857 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
858 $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
859 $dblist->id = $this->id;
860 $dblist->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
861 $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] === '0';
862 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
863 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
864 if (!$dblist->nextThree) {
865 $dblist->nextThree = 1;
866 }
867 $dblist->externalTables = $this->externalTables;
868 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
869 $h_menu = $dblist->getTableMenu($this->id);
870 // Initialize other variables:
871 $h_func = '';
872 $tableOutput = array();
873 $tableJSOutput = array();
874 $CMcounter = 0;
875 // Traverse the list of table names which has records on this page (that array is populated
876 // by the $dblist object during the function getTableMenu()):
877 foreach ($dblist->activeTables as $table => $value) {
878 if (!isset($dblist->externalTables[$table])) {
879 $q_count = $this->getNumberOfHiddenElements();
880 $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>';
881 // Boolean: Display up/down arrows and edit icons for tt_content records
882 $dblist->tt_contentConfig['showCommands'] = 1;
883 // Boolean: Display info-marks or not
884 $dblist->tt_contentConfig['showInfo'] = 1;
885 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown
886 // in the total width of the page
887 $dblist->tt_contentConfig['single'] = 0;
888 if ($this->MOD_SETTINGS['function'] == 4) {
889 // Grid view
890 $dblist->tt_contentConfig['showAsGrid'] = 1;
891 }
892 // Setting up the tt_content columns to show:
893 if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
894 $colList = array();
895 $tcaItems = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $this->id, $this);
896 foreach ($tcaItems as $temp) {
897 $colList[] = $temp[1];
898 }
899 } else {
900 // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
901 $colList = array('1', '0', '2', '3');
902 }
903 if (strcmp($this->colPosList, '')) {
904 $colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
905 }
906 // If only one column found, display the single-column view.
907 if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) {
908 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol']
909 // is shown in the total width of the page
910 $dblist->tt_contentConfig['single'] = 1;
911 // The column(s) to show if single mode (under each other)
912 $dblist->tt_contentConfig['showSingleCol'] = current($colList);
913 }
914 // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
915 $dblist->tt_contentConfig['cols'] = implode(',', $colList);
916 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
917 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
918 // If the function menu is set to "Language":
919 if ($this->MOD_SETTINGS['function'] == 2) {
920 $dblist->tt_contentConfig['single'] = 0;
921 $dblist->tt_contentConfig['languageMode'] = 1;
922 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
923 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
924 }
925 } else {
926 if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
927 $h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
928 } else {
929 $h_func = '';
930 }
931 }
932 // Start the dblist object:
933 $dblist->itemsLimitSingleTable = 1000;
934 $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
935 $dblist->counter = $CMcounter;
936 $dblist->ext_function = $this->MOD_SETTINGS['function'];
937 // Render versioning selector:
938 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
939 // Generate the list of elements here:
940 $dblist->generateList();
941 // Adding the list content to the tableOutput variable:
942 $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 : '');
943 // ... and any accumulated JavaScript goes the same way!
944 $tableJSOutput[$table] = $dblist->JScode;
945 // Increase global counter:
946 $CMcounter += $dblist->counter;
947 // Reset variables after operation:
948 $dblist->HTMLcode = '';
949 $dblist->JScode = '';
950 $h_func = '';
951 $h_func_b = '';
952 }
953 // END: traverse tables
954 // For Context Sensitive Menus:
955 $this->doc->getContextMenuCode();
956 // Add the content for each table we have rendered (traversing $tableOutput variable)
957 foreach ($tableOutput as $table => $output) {
958 $content .= $this->doc->section('', $output, TRUE, TRUE, 0, TRUE);
959 $content .= $this->doc->spacer(15);
960 $content .= $this->doc->sectionEnd();
961 }
962 // Making search form:
963 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
964 $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
965 $content .= $this->doc->section($sectionTitle, $dblist->getSearchBox(0), FALSE, TRUE, FALSE, TRUE);
966 }
967 // Additional footer content
968 $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'];
969 if (is_array($footerContentHook)) {
970 foreach ($footerContentHook as $hook) {
971 $params = array();
972 $content .= GeneralUtility::callUserFunction($hook, $params, $this);
973 }
974 }
975 return $content;
976 }
977
978 /**
979 * Print accumulated content of module
980 *
981 * @return void
982 * @todo Define visibility
983 */
984 public function printContent() {
985 echo $this->content;
986 }
987
988 /***************************
989 *
990 * Sub-content functions, rendering specific parts of the module content.
991 *
992 ***************************/
993 /**
994 * Create the panel of buttons for submitting the form or otherwise perform operations.
995 *
996 * @param string $function Identifier for function of module
997 * @return array all available buttons as an assoc. array
998 */
999 protected function getButtons($function = '') {
1000 $buttons = array(
1001 'view' => '',
1002 'history_page' => '',
1003 'new_content' => '',
1004 'move_page' => '',
1005 'move_record' => '',
1006 'new_page' => '',
1007 'edit_page' => '',
1008 'edit_language' => '',
1009 'csh' => '',
1010 'shortcut' => '',
1011 'cache' => '',
1012 'savedok' => '',
1013 'save_close' => '',
1014 'savedokshow' => '',
1015 'closedok' => '',
1016 'deletedok' => '',
1017 'undo' => '',
1018 'history_record' => ''
1019 );
1020 // View page
1021 $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>';
1022 // Shortcut
1023 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1024 $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']);
1025 }
1026 // Cache
1027 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1028 $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>';
1029 }
1030 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1031 // Move record
1032 if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
1033 $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>';
1034 }
1035
1036 // Edit page properties and page language overlay icons
1037 if ($this->CALC_PERMS & 2) {
1038
1039 // Edit localized page_language_overlay only when one specific language is selected
1040 if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
1041 $overlayRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
1042 'uid',
1043 'pages_language_overlay',
1044 'pid = ' . intval($this->id) . ' ' .
1045 'AND sys_language_uid = ' . intval($this->current_sys_language) .
1046 BackendUtility::deleteClause('pages_language_overlay') .
1047 BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1048 '',
1049 '',
1050 '',
1051 'sys_language_uid'
1052 );
1053
1054 $editLanguageOnClick = htmlspecialchars(
1055 BackendUtility::editOnClick(
1056 '&edit[pages_language_overlay][' . $overlayRecord['uid'] . ']=edit',
1057 $GLOBALS['BACK_PATH'])
1058 );
1059 $buttons['edit_language'] = '<a href="#" ' .
1060 'onclick="' . $editLanguageOnClick . '"' .
1061 'title="' . $GLOBALS['LANG']->getLL('editPageLanguageOverlayProperties', TRUE) . '">' .
1062 \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay') .
1063 '</a>';
1064 }
1065
1066
1067 // Edit page properties
1068 $editPageOnClick = htmlspecialchars(
1069 BackendUtility::editOnClick('&edit[pages][' . $this->id . ']=edit', $GLOBALS['BACK_PATH'])
1070 );
1071 $buttons['edit_page'] = '<a href="#" ' .
1072 'onclick="' . $editPageOnClick . '"' .
1073 'title="' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . '">' .
1074 \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-page-open') .
1075 '</a>';
1076 }
1077
1078 // Add CSH (Context Sensitive Help) icon to tool bar
1079 if ($function == 'quickEdit') {
1080 $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'quickEdit', $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1081 } else {
1082 $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1083 }
1084 if ($function == 'quickEdit') {
1085 // Save record
1086 $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) . '" />'));
1087 // Save and close
1088 $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) . '" />'));
1089 // Save record and show page
1090 $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>';
1091 // Close record
1092 $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>';
1093 // Delete record
1094 if ($this->deleteButton) {
1095 $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>';
1096 }
1097 if ($this->undoButton) {
1098 // Undo button
1099 $buttons['undo'] = '<a href="#"
1100 onclick="' . htmlspecialchars(('window.location.href=\'' . $GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode(($this->eRParts[0] . ':' . $this->eRParts[1])) . '&revert=ALL_FIELDS&sumUp=-1&returnUrl=' . rawurlencode($this->R_URI) . '\'; return false;')) . '"
1101 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>';
1102 // History button
1103 $buttons['history_record'] = '<a href="#" onclick="' . htmlspecialchars(('jumpToUrl(\'' . $GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode(($this->eRParts[0] . ':' . $this->eRParts[1])) . '&returnUrl=' . rawurlencode($this->R_URI) . '#latest\');return false;')) . '" title="' . $GLOBALS['LANG']->getLL('recordHistory', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
1104 }
1105 }
1106 }
1107 return $buttons;
1108 }
1109
1110 /*******************************
1111 *
1112 * Other functions
1113 *
1114 ******************************/
1115 /**
1116 * Returns the number of hidden elements (including those hidden by start/end times)
1117 * on the current page (for the current sys_language)
1118 *
1119 * @return void
1120 * @todo Define visibility
1121 */
1122 public function getNumberOfHiddenElements() {
1123 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1124 'uid',
1125 'tt_content',
1126 'pid=' . intval($this->id) . ' AND sys_language_uid=' . intval($this->current_sys_language) . BackendUtility::BEenableFields('tt_content', 1) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content')
1127 );
1128 }
1129
1130 /**
1131 * Returns URL to the current script.
1132 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1133 *
1134 * @param array $params Parameters array, merged with global GET vars.
1135 * @return string URL
1136 * @todo Define visibility
1137 */
1138 public function local_linkThisScript($params) {
1139 $params['popView'] = '';
1140 $params['new_unique_uid'] = '';
1141 return GeneralUtility::linkThisScript($params);
1142 }
1143
1144 /**
1145 * Returns a SQL query for selecting sys_language records.
1146 *
1147 * @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)
1148 * @return string Return query string.
1149 * @todo Define visibility
1150 */
1151 public function exec_languageQuery($id) {
1152 if ($id) {
1153 $exQ = BackendUtility::deleteClause('pages_language_overlay') .
1154 ($GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0');
1155 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1156 'sys_language.*',
1157 'pages_language_overlay,sys_language',
1158 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . intval($id) . $exQ .
1159 BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1160 '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',
1161 'sys_language.title'
1162 );
1163 } else {
1164 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1165 'sys_language.*',
1166 'sys_language',
1167 'sys_language.hidden=0',
1168 '',
1169 'sys_language.title'
1170 );
1171 }
1172 }
1173
1174 }