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