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