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