TYPO3 CMS  TYPO3_6-2
RecordList.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Recordlist;
3 
19 
25 class RecordList {
26 
27  // Internal, GPvars:
28  // Page Id for which to make the listing
33  public $id;
34 
35  // Pointer - for browsing list of records.
39  public $pointer;
40 
41  // Thumbnails or not
45  public $imagemode;
46 
47  // Which table to make extended listing for
51  public $table;
52 
53  // Search-fields
57  public $search_field;
58 
59  // Search-levels
64 
65  // Show-limit
69  public $showLimit;
70 
71  // Return URL
75  public $returnUrl;
76 
77  // Clear-cache flag - if set, clears page cache for current id.
81  public $clear_cache;
82 
83  // Command: Eg. "delete" or "setCB" (for TCEmain / clipboard operations)
87  public $cmd;
88 
89  // Table on which the cmd-action is performed.
93  public $cmd_table;
94 
95  // Internal, static:
96  // Page select perms clause
101 
102  // Module TSconfig
106  public $modTSconfig;
107 
108  // Current ids page record
112  public $pageinfo;
113 
120  public $doc;
121 
122  // Module configuration
126  public $MCONF = array();
127 
128  // Menu configuration
132  public $MOD_MENU = array();
133 
134  // Module settings (session variable)
138  public $MOD_SETTINGS = array();
139 
140  // Internal, dynamic:
141  // Module output accumulation
145  public $content;
146 
150  public function __construct() {
151  $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_list.xlf');
152  $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1);
153  }
154 
161  public function init() {
162  // Setting module configuration / page select clause
163  $this->MCONF = $GLOBALS['MCONF'];
164  $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
165  // GPvars:
166  $this->id = (int)GeneralUtility::_GP('id');
167  $this->pointer = GeneralUtility::_GP('pointer');
168  $this->imagemode = GeneralUtility::_GP('imagemode');
169  $this->table = GeneralUtility::_GP('table');
170  $this->search_field = GeneralUtility::_GP('search_field');
171  $this->search_levels = (int)GeneralUtility::_GP('search_levels');
172  $this->showLimit = GeneralUtility::_GP('showLimit');
173  $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
174  $this->clear_cache = GeneralUtility::_GP('clear_cache');
175  $this->cmd = GeneralUtility::_GP('cmd');
176  $this->cmd_table = GeneralUtility::_GP('cmd_table');
177  // Initialize menu
178  $this->menuConfig();
179  }
180 
187  public function menuConfig() {
188  // MENU-ITEMS:
189  $this->MOD_MENU = array(
190  'bigControlPanel' => '',
191  'clipBoard' => '',
192  'localization' => ''
193  );
194  // Loading module configuration:
195  $this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
196  // Clean up settings:
197  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']);
198  }
199 
206  public function clearCache() {
207  if ($this->clear_cache) {
208  $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
209  $tce->stripslashes_values = 0;
210  $tce->start(array(), array());
211  $tce->clear_cacheCmd($this->id);
212  }
213  }
214 
221  public function main() {
222  // Start document template object:
223  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
224  $this->doc->backPath = $GLOBALS['BACK_PATH'];
225  $this->doc->setModuleTemplate('EXT:recordlist/Resources/Private/Templates/db_list.html');
226  // Loading current page record and checking access:
227  $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
228  $access = is_array($this->pageinfo) ? 1 : 0;
229  // Apply predefined values for hidden checkboxes
230  // Set predefined value for DisplayBigControlPanel:
231  if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') {
232  $this->MOD_SETTINGS['bigControlPanel'] = TRUE;
233  } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') {
234  $this->MOD_SETTINGS['bigControlPanel'] = FALSE;
235  }
236  // Set predefined value for Clipboard:
237  if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') {
238  $this->MOD_SETTINGS['clipBoard'] = TRUE;
239  } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') {
240  $this->MOD_SETTINGS['clipBoard'] = FALSE;
241  }
242  // Set predefined value for LocalizationView:
243  if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') {
244  $this->MOD_SETTINGS['localization'] = TRUE;
245  } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') {
246  $this->MOD_SETTINGS['localization'] = FALSE;
247  }
248  // Initialize the dblist object:
250  $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Recordlist\\RecordList\\DatabaseRecordList');
251  $dblist->backPath = $GLOBALS['BACK_PATH'];
252  $dblist->script = BackendUtility::getModuleUrl('web_list', array(), '');
253  $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
254  $dblist->thumbs = $GLOBALS['BE_USER']->uc['thumbnailsByDefault'];
255  $dblist->returnUrl = $this->returnUrl;
256  $dblist->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0;
257  $dblist->localizationView = $this->MOD_SETTINGS['localization'];
258  $dblist->showClipboard = 1;
259  $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
260  $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
261  $dblist->hideTables = $this->modTSconfig['properties']['hideTables'];
262  $dblist->hideTranslations = $this->modTSconfig['properties']['hideTranslations'];
263  $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
264  $dblist->alternateBgColors = $this->modTSconfig['properties']['alternateBgColors'] ? 1 : 0;
265  $dblist->allowedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], TRUE);
266  $dblist->deniedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], TRUE);
267  $dblist->newWizards = $this->modTSconfig['properties']['newWizards'] ? 1 : 0;
268  $dblist->pageRow = $this->pageinfo;
269  $dblist->counter++;
270  $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
271  $dblist->modTSconfig = $this->modTSconfig;
272  $clickTitleMode = trim($this->modTSconfig['properties']['clickTitleMode']);
273  $dblist->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode;
274  // Clipboard is initialized:
275  // Start clipboard
276  $dblist->clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
277  // Initialize - reads the clipboard content from the user session
278  $dblist->clipObj->initializeClipboard();
279  // Clipboard actions are handled:
280  // CB is the clipboard command array
281  $CB = GeneralUtility::_GET('CB');
282  if ($this->cmd == 'setCB') {
283  // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked.
284  // By merging we get a full array of checked/unchecked elements
285  // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
286  $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array)GeneralUtility::_POST('CBC')), $this->cmd_table);
287  }
288  if (!$this->MOD_SETTINGS['clipBoard']) {
289  // If the clipboard is NOT shown, set the pad to 'normal'.
290  $CB['setP'] = 'normal';
291  }
292  // Execute commands.
293  $dblist->clipObj->setCmd($CB);
294  // Clean up pad
295  $dblist->clipObj->cleanCurrent();
296  // Save the clipboard content
297  $dblist->clipObj->endClipboard();
298  // This flag will prevent the clipboard panel in being shown.
299  // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
300  $dblist->dontShowClipControlPanels = (!$this->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers']);
301  // If there is access to the page or root page is used for searching, then render the list contents and set up the document template object:
302  if ($access || ($this->id === 0 && $this->search_levels > 0 && strlen($this->search_field) > 0)) {
303  // Deleting records...:
304  // 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.
305  if ($this->cmd == 'delete') {
306  $items = $dblist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), $this->cmd_table, 1);
307  if (count($items)) {
308  $cmd = array();
309  foreach ($items as $iK => $value) {
310  $iKParts = explode('|', $iK);
311  $cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1;
312  }
313  $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
314  $tce->stripslashes_values = 0;
315  $tce->start(array(), $cmd);
316  $tce->process_cmdmap();
317  if (isset($cmd['pages'])) {
318  BackendUtility::setUpdateSignal('updatePageTree');
319  }
320  $tce->printLogErrorMessages(GeneralUtility::getIndpEnv('REQUEST_URI'));
321  }
322  }
323  // Initialize the listing object, dblist, for rendering the list:
324  $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
325  $dblist->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
326  $dblist->setDispFields();
327  // Render versioning selector:
328  if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version')) {
329  $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
330  }
331  // Render the list of tables:
332  $dblist->generateList();
333  $listUrl = substr($dblist->listURL(), strlen($GLOBALS['BACK_PATH']));
334  // Add JavaScript functions to the page:
335  $this->doc->JScode = $this->doc->wrapScriptTags('
336  function jumpExt(URL,anchor) { //
337  var anc = anchor?anchor:"";
338  window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
339  return false;
340  }
341  function jumpSelf(URL) { //
342  window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
343  return false;
344  }
345 
346  function setHighlight(id) { //
347  top.fsMod.recentIds["web"]=id;
348  top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting
349 
350  if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
351  top.content.nav_frame.refresh_nav();
352  }
353  }
354  ' . $this->doc->redirectUrls($listUrl) . '
355  ' . $dblist->CBfunctions() . '
356  function editRecords(table,idList,addParams,CBflag) { //
357  window.location.href="' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '&edit["+table+"]["+idList+"]=edit"+addParams;
358  }
359  function editList(table,idList) { //
360  var list="";
361 
362  // Checking how many is checked, how many is not
363  var pointer=0;
364  var pos = idList.indexOf(",");
365  while (pos!=-1) {
366  if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
367  list+=idList.substr(pointer,pos-pointer)+",";
368  }
369  pointer=pos+1;
370  pos = idList.indexOf(",",pointer);
371  }
372  if (cbValue(table+"|"+idList.substr(pointer))) {
373  list+=idList.substr(pointer)+",";
374  }
375 
376  return list ? list : idList;
377  }
378 
379  if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';
380  ');
381  // Setting up the context sensitive menu:
382  $this->doc->getContextMenuCode();
383  }
384  // access
385  // Begin to compile the whole page, starting out with page header:
386  $this->body = $this->doc->header($this->pageinfo['title']);
387  $this->body .= '<form action="' . htmlspecialchars($dblist->listURL()) . '" method="post" name="dblistForm">';
388  $this->body .= $dblist->HTMLcode;
389  $this->body .= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
390  // If a listing was produced, create the page footer with search form etc:
391  if ($dblist->HTMLcode) {
392  // Making field select box (when extended view for a single table is enabled):
393  if ($dblist->table) {
394  $this->body .= $dblist->fieldSelectBox($dblist->table);
395  }
396  // Adding checkbox options for extended listing and clipboard display:
397  $this->body .= '
398 
399  <!--
400  Listing options for extended view, clipboard and localization view
401  -->
402  <div id="typo3-listOptions">
403  <form action="" method="post">';
404  // Add "display bigControlPanel" checkbox:
405  if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
406  $this->body .= BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"');
407  $this->body .= '<label for="checkLargeControl">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('largeControl', TRUE)) . '</label><br />';
408  }
409  // Add "clipboard" checkbox:
410  if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') {
411  if ($dblist->showClipboard) {
412  $this->body .= BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"');
413  $this->body .= '<label for="checkShowClipBoard">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('showClipBoard', TRUE)) . '</label><br />';
414  }
415  }
416  // Add "localization view" checkbox:
417  if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
418  $this->body .= BackendUtility::getFuncCheck($this->id, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"');
419  $this->body .= '<label for="checkLocalization">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('localization', TRUE)) . '</label><br />';
420  }
421  $this->body .= '
422  </form>
423  </div>';
424  }
425  // Printing clipboard if enabled
426  if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard && ($dblist->HTMLcode || $dblist->clipObj->hasElements())) {
427  $this->body .= '<div class="db_list-dashboard">' . $dblist->clipObj->printClipboard() . '</div>';
428  }
429  // Search box:
430  if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || $dblist->searchString !== '')) {
431  $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
432  $this->body .= '<div class="db_list-searchbox">' . $this->doc->section($sectionTitle, $dblist->getSearchBox(), FALSE, TRUE, FALSE, TRUE) . '</div>';
433  }
434  // Additional footer content
435  $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/mod1/index.php']['drawFooterHook'];
436  if (is_array($footerContentHook)) {
437  foreach ($footerContentHook as $hook) {
438  $params = array();
439  $this->body .= GeneralUtility::callUserFunction($hook, $params, $this);
440  }
441  }
442  // Setting up the buttons and markers for docheader
443  $docHeaderButtons = $dblist->getButtons();
444  $markers = array(
445  'CSH' => $docHeaderButtons['csh'],
446  'CONTENT' => $this->body,
447  'EXTRACONTAINERCLASS' => $this->table ? 'singletable' : ''
448  );
449  // Build the <body> for the module
450  $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
451  // Renders the module page
452  $this->content = $this->doc->render('DB list', $this->content);
453  }
454 
461  public function printContent() {
462  echo $this->content;
463  }
464 
465 }
static getFuncCheck($mainParams, $elementName, $currentValue, $script='', $addParams='', $tagParams='')
static readPageAccess($id, $perms_clause)
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static wrapInHelp($table, $field, $text='', array $overloadHelpText=array())
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static setUpdateSignal($set='', $params='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]