[FEATURE] Hide translated records from List module
[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->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 $dblist->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
234 $dblist->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
235
236 // Clipboard actions are handled:
237 $CB = t3lib_div::_GET('CB'); // CB is the clipboard command array
238 if ($this->cmd=='setCB') {
239 // 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
240 // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
241 $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge((array)t3lib_div::_POST('CBH'),(array)t3lib_div::_POST('CBC')),$this->cmd_table);
242 }
243 if (!$this->MOD_SETTINGS['clipBoard']) $CB['setP']='normal'; // If the clipboard is NOT shown, set the pad to 'normal'.
244 $dblist->clipObj->setCmd($CB); // Execute commands.
245 $dblist->clipObj->cleanCurrent(); // Clean up pad
246 $dblist->clipObj->endClipboard(); // Save the clipboard content
247
248 // This flag will prevent the clipboard panel in being shown.
249 // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
250 $dblist->dontShowClipControlPanels = $GLOBALS['CLIENT']['FORMSTYLE'] && !$this->MOD_SETTINGS['bigControlPanel']
251 && $dblist->clipObj->current=='normal' && !$GLOBALS['BE_USER']->uc['disableCMlayers']
252 && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
253
254
255
256 // If there is access to the page, then render the list contents and set up the document template object:
257 if ($access) {
258
259 // Deleting records...:
260 // 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.
261 if ($this->cmd=='delete') {
262 $items = $dblist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),$this->cmd_table,1);
263 if (count($items)) {
264 $cmd=array();
265 foreach ($items as $iK => $value) {
266 $iKParts = explode('|',$iK);
267 $cmd[$iKParts[0]][$iKParts[1]]['delete']=1;
268 }
269 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
270 $tce->stripslashes_values=0;
271 $tce->start(array(),$cmd);
272 $tce->process_cmdmap();
273
274 if (isset($cmd['pages'])) {
275 t3lib_BEfunc::setUpdateSignal('updatePageTree');
276 }
277
278 $tce->printLogErrorMessages(t3lib_div::getIndpEnv('REQUEST_URI'));
279 }
280 }
281
282 // Initialize the listing object, dblist, for rendering the list:
283 $this->pointer = t3lib_utility_Math::forceIntegerInRange($this->pointer,0,100000);
284 $dblist->start($this->id,$this->table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
285 $dblist->setDispFields();
286
287 // Render versioning selector:
288 if (t3lib_extMgm::isLoaded('version')) {
289 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
290 }
291
292 // Render the list of tables:
293 $dblist->generateList();
294
295 // Write the bottom of the page:
296 $dblist->writeBottom();
297 $listUrl = substr($dblist->listURL(), strlen($GLOBALS['BACK_PATH']));
298 // Add JavaScript functions to the page:
299 $this->doc->JScode=$this->doc->wrapScriptTags('
300 function jumpToUrl(URL) { //
301 window.location.href = URL;
302 return false;
303 }
304 function jumpExt(URL,anchor) { //
305 var anc = anchor?anchor:"";
306 window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
307 return false;
308 }
309 function jumpSelf(URL) { //
310 window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
311 return false;
312 }
313
314 function setHighlight(id) { //
315 top.fsMod.recentIds["web"]=id;
316 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting
317
318 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
319 top.content.nav_frame.refresh_nav();
320 }
321 }
322 ' . $this->doc->redirectUrls($listUrl) . '
323 '.$dblist->CBfunctions().'
324 function editRecords(table,idList,addParams,CBflag) { //
325 window.location.href="' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) .
326 '&edit["+table+"]["+idList+"]=edit"+addParams;
327 }
328 function editList(table,idList) { //
329 var list="";
330
331 // Checking how many is checked, how many is not
332 var pointer=0;
333 var pos = idList.indexOf(",");
334 while (pos!=-1) {
335 if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
336 list+=idList.substr(pointer,pos-pointer)+",";
337 }
338 pointer=pos+1;
339 pos = idList.indexOf(",",pointer);
340 }
341 if (cbValue(table+"|"+idList.substr(pointer))) {
342 list+=idList.substr(pointer)+",";
343 }
344
345 return list ? list : idList;
346 }
347
348 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
349 ');
350
351 // Setting up the context sensitive menu:
352 $this->doc->getContextMenuCode();
353 } // access
354
355 // Begin to compile the whole page, starting out with page header:
356 $this->body='';
357 $this->body.= '<form action="'.htmlspecialchars($dblist->listURL()).'" method="post" name="dblistForm">';
358 $this->body.= $dblist->HTMLcode;
359 $this->body.= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
360
361 // If a listing was produced, create the page footer with search form etc:
362 if ($dblist->HTMLcode) {
363
364 // Making field select box (when extended view for a single table is enabled):
365 if ($dblist->table) {
366 $this->body.=$dblist->fieldSelectBox($dblist->table);
367 }
368
369 // Adding checkbox options for extended listing and clipboard display:
370 $this->body.='
371
372 <!--
373 Listing options for extended view, clipboard and localization view
374 -->
375 <div id="typo3-listOptions">
376 <form action="" method="post">';
377
378 // Add "display bigControlPanel" checkbox:
379 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
380 $this->body .= t3lib_BEfunc::getFuncCheck(
381 $this->id,
382 'SET[bigControlPanel]',
383 $this->MOD_SETTINGS['bigControlPanel'],
384 '',
385 ($this->table ? '&table=' . $this->table : ''),
386 'id="checkLargeControl"'
387 );
388 $this->body .= '<label for="checkLargeControl">' .
389 t3lib_BEfunc::wrapInHelp(
390 'xMOD_csh_corebe',
391 'list_options',
392 $GLOBALS['LANG']->getLL('largeControl', TRUE)
393 ) . '</label><br />';
394 }
395
396 // Add "clipboard" checkbox:
397 if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') {
398 if ($dblist->showClipboard) {
399 $this->body .= t3lib_BEfunc::getFuncCheck(
400 $this->id,
401 'SET[clipBoard]',
402 $this->MOD_SETTINGS['clipBoard'],
403 '',
404 ($this->table ? '&table=' . $this->table : ''),
405 'id="checkShowClipBoard"'
406 );
407 $this->body .= '<label for="checkShowClipBoard">' .
408 t3lib_BEfunc::wrapInHelp(
409 'xMOD_csh_corebe',
410 'list_options',
411 $GLOBALS['LANG']->getLL('showClipBoard', TRUE)
412 ) . '</label><br />';
413 }
414 }
415
416 // Add "localization view" checkbox:
417 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
418 $this->body .= t3lib_BEfunc::getFuncCheck(
419 $this->id,
420 'SET[localization]',
421 $this->MOD_SETTINGS['localization'],
422 '',
423 ($this->table ? '&table=' . $this->table : ''),
424 'id="checkLocalization"'
425 );
426 $this->body .= '<label for="checkLocalization">' .
427 t3lib_BEfunc::wrapInHelp(
428 'xMOD_csh_corebe',
429 'list_options',
430 $GLOBALS['LANG']->getLL('localization', TRUE)
431 ) . '</label><br />';
432 }
433
434 $this->body.='
435 </form>
436 </div>';
437
438 // Printing clipboard if enabled:
439 if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard) {
440 $this->body.= $dblist->clipObj->printClipboard();
441 }
442
443 // Search box:
444 if (!$this->modTSconfig['properties']['disableSearchBox']) {
445 $sectionTitle = t3lib_BEfunc::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search', TRUE));
446 $this->body .= $this->doc->section(
447 $sectionTitle,
448 $dblist->getSearchBox(),
449 FALSE, TRUE, FALSE, TRUE
450 );
451 }
452
453 // Display sys-notes, if any are found:
454 $this->body.=$dblist->showSysNotesForPage();
455 }
456
457 // Setting up the buttons and markers for docheader
458 $docHeaderButtons = $dblist->getButtons();
459 $markers = array(
460 'CSH' => $docHeaderButtons['csh'],
461 'CONTENT' => $this->body
462 );
463
464 // Build the <body> for the module
465 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
466 // Renders the module page
467 $this->content = $this->doc->render(
468 'DB list',
469 $this->content
470 );
471 }
472
473 /**
474 * Outputting the accumulated content to screen
475 *
476 * @return void
477 */
478 function printContent() {
479 echo $this->content;
480 }
481
482 }
483
484
485 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_list.php'])) {
486 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_list.php']);
487 }
488
489
490
491 // Make instance:
492 $SOBE = t3lib_div::makeInstance('SC_db_list');
493 $SOBE->init();
494
495 // Include files?
496 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
497
498 $SOBE->clearCache();
499 $SOBE->main();
500 $SOBE->printContent();
501
502 ?>