[TASK] Clean up phpDoc comments in typo3/sysext/
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / db_layout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Module: Web>Page
30 *
31 * This module lets you view a page in a more Content Management like style than the ordinary record-list
32 *
33 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
34 * XHTML compliant
35 *
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 */
38
39 unset($MCONF);
40 require('conf.php');
41 require($BACK_PATH.'init.php');
42 require($BACK_PATH.'template.php');
43 $LANG->includeLLFile('EXT:cms/layout/locallang.xml');
44 require_once(PATH_typo3.'class.db_list.inc');
45 require_once('class.tx_cms_layout.php');
46 $BE_USER->modAccess($MCONF, 1);
47
48 // Will open up records locked by current user. It's assumed that the locking should end if this script is hit.
49 t3lib_BEfunc::lockRecords();
50
51 // Exits if 'cms' extension is not loaded:
52 t3lib_extMgm::isLoaded('cms', 1);
53
54 /**
55 * Local extension of position map class
56 *
57 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
58 * @package TYPO3
59 * @subpackage core
60 */
61 class ext_posMap extends t3lib_positionMap {
62 var $dontPrintPageInsertIcons = 1;
63 var $l_insertNewRecordHere = 'newContentElement';
64
65 /**
66 * Wrapping the title of the record.
67 *
68 * @param string $str The title value.
69 * @param array $row The record row.
70 * @return string Wrapped title string.
71 */
72 function wrapRecordTitle($str, $row) {
73 $aOnClick = 'jumpToUrl(\''.$GLOBALS['SOBE']->local_linkThisScript(array('edit_record'=>'tt_content:'.$row['uid'])).'\');return false;';
74 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$str.'</a>';
75 }
76
77 /**
78 * Wrapping the column header
79 *
80 * @param string $str Header value
81 * @param string $vv Column info.
82 * @return string
83 * @see printRecordMap()
84 */
85 function wrapColumnHeader($str, $vv) {
86 $aOnClick = 'jumpToUrl(\''.$GLOBALS['SOBE']->local_linkThisScript(array('edit_record'=>'_EDIT_COL:'.$vv)).'\');return false;';
87 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$str.'</a>';
88 }
89
90 /**
91 * Create on-click event value.
92 *
93 * @param array $row The record.
94 * @param string $vv Column position value.
95 * @param integer $moveUid Move uid
96 * @param integer $pid PID value.
97 * @param integer $sys_lang System language
98 * @return string
99 */
100 function onClickInsertRecord($row, $vv, $moveUid, $pid, $sys_lang = 0) {
101 if (is_array($row)) {
102 $location = $GLOBALS['SOBE']->local_linkThisScript(array('edit_record'=>'tt_content:new/-'.$row['uid'].'/'.$row['colPos']));
103 } else {
104 $location = $GLOBALS['SOBE']->local_linkThisScript(array('edit_record'=>'tt_content:new/'.$pid.'/'.$vv));
105 }
106 return 'jumpToUrl(\''.$location.'\');return false;';
107 }
108
109 /**
110 * Wrapping the record header (from getRecordHeader())
111 *
112 * @param string $str HTML content
113 * @param array $row Record array.
114 * @return string HTML content
115 */
116 function wrapRecordHeader($str, $row) {
117 if ($row['uid'] == $this->moveUid) {
118 return '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/content_client.gif', 'width="7" height="10"').' alt="" />'.$str;
119 } else {
120 return $str;
121 }
122 }
123 }
124
125 /**
126 * Script Class for Web > Layout module
127 *
128 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
129 * @package TYPO3
130 * @subpackage core
131 */
132 class SC_db_layout {
133
134 // Internal, GPvars:
135 // Page Id for which to make the listing
136 var $id;
137 // Pointer - for browsing list of records.
138 var $pointer;
139 // Thumbnails or not
140 var $imagemode;
141 // Search-fields
142 var $search_field;
143 // Search-levels
144 var $search_levels;
145 // Show-limit
146 var $showLimit;
147 // Return URL
148 var $returnUrl;
149 // Clear-cache flag - if set, clears page cache for current id.
150 var $clear_cache;
151 // PopView id - for opening a window with the page
152 var $popView;
153 // 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).
154 var $edit_record;
155 // 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.
156 var $new_unique_uid;
157
158 // Internal, static:
159 // Page select perms clause
160 var $perms_clause;
161 // Module TSconfig
162 var $modTSconfig;
163 // Current ids page record
164 var $pageinfo;
165
166 /**
167 * Document template object
168 *
169 * @var mediumDoc
170 */
171 var $doc;
172 // Back path of the module
173 var $backPath;
174 // "Pseudo" Description -table name
175 var $descrTable;
176 // List of column-integers to edit. Is set from TSconfig, default is "1,0,2,3"
177 var $colPosList;
178 // Flag: If content can be edited or not.
179 var $EDIT_CONTENT;
180 // Users permissions integer for this page.
181 var $CALC_PERMS;
182 // Currently selected language for editing content elements
183 var $current_sys_language;
184 // Module configuration
185 var $MCONF=array();
186 // Menu configuration
187 var $MOD_MENU=array();
188 // Module settings (session variable)
189 var $MOD_SETTINGS=array();
190 // Array, where files to include is accumulated in the init() function
191 var $include_once=array();
192 // Array of tables to be listed by the Web > Page module in addition to the default tables
193 var $externalTables = array();
194
195 // Internal, dynamic:
196 // Module output accumulation
197 var $content;
198 // Function menu temporary storage
199 var $topFuncMenu;
200 // Temporary storage for page edit icon
201 var $editIcon;
202
203 /**
204 * Initializing the module
205 *
206 * @return void
207 */
208 function init() {
209
210 // Setting module configuration / page select clause
211 $this->MCONF = $GLOBALS['MCONF'];
212 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
213 $this->backPath = $GLOBALS['BACK_PATH'];
214
215 // GPvars:
216 $this->id = intval(t3lib_div::_GP('id'));
217 $this->pointer = t3lib_div::_GP('pointer');
218 $this->imagemode = t3lib_div::_GP('imagemode');
219
220 $this->clear_cache = t3lib_div::_GP('clear_cache');
221 $this->popView = t3lib_div::_GP('popView');
222 $this->edit_record = t3lib_div::_GP('edit_record');
223 $this->new_unique_uid = t3lib_div::_GP('new_unique_uid');
224 $this->search_field = t3lib_div::_GP('search_field');
225 $this->search_levels = t3lib_div::_GP('search_levels');
226 $this->showLimit = t3lib_div::_GP('showLimit');
227 $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
228 $this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
229
230 // Load page info array:
231 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
232
233 // Initialize menu
234 $this->menuConfig();
235
236 // Setting sys language from session var:
237 $this->current_sys_language=intval($this->MOD_SETTINGS['language']);
238
239 // Include scripts: QuickEdit
240 if ($this->MOD_SETTINGS['function']==0) {
241 $this->include_once[]=PATH_t3lib.'class.t3lib_tceforms.php';
242 $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
243 $this->include_once[]=PATH_t3lib.'class.t3lib_loaddbgroup.php';
244 $this->include_once[]=PATH_t3lib.'class.t3lib_transferdata.php';
245 }
246
247 // Include scripts: Clear-cache cmd.
248 if ($this->clear_cache) {
249 $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
250 }
251
252 // CSH / Descriptions:
253 $this->descrTable = '_MOD_'.$this->MCONF['name'];
254 }
255
256 /**
257 * Initialize menu array
258 *
259 * @return void
260 */
261 function menuConfig() {
262 // MENU-ITEMS:
263 $this->MOD_MENU = array(
264 'tt_content_showHidden' => '',
265 'showPalettes' => '',
266 'showDescriptions' => '',
267 'disableRTE' => '',
268 'function' => array(
269 0 => $GLOBALS['LANG']->getLL('m_function_0'),
270 1 => $GLOBALS['LANG']->getLL('m_function_1'),
271 2 => $GLOBALS['LANG']->getLL('m_function_2')
272 ),
273 'language' => array(
274 0 => $GLOBALS['LANG']->getLL('m_default')
275 )
276 );
277
278 // example settings:
279 // $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['tx_myext'] =
280 // array ('default' => array(
281 // 'MENU' => 'LLL:EXT:tx_myext/locallang_db.xml:menuDefault',
282 // 'fList' => 'title,description,image',
283 // 'icon' => TRUE));
284 if (is_array($this->externalTables)) {
285 foreach ($this->externalTables as $table => $tableSettings) {
286 // delete the default settings from above
287 if (is_array($this->MOD_MENU[$table])) {
288 unset ($this->MOD_MENU[$table]);
289 }
290 if (is_array($tableSettings) && count($tableSettings) > 1) {
291 foreach ($tableSettings as $key => $settings) {
292 $this->MOD_MENU[$table][$key] = $GLOBALS['LANG']->sL($settings['MENU']);
293 }
294 }
295 }
296 }
297
298 // 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.
299 $res = $this->exec_languageQuery($this->id);
300 while ($lrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
301 if ($GLOBALS['BE_USER']->checkLanguageAccess($lrow['uid'])) {
302 $this->MOD_MENU['language'][$lrow['uid']] = ($lrow['hidden']?'('.$lrow['title'].')':$lrow['title']);
303 }
304 }
305
306 // Find if there are ANY languages at all (and if not, remove the language option from function menu).
307 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
308 'uid',
309 'sys_language',
310 ($GLOBALS['BE_USER']->isAdmin() ? '' : 'hidden=0')
311 );
312 if (!$count) {
313 unset($this->MOD_MENU['function']['2']);
314 }
315
316 // page/be_user TSconfig settings and blinding of menu-items
317 $this->modSharedTSconfig = t3lib_BEfunc::getModTSconfig($this->id, 'mod.SHARED');
318 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id, 'mod.'.$this->MCONF['name']);
319 if ($this->modTSconfig['properties']['QEisDefault']) ksort($this->MOD_MENU['function']);
320 $this->MOD_MENU['function'] = t3lib_BEfunc::unsetMenuItems($this->modTSconfig['properties'], $this->MOD_MENU['function'], 'menu.function');
321
322 if (!$this->modTSconfig['properties']['disablePageInformation']) {
323 $this->MOD_MENU['function'][3] = $GLOBALS['LANG']->getLL('pageInformation');
324 }
325
326 // Remove QuickEdit as option if page type is not...
327 if (!t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'] . ',6', $this->pageinfo['doktype'])) {
328 unset($this->MOD_MENU['function'][0]);
329 }
330
331 // Setting alternative default label:
332 if (($this->modSharedTSconfig['properties']['defaultLanguageLabel'] || $this->modTSconfig['properties']['defaultLanguageLabel']) && isset($this->MOD_MENU['language'][0])) {
333 $this->MOD_MENU['language'][0] = $this->modTSconfig['properties']['defaultLanguageLabel'] ? $this->modSharedTSconfig['properties']['defaultLanguageLabel'] : $this->modSharedTSconfig['properties']['defaultLanguageLabel'];
334 }
335
336 // Clean up settings
337 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
338
339 // For all elements to be shown in draft workspaces & to also show hidden elements by default if user hasn't disabled the option
340 if (($GLOBALS['BE_USER']->workspace != 0) || ($this->MOD_SETTINGS['tt_content_showHidden'] !== '0')) {
341 $this->MOD_SETTINGS['tt_content_showHidden'] = 1;
342 }
343 }
344
345 /**
346 * Clears page cache for the current id, $this->id
347 *
348 * @return void
349 */
350 function clearCache() {
351 if ($this->clear_cache) {
352 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
353 $tce->stripslashes_values = 0;
354 $tce->start(array(), array());
355 $tce->clear_cacheCmd($this->id);
356 }
357 }
358
359 /**
360 * Main function.
361 * Creates some general objects and calls other functions for the main rendering of module content.
362 *
363 * @return void
364 */
365 function main() {
366 // Access check...
367 // The page will show only if there is a valid page and if this page may be viewed by the user
368 $access = is_array($this->pageinfo) ? 1 : 0;
369 if ($this->id && $access) {
370
371 // Initialize permission settings:
372 $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
373 $this->EDIT_CONTENT = ($this->CALC_PERMS&16) ? 1 : 0;
374
375 // Start document template object:
376 $this->doc = t3lib_div::makeInstance('template');
377 $this->doc->backPath = $GLOBALS['BACK_PATH'];
378 $this->doc->setModuleTemplate('templates/db_layout.html');
379
380 // JavaScript:
381 $this->doc->JScode = '<script type="text/javascript" ' .
382 'src="' . t3lib_div::createVersionNumberedFilename($GLOBALS['BACK_PATH'] . '../t3lib/jsfunc.updateform.js') . '">' .
383 '</script>';
384 $this->doc->JScode.= $this->doc->wrapScriptTags('
385 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
386 if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages'.intval($this->id).'_"+top.fsMod.currentBank; '.intval($this->id).';
387 function jumpToUrl(URL,formEl) { //
388 if (document.editform && TBE_EDITOR.isFormChanged) { // Check if the function exists... (works in all browsers?)
389 if (!TBE_EDITOR.isFormChanged()) { //
390 window.location.href = URL;
391 } else if (formEl) {
392 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
393 }
394 } else window.location.href = URL;
395 }
396 ' . ($this->popView ? t3lib_BEfunc::viewOnClick($this->id, $GLOBALS['BACK_PATH'], t3lib_BEfunc::BEgetRootLine($this->id)) : '') . '
397
398 function deleteRecord(table,id,url) { //
399 if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')) . ')) {
400 window.location.href = "' . $GLOBALS['BACK_PATH'] .
401 'tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC=' . $GLOBALS['BE_USER']->veriCode() .
402 t3lib_BEfunc::getUrlToken('tceAction') . '&prErr=1&uPT=1";
403 }
404 return false;
405 }
406 ');
407 $this->doc->JScode.= $this->doc->wrapScriptTags('
408 var DTM_array = new Array();
409 var DTM_origClass = new String();
410
411 // if tabs are used in a popup window the array might not exists
412 if(!top.DTM_currentTabs) {
413 top.DTM_currentTabs = new Array();
414 }
415
416 function DTM_activate(idBase,index,doToogle) { //
417 // Hiding all:
418 if (DTM_array[idBase]) {
419 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
420 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
421 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
422 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
423 }
424 }
425 }
426
427 // Showing one:
428 if (document.getElementById(idBase+"-"+index+"-DIV")) {
429 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
430 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
431 if(DTM_origClass=="") {
432 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
433 } else {
434 DTM_origClass = "tab";
435 }
436 top.DTM_currentTabs[idBase] = -1;
437 } else {
438 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
439 if(DTM_origClass=="") {
440 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
441 } else {
442 DTM_origClass = "tabact";
443 }
444 top.DTM_currentTabs[idBase] = index;
445 }
446 }
447 }
448 function DTM_toggle(idBase,index,isInit) { //
449 // Showing one:
450 if (document.getElementById(idBase+"-"+index+"-DIV")) {
451 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
452 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
453 if(isInit) {
454 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
455 } else {
456 DTM_origClass = "tab";
457 }
458 top.DTM_currentTabs[idBase+"-"+index] = 0;
459 } else {
460 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
461 if(isInit) {
462 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
463 } else {
464 DTM_origClass = "tabact";
465 }
466 top.DTM_currentTabs[idBase+"-"+index] = 1;
467 }
468 }
469 }
470
471 function DTM_mouseOver(obj) { //
472 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
473 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
474 }
475
476 function DTM_mouseOut(obj) { //
477 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
478 DTM_origClass = "";
479 }
480 ');
481
482 // Setting doc-header
483 $this->doc->form='<form action="'.htmlspecialchars('db_layout.php?id='.$this->id.'&imagemode='.$this->imagemode).'" method="post">';
484
485 // Creating the top function menu:
486 $this->topFuncMenu = t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function'], 'db_layout.php', '');
487 $this->languageMenu = (count($this->MOD_MENU['language'])>1 ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.language', 1) . t3lib_BEfunc::getFuncMenu($this->id, 'SET[language]', $this->current_sys_language, $this->MOD_MENU['language'], 'db_layout.php', '') : '');
488
489 // Find columns
490 // SHARED page-TSconfig settings.
491 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->id, 'mod.SHARED');
492 $this->colPosList = strcmp(trim($this->modTSconfig['properties']['tt_content.']['colPos_list']), '') ? trim($this->modTSconfig['properties']['tt_content.']['colPos_list']) : $modTSconfig_SHARED['properties']['colPos_list'];
493 if (!strcmp($this->colPosList, '')) {
494 $backendLayout = t3lib_div::callUserFunction( 'EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getSelectedBackendLayout', $this->id, $this );
495
496 if (count($backendLayout['__colPosList'])) {
497 $this->colPosList = implode(',', $backendLayout['__colPosList']);
498 }
499 }
500 if (!strcmp($this->colPosList, '')) {
501 $this->colPosList = '1,0,2,3';
502 }
503 // Removing duplicates, if any
504 $this->colPosList = implode(',', array_unique(t3lib_div::intExplode(',', $this->colPosList)));
505
506 // Render the primary module content:
507 if ($this->MOD_SETTINGS['function'] == 0) {
508 // QuickEdit
509 $body = $this->renderQuickEdit();
510 } else {
511 // All other listings
512 $body = $this->renderListContent();
513 }
514
515 // If page is a folder
516 if ($this->pageinfo['doktype'] == 254) {
517
518 // access to list module
519 $moduleLoader = t3lib_div::makeInstance('t3lib_loadModules');
520 $moduleLoader->load($GLOBALS['TBE_MODULES']);
521 $modules = $moduleLoader->modules;
522
523 if (is_array($modules['web']['sub']['list'])) {
524 $flashMessage = t3lib_div::makeInstance(
525 't3lib_FlashMessage',
526 '<p>' . $GLOBALS['LANG']->getLL('goToListModuleMessage') . '</p>
527 <br />
528 <p>' .
529 t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
530 '<a href="javascript:top.goToModule( \'web_list\',1);">' .
531 $GLOBALS['LANG']->getLL('goToListModule') . '
532 </a>
533 </p>',
534 '',
535 t3lib_FlashMessage::INFO
536 );
537 $body = $flashMessage->render() . $body;
538 }
539 }
540
541
542 if ($this->pageinfo['content_from_pid']) {
543 $contentPage = t3lib_BEfunc::getRecord('pages', intval($this->pageinfo['content_from_pid']));
544 $title = t3lib_BEfunc::getRecordTitle('pages', $contentPage);
545 $linkToPid = $this->local_linkThisScript(array('id' => $this->pageinfo['content_from_pid']));
546 $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . intval($this->pageinfo['content_from_pid']) . ')</a>';
547 $flashMessage = t3lib_div::makeInstance(
548 't3lib_FlashMessage',
549 '',
550 sprintf($GLOBALS['LANG']->getLL('content_from_pid_title'), $link),
551 t3lib_FlashMessage::INFO
552 );
553 $body = $flashMessage->render() . $body;
554 }
555
556 // Setting up the buttons and markers for docheader
557 $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function']==0 ? 'quickEdit' : '');
558 $markers = array(
559 'CSH' => $docHeaderButtons['csh'],
560 'TOP_FUNCTION_MENU' => $this->editSelect . $this->topFuncMenu,
561 'LANGSELECTOR' => $this->languageMenu,
562 'CONTENT' => $body
563 );
564
565 // Build the <body> for the module
566 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
567 // Renders the module page
568 $this->content = $this->doc->render(
569 $GLOBALS['LANG']->getLL('title'),
570 $this->content
571 );
572
573 } else {
574
575 // If no access or id value, create empty document:
576 $this->doc = t3lib_div::makeInstance('template');
577 $this->doc->backPath = $GLOBALS['BACK_PATH'];
578 $this->doc->setModuleTemplate('templates/db_layout.html');
579
580 $this->doc->JScode = $this->doc->wrapScriptTags('
581 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
582 ');
583
584 $flashMessage = t3lib_div::makeInstance(
585 't3lib_FlashMessage',
586 $GLOBALS['LANG']->getLL('clickAPage_content'),
587 $GLOBALS['LANG']->getLL('clickAPage_header'),
588 t3lib_FlashMessage::INFO
589 );
590 $body = $flashMessage->render();
591
592 // Setting up the buttons and markers for docheader
593 $docHeaderButtons = array(
594 'view' => '',
595 'history_page' => '',
596 'new_content' => '',
597 'move_page' => '',
598 'move_record' => '',
599 'new_page' => '',
600 'edit_page' => '',
601 'record_list' => '',
602 'csh' => '',
603 'shortcut' => '',
604 'cache' => '',
605 'savedok' => '',
606 'savedokshow' => '',
607 'closedok' => '',
608 'deletedok' => '',
609 'undo' => '',
610 'history_record' => ''
611 );
612
613 $markers = array(
614 'CSH' => t3lib_BEfunc::cshItem($this->descrTable, '', $GLOBALS['BACK_PATH'], '', TRUE),
615 'TOP_FUNCTION_MENU' => '',
616 'LANGSELECTOR' => '',
617 'CONTENT' => $body
618 );
619
620 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
621 // Renders the module page
622 $this->content = $this->doc->render(
623 $GLOBALS['LANG']->getLL('title'),
624 $this->content
625 );
626 }
627 }
628
629 /**
630 * Rendering the quick-edit view.
631 *
632 * @return void
633 */
634 function renderQuickEdit() {
635 // Alternative template
636 $this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
637
638 // Alternative form tag; Quick Edit submits its content to tce_db.php.
639 $this->doc->form = '<form action="' .
640 htmlspecialchars($GLOBALS['BACK_PATH'] . 'tce_db.php?&prErr=1&uPT=1') . '" method="post" enctype="' .
641 $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
642
643 // Setting up the context sensitive menu:
644 $this->doc->getContextMenuCode();
645
646 // Set the edit_record value for internal use in this function:
647 $edit_record = $this->edit_record;
648
649 // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
650 if (substr($edit_record, 0, 9) == '_EDIT_COL') {
651 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
652 '*',
653 'tt_content',
654 'pid=' . intval($this->id) . ' AND colPos=' . intval(substr($edit_record, 10)) . ' AND sys_language_uid=' . intval($this->current_sys_language) .
655 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
656 t3lib_BEfunc::deleteClause('tt_content').
657 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
658 '',
659 'sorting'
660 );
661 $idListA = array();
662 while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
663 $idListA[] = $cRow['uid'];
664 }
665
666 $url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) .
667 ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record'=>'')));
668 t3lib_utility_Http::redirect($url);
669 }
670
671 // If the former record edited was the creation of a NEW record, this will look up the created records uid:
672 if ($this->new_unique_uid) {
673 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
674 '*',
675 'sys_log',
676 'userid=' . intval($GLOBALS['BE_USER']->user['uid']) . ' AND NEWid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->new_unique_uid, 'sys_log')
677 );
678 $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
679 if (is_array($sys_log_row)) {
680 $edit_record=$sys_log_row['tablename'].':'.$sys_log_row['recuid'];
681 }
682 }
683
684
685 // Creating the selector box, allowing the user to select which element to edit:
686 $opt = array();
687 $is_selected = 0;
688 $languageOverlayRecord = '';
689 if ($this->current_sys_language) {
690 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid='.intval($this->current_sys_language));
691 }
692 if (is_array($languageOverlayRecord)) {
693 $inValue = 'pages_language_overlay:'.$languageOverlayRecord['uid'];
694 $is_selected += intval($edit_record==$inValue);
695 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', 1) . ' ]</option>';
696 } else {
697 $inValue = 'pages:'.$this->id;
698 $is_selected += intval($edit_record==$inValue);
699 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', 1) . ' ]</option>';
700 }
701
702 // Selecting all content elements from this language and allowed colPos:
703 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
704 '*',
705 'tt_content',
706 'pid='.intval($this->id).' AND sys_language_uid='.intval($this->current_sys_language).' AND colPos IN ('.$this->colPosList.')'.
707 ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
708 t3lib_Befunc::deleteClause('tt_content').
709 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
710 '',
711 'colPos,sorting'
712 );
713 $colPos = '';
714 $first = 1;
715 // Page is the pid if no record to put this after.
716 $prev = $this->id;
717 while($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
718 t3lib_BEfunc::workspaceOL('tt_content', $cRow);
719
720 if (is_array($cRow)) {
721 if ($first) {
722 if (!$edit_record) {
723 $edit_record='tt_content:'.$cRow['uid'];
724 }
725 $first = 0;
726 }
727 if (strcmp($cRow['colPos'], $colPos)) {
728 $colPos = $cRow['colPos'];
729 $opt[] = '<option value=""></option>';
730 $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'colPos', $colPos), 1) . ':__</option>';
731 }
732 $inValue = 'tt_content:'.$cRow['uid'];
733 $is_selected += intval($edit_record == $inValue);
734 $opt[] = '<option value="' . $inValue . '"' .
735 ($edit_record == $inValue ? ' selected="selected"' : '') .
736 '>' . htmlspecialchars(t3lib_div::fixed_lgd_cs(
737 ($cRow['header']
738 ? $cRow['header']
739 : '[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title') . '] ' . strip_tags($cRow['bodytext'])),
740 $GLOBALS['BE_USER']->uc['titleLen'])
741 ) . '</option>';
742 $prev = -$cRow['uid'];
743 }
744 }
745
746 // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
747 if (!$edit_record) {
748 $edit_record='tt_content:new/'.$prev.'/'.$colPos;
749
750 $inValue = 'tt_content:new/'.$prev.'/'.$colPos;
751 $is_selected += intval($edit_record == $inValue);
752 $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
753 }
754
755 // If none is yet selected...
756 if (!$is_selected) {
757 $opt[] = '<option value=""></option>';
758 $opt[] = '<option value="' . $edit_record . '" selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
759 }
760
761 // Splitting the edit-record cmd value into table/uid:
762 $this->eRParts = explode(':', $edit_record);
763
764 // Delete-button flag?
765 $this->deleteButton = (t3lib_utility_Math::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && (($this->eRParts[0]!='pages' && $this->EDIT_CONTENT) || ($this->eRParts[0]=='pages' && ($this->CALC_PERMS&4))));
766
767 // If undo-button should be rendered (depends on available items in sys_history)
768 $this->undoButton = 0;
769 $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history').' AND recuid='.intval($this->eRParts[1]), '', 'tstamp DESC', '1');
770 if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
771 $this->undoButton = 1;
772 }
773
774 // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
775 $R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
776 $R_URL_getvars = t3lib_div::_GET();
777
778 unset($R_URL_getvars['popView']);
779 unset($R_URL_getvars['new_unique_uid']);
780 $R_URL_getvars['edit_record']=$edit_record;
781 $this->R_URI = $R_URL_parts['path'] . '?' . t3lib_div::implodeArrayForUrl('', $R_URL_getvars);
782
783 // Setting close url/return url for exiting this script:
784 // Goes to 'Columns' view if close is pressed (default)
785 $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
786
787 if ($GLOBALS['BE_USER']->uc['condensedMode']) {
788 $this->closeUrl = $GLOBALS['BACK_PATH'] . 'alt_db_navframe.php';
789 }
790 if ($this->returnUrl) {
791 $this->closeUrl = $this->returnUrl;
792 }
793 // Return-url for JavaScript:
794 $retUrlStr = $this->returnUrl?"+'&returnUrl='+'".rawurlencode($this->returnUrl)."'":'';
795
796 // Drawing the edit record selectbox
797 $this->editSelect = '<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>';
798
799 // Creating editing form:
800 if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record
801 && (($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT) || ($this->eRParts[0] === 'pages' && ($this->CALC_PERMS&1)))) {
802
803 // Splitting uid parts for special features, if new:
804 list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
805
806 // Convert $uidVal to workspace version if any:
807 if ($uidVal != 'new') {
808 if ($draftRecord = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
809 $uidVal = $draftRecord['uid'];
810 }
811 }
812
813 // Initializing transfer-data object:
814 $trData = t3lib_div::makeInstance('t3lib_transferData');
815 $trData->addRawData = TRUE;
816 $trData->defVals[$this->eRParts[0]] = array (
817 'colPos' => intval($ex_colPos),
818 'sys_language_uid' => intval($this->current_sys_language)
819 );
820 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
821 $trData->lockRecords = 1;
822 // 'new'
823 $trData->fetchRecord($this->eRParts[0], ($uidVal=='new'?$this->id:$uidVal), $uidVal);
824
825 // Getting/Making the record:
826 reset($trData->regTableItems_data);
827 $rec = current($trData->regTableItems_data);
828 if ($uidVal == 'new') {
829 $new_unique_uid = uniqid('NEW');
830 $rec['uid'] = $new_unique_uid;
831 $rec['pid'] = intval($ex_pid)?intval($ex_pid):$this->id;
832 $recordAccess = TRUE;
833 } else {
834 $rec['uid'] = $uidVal;
835
836 // Checking internals access:
837 $recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
838 }
839
840 if (!$recordAccess) {
841 // If no edit access, print error message:
842 $content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />' .
843 ($GLOBALS['BE_USER']->errorMsg ? 'Reason: ' . $GLOBALS['BE_USER']->errorMsg . '<br /><br />' : ''), 0, 1);
844 } elseif (is_array($rec)) { // If the record is an array (which it will always be... :-)
845
846 // Create instance of TCEforms, setting defaults:
847 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
848 $tceforms->backPath = $GLOBALS['BACK_PATH'];
849 $tceforms->initDefaultBEMode();
850 $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
851 $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
852 $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
853 $tceforms->enableClickMenu = TRUE;
854
855 // Clipboard is initialized:
856 // Start clipboard
857 $tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
858 // Initialize - reads the clipboard content from the user session
859 $tceforms->clipObj->initializeClipboard();
860
861
862 if ($GLOBALS['BE_USER']->uc['edit_showFieldHelp'] !== 'text' && $this->MOD_SETTINGS['showDescriptions']) {
863 $tceforms->edit_showFieldHelp = 'text';
864 }
865
866 // Render form, wrap it:
867 $panel = '';
868 $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
869 $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
870
871 // Add hidden fields:
872 $theCode = $panel;
873 if ($uidVal == 'new') {
874 $theCode .= '<input type="hidden" name="data['.$this->eRParts[0].']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
875 }
876 $theCode .= '
877 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
878 <input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
879 <input type="hidden" name="edit_record" value="' . $edit_record . '" />
880 <input type="hidden" name="redirect" value="' . htmlspecialchars($uidVal == 'new' ? t3lib_extMgm::extRelPath('cms') . 'layout/db_layout.php?id=' .
881 $this->id . '&new_unique_uid=' . $new_unique_uid . '&returnUrl=' . rawurlencode($this->returnUrl) : $this->R_URI ) . '" />
882 ' . t3lib_TCEforms::getHiddenTokenField('tceAction');
883
884 // Add JavaScript as needed around the form:
885 $theCode=$tceforms->printNeededJSFunctions_top().$theCode.$tceforms->printNeededJSFunctions();
886
887 // Add warning sign if record was "locked":
888 if ($lockInfo = t3lib_BEfunc::isRecordLocked($this->eRParts[0], $rec['uid'])) {
889 $lockedMessage = t3lib_div::makeInstance(
890 't3lib_FlashMessage',
891 htmlspecialchars($lockInfo['msg']),
892 '',
893 t3lib_FlashMessage::WARNING
894 );
895 t3lib_FlashMessageQueue::addMessage($lockedMessage);
896 }
897
898 // Add whole form as a document section:
899 $content .= $this->doc->section('', $theCode);
900 }
901 } else {
902 // If no edit access, print error message:
903 $content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />', 0, 1);
904 }
905
906
907 // Bottom controls (function menus):
908 $q_count = $this->getNumberOfHiddenElements();
909 $h_func_b= t3lib_BEfunc::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], 'db_layout.php', '', 'id="checkTt_content_showHidden"').
910 '<label for="checkTt_content_showHidden">' .
911 (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('hiddenCE', 1)) : $GLOBALS['LANG']->getLL('hiddenCE', 1) .
912 ' (' . $q_count . ')') . '</label>';
913
914 $h_func_b.= '<br />'.
915 t3lib_BEfunc::getFuncCheck($this->id, 'SET[showPalettes]', $this->MOD_SETTINGS['showPalettes'], 'db_layout.php', '', 'id="checkShowPalettes"').
916 '<label for="checkShowPalettes">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes', 1) . '</label>';
917
918 if (t3lib_extMgm::isLoaded('context_help') && $GLOBALS['BE_USER']->uc['edit_showFieldHelp'] !== 'text') {
919 $h_func_b.= '<br />'.
920 t3lib_BEfunc::getFuncCheck($this->id, 'SET[showDescriptions]', $this->MOD_SETTINGS['showDescriptions'], 'db_layout.php', '', 'id="checkShowDescriptions"').
921 '<label for="checkShowDescriptions">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions', 1) . '</label>';
922 }
923
924 if ($GLOBALS['BE_USER']->isRTE()) {
925 $h_func_b.= '<br />'.
926 t3lib_BEfunc::getFuncCheck($this->id, 'SET[disableRTE]', $this->MOD_SETTINGS['disableRTE'], 'db_layout.php', '', 'id="checkDisableRTE"').
927 '<label for="checkDisableRTE">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE', 1) . '</label>';
928 }
929
930 // Add the function menus to bottom:
931 $content.=$this->doc->section('', $h_func_b, 0, 0);
932 $content.=$this->doc->spacer(10);
933
934
935 // Select element matrix:
936 if ($this->eRParts[0]=='tt_content' && t3lib_utility_Math::canBeInterpretedAsInteger($this->eRParts[1])) {
937 $posMap = t3lib_div::makeInstance('ext_posMap');
938 $posMap->backPath = $GLOBALS['BACK_PATH'];
939 $posMap->cur_sys_language=$this->current_sys_language;
940
941 $HTMLcode = '';
942
943 // CSH:
944 $HTMLcode.= t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit_selElement', $GLOBALS['BACK_PATH'], '|<br />');
945
946 $HTMLcode.=$posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
947
948 $content.=$this->doc->spacer(20);
949 $content.=$this->doc->section($GLOBALS['LANG']->getLL('CEonThisPage'), $HTMLcode, 0, 1);
950 $content.=$this->doc->spacer(20);
951 }
952
953 // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
954 if (count($tceforms->commentMessages)) {
955 $content.='
956 <!-- TCEFORM messages
957 '.htmlspecialchars(implode(LF, $tceforms->commentMessages)).'
958 -->
959 ';
960 }
961 return $content;
962 }
963
964 /**
965 * Rendering all other listings than QuickEdit
966 *
967 * @return void
968 */
969 function renderListContent() {
970 // Initialize list object (see "class.db_layout.inc"):
971 /** @var $dblist tx_cms_layout */
972 $dblist = t3lib_div::makeInstance('tx_cms_layout');
973 $dblist->backPath = $GLOBALS['BACK_PATH'];
974 $dblist->thumbs = $this->imagemode;
975 $dblist->no_noWrap = 1;
976 $dblist->descrTable = $this->descrTable;
977
978 $this->pointer = t3lib_utility_Math::forceIntegerInRange($this->pointer, 0, 100000);
979 $dblist->script = 'db_layout.php';
980 $dblist->showIcon = 0;
981 $dblist->setLMargin=0;
982 $dblist->doEdit = $this->EDIT_CONTENT;
983 $dblist->ext_CALC_PERMS = $this->CALC_PERMS;
984
985 $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
986 $dblist->id = $this->id;
987 $dblist->nextThree = t3lib_utility_Math::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10);
988 $dblist->option_showBigButtons = ($this->modTSconfig['properties']['disableBigButtons'] === '0');
989 $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1;
990 $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
991 if (!$dblist->nextThree) {
992 $dblist->nextThree = 1;
993 }
994
995 $dblist->externalTables = $this->externalTables;
996
997 // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
998 $h_menu = $dblist->getTableMenu($this->id);
999
1000 // Initialize other variables:
1001 $h_func = '';
1002 $tableOutput = array();
1003 $tableJSOutput = array();
1004 $CMcounter = 0;
1005
1006 // Traverse the list of table names which has records on this page (that array is populated
1007 // by the $dblist object during the function getTableMenu()):
1008 foreach ($dblist->activeTables as $table => $value) {
1009
1010 // Load full table definitions:
1011 t3lib_div::loadTCA($table);
1012
1013 if (!isset($dblist->externalTables[$table])) {
1014 $q_count = $this->getNumberOfHiddenElements();
1015 $h_func_b = t3lib_BEfunc::getFuncCheck(
1016 $this->id,
1017 'SET[tt_content_showHidden]',
1018 $this->MOD_SETTINGS['tt_content_showHidden'],
1019 'db_layout.php',
1020 '',
1021 'id="checkTt_content_showHidden"'
1022 ) . '<label for="checkTt_content_showHidden">' .
1023 (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('hiddenCE')) : $GLOBALS['LANG']->getLL('hiddenCE') . ' (' . $q_count . ')') . '</label>';
1024 // Boolean: Display up/down arrows and edit icons for tt_content records
1025 $dblist->tt_contentConfig['showCommands'] = 1;
1026 // Boolean: Display info-marks or not
1027 $dblist->tt_contentConfig['showInfo'] = 1;
1028 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown
1029 // in the total width of the page
1030 $dblist->tt_contentConfig['single'] = 0;
1031
1032 if ($this->MOD_SETTINGS['function'] == 4) {
1033 // Grid view
1034 $dblist->tt_contentConfig['showAsGrid'] = 1;
1035 }
1036
1037 // Setting up the tt_content columns to show:
1038 if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) {
1039 $colList = array();
1040 $tcaItems = t3lib_div::callUserFunction( 'EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed', $this->id, $this );
1041 foreach($tcaItems as $temp) {
1042 $colList[] = $temp[1];
1043 }
1044 } else { // ... should be impossible that colPos has no array. But this is the fallback should it make any sense:
1045 $colList = array('1', '0', '2', '3');
1046 }
1047 if (strcmp($this->colPosList, '')) {
1048 $colList = array_intersect(t3lib_div::intExplode(',', $this->colPosList), $colList);
1049 }
1050
1051 // If only one column found, display the single-column view.
1052 if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) {
1053 // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol']
1054 // is shown in the total width of the page
1055 $dblist->tt_contentConfig['single'] = 1;
1056 // The column(s) to show if single mode (under each other)
1057 $dblist->tt_contentConfig['showSingleCol'] = current($colList);
1058 }
1059 // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
1060 $dblist->tt_contentConfig['cols'] = implode(',', $colList);
1061 $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden'];
1062 $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language);
1063
1064 // If the function menu is set to "Language":
1065 if ($this->MOD_SETTINGS['function'] == 2) {
1066 $dblist->tt_contentConfig['single'] = 0;
1067 $dblist->tt_contentConfig['languageMode'] = 1;
1068 $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language'];
1069 $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language;
1070 }
1071 } else {
1072 if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
1073 $h_func = t3lib_BEfunc::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
1074 } else {
1075 $h_func = '';
1076 }
1077 }
1078
1079 // Start the dblist object:
1080 $dblist->itemsLimitSingleTable = 1000;
1081 $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
1082 $dblist->counter = $CMcounter;
1083 $dblist->ext_function = $this->MOD_SETTINGS['function'];
1084
1085 // Render versioning selector:
1086 $dblist->HTMLcode.= $this->doc->getVersionSelector($this->id);
1087
1088 // Generate the list of elements here:
1089 $dblist->generateList();
1090
1091 // Adding the list content to the tableOutput variable:
1092 $tableOutput[$table]=
1093 ($h_func ? $h_func . '<br /><img src="clear.gif" width="1" height="4" alt="" /><br />' : '').
1094 $dblist->HTMLcode.
1095 ($h_func_b ? '<img src="clear.gif" width="1" height="10" alt="" /><br />' . $h_func_b : '');
1096
1097 // ... and any accumulated JavaScript goes the same way!
1098 $tableJSOutput[$table] = $dblist->JScode;
1099
1100 // Increase global counter:
1101 $CMcounter+= $dblist->counter;
1102
1103 // Reset variables after operation:
1104 $dblist->HTMLcode = '';
1105 $dblist->JScode = '';
1106 $h_func = '';
1107 $h_func_b = '';
1108 } // END: traverse tables
1109
1110
1111 // For Context Sensitive Menus:
1112 $this->doc->getContextMenuCode();
1113
1114 $content .= $this->doc->header($this->pageinfo['title']);
1115
1116 // Now, create listing based on which element is selected in the function menu:
1117 if ($this->MOD_SETTINGS['function']==3) {
1118
1119 // Making page info:
1120 $content .= $this->doc->section($GLOBALS['LANG']->getLL('pageInformation'), $dblist->getPageInfoBox($this->pageinfo, $this->CALC_PERMS&2), 0, 1);
1121 } else {
1122
1123 // Add the content for each table we have rendered (traversing $tableOutput variable)
1124 foreach ($tableOutput as $table => $output) {
1125 $content .= $this->doc->section('', $output, TRUE, TRUE, 0, TRUE);
1126 $content .= $this->doc->spacer(15);
1127 $content .= $this->doc->sectionEnd();
1128 }
1129
1130 // Making search form:
1131 if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
1132 $sectionTitle = t3lib_BEfunc::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search', TRUE));
1133 $content .= $this->doc->section(
1134 $sectionTitle,
1135 $dblist->getSearchBox(0),
1136 FALSE, TRUE, FALSE, TRUE
1137 );
1138 }
1139
1140 // Making display of Sys-notes (from extension "sys_note")
1141 $dblist->id=$this->id;
1142 $sysNotes = $dblist->showSysNotesForPage();
1143 if ($sysNotes) {
1144 $content .= $this->doc->spacer(10);
1145 $content .= $this->doc->section($GLOBALS['LANG']->getLL('internalNotes'), $sysNotes, 0, 1);
1146 }
1147
1148 // Add spacer in bottom of page:
1149 $content.=$this->doc->spacer(10);
1150 }
1151
1152 // Ending page:
1153 $content .= $this->doc->spacer(10);
1154
1155 return $content;
1156 }
1157
1158 /**
1159 * Print accumulated content of module
1160 *
1161 * @return void
1162 */
1163 function printContent() {
1164 echo $this->content;
1165 }
1166
1167 /***************************
1168 *
1169 * Sub-content functions, rendering specific parts of the module content.
1170 *
1171 ***************************/
1172
1173 /**
1174 * Create the panel of buttons for submitting the form or otherwise perform operations.
1175 *
1176 * @param string $function Identifier for function of module
1177 * @return array all available buttons as an assoc. array
1178 */
1179 protected function getButtons($function = '') {
1180 $buttons = array(
1181 'view' => '',
1182 'history_page' => '',
1183 'new_content' => '',
1184 'move_page' => '',
1185 'move_record' => '',
1186 'new_page' => '',
1187 'edit_page' => '',
1188 'record_list' => '',
1189 'csh' => '',
1190 'shortcut' => '',
1191 'cache' => '',
1192 'savedok' => '',
1193 'savedokshow' => '',
1194 'closedok' => '',
1195 'deletedok' => '',
1196 'undo' => '',
1197 'history_record' => ''
1198 );
1199
1200 // View page
1201 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
1202 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1203 '</a>';
1204
1205 // Shortcut
1206 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1207 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
1208 }
1209
1210 // Cache
1211 if (!$this->modTSconfig['properties']['disableAdvanced']) {
1212 $buttons['cache'] = '<a href="' . htmlspecialchars('db_layout.php?id=' . $this->pageinfo['uid'] . '&clear_cache=1') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', TRUE) . '">' .
1213 t3lib_iconWorks::getSpriteIcon('actions-system-cache-clear') .
1214 '</a>';
1215 }
1216
1217 // If access to Web>List for user, then link to that module.
1218 $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
1219 array(
1220 'id' => $this->pageinfo['uid'],
1221 'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
1222 ),
1223 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
1224 );
1225
1226 if (!$this->modTSconfig['properties']['disableIconToolbar']) {
1227
1228 // Move record
1229 if (t3lib_utility_Math::canBeInterpretedAsInteger($this->eRParts[1])) {
1230 $buttons['move_record'] = '<a href="' . htmlspecialchars($GLOBALS['BACK_PATH'] . 'move_el.php?table=' . $this->eRParts[0] . '&uid=' . $this->eRParts[1] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
1231 t3lib_iconWorks::getSpriteIcon('actions-' . ($this->eRParts[0] == 'tt_content' ? 'document' : 'page') . '-move', array('class'=>'c-inputButton','title' => $GLOBALS['LANG']->getLL('move_' . ($this->eRParts[0] == 'tt_content' ? 'record' : 'page'), 1))) .
1232 '</a>';
1233 }
1234 // Edit page properties
1235 if ($this->CALC_PERMS&2) {
1236 $params='&edit[pages][' . $this->id . ']=edit';
1237 $buttons['edit_page'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $GLOBALS['BACK_PATH'])) . '" title="' . $GLOBALS['LANG']->getLL('editPageProperties', TRUE) . '">' .
1238 t3lib_iconWorks::getSpriteIcon('actions-page-open') .
1239 '</a>';
1240 }
1241
1242 // Add CSH (Context Sensitive Help) icon to tool bar
1243 if ($function == 'quickEdit') {
1244 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit', $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1245 } else {
1246 $buttons['csh'] = t3lib_BEfunc::cshItem($this->descrTable, 'columns_' . $this->MOD_SETTINGS['function'], $GLOBALS['BACK_PATH'], '', TRUE, 'margin-top: 0px; margin-bottom: 0px;');
1247 }
1248
1249 if ($function == 'quickEdit') {
1250 // Save record
1251 $buttons['savedok'] = '<input class="c-inputButton" type="image" name="savedok"' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/savedok.gif', '') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" alt="" />';
1252
1253 // Save record and show page
1254 $buttons['savedokshow'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow', TRUE) . '">' .
1255 t3lib_iconWorks::getSpriteIcon('actions-document-save-view') .
1256 '</a>';
1257
1258 // Close record
1259 $buttons['closedok'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode($this->closeUrl) . '\')); return false;') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', TRUE) . '">' .
1260 t3lib_iconWorks::getSpriteIcon('actions-document-close') .
1261 '</a>';
1262
1263 // Delete record
1264 if ($this->deleteButton) {
1265 $buttons['deletedok'] = '<a href="#" onclick="' . htmlspecialchars('return deleteRecord(\'' . $this->eRParts[0] . '\',\'' . $this->eRParts[1] . '\',\'' . t3lib_div::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id . '\');') . '" title="' . $GLOBALS['LANG']->getLL('deleteItem', TRUE) . '">' .
1266 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1267 '</a>';
1268 }
1269
1270 if ($this->undoButton) {
1271 // Undo button
1272 $buttons['undo'] = '<a href="#"
1273 onclick="' . htmlspecialchars('window.location.href=\'' . $GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode($this->eRParts[0] . ':' . $this->eRParts[1]) . '&revert=ALL_FIELDS&sumUp=-1&returnUrl=' . rawurlencode($this->R_URI) . '\'; return false;') . '"
1274 title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('undoLastChange'), t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $this->undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '">' .
1275 t3lib_iconWorks::getSpriteIcon('actions-edit-undo') .
1276 '</a>';
1277
1278 // History button
1279 $buttons['history_record'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(\'' . $GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode($this->eRParts[0] . ':' . $this->eRParts[1]) . '&returnUrl=' . rawurlencode($this->R_URI) . '#latest\');return false;') . '" title="' . $GLOBALS['LANG']->getLL('recordHistory', TRUE) . '">' .
1280 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1281 '</a>';
1282 }
1283 }
1284 }
1285
1286 return $buttons;
1287 }
1288
1289 /*******************************
1290 *
1291 * Other functions
1292 *
1293 ******************************/
1294
1295 /**
1296 * Returns the number of hidden elements (including those hidden by start/end times)
1297 * on the current page (for the current sys_language)
1298 *
1299 * @return void
1300 */
1301 function getNumberOfHiddenElements() {
1302 return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1303 'uid',
1304 'tt_content',
1305 'pid=' . intval($this->id) .
1306 ' AND sys_language_uid=' . intval($this->current_sys_language) .
1307 t3lib_BEfunc::BEenableFields('tt_content', 1) .
1308 t3lib_BEfunc::deleteClause('tt_content') .
1309 t3lib_BEfunc::versioningPlaceholderClause('tt_content')
1310 );
1311 }
1312
1313 /**
1314 * Returns URL to the current script.
1315 * In particular the "popView" and "new_unique_uid" Get vars are unset.
1316 *
1317 * @param array $params Parameters array, merged with global GET vars.
1318 * @return string URL
1319 */
1320 function local_linkThisScript($params) {
1321 $params['popView'] = '';
1322 $params['new_unique_uid'] = '';
1323 return t3lib_div::linkThisScript($params);
1324 }
1325
1326 /**
1327 * Returns a SQL query for selecting sys_language records.
1328 *
1329 * @param integer $id 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)
1330 * @return string Return query string.
1331 */
1332 function exec_languageQuery($id) {
1333 if ($id) {
1334 $exQ = t3lib_BEfunc::deleteClause('pages_language_overlay') . ($GLOBALS['BE_USER']->isAdmin()?'':' AND sys_language.hidden=0');
1335 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1336 'sys_language.*',
1337 'pages_language_overlay,sys_language',
1338 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ,
1339 'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.static_lang_isocode,sys_language.flag',
1340 'sys_language.title'
1341 );
1342 } else {
1343 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1344 'sys_language.*',
1345 'sys_language',
1346 'sys_language.hidden=0',
1347 '',
1348 'sys_language.title'
1349 );
1350 }
1351 }
1352 }
1353
1354 // Make instance:
1355 $SOBE = t3lib_div::makeInstance('SC_db_layout');
1356 $SOBE->init();
1357
1358 // Include files?
1359 foreach($SOBE->include_once as $INC_FILE) {
1360 include_once($INC_FILE);
1361 }
1362
1363 $SOBE->clearCache();
1364 $SOBE->main();
1365 $SOBE->printContent();
1366
1367 ?>