Fixed bug #14733: Improvements to Backend skin (Thanks to Steffen Gebert)
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / db_layout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 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" ' .
430 'src="' . t3lib_div::createVersionNumberedFilename($BACK_PATH . '../t3lib/jsfunc.updateform.js') . '">' .
431 '</script>';
432 $this->doc->JScode.= $this->doc->wrapScriptTags('
433 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
434 if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages'.intval($this->id).'_"+top.fsMod.currentBank; '.intval($this->id).';
435 function jumpToUrl(URL,formEl) { //
436 if (document.editform && TBE_EDITOR.isFormChanged) { // Check if the function exists... (works in all browsers?)
437 if (!TBE_EDITOR.isFormChanged()) { //
438 window.location.href = URL;
439 } else if (formEl) {
440 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
441 }
442 } else window.location.href = URL;
443 }
444 '.($this->popView ? t3lib_BEfunc::viewOnClick($this->id,$BACK_PATH,t3lib_BEfunc::BEgetRootLine($this->id)) : '').'
445
446 function deleteRecord(table,id,url) { //
447 if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {
448 window.location.href = "'.$BACK_PATH.'tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
449 }
450 return false;
451 }
452 ');
453 $this->doc->JScode.= $this->doc->wrapScriptTags('
454 var DTM_array = new Array();
455 var DTM_origClass = new String();
456
457 // if tabs are used in a popup window the array might not exists
458 if(!top.DTM_currentTabs) {
459 top.DTM_currentTabs = new Array();
460 }
461
462 function DTM_activate(idBase,index,doToogle) { //
463 // Hiding all:
464 if (DTM_array[idBase]) {
465 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
466 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
467 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
468 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
469 }
470 }
471 }
472
473 // Showing one:
474 if (document.getElementById(idBase+"-"+index+"-DIV")) {
475 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
476 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
477 if(DTM_origClass=="") {
478 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
479 } else {
480 DTM_origClass = "tab";
481 }
482 top.DTM_currentTabs[idBase] = -1;
483 } else {
484 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
485 if(DTM_origClass=="") {
486 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
487 } else {
488 DTM_origClass = "tabact";
489 }
490 top.DTM_currentTabs[idBase] = index;
491 }
492 }
493 }
494 function DTM_toggle(idBase,index,isInit) { //
495 // Showing one:
496 if (document.getElementById(idBase+"-"+index+"-DIV")) {
497 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
498 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
499 if(isInit) {
500 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
501 } else {
502 DTM_origClass = "tab";
503 }
504 top.DTM_currentTabs[idBase+"-"+index] = 0;
505 } else {
506 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
507 if(isInit) {
508 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
509 } else {
510 DTM_origClass = "tabact";
511 }
512 top.DTM_currentTabs[idBase+"-"+index] = 1;
513 }
514 }
515 }
516
517 function DTM_mouseOver(obj) { //
518 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
519 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
520 }
521
522 function DTM_mouseOut(obj) { //
523 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
524 DTM_origClass = "";
525 }
526 ');
527
528 // Setting doc-header
529 $this->doc->form='<form action="'.htmlspecialchars('db_layout.php?id='.$this->id.'&imagemode='.$this->imagemode).'" method="post">';
530
531 // Creating the top function menu:
532 $this->topFuncMenu = t3lib_BEfunc::getFuncMenu($this->id,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'],'db_layout.php','');
533 $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','') : '');
534
535 // Find columns
536 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->id,'mod.SHARED'); // SHARED page-TSconfig settings.
537 $this->colPosList = strcmp(trim($this->modTSconfig['properties']['tt_content.']['colPos_list']),'') ? trim($this->modTSconfig['properties']['tt_content.']['colPos_list']) : $modTSconfig_SHARED['properties']['colPos_list'];
538 $this->colPosList = strcmp($this->colPosList,'')?$this->colPosList:'1,0,2,3';
539 $this->colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$this->colPosList))); // Removing duplicates, if any
540
541
542 // Render the primary module content:
543 if ($this->MOD_SETTINGS['function']==0) {
544 $body = $this->renderQuickEdit(); // QuickEdit
545 } else {
546 $body = $this->renderListContent(); // All other listings
547 }
548
549
550 if ($this->pageinfo['content_from_pid']) {
551 //$contentPage = t3lib_BEfunc::getRecord('pages', intval($this->pageinfo['content_from_pid']));
552 $title = t3lib_BEfunc::getRecordTitle('pages', $contentPage);
553 $linkToPid = $this->local_linkThisScript(array('id' => $this->pageinfo['content_from_pid']));
554 $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . intval($this->pageinfo['content_from_pid']) . ')</a>';
555 $flashMessage = t3lib_div::makeInstance(
556 't3lib_FlashMessage',
557 '',
558 sprintf($GLOBALS['LANG']->getLL('content_from_pid_title'), $link),
559 t3lib_FlashMessage::INFO
560 );
561 $body = $flashMessage->render() . $body;
562 }
563
564 // Setting up the buttons and markers for docheader
565 $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function']==0 ? 'quickEdit' : '');
566 $markers = array(
567 'CSH' => $docHeaderButtons['csh'],
568 'TOP_FUNCTION_MENU' => $this->editSelect . $this->topFuncMenu,
569 'LANGSELECTOR' => $this->languageMenu,
570 'CONTENT' => $body
571 );
572
573 // Build the <body> for the module
574 $this->content = $this->doc->startPage($LANG->getLL('title'));
575 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
576 $this->content.= $this->doc->endPage();
577 $this->content = $this->doc->insertStylesAndJS($this->content);
578
579 } else {
580
581 // If no access or id value, create empty document:
582 $this->doc = t3lib_div::makeInstance('template');
583 $this->doc->backPath = $BACK_PATH;
584 $this->doc->setModuleTemplate('templates/db_layout.html');
585
586 $this->doc->JScode = $this->doc->wrapScriptTags('
587 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
588 ');
589
590 $flashMessage = t3lib_div::makeInstance(
591 't3lib_FlashMessage',
592 $LANG->getLL('clickAPage_content'),
593 $LANG->getLL('clickAPage_header'),
594 t3lib_FlashMessage::INFO
595 );
596 $body = $flashMessage->render();
597
598 // Setting up the buttons and markers for docheader
599 $docHeaderButtons = array(
600 'view' => '',
601 'history_page' => '',
602 'new_content' => '',
603 'move_page' => '',
604 'move_record' => '',
605 'new_page' => '',
606 'edit_page' => '',
607 'record_list' => '',
608 'csh' => '',
609 'shortcut' => '',
610 'cache' => '',
611 'savedok' => '',
612 'savedokshow' => '',
613 'closedok' => '',
614 'deletedok' => '',
615 'undo' => '',
616 'history_record' => ''
617 );
618
619 $markers = array(
620 'CSH' => t3lib_BEfunc::cshItem($this->descrTable, '', $BACK_PATH, '', TRUE),
621 'TOP_FUNCTION_MENU' => '',
622 'LANGSELECTOR' => '',
623 'CONTENT' => $body
624 );
625
626 $this->content=$this->doc->startPage($LANG->getLL('title'));
627 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
628 $this->content.=$this->doc->endPage();
629 $this->content = $this->doc->insertStylesAndJS($this->content);
630 }
631 }
632
633 /**
634 * Rendering the quick-edit view.
635 *
636 * @return void
637 */
638 function renderQuickEdit() {
639 global $LANG,$BE_USER,$BACK_PATH;
640 // Alternative template
641 $this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
642
643 // Alternative form tag; Quick Edit submits its content to tce_db.php.
644 $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);">';
645
646 // Setting up the context sensitive menu:
647 $this->doc->getContextMenuCode();
648
649 // Set the edit_record value for internal use in this function:
650 $edit_record = $this->edit_record;
651
652 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
653 if (substr($edit_record,0,9)=='_EDIT_COL') {
654 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
655 '*',
656 'tt_content',
657 'pid='.intval($this->id).' AND colPos='.intval(substr($edit_record,10)).' AND sys_language_uid='.intval($this->current_sys_language).
658 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
659 t3lib_BEfunc::deleteClause('tt_content').
660 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
661 '',
662 'sorting'
663 );
664 $idListA = array();
665 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
666 $idListA[] = $cRow['uid'];
667 }
668
669 $url = $BACK_PATH.'alt_doc.php?edit[tt_content]['.implode(',',$idListA).']=edit&returnUrl='.rawurlencode($this->local_linkThisScript(array('edit_record'=>'')));
670 t3lib_utility_Http::redirect($url);
671 }
672
673 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
674 if ($this->new_unique_uid) {
675 $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'));
676 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
677 if (is_array($sys_log_row)) {
678 $edit_record=$sys_log_row['tablename'].':'.$sys_log_row['recuid'];
679 }
680 }
681
682
683 // Creating the selector box, allowing the user to select which element to edit:
684 $opt=array();
685 $is_selected=0;
686 $languageOverlayRecord='';
687 if ($this->current_sys_language) {
688 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$this->id,'AND sys_language_uid='.intval($this->current_sys_language));
689 }
690 if (is_array($languageOverlayRecord)) {
691 $inValue = 'pages_language_overlay:'.$languageOverlayRecord['uid'];
692 $is_selected+=intval($edit_record==$inValue);
693 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('editLanguageHeader',1).' ]</option>';
694 } else {
695 $inValue = 'pages:'.$this->id;
696 $is_selected+=intval($edit_record==$inValue);
697 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('editPageProperties',1).' ]</option>';
698 }
699
700 // Selecting all content elements from this language and allowed colPos:
701 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
702 '*',
703 'tt_content',
704 'pid='.intval($this->id).' AND sys_language_uid='.intval($this->current_sys_language).' AND colPos IN ('.$this->colPosList.')'.
705 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
706 t3lib_Befunc::deleteClause('tt_content').
707 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
708 '',
709 'colPos,sorting'
710 );
711 $colPos='';
712 $first=1;
713 $prev=$this->id; // Page is the pid if no record to put this after.
714 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
715 t3lib_BEfunc::workspaceOL('tt_content', $cRow);
716
717 if (is_array($cRow)) {
718 if ($first) {
719 if (!$edit_record) {
720 $edit_record='tt_content:'.$cRow['uid'];
721 }
722 $first = 0;
723 }
724 if (strcmp($cRow['colPos'],$colPos)) {
725 $colPos=$cRow['colPos'];
726 $opt[]='<option value=""></option>';
727 $opt[]='<option value="_EDIT_COL:'.$colPos.'">__'.$LANG->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','colPos',$colPos),1).':__</option>';
728 }
729 $inValue = 'tt_content:'.$cRow['uid'];
730 $is_selected+=intval($edit_record==$inValue);
731 $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>';
732 $prev=-$cRow['uid'];
733 }
734 }
735
736 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
737 if (!$edit_record) {
738 $edit_record='tt_content:new/'.$prev.'/'.$colPos;
739
740 $inValue = 'tt_content:new/'.$prev.'/'.$colPos;
741 $is_selected+=intval($edit_record==$inValue);
742 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('newLabel',1).' ]</option>';
743 }
744
745 // If none is yet selected...
746 if (!$is_selected) {
747 $opt[]='<option value=""></option>';
748 $opt[]='<option value="'.$edit_record.'" selected="selected">[ '.$LANG->getLL('newLabel',1).' ]</option>';
749 }
750
751
752 // Splitting the edit-record cmd value into table/uid:
753 $this->eRParts = explode(':',$edit_record);
754
755
756
757 // Delete-button flag?
758 $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))));
759
760 // If undo-button should be rendered (depends on available items in sys_history)
761 $this->undoButton=0;
762 $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');
763 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
764 $this->undoButton=1;
765 }
766
767 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
768 $R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
769 $R_URL_getvars = t3lib_div::_GET();
770
771 unset($R_URL_getvars['popView']);
772 unset($R_URL_getvars['new_unique_uid']);
773 $R_URL_getvars['edit_record']=$edit_record;
774 $this->R_URI = $R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$R_URL_getvars);
775
776 // Setting close url/return url for exiting this script:
777 $this->closeUrl = $this->local_linkThisScript(array('SET'=>array('function'=>1))); // Goes to 'Columns' view if close is pressed (default)
778
779 if ($BE_USER->uc['condensedMode']) {
780 $this->closeUrl = $BACK_PATH.'alt_db_navframe.php';
781 }
782 if ($this->returnUrl) {
783 $this->closeUrl = $this->returnUrl;
784 }
785 // Return-url for JavaScript:
786 $retUrlStr = $this->returnUrl?"+'&returnUrl='+'".rawurlencode($this->returnUrl)."'":'';
787
788 // Drawing the edit record selectbox
789 $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>';
790
791 // Creating editing form:
792 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)))) {
793
794 // Splitting uid parts for special features, if new:
795 list($uidVal,$ex_pid,$ex_colPos) = explode('/',$this->eRParts[1]);
796
797 // Convert $uidVal to workspace version if any:
798 if ($uidVal!='new') {
799 if ($draftRecord = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
800 $uidVal = $draftRecord['uid'];
801 }
802 }
803
804 // Initializing transfer-data object:
805 $trData = t3lib_div::makeInstance('t3lib_transferData');
806 $trData->addRawData = TRUE;
807 $trData->defVals[$this->eRParts[0]] = array (
808 'colPos' => intval($ex_colPos),
809 'sys_language_uid' => intval($this->current_sys_language)
810 );
811 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
812 $trData->lockRecords=1;
813 $trData->fetchRecord($this->eRParts[0],($uidVal=='new'?$this->id:$uidVal),$uidVal); // 'new'
814
815 // Getting/Making the record:
816 reset($trData->regTableItems_data);
817 $rec = current($trData->regTableItems_data);
818 if ($uidVal=='new') {
819 $new_unique_uid = uniqid('NEW');
820 $rec['uid'] = $new_unique_uid;
821 $rec['pid'] = intval($ex_pid)?intval($ex_pid):$this->id;
822 $recordAccess = TRUE;
823 } else {
824 $rec['uid'] = $uidVal;
825
826 // Checking internals access:
827 $recordAccess = $BE_USER->recordEditAccessInternals($this->eRParts[0],$uidVal);
828 }
829
830 if (!$recordAccess) {
831 // If no edit access, print error message:
832 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />'.
833 ($BE_USER->errorMsg ? 'Reason: ' . $BE_USER->errorMsg . '<br /><br />' : ''), 0, 1);
834 } elseif (is_array($rec)) { // If the record is an array (which it will always be... :-)
835
836 // Create instance of TCEforms, setting defaults:
837 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
838 $tceforms->backPath = $BACK_PATH;
839 $tceforms->initDefaultBEMode();
840 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
841 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
842 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
843 $tceforms->enableClickMenu = TRUE;
844
845 // Clipboard is initialized:
846 $tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
847 $tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
848
849
850 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $tceforms->edit_showFieldHelp='text';
851
852 // Render form, wrap it:
853 $panel='';
854 $panel.=$tceforms->getMainFields($this->eRParts[0],$rec);
855 $panel=$tceforms->wrapTotal($panel,$rec,$this->eRParts[0]);
856
857 // Add hidden fields:
858 $theCode=$panel;
859 if ($uidVal=='new') {
860 $theCode.='<input type="hidden" name="data['.$this->eRParts[0].']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
861 }
862 $theCode.='
863 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />
864 <input type="hidden" name="_disableRTE" value="'.$tceforms->disableRTE.'" />
865 <input type="hidden" name="edit_record" value="'.$edit_record.'" />
866 <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 ).'" />
867 ';
868
869 // Add JavaScript as needed around the form:
870 $theCode=$tceforms->printNeededJSFunctions_top().$theCode.$tceforms->printNeededJSFunctions();
871
872 // Add warning sign if record was "locked":
873 if ($lockInfo = t3lib_BEfunc::isRecordLocked($this->eRParts[0], $rec['uid'])) {
874 $lockedMessage = t3lib_div::makeInstance(
875 't3lib_FlashMessage',
876 htmlspecialchars($lockInfo['msg']),
877 '',
878 t3lib_FlashMessage::WARNING
879 );
880 t3lib_FlashMessageQueue::addMessage($lockedMessage);
881 }
882
883 // Add whole form as a document section:
884 $content .= $this->doc->section('', $theCode);
885 }
886 } else {
887 // If no edit access, print error message:
888 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />',0,1);
889 }
890
891
892 // Bottom controls (function menus):
893 $q_count = $this->getNumberOfHiddenElements();
894 $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"').
895 '<label for="checkTt_content_showHidden">'.(!$q_count?$GLOBALS['TBE_TEMPLATE']->dfw($LANG->getLL('hiddenCE',1)):$LANG->getLL('hiddenCE',1).' ('.$q_count.')').'</label>';
896
897 $h_func_b.= '<br />'.
898 t3lib_BEfunc::getFuncCheck($this->id,'SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'db_layout.php','','id="checkShowPalettes"').
899 '<label for="checkShowPalettes">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1).'</label>';
900
901 if (t3lib_extMgm::isLoaded('context_help') && $BE_USER->uc['edit_showFieldHelp']!='text') {
902 $h_func_b.= '<br />'.
903 t3lib_BEfunc::getFuncCheck($this->id,'SET[showDescriptions]',$this->MOD_SETTINGS['showDescriptions'],'db_layout.php','','id="checkShowDescriptions"').
904 '<label for="checkShowDescriptions">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1).'</label>';
905 }
906
907 if ($BE_USER->isRTE()) {
908 $h_func_b.= '<br />'.
909 t3lib_BEfunc::getFuncCheck($this->id,'SET[disableRTE]',$this->MOD_SETTINGS['disableRTE'],'db_layout.php','','id="checkDisableRTE"').
910 '<label for="checkDisableRTE">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1).'</label>';
911 }
912
913 // Add the function menus to bottom:
914 $content.=$this->doc->section('',$h_func_b,0,0);
915 $content.=$this->doc->spacer(10);
916
917
918 // Select element matrix:
919 if ($this->eRParts[0]=='tt_content' && t3lib_div::testInt($this->eRParts[1])) {
920 $posMap = t3lib_div::makeInstance('ext_posMap');
921 $posMap->backPath = $BACK_PATH;
922 $posMap->cur_sys_language=$this->current_sys_language;
923
924 $HTMLcode = '';
925
926 // CSH:
927 $HTMLcode.= t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit_selElement', $BACK_PATH, '|<br />');
928
929 $HTMLcode.=$posMap->printContentElementColumns($this->id,$this->eRParts[1],$this->colPosList,$this->MOD_SETTINGS['tt_content_showHidden'],$this->R_URI);
930
931 $content.=$this->doc->spacer(20);
932 $content.=$this->doc->section($LANG->getLL('CEonThisPage'),$HTMLcode,0,1);
933 $content.=$this->doc->spacer(20);
934 }
935
936 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
937 if (count($tceforms->commentMessages)) {
938 $content.='
939 <!-- TCEFORM messages
940 '.htmlspecialchars(implode(LF,$tceforms->commentMessages)).'
941 -->
942 ';
943 }
944 return $content;
945 }
946
947 /**
948 * Rendering all other listings than QuickEdit
949 *
950 * @return void
951 */
952 function renderListContent() {
953 global $LANG,$BACK_PATH,$TCA;
954
955 // Initialize list object (see "class.db_layout.inc"):
956 $dblist = t3lib_div::makeInstance('tx_cms_layout');
957 $dblist->backPath = $BACK_PATH;
958 $dblist->thumbs = $this->imagemode;
959 $dblist->no_noWrap = 1;
960 $dblist->descrTable = $this->descrTable;
961
962 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
963 $dblist->script = 'db_layout.php';
964 $dblist->showIcon = 0;
965 $dblist->setLMargin=0;
966 $dblist->doEdit = $this->EDIT_CONTENT;
967 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
968
969 $dblist->agePrefixes = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
970 $dblist->id = $this->id;
971 $dblist->nextThree = t3lib_div::intInRange($this->modTSconfig['properties']['editFieldsAtATime'],0,10);
972 $dblist->option_showBigButtons = ($this->modTSconfig['properties']['disableBigButtons'] === '0');
973 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
974 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
975 if (!$dblist->nextThree) $dblist->nextThree = 1;
976
977 $dblist->externalTables = $this->externalTables;
978
979 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
980 $h_menu = $dblist->getTableMenu($this->id);
981
982 // Initialize other variables:
983 $h_func='';
984 $tableOutput=array();
985 $tableJSOutput=array();
986 $CMcounter = 0;
987
988 // Traverse the list of table names which has records on this page (that array is populated by the $dblist object during the function getTableMenu()):
989 foreach ($dblist->activeTables as $table => $value) {
990
991 // Load full table definitions:
992 t3lib_div::loadTCA($table);
993
994 if (!isset($dblist->externalTables[$table])) {
995 // Creating special conditions for each table:
996 switch($table) {
997 case 'tt_board':
998 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_board]',$this->MOD_SETTINGS['tt_board'],$this->MOD_MENU['tt_board'],'db_layout.php','');
999 break;
1000 case 'tt_address':
1001 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_address]',$this->MOD_SETTINGS['tt_address'],$this->MOD_MENU['tt_address'],'db_layout.php','');
1002 break;
1003 case 'tt_links':
1004 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_links]',$this->MOD_SETTINGS['tt_links'],$this->MOD_MENU['tt_links'],'db_layout.php','');
1005 break;
1006 case 'tt_calender':
1007 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_calender]',$this->MOD_SETTINGS['tt_calender'],$this->MOD_MENU['tt_calender'],'db_layout.php','');
1008 break;
1009 case 'tt_products':
1010 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_products]',$this->MOD_SETTINGS['tt_products'],$this->MOD_MENU['tt_products'],'db_layout.php','');
1011 break;
1012 case 'tt_guest':
1013 case 'tt_news':
1014 case 'fe_users':
1015 // Nothing
1016 break;
1017 case 'tt_content':
1018 $q_count = $this->getNumberOfHiddenElements();
1019 $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>';
1020
1021 $dblist->tt_contentConfig['showCommands'] = 1; // Boolean: Display up/down arrows and edit icons for tt_content records
1022 $dblist->tt_contentConfig['showInfo'] = 1; // Boolean: Display info-marks or not
1023 $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
1024
1025 // Setting up the tt_content columns to show:
1026 if (is_array($TCA['tt_content']['columns']['colPos']['config']['items'])) {
1027 $colList = array();
1028 foreach($TCA['tt_content']['columns']['colPos']['config']['items'] as $temp) {
1029 $colList[] = $temp[1];
1030 }
1031 } else { // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
1032 $colList = array('1','0','2','3');
1033 }
1034 if (strcmp($this->colPosList,'')) {
1035 $colList = array_intersect(t3lib_div::intExplode(',',$this->colPosList),$colList);
1036 }
1037
1038 // If only one column found, display the single-column view.
1039 if (count($colList)==1) {
1040 $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
1041 $dblist->tt_contentConfig['showSingleCol'] = current($colList); // The column(s) to show if single mode (under each other)
1042 }
1043 $dblist->tt_contentConfig['cols'] = implode(',',$colList); // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
1044 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
1045 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
1046
1047 // If the function menu is set to "Language":
1048 if ($this->MOD_SETTINGS['function']==2) {
1049 $dblist->tt_contentConfig['single'] = 0;
1050 $dblist->tt_contentConfig['languageMode'] = 1;
1051 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
1052 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
1053 }
1054 break;
1055 }
1056 } else {
1057 if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
1058 $h_func = t3lib_BEfunc::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
1059 } else {
1060 $h_func = '';
1061 }
1062 }
1063
1064 // Start the dblist object:
1065 $dblist->itemsLimitSingleTable = 1000;
1066 $dblist->start($this->id,$table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
1067 $dblist->counter = $CMcounter;
1068 $dblist->ext_function = $this->MOD_SETTINGS['function'];
1069
1070 // Render versioning selector:
1071 $dblist->HTMLcode.= $this->doc->getVersionSelector($this->id);
1072
1073 // Generate the list of elements here:
1074 $dblist->generateList();
1075
1076 // Adding the list content to the tableOutput variable:
1077 $tableOutput[$table]=
1078 ($h_func?$h_func.'<br /><img src="clear.gif" width="1" height="4" alt="" /><br />':'').
1079 $dblist->HTMLcode.
1080 ($h_func_b?'<img src="clear.gif" width="1" height="10" alt="" /><br />'.$h_func_b:'');
1081
1082 // ... and any accumulated JavaScript goes the same way!
1083 $tableJSOutput[$table] = $dblist->JScode;
1084
1085 // Increase global counter:
1086 $CMcounter+= $dblist->counter;
1087
1088 // Reset variables after operation:
1089 $dblist->HTMLcode='';
1090 $dblist->JScode='';
1091 $h_func = '';
1092 $h_func_b = '';
1093 } // END: traverse tables
1094
1095
1096 // For Context Sensitive Menus:
1097 $this->doc->getContextMenuCode();
1098
1099 // Now, create listing based on which element is selected in the function menu:
1100
1101 if ($this->MOD_SETTINGS['function']==3) {
1102
1103 // Making page info:
1104 $content.=$this->doc->spacer(10);
1105 $content.=$this->doc->section($LANG->getLL('pageInformation'),$dblist->getPageInfoBox($this->pageinfo,$this->CALC_PERMS&2),0,1);
1106 } else {
1107
1108 // Add the content for each table we have rendered (traversing $tableOutput variable)
1109 foreach($tableOutput as $table => $output) {
1110 $content.=$this->doc->section('<a name="'.$table.'"></a>'.$dblist->activeTables[$table],$output,TRUE,TRUE,0,TRUE);
1111 $content.=$this->doc->spacer(15);
1112 $content.=$this->doc->sectionEnd();
1113 }
1114
1115 // Making search form:
1116 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
1117 $content.=$this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:labels.search'),$dblist->getSearchBox(),0,1);
1118 }
1119
1120 // Making display of Sys-notes (from extension "sys_note")
1121 $dblist->id=$this->id;
1122 $sysNotes = $dblist->showSysNotesForPage();
1123 if ($sysNotes) {
1124 $content.=$this->doc->spacer(10);
1125 $content.=$this->doc->section($LANG->getLL('internalNotes'),$sysNotes,0,1);
1126 }
1127
1128 // Add spacer in bottom of page:
1129 $content.=$this->doc->spacer(10);
1130 }
1131
1132 // Ending page:
1133 $content.=$this->doc->spacer(10);
1134
1135 return $content;
1136 }
1137
1138 /**
1139 * Print accumulated content of module
1140 *
1141 * @return void
1142 */
1143 function printContent() {
1144 echo $this->content;
1145 }
1146
1147 /***************************
1148 *
1149 * Sub-content functions, rendering specific parts of the module content.
1150 *
1151 ***************************/
1152
1153 /**
1154 * Create the panel of buttons for submitting the form or otherwise perform operations.
1155 *
1156 * @param string Identifier for function of module
1157 * @return array all available buttons as an assoc. array
1158 */
1159 protected function getButtons($function = '') {
1160 global $TCA, $LANG, $BACK_PATH, $BE_USER;
1161
1162 $buttons = array(
1163 'view' => '',
1164 'history_page' => '',
1165 'new_content' => '',
1166 'move_page' => '',
1167 'move_record' => '',
1168 'new_page' => '',
1169 'edit_page' => '',
1170 'record_list' => '',
1171 'csh' => '',
1172 'shortcut' => '',
1173 'cache' => '',
1174 'savedok' => '',
1175 'savedokshow' => '',
1176 'closedok' => '',
1177 'deletedok' => '',
1178 'undo' => '',
1179 'history_record' => ''
1180 );
1181
1182 // View page
1183 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
1184 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1185 '</a>';
1186
1187 // Shortcut
1188 if ($BE_USER->mayMakeShortcut()) {
1189 $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']);
1190 }
1191
1192 // Cache
1193 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1194 $buttons['cache'] = '<a href="' . htmlspecialchars('db_layout.php?id=' . $this->pageinfo['uid'] . '&clear_cache=1') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', TRUE) . '">' .
1195 t3lib_iconWorks::getSpriteIcon('actions-system-cache-clear') .
1196 '</a>';
1197 }
1198
1199 // If access to Web>List for user, then link to that module.
1200 if ($BE_USER->check('modules','web_list')) {
1201 $href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1202 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', TRUE) . '">' .
1203 t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
1204 '</a>';
1205 }
1206
1207 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1208
1209 // Page history
1210 $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;') . '" title="' . $LANG->getLL('recordHistory', TRUE) . '">' .
1211 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1212 '</a>';
1213 // New content element
1214 $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'))) . '" title="' . $LANG->getLL('newContentElement', TRUE) . '">' .
1215 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
1216 '</a>';
1217 // Move page
1218 $buttons['move_page'] = '<a href="' . htmlspecialchars($BACK_PATH . 'move_el.php?table=pages&uid=' . $this->id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '" title="' . $LANG->getLL('move_page', TRUE) . '">' .
1219 t3lib_iconWorks::getSpriteIcon('actions-page-move') .
1220 '</a>';
1221 // Move record
1222 if (t3lib_div::testInt($this->eRParts[1])) {
1223 $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'))) . '">' .
1224 t3lib_iconWorks::getSpriteIcon('actions-' . ($this->eRParts[0] == 'tt_content' ? 'document' : 'page') . '-move',array('class'=>'c-inputButton','title' => $LANG->getLL('move_' . ($this->eRParts[0] == 'tt_content' ? 'record' : 'page'), 1))) .
1225 '</a>';
1226 }
1227 // Create new page (wizard)
1228 $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;') . '" title="' . $LANG->getLL('newPage', TRUE) . '">' .
1229 t3lib_iconWorks::getSpriteIcon('actions-page-new') .
1230 '</a>';
1231 // Edit page properties
1232 if ($this->CALC_PERMS&2) {
1233 $params='&edit[pages][' . $this->id . ']=edit';
1234 $buttons['edit_page'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $BACK_PATH)) . '" title="' . $LANG->getLL('editPageProperties', TRUE) . '">' .
1235 t3lib_iconWorks::getSpriteIcon('actions-page-open') .
1236 '</a>';
1237 }
1238
1239 // Add CSH (Context Sensitive Help) icon to tool bar
1240 if($function == 'quickEdit') {
1241 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit', $BACK_PATH, '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1242 } else {
1243 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $BACK_PATH, '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1244 }
1245
1246 if($function == 'quickEdit') {
1247 // Save record
1248 $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="" />';
1249
1250 // Save record and show page
1251 $buttons['savedokshow'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow', TRUE) . '">' .
1252 t3lib_iconWorks::getSpriteIcon('actions-document-save-view') .
1253 '</a>';
1254
1255 // Close record
1256 $buttons['closedok'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode($this->closeUrl) . '\')); return false;') . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', TRUE) . '">' .
1257 t3lib_iconWorks::getSpriteIcon('actions-document-close') .
1258 '</a>';
1259
1260 // Delete record
1261 if($this->deleteButton) {
1262 $buttons['deletedok'] = '<a href="#" onclick="' . htmlspecialchars('return deleteRecord(\'' . $this->eRParts[0] . '\',\'' . $this->eRParts[1] . '\',\'' . t3lib_div::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id . '\');') . '" title="' . $LANG->getLL('deleteItem', TRUE) . '">' .
1263 t3lib_iconWorks::getSpriteIcon('actions-document-delete') .
1264 '</a>';
1265 }
1266
1267 if($this->undoButton) {
1268 // Undo button
1269 $buttons['undo'] = '<a href="#"
1270 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;') . '"
1271 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')))) . '">' .
1272 t3lib_iconWorks::getSpriteIcon('actions-edit-undo') .
1273 '</a>';
1274
1275 // History button
1276 $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;') . '" title="' . $LANG->getLL('recordHistory', TRUE) . '">' .
1277 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1278 '</a>';
1279 }
1280 }
1281 }
1282
1283 return $buttons;
1284 }
1285
1286 /*******************************
1287 *
1288 * Other functions
1289 *
1290 ******************************/
1291
1292 /**
1293 * Returns the number of hidden elements (including those hidden by start/end times) on the current page (for the current sys_language)
1294 *
1295 * @return void
1296 */
1297 function getNumberOfHiddenElements() {
1298 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1299 'uid',
1300 'tt_content',
1301 'pid=' . intval($this->id) .
1302 ' AND sys_language_uid=' . intval($this->current_sys_language) .
1303 t3lib_BEfunc::BEenableFields('tt_content', 1) .
1304 t3lib_BEfunc::deleteClause('tt_content') .
1305 t3lib_BEfunc::versioningPlaceholderClause('tt_content')
1306 );
1307 }
1308
1309 /**
1310 * Returns URL to the current script.
1311 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1312 *
1313 * @param array Parameters array, merged with global GET vars.
1314 * @return string URL
1315 */
1316 function local_linkThisScript($params) {
1317 $params['popView']='';
1318 $params['new_unique_uid']='';
1319 return t3lib_div::linkThisScript($params);
1320 }
1321
1322 /**
1323 * Returns a SQL query for selecting sys_language records.
1324 *
1325 * @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)
1326 * @return string Return query string.
1327 */
1328 function exec_languageQuery($id) {
1329 if ($id) {
1330 $exQ = t3lib_BEfunc::deleteClause('pages_language_overlay') . ($GLOBALS['BE_USER']->isAdmin()?'':' AND sys_language.hidden=0');
1331 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1332 'sys_language.*',
1333 'pages_language_overlay,sys_language',
1334 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ,
1335 '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',
1336 'sys_language.title'
1337 );
1338 } else {
1339 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1340 'sys_language.*',
1341 'sys_language',
1342 'sys_language.hidden=0',
1343 '',
1344 'sys_language.title'
1345 );
1346 }
1347 }
1348 }
1349
1350
1351 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']) {
1352 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']);
1353 }
1354
1355
1356 // Make instance:
1357 $SOBE = t3lib_div::makeInstance('SC_db_layout');
1358 $SOBE->init();
1359
1360 // Include files?
1361 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1362
1363 $SOBE->clearCache();
1364 $SOBE->main();
1365 $SOBE->printContent();
1366
1367 ?>