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