Follow-up to bug #12154: renamed t3lib_MessageQueue to t3lib_FlashMessageQueue, chang...
[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 // Setting up the buttons and markers for docheader
526 $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function']==0 ? 'quickEdit' : '');
527 $markers = array(
528 'CSH' => $docHeaderButtons['csh'],
529 'TOP_FUNCTION_MENU' => $this->editSelect . $this->topFuncMenu,
530 'LANGSELECTOR' => $this->languageMenu,
531 'CONTENT' => $body
532 );
533
534 // Build the <body> for the module
535 $this->content = $this->doc->startPage($LANG->getLL('title'));
536 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
537 $this->content.= $this->doc->endPage();
538 $this->content = $this->doc->insertStylesAndJS($this->content);
539
540 } else {
541
542 // If no access or id value, create empty document:
543 $this->doc = t3lib_div::makeInstance('template');
544 $this->doc->backPath = $BACK_PATH;
545 $this->doc->setModuleTemplate('templates/db_layout.html');
546
547 $this->doc->JScode = $this->doc->wrapScriptTags('
548 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
549 ');
550
551 $body = $this->doc->section($LANG->getLL('clickAPage_header'), $LANG->getLL('clickAPage_content'), 0, 1);
552
553 // Setting up the buttons and markers for docheader
554 $docHeaderButtons = array(
555 'view' => '',
556 'history_page' => '',
557 'new_content' => '',
558 'move_page' => '',
559 'move_record' => '',
560 'new_page' => '',
561 'edit_page' => '',
562 'record_list' => '',
563 'csh' => '',
564 'shortcut' => '',
565 'cache' => '',
566 'savedok' => '',
567 'savedokshow' => '',
568 'closedok' => '',
569 'deletedok' => '',
570 'undo' => '',
571 'history_record' => ''
572 );
573
574 $markers = array(
575 'CSH' => t3lib_BEfunc::cshItem($this->descrTable, '', $BACK_PATH, '', TRUE),
576 'TOP_FUNCTION_MENU' => '',
577 'LANGSELECTOR' => '',
578 'CONTENT' => $body
579 );
580
581 $this->content=$this->doc->startPage($LANG->getLL('title'));
582 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
583 $this->content.=$this->doc->endPage();
584 $this->content = $this->doc->insertStylesAndJS($this->content);
585 }
586 }
587
588 /**
589 * Rendering the quick-edit view.
590 *
591 * @return void
592 */
593 function renderQuickEdit() {
594 global $LANG,$BE_USER,$BACK_PATH;
595 // Alternative template
596 $this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
597
598 // Alternative form tag; Quick Edit submits its content to tce_db.php.
599 $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);">';
600
601 // Setting up the context sensitive menu:
602 $this->doc->getContextMenuCode();
603
604 // Set the edit_record value for internal use in this function:
605 $edit_record = $this->edit_record;
606
607 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
608 if (substr($edit_record,0,9)=='_EDIT_COL') {
609 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
610 '*',
611 'tt_content',
612 'pid='.intval($this->id).' AND colPos='.intval(substr($edit_record,10)).' AND sys_language_uid='.intval($this->current_sys_language).
613 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
614 t3lib_BEfunc::deleteClause('tt_content').
615 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
616 '',
617 'sorting'
618 );
619 $idListA = array();
620 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
621 $idListA[] = $cRow['uid'];
622 }
623
624 $url = $BACK_PATH.'alt_doc.php?edit[tt_content]['.implode(',',$idListA).']=edit&returnUrl='.rawurlencode($this->local_linkThisScript(array('edit_record'=>'')));
625 t3lib_div::redirect($url);
626 }
627
628 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
629 if ($this->new_unique_uid) {
630 $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'));
631 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
632 if (is_array($sys_log_row)) {
633 $edit_record=$sys_log_row['tablename'].':'.$sys_log_row['recuid'];
634 }
635 }
636
637
638 // Creating the selector box, allowing the user to select which element to edit:
639 $opt=array();
640 $is_selected=0;
641 $languageOverlayRecord='';
642 if ($this->current_sys_language) {
643 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$this->id,'AND sys_language_uid='.intval($this->current_sys_language));
644 }
645 if (is_array($languageOverlayRecord)) {
646 $inValue = 'pages_language_overlay:'.$languageOverlayRecord['uid'];
647 $is_selected+=intval($edit_record==$inValue);
648 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('editLanguageHeader',1).' ]</option>';
649 } else {
650 $inValue = 'pages:'.$this->id;
651 $is_selected+=intval($edit_record==$inValue);
652 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('editPageProperties',1).' ]</option>';
653 }
654
655 // Selecting all content elements from this language and allowed colPos:
656 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
657 '*',
658 'tt_content',
659 'pid='.intval($this->id).' AND sys_language_uid='.intval($this->current_sys_language).' AND colPos IN ('.$this->colPosList.')'.
660 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
661 t3lib_Befunc::deleteClause('tt_content').
662 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
663 '',
664 'colPos,sorting'
665 );
666 $colPos='';
667 $first=1;
668 $prev=$this->id; // Page is the pid if no record to put this after.
669 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
670 t3lib_BEfunc::workspaceOL('tt_content', $cRow);
671
672 if (is_array($cRow)) {
673 if ($first) {
674 if (!$edit_record) {
675 $edit_record='tt_content:'.$cRow['uid'];
676 }
677 $first = 0;
678 }
679 if (strcmp($cRow['colPos'],$colPos)) {
680 $colPos=$cRow['colPos'];
681 $opt[]='<option value=""></option>';
682 $opt[]='<option value="_EDIT_COL:'.$colPos.'">__'.$LANG->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','colPos',$colPos),1).':__</option>';
683 }
684 $inValue = 'tt_content:'.$cRow['uid'];
685 $is_selected+=intval($edit_record==$inValue);
686 $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>';
687 $prev=-$cRow['uid'];
688 }
689 }
690
691 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
692 if (!$edit_record) {
693 $edit_record='tt_content:new/'.$prev.'/'.$colPos;
694
695 $inValue = 'tt_content:new/'.$prev.'/'.$colPos;
696 $is_selected+=intval($edit_record==$inValue);
697 $opt[]='<option value="'.$inValue.'"'.($edit_record==$inValue?' selected="selected"':'').'>[ '.$LANG->getLL('newLabel',1).' ]</option>';
698 }
699
700 // If none is yet selected...
701 if (!$is_selected) {
702 $opt[]='<option value=""></option>';
703 $opt[]='<option value="'.$edit_record.'" selected="selected">[ '.$LANG->getLL('newLabel',1).' ]</option>';
704 }
705
706
707 // Splitting the edit-record cmd value into table/uid:
708 $this->eRParts = explode(':',$edit_record);
709
710
711
712 // Delete-button flag?
713 $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))));
714
715 // If undo-button should be rendered (depends on available items in sys_history)
716 $this->undoButton=0;
717 $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');
718 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
719 $this->undoButton=1;
720 }
721
722 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
723 $R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
724 $R_URL_getvars = t3lib_div::_GET();
725
726 unset($R_URL_getvars['popView']);
727 unset($R_URL_getvars['new_unique_uid']);
728 $R_URL_getvars['edit_record']=$edit_record;
729 $this->R_URI = $R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$R_URL_getvars);
730
731 // Setting close url/return url for exiting this script:
732 $this->closeUrl = $this->local_linkThisScript(array('SET'=>array('function'=>1))); // Goes to 'Columns' view if close is pressed (default)
733
734 if ($BE_USER->uc['condensedMode']) {
735 $this->closeUrl = $BACK_PATH.'alt_db_navframe.php';
736 }
737 if ($this->returnUrl) {
738 $this->closeUrl = $this->returnUrl;
739 }
740 // Return-url for JavaScript:
741 $retUrlStr = $this->returnUrl?"+'&returnUrl='+'".rawurlencode($this->returnUrl)."'":'';
742
743 // Drawing the edit record selectbox
744 $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>';
745
746 // Creating editing form:
747 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)))) {
748
749 // Splitting uid parts for special features, if new:
750 list($uidVal,$ex_pid,$ex_colPos) = explode('/',$this->eRParts[1]);
751
752 // Convert $uidVal to workspace version if any:
753 if ($uidVal!='new') {
754 if ($draftRecord = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
755 $uidVal = $draftRecord['uid'];
756 }
757 }
758
759 // Initializing transfer-data object:
760 $trData = t3lib_div::makeInstance('t3lib_transferData');
761 $trData->addRawData = TRUE;
762 $trData->defVals[$this->eRParts[0]] = array (
763 'colPos' => intval($ex_colPos),
764 'sys_language_uid' => intval($this->current_sys_language)
765 );
766 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
767 $trData->lockRecords=1;
768 $trData->fetchRecord($this->eRParts[0],($uidVal=='new'?$this->id:$uidVal),$uidVal); // 'new'
769
770 // Getting/Making the record:
771 reset($trData->regTableItems_data);
772 $rec = current($trData->regTableItems_data);
773 if ($uidVal=='new') {
774 $new_unique_uid = uniqid('NEW');
775 $rec['uid'] = $new_unique_uid;
776 $rec['pid'] = intval($ex_pid)?intval($ex_pid):$this->id;
777 $recordAccess = TRUE;
778 } else {
779 $rec['uid'] = $uidVal;
780
781 // Checking internals access:
782 $recordAccess = $BE_USER->recordEditAccessInternals($this->eRParts[0],$uidVal);
783 }
784
785 if (!$recordAccess) {
786 // If no edit access, print error message:
787 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />'.
788 ($BE_USER->errorMsg ? 'Reason: ' . $BE_USER->errorMsg . '<br /><br />' : ''), 0, 1);
789 } elseif (is_array($rec)) { // If the record is an array (which it will always be... :-)
790
791 // Create instance of TCEforms, setting defaults:
792 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
793 $tceforms->backPath = $BACK_PATH;
794 $tceforms->initDefaultBEMode();
795 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
796 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
797 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
798 $tceforms->enableClickMenu = TRUE;
799
800 // Clipboard is initialized:
801 $tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
802 $tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
803
804
805 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $tceforms->edit_showFieldHelp='text';
806
807 // Render form, wrap it:
808 $panel='';
809 $panel.=$tceforms->getMainFields($this->eRParts[0],$rec);
810 $panel=$tceforms->wrapTotal($panel,$rec,$this->eRParts[0]);
811
812 // Add hidden fields:
813 $theCode=$panel;
814 if ($uidVal=='new') {
815 $theCode.='<input type="hidden" name="data['.$this->eRParts[0].']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
816 }
817 $theCode.='
818 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />
819 <input type="hidden" name="_disableRTE" value="'.$tceforms->disableRTE.'" />
820 <input type="hidden" name="edit_record" value="'.$edit_record.'" />
821 <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 ).'" />
822 ';
823
824 // Add JavaScript as needed around the form:
825 $theCode=$tceforms->printNeededJSFunctions_top().$theCode.$tceforms->printNeededJSFunctions();
826
827 // Add warning sign if record was "locked":
828 if ($lockInfo = t3lib_BEfunc::isRecordLocked($this->eRParts[0], $rec['uid'])) {
829 $lockedMessage = t3lib_div::makeInstance(
830 't3lib_FlashMessage',
831 htmlspecialchars($lockInfo['msg']),
832 '',
833 t3lib_FlashMessage::WARNING
834 );
835 t3lib_FlashMessageQueue::addMessage($lockedMessage);
836 }
837
838 // Add whole form as a document section:
839 $content .= $this->doc->section('', $theCode);
840 }
841 } else {
842 // If no edit access, print error message:
843 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />',0,1);
844 }
845
846
847 // Bottom controls (function menus):
848 $q_count = $this->getNumberOfHiddenElements();
849 $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"').
850 '<label for="checkTt_content_showHidden">'.(!$q_count?$GLOBALS['TBE_TEMPLATE']->dfw($LANG->getLL('hiddenCE',1)):$LANG->getLL('hiddenCE',1).' ('.$q_count.')').'</label>';
851
852 $h_func_b.= '<br />'.
853 t3lib_BEfunc::getFuncCheck($this->id,'SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'db_layout.php','','id="checkShowPalettes"').
854 '<label for="checkShowPalettes">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1).'</label>';
855
856 if (t3lib_extMgm::isLoaded('context_help') && $BE_USER->uc['edit_showFieldHelp']!='text') {
857 $h_func_b.= '<br />'.
858 t3lib_BEfunc::getFuncCheck($this->id,'SET[showDescriptions]',$this->MOD_SETTINGS['showDescriptions'],'db_layout.php','','id="checkShowDescriptions"').
859 '<label for="checkShowDescriptions">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1).'</label>';
860 }
861
862 if ($BE_USER->isRTE()) {
863 $h_func_b.= '<br />'.
864 t3lib_BEfunc::getFuncCheck($this->id,'SET[disableRTE]',$this->MOD_SETTINGS['disableRTE'],'db_layout.php','','id="checkDisableRTE"').
865 '<label for="checkDisableRTE">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1).'</label>';
866 }
867
868 // Add the function menus to bottom:
869 $content.=$this->doc->section('',$h_func_b,0,0);
870 $content.=$this->doc->spacer(10);
871
872
873 // Select element matrix:
874 if ($this->eRParts[0]=='tt_content' && t3lib_div::testInt($this->eRParts[1])) {
875 $posMap = t3lib_div::makeInstance('ext_posMap');
876 $posMap->backPath = $BACK_PATH;
877 $posMap->cur_sys_language=$this->current_sys_language;
878
879 $HTMLcode = '';
880
881 // CSH:
882 $HTMLcode.= t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit_selElement', $BACK_PATH, '|<br />');
883
884 $HTMLcode.=$posMap->printContentElementColumns($this->id,$this->eRParts[1],$this->colPosList,$this->MOD_SETTINGS['tt_content_showHidden'],$this->R_URI);
885
886 $content.=$this->doc->spacer(20);
887 $content.=$this->doc->section($LANG->getLL('CEonThisPage'),$HTMLcode,0,1);
888 $content.=$this->doc->spacer(20);
889 }
890
891 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
892 if (count($tceforms->commentMessages)) {
893 $content.='
894 <!-- TCEFORM messages
895 '.htmlspecialchars(implode(chr(10),$tceforms->commentMessages)).'
896 -->
897 ';
898 }
899 return $content;
900 }
901
902 /**
903 * Rendering all other listings than QuickEdit
904 *
905 * @return void
906 */
907 function renderListContent() {
908 global $LANG,$BACK_PATH,$TCA;
909
910 // Initialize list object (see "class.db_layout.inc"):
911 $dblist = t3lib_div::makeInstance('tx_cms_layout');
912 $dblist->backPath = $BACK_PATH;
913 $dblist->thumbs = $this->imagemode;
914 $dblist->no_noWrap = 1;
915 $dblist->descrTable = $this->descrTable;
916
917 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
918 $dblist->script = 'db_layout.php';
919 $dblist->showIcon = 0;
920 $dblist->setLMargin=0;
921 $dblist->doEdit = $this->EDIT_CONTENT;
922 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
923
924 $dblist->agePrefixes = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
925 $dblist->id = $this->id;
926 $dblist->nextThree = t3lib_div::intInRange($this->modTSconfig['properties']['editFieldsAtATime'],0,10);
927 $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] ? 0 : 1;
928 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
929 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
930 if (!$dblist->nextThree) $dblist->nextThree = 1;
931
932 $dblist->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
933 $dblist->translateTools = t3lib_div::makeInstance('t3lib_transl8tools');
934
935
936 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
937 $h_menu = $dblist->getTableMenu($this->id);
938
939 // Initialize other variables:
940 $h_func='';
941 $tableOutput=array();
942 $tableJSOutput=array();
943 $CMcounter = 0;
944
945 // Traverse the list of table names which has records on this page (that array is populated by the $dblist object during the function getTableMenu()):
946 reset($dblist->activeTables);
947 while(list($table)=each($dblist->activeTables)) {
948
949 // Load full table definitions:
950 t3lib_div::loadTCA($table);
951
952 if (!isset($dblist->externalTables[$table])) {
953 // Creating special conditions for each table:
954 switch($table) {
955 case 'tt_board':
956 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_board]',$this->MOD_SETTINGS['tt_board'],$this->MOD_MENU['tt_board'],'db_layout.php','');
957 break;
958 case 'tt_address':
959 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_address]',$this->MOD_SETTINGS['tt_address'],$this->MOD_MENU['tt_address'],'db_layout.php','');
960 break;
961 case 'tt_links':
962 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_links]',$this->MOD_SETTINGS['tt_links'],$this->MOD_MENU['tt_links'],'db_layout.php','');
963 break;
964 case 'tt_calender':
965 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_calender]',$this->MOD_SETTINGS['tt_calender'],$this->MOD_MENU['tt_calender'],'db_layout.php','');
966 break;
967 case 'tt_products':
968 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_products]',$this->MOD_SETTINGS['tt_products'],$this->MOD_MENU['tt_products'],'db_layout.php','');
969 break;
970 case 'tt_guest':
971 case 'tt_news':
972 case 'fe_users':
973 // Nothing
974 break;
975 case 'tt_content':
976 $q_count = $this->getNumberOfHiddenElements();
977 $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>';
978
979 $dblist->tt_contentConfig['showCommands'] = 1; // Boolean: Display up/down arrows and edit icons for tt_content records
980 $dblist->tt_contentConfig['showInfo'] = 1; // Boolean: Display info-marks or not
981 $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
982
983 // Setting up the tt_content columns to show:
984 if (is_array($TCA['tt_content']['columns']['colPos']['config']['items'])) {
985 $colList = array();
986 foreach($TCA['tt_content']['columns']['colPos']['config']['items'] as $temp) {
987 $colList[] = $temp[1];
988 }
989 } else { // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
990 $colList = array('1','0','2','3');
991 }
992 if (strcmp($this->colPosList,'')) {
993 $colList = array_intersect(t3lib_div::intExplode(',',$this->colPosList),$colList);
994 }
995
996 // If only one column found, display the single-column view.
997 if (count($colList)==1) {
998 $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
999 $dblist->tt_contentConfig['showSingleCol'] = current($colList); // The column(s) to show if single mode (under each other)
1000 }
1001 $dblist->tt_contentConfig['cols'] = implode(',',$colList); // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
1002 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
1003 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
1004
1005 // If the function menu is set to "Language":
1006 if ($this->MOD_SETTINGS['function']==2) {
1007 $dblist->tt_contentConfig['single'] = 0;
1008 $dblist->tt_contentConfig['languageMode'] = 1;
1009 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
1010 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
1011 }
1012 break;
1013 }
1014 } else {
1015 $h_func = '';
1016 }
1017
1018 // Start the dblist object:
1019 $dblist->itemsLimitSingleTable = 1000;
1020 $dblist->start($this->id,$table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
1021 $dblist->counter = $CMcounter;
1022 $dblist->ext_function = $this->MOD_SETTINGS['function'];
1023
1024 // Render versioning selector:
1025 $dblist->HTMLcode.= $this->doc->getVersionSelector($this->id);
1026
1027 // Generate the list of elements here:
1028 $dblist->generateList();
1029
1030 // Adding the list content to the tableOutput variable:
1031 $tableOutput[$table]=
1032 ($h_func?$h_func.'<br /><img src="clear.gif" width="1" height="4" alt="" /><br />':'').
1033 $dblist->HTMLcode.
1034 ($h_func_b?'<img src="clear.gif" width="1" height="10" alt="" /><br />'.$h_func_b:'');
1035
1036 // ... and any accumulated JavaScript goes the same way!
1037 $tableJSOutput[$table] = $dblist->JScode;
1038
1039 // Increase global counter:
1040 $CMcounter+= $dblist->counter;
1041
1042 // Reset variables after operation:
1043 $dblist->HTMLcode='';
1044 $dblist->JScode='';
1045 $h_func = '';
1046 $h_func_b = '';
1047 } // END: traverse tables
1048
1049
1050 // For Context Sensitive Menus:
1051 $this->doc->getContextMenuCode();
1052
1053 // Now, create listing based on which element is selected in the function menu:
1054
1055 if ($this->MOD_SETTINGS['function']==3) {
1056
1057 // Making page info:
1058 $content.=$this->doc->spacer(10);
1059 $content.=$this->doc->section($LANG->getLL('pageInformation'),$dblist->getPageInfoBox($this->pageinfo,$this->CALC_PERMS&2),0,1);
1060 } else {
1061
1062 // Add the content for each table we have rendered (traversing $tableOutput variable)
1063 foreach($tableOutput as $table => $output) {
1064 $content.=$this->doc->section('<a name="'.$table.'"></a>'.$dblist->activeTables[$table],$output,TRUE,TRUE,0,TRUE);
1065 $content.=$this->doc->spacer(15);
1066 $content.=$this->doc->sectionEnd();
1067 }
1068
1069 // Making search form:
1070 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
1071 $content.=$this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:labels.search'),$dblist->getSearchBox(),0,1);
1072 }
1073
1074 // Making display of Sys-notes (from extension "sys_note")
1075 $dblist->id=$this->id;
1076 $sysNotes = $dblist->showSysNotesForPage();
1077 if ($sysNotes) {
1078 $content.=$this->doc->spacer(10);
1079 $content.=$this->doc->section($LANG->getLL('internalNotes'),$sysNotes,0,1);
1080 }
1081
1082 // Add spacer in bottom of page:
1083 $content.=$this->doc->spacer(10);
1084 }
1085
1086 // Ending page:
1087 $content.=$this->doc->spacer(10);
1088
1089 return $content;
1090 }
1091
1092 /**
1093 * Print accumulated content of module
1094 *
1095 * @return void
1096 */
1097 function printContent() {
1098 echo $this->content;
1099 }
1100
1101 /***************************
1102 *
1103 * Sub-content functions, rendering specific parts of the module content.
1104 *
1105 ***************************/
1106
1107 /**
1108 * Create the panel of buttons for submitting the form or otherwise perform operations.
1109 *
1110 * @param string Identifier for function of module
1111 * @return array all available buttons as an assoc. array
1112 */
1113 protected function getButtons($function = '') {
1114 global $TCA, $LANG, $BACK_PATH, $BE_USER;
1115
1116 $buttons = array(
1117 'view' => '',
1118 'history_page' => '',
1119 'new_content' => '',
1120 'move_page' => '',
1121 'move_record' => '',
1122 'new_page' => '',
1123 'edit_page' => '',
1124 'record_list' => '',
1125 'csh' => '',
1126 'shortcut' => '',
1127 'cache' => '',
1128 'savedok' => '',
1129 'savedokshow' => '',
1130 'closedok' => '',
1131 'deletedok' => '',
1132 'undo' => '',
1133 'history_record' => ''
1134 );
1135
1136 // View page
1137 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
1138 '<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="" />' .
1139 '</a>';
1140
1141 // Shortcut
1142 if ($BE_USER->mayMakeShortcut()) {
1143 $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']);
1144 }
1145
1146 // Cache
1147 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1148 $buttons['cache'] = '<a href="' . htmlspecialchars('db_layout.php?id=' . $this->pageinfo['uid'] . '&clear_cache=1') . '">' .
1149 '<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="" />' .
1150 '</a>';
1151 }
1152
1153 // If access to Web>List for user, then link to that module.
1154 if ($BE_USER->check('modules','web_list')) {
1155 $href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1156 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
1157 '<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="" />' .
1158 '</a>';
1159 }
1160
1161 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1162
1163 // Page history
1164 $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;') . '">' .
1165 '<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="" />' .
1166 '</a>';
1167 // New content element
1168 $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'))) . '">' .
1169 '<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="" />' .
1170 '</a>';
1171 // Move page
1172 $buttons['move_page'] = '<a href="' . htmlspecialchars($BACK_PATH . 'move_el.php?table=pages&uid=' . $this->id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
1173 '<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="" />' .
1174 '</a>';
1175 // Move record
1176 if (t3lib_div::testInt($this->eRParts[1])) {
1177 $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'))) . '">' .
1178 '<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="" />' .
1179 '</a>';
1180 }
1181 // Create new page (wizard)
1182 $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;') . '">' .
1183 '<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="" />' .
1184 '</a>';
1185 // Edit page properties
1186 if ($this->CALC_PERMS&2) {
1187 $params='&edit[pages][' . $this->id . ']=edit';
1188 $buttons['edit_page'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $BACK_PATH)) . '">' .
1189 '<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="" />' .
1190 '</a>';
1191 }
1192
1193 // Add CSH (Context Sensitive Help) icon to tool bar
1194 if($function == 'quickEdit') {
1195 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit', $BACK_PATH, '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1196 } else {
1197 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $BACK_PATH, '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1198 }
1199
1200 if($function == 'quickEdit') {
1201 // Save record
1202 $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="" />';
1203
1204 // Save record and show page
1205 $buttons['savedokshow'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '">' .
1206 '<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="" />' .
1207 '</a>';
1208
1209 // Close record
1210 $buttons['closedok'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode($this->closeUrl) . '\')); return false;') . '">' .
1211 '<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="" />' .
1212 '</a>';
1213
1214 // Delete record
1215 if($this->deleteButton) {
1216 $buttons['deletedok'] = '<a href="#" onclick="' . htmlspecialchars('return deleteRecord(\'' . $this->eRParts[0] . '\',\'' . $this->eRParts[1] . '\',\'' . t3lib_div::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id . '\');') . '">' .
1217 '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/deletedok.gif','width="21" height="16"') . ' class="c-inputButton" title="' . $LANG->getLL('deleteItem', 1) . '" alt="" />' .
1218 '</a>';
1219 }
1220
1221 if($this->undoButton) {
1222 // Undo button
1223 $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;') . '">' .
1224 '<img' .
1225 t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/undo.gif', 'width="21" height="16"') .
1226 ' class="c-inputButton"' .
1227 ' 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')))) .
1228 '" alt="" />' .
1229 '</a>';
1230
1231 // History button
1232 $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;') . '">' .
1233 '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/history2.gif', 'width="13" height="12"') . ' class="c-inputButton" title="' . $LANG->getLL('recordHistory', 1) . '" alt="" />' .
1234 '</a>';
1235 }
1236 }
1237 }
1238
1239 return $buttons;
1240 }
1241
1242 /*******************************
1243 *
1244 * Other functions
1245 *
1246 ******************************/
1247
1248 /**
1249 * Returns the number of hidden elements (including those hidden by start/end times) on the current page (for the current sys_language)
1250 *
1251 * @return void
1252 */
1253 function getNumberOfHiddenElements() {
1254 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1255 'uid',
1256 'tt_content',
1257 'pid=' . intval($this->id) .
1258 ' AND sys_language_uid=' . intval($this->current_sys_language) .
1259 t3lib_BEfunc::BEenableFields('tt_content', 1) .
1260 t3lib_BEfunc::deleteClause('tt_content') .
1261 t3lib_BEfunc::versioningPlaceholderClause('tt_content')
1262 );
1263 }
1264
1265 /**
1266 * Returns URL to the current script.
1267 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1268 *
1269 * @param array Parameters array, merged with global GET vars.
1270 * @return string URL
1271 */
1272 function local_linkThisScript($params) {
1273 $params['popView']='';
1274 $params['new_unique_uid']='';
1275 return t3lib_div::linkThisScript($params);
1276 }
1277
1278 /**
1279 * Returns a SQL query for selecting sys_language records.
1280 *
1281 * @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)
1282 * @return string Return query string.
1283 */
1284 function exec_languageQuery($id) {
1285 if ($id) {
1286 $exQ = t3lib_BEfunc::deleteClause('pages_language_overlay') . ($GLOBALS['BE_USER']->isAdmin()?'':' AND sys_language.hidden=0');
1287 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1288 'sys_language.*',
1289 'pages_language_overlay,sys_language',
1290 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ,
1291 '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',
1292 'sys_language.title'
1293 );
1294 } else {
1295 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1296 'sys_language.*',
1297 'sys_language',
1298 'sys_language.hidden=0',
1299 '',
1300 'sys_language.title'
1301 );
1302 }
1303 }
1304 }
1305
1306
1307 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']) {
1308 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']);
1309 }
1310
1311
1312 // Make instance:
1313 $SOBE = t3lib_div::makeInstance('SC_db_layout');
1314 $SOBE->init();
1315
1316 // Include files?
1317 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1318
1319 $SOBE->clearCache();
1320 $SOBE->main();
1321 $SOBE->printContent();
1322
1323 ?>