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