7d0a0423432949e8c79c4a60cb57b8aca87a3d36
[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 $LANG->includeLLFile('EXT:cms/layout/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 }
278
279 /**
280 * Initialize menu array
281 *
282 * @return void
283 */
284 function menuConfig() {
285 global $BE_USER,$LANG,$TYPO3_CONF_VARS;
286
287 // MENU-ITEMS:
288 $this->MOD_MENU = array(
289 'tt_board' => array(
290 0 => $LANG->getLL('m_tt_board_0'),
291 'expand' => $LANG->getLL('m_tt_board_expand')
292 ),
293 'tt_address' => array(
294 0 => $LANG->getLL('m_tt_address_0'),
295 1 => $LANG->getLL('m_tt_address_1'),
296 2 => $LANG->getLL('m_tt_address_2')
297 ),
298 'tt_links' => array(
299 0 => $LANG->getLL('m_default'),
300 1 => $LANG->getLL('m_tt_links_1'),
301 2 => $LANG->getLL('m_tt_links_2')
302 ),
303 'tt_calender' => array (
304 0 => $LANG->getLL('m_default'),
305 'date' => $LANG->getLL('m_tt_calender_date'),
306 'date_ext' => $LANG->getLL('m_tt_calender_date_ext'),
307 'todo' => $LANG->getLL('m_tt_calender_todo'),
308 'todo_ext' => $LANG->getLL('m_tt_calender_todo_ext')
309 ),
310 'tt_products' => array (
311 0 => $LANG->getLL('m_default'),
312 'ext' => $LANG->getLL('m_tt_products_ext')
313 ),
314 'tt_content_showHidden' => '',
315 'showPalettes' => '',
316 'showDescriptions' => '',
317 'disableRTE' => '',
318 'function' => array(
319 1 => $LANG->getLL('m_function_1'),
320 0 => $LANG->getLL('m_function_0'),
321 2 => $LANG->getLL('m_function_2'),
322 3 => $LANG->getLL('pageInformation')
323 ),
324 'language' => array(
325 0 => $LANG->getLL('m_default')
326 )
327 );
328
329 // 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.
330 $res = $this->exec_languageQuery($this->id);
331 while($lrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
332 $this->MOD_MENU['language'][$lrow['uid']]=($lrow['hidden']?'('.$lrow['title'].')':$lrow['title']);
333 }
334
335 // Find if there are ANY languages at all (and if not, remove the language option from function menu).
336 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'sys_language', ($BE_USER->isAdmin()?'':'hidden=0'));
337 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
338 unset($this->MOD_MENU['function']['2']);
339 }
340
341 // page/be_user TSconfig settings and blinding of menu-items
342 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
343 if ($this->modTSconfig['properties']['QEisDefault']) ksort($this->MOD_MENU['function']);
344 $this->MOD_MENU['function'] = t3lib_BEfunc::unsetMenuItems($this->modTSconfig['properties'],$this->MOD_MENU['function'],'menu.function');
345
346 // Remove QuickEdit as option if page type is not...
347 if (!t3lib_div::inList($TYPO3_CONF_VARS['FE']['content_doktypes'].',6',$this->pageinfo['doktype'])) {
348 unset($this->MOD_MENU['function'][0]);
349 }
350
351 // Clean up settings
352 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
353 }
354
355 /**
356 * Clears page cache for the current id, $this->id
357 *
358 * @return void
359 */
360 function clearCache() {
361 if ($this->clear_cache) {
362 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
363 $tce->stripslashes_values=0;
364 $tce->start(Array(),Array());
365 $tce->clear_cacheCmd($this->id);
366 }
367 }
368
369 /**
370 * Main function.
371 * Creates some general objects and calls other functions for the main rendering of module content.
372 *
373 * @return void
374 */
375 function main() {
376 global $BE_USER,$LANG,$BACK_PATH;
377
378 // Access check...
379 // The page will show only if there is a valid page and if this page may be viewed by the user
380 $access = is_array($this->pageinfo) ? 1 : 0;
381 if ($this->id && $access) {
382
383 // Initialize permission settings:
384 $this->CALC_PERMS = $BE_USER->calcPerms($this->pageinfo);
385 $this->EDIT_CONTENT = ($this->CALC_PERMS&16) ? 1 : 0;
386
387 // Start document template object:
388 $this->doc = t3lib_div::makeInstance('mediumDoc');
389 $this->doc->backPath = $BACK_PATH;
390 $this->doc->docType='xhtml_trans';
391
392 // JavaScript:
393 $this->doc->JScode = '<script type="text/javascript" src="'.$BACK_PATH.'t3lib/jsfunc.updateform.js"></script>';
394 $this->doc->JScode.= $this->doc->wrapScriptTags('
395 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
396 function jumpToUrl(URL,formEl) { //
397 if (document.editform && document.TBE_EDITOR_isFormChanged) { // Check if the function exists... (works in all browsers?)
398 if (!TBE_EDITOR_isFormChanged()) { //
399 document.location = URL;
400 } else if (formEl) {
401 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
402 }
403 } else document.location = URL;
404 }
405 '.($this->popView ? t3lib_BEfunc::viewOnClick($this->id,$BACK_PATH,t3lib_BEfunc::BEgetRootLine($this->id)) : '').'
406
407 function deleteRecord(table,id,url) { //
408 if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {
409 document.location = "'.$BACK_PATH.'tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
410 }
411 return false;
412 }
413 ');
414
415 // Setting doc-header
416 $this->doc->form='<form action="'.htmlspecialchars('db_layout.php?id='.$this->id.'&imagemode='.$this->imagemode).'" method="post">';
417
418 // Creating the top function menu:
419 $this->topFuncMenu = t3lib_BEfunc::getFuncMenu($this->id,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'],'db_layout.php','').
420 (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','') : '');
421
422 // Creating the top edit page icon:
423 if ($this->CALC_PERMS&2) {
424 $params='&edit[pages]['.$this->id.']=edit';
425 $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>';
426 } else {
427 $this->editIcon='';
428 }
429
430 // Find columns
431 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->id,'mod.SHARED'); // SHARED page-TSconfig settings.
432 $this->colPosList = strcmp(trim($this->modTSconfig['properties']['tt_content.']['colPos_list']),'') ? trim($this->modTSconfig['properties']['tt_content.']['colPos_list']) : $modTSconfig_SHARED['properties']['colPos_list'];
433 $this->colPosList = strcmp($this->colPosList,'')?$this->colPosList:'1,0,2,3';
434 $this->colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$this->colPosList))); // Removing duplicates, if any
435
436
437 // Render the primary module content:
438 if ($this->MOD_SETTINGS['function']==0) {
439 $this->renderQuickEdit(); // QuickEdit
440 } else {
441 $this->renderListContent(); // All other listings
442 }
443
444
445 // ShortCut
446 if ($BE_USER->mayMakeShortcut()) {
447 $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']));
448 }
449
450 // Ending page:
451 $this->content.=$this->doc->spacer(10);
452 $this->content.=$this->doc->endPage();
453 } else {
454
455 // If no access or id value, create empty document:
456 $this->doc = t3lib_div::makeInstance('mediumDoc');
457 $this->doc->docType='xhtml_trans';
458 $this->doc->backPath = $BACK_PATH;
459 $this->doc->JScode = $this->doc->wrapScriptTags('
460 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
461 ');
462 $this->content=$this->doc->startPage($LANG->getLL('title'));
463 $this->content.=$this->doc->section($LANG->getLL('clickAPage_header'),$LANG->getLL('clickAPage_content'),0,1);
464
465 $this->content.= t3lib_BEfunc::cshItem($this->descrTable,'',$BACK_PATH,'<br/><br/>');
466
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_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>';
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
664 // CSH:
665 $toolBar.= t3lib_BEfunc::cshItem($this->descrTable,'quickEdit',$BACK_PATH,'',FALSE,'margin-top: 0px; margin-bottom: 0px;');
666
667 // Setting page header:
668 $hS2 = '
669 <table border="0" cellpadding="0" cellspacing="0" width="460">
670 <tr>
671 <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>
672 <td valign="top" width="1%">'.$this->topFuncMenu.'</td>
673 <td valign="top" width="1%"><img src="clear.gif" width="1" height="3" alt="" /><br />'.$this->editIcon.'</td>
674 </tr>
675 <tr>
676 <td><img src="clear.gif" width="300" height="1" alt="" /></td>
677 <td></td>
678 <td></td>
679 </tr>
680 <tr>
681 <td colspan="3" class="bgColor4">'.$toolBar.'</td>
682 </tr>
683 </table>';
684
685 $content.=$this->doc->startPage($LANG->getLL('title'));
686 $content.=$this->doc->section('',$hS2);
687 $content.=$this->doc->spacer(7);
688
689
690 // Creating editing form:
691 if ($BE_USER->check('tables_modify',$eRParts[0]) && $edit_record && (($eRParts[0]!='pages'&&$this->EDIT_CONTENT) || ($eRParts[0]=='pages'&&($this->CALC_PERMS&1)))) {
692
693 // Splitting uid parts for special features, if new:
694 list($uidVal,$ex_pid,$ex_colPos) = explode('/',$eRParts[1]);
695
696 // Initializing transfer-data object:
697 $trData = t3lib_div::makeInstance('t3lib_transferData');
698 $trData->defVals[$eRParts[0]] = array (
699 'colPos' => intval($ex_colPos),
700 'sys_language_uid' => intval($this->current_sys_language)
701 );
702 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
703 $trData->lockRecords=1;
704 $trData->fetchRecord($eRParts[0],($uidVal=='new'?$this->id:$uidVal),$uidVal); // 'new'
705
706 // Getting/Making the record:
707 reset($trData->regTableItems_data);
708 $rec = current($trData->regTableItems_data);
709 if ($uidVal=='new') {
710 $new_unique_uid = uniqid('NEW');
711 $rec['uid'] = $new_unique_uid;
712 $rec['pid'] = intval($ex_pid)?intval($ex_pid):$this->id;
713 } else {
714 $rec['uid'] = $uidVal;
715 }
716
717 // If the record is an array (which it will always be... :-)
718 if (is_array($rec)) {
719
720 // Create instance of TCEforms, setting defaults:
721 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
722 $tceforms->backPath = $BACK_PATH;
723 $tceforms->initDefaultBEMode();
724 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
725 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
726 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
727 $tceforms->enableClickMenu = TRUE;
728
729 // Clipboard is initialized:
730 $tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
731 $tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
732
733
734 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $tceforms->edit_showFieldHelp='text';
735
736 // Render form, wrap it:
737 $panel='';
738 $panel.=$tceforms->getMainFields($eRParts[0],$rec);
739 $panel=$tceforms->wrapTotal($panel,$rec,$eRParts[0]);
740
741 // Add hidden fields:
742 $theCode=$panel;
743 if ($uidVal=='new') {
744 $theCode.='<input type="hidden" name="data['.$eRParts[0].']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
745 }
746 $theCode.='
747 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />
748 <input type="hidden" name="_disableRTE" value="'.$tceforms->disableRTE.'" />
749 <input type="hidden" name="edit_record" value="'.$edit_record.'" />
750 <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 ).'" />
751 ';
752
753 // Add JavaScript as needed around the form:
754 $theCode=$tceforms->printNeededJSFunctions_top().$theCode.$tceforms->printNeededJSFunctions();
755
756 // Add warning sign if record was "locked":
757 if ($lockInfo=t3lib_BEfunc::isRecordLocked($eRParts[0],$rec['uid'])) {
758 $lockIcon='
759
760 <!--
761 Warning box:
762 -->
763 <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
764 <tr>
765 <td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
766 <td>'.htmlspecialchars($lockInfo['msg']).'</td>
767 </tr>
768 </table>
769 ';
770 } else $lockIcon='';
771
772 // Add whole form as a document section:
773 $content.=$this->doc->section('',$lockIcon.$theCode);
774 }
775 } else {
776 // If no edit access, print error message:
777 $content.=$this->doc->section($LANG->getLL('noAccess'),$LANG->getLL('noAccess_msg').'<br /><br />',0,1);
778 }
779
780
781 // Bottom controls (function menus):
782 $q_count = $this->getNumberOfHiddenElements();
783 $h_func_b= t3lib_BEfunc::getFuncCheck($this->id,'SET[tt_content_showHidden]',$this->MOD_SETTINGS['tt_content_showHidden'],'db_layout.php','').
784 (!$q_count?$GLOBALS['TBE_TEMPLATE']->dfw($LANG->getLL('hiddenCE',1)):$LANG->getLL('hiddenCE',1).' ('.$q_count.')');
785
786 $h_func_b.= '<br />'.
787 t3lib_BEfunc::getFuncCheck($this->id,'SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'db_layout.php','').
788 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1);
789
790 if (t3lib_extMgm::isLoaded('context_help') && $BE_USER->uc['edit_showFieldHelp']!='text') {
791 $h_func_b.= '<br />'.
792 t3lib_BEfunc::getFuncCheck($this->id,'SET[showDescriptions]',$this->MOD_SETTINGS['showDescriptions'],'db_layout.php','').
793 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1);
794 }
795
796 if ($BE_USER->isRTE()) {
797 $h_func_b.= '<br />'.
798 t3lib_BEfunc::getFuncCheck($this->id,'SET[disableRTE]',$this->MOD_SETTINGS['disableRTE'],'db_layout.php','').
799 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1);
800 }
801
802 // Add the function menus to bottom:
803 $content.=$this->doc->section('',$h_func_b,0,0);
804 $content.=$this->doc->spacer(10);
805
806
807 // Select element matrix:
808 if ($eRParts[0]=='tt_content' && t3lib_div::testInt($eRParts[1])) {
809 $posMap = t3lib_div::makeInstance('ext_posMap');
810 $posMap->backPath = $BACK_PATH;
811 $posMap->cur_sys_language=$this->current_sys_language;
812
813 $HTMLcode = '';
814
815 // CSH:
816 $HTMLcode.= t3lib_BEfunc::cshItem($this->descrTable,'quickEdit_selElement',$BACK_PATH,'|<br/>');
817
818 $HTMLcode.=$posMap->printContentElementColumns($this->id,$eRParts[1],$this->colPosList,$this->MOD_SETTINGS['tt_content_showHidden'],$R_URI);
819
820 $HTMLcode.='<br /><br />'.
821 '<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="" />'.
822 $LANG->getLL('move_record',1).
823 '</a>';
824
825 $HTMLcode.='<br /><img src="clear.gif" width="1" height="5" alt="" />';
826 $HTMLcode.='<br />'.
827 '<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'))).'">'.
828 '<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="" />'.
829 $LANG->getLL('newContentElement',1).
830 '</a>';
831
832 $content.=$this->doc->spacer(20);
833 $content.=$this->doc->section($LANG->getLL('CEonThisPage'),$HTMLcode,0,1);
834 $content.=$this->doc->spacer(20);
835 }
836
837 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
838 if (count($tceforms->commentMessages)) {
839 $content.='
840 <!-- TCEFORM messages
841 '.htmlspecialchars(implode(chr(10),$tceforms->commentMessages)).'
842 -->
843 ';
844 }
845
846 // Adding content to internal accumulation variable:
847 $this->content.=$content;
848 }
849
850 /**
851 * Rendering all other listings than QuickEdit
852 *
853 * @return void
854 */
855 function renderListContent() {
856 global $LANG,$BACK_PATH,$TCA;
857
858 // Initialize list object (see "class.db_layout.inc"):
859 $dblist = t3lib_div::makeInstance('tx_cms_layout');
860 $dblist->backPath = $BACK_PATH;
861 $dblist->thumbs = $this->imagemode;
862 $dblist->no_noWrap = 1;
863 $dblist->descrTable = $this->descrTable;
864
865 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
866 $dblist->script = 'db_layout.php';
867 $dblist->showIcon = 0;
868 $dblist->setLMargin=0;
869 $dblist->doEdit = $this->CALC_PERMS&16 ? 1 : 0;
870 $dblist->agePrefixes = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
871 $dblist->id = $this->id;
872 $dblist->nextThree = t3lib_div::intInRange($this->modTSconfig['properties']['editFieldsAtATime'],0,10);
873 $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] ? 0 : 1;
874 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
875 if (!$dblist->nextThree) $dblist->nextThree = 1;
876
877 $dblist->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
878
879
880 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
881 $h_menu = $dblist->getTableMenu($this->id);
882
883 // Initialize other variables:
884 $h_func='';
885 $optionArr=array();
886 $tableOutput=array();
887 $tableJSOutput=array();
888 $CMcounter = 0;
889
890 // Traverse the list of table names which has records on this page (that array is populated by the $dblist object during the function getTableMenu()):
891 reset($dblist->activeTables);
892 while(list($table)=each($dblist->activeTables)) {
893
894 // Load full table definitions:
895 t3lib_div::loadTCA($table);
896
897 if (!isset($dblist->externalTables[$table])) {
898 // Creating special conditions for each table:
899 switch($table) {
900 case 'tt_board':
901 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_board]',$this->MOD_SETTINGS['tt_board'],$this->MOD_MENU['tt_board'],'db_layout.php','');
902 break;
903 case 'tt_address':
904 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_address]',$this->MOD_SETTINGS['tt_address'],$this->MOD_MENU['tt_address'],'db_layout.php','');
905 break;
906 case 'tt_links':
907 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_links]',$this->MOD_SETTINGS['tt_links'],$this->MOD_MENU['tt_links'],'db_layout.php','');
908 break;
909 case 'tt_calender':
910 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_calender]',$this->MOD_SETTINGS['tt_calender'],$this->MOD_MENU['tt_calender'],'db_layout.php','');
911 break;
912 case 'tt_products':
913 $h_func = t3lib_BEfunc::getFuncMenu($this->id,'SET[tt_products]',$this->MOD_SETTINGS['tt_products'],$this->MOD_MENU['tt_products'],'db_layout.php','');
914 break;
915 case 'tt_guest':
916 case 'tt_news':
917 case 'fe_users':
918 // Nothing
919 break;
920 case 'tt_content':
921 $q_count = $this->getNumberOfHiddenElements();
922 $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.')');
923
924 $dblist->tt_contentConfig['showCommands'] = 1; // Boolean: Display up/down arrows and edit icons for tt_content records
925 $dblist->tt_contentConfig['showInfo'] = 1; // Boolean: Display info-marks or not
926 $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
927
928 // Setting up the tt_content columns to show:
929 if (is_array($TCA['tt_content']['columns']['colPos']['config']['items'])) {
930 $colList = array();
931 foreach($TCA['tt_content']['columns']['colPos']['config']['items'] as $temp) {
932 $colList[] = $temp[1];
933 }
934 } else { // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
935 $colList = array('1','0','2','3');
936 }
937 if (strcmp($this->colPosList,'')) {
938 $colList = array_intersect(t3lib_div::intExplode(',',$this->colPosList),$colList);
939 }
940
941 // If only one column found, display the single-column view.
942 if (count($colList)==1) {
943 $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
944 $dblist->tt_contentConfig['showSingleCol'] = current($colList); // The column(s) to show if single mode (under each other)
945 }
946 $dblist->tt_contentConfig['cols'] = implode(',',$colList); // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
947 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
948 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
949
950 // If the function menu is set to "Language":
951 if ($this->MOD_SETTINGS['function']==2) {
952 $dblist->tt_contentConfig['single'] = 0;
953 $dblist->tt_contentConfig['languageMode'] = 1;
954 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
955 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
956 }
957 break;
958 }
959 } else {
960 $h_func = '';
961 }
962
963 // Start the dblist object:
964 $dblist->start($this->id,$table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
965 $dblist->counter = $CMcounter;
966 $dblist->ext_function = $this->MOD_SETTINGS['function'];
967
968 // Generate the list of elements here:
969 $dblist->generateList();
970
971 // Adding the list content to the tableOutput variable:
972 $tableOutput[$table]=
973 ($h_func?$h_func.'<br /><img src="clear.gif" width="1" height="4" alt="" /><br />':'').
974 $dblist->HTMLcode.
975 ($h_func_b?'<img src="clear.gif" width="1" height="10" alt="" /><br />'.$h_func_b:'');
976
977 // ... and any accumulated JavaScript goes the same way!
978 $tableJSOutput[$table] = $dblist->JScode;
979
980 // Increase global counter:
981 $CMcounter+= $dblist->counter;
982
983 // Reset variables after operation:
984 $dblist->HTMLcode='';
985 $dblist->JScode='';
986 $h_func = '';
987 $h_func_b = '';
988 } // END: traverse tables
989
990
991 // For Context Sensitive Menus:
992 $CMparts = $this->doc->getContextMenuCode();
993 $this->doc->bodyTagAdditions = $CMparts[1];
994 $this->doc->JScode.= $CMparts[0];
995 $this->doc->postCode.= $CMparts[2];
996
997
998 // Draw the page header.
999 $headerSection = $this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br />'.
1000 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.
1001 '<span title="'.htmlspecialchars($this->pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-50)).'</span>';
1002
1003
1004 // Create icon "toolbar" for common operations like creating/moving elements/pages etc.
1005 $toolBar='';
1006 // History:
1007 $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;').'">'.
1008 '<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="" />'.
1009 '</a>';
1010 // New content element
1011 $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'))).'">'.
1012 '<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="" />'.
1013 '</a>';
1014 // Move page:
1015 $toolBar.='<a href="'.htmlspecialchars($BACK_PATH.'move_el.php?table=pages&uid='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
1016 '<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="" />'.
1017 '</a>';
1018 // Create new page (wizard):
1019 $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;').'">'.
1020 '<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="" />'.
1021 '</a>';
1022 // Edit page header:
1023 $params='&edit[pages]['.$this->id.']=edit';
1024 $toolBar.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$BACK_PATH)).'">'.
1025 '<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="" />'.
1026 '</a>';
1027
1028 // Add CSH (Context Sensitive Help) icon to tool bar:
1029 $toolBar.= t3lib_BEfunc::cshItem($this->descrTable,'columns_'.$this->MOD_SETTINGS['function'],$BACK_PATH,'',FALSE,'margin-top: 0px; margin-bottom: 0px;');
1030
1031 // Wrap the toolbar into a table:
1032 $headerSection.='
1033 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4">
1034 <tr>
1035 <td>'.$toolBar.'</td>
1036 </tr>
1037 </table>';
1038
1039
1040 // Create menu of table-icons for jumping to table-listing anchor points:
1041 if ($this->MOD_SETTINGS['function']!=3 && count($tableOutput)>1) {
1042 $goToTable_menu = '<td valign="top" width="1%" nowrap="nowrap">'.$h_menu.'</td>';
1043 } else {
1044 $goToTable_menu = '';
1045 }
1046
1047 // Compile the whole header section into a table: Toolbar, Table selector, Function menu(s), Page-edit icon:
1048 $hS2='
1049 <table border="0" cellpadding="0" cellspacing="0" width="100%">
1050 <tr>
1051 <td valign="top" width="99%">'.$headerSection.'</td>
1052 '.$goToTable_menu.'
1053 <td valign="top" width="1%">'.$this->topFuncMenu.'</td>
1054 <td valign="top" align="right" width="1%"><img src="clear.gif" width="1" height="3" alt="" /><br />'.$this->editIcon.'</td>
1055 </tr>
1056 </table>';
1057
1058 // Create page header:
1059 $this->content.=$this->doc->startPage($LANG->getLL('title'));
1060 $this->content.=$this->doc->section('',$hS2);
1061
1062
1063 // Now, create listing based on which element is selected in the function menu:
1064
1065 if ($this->MOD_SETTINGS['function']==3) {
1066
1067 // Making page info:
1068 $this->content.=$this->doc->spacer(10);
1069 $this->content.=$this->doc->section($LANG->getLL('pageInformation'),$dblist->getPageInfoBox($this->pageinfo,$this->CALC_PERMS&2),0,1);
1070 } else {
1071
1072 // Add the content for each table we have rendered (traversing $tableOutput variable)
1073 foreach($tableOutput as $table => $output) {
1074 $this->content.=$this->doc->section('<a name="'.$table.'"></a>'.$dblist->activeTables[$table],$output,TRUE,TRUE,0,TRUE);
1075 $this->content.=$this->doc->spacer(15);
1076 $this->content.=$this->doc->sectionEnd();
1077 }
1078
1079 // Making search form:
1080 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
1081 $this->content.=$this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:labels.search'),$dblist->getSearchBox(),0,1);
1082 }
1083
1084 // Making display of Sys-notes (from extension "sys_note")
1085 $dblist->id=$this->id;
1086 $sysNotes = $dblist->showSysNotesForPage();
1087 if ($sysNotes) {
1088 $this->content.=$this->doc->spacer(10);
1089 $this->content.=$this->doc->section($LANG->getLL('internalNotes'),$sysNotes,0,1);
1090 }
1091
1092 // Display advanced options: Clear cache, new record link etc:
1093 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1094
1095 // Clear cache links:
1096 $af_content = $this->doc->clearCacheMenu($this->id);
1097
1098 // "Create new record" link:
1099 if (!$this->modTSconfig['properties']['noCreateRecordsLink']) {
1100 $af_content.='
1101
1102 <!--
1103 Link for creating a new record:
1104 -->
1105 <div id="typo3-newRecordLink">
1106 <a href="'.htmlspecialchars($BACK_PATH.'db_new.php?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
1107 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/new_el.gif','width="11" height="12"').' alt="" />'.
1108 $LANG->getLL('newRecordGeneral',1).
1109 '</a>
1110 </div>';
1111 }
1112
1113 // Add content of the advanced-options section:
1114 $this->content.=$this->doc->spacer(10);
1115 $this->content.=$this->doc->section($LANG->getLL('advancedFunctions'),$af_content,0,1);
1116 }
1117
1118 // Add spacer in bottom of page:
1119 $this->content.=$this->doc->spacer(10);
1120 }
1121 }
1122
1123 /**
1124 * Print accumulated content of module
1125 *
1126 * @return void
1127 */
1128 function printContent() {
1129 echo $this->content;
1130 }
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144 /*******************************
1145 *
1146 * Other functions
1147 *
1148 ******************************/
1149
1150 /**
1151 * Returns the number of hidden elements (including those hidden by start/end times) on the current page (for the current sys_language)
1152 *
1153 * @return void
1154 */
1155 function getNumberOfHiddenElements() {
1156 $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'));
1157 list($q_count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($q_res);
1158 return $q_count;
1159 }
1160
1161 /**
1162 * Returns URL to the current script.
1163 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1164 *
1165 * @param array Parameters array, merged with global GET vars.
1166 * @return string URL
1167 */
1168 function local_linkThisScript($params) {
1169 $params['popView']='';
1170 $params['new_unique_uid']='';
1171 return t3lib_div::linkThisScript($params);
1172 }
1173
1174 /**
1175 * Returns a SQL query for selecting sys_language records.
1176 *
1177 * @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)
1178 * @return string Return query string.
1179 */
1180 function exec_languageQuery($id) {
1181 $exQ = $GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0';
1182 if ($id) {
1183 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1184 'sys_language.*',
1185 'pages_language_overlay,sys_language',
1186 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ,
1187 'pages_language_overlay.sys_language_uid',
1188 'sys_language.title'
1189 );
1190 } else {
1191 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1192 'sys_language.*',
1193 'sys_language',
1194 'sys_language.hidden=0',
1195 '',
1196 'sys_language.title'
1197 );
1198 }
1199 }
1200 }
1201
1202 // Include extension?
1203 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']) {
1204 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_layout.php']);
1205 }
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218 // Make instance:
1219 $SOBE = t3lib_div::makeInstance('SC_db_layout');
1220 $SOBE->init();
1221
1222 // Include files?
1223 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1224
1225 $SOBE->clearCache();
1226 $SOBE->main();
1227 $SOBE->printContent();
1228 ?>