[TASK] XLF core locallang files are still referenced with .php/.xml
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / RecordList.php
1 <?php
2 namespace TYPO3\CMS\Recordlist;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Script Class for the Web > List module; rendering the listing of records on a page
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35 class RecordList {
36
37 // Internal, GPvars:
38 // Page Id for which to make the listing
39 /**
40 * @var integer
41 * @todo Define visibility
42 */
43 public $id;
44
45 // Pointer - for browsing list of records.
46 /**
47 * @todo Define visibility
48 */
49 public $pointer;
50
51 // Thumbnails or not
52 /**
53 * @todo Define visibility
54 */
55 public $imagemode;
56
57 // Which table to make extended listing for
58 /**
59 * @todo Define visibility
60 */
61 public $table;
62
63 // Search-fields
64 /**
65 * @todo Define visibility
66 */
67 public $search_field;
68
69 // Search-levels
70 /**
71 * @todo Define visibility
72 */
73 public $search_levels;
74
75 // Show-limit
76 /**
77 * @todo Define visibility
78 */
79 public $showLimit;
80
81 // Return URL
82 /**
83 * @todo Define visibility
84 */
85 public $returnUrl;
86
87 // Clear-cache flag - if set, clears page cache for current id.
88 /**
89 * @todo Define visibility
90 */
91 public $clear_cache;
92
93 // Command: Eg. "delete" or "setCB" (for TCEmain / clipboard operations)
94 /**
95 * @todo Define visibility
96 */
97 public $cmd;
98
99 // Table on which the cmd-action is performed.
100 /**
101 * @todo Define visibility
102 */
103 public $cmd_table;
104
105 // Internal, static:
106 // Page select perms clause
107 /**
108 * @todo Define visibility
109 */
110 public $perms_clause;
111
112 // Module TSconfig
113 /**
114 * @todo Define visibility
115 */
116 public $modTSconfig;
117
118 // Current ids page record
119 /**
120 * @todo Define visibility
121 */
122 public $pageinfo;
123
124 /**
125 * Document template object
126 *
127 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
128 * @todo Define visibility
129 */
130 public $doc;
131
132 // Module configuration
133 /**
134 * @todo Define visibility
135 */
136 public $MCONF = array();
137
138 // Menu configuration
139 /**
140 * @todo Define visibility
141 */
142 public $MOD_MENU = array();
143
144 // Module settings (session variable)
145 /**
146 * @todo Define visibility
147 */
148 public $MOD_SETTINGS = array();
149
150 // Array, where files to include is accumulated in the init() function
151 /**
152 * @todo Define visibility
153 */
154 public $include_once = array();
155
156 // Internal, dynamic:
157 // Module output accumulation
158 /**
159 * @todo Define visibility
160 */
161 public $content;
162
163 /**
164 * Initializing the module
165 *
166 * @return void
167 * @todo Define visibility
168 */
169 public function init() {
170 // Setting module configuration / page select clause
171 $this->MCONF = $GLOBALS['MCONF'];
172 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
173 // GPvars:
174 $this->id = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
175 $this->pointer = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pointer');
176 $this->imagemode = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('imagemode');
177 $this->table = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('table');
178 $this->search_field = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_field');
179 $this->search_levels = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_levels');
180 $this->showLimit = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('showLimit');
181 $this->returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl'));
182 $this->clear_cache = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('clear_cache');
183 $this->cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cmd');
184 $this->cmd_table = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cmd_table');
185 // Initialize menu
186 $this->menuConfig();
187 }
188
189 /**
190 * Initialize function menu array
191 *
192 * @return void
193 * @todo Define visibility
194 */
195 public function menuConfig() {
196 // MENU-ITEMS:
197 $this->MOD_MENU = array(
198 'bigControlPanel' => '',
199 'clipBoard' => '',
200 'localization' => ''
201 );
202 // Loading module configuration:
203 $this->modTSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
204 // Clean up settings:
205 $this->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $this->MCONF['name']);
206 }
207
208 /**
209 * Clears page cache for the current id, $this->id
210 *
211 * @return void
212 * @todo Define visibility
213 */
214 public function clearCache() {
215 if ($this->clear_cache) {
216 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
217 $tce->stripslashes_values = 0;
218 $tce->start(array(), array());
219 $tce->clear_cacheCmd($this->id);
220 }
221 }
222
223 /**
224 * Main function, starting the rendering of the list.
225 *
226 * @return void
227 * @todo Define visibility
228 */
229 public function main() {
230 // Start document template object:
231 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
232 $this->doc->backPath = $GLOBALS['BACK_PATH'];
233 $this->doc->setModuleTemplate('templates/db_list.html');
234 // Loading current page record and checking access:
235 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
236 $access = is_array($this->pageinfo) ? 1 : 0;
237 // Apply predefined values for hidden checkboxes
238 // Set predefined value for DisplayBigControlPanel:
239 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') {
240 $this->MOD_SETTINGS['bigControlPanel'] = TRUE;
241 } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') {
242 $this->MOD_SETTINGS['bigControlPanel'] = FALSE;
243 }
244 // Set predefined value for Clipboard:
245 if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') {
246 $this->MOD_SETTINGS['clipBoard'] = TRUE;
247 } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') {
248 $this->MOD_SETTINGS['clipBoard'] = FALSE;
249 }
250 // Set predefined value for LocalizationView:
251 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') {
252 $this->MOD_SETTINGS['localization'] = TRUE;
253 } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') {
254 $this->MOD_SETTINGS['localization'] = FALSE;
255 }
256 // Initialize the dblist object:
257 /** @var $dblist \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList */
258 $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Recordlist\\RecordList\\DatabaseRecordList');
259 $dblist->backPath = $GLOBALS['BACK_PATH'];
260 $dblist->script = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_list', array(), '');
261 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
262 $dblist->thumbs = $GLOBALS['BE_USER']->uc['thumbnailsByDefault'];
263 $dblist->returnUrl = $this->returnUrl;
264 $dblist->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0;
265 $dblist->localizationView = $this->MOD_SETTINGS['localization'];
266 $dblist->showClipboard = 1;
267 $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
268 $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
269 $dblist->hideTables = $this->modTSconfig['properties']['hideTables'];
270 $dblist->hideTranslations = $this->modTSconfig['properties']['hideTranslations'];
271 $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
272 $dblist->alternateBgColors = $this->modTSconfig['properties']['alternateBgColors'] ? 1 : 0;
273 $dblist->allowedNewTables = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], 1);
274 $dblist->deniedNewTables = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], 1);
275 $dblist->newWizards = $this->modTSconfig['properties']['newWizards'] ? 1 : 0;
276 $dblist->pageRow = $this->pageinfo;
277 $dblist->counter++;
278 $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
279 $dblist->modTSconfig = $this->modTSconfig;
280 $clickTitleMode = trim($this->modTSconfig['properties']['clickTitleMode']);
281 $dblist->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode;
282 // Clipboard is initialized:
283 // Start clipboard
284 $dblist->clipObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
285 // Initialize - reads the clipboard content from the user session
286 $dblist->clipObj->initializeClipboard();
287 // Clipboard actions are handled:
288 // CB is the clipboard command array
289 $CB = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('CB');
290 if ($this->cmd == 'setCB') {
291 // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked.
292 // By merging we get a full array of checked/unchecked elements
293 // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
294 $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge((array) \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('CBH'), (array) \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('CBC')), $this->cmd_table);
295 }
296 if (!$this->MOD_SETTINGS['clipBoard']) {
297 // If the clipboard is NOT shown, set the pad to 'normal'.
298 $CB['setP'] = 'normal';
299 }
300 // Execute commands.
301 $dblist->clipObj->setCmd($CB);
302 // Clean up pad
303 $dblist->clipObj->cleanCurrent();
304 // Save the clipboard content
305 $dblist->clipObj->endClipboard();
306 // This flag will prevent the clipboard panel in being shown.
307 // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
308 $dblist->dontShowClipControlPanels = $GLOBALS['CLIENT']['FORMSTYLE'] && !$this->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
309 // If there is access to the page, then render the list contents and set up the document template object:
310 if ($access) {
311 // Deleting records...:
312 // 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.
313 if ($this->cmd == 'delete') {
314 $items = $dblist->clipObj->cleanUpCBC(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('CBC'), $this->cmd_table, 1);
315 if (count($items)) {
316 $cmd = array();
317 foreach ($items as $iK => $value) {
318 $iKParts = explode('|', $iK);
319 $cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1;
320 }
321 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
322 $tce->stripslashes_values = 0;
323 $tce->start(array(), $cmd);
324 $tce->process_cmdmap();
325 if (isset($cmd['pages'])) {
326 \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
327 }
328 $tce->printLogErrorMessages(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'));
329 }
330 }
331 // Initialize the listing object, dblist, for rendering the list:
332 $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
333 $dblist->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
334 $dblist->setDispFields();
335 // Render versioning selector:
336 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version')) {
337 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
338 }
339 // Render the list of tables:
340 $dblist->generateList();
341 // Write the bottom of the page:
342 $dblist->writeBottom();
343 $listUrl = substr($dblist->listURL(), strlen($GLOBALS['BACK_PATH']));
344 // Add JavaScript functions to the page:
345 $this->doc->JScode = $this->doc->wrapScriptTags('
346 function jumpToUrl(URL) { //
347 window.location.href = URL;
348 return false;
349 }
350 function jumpExt(URL,anchor) { //
351 var anc = anchor?anchor:"";
352 window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
353 return false;
354 }
355 function jumpSelf(URL) { //
356 window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
357 return false;
358 }
359
360 function setHighlight(id) { //
361 top.fsMod.recentIds["web"]=id;
362 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting
363
364 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
365 top.content.nav_frame.refresh_nav();
366 }
367 }
368 ' . $this->doc->redirectUrls($listUrl) . '
369 ' . $dblist->CBfunctions() . '
370 function editRecords(table,idList,addParams,CBflag) { //
371 window.location.href="' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')) . '&edit["+table+"]["+idList+"]=edit"+addParams;
372 }
373 function editList(table,idList) { //
374 var list="";
375
376 // Checking how many is checked, how many is not
377 var pointer=0;
378 var pos = idList.indexOf(",");
379 while (pos!=-1) {
380 if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
381 list+=idList.substr(pointer,pos-pointer)+",";
382 }
383 pointer=pos+1;
384 pos = idList.indexOf(",",pointer);
385 }
386 if (cbValue(table+"|"+idList.substr(pointer))) {
387 list+=idList.substr(pointer)+",";
388 }
389
390 return list ? list : idList;
391 }
392
393 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
394 ');
395 // Setting up the context sensitive menu:
396 $this->doc->getContextMenuCode();
397 }
398 // access
399 // Begin to compile the whole page, starting out with page header:
400 $this->body = $this->doc->header($this->pageinfo['title']);
401 $this->body .= '<form action="' . htmlspecialchars($dblist->listURL()) . '" method="post" name="dblistForm">';
402 $this->body .= $dblist->HTMLcode;
403 $this->body .= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
404 // If a listing was produced, create the page footer with search form etc:
405 if ($dblist->HTMLcode) {
406 // Making field select box (when extended view for a single table is enabled):
407 if ($dblist->table) {
408 $this->body .= $dblist->fieldSelectBox($dblist->table);
409 }
410 // Adding checkbox options for extended listing and clipboard display:
411 $this->body .= '
412
413 <!--
414 Listing options for extended view, clipboard and localization view
415 -->
416 <div id="typo3-listOptions">
417 <form action="" method="post">';
418 // Add "display bigControlPanel" checkbox:
419 if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
420 $this->body .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"');
421 $this->body .= '<label for="checkLargeControl">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('largeControl', TRUE)) . '</label><br />';
422 }
423 // Add "clipboard" checkbox:
424 if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') {
425 if ($dblist->showClipboard) {
426 $this->body .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"');
427 $this->body .= '<label for="checkShowClipBoard">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('showClipBoard', TRUE)) . '</label><br />';
428 }
429 }
430 // Add "localization view" checkbox:
431 if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
432 $this->body .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"');
433 $this->body .= '<label for="checkLocalization">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('localization', TRUE)) . '</label><br />';
434 }
435 $this->body .= '
436 </form>
437 </div>';
438 // Printing clipboard if enabled:
439 if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard) {
440 $this->body .= '<div class="db_list-dashboard">' . $dblist->clipObj->printClipboard() . '</div>';
441 }
442 // Search box:
443 if (!$this->modTSconfig['properties']['disableSearchBox']) {
444 $sectionTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
445 $this->body .= '<div class="db_list-searchbox">' . $this->doc->section($sectionTitle, $dblist->getSearchBox(), FALSE, TRUE, FALSE, TRUE) . '</div>';
446 }
447 // Additional footer content
448 $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/mod1/index.php']['drawFooterHook'];
449 if (is_array($footerContentHook)) {
450 foreach ($footerContentHook as $hook) {
451 $params = array();
452 $this->body .= \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hook, $params, $this);
453 }
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 'EXTRACONTAINERCLASS' => $this->table ? 'singletable' : ''
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('DB list', $this->content);
467 }
468
469 /**
470 * Outputting the accumulated content to screen
471 *
472 * @return void
473 * @todo Define visibility
474 */
475 public function printContent() {
476 echo $this->content;
477 }
478
479 }
480
481
482 ?>