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