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