Fixed issue #17153: Protect C(R)UD actions against CSRF (Thanks to Helmut Hummel)
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / db_layout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * 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 Skårhøj
34 * XHTML compliant
35 *
36 * @author Kasper Skårhøj <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 Skårhøj <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 Skårhøj <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::sanitizeLocalUrl(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) && count($tableSettings) > 1) {
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 & to also show hidden elements by default if user hasn't disabled the option
386 if (($GLOBALS['BE_USER']->workspace != 0) || ($this->MOD_SETTINGS['tt_content_showHidden'] !== '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() . t3lib_BEfunc::getUrlToken('tceAction') . '&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 if (!strcmp($this->colPosList,'')) {
539 $backendLayout = t3lib_div::callUserFunction( 'EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getSelectedBackendLayout' , $this->id, $this );
540
541 if(count($backendLayout['__colPosList'])) {
542 $this->colPosList = implode(',', $backendLayout['__colPosList']);
543 }
544 }
545 if( !strcmp($this->colPosList, '') ){
546 $this->colPosList = '1,0,2,3';
547 }
548 $this->colPosList = implode(',', array_unique(t3lib_div::intExplode(',',$this->colPosList))); // Removing duplicates, if any
549
550 // Render the primary module content:
551 if ($this->MOD_SETTINGS['function']==0) {
552 $body = $this->renderQuickEdit(); // QuickEdit
553 } else {
554 $body = $this->renderListContent(); // All other listings
555 }
556
557 // If page is a folder
558 if ($this->pageinfo['doktype'] == 254) {
559
560 // access to list module
561 $moduleLoader = t3lib_div::makeInstance('t3lib_loadModules');
562 $moduleLoader->load($GLOBALS['TBE_MODULES']);
563 $modules = $moduleLoader->modules;
564
565 if (is_array($modules['web']['sub']['list'])) {
566 $flashMessage = t3lib_div::makeInstance(
567 't3lib_FlashMessage',
568 '<p>' . $GLOBALS['LANG']->getLL('goToListModuleMessage') . '</p>
569 <br />
570 <p>' .
571 t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
572 '<a href="javascript:top.goToModule( \'web_list\',1);">' .
573 $GLOBALS['LANG']->getLL('goToListModule') . '
574 </a>
575 </p>',
576 '',
577 t3lib_FlashMessage::INFO
578 );
579 $body = $flashMessage->render() . $body;
580 }
581 }
582
583
584 if ($this->pageinfo['content_from_pid']) {
585 $contentPage = t3lib_BEfunc::getRecord('pages', intval($this->pageinfo['content_from_pid']));
586 $title = t3lib_BEfunc::getRecordTitle('pages', $contentPage);
587 $linkToPid = $this->local_linkThisScript(array('id' => $this->pageinfo['content_from_pid']));
588 $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . intval($this->pageinfo['content_from_pid']) . ')</a>';
589 $flashMessage = t3lib_div::makeInstance(
590 't3lib_FlashMessage',
591 '',
592 sprintf($GLOBALS['LANG']->getLL('content_from_pid_title'), $link),
593 t3lib_FlashMessage::INFO
594 );
595 $body = $flashMessage->render() . $body;
596 }
597
598 // Setting up the buttons and markers for docheader
599 $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function']==0 ? 'quickEdit' : '');
600 $markers = array(
601 'CSH' => $docHeaderButtons['csh'],
602 'TOP_FUNCTION_MENU' => $this->editSelect . $this->topFuncMenu,
603 'LANGSELECTOR' => $this->languageMenu,
604 'CONTENT' => $body
605 );
606
607 // Build the <body> for the module
608 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
609 // Renders the module page
610 $this->content = $this->doc->render(
611 $LANG->getLL('title'),
612 $this->content
613 );
614
615 } else {
616
617 // If no access or id value, create empty document:
618 $this->doc = t3lib_div::makeInstance('template');
619 $this->doc->backPath = $BACK_PATH;
620 $this->doc->setModuleTemplate('templates/db_layout.html');
621
622 $this->doc->JScode = $this->doc->wrapScriptTags('
623 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
624 ');
625
626 $flashMessage = t3lib_div::makeInstance(
627 't3lib_FlashMessage',
628 $LANG->getLL('clickAPage_content'),
629 $LANG->getLL('clickAPage_header'),
630 t3lib_FlashMessage::INFO
631 );
632 $body = $flashMessage->render();
633
634 // Setting up the buttons and markers for docheader
635 $docHeaderButtons = array(
636 'view' => '',
637 'history_page' => '',
638 'new_content' => '',
639 'move_page' => '',
640 'move_record' => '',
641 'new_page' => '',
642 'edit_page' => '',
643 'record_list' => '',
644 'csh' => '',
645 'shortcut' => '',
646 'cache' => '',
647 'savedok' => '',
648 'savedokshow' => '',
649 'closedok' => '',
650 'deletedok' => '',
651 'undo' => '',
652 'history_record' => ''
653 );
654
655 $markers = array(
656 'CSH' => t3lib_BEfunc::cshItem($this->descrTable, '', $BACK_PATH, '', TRUE),
657 'TOP_FUNCTION_MENU' => '',
658 'LANGSELECTOR' => '',
659 'CONTENT' => $body
660 );
661
662 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
663 // Renders the module page
664 $this->content = $this->doc->render(
665 $LANG->getLL('title'),
666 $this->content
667 );
668 }
669 }
670
671 /**
672 * Rendering the quick-edit view.
673 *
674 * @return void
675 */
676 function renderQuickEdit() {
677 global $LANG,$BE_USER,$BACK_PATH;
678 // Alternative template
679 $this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
680
681 // Alternative form tag; Quick Edit submits its content to tce_db.php.
682 $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);">';
683
684 // Setting up the context sensitive menu:
685 $this->doc->getContextMenuCode();
686
687 // Set the edit_record value for internal use in this function:
688 $edit_record = $this->edit_record;
689
690 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
691 if (substr($edit_record,0,9)=='_EDIT_COL') {
692 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
693 '*',
694 'tt_content',
695 'pid='.intval($this->id).' AND colPos='.intval(substr($edit_record,10)).' AND sys_language_uid='.intval($this->current_sys_language).
696 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
697 t3lib_BEfunc::deleteClause('tt_content').
698 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
699 '',
700 'sorting'
701 );
702 $idListA = array();
703 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
704 $idListA[] = $cRow['uid'];
705 }
706
707 $url = $BACK_PATH.'alt_doc.php?edit[tt_content]['.implode(',',$idListA).']=edit&returnUrl='.rawurlencode($this->local_linkThisScript(array('edit_record'=>'')));
708 t3lib_utility_Http::redirect($url);
709 }
710
711 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
712 if ($this->new_unique_uid) {
713 $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'));
714 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
715 if (is_array($sys_log_row)) {
716 $edit_record=$sys_log_row['tablename'].':'.$sys_log_row['recuid'];
717 }
718 }
719
720
721 // Creating the selector box, allowing the user to select which element to edit:
722 $opt=array();
723 $is_selected=0;
724 $languageOverlayRecord='';
725 if ($this->current_sys_language) {
726 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$this->id,'AND sys_language_uid='.intval($this->current_sys_language));
727 }
728 if (is_array($languageOverlayRecord)) {
729 $inValue = 'pages_language_overlay:'.$languageOverlayRecord['uid'];
730 $is_selected+=intval($edit_record==$inValue);
731 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('editLanguageHeader',1).' ]</option>';
732 } else {
733 $inValue = 'pages:'.$this->id;
734 $is_selected+=intval($edit_record==$inValue);
735 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('editPageProperties',1).' ]</option>';
736 }
737
738 // Selecting all content elements from this language and allowed colPos:
739 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
740 '*',
741 'tt_content',
742 'pid='.intval($this->id).' AND sys_language_uid='.intval($this->current_sys_language).' AND colPos IN ('.$this->colPosList.')'.
743 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
744 t3lib_Befunc::deleteClause('tt_content').
745 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
746 '',
747 'colPos,sorting'
748 );
749 $colPos='';
750 $first=1;
751 $prev=$this->id; // Page is the pid if no record to put this after.
752 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
753 t3lib_BEfunc::workspaceOL('tt_content', $cRow);
754
755 if (is_array($cRow)) {
756 if ($first) {
757 if (!$edit_record) {
758 $edit_record='tt_content:'.$cRow['uid'];
759 }
760 $first = 0;
761 }
762 if (strcmp($cRow['colPos'],$colPos)) {
763 $colPos=$cRow['colPos'];
764 $opt[]='<option value=""></option>';
765 $opt[]='<option value="_EDIT_COL:'.$colPos.'">__'.$LANG->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','colPos',$colPos),1).':__</option>';
766 }
767 $inValue = 'tt_content:'.$cRow['uid'];
768 $is_selected+=intval($edit_record==$inValue);
769 $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>';
770 $prev=-$cRow['uid'];
771 }
772 }
773
774 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
775 if (!$edit_record) {
776 $edit_record='tt_content:new/'.$prev.'/'.$colPos;
777
778 $inValue = 'tt_content:new/'.$prev.'/'.$colPos;
779 $is_selected+=intval($edit_record==$inValue);
780 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('newLabel',1).' ]</option>';
781 }
782
783 // If none is yet selected...
784 if (!$is_selected) {
785 $opt[]='<option value=""></option>';
786 $opt[]='<option value="'.$edit_record.'" selected="selected">[ '.$LANG->getLL('newLabel',1).' ]</option>';
787 }
788
789
790 // Splitting the edit-record cmd value into table/uid:
791 $this->eRParts = explode(':',$edit_record);
792
793
794
795 // Delete-button flag?
796 $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))));
797
798 // If undo-button should be rendered (depends on available items in sys_history)
799 $this->undoButton=0;
800 $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');
801 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
802 $this->undoButton=1;
803 }
804
805 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
806 $R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
807 $R_URL_getvars = t3lib_div::_GET();
808
809 unset($R_URL_getvars['popView']);
810 unset($R_URL_getvars['new_unique_uid']);
811 $R_URL_getvars['edit_record']=$edit_record;
812 $this->R_URI = $R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$R_URL_getvars);
813
814 // Setting close url/return url for exiting this script:
815 $this->closeUrl = $this->local_linkThisScript(array('SET'=>array('function'=>1))); // Goes to 'Columns' view if close is pressed (default)
816
817 if ($BE_USER->uc['condensedMode']) {
818 $this->closeUrl = $BACK_PATH.'alt_db_navframe.php';
819 }
820 if ($this->returnUrl) {
821 $this->closeUrl = $this->returnUrl;
822 }
823 // Return-url for JavaScript:
824 $retUrlStr = $this->returnUrl?"+'&returnUrl='+'".rawurlencode($this->returnUrl)."'":'';
825
826 // Drawing the edit record selectbox
827 $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>';
828
829 // Creating editing form:
830 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)))) {
831
832 // Splitting uid parts for special features, if new:
833 list($uidVal,$ex_pid,$ex_colPos) = explode('/',$this->eRParts[1]);
834
835 // Convert $uidVal to workspace version if any:
836 if ($uidVal!='new') {
837 if ($draftRecord = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
838 $uidVal = $draftRecord['uid'];
839 }
840 }
841
842 // Initializing transfer-data object:
843 $trData = t3lib_div::makeInstance('t3lib_transferData');
844 $trData->addRawData = TRUE;
845 $trData->defVals[$this->eRParts[0]] = array (
846 'colPos' => intval($ex_colPos),
847 'sys_language_uid' => intval($this->current_sys_language)
848 );
849 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
850 $trData->lockRecords=1;
851 $trData->fetchRecord($this->eRParts[0],($uidVal=='new'?$this->id:$uidVal),$uidVal); // 'new'
852
853 // Getting/Making the record:
854 reset($trData->regTableItems_data);
855 $rec = current($trData->regTableItems_data);
856 if ($uidVal=='new') {
857 $new_unique_uid = uniqid('NEW');
858 $rec['uid'] = $new_unique_uid;
859 $rec['pid'] = intval($ex_pid)?intval($ex_pid):$this->id;
860 $recordAccess = TRUE;
861 } else {
862 $rec['uid'] = $uidVal;
863
864 // Checking internals access:
865 $recordAccess = $BE_USER->recordEditAccessInternals($this->eRParts[0],$uidVal);
866 }
867
868 if (!$recordAccess) {
869 // If no edit access, print error message:
870 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />'.
871 ($BE_USER->errorMsg ? 'Reason: ' . $BE_USER->errorMsg . '<br /><br />' : ''), 0, 1);
872 } elseif (is_array($rec)) { // If the record is an array (which it will always be... :-)
873
874 // Create instance of TCEforms, setting defaults:
875 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
876 $tceforms->backPath = $BACK_PATH;
877 $tceforms->initDefaultBEMode();
878 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
879 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
880 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
881 $tceforms->enableClickMenu = TRUE;
882
883 // Clipboard is initialized:
884 $tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
885 $tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
886
887
888 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $tceforms->edit_showFieldHelp='text';
889
890 // Render form, wrap it:
891 $panel='';
892 $panel.=$tceforms->getMainFields($this->eRParts[0],$rec);
893 $panel=$tceforms->wrapTotal($panel,$rec,$this->eRParts[0]);
894
895 // Add hidden fields:
896 $theCode=$panel;
897 if ($uidVal=='new') {
898 $theCode.='<input type="hidden" name="data['.$this->eRParts[0].']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
899 }
900 $theCode.='
901 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />
902 <input type="hidden" name="_disableRTE" value="'.$tceforms->disableRTE.'" />
903 <input type="hidden" name="edit_record" value="'.$edit_record.'" />
904 <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 ).'" />
905 ' . t3lib_TCEforms::getHiddenTokenField('tceAction');
906
907 // Add JavaScript as needed around the form:
908 $theCode=$tceforms->printNeededJSFunctions_top().$theCode.$tceforms->printNeededJSFunctions();
909
910 // Add warning sign if record was "locked":
911 if ($lockInfo = t3lib_BEfunc::isRecordLocked($this->eRParts[0], $rec['uid'])) {
912 $lockedMessage = t3lib_div::makeInstance(
913 't3lib_FlashMessage',
914 htmlspecialchars($lockInfo['msg']),
915 '',
916 t3lib_FlashMessage::WARNING
917 );
918 t3lib_FlashMessageQueue::addMessage($lockedMessage);
919 }
920
921 // Add whole form as a document section:
922 $content .= $this->doc->section('', $theCode);
923 }
924 } else {
925 // If no edit access, print error message:
926 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />',0,1);
927 }
928
929
930 // Bottom controls (function menus):
931 $q_count = $this->getNumberOfHiddenElements();
932 $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"').
933 '<label for="checkTt_content_showHidden">'.(!$q_count?$GLOBALS['TBE_TEMPLATE']->dfw($LANG->getLL('hiddenCE',1)):$LANG->getLL('hiddenCE',1).' ('.$q_count.')').'</label>';
934
935 $h_func_b.= '<br />'.
936 t3lib_BEfunc::getFuncCheck($this->id,'SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'db_layout.php','','id="checkShowPalettes"').
937 '<label for="checkShowPalettes">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1).'</label>';
938
939 if (t3lib_extMgm::isLoaded('context_help') && $BE_USER->uc['edit_showFieldHelp']!='text') {
940 $h_func_b.= '<br />'.
941 t3lib_BEfunc::getFuncCheck($this->id,'SET[showDescriptions]',$this->MOD_SETTINGS['showDescriptions'],'db_layout.php','','id="checkShowDescriptions"').
942 '<label for="checkShowDescriptions">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1).'</label>';
943 }
944
945 if ($BE_USER->isRTE()) {
946 $h_func_b.= '<br />'.
947 t3lib_BEfunc::getFuncCheck($this->id,'SET[disableRTE]',$this->MOD_SETTINGS['disableRTE'],'db_layout.php','','id="checkDisableRTE"').
948 '<label for="checkDisableRTE">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1).'</label>';
949 }
950
951 // Add the function menus to bottom:
952 $content.=$this->doc->section('',$h_func_b,0,0);
953 $content.=$this->doc->spacer(10);
954
955
956 // Select element matrix:
957 if ($this->eRParts[0]=='tt_content' && t3lib_div::testInt($this->eRParts[1])) {
958 $posMap = t3lib_div::makeInstance('ext_posMap');
959 $posMap->backPath = $BACK_PATH;
960 $posMap->cur_sys_language=$this->current_sys_language;
961
962 $HTMLcode = '';
963
964 // CSH:
965 $HTMLcode.= t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit_selElement', $BACK_PATH, '|<br />');
966
967 $HTMLcode.=$posMap->printContentElementColumns($this->id,$this->eRParts[1],$this->colPosList,$this->MOD_SETTINGS['tt_content_showHidden'],$this->R_URI);
968
969 $content.=$this->doc->spacer(20);
970 $content.=$this->doc->section($LANG->getLL('CEonThisPage'),$HTMLcode,0,1);
971 $content.=$this->doc->spacer(20);
972 }
973
974 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
975 if (count($tceforms->commentMessages)) {
976 $content.='
977 <!-- TCEFORM messages
978 '.htmlspecialchars(implode(LF,$tceforms->commentMessages)).'
979 -->
980 ';
981 }
982 return $content;
983 }
984
985 /**
986 * Rendering all other listings than QuickEdit
987 *
988 * @return void
989 */
990 function renderListContent() {
991 global $LANG,$BACK_PATH,$TCA;
992
993 // Initialize list object (see "class.db_layout.inc"):
994 $dblist = t3lib_div::makeInstance('tx_cms_layout');
995 $dblist->backPath = $BACK_PATH;
996 $dblist->thumbs = $this->imagemode;
997 $dblist->no_noWrap = 1;
998 $dblist->descrTable = $this->descrTable;
999
1000 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
1001 $dblist->script = 'db_layout.php';
1002 $dblist->showIcon = 0;
1003 $dblist->setLMargin=0;
1004 $dblist->doEdit = $this->EDIT_CONTENT;
1005 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
1006
1007 $dblist->agePrefixes = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
1008 $dblist->id = $this->id;
1009 $dblist->nextThree = t3lib_div::intInRange($this->modTSconfig['properties']['editFieldsAtATime'],0,10);
1010 $dblist->option_showBigButtons = ($this->modTSconfig['properties']['disableBigButtons'] === '0');
1011 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
1012 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
1013 if (!$dblist->nextThree) $dblist->nextThree = 1;
1014
1015 $dblist->externalTables = $this->externalTables;
1016
1017 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
1018 $h_menu = $dblist->getTableMenu($this->id);
1019
1020 // Initialize other variables:
1021 $h_func='';
1022 $tableOutput=array();
1023 $tableJSOutput=array();
1024 $CMcounter = 0;
1025
1026 // Traverse the list of table names which has records on this page (that array is populated by the $dblist object during the function getTableMenu()):
1027 foreach ($dblist->activeTables as $table => $value) {
1028
1029 // Load full table definitions:
1030 t3lib_div::loadTCA($table);
1031
1032 if (!isset($dblist->externalTables[$table])) {
1033 // Creating special conditions for each table:
1034 switch($table) {
1035 case 'tt_board':
1036 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_board]',$this->MOD_SETTINGS['tt_board'],$this->MOD_MENU['tt_board'],'db_layout.php','');
1037 break;
1038 case 'tt_address':
1039 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_address]',$this->MOD_SETTINGS['tt_address'],$this->MOD_MENU['tt_address'],'db_layout.php','');
1040 break;
1041 case 'tt_links':
1042 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_links]',$this->MOD_SETTINGS['tt_links'],$this->MOD_MENU['tt_links'],'db_layout.php','');
1043 break;
1044 case 'tt_calender':
1045 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_calender]',$this->MOD_SETTINGS['tt_calender'],$this->MOD_MENU['tt_calender'],'db_layout.php','');
1046 break;
1047 case 'tt_products':
1048 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_products]',$this->MOD_SETTINGS['tt_products'],$this->MOD_MENU['tt_products'],'db_layout.php','');
1049 break;
1050 case 'tt_guest':
1051 case 'tt_news':
1052 case 'fe_users':
1053 // Nothing
1054 break;
1055 case 'tt_content':
1056 $q_count = $this->getNumberOfHiddenElements();
1057 $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>';
1058
1059 $dblist->tt_contentConfig['showCommands'] = 1; // Boolean: Display up/down arrows and edit icons for tt_content records
1060 $dblist->tt_contentConfig['showInfo'] = 1; // Boolean: Display info-marks or not
1061 $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
1062
1063 if ($this->MOD_SETTINGS['function'] == 4) {
1064 // grid view
1065 $dblist->tt_contentConfig['showAsGrid'] = 1;
1066 }
1067
1068 // Setting up the tt_content columns to show:
1069 if (is_array($TCA['tt_content']['columns']['colPos']['config']['items'])) {
1070 $colList = array();
1071 $tcaItems = t3lib_div::callUserFunction( 'EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed' , $this->id, $this );
1072 foreach($tcaItems as $temp) {
1073 $colList[] = $temp[1];
1074 }
1075 } else { // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
1076 $colList = array('1','0','2','3');
1077 }
1078 if (strcmp($this->colPosList,'')) {
1079 $colList = array_intersect(t3lib_div::intExplode(',',$this->colPosList),$colList);
1080 }
1081
1082 // If only one column found, display the single-column view.
1083 if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) {
1084 $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
1085 $dblist->tt_contentConfig['showSingleCol'] = current($colList); // The column(s) to show if single mode (under each other)
1086 }
1087 $dblist->tt_contentConfig['cols'] = implode(',',$colList); // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
1088 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
1089 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
1090
1091 // If the function menu is set to "Language":
1092 if ($this->MOD_SETTINGS['function']==2) {
1093 $dblist->tt_contentConfig['single'] = 0;
1094 $dblist->tt_contentConfig['languageMode'] = 1;
1095 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
1096 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
1097 }
1098 break;
1099 }
1100 } else {
1101 if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
1102 $h_func = t3lib_BEfunc::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
1103 } else {
1104 $h_func = '';
1105 }
1106 }
1107
1108 // Start the dblist object:
1109 $dblist->itemsLimitSingleTable = 1000;
1110 $dblist->start($this->id,$table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
1111 $dblist->counter = $CMcounter;
1112 $dblist->ext_function = $this->MOD_SETTINGS['function'];
1113
1114 // Render versioning selector:
1115 $dblist->HTMLcode.= $this->doc->getVersionSelector($this->id);
1116
1117 // Generate the list of elements here:
1118 $dblist->generateList();
1119
1120 // Adding the list content to the tableOutput variable:
1121 $tableOutput[$table]=
1122 ($h_func?$h_func.'<br /><img src="clear.gif" width="1" height="4" alt="" /><br />':'').
1123 $dblist->HTMLcode.
1124 ($h_func_b?'<img src="clear.gif" width="1" height="10" alt="" /><br />'.$h_func_b:'');
1125
1126 // ... and any accumulated JavaScript goes the same way!
1127 $tableJSOutput[$table] = $dblist->JScode;
1128
1129 // Increase global counter:
1130 $CMcounter+= $dblist->counter;
1131
1132 // Reset variables after operation:
1133 $dblist->HTMLcode='';
1134 $dblist->JScode='';
1135 $h_func = '';
1136 $h_func_b = '';
1137 } // END: traverse tables
1138
1139
1140 // For Context Sensitive Menus:
1141 $this->doc->getContextMenuCode();
1142
1143 // Now, create listing based on which element is selected in the function menu:
1144
1145 if ($this->MOD_SETTINGS['function']==3) {
1146
1147 // Making page info:
1148 $content.=$this->doc->spacer(10);
1149 $content.=$this->doc->section($LANG->getLL('pageInformation'),$dblist->getPageInfoBox($this->pageinfo,$this->CALC_PERMS&2),0,1);
1150 } else {
1151
1152 // Add the content for each table we have rendered (traversing $tableOutput variable)
1153 foreach($tableOutput as $table => $output) {
1154 $content.=$this->doc->section('<a name="'.$table.'"></a>'.$dblist->activeTables[$table],$output,TRUE,TRUE,0,TRUE);
1155 $content.=$this->doc->spacer(15);
1156 $content.=$this->doc->sectionEnd();
1157 }
1158
1159 // Making search form:
1160 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
1161 $sectionTitle = t3lib_BEfunc::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.search', TRUE));
1162 $content .= $this->doc->section(
1163 $sectionTitle,
1164 $dblist->getSearchBox(0),
1165 FALSE, TRUE, FALSE, TRUE
1166 );
1167 }
1168
1169 // Making display of Sys-notes (from extension "sys_note")
1170 $dblist->id=$this->id;
1171 $sysNotes = $dblist->showSysNotesForPage();
1172 if ($sysNotes) {
1173 $content.=$this->doc->spacer(10);
1174 $content.=$this->doc->section($LANG->getLL('internalNotes'),$sysNotes,0,1);
1175 }
1176
1177 // Add spacer in bottom of page:
1178 $content.=$this->doc->spacer(10);
1179 }
1180
1181 // Ending page:
1182 $content.=$this->doc->spacer(10);
1183
1184 return $content;
1185 }
1186
1187 /**
1188 * Print accumulated content of module
1189 *
1190 * @return void
1191 */
1192 function printContent() {
1193 echo $this->content;
1194 }
1195
1196 /***************************
1197 *
1198 * Sub-content functions, rendering specific parts of the module content.
1199 *
1200 ***************************/
1201
1202 /**
1203 * Create the panel of buttons for submitting the form or otherwise perform operations.
1204 *
1205 * @param string Identifier for function of module
1206 * @return array all available buttons as an assoc. array
1207 */
1208 protected function getButtons($function = '') {
1209 global $TCA, $LANG, $BACK_PATH, $BE_USER;
1210
1211 $buttons = array(
1212 'view' => '',
1213 'history_page' => '',
1214 'new_content' => '',
1215 'move_page' => '',
1216 'move_record' => '',
1217 'new_page' => '',
1218 'edit_page' => '',
1219 'record_list' => '',
1220 'csh' => '',
1221 'shortcut' => '',
1222 'cache' => '',
1223 'savedok' => '',
1224 'savedokshow' => '',
1225 'closedok' => '',
1226 'deletedok' => '',
1227 'undo' => '',
1228 'history_record' => ''
1229 );
1230
1231 // View page
1232 $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) . '">' .
1233 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1234 '</a>';
1235
1236 // Shortcut
1237 if ($BE_USER->mayMakeShortcut()) {
1238 $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']);
1239 }
1240
1241 // Cache
1242 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1243 $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) . '">' .
1244 t3lib_iconWorks::getSpriteIcon('actions-system-cache-clear') .
1245 '</a>';
1246 }
1247
1248 // If access to Web>List for user, then link to that module.
1249 $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
1250 array(
1251 'id' => $this->pageinfo['uid'],
1252 'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
1253 ),
1254 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
1255 );
1256
1257 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1258
1259 // Page history
1260 $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) . '">' .
1261 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1262 '</a>';
1263 // New content element
1264 $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) . '">' .
1265 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
1266 '</a>';
1267 // Move page
1268 $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) . '">' .
1269 t3lib_iconWorks::getSpriteIcon('actions-page-move') .
1270 '</a>';
1271 // Move record
1272 if (t3lib_div::testInt($this->eRParts[1])) {
1273 $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'))) . '">' .
1274 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))) .
1275 '</a>';
1276 }
1277 // Create new page (wizard)
1278 $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) . '">' .
1279 t3lib_iconWorks::getSpriteIcon('actions-page-new') .
1280 '</a>';
1281 // Edit page properties
1282 if ($this->CALC_PERMS&2) {
1283 $params='&edit[pages][' . $this->id . ']=edit';
1284 $buttons['edit_page'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $BACK_PATH)) . '" title="' . $LANG->getLL('editPageProperties', TRUE) . '">' .
1285 t3lib_iconWorks::getSpriteIcon('actions-page-open') .
1286 '</a>';
1287 }
1288
1289 // Add CSH (Context Sensitive Help) icon to tool bar
1290 if($function == 'quickEdit') {
1291 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit', $BACK_PATH, '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1292 } else {
1293 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $BACK_PATH, '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1294 }
1295
1296 if($function == 'quickEdit') {
1297 // Save record
1298 $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="" />';
1299
1300 // Save record and show page
1301 $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) . '">' .
1302 t3lib_iconWorks::getSpriteIcon('actions-document-save-view') .
1303 '</a>';
1304
1305 // Close record
1306 $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) . '">' .
1307 t3lib_iconWorks::getSpriteIcon('actions-document-close') .
1308 '</a>';
1309
1310 // Delete record
1311 if($this->deleteButton) {
1312 $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) . '">' .
1313 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1314 '</a>';
1315 }
1316
1317 if($this->undoButton) {
1318 // Undo button
1319 $buttons['undo'] = '<a href="#"
1320 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;') . '"
1321 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')))) . '">' .
1322 t3lib_iconWorks::getSpriteIcon('actions-edit-undo') .
1323 '</a>';
1324
1325 // History button
1326 $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) . '">' .
1327 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1328 '</a>';
1329 }
1330 }
1331 }
1332
1333 return $buttons;
1334 }
1335
1336 /*******************************
1337 *
1338 * Other functions
1339 *
1340 ******************************/
1341
1342 /**
1343 * Returns the number of hidden elements (including those hidden by start/end times) on the current page (for the current sys_language)
1344 *
1345 * @return void
1346 */
1347 function getNumberOfHiddenElements() {
1348 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1349 'uid',
1350 'tt_content',
1351 'pid=' . intval($this->id) .
1352 ' AND sys_language_uid=' . intval($this->current_sys_language) .
1353 t3lib_BEfunc::BEenableFields('tt_content', 1) .
1354 t3lib_BEfunc::deleteClause('tt_content') .
1355 t3lib_BEfunc::versioningPlaceholderClause('tt_content')
1356 );
1357 }
1358
1359 /**
1360 * Returns URL to the current script.
1361 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1362 *
1363 * @param array Parameters array, merged with global GET vars.
1364 * @return string URL
1365 */
1366 function local_linkThisScript($params) {
1367 $params['popView']='';
1368 $params['new_unique_uid']='';
1369 return t3lib_div::linkThisScript($params);
1370 }
1371
1372 /**
1373 * Returns a SQL query for selecting sys_language records.
1374 *
1375 * @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)
1376 * @return string Return query string.
1377 */
1378 function exec_languageQuery($id) {
1379 if ($id) {
1380 $exQ = t3lib_BEfunc::deleteClause('pages_language_overlay') . ($GLOBALS['BE_USER']->isAdmin()?'':' AND sys_language.hidden=0');
1381 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1382 'sys_language.*',
1383 'pages_language_overlay,sys_language',
1384 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ,
1385 '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',
1386 'sys_language.title'
1387 );
1388 } else {
1389 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1390 'sys_language.*',
1391 'sys_language',
1392 'sys_language.hidden=0',
1393 '',
1394 'sys_language.title'
1395 );
1396 }
1397 }
1398 }
1399
1400
1401 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php'])) {
1402 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']);
1403 }
1404
1405
1406 // Make instance:
1407 $SOBE = t3lib_div::makeInstance('SC_db_layout');
1408 $SOBE->init();
1409
1410 // Include files?
1411 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1412
1413 $SOBE->clearCache();
1414 $SOBE->main();
1415 $SOBE->printContent();
1416 t3lib_formprotection_Factory::get('t3lib_formprotection_BackendFormProtection')->persistTokens();
1417
1418 ?>