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