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