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