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