[FEATURE] Improve livesearch results
[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.xml: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'] . '../t3lib/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', 1) . 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 );
586 $markers = array(
587 'CSH' => BackendUtility::cshItem($this->descrTable, '', $GLOBALS['BACK_PATH'], '', TRUE),
588 'TOP_FUNCTION_MENU' => '',
589 'LANGSELECTOR' => '',
590 'CONTENT' => $body
591 );
592 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
593 // Renders the module page
594 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
595 }
596 }
597
598 /**
599 * Rendering the quick-edit view.
600 *
601 * @return void
602 * @todo Define visibility
603 */
604 public function renderQuickEdit() {
605 // Alternative template
606 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout_quickedit.html');
607 // Alternative form tag; Quick Edit submits its content to tce_db.php.
608 $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);">';
609 // Setting up the context sensitive menu:
610 $this->doc->getContextMenuCode();
611 // Set the edit_record value for internal use in this function:
612 $edit_record = $this->edit_record;
613 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
614 if (substr($edit_record, 0, 9) == '_EDIT_COL') {
615 $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');
616 $idListA = array();
617 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
618 $idListA[] = $cRow['uid'];
619 }
620 $url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
621 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
622 }
623 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
624 if ($this->new_unique_uid) {
625 $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'));
626 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
627 if (is_array($sys_log_row)) {
628 $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
629 }
630 }
631 // Creating the selector box, allowing the user to select which element to edit:
632 $opt = array();
633 $is_selected = 0;
634 $languageOverlayRecord = '';
635 if ($this->current_sys_language) {
636 list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . intval($this->current_sys_language));
637 }
638 if (is_array($languageOverlayRecord)) {
639 $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
640 $is_selected += intval($edit_record == $inValue);
641 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', 1) . ' ]</option>';
642 } else {
643 $inValue = 'pages:' . $this->id;
644 $is_selected += intval($edit_record == $inValue);
645 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', 1) . ' ]</option>';
646 }
647 // Selecting all content elements from this language and allowed colPos:
648 $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');
649 $colPos = '';
650 $first = 1;
651 // Page is the pid if no record to put this after.
652 $prev = $this->id;
653 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
654 BackendUtility::workspaceOL('tt_content', $cRow);
655 if (is_array($cRow)) {
656 if ($first) {
657 if (!$edit_record) {
658 $edit_record = 'tt_content:' . $cRow['uid'];
659 }
660 $first = 0;
661 }
662 if (strcmp($cRow['colPos'], $colPos)) {
663 $colPos = $cRow['colPos'];
664 $opt[] = '<option value=""></option>';
665 $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), 1) . ':__</option>';
666 }
667 $inValue = 'tt_content:' . $cRow['uid'];
668 $is_selected += intval($edit_record == $inValue);
669 $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>';
670 $prev = -$cRow['uid'];
671 }
672 }
673 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
674 if (!$edit_record) {
675 $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
676 $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
677 $is_selected += intval($edit_record == $inValue);
678 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
679 }
680 // If none is yet selected...
681 if (!$is_selected) {
682 $opt[] = '<option value=""></option>';
683 $opt[] = '<option value="' . $edit_record . '" selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
684 }
685 // Splitting the edit-record cmd value into table/uid:
686 $this->eRParts = explode(':', $edit_record);
687 // Delete-button flag?
688 $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
689 // If undo-button should be rendered (depends on available items in sys_history)
690 $this->undoButton = 0;
691 $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');
692 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
693 $this->undoButton = 1;
694 }
695 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
696 $R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
697 $R_URL_getvars = GeneralUtility::_GET();
698 unset($R_URL_getvars['popView']);
699 unset($R_URL_getvars['new_unique_uid']);
700 $R_URL_getvars['edit_record'] = $edit_record;
701 $this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
702 // Setting close url/return url for exiting this script:
703 // Goes to 'Columns' view if close is pressed (default)
704 $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
705 if ($GLOBALS['BE_USER']->uc['condensedMode']) {
706 $this->closeUrl = $GLOBALS['BACK_PATH'] . 'alt_db_navframe.php';
707 }
708 if ($this->returnUrl) {
709 $this->closeUrl = $this->returnUrl;
710 }
711 // Return-url for JavaScript:
712 $retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
713 // Drawing the edit record selectbox
714 $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>';
715 // Creating editing form:
716 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)) {
717 // Splitting uid parts for special features, if new:
718 list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
719 // Convert $uidVal to workspace version if any:
720 if ($uidVal != 'new') {
721 if ($draftRecord = BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
722 $uidVal = $draftRecord['uid'];
723 }
724 }
725 // Initializing transfer-data object:
726 $trData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
727 $trData->addRawData = TRUE;
728 $trData->defVals[$this->eRParts[0]] = array(
729 'colPos' => intval($ex_colPos),
730 'sys_language_uid' => intval($this->current_sys_language)
731 );
732 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
733 $trData->lockRecords = 1;
734 // 'new'
735 $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
736 // Getting/Making the record:
737 reset($trData->regTableItems_data);
738 $rec = current($trData->regTableItems_data);
739 if ($uidVal == 'new') {
740 $new_unique_uid = uniqid('NEW');
741 $rec['uid'] = $new_unique_uid;
742 $rec['pid'] = intval($ex_pid) ? intval($ex_pid) : $this->id;
743 $recordAccess = TRUE;
744 } else {
745 $rec['uid'] = $uidVal;
746 // Checking internals access:
747 $recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
748 }
749 if (!$recordAccess) {
750 // If no edit access, print error message:
751 $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);
752 } elseif (is_array($rec)) {
753 // If the record is an array (which it will always be... :-)
754 // Create instance of TCEforms, setting defaults:
755 $tceforms = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
756 $tceforms->backPath = $GLOBALS['BACK_PATH'];
757 $tceforms->initDefaultBEMode();
758 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
759 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
760 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
761 $tceforms->enableClickMenu = TRUE;
762 // Clipboard is initialized:
763 // Start clipboard
764 $tceforms->clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
765 // Initialize - reads the clipboard content from the user session
766 $tceforms->clipObj->initializeClipboard();
767 // Render form, wrap it:
768 $panel = '';
769 $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
770 $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
771 // Add hidden fields:
772 $theCode = $panel;
773 if ($uidVal == 'new') {
774 $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
775 }
776 $theCode .= '
777 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
778 <input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
779 <input type="hidden" name="edit_record" value="' . $edit_record . '" />
780 <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)) . '" />
781 ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
782 // Add JavaScript as needed around the form:
783 $theCode = $tceforms->printNeededJSFunctions_top() . $theCode . $tceforms->printNeededJSFunctions();
784 // Add warning sign if record was "locked":
785 if ($lockInfo = BackendUtility::isRecordLocked($this->eRParts[0], $rec['uid'])) {
786 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
787 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
788 $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
789 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
790 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
791 $defaultFlashMessageQueue->enqueue($flashMessage);
792 }
793 // Add whole form as a document section:
794 $content .= $this->doc->section('', $theCode);
795 }
796 } else {
797 // If no edit access, print error message:
798 $content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />', 0, 1);
799 }
800 // Bottom controls (function menus):
801 $q_count = $this->getNumberOfHiddenElements();
802 $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', 1)) : $GLOBALS['LANG']->getLL('hiddenCE', 1) . ' (' . $q_count . ')') . '</label>';
803 $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', 1) . '</label>';
804 if (ExtensionManagementUtility::isLoaded('context_help')) {
805 $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', 1) . '</label>';
806 }
807 if ($GLOBALS['BE_USER']->isRTE()) {
808 $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', 1) . '</label>';
809 }
810 // Add the function menus to bottom:
811 $content .= $this->doc->section('', $h_func_b, 0, 0);
812 $content .= $this->doc->spacer(10);
813 // Select element matrix:
814 if ($this->eRParts[0] == 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
815 $posMap = GeneralUtility::makeInstance('ext_posMap');
816 $posMap->backPath = $GLOBALS['BACK_PATH'];
817 $posMap->cur_sys_language = $this->current_sys_language;
818 $HTMLcode = '';
819 // CSH:
820 $HTMLcode .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', $GLOBALS['BACK_PATH'], '|<br />');
821 $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
822 $content .= $this->doc->spacer(20);
823 $content .= $this->doc->section($GLOBALS['LANG']->getLL('CEonThisPage'), $HTMLcode, 0, 1);
824 $content .= $this->doc->spacer(20);
825 }
826 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
827 if (count($tceforms->commentMessages)) {
828 $content .= '
829 <!-- TCEFORM messages
830 ' . htmlspecialchars(implode(LF, $tceforms->commentMessages)) . '
831 -->
832 ';
833 }
834 return $content;
835 }
836
837 /**
838 * Rendering all other listings than QuickEdit
839 *
840 * @return void
841 * @todo Define visibility
842 */
843 public function renderListContent() {
844 // Initialize list object (see "class.db_layout.inc"):
845 /** @var $dblist \TYPO3\CMS\Backend\View\PageLayoutView */
846 $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView');
847 $dblist->backPath = $GLOBALS['BACK_PATH'];
848 $dblist->thumbs = $this->imagemode;
849 $dblist->no_noWrap = 1;
850 $dblist->descrTable = $this->descrTable;
851 $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
852 $dblist->script = 'db_layout.php';
853 $dblist->showIcon = 0;
854 $dblist->setLMargin = 0;
855 $dblist->doEdit = $this->EDIT_CONTENT;
856 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
857 $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
858 $dblist->id = $this->id;
859 $dblist->nextThree = MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
860 $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] === '0';
861 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
862 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
863 if (!$dblist->nextThree) {
864 $dblist->nextThree = 1;
865 }
866 $dblist->externalTables = $this->externalTables;
867 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
868 $h_menu = $dblist->getTableMenu($this->id);
869 // Initialize other variables:
870 $h_func = '';
871 $tableOutput = array();
872 $tableJSOutput = array();
873 $CMcounter = 0;
874 // Traverse the list of table names which has records on this page (that array is populated
875 // by the $dblist object during the function getTableMenu()):
876 foreach ($dblist->activeTables as $table => $value) {
877 if (!isset($dblist->externalTables[$table])) {
878 $q_count = $this->getNumberOfHiddenElements();
879 $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>';
880 // Boolean: Display up/down arrows and edit icons for tt_content records
881 $dblist->tt_contentConfig['showCommands'] = 1;
882 // Boolean: Display info-marks or not
883 $dblist->tt_contentConfig['showInfo'] = 1;
884 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown
885 // in the total width of the page
886 $dblist->tt_contentConfig['single'] = 0;
887 if ($this->MOD_SETTINGS['function'] == 4) {
888 // Grid view
889 $dblist->tt_contentConfig['showAsGrid'] = 1;
890 }
891 // Setting up the tt_content columns to show:
892 if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
893 $colList = array();
894 $tcaItems = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $this->id, $this);
895 foreach ($tcaItems as $temp) {
896 $colList[] = $temp[1];
897 }
898 } else {
899 // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
900 $colList = array('1', '0', '2', '3');
901 }
902 if (strcmp($this->colPosList, '')) {
903 $colList = array_intersect(GeneralUtility::intExplode(',', $this->colPosList), $colList);
904 }
905 // If only one column found, display the single-column view.
906 if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) {
907 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol']
908 // is shown in the total width of the page
909 $dblist->tt_contentConfig['single'] = 1;
910 // The column(s) to show if single mode (under each other)
911 $dblist->tt_contentConfig['showSingleCol'] = current($colList);
912 }
913 // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
914 $dblist->tt_contentConfig['cols'] = implode(',', $colList);
915 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
916 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
917 // If the function menu is set to "Language":
918 if ($this->MOD_SETTINGS['function'] == 2) {
919 $dblist->tt_contentConfig['single'] = 0;
920 $dblist->tt_contentConfig['languageMode'] = 1;
921 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
922 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
923 }
924 } else {
925 if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
926 $h_func = BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
927 } else {
928 $h_func = '';
929 }
930 }
931 // Start the dblist object:
932 $dblist->itemsLimitSingleTable = 1000;
933 $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
934 $dblist->counter = $CMcounter;
935 $dblist->ext_function = $this->MOD_SETTINGS['function'];
936 // Render versioning selector:
937 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
938 // Generate the list of elements here:
939 $dblist->generateList();
940 // Adding the list content to the tableOutput variable:
941 $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 : '');
942 // ... and any accumulated JavaScript goes the same way!
943 $tableJSOutput[$table] = $dblist->JScode;
944 // Increase global counter:
945 $CMcounter += $dblist->counter;
946 // Reset variables after operation:
947 $dblist->HTMLcode = '';
948 $dblist->JScode = '';
949 $h_func = '';
950 $h_func_b = '';
951 }
952 // END: traverse tables
953 // For Context Sensitive Menus:
954 $this->doc->getContextMenuCode();
955 // Add the content for each table we have rendered (traversing $tableOutput variable)
956 foreach ($tableOutput as $table => $output) {
957 $content .= $this->doc->section('', $output, TRUE, TRUE, 0, TRUE);
958 $content .= $this->doc->spacer(15);
959 $content .= $this->doc->sectionEnd();
960 }
961 // Making search form:
962 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
963 $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
964 $content .= $this->doc->section($sectionTitle, $dblist->getSearchBox(0), FALSE, TRUE, FALSE, TRUE);
965 }
966 // Additional footer content
967 $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'];
968 if (is_array($footerContentHook)) {
969 foreach ($footerContentHook as $hook) {
970 $params = array();
971 $content .= GeneralUtility::callUserFunction($hook, $params, $this);
972 }
973 }
974 return $content;
975 }
976
977 /**
978 * Print accumulated content of module
979 *
980 * @return void
981 * @todo Define visibility
982 */
983 public function printContent() {
984 echo $this->content;
985 }
986
987 /***************************
988 *
989 * Sub-content functions, rendering specific parts of the module content.
990 *
991 ***************************/
992 /**
993 * Create the panel of buttons for submitting the form or otherwise perform operations.
994 *
995 * @param string $function Identifier for function of module
996 * @return array all available buttons as an assoc. array
997 */
998 protected function getButtons($function = '') {
999 $buttons = array(
1000 'view' => '',
1001 'history_page' => '',
1002 'new_content' => '',
1003 'move_page' => '',
1004 'move_record' => '',
1005 'new_page' => '',
1006 'edit_page' => '',
1007 'csh' => '',
1008 'shortcut' => '',
1009 'cache' => '',
1010 'savedok' => '',
1011 'save_close' => '',
1012 'savedokshow' => '',
1013 'closedok' => '',
1014 'deletedok' => '',
1015 'undo' => '',
1016 'history_record' => ''
1017 );
1018 // View page
1019 $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>';
1020 // Shortcut
1021 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1022 $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']);
1023 }
1024 // Cache
1025 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1026 $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>';
1027 }
1028 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1029 // Move record
1030 if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
1031 $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')), 1))) . '</a>';
1032 }
1033 // Edit page properties
1034 if ($this->CALC_PERMS & 2) {
1035 $params = '&edit[pages][' . $this->id . ']=edit';
1036 $buttons['edit_page'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '" title="' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . '">' . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
1037 }
1038 // Add CSH (Context Sensitive Help) icon to tool bar
1039 if ($function == 'quickEdit') {
1040 $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'quickEdit', $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1041 } else {
1042 $buttons['csh'] = BackendUtility::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1043 }
1044 if ($function == 'quickEdit') {
1045 // Save record
1046 $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) . '" />'));
1047 // Save and close
1048 $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', 1) . '" />'));
1049 // Save record and show page
1050 $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>';
1051 // Close record
1052 $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>';
1053 // Delete record
1054 if ($this->deleteButton) {
1055 $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>';
1056 }
1057 if ($this->undoButton) {
1058 // Undo button
1059 $buttons['undo'] = '<a href="#"
1060 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;')) . '"
1061 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>';
1062 // History button
1063 $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>';
1064 }
1065 }
1066 }
1067 return $buttons;
1068 }
1069
1070 /*******************************
1071 *
1072 * Other functions
1073 *
1074 ******************************/
1075 /**
1076 * Returns the number of hidden elements (including those hidden by start/end times)
1077 * on the current page (for the current sys_language)
1078 *
1079 * @return void
1080 * @todo Define visibility
1081 */
1082 public function getNumberOfHiddenElements() {
1083 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1084 'uid',
1085 'tt_content',
1086 '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')
1087 );
1088 }
1089
1090 /**
1091 * Returns URL to the current script.
1092 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1093 *
1094 * @param array $params Parameters array, merged with global GET vars.
1095 * @return string URL
1096 * @todo Define visibility
1097 */
1098 public function local_linkThisScript($params) {
1099 $params['popView'] = '';
1100 $params['new_unique_uid'] = '';
1101 return GeneralUtility::linkThisScript($params);
1102 }
1103
1104 /**
1105 * Returns a SQL query for selecting sys_language records.
1106 *
1107 * @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)
1108 * @return string Return query string.
1109 * @todo Define visibility
1110 */
1111 public function exec_languageQuery($id) {
1112 if ($id) {
1113 $exQ = BackendUtility::deleteClause('pages_language_overlay') .
1114 ($GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0');
1115 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1116 'sys_language.*',
1117 'pages_language_overlay,sys_language',
1118 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . intval($id) . $exQ .
1119 BackendUtility::versioningPlaceholderClause('pages_language_overlay'),
1120 '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',
1121 'sys_language.title'
1122 );
1123 } else {
1124 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1125 'sys_language.*',
1126 'sys_language',
1127 'sys_language.hidden=0',
1128 '',
1129 'sys_language.title'
1130 );
1131 }
1132 }
1133
1134 }
1135
1136 ?>