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