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