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