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