[TASK] Remove deprecated usages of intInRange, intval_positive and int_from_ver
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / mod1 / index.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 * Module: Web>List
29 *
30 * Listing database records from the tables configured in $GLOBALS['TCA'] as they are related to the current page or root.
31 *
32 * Notice: This module and Web>Page (db_layout.php) module has a special status since they
33 * are NOT located in their actual module directories (fx. mod/web/list/) but in the
34 * backend root directory. This has some historical and practical causes.
35 *
36 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
37 * XHTML compliant
38 *
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 */
41
42
43 $LANG->includeLLFile('EXT:lang/locallang_mod_web_list.xml');
44 require_once ($BACK_PATH.'class.db_list.inc');
45 require_once ($BACK_PATH.'class.db_list_extra.inc');
46 $BE_USER->modAccess($MCONF,1);
47
48 t3lib_BEfunc::lockRecords();
49
50
51
52
53
54
55
56
57 /**
58 * Script Class for the Web > List module; rendering the listing of records on a page
59 *
60 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
61 * @package TYPO3
62 * @subpackage core
63 */
64 class SC_db_list {
65
66 // Internal, GPvars:
67 var $id; // Page Id for which to make the listing
68 var $pointer; // Pointer - for browsing list of records.
69 var $imagemode; // Thumbnails or not
70 var $table; // Which table to make extended listing for
71 var $search_field; // Search-fields
72 var $search_levels; // Search-levels
73 var $showLimit; // Show-limit
74 var $returnUrl; // Return URL
75
76 var $clear_cache; // Clear-cache flag - if set, clears page cache for current id.
77 var $cmd; // Command: Eg. "delete" or "setCB" (for TCEmain / clipboard operations)
78 var $cmd_table; // Table on which the cmd-action is performed.
79
80 // Internal, static:
81 var $perms_clause; // Page select perms clause
82 var $modTSconfig; // Module TSconfig
83 var $pageinfo; // Current ids page record
84
85 /**
86 * Document template object
87 *
88 * @var template
89 */
90 var $doc;
91
92 var $MCONF=array(); // Module configuration
93 var $MOD_MENU=array(); // Menu configuration
94 var $MOD_SETTINGS=array(); // Module settings (session variable)
95 var $include_once=array(); // Array, where files to include is accumulated in the init() function
96
97 // Internal, dynamic:
98 var $content; // Module output accumulation
99
100
101 /**
102 * Initializing the module
103 *
104 * @return void
105 */
106 function init() {
107
108 // Setting module configuration / page select clause
109 $this->MCONF = $GLOBALS['MCONF'];
110 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
111
112 // GPvars:
113 $this->id = t3lib_div::_GP('id');
114 $this->pointer = t3lib_div::_GP('pointer');
115 $this->imagemode = t3lib_div::_GP('imagemode');
116 $this->table = t3lib_div::_GP('table');
117 $this->search_field = t3lib_div::_GP('search_field');
118 $this->search_levels = t3lib_div::_GP('search_levels');
119 $this->showLimit = t3lib_div::_GP('showLimit');
120 $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
121
122 $this->clear_cache = t3lib_div::_GP('clear_cache');
123 $this->cmd = t3lib_div::_GP('cmd');
124 $this->cmd_table = t3lib_div::_GP('cmd_table');
125
126 // Initialize menu
127 $this->menuConfig();
128
129 // Inclusions?
130 if ($this->clear_cache || $this->cmd=='delete') {
131 $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
132 }
133 }
134
135 /**
136 * Initialize function menu array
137 *
138 * @return void
139 */
140 function menuConfig() {
141
142 // MENU-ITEMS:
143 $this->MOD_MENU = array(
144 'bigControlPanel' => '',
145 'clipBoard' => '',
146 'localization' => ''
147 );
148
149 // Loading module configuration:
150 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
151
152 // Clean up settings:
153 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
154 }
155
156 /**
157 * Clears page cache for the current id, $this->id
158 *
159 * @return void
160 */
161 function clearCache() {
162 if ($this->clear_cache) {
163 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
164 $tce->stripslashes_values=0;
165 $tce->start(Array(),Array());
166 $tce->clear_cacheCmd($this->id);
167 }
168 }
169
170 /**
171 * Main function, starting the rendering of the list.
172 *
173 * @return void
174 */
175 function main() {
176 // Start document template object:
177 $this->doc = t3lib_div::makeInstance('template');
178 $this->doc->backPath = $GLOBALS['BACK_PATH'];
179 $this->doc->setModuleTemplate('templates/db_list.html');
180
181 // Loading current page record and checking access:
182 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
183 $access = is_array($this->pageinfo) ? 1 : 0;
184
185 // Apply predefined values for hidden checkboxes
186 // Set predefined value for DisplayBigControlPanel:
187 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') {
188 $this->MOD_SETTINGS['bigControlPanel'] = TRUE;
189 } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') {
190 $this->MOD_SETTINGS['bigControlPanel'] = FALSE;
191 }
192
193 // Set predefined value for Clipboard:
194 if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') {
195 $this->MOD_SETTINGS['clipBoard'] = TRUE;
196 } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') {
197 $this->MOD_SETTINGS['clipBoard'] = FALSE;
198 }
199
200 // Set predefined value for LocalizationView:
201 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') {
202 $this->MOD_SETTINGS['localization'] = TRUE;
203 } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') {
204 $this->MOD_SETTINGS['localization'] = FALSE;
205 }
206
207 // Initialize the dblist object:
208 $dblist = t3lib_div::makeInstance('localRecordList');
209 $dblist->backPath = $GLOBALS['BACK_PATH'];
210 $dblist->script = t3lib_BEfunc::getModuleUrl('web_list', array(), '');
211 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
212 $dblist->thumbs = $GLOBALS['BE_USER']->uc['thumbnailsByDefault'];
213 $dblist->returnUrl=$this->returnUrl;
214 $dblist->allFields = ($this->MOD_SETTINGS['bigControlPanel'] || $this->table) ? 1 : 0;
215 $dblist->localizationView = $this->MOD_SETTINGS['localization'];
216 $dblist->showClipboard = 1;
217 $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
218 $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
219 $dblist->hideTables = $this->modTSconfig['properties']['hideTables'];
220 $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
221 $dblist->clickTitleMode = $this->modTSconfig['properties']['clickTitleMode'];
222 $dblist->alternateBgColors=$this->modTSconfig['properties']['alternateBgColors']?1:0;
223 $dblist->allowedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], 1);
224 $dblist->deniedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], 1);
225 $dblist->newWizards=$this->modTSconfig['properties']['newWizards']?1:0;
226 $dblist->pageRow = $this->pageinfo;
227 $dblist->counter++;
228 $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
229 $dblist->modTSconfig = $this->modTSconfig;
230
231 // Clipboard is initialized:
232 $dblist->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
233 $dblist->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
234
235 // Clipboard actions are handled:
236 $CB = t3lib_div::_GET('CB'); // CB is the clipboard command array
237 if ($this->cmd=='setCB') {
238 // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked. By merging we get a full array of checked/unchecked elements
239 // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
240 $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge((array)t3lib_div::_POST('CBH'),(array)t3lib_div::_POST('CBC')),$this->cmd_table);
241 }
242 if (!$this->MOD_SETTINGS['clipBoard']) $CB['setP']='normal'; // If the clipboard is NOT shown, set the pad to 'normal'.
243 $dblist->clipObj->setCmd($CB); // Execute commands.
244 $dblist->clipObj->cleanCurrent(); // Clean up pad
245 $dblist->clipObj->endClipboard(); // Save the clipboard content
246
247 // This flag will prevent the clipboard panel in being shown.
248 // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
249 $dblist->dontShowClipControlPanels = $GLOBALS['CLIENT']['FORMSTYLE'] && !$this->MOD_SETTINGS['bigControlPanel']
250 && $dblist->clipObj->current=='normal' && !$GLOBALS['BE_USER']->uc['disableCMlayers']
251 && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
252
253
254
255 // If there is access to the page, then render the list contents and set up the document template object:
256 if ($access) {
257
258 // Deleting records...:
259 // Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table.
260 if ($this->cmd=='delete') {
261 $items = $dblist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),$this->cmd_table,1);
262 if (count($items)) {
263 $cmd=array();
264 foreach ($items as $iK => $value) {
265 $iKParts = explode('|',$iK);
266 $cmd[$iKParts[0]][$iKParts[1]]['delete']=1;
267 }
268 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
269 $tce->stripslashes_values=0;
270 $tce->start(array(),$cmd);
271 $tce->process_cmdmap();
272
273 if (isset($cmd['pages'])) {
274 t3lib_BEfunc::setUpdateSignal('updatePageTree');
275 }
276
277 $tce->printLogErrorMessages(t3lib_div::getIndpEnv('REQUEST_URI'));
278 }
279 }
280
281 // Initialize the listing object, dblist, for rendering the list:
282 $this->pointer = t3lib_utility_Math::forceIntegerInRange($this->pointer,0,100000);
283 $dblist->start($this->id,$this->table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
284 $dblist->setDispFields();
285
286 // Render versioning selector:
287 if (t3lib_extMgm::isLoaded('version')) {
288 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
289 }
290
291 // Render the list of tables:
292 $dblist->generateList();
293
294 // Write the bottom of the page:
295 $dblist->writeBottom();
296 $listUrl = substr($dblist->listURL(), strlen($GLOBALS['BACK_PATH']));
297 // Add JavaScript functions to the page:
298 $this->doc->JScode=$this->doc->wrapScriptTags('
299 function jumpToUrl(URL) { //
300 window.location.href = URL;
301 return false;
302 }
303 function jumpExt(URL,anchor) { //
304 var anc = anchor?anchor:"";
305 window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
306 return false;
307 }
308 function jumpSelf(URL) { //
309 window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
310 return false;
311 }
312
313 function setHighlight(id) { //
314 top.fsMod.recentIds["web"]=id;
315 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting
316
317 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
318 top.content.nav_frame.refresh_nav();
319 }
320 }
321 ' . $this->doc->redirectUrls($listUrl) . '
322 '.$dblist->CBfunctions().'
323 function editRecords(table,idList,addParams,CBflag) { //
324 window.location.href="' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) .
325 '&edit["+table+"]["+idList+"]=edit"+addParams;
326 }
327 function editList(table,idList) { //
328 var list="";
329
330 // Checking how many is checked, how many is not
331 var pointer=0;
332 var pos = idList.indexOf(",");
333 while (pos!=-1) {
334 if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
335 list+=idList.substr(pointer,pos-pointer)+",";
336 }
337 pointer=pos+1;
338 pos = idList.indexOf(",",pointer);
339 }
340 if (cbValue(table+"|"+idList.substr(pointer))) {
341 list+=idList.substr(pointer)+",";
342 }
343
344 return list ? list : idList;
345 }
346
347 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
348 ');
349
350 // Setting up the context sensitive menu:
351 $this->doc->getContextMenuCode();
352 } // access
353
354 // Begin to compile the whole page, starting out with page header:
355 $this->body='';
356 $this->body.= '<form action="'.htmlspecialchars($dblist->listURL()).'" method="post" name="dblistForm">';
357 $this->body.= $dblist->HTMLcode;
358 $this->body.= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
359
360 // If a listing was produced, create the page footer with search form etc:
361 if ($dblist->HTMLcode) {
362
363 // Making field select box (when extended view for a single table is enabled):
364 if ($dblist->table) {
365 $this->body.=$dblist->fieldSelectBox($dblist->table);
366 }
367
368 // Adding checkbox options for extended listing and clipboard display:
369 $this->body.='
370
371 <!--
372 Listing options for extended view, clipboard and localization view
373 -->
374 <div id="typo3-listOptions">
375 <form action="" method="post">';
376
377 // Add "display bigControlPanel" checkbox:
378 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
379 $this->body .= t3lib_BEfunc::getFuncCheck(
380 $this->id,
381 'SET[bigControlPanel]',
382 $this->MOD_SETTINGS['bigControlPanel'],
383 '',
384 ($this->table ? '&table=' . $this->table : ''),
385 'id="checkLargeControl"'
386 );
387 $this->body .= '<label for="checkLargeControl">' .
388 t3lib_BEfunc::wrapInHelp(
389 'xMOD_csh_corebe',
390 'list_options',
391 $GLOBALS['LANG']->getLL('largeControl', TRUE)
392 ) . '</label><br />';
393 }
394
395 // Add "clipboard" checkbox:
396 if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') {
397 if ($dblist->showClipboard) {
398 $this->body .= t3lib_BEfunc::getFuncCheck(
399 $this->id,
400 'SET[clipBoard]',
401 $this->MOD_SETTINGS['clipBoard'],
402 '',
403 ($this->table ? '&table=' . $this->table : ''),
404 'id="checkShowClipBoard"'
405 );
406 $this->body .= '<label for="checkShowClipBoard">' .
407 t3lib_BEfunc::wrapInHelp(
408 'xMOD_csh_corebe',
409 'list_options',
410 $GLOBALS['LANG']->getLL('showClipBoard', TRUE)
411 ) . '</label><br />';
412 }
413 }
414
415 // Add "localization view" checkbox:
416 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
417 $this->body .= t3lib_BEfunc::getFuncCheck(
418 $this->id,
419 'SET[localization]',
420 $this->MOD_SETTINGS['localization'],
421 '',
422 ($this->table ? '&table=' . $this->table : ''),
423 'id="checkLocalization"'
424 );
425 $this->body .= '<label for="checkLocalization">' .
426 t3lib_BEfunc::wrapInHelp(
427 'xMOD_csh_corebe',
428 'list_options',
429 $GLOBALS['LANG']->getLL('localization', TRUE)
430 ) . '</label><br />';
431 }
432
433 $this->body.='
434 </form>
435 </div>';
436
437 // Printing clipboard if enabled:
438 if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard) {
439 $this->body.= $dblist->clipObj->printClipboard();
440 }
441
442 // Search box:
443 if (!$this->modTSconfig['properties']['disableSearchBox']) {
444 $sectionTitle = t3lib_BEfunc::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search', TRUE));
445 $this->body .= $this->doc->section(
446 $sectionTitle,
447 $dblist->getSearchBox(),
448 FALSE, TRUE, FALSE, TRUE
449 );
450 }
451
452 // Display sys-notes, if any are found:
453 $this->body.=$dblist->showSysNotesForPage();
454 }
455
456 // Setting up the buttons and markers for docheader
457 $docHeaderButtons = $dblist->getButtons();
458 $markers = array(
459 'CSH' => $docHeaderButtons['csh'],
460 'CONTENT' => $this->body
461 );
462
463 // Build the <body> for the module
464 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
465 // Renders the module page
466 $this->content = $this->doc->render(
467 'DB list',
468 $this->content
469 );
470 }
471
472 /**
473 * Outputting the accumulated content to screen
474 *
475 * @return void
476 */
477 function printContent() {
478 echo $this->content;
479 }
480
481 }
482
483
484 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_list.php'])) {
485 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_list.php']);
486 }
487
488
489
490 // Make instance:
491 $SOBE = t3lib_div::makeInstance('SC_db_list');
492 $SOBE->init();
493
494 // Include files?
495 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
496
497 $SOBE->clearCache();
498 $SOBE->main();
499 $SOBE->printContent();
500
501 ?>