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