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