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