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