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