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