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