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