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