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