[BUGFIX] List module - Fix pointer issue in pagebrowser
[Packages/TYPO3.CMS.git] / typo3 / class.db_list_extra.inc
1 <?php
2 /*************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2009 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  * Include file extending recordList which extended t3lib_recordList
29  * Used specifically for the Web>List module (db_list.php)
30  *
31  * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
32  * XHTML compliant
33  *
34  * @author      Kasper Skårhøj <kasperYYYY@typo3.com>
35  */
36 /**
37  * [CLASS/FUNCTION INDEX of SCRIPT]
38  *
39  *
40  *
41  *   91: class localRecordList extends recordList
42  *  123:     function writeTop($row)
43  *  304:     function getTable($table,$id,$rowlist)
44  *  559:     function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0)
45  *  648:     function renderListHeader($table,$currentIdList)
46  *
47  *              SECTION: Rendering of various elements
48  *  796:     function makeControl($table,$row)
49  *  986:     function makeClip($table,$row)
50  * 1057:     function makeRef($table,$uid)
51  * 1086:     function makeLocalizationPanel($table,$row)
52  * 1148:     function fieldSelectBox($table,$formFields=1)
53  *
54  *              SECTION: Helper functions
55  * 1231:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
56  * 1242:     function clipNumPane()
57  * 1256:     function addSortLink($code,$field,$table)
58  * 1281:     function recPath($pid)
59  * 1294:     function showNewRecLink($table)
60  * 1304:     function makeReturnUrl()
61  *
62  *              SECTION: CSV related functions
63  * 1329:     function initCSV()
64  * 1352:     function addToCSV($row,$table)
65  * 1376:     function setCsvRow($csvRow)
66  * 1387:     function outputCSV($prefix)
67  *
68  * TOTAL FUNCTIONS: 19
69  * (This index is automatically created/updated by the extension "extdeveval")
70  *
71  */
72
73
74
75
76
77
78
79
80
81
82 /**
83  * Class for rendering of Web>List module
84  *
85  * @author      Kasper Skårhøj <kasperYYYY@typo3.com>
86  * @package TYPO3
87  * @subpackage core
88  */
89 class localRecordList extends recordList {
90
91                 // External:
92         var $alternateBgColors=FALSE;                   // If true, table rows in the list will alternate in background colors (and have background colors at all!)
93         var $allowedNewTables=array();                  // Used to indicate which tables (values in the array) that can have a create-new-record link. If the array is empty, all tables are allowed.
94         var $deniedNewTables=array();                   // Used to indicate which tables (values in the array) that cannot have a create-new-record link. If the array is empty, all tables are allowed.
95         var $newWizards=FALSE;                                  // If true, the control panel will contain links to the create-new wizards for pages and tt_content elements (normally, the link goes to just creating a new element without the wizards!).
96
97         var $dontShowClipControlPanels=FALSE;   // If true, will disable the rendering of clipboard + control panels.
98         var $showClipboard=FALSE;                               // If true, will show the clipboard in the field list.
99         var $noControlPanels = FALSE;                   // If true, will DISABLE all control panels in lists. (Takes precedence)
100         var $clickMenuEnabled = TRUE;                   // If true, clickmenus will be rendered
101
102         var $totalRowCount;                                             // count of record rows in view
103
104         var $spaceIcon;                                                 // space icon used for alignment
105
106                 // Internal:
107         var $pageRow=array();                                   // Set to the page record (see writeTop())
108
109                 // Used to accumulate CSV lines for CSV export.
110         protected $csvLines = array();
111
112         var $csvOutput=FALSE;                                   // If set, the listing is returned as CSV instead.
113
114         /**
115          * Clipboard object
116          *
117          * @var t3lib_clipboard
118          */
119         var $clipObj;
120         var $CBnames=array();                                   // Tracking names of elements (for clipboard use)
121         var $duplicateStack=array();                    // Used to track which elements has duplicates and how many
122
123         /**
124          * references of the current record
125          *
126          * @var array
127          *
128          * @deprecated since 4.4: Use getReferenceCount instead
129          */
130         public $references;
131
132         /**
133          * [$tablename][$uid] = number of references to this record
134          *
135          * @var array
136          */
137         protected $referenceCount = array();
138
139         var $translations;                                              // Translations of the current record
140         var $selFieldList;                                              // select fields for the query which fetches the translations of the current record
141
142         public function __construct() {
143                 parent::__construct();
144         }
145
146         /**
147          * Create the panel of buttons for submitting the form or otherwise perform operations.
148          *
149          * @return      array   all available buttons as an assoc. array
150          */
151         public function getButtons()    {
152                 global $LANG;
153
154                 $buttons = array(
155                         'csh' => '',
156                         'view' => '',
157                         'edit' => '',
158                         'hide_unhide' => '',
159                         'move' => '',
160                         'new_record' => '',
161                         'paste' => '',
162                         'level_up' => '',
163                         'cache' => '',
164                         'reload' => '',
165                         'shortcut' => '',
166                         'back' => '',
167                         'csv' => '',
168                         'export' => ''
169                 );
170
171                         // Get users permissions for this page record:
172                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageRow);
173
174                         // CSH
175                 if (!strlen($this->id)) {
176                         $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_noId', $GLOBALS['BACK_PATH'], '', TRUE);
177                 } elseif(!$this->id) {
178                         $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_root', $GLOBALS['BACK_PATH'], '', TRUE);
179                 } else {
180                         $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH'], '', TRUE);
181                 }
182
183                 if (isset($this->id)) {
184                                 // View  Exclude doktypes 254,255 Configuration: mod.web_list.noViewWithDokTypes = 254,255
185                         if (isset($GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'])) {
186                                 $noViewDokTypes = t3lib_div::trimExplode(',', $GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'], true);
187                         } else {
188                                         //default exclusion: doktype 254 (folder), 255 (recycler)
189                                 $noViewDokTypes = array(t3lib_pageSelect::DOKTYPE_SYSFOLDER, t3lib_pageSelect::DOKTYPE_RECYCLER);
190                         }
191
192                         if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
193                                 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id))) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
194                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
195                                                         '</a>';
196                         }
197
198                                 // New record
199                         if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) {
200                                 $buttons['new_record'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');') . '" title="' . $LANG->getLL('newRecordGeneral', TRUE) . '">' .
201                                                                         t3lib_iconWorks::getSpriteIcon('actions-document-new') .
202                                                                 '</a>';
203                         }
204
205                                 // If edit permissions are set (see class.t3lib_userauthgroup.php)
206                         if ($localCalcPerms&2 && !empty($this->id))     {
207
208                                         // Edit
209                                 $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
210                                 $buttons['edit'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) . '" title="' . $LANG->getLL('editPage', TRUE) . '">' .
211                                                                         t3lib_iconWorks::getSpriteIcon('actions-page-open') .
212                                                                 '</a>';
213                                         // Unhide
214                                 if ($this->pageRow['hidden'])   {
215                                         $params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=0';
216                                         $buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $LANG->getLL('unHidePage', TRUE) . '">' .
217                                                                                 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
218                                                                         '</a>';
219                                         // Hide
220                                 } else {
221                                         $params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=1';
222                                         $buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $LANG->getLL('hidePage', TRUE) . '">'.
223                                                                                 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
224                                                                         '</a>';
225                                 }
226
227                                         // Move
228                                 $buttons['move'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'move_el.php?table=pages&uid=' . $this->pageRow['uid'] . '\');') . '" title="' . $LANG->getLL('move_page', TRUE) . '">' .
229                                                                         (($this->table == 'tt_content') ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
230                                                                 '</a>';
231
232                                         // Up one level
233                                 $buttons['level_up'] = '<a href="' . htmlspecialchars($this->listURL($this->pageRow['pid'], '-1', 'firstElementNumber')) . '" onclick="setHighlight(' . $this->pageRow['pid'] . ')" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', TRUE) . '">' .
234                                                                 t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
235                                                         '</a>';
236
237                         }
238
239
240                                 // Paste
241                         if (($localCalcPerms&8) || ($localCalcPerms&16)) {
242                                 $elFromTable = $this->clipObj->elFromTable('');
243                                 if (count($elFromTable)) {
244                                         $buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)) . '" title="' . $LANG->getLL('clip_paste', TRUE) . '">' .
245                                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
246                                                                         '</a>';
247                                 }
248                         }
249
250                                 // Cache
251                         $buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', TRUE) . '">' .
252                                                                 t3lib_iconWorks::getSpriteIcon('actions-system-cache-clear') .
253                                                         '</a>';
254
255                         if ($this->table) {
256
257                                         // CSV
258                                 $buttons['csv'] = '<a href="' . htmlspecialchars($this->listURL() . '&csv=1') . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv', TRUE) . '">' .
259                                                                         t3lib_iconWorks::getSpriteIcon('mimetypes-text-csv') .
260                                                                 '</a>';
261
262                                         // Export
263                                 if (t3lib_extMgm::isLoaded('impexp')) {
264                                         $url = $this->backPath . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export';
265                                         $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id)) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export', TRUE) . '">' .
266                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-export-t3d') .
267                                                         '</a>';
268                                 }
269
270                         }
271
272                                 // Reload
273                         $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload', TRUE) . '">' .
274                                                                 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
275                                                         '</a>';
276
277                                 // Shortcut
278                         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
279                                 $buttons['shortcut'] = $GLOBALS['TBE_TEMPLATE']->makeShortcutIcon('id, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev', implode(',', array_keys($this->MOD_MENU)), 'web_list');
280                         }
281
282                                 // Back
283                         if ($this->returnUrl) {
284                                 $buttons['back'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl, array('id' => $this->id))) . '" class="typo3-goBack" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', TRUE) . '">' .
285                                                                         t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
286                                                                 '</a>';
287                         }
288                 }
289
290                 return $buttons;
291         }
292
293         /**
294          * Creates the listing of records from a single table
295          *
296          * @param       string          Table name
297          * @param       integer         Page id
298          * @param       string          List of fields to show in the listing. Pseudo fields will be added including the record header.
299          * @return      string          HTML table with the listing for the record.
300          */
301         function getTable($table,$id,$rowlist)  {
302                 global $TCA, $TYPO3_CONF_VARS;
303
304                         // Loading all TCA details for this table:
305                 t3lib_div::loadTCA($table);
306
307                         // Init
308                 $addWhere = '';
309                 $titleCol = $TCA[$table]['ctrl']['label'];
310                 $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
311                 $l10nEnabled = $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'];
312                 $tableCollapsed = (!$this->tablesCollapsed[$table]) ? false : true;
313
314                 // prepare space icon
315                 $this->spaceIcon = t3lib_iconWorks::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
316
317                         // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
318                 $this->fieldArray=array();
319                         // title Column
320                 $this->fieldArray[] = $titleCol;        // Add title column
321                         // Control-Panel
322                 if (!t3lib_div::inList($rowlist,'_CONTROL_'))   {
323                         $this->fieldArray[] = '_CONTROL_';
324                         $this->fieldArray[] = '_AFTERCONTROL_';
325                 }
326                         // Clipboard
327                 if ($this->showClipboard)       {
328                         $this->fieldArray[] = '_CLIPBOARD_';
329                 }
330                         // Ref
331                 if (!$this->dontShowClipControlPanels)  {
332                         $this->fieldArray[]='_REF_';
333                         $this->fieldArray[]='_AFTERREF_';
334                 }
335                         // Path
336                 if ($this->searchLevels)        {
337                         $this->fieldArray[]='_PATH_';
338                 }
339                         // Localization
340                 if ($this->localizationView && $l10nEnabled)    {
341                         $this->fieldArray[] = '_LOCALIZATION_';
342                         $this->fieldArray[] = '_LOCALIZATION_b';
343                         $addWhere.=' AND (
344                                 '.$TCA[$table]['ctrl']['languageField'].'<=0
345                                 OR
346                                 '.$TCA[$table]['ctrl']['transOrigPointerField'].' = 0
347                         )';
348                 }
349                         // Cleaning up:
350                 $this->fieldArray=array_unique(array_merge($this->fieldArray,t3lib_div::trimExplode(',',$rowlist,1)));
351                 if ($this->noControlPanels)     {
352                         $tempArray = array_flip($this->fieldArray);
353                         unset($tempArray['_CONTROL_']);
354                         unset($tempArray['_CLIPBOARD_']);
355                         $this->fieldArray = array_keys($tempArray);
356                 }
357
358                         // Creating the list of fields to include in the SQL query:
359                 $selectFields = $this->fieldArray;
360                 $selectFields[] = 'uid';
361                 $selectFields[] = 'pid';
362                 if ($thumbsCol) $selectFields[] = $thumbsCol;   // adding column for thumbnails
363                 if ($table=='pages')    {
364                         if (t3lib_extMgm::isLoaded('cms'))      {
365                                 $selectFields[] = 'module';
366                                 $selectFields[] = 'extendToSubpages';
367                                 $selectFields[] = 'nav_hide';
368                         }
369                         $selectFields[] = 'doktype';
370                 }
371                 if (is_array($TCA[$table]['ctrl']['enablecolumns']))    {
372                         $selectFields = array_merge($selectFields,$TCA[$table]['ctrl']['enablecolumns']);
373                 }
374                 if ($TCA[$table]['ctrl']['type'])       {
375                         $selectFields[] = $TCA[$table]['ctrl']['type'];
376                 }
377                 if ($TCA[$table]['ctrl']['typeicon_column'])    {
378                         $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
379                 }
380                 if ($TCA[$table]['ctrl']['versioningWS'])       {
381                         $selectFields[] = 't3ver_id';
382                         $selectFields[] = 't3ver_state';
383                         $selectFields[] = 't3ver_wsid';
384                         $selectFields[] = 't3ver_swapmode';             // Filtered out when pages in makeFieldList()
385                 }
386                 if ($l10nEnabled)       {
387                         $selectFields[] = $TCA[$table]['ctrl']['languageField'];
388                         $selectFields[] = $TCA[$table]['ctrl']['transOrigPointerField'];
389                 }
390                 if ($TCA[$table]['ctrl']['label_alt'])  {
391                         $selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
392                 }
393                 $selectFields = array_unique($selectFields);            // Unique list!
394                 $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));          // Making sure that the fields in the field-list ARE in the field-list from TCA!
395                 $selFieldList = implode(',',$selectFields);             // implode it into a list of fields for the SQL-statement.
396                 $this->selFieldList = $selFieldList;
397
398                 /**
399                  * @hook                        DB-List getTable
400                  * @date                        2007-11-16
401                  * @request             Malte Jansen  <mail@maltejansen.de>
402                  */
403                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
404                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
405                                 $hookObject = t3lib_div::getUserObj($classData);
406
407                                 if(!($hookObject instanceof t3lib_localRecordListGetTableHook)) {
408                                         throw new UnexpectedValueException('$hookObject must implement interface t3lib_localRecordListGetTableHook', 1195114460);
409                                 }
410
411                                 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
412                         }
413                 }
414
415                         // Create the SQL query for selecting the elements in the listing:
416                 if ($this->csvOutput) { // do not do paging when outputting as CSV
417                         $this->iLimit = 0;
418                 }
419
420                 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
421                                 // Get the two previous rows for sorting if displaying page > 1
422                         $this->firstElementNumber = $this->firstElementNumber - 2;
423                         $this->iLimit = $this->iLimit + 2;
424                         $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
425                         $this->firstElementNumber = $this->firstElementNumber + 2;
426                         $this->iLimit = $this->iLimit - 2;
427                 } else {
428                         $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
429                 }
430
431                 $this->setTotalItems($queryParts);              // Finding the total amount of records on the page (API function from class.db_list.inc)
432
433                         // Init:
434                 $dbCount = 0;
435                 $out = '';
436                 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
437
438                         // If the count query returned any number of records, we perform the real query, selecting records.
439                 if ($this->totalItems)  {
440                         // Fetch records only if not in single table mode or if in multi table mode and not collapsed
441                         if ($listOnlyInSingleTableMode || (!$this->table && $tableCollapsed)) {
442                                 $dbCount = $this->totalItems;
443                         } else {
444                                         // set the showLimit to the number of records when outputting as CSV
445                                 if ($this->csvOutput) {
446                                         $this->showLimit = $this->totalItems;
447                                         $this->iLimit = $this->totalItems;
448                                 }
449                                 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
450                                 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
451                         }
452                 }
453
454                         // If any records was selected, render the list:
455                 if ($dbCount)   {
456
457                                 // Half line is drawn between tables:
458                         if (!$listOnlyInSingleTableMode)        {
459                                 $theData = Array();
460                                 if (!$this->table && !$rowlist) {
461                                         $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
462                                         if (in_array('_CONTROL_',$this->fieldArray))    $theData['_CONTROL_']='';
463                                         if (in_array('_CLIPBOARD_',$this->fieldArray))  $theData['_CLIPBOARD_']='';
464                                 }
465                                 $out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
466                         }
467
468                                 // Header line is drawn
469                         $theData = Array();
470                         if ($this->disableSingleTableView)      {
471                                 $theData[$titleCol] = '<span class="c-table">' . t3lib_BEfunc::wrapInHelp($table, '', $GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'], TRUE)) . '</span> ('.$this->totalItems.')';
472                         } else {
473                                 $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'], TRUE) . '</span> (' . $this->totalItems . ') ' .
474                                                 ($this->table ? t3lib_iconWorks::getSpriteIcon('actions-view-table-collapse', array('title' => $GLOBALS['LANG']->getLL('contractView', TRUE))) : t3lib_iconWorks::getSpriteIcon('actions-view-table-expand', array('title' => $GLOBALS['LANG']->getLL('expandView', TRUE))))
475                                         );
476                         }
477
478                         if ($listOnlyInSingleTableMode) {
479                                 $out.='
480                                         <tr>
481                                                 <td class="t3-row-header" style="width:95%;">' . t3lib_BEfunc::wrapInHelp($table, '', $theData[$titleCol]) . '</td>
482                                         </tr>';
483                         } else {
484                                 // Render collapse button if in multi table mode
485                                 $collapseIcon = '';
486                                 if (!$this->table) {
487                                         $collapseIcon = '<a href="' . htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')) . '" title="' . ($tableCollapsed ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.expandTable', TRUE) : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.collapseTable', TRUE)) . '">' .
488                                                         ($tableCollapsed ? t3lib_iconWorks::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon')) : t3lib_iconWorks::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'))) .
489                                                 '</a>';
490                                 }
491                                 $out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
492                         }
493
494                         // Render table rows only if in multi table view and not collapsed or if in single table view
495                         if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
496                                         // Fixing a order table for sortby tables
497                                 $this->currentTable = array();
498                                 $currentIdList = array();
499                                 $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
500
501                                 $prevUid = 0;
502                                 $prevPrevUid = 0;
503
504                                         // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
505                                 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
506                                         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
507                                         $prevPrevUid = -(int) $row['uid'];
508                                         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
509                                         $prevUid = $row['uid'];
510                                 }
511
512                                 $accRows = array();     // Accumulate rows here
513                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
514
515                                                 // In offline workspace, look for alternative record:
516                                         t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
517
518                                         if (is_array($row))     {
519                                                 $accRows[] = $row;
520                                                 $currentIdList[] = $row['uid'];
521                                                 if ($doSort)    {
522                                                         if ($prevUid)   {
523                                                                 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
524                                                                 $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
525                                                                 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
526                                                         }
527                                                         $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
528                                                         $prevUid=$row['uid'];
529                                                 }
530                                         }
531                                 }
532                                 $GLOBALS['TYPO3_DB']->sql_free_result($result);
533
534                                 $this->totalRowCount = count($accRows);
535
536                                         // CSV initiated
537                                 if ($this->csvOutput) $this->initCSV();
538
539                                         // Render items:
540                                 $this->CBnames=array();
541                                 $this->duplicateStack=array();
542                                 $this->eCounter=$this->firstElementNumber;
543
544                                 $iOut = '';
545                                 $cc = 0;
546
547                                 foreach($accRows as $row)       {
548                                         // Render item row if counter < limit
549                                         if ($cc < $this->iLimit) {
550                                                 $cc++;
551                                                 $this->translations = FALSE;
552                                                 $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
553
554                                                         // If localization view is enabled it means that the selected records are either default or All language and here we will not select translations which point to the main record:
555                                                 if ($this->localizationView && $l10nEnabled)    {
556                                                                 // For each available translation, render the record:
557                                                         if (is_array($this->translations)) {
558                                                                 foreach ($this->translations as $lRow) {
559                                                                                 // $lRow isn't always what we want - if record was moved we've to work with the placeholder records otherwise the list is messed up a bit
560                                                                         if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
561                                                                                 $tmpRow = t3lib_BEfunc::getRecordRaw($table, 't3ver_move_id="'.intval($lRow['uid']) . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . t3lib_beFunc::deleteClause($table), $selFieldList);
562                                                                                 $lRow = is_array($tmpRow)?$tmpRow:$lRow;
563                                                                         }
564                                                                                 // In offline workspace, look for alternative record:
565                                                                         t3lib_BEfunc::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, true);
566                                                                         if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']]))  {
567                                                                                 $currentIdList[] = $lRow['uid'];
568                                                                                 $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
569                                                                         }
570                                                                 }
571                                                         }
572                                                 }
573                                         }
574
575                                                 // Counter of total rows incremented:
576                                         $this->eCounter++;
577                                 }
578
579                                         // Record navigation is added to the beginning and end of the table if in single table mode
580                                 if ($this->table) {
581                                         $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
582                                 } else {
583                                                 // show that there are more records than shown
584                                         if ($this->totalItems > $this->itemsLimitPerTable) {
585                                                 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
586                                                 $hasMore = ($this->totalItems > $this->itemsLimitSingleTable);
587                                                 $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
588                                                                 <a href="'.htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' .
589                                                                 '<img' . t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif', 'width="14" height="14"') .' alt="" />'.
590                                                                 ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
591                                                                 </td></tr>';
592                                                 }
593
594                                 }
595
596                                         // The header row for the table is now created:
597                                 $out .= $this->renderListHeader($table,$currentIdList);
598                         }
599
600                                 // The list of records is added after the header:
601                         $out .= $iOut;
602                         unset($iOut);
603
604                                 // ... and it is all wrapped in a table:
605                         $out='
606
607
608
609                         <!--
610                                 DB listing of elements: "'.htmlspecialchars($table).'"
611                         -->
612                                 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($listOnlyInSingleTableMode?' typo3-dblist-overview':'').'">
613                                         '.$out.'
614                                 </table>';
615
616                                 // Output csv if...
617                         if ($this->csvOutput)   $this->outputCSV($table);       // This ends the page with exit.
618                 }
619
620                         // Return content:
621                 return $out;
622         }
623
624         /**
625          * Rendering a single row for the list
626          *
627          * @param       string          Table name
628          * @param       array           Current record
629          * @param       integer         Counter, counting for each time an element is rendered (used for alternating colors)
630          * @param       string          Table field (column) where header value is found
631          * @param       string          Table field (column) where (possible) thumbnails can be found
632          * @param       integer         Indent from left.
633          * @return      string          Table row for the element
634          * @access private
635          * @see getTable()
636          */
637         function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0)  {
638                 $iOut = '';
639
640                 if (strlen($this->searchString))        {       // If in search mode, make sure the preview will show the correct page
641                         $id_orig = $this->id;
642                         $this->id = $row['pid'];
643                 }
644
645                 if (is_array($row))     {
646                                 // add special classes for first and last row
647                         $rowSpecial = '';
648                         if ($cc == 1 && $indent == 0) {
649                                 $rowSpecial .= ' firstcol';
650                         }
651                         if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
652                                 $rowSpecial .= ' lastcol';
653                         }
654
655                                 // Background color, if any:
656                         if ($this->alternateBgColors) {
657                                 $row_bgColor = ($cc%2) ? ' class="db_list_normal'.$rowSpecial.'"' : ' class="db_list_alt'.$rowSpecial.'"';
658                         } else {
659                                 $row_bgColor = ' class="db_list_normal'.$rowSpecial.'"';
660                         }
661                                 // Overriding with versions background color if any:
662                         $row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
663
664                                 // Incr. counter.
665                         $this->counter++;
666
667                                 // The icon with link
668                         $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
669                         $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => ($indent ? ' margin-left: ' . $indent . 'px;' : '')));
670
671
672                         $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
673
674                                 // Preparing and getting the data-array
675                         $theData = Array();
676                         foreach($this->fieldArray as $fCol)     {
677                                 if ($fCol==$titleCol)   {
678                                         $recTitle = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
679                                                 // If the record is edit-locked by another user, we will show a little warning sign:
680                                         if (($lockInfo = t3lib_BEfunc::isRecordLocked($table, $row['uid']))) {
681                                                 $warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' .
682                                                                 t3lib_iconWorks::getSpriteIcon('status-warning-in-use') .
683                                                         '</a>';
684                                         }
685                                         $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
686
687                                                 // Render thumbsnails if a thumbnail column exists and there is content in it:
688                                         if ($this->thumbs && trim($row[$thumbsCol])) {
689                                                 $theData[$fCol] .= '<br />' . $this->thumbCode($row,$table,$thumbsCol);
690                                         }
691
692                                         $localizationMarkerClass = '';
693                                         if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
694                                         && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
695                                         && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
696                                                         // it's a translated record with a language parent
697                                                 $localizationMarkerClass = ' localization';
698                                         }
699                                 } elseif ($fCol == 'pid') {
700                                         $theData[$fCol]=$row[$fCol];
701                                 } elseif ($fCol == '_PATH_') {
702                                         $theData[$fCol]=$this->recPath($row['pid']);
703                                 } elseif ($fCol == '_REF_') {
704                                         $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
705                                 } elseif ($fCol == '_CONTROL_') {
706                                         $theData[$fCol]=$this->makeControl($table,$row);
707                                 } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
708                                         $theData[$fCol] = '&nbsp;';
709                                 } elseif ($fCol == '_CLIPBOARD_') {
710                                         $theData[$fCol]=$this->makeClip($table,$row);
711                                 } elseif ($fCol == '_LOCALIZATION_') {
712                                         list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
713                                         $theData[$fCol] = $lC1;
714                                         $theData[$fCol.'b'] = $lC2;
715                                 } elseif ($fCol == '_LOCALIZATION_b') {
716                                         // Do nothing, has been done above.
717                                 } else {
718                                         $tmpProc = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
719                                         $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
720                                         if ($this->csvOutput) {
721                                                 $row[$fCol] = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
722                                         }
723                                 }
724                         }
725
726                         if (strlen($this->searchString))        {       // Reset the ID if it was overwritten
727                                 $this->id = $id_orig;
728                         }
729
730                                 // Add row to CSV list:
731                         if ($this->csvOutput) {
732                                 $this->addToCSV($row,$table);
733                         }
734
735                         // Add classes to table cells
736                         $this->addElement_tdCssClass[$titleCol]         = 'col-title' . $localizationMarkerClass;
737                         if (!$this->dontShowClipControlPanels) {
738                                 $this->addElement_tdCssClass['_CONTROL_']       = 'col-control';
739                                 $this->addElement_tdCssClass['_AFTERCONTROL_']  = 'col-control-space';
740                                 $this->addElement_tdCssClass['_CLIPBOARD_']     = 'col-clipboard';
741                         }
742                         $this->addElement_tdCssClass['_PATH_']          = 'col-path';
743                         $this->addElement_tdCssClass['_LOCALIZATION_']  = 'col-localizationa';
744                         $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
745
746                                 // Create element in table cells:
747                         $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
748
749                                 // Finally, return table row element:
750                         return $iOut;
751                 }
752         }
753
754         /**
755          * Write sys_refindex entries for current record to $this->references
756          *
757          * @param       string          Table name
758          * @param       integer         Uid of current record
759          * @return      void
760          *
761          * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use getReferenceCount instead
762          */
763         function setReferences($table, $uid) {
764                 t3lib_div::logDeprecatedFunction();
765
766                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
767                         'tablename, recuid, field',
768                         'sys_refindex',
769                         'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
770                                 ' AND ref_uid='.intval($uid).
771                                 ' AND deleted=0'
772                 );
773                 $this->references = $rows;
774         }
775
776         /**
777          * Gets the number of records referencing the record with the UID $uid in
778          * the table $tableName.
779          *
780          * @param string $tableName
781          *        table name of the referenced record, must not be empty
782          * @param integer $uid
783          *        UID of the referenced record, must be > 0
784          *
785          * @return integer the number of references to record $uid in table
786          *                 $tableName, will be >= 0
787          */
788         protected function getReferenceCount($tableName, $uid) {
789                 if (!isset($this->referenceCount[$tableName][$uid])) {
790                         $numberOfReferences = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
791                                 '*',
792                                 'sys_refindex',
793                                 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
794                                         $tableName, 'sys_refindex'
795                                 ) .
796                                         ' AND ref_uid = ' . $uid .
797                                         ' AND deleted = 0'
798                         );
799
800                         $this->referenceCount[$tableName][$uid] = $numberOfReferences;
801                 }
802
803                 return $this->referenceCount[$tableName][$uid];
804         }
805
806         /**
807          * Rendering the header row for a table
808          *
809          * @param       string          Table name
810          * @param       array           Array of the currently displayed uids of the table
811          * @return      string          Header table row
812          * @access private
813          * @see getTable()
814          */
815         function renderListHeader($table, $currentIdList)       {
816                 global $TCA, $LANG, $TYPO3_CONF_VARS;
817
818                         // Init:
819                 $theData = Array();
820
821                         // Traverse the fields:
822                 foreach($this->fieldArray as $fCol)     {
823
824                                 // Calculate users permissions to edit records in the table:
825                         $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
826
827                         switch((string)$fCol)   {
828                                 case '_PATH_':                  // Path
829                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
830                                 break;
831                                 case '_REF_':                   // References
832                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_',1).']</i>';
833                                 break;
834                                 case '_LOCALIZATION_':                  // Path
835                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_',1).']</i>';
836                                 break;
837                                 case '_LOCALIZATION_b':                 // Path
838                                         $theData[$fCol] = $LANG->getLL('Localize',1);
839                                 break;
840                                 case '_CLIPBOARD_':             // Clipboard:
841                                         $cells=array();
842
843                                                 // If there are elements on the clipboard for this table, then display the "paste into" icon:
844                                         $elFromTable = $this->clipObj->elFromTable($table);
845                                         if (count($elFromTable))        {
846                                                 $cells['pasteAfter']='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'" title="' . $LANG->getLL('clip_paste', TRUE) . '">' .
847                                                                         t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
848                                                                 '</a>';
849                                         }
850
851                                                 // If the numeric clipboard pads are enabled, display the control icons for that:
852                                         if ($this->clipObj->current!='normal')  {
853
854                                                         // The "select" link:
855                                                 $cells['copyMarked']=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-copy', array('title' => $LANG->getLL('clip_selectMarked', TRUE))), $table, 'setCB');
856
857                                                         // The "edit marked" link:
858                                                 $editIdList = implode(',',$currentIdList);
859                                                 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
860                                                 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
861                                                 $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="' . $LANG->getLL('clip_editMarked', TRUE) . '">' .
862                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
863                                                                 '</a>';
864
865                                                         // The "Delete marked" link:
866                                                 $cells['delete']=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => $LANG->getLL('clip_deleteMarked', TRUE))), $table,'delete',sprintf($LANG->getLL('clip_deleteMarkedWarning'), $LANG->sL($TCA[$table]['ctrl']['title'])));
867
868                                                         // The "Select all" link:
869                                                 $cells['markAll'] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;') . '" title="' . $LANG->getLL('clip_markRecords', TRUE) . '">' .
870                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-select') .
871                                                                 '</a>';
872                                         } else {
873                                                 $cells['empty']='';
874                                         }
875                                         /**
876                                          * @hook                        renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
877                                          * @date                        2007-11-20
878                                          * @request             Bernhard Kraft  <krafbt@kraftb.at>
879                                          * @usage               Above each listed table in Web>List a header row is shown. This hook allows to modify the icons responsible for the clipboard functions (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected), or other "Action" functions which perform operations on the listed records.
880                                          */
881                                         if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions']))        {
882                                                 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData)       {
883                                                         $hookObject = t3lib_div::getUserObj($classData);
884                                                         if(!($hookObject instanceof localRecordList_actionsHook))       {
885                                                                 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567850);
886                                                         }
887                                                         $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
888                                                 }
889                                         }
890                                         $theData[$fCol]=implode('',$cells);
891                                 break;
892                                 case '_CONTROL_':               // Control panel:
893                                         if (!$TCA[$table]['ctrl']['readOnly'])  {
894
895                                                         // If new records can be created on this page, add links:
896                                                 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table))   {
897                                                         if ($table=="tt_content" && $this->newWizards)  {
898                                                                         //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
899                                                                 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
900                                                                 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
901                                                                 $newContentWizScriptPath = $this->backPath.t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
902
903                                                                 $icon = '<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'" title="' . $LANG->getLL('new', TRUE) . '">'.
904                                                                                                         ($table == 'pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
905                                                                                                 '</a>';
906                                                         } elseif ($table=='pages' && $this->newWizards) {
907                                                                 $icon = '<a href="'.htmlspecialchars($this->backPath.'db_new.php?id='.$this->id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'" title="'.$LANG->getLL('new', TRUE).'">'.
908                                                                                                         ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
909                                                                                                 '</a>';
910
911                                                         } else {
912                                                                 $params = '&edit['.$table.']['.$this->id.']=new';
913                                                                 if ($table == 'pages_language_overlay') {
914                                                                         $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
915                                                                 }
916                                                                 $icon   = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new', TRUE).'">'.
917                                                                                                         ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
918                                                                                                 '</a>';
919                                                         }
920                                                 }
921
922                                                         // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
923                                                 if ($permsEdit && $this->table && is_array($currentIdList))     {
924                                                         $editIdList = implode(',',$currentIdList);
925                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
926                                                         $params = '&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
927                                                         $icon  .= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('editShownColumns', TRUE) . '">'.
928                                                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
929                                                                                         '</a>';
930                                                 }
931                                                         // add an empty entry, so column count fits again after moving this into $icon
932                                                 $theData[$fCol] = '&nbsp;';
933                                         }
934                                 break;
935                                 case '_AFTERCONTROL_':  // space column
936                                 case '_AFTERREF_':      // space column
937                                         $theData[$fCol] = '&nbsp;';
938                                 break;
939                                 default:                        // Regular fields header:
940                                         $theData[$fCol]='';
941                                         if ($this->table && is_array($currentIdList))   {
942
943                                                         // If the numeric clipboard pads are selected, show duplicate sorting link:
944                                                 if ($this->clipNumPane()) {
945                                                         $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'" title="'.$LANG->getLL('clip_duplicates', TRUE) . '">'.
946                                                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-duplicates-select') .
947                                                                                         '</a>';
948                                                 }
949
950                                                         // If the table can be edited, add link for editing THIS field for all listed records:
951                                                 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol])  {
952                                                         $editIdList = implode(',',$currentIdList);
953                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
954                                                         $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
955                                                         $iTitle = sprintf($LANG->getLL('editThisColumn'),rtrim(trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol))),':'));
956                                                         $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.htmlspecialchars($iTitle).'">'.
957                                                                                                 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
958                                                                                         '</a>';
959                                                 }
960                                         }
961                                         $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
962                                 break;
963                         }
964
965                 }
966
967                 /**
968                  * @hook                        renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
969                  * @date                        2007-11-20
970                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
971                  * @usage               Above each listed table in Web>List a header row is shown. Containing the labels of all shown fields and additional icons to create new records for this table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
972                  */
973                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions']))        {
974                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData)       {
975                                 $hookObject = t3lib_div::getUserObj($classData);
976                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
977                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567855);
978                                 }
979                                 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
980                         }
981                 }
982
983                         // Create and return header table row:
984                 return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
985         }
986
987         /**
988          * Creates a page browser for tables with many records
989          *
990          * @param       string          Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
991          * @return      string  Navigation HTML
992          *
993          */
994         protected function renderListNavigation($renderPart = 'top') {
995                 $totalPages = ceil($this->totalItems / $this->iLimit);
996
997                 $content = '';
998                 $returnContent = '';
999
1000                         // Show page selector if not all records fit into one page
1001                 if ($totalPages > 1) {
1002                         $first = $previous = $next = $last = $reload = '';
1003                         $listURL = $this->listURL('', $this->table);
1004
1005                                 // 1 = first page
1006                         $currentPage = floor(($this->firstElementNumber + 1) / $this->iLimit) + 1;
1007
1008                                 // Compile first, previous, next, last and refresh buttons
1009                         if ($currentPage > 1) {
1010                                 $labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:first');
1011
1012                                 $first = '<a href="' . $listURL . '&pointer=0">' .
1013                                         t3lib_iconWorks::getSpriteIcon('actions-view-paging-first', array('title'=> $labelFirst)) .
1014                                 '</a>';
1015                         } else {
1016                                 $first = t3lib_iconWorks::getSpriteIcon('actions-view-paging-first-disabled');
1017                         }
1018
1019                         if (($currentPage - 1) > 0) {
1020                                 $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
1021
1022                                 $previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">' .
1023                                         t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous', array('title' => $labelPrevious)) .
1024                                         '</a>';
1025                         } else {
1026                                 $previous = t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous-disabled');
1027                         }
1028
1029                         if (($currentPage + 1) <= $totalPages) {
1030                                 $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
1031
1032                                 $next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">' .
1033                                         t3lib_iconWorks::getSpriteIcon('actions-view-paging-next', array('title' => $labelNext)) .
1034                                         '</a>';
1035                         } else {
1036                                 $next = t3lib_iconWorks::getSpriteIcon('actions-view-paging-next-disabled');
1037                         }
1038
1039                         if ($currentPage != $totalPages) {
1040                                 $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
1041
1042                                 $last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">' .
1043                                         t3lib_iconWorks::getSpriteIcon('actions-view-paging-last', array('title' => $labelLast)) .
1044                                         '</a>';
1045                         } else {
1046                                 $last = t3lib_iconWorks::getSpriteIcon('actions-view-paging-last-disabled');
1047                         }
1048
1049                         $reload = '<a href="#" onclick="document.dblistForm.action=\''
1050                                 . $listURL . '&pointer=\'+calculatePointer(document.getElementById(\'jumpPage-' . $renderPart .'\').value); document.dblistForm.submit(); return true;" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:reload', TRUE) . '">' .
1051                                         t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1052                                 '</a>';
1053
1054                         if ($renderPart === 'top') {
1055                                         // Add js to traverse a page select input to a pointer value
1056                                 $content = '
1057 <script type="text/JavaScript">
1058 /*<![CDATA[*/
1059
1060         function calculatePointer(page) {
1061                 if (page > ' . $totalPages . ') {
1062                         page = ' . $totalPages . ';
1063                 }
1064
1065                 if (page < 1) {
1066                         page = 1;
1067                 }
1068
1069                 pointer = (page - 1) * ' . $this->iLimit . ';
1070
1071                 return pointer;
1072         }
1073
1074 /*]]>*/
1075 </script>
1076 ';
1077                         }
1078                         $pageNumberInput = '<span>
1079                                 <input type="text" value="' . $currentPage
1080                                 . '" size="3" id="jumpPage-' . $renderPart . '" name="jumpPage-' . $renderPart . '" onkeyup="if (event.keyCode == Event.KEY_RETURN) { document.dblistForm.action=\'' . $listURL . '&pointer=\'+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1081                                 </span>';
1082                         $pageIndicator = '<span class="pageIndicator">'
1083                                 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
1084                                 . '</span>';
1085
1086                         if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
1087                                 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1088                         } else {
1089                                 $lastElementNumber = $this->totalItems;
1090                         }
1091                         $rangeIndicator = '<span class="pageIndicator">'
1092                                 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
1093                                 . '</span>';
1094
1095                         $content .= '<div id="typo3-dblist-pagination">'
1096                                 . $first . $previous
1097                                 . '<span class="bar">&nbsp;</span>'
1098                                 . $rangeIndicator . '<span class="bar">&nbsp;</span>'
1099                                 . $pageIndicator . '<span class="bar">&nbsp;</span>'
1100                                 . $next . $last . '<span class="bar">&nbsp;</span>'
1101                                 . $reload
1102                                 . '</div>';
1103
1104                         $data = Array();
1105                         $titleColumn = $this->fieldArray[0];
1106                         $data[$titleColumn] = $content;
1107
1108                         $returnContent = $this->addElement(1, '', $data);
1109                 } // end of if pages > 1
1110
1111                 return $returnContent;
1112         }
1113
1114
1115
1116
1117
1118
1119         /*********************************
1120          *
1121          * Rendering of various elements
1122          *
1123          *********************************/
1124
1125         /**
1126          * Creates the control panel for a single record in the listing.
1127          *
1128          * @param       string          The table
1129          * @param       array           The record for which to make the control panel.
1130          * @return      string          HTML table with the control panel (unless disabled)
1131          */
1132         function makeControl($table,$row)       {
1133                 global $TCA, $LANG, $SOBE, $TYPO3_CONF_VARS;
1134
1135                 if ($this->dontShowClipControlPanels)   return '';
1136
1137                         // Initialize:
1138                 t3lib_div::loadTCA($table);
1139                 $cells=array();
1140
1141                         // If the listed table is 'pages' we have to request the permission settings for each page:
1142                 if ($table=='pages')    {
1143                         $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
1144                 }
1145
1146                         // This expresses the edit permissions for this particular element:
1147                 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
1148
1149                         // "Show" link (only pages and tt_content elements)
1150                 if ($table=='pages' || $table=='tt_content')    {
1151                         $params='&edit['.$table.']['.$row['uid'].']=edit';
1152                         $cells['view']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'], $this->backPath)).'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE).'">'.
1153                                                 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1154                                         '</a>';
1155                 } elseif(!$this->table) {
1156                         $cells['view'] = $this->spaceIcon;
1157                 }
1158
1159                         // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1160                 if ($permsEdit) {
1161                         $params='&edit['.$table.']['.$row['uid'].']=edit';
1162                         $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('edit', TRUE).'">'.
1163                                                 ( $TCA[$table]['ctrl']['readOnly'] ? t3lib_iconWorks::getSpriteIcon('actions-document-open-read-only') : t3lib_iconWorks::getSpriteIcon('actions-document-open') ).
1164                                         '</a>';
1165                 } elseif(!$this->table) {
1166                         $cells['edit'] = $this->spaceIcon;
1167                 }
1168
1169                         // "Move" wizard link for pages/tt_content elements:
1170                 if (($table=="tt_content" && $permsEdit) || ($table=='pages'))  {
1171                         $cells['move']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'" title="'.$LANG->getLL('move_' . ($table == 'tt_content' ? 'record' : 'page'), TRUE) . '">' .
1172                                                 ($table == 'tt_content' ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
1173                                         '</a>';
1174                 } elseif(!$this->table) {
1175                         $cells['move'] = $this->spaceIcon;
1176                 }
1177
1178                         // If the extended control panel is enabled OR if we are seeing a single table:
1179                 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table)     {
1180
1181                                 // "Info": (All records)
1182                         $cells['viewBig']='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'" title="'.$LANG->getLL('showInfo', TRUE).'">'.
1183                                                 t3lib_iconWorks::getSpriteIcon('actions-document-info') .
1184                                         '</a>';
1185
1186                                 // If the table is NOT a read-only table, then show these links:
1187                         if (!$TCA[$table]['ctrl']['readOnly'])  {
1188
1189                                         // "Revert" link (history/undo)
1190                                 $cells['history']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'" title="'.$LANG->getLL('history', TRUE).'">'.
1191                                                         t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1192                                                 '</a>';
1193
1194                                         // Versioning:
1195                                 if (t3lib_extMgm::isLoaded('version'))  {
1196                                         $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row);
1197                                         if (is_array($vers))    {       // If table can be versionized.
1198                                                 $versionIcon = 'no-version';
1199                                                 if (count($vers) > 1) {
1200                                                         $versionIcon = count($vers) - 1;
1201                                                 }
1202
1203                                                 $cells['version'] = '<a href="' . htmlspecialchars($this->backPath . t3lib_extMgm::extRelPath('version') . 'cm1/index.php?table=' . rawurlencode($table) . '&uid=' . rawurlencode($row['uid'])) . '" title="' . $LANG->getLL('displayVersions', TRUE) . '">' .
1204                                                                 t3lib_iconWorks::getSpriteIcon('status-version-' . $versionIcon) .
1205                                                                 '</a>';
1206                                         } elseif(!$this->table) {
1207                                                 $cells['version'] = $this->spaceIcon;
1208                                         }
1209                                 }
1210
1211                                         // "Edit Perms" link:
1212                                 if ($table == 'pages' && $GLOBALS['BE_USER']->check('modules','web_perm') && t3lib_extMgm::isLoaded('perm'))    {
1213                                         $cells['perms'] =
1214                                                 '<a href="' .
1215                                                         htmlspecialchars(
1216                                                                 t3lib_extMgm::extRelPath('perm') . 'mod1/index.php' .
1217                                                                 '?id=' . $row['uid'] . '&return_id=' . $row['uid'] . '&edit=1'
1218                                                         ) .
1219                                                         '" title="' . $LANG->getLL('permissions', TRUE) .
1220                                                 '">'.
1221                                                         t3lib_iconWorks::getSpriteIcon('status-status-locked') .
1222                                                 '</a>';
1223                                 } elseif(!$this->table && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1224                                         $cells['perms'] = $this->spaceIcon;
1225                                 }
1226
1227                                         // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
1228                                 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
1229                                         if (
1230                                                 ($table!='pages' && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
1231                                                 ($table=='pages' && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
1232                                                 )       {
1233                                                 if ($this->showNewRecLink($table))      {
1234                                                         $params='&edit['.$table.']['.(-($row['_MOVE_PLH']?$row['_MOVE_PLH_uid']:$row['uid'])).']=new';
1235                                                         $cells['new']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'), TRUE).'">'.
1236                                                                                 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
1237                                                                         '</a>';
1238                                                 }
1239                                         }
1240                                 } elseif(!$this->table) {
1241                                         $cells['new'] = $this->spaceIcon;
1242                                 }
1243
1244                                         // "Up/Down" links
1245                                 if ($permsEdit && $TCA[$table]['ctrl']['sortby']  && !$this->sortField && !$this->searchLevels) {
1246                                         if (isset($this->currentTable['prev'][$row['uid']]))    {       // Up
1247                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
1248                                                 $cells['moveUp']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveUp', TRUE) . '">' .
1249                                                                         t3lib_iconWorks::getSpriteIcon('actions-move-up') .
1250                                                                 '</a>';
1251                                         } else {
1252                                                 $cells['moveUp'] = $this->spaceIcon;
1253                                         }
1254                                         if ($this->currentTable['next'][$row['uid']])   {       // Down
1255                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
1256                                                 $cells['moveDown']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveDown', TRUE) . '">' .
1257                                                                         t3lib_iconWorks::getSpriteIcon('actions-move-down') .
1258                                                                 '</a>';
1259                                         } else {
1260                                                 $cells['moveDown'] = $this->spaceIcon;
1261                                         }
1262                                 } elseif(!$this->table) {
1263                                         $cells['moveUp']  = $this->spaceIcon;
1264                                         $cells['moveDown'] = $this->spaceIcon;
1265                                 }
1266
1267                                         // "Hide/Unhide" links:
1268                                 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1269                                 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
1270                                         if ($row[$hiddenField]) {
1271                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1272                                                 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('unHide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1273                                                                         t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1274                                                                 '</a>';
1275                                         } else {
1276                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1277                                                 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('hide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1278                                                                         t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1279                                                                 '</a>';
1280                                         }
1281                                 } elseif(!$this->table) {
1282                                         $cells['hide'] = $this->spaceIcon;
1283                                 }
1284
1285                                         // "Delete" link:
1286                                 if (($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))) {
1287                                         $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
1288                                         $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
1289                                         $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
1290
1291                                         $refCountMsg = t3lib_BEfunc::referenceCount(
1292                                                 $table,
1293                                                 $row['uid'],
1294                                                 ' ' . $GLOBALS['LANG']->sL(
1295                                                         'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
1296                                                 ),
1297                                                 $this->getReferenceCount($table, $row['uid'])
1298                                         ) .
1299                                                 t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
1300                                         $cells['delete']='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').' "'. $title.'" '.$refCountMsg).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'" title="' . $LANG->getLL('delete', TRUE) . '">' .
1301                                                         t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1302                                                         '</a>';
1303                                 } elseif(!$this->table) {
1304                                         $cells['delete'] = $this->spaceIcon;
1305                                 }
1306
1307                                         // "Levels" links: Moving pages into new levels...
1308                                 if ($permsEdit && $table=='pages' && !$this->searchLevels)      {
1309
1310                                                 // Up (Paste as the page right after the current parent page)
1311                                         if ($this->calcPerms&8) {
1312                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
1313                                                 $cells['moveLeft']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('prevLevel', TRUE).'">'.
1314                                                                         t3lib_iconWorks::getSpriteIcon('actions-move-left') .
1315                                                                 '</a>';
1316                                         }
1317                                                 // Down (Paste as subpage to the page right above)
1318                                         if ($this->currentTable['prevUid'][$row['uid']])        {
1319                                                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
1320                                                 if ($localCalcPerms&8)  {
1321                                                         $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
1322                                                         $cells['moveRight']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('nextLevel', TRUE).'">'.
1323                                                                                 t3lib_iconWorks::getSpriteIcon('actions-move-right') .
1324                                                                         '</a>';
1325                                                 } else {
1326                                                         $cells['moveRight'] = $this->spaceIcon;
1327                                                 }
1328                                         } else {
1329                                                 $cells['moveRight'] = $this->spaceIcon;
1330                                         }
1331                                 } elseif(!$this->table) {
1332                                         $cells['moveLeft'] = $this->spaceIcon;
1333                                         $cells['moveRight'] = $this->spaceIcon;
1334                                 }
1335                         }
1336                 }
1337
1338
1339                 /**
1340                  * @hook                        recStatInfoHooks: Allows to insert HTML before record icons on various places
1341                  * @date                        2007-09-22
1342                  * @request             Kasper Skårhøj  <kasper2007@typo3.com>
1343                  */
1344                 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))     {
1345                         $stat='';
1346                         $_params = array($table,$row['uid']);
1347                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)     {
1348                                 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1349                         }
1350                         $cells['stat'] = $stat;
1351                 }
1352                 /**
1353                  * @hook                        makeControl: Allows to change control icons of records in list-module
1354                  * @date                        2007-11-20
1355                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
1356                  * @usage               This hook method gets passed the current $cells array as third parameter. This array contains values for the icons/actions generated for each record in Web>List. Each array entry is accessible by an index-key. The order of the icons is dependend on the order of those array entries.
1357                  */
1358                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1359                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1360                                 $hookObject = t3lib_div::getUserObj($classData);
1361                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
1362                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567840);
1363                                 }
1364                                 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1365                         }
1366                 }
1367
1368                         // Compile items into a DIV-element:
1369                 return '
1370                                                                                         <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
1371                                                                                         <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
1372         }
1373
1374         /**
1375          * Creates the clipboard panel for a single record in the listing.
1376          *
1377          * @param       string          The table
1378          * @param       array           The record for which to make the clipboard panel.
1379          * @return      string          HTML table with the clipboard panel (unless disabled)
1380          */
1381         function makeClip($table,$row)  {
1382                 global $TCA, $LANG, $TYPO3_CONF_VARS;
1383
1384                         // Return blank, if disabled:
1385                 if ($this->dontShowClipControlPanels)   return '';
1386                 $cells=array();
1387
1388                 $cells['pasteAfter'] = $cells['pasteInto'] = $this->spaceIcon;
1389                         //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1390                 $isL10nOverlay = $this->localizationView && $table != 'pages_language_overlay' && $row[$TCA[$table]['ctrl']['transOrigPointerField']] != 0;
1391                         // Return blank, if disabled:
1392                         // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1393                 if ($this->clipObj->current=='normal')  {       // For the "Normal" pad:
1394
1395                                 // Show copy/cut icons:
1396                         $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1397                         $cells['copy'] = $isL10nOverlay ? $this->spaceIcon : '<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.copy', TRUE).'">'.
1398                                                 ((!$isSel=='copy') ? t3lib_iconWorks::getSpriteIcon('actions-edit-copy') : t3lib_iconWorks::getSpriteIcon('actions-edit-copy-release')) .
1399                                         '</a>';
1400                         $cells['cut'] = $isL10nOverlay ? $this->spaceIcon : '<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.cut', TRUE).'">'.
1401                                                 ((!$isSel=='cut') ? t3lib_iconWorks::getSpriteIcon('actions-edit-cut') : t3lib_iconWorks::getSpriteIcon('actions-edit-cut-release')) .
1402                                         '</a>';
1403
1404                 } else {        // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1405
1406                                 // Setting name of the element in ->CBnames array:
1407                         $n=$table.'|'.$row['uid'];
1408                         $this->CBnames[]=$n;
1409
1410                                 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1411                         $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1412
1413                                 // If the "duplicateField" value is set then select all elements which are duplicates...
1414                         if ($this->duplicateField && isset($row[$this->duplicateField]))        {
1415                                 $checked='';
1416                                 if (in_array($row[$this->duplicateField], $this->duplicateStack))       {
1417                                         $checked=' checked="checked"';
1418                                 }
1419                                 $this->duplicateStack[] = $row[$this->duplicateField];
1420                         }
1421
1422                                 // Adding the checkbox to the panel:
1423                         $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1424                 }
1425
1426                         // Now, looking for selected elements from the current table:
1427                 $elFromTable = $this->clipObj->elFromTable($table);
1428                 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby'])      {       // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1429                         $cells['pasteAfter'] = $isL10nOverlay ? $this->spaceIcon : '<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'" title="'.$LANG->getLL('clip_pasteAfter', TRUE).'">'.
1430                                                 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
1431                                         '</a>';
1432                 }
1433
1434                         // Now, looking for elements in general:
1435                 $elFromTable = $this->clipObj->elFromTable('');
1436                 if ($table=='pages' && count($elFromTable))     {
1437                         $cells['pasteInto']='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'" title="'.$LANG->getLL('clip_pasteInto', TRUE).'">'.
1438                                                 t3lib_iconWorks::getSpriteIcon('actions-document-paste-into') .
1439                                         '</a>';
1440                 }
1441
1442                 /*
1443                  * @hook                        makeClip: Allows to change clip-icons of records in list-module
1444                  * @date                        2007-11-20
1445                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
1446                  * @usage               This hook method gets passed the current $cells array as third parameter. This array contains values for the clipboard icons generated for each record in Web>List. Each array entry is accessible by an index-key. The order of the icons is dependend on the order of those array entries.
1447                  */
1448                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1449                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1450                                 $hookObject = t3lib_div::getUserObj($classData);
1451                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
1452                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567845);
1453                                 }
1454                                 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1455                         }
1456                 }
1457
1458                         // Compile items into a DIV-element:
1459                 return '                                                        <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1460                                                                                         <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1461         }
1462
1463         /**
1464          * Make reference count
1465          *
1466          * @param       string          Table name
1467          * @param       integer         UID of record
1468          * @return      string          HTML-table
1469          *
1470          * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use createReferenceHtml() instead
1471          */
1472         function makeRef($table,$uid)   {
1473                 t3lib_div::logDeprecatedFunction();
1474
1475                         // Compile information for title tag:
1476                 $infoData=array();
1477                 if (is_array($this->references)) {
1478                         foreach ($this->references as $row) {
1479                                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1480                         }
1481                 }
1482
1483                 return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$uid.'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd_cs(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
1484         }
1485
1486         /**
1487          * Creates the HTML for a reference count for the record with the UID $uid
1488          * in the table $tableName.
1489          *
1490          * @param string $tableName
1491          *        table name of the referenced record, must not be empty
1492          * @param integer $uid
1493          *        UID of the referenced record, must be > 0
1494          *
1495          * @return string HTML of reference a link, will be empty if there are no
1496          *                references to the corresponding record
1497          */
1498         protected function createReferenceHtml($tableName, $uid) {
1499                 $referenceCount = $this->getReferenceCount($tableName, $uid);
1500                 if ($referenceCount == 0) {
1501                         return '';
1502                 }
1503
1504                 $queryResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1505                         'tablename, recuid, field',
1506                         'sys_refindex',
1507                         'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
1508                                 $tableName, 'sys_refindex'
1509                         ) .
1510                                 ' AND ref_uid = ' . $uid .
1511                                 ' AND deleted = 0',
1512                         '',
1513                         '',
1514                         '0,20'
1515                 );
1516
1517                 $referenceTitles = array();
1518
1519                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
1520                         $referenceTitles[] = $row['tablename'] . ':' . $row['recuid'] .
1521                                 ':' . $row['field'];
1522                         if (strlen(implode(' / ', $referenceTitles)) >= 100) {
1523                                 break;
1524                         }
1525                 }
1526                 $GLOBALS['TYPO3_DB']->sql_free_result($queryResult);
1527
1528                 return '<a href="#" ' .
1529                         'onclick="' . htmlspecialchars(
1530                                 'top.launchView(\'' . $tableName . '\', \'' . $uid .
1531                                 '\'); return false;'
1532                         ) . '" ' .
1533                         'title="' . htmlspecialchars(
1534                                 t3lib_div::fixed_lgd_cs(implode(' / ', $referenceTitles), 100)
1535                         ) . '">' . $referenceCount . '</a>';
1536         }
1537
1538         /**
1539          * Creates the localization panel
1540          *
1541          * @param       string          The table
1542          * @param       array           The record for which to make the localization panel.
1543          * @return      array           Array with key 0/1 with content for column 1 and 2
1544          */
1545         function makeLocalizationPanel($table,$row)     {
1546                 global $TCA,$LANG;
1547
1548                 $out = array(
1549                         0 => '',
1550                         1 => '',
1551                 );
1552
1553                 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
1554                 $this->translations = $translations['translations'];
1555
1556                         // Language title and icon:
1557                 $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
1558
1559                 if (is_array($translations))    {
1560
1561                                 // Traverse page translations and add icon for each language that does NOT yet exist:
1562                         $lNew = '';
1563                         foreach($this->pageOverlays as $lUid_OnPage => $lsysRec)        {
1564                                 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage))      {
1565                                         $url = substr($this->listURL(), strlen($this->backPath));
1566                                         $href = $GLOBALS['SOBE']->doc->issueCommand(
1567                                                 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1568                                                 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1569                                         );
1570                                         $language = t3lib_BEfunc::getRecord('sys_language', $lUid_OnPage, 'title');
1571                                         if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
1572                                                 $lC = t3lib_iconWorks::getSpriteIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon']);;
1573                                         } else {
1574                                                 $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
1575                                         }
1576                                         $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
1577
1578                                         $lNew.=$lC;
1579                                 }
1580                         }
1581
1582                         if ($lNew)      $out[1].= $lNew;
1583                 } else if ($row['l18n_parent']) {
1584                         $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
1585                 }
1586
1587
1588                 return $out;
1589         }
1590
1591         /**
1592          * Create the selector box for selecting fields to display from a table:
1593          *
1594          * @param       string          Table name
1595          * @param       boolean         If true, form-fields will be wrapped around the table.
1596          * @return      string          HTML table with the selector box (name: displayFields['.$table.'][])
1597          */
1598         function fieldSelectBox($table,$formFields=1)   {
1599                 global $TCA, $LANG;
1600
1601                         // Init:
1602                 t3lib_div::loadTCA($table);
1603                 $formElements=array('','');
1604                 if ($formFields)        {
1605                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1606                 }
1607
1608                         // Load already selected fields, if any:
1609                 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1610
1611                         // Request fields from table:
1612                 $fields = $this->makeFieldList($table, false, true);
1613
1614                         // Add pseudo "control" fields
1615                 $fields[]='_PATH_';
1616                 $fields[]='_REF_';
1617                 $fields[]='_LOCALIZATION_';
1618                 $fields[]='_CONTROL_';
1619                 $fields[]='_CLIPBOARD_';
1620
1621                         // Create an option for each field:
1622                 $opt=array();
1623                 $opt[] = '<option value=""></option>';
1624                 foreach($fields as $fN) {
1625                         $fL = is_array($TCA[$table]['columns'][$fN]) ? rtrim($LANG->sL($TCA[$table]['columns'][$fN]['label']),':') : '['.$fN.']';       // Field label
1626                         $opt[] = '
1627                                                                                         <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1628                 }
1629
1630                         // Compile the options into a multiple selector box:
1631                 $lMenu = '
1632                                                                                 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1633                                                                                 </select>
1634                                 ';
1635
1636                         // Table with the field selector::
1637                 $content.= '
1638                         '.$formElements[0].'
1639
1640                                 <!--
1641                                         Field selector for extended table view:
1642                                 -->
1643                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-fieldSelect">
1644                                         <tr>
1645                                                 <td>'.$lMenu.'</td>
1646                                                 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
1647                                         </tr>
1648                                 </table>
1649                         '.$formElements[1];
1650                 return $content;
1651         }
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663         /*********************************
1664          *
1665          * Helper functions
1666          *
1667          *********************************/
1668
1669         /**
1670          * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1671          * Currently, this is used for setting elements / delete elements.
1672          *
1673          * @param       string          The HTML content to link (image/text)
1674          * @param       string          Table name
1675          * @param       string          Clipboard command (eg. "setCB" or "delete")
1676          * @param       string          Warning text, if any ("delete" uses this for confirmation)
1677          * @return      string          <a> tag wrapped link.
1678          */
1679         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
1680                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1681                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1682                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1683         }
1684
1685         /**
1686          * Returns true if a numeric clipboard pad is selected/active
1687          *
1688          * @return      boolean
1689          */
1690         function clipNumPane()  {
1691                 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1692         }
1693
1694         /**
1695          * Creates a sort-by link on the input string ($code).
1696          * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1697          * Also some fields will not be possible to sort (including if single-table-view is disabled).
1698          *
1699          * @param       string          The string to link (text)
1700          * @param       string          The fieldname represented by the title ($code)
1701          * @param       string          Table name
1702          * @return      string          Linked $code variable
1703          */
1704         function addSortLink($code,$field,$table)       {
1705
1706                         // Certain circumstances just return string right away (no links):
1707                 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView)       return $code;
1708
1709                         // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1710                 if ($field=='_PATH_')   $field=pid;
1711
1712                         //       Create the sort link:
1713                 $sortUrl = $this->listURL('', -1, 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || ($this->sortField != $field) ? 0 : 1);
1714                 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1715
1716                         // Return linked field:
1717                 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1718                                 $sortArrow.
1719                                 '</a>';
1720         }
1721
1722         /**
1723          * Returns the path for a certain pid
1724          * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1725          *
1726          * @param       integer         The page id for which to get the path
1727          * @return      string          The path.
1728          */
1729         function recPath($pid)  {
1730                 if (!isset($this->recPath_cache[$pid])) {
1731                         $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1732                 }
1733                 return $this->recPath_cache[$pid];
1734         }
1735
1736         /**
1737          * Returns true if a link for creating new records should be displayed for $table
1738          *
1739          * @param       string          Table name
1740          * @return      boolean         Returns true if a link for creating new records should be displayed for $table
1741          * @see         SC_db_new::showNewRecLink
1742          */
1743         function showNewRecLink($table) {
1744                         // No deny/allow tables are set:
1745                 if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
1746                         return true;
1747                         // If table is not denied (which takes precedence over allowed tables):
1748                 } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
1749                         return true;
1750                         // If table is denied or allowed tables are set, but table is not part of:
1751                 } else {
1752                         return false;
1753                 }
1754         }
1755
1756         /**
1757          * Creates the "&returnUrl" parameter for links - this is used when the script links to other scripts and passes its own URL with the link so other scripts can return to the listing again.
1758          * Uses REQUEST_URI as value.
1759          *
1760          * @return      string
1761          */
1762         function makeReturnUrl()        {
1763                 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1764         }
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776         /************************************
1777          *
1778          * CSV related functions
1779          *
1780          ************************************/
1781
1782         /**
1783          * Initializes internal csvLines array with the header of field names
1784          *
1785          * @return      void
1786          */
1787         protected function initCSV() {
1788                 $this->addHeaderRowToCSV();
1789         }
1790
1791         /**
1792          * Add header line with field names as CSV line
1793          *
1794          * @return void
1795          */
1796         protected function addHeaderRowToCSV() {
1797                         // Add header row, control fields will be reduced inside addToCSV()
1798                 $this->addToCSV(array_combine($this->fieldArray, $this->fieldArray));
1799         }
1800
1801         /**
1802          * Adds selected columns of one table row as CSV line.
1803          *
1804          * @param       array           Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1805          * @param       string          Table name @deprecated since 4.4
1806          * @return      void
1807          */
1808         protected function addToCSV(array $row = array(), $table = '') {
1809                 $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
1810                 $rowReducedToSelectedColumns = array_intersect_key($rowReducedByControlFields, array_flip($this->fieldArray));
1811                 $this->setCsvRow($rowReducedToSelectedColumns);
1812         }
1813
1814         /**
1815          * Remove control fields from row for CSV export
1816          *
1817          * @param array fieldNames => fieldValues
1818          * @return array Input array reduces by control fields
1819          */
1820         protected static function removeControlFieldsFromFieldRow(array $row = array()) {
1821                         // Possible control fields in a list row
1822                 $controlFields = array(
1823                         '_PATH_',
1824                         '_REF_',
1825                         '_CONTROL_',
1826                         '_AFTERCONTROL_',
1827                         '_AFTERREF_',
1828                         '_CLIPBOARD_',
1829                         '_LOCALIZATION_',
1830                         '_LOCALIZATION_b',
1831                 );
1832                 return array_diff_key($row, array_flip($controlFields));
1833         }
1834
1835
1836         /**
1837          * Adds input row of values to the internal csvLines array as a CSV formatted line
1838          *
1839          * @param       array           Array with values to be listed.
1840          * @return      void
1841          */
1842         function setCsvRow($csvRow)     {
1843                 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1844         }
1845
1846         /**
1847          * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1848          * This function exits!
1849          *
1850          * @param       string          Filename prefix:
1851          * @return      void            EXITS php execusion!
1852          */
1853         function outputCSV($prefix)     {
1854
1855                         // Setting filename:
1856                 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1857
1858                         // Creating output header:
1859                 $mimeType = 'application/octet-stream';
1860                 Header('Content-Type: '.$mimeType);
1861                 Header('Content-Disposition: attachment; filename='.$filename);
1862
1863                         // Printing the content of the CSV lines:
1864                 echo implode(chr(13).chr(10),$this->csvLines);
1865
1866                         // Exits:
1867                 exit;
1868         }
1869 }
1870
1871
1872
1873 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])) {
1874         include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1875 }
1876
1877 ?>