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