Fixed bug #14636: Improvements to new Backend skin, replace old styling - Part 5...
[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-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-record') .
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                                         <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_first.gif')
1025                                         . 'alt="' . $labelFirst . '" title="' . $labelFirst . '" />
1026                                 </a>';
1027                         } else {
1028                                 $first = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_first_disabled.gif') . 'alt="" title="" />';
1029                         }
1030
1031                         if (($currentPage - 1) > 0) {
1032                                 $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
1033
1034                                 $previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">
1035                                         <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_previous.gif')
1036                                         . 'alt="' . $labelPrevious . '" title="' . $labelPrevious . '" />
1037                                         </a>';
1038                         } else {
1039                                 $previous = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_previous_disabled.gif') . 'alt="" title="" />';
1040                         }
1041
1042                         if (($currentPage + 1) <= $totalPages) {
1043                                 $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
1044
1045                                 $next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">
1046                                         <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_next.gif')
1047                                         . 'alt="' . $labelNext . '" title="' . $labelNext . '" />
1048                                         </a>';
1049                         } else {
1050                                 $next = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_next_disabled.gif') . 'alt="" title="" />';
1051                         }
1052
1053                         if ($currentPage != $totalPages) {
1054                                 $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
1055
1056                                 $last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">
1057                                         <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_last.gif')
1058                                         . 'alt="' . $labelLast . '" title="' . $labelLast . '" />
1059                                         </a>';
1060                         } else {
1061                                 $last = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_last_disabled.gif') . 'alt="" title="" />';
1062                         }
1063
1064                         $reload = '<a href="#" onclick="document.dblistForm.action=\''
1065                                 . $listURL . '&pointer=\'+calculatePointer(); document.dblistForm.submit(); return true;" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:reload', TRUE) . '">' .
1066                                         t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1067                                 '</a>';
1068
1069                         // Add js to traverse a page select input to a pointer value
1070                         $content = '
1071 <script type="text/JavaScript">
1072 /*<![CDATA[*/
1073
1074         function calculatePointer(){
1075                 page = document.getElementById(\'jumpPage\').value;
1076
1077                 if (page > ' . $totalPages . ') {
1078                         page = ' . $totalPages . ';
1079                 }
1080
1081                 if (page < 1) {
1082                         page = 1;
1083                 }
1084
1085                 pointer = (page - 1) * ' . $this->iLimit . ';
1086
1087                 return pointer;
1088         }
1089
1090 /*]]>*/
1091 </script>
1092 ';
1093
1094                         $pageNumberInput = '<span>
1095                                 <input type="text" value="' . $currentPage
1096                                 . '" size="3" id="jumpPage" name="jumpPage" onkeyup="if (event.keyCode == Event.KEY_RETURN) { document.dblistForm.action=\'' . $listURL . '&pointer=\'+calculatePointer(); document.dblistForm.submit(); } return true;" />
1097                                 </span>';
1098                         $pageIndicator = '<span class="pageIndicator">'
1099                                 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
1100                                 . '</span>';
1101
1102                         if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
1103                                 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1104                         } else {
1105                                 $lastElementNumber = $this->totalItems;
1106                         }
1107                         $rangeIndicator = '<span class="pageIndicator">'
1108                                 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
1109                                 . '</span>';
1110
1111                         $content .= '<div id="typo3-dblist-pagination">'
1112                                 . $first . $previous
1113                                 . '<span class="bar">&nbsp;</span>'
1114                                 . $rangeIndicator . '<span class="bar">&nbsp;</span>'
1115                                 . $pageIndicator . '<span class="bar">&nbsp;</span>'
1116                                 . $next . $last . '<span class="bar">&nbsp;</span>'
1117                                 . $reload
1118                                 . '</div>';
1119
1120                         $data = Array();
1121                         $titleColumn = $this->fieldArray[0];
1122                         $data[$titleColumn] = $content;
1123
1124                         $returnContent = $this->addElement(1, '', $data);
1125                 } // end of if pages > 1
1126
1127                 return $returnContent;
1128         }
1129
1130
1131
1132
1133
1134
1135         /*********************************
1136          *
1137          * Rendering of various elements
1138          *
1139          *********************************/
1140
1141         /**
1142          * Creates the control panel for a single record in the listing.
1143          *
1144          * @param       string          The table
1145          * @param       array           The record for which to make the control panel.
1146          * @return      string          HTML table with the control panel (unless disabled)
1147          */
1148         function makeControl($table,$row)       {
1149                 global $TCA, $LANG, $SOBE, $TYPO3_CONF_VARS;
1150
1151                 if ($this->dontShowClipControlPanels)   return '';
1152
1153                         // Initialize:
1154                 t3lib_div::loadTCA($table);
1155                 $cells=array();
1156
1157                         // If the listed table is 'pages' we have to request the permission settings for each page:
1158                 if ($table=='pages')    {
1159                         $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
1160                 }
1161
1162                         // This expresses the edit permissions for this particular element:
1163                 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
1164
1165                         // "Show" link (only pages and tt_content elements)
1166                 if ($table=='pages' || $table=='tt_content')    {
1167                         $params='&edit['.$table.']['.$row['uid'].']=edit';
1168                         $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).'">'.
1169                                                 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1170                                         '</a>';
1171                 } elseif(!$this->table) {
1172                         $cells['view'] = $this->spaceIcon;
1173                 }
1174
1175                         // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1176                 if ($permsEdit) {
1177                         $params='&edit['.$table.']['.$row['uid'].']=edit';
1178                         $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('edit', TRUE).'">'.
1179                                                 ( $TCA[$table]['ctrl']['readOnly'] ? t3lib_iconWorks::getSpriteIcon('actions-document-open-read-only') : t3lib_iconWorks::getSpriteIcon('actions-document-open') ).
1180                                         '</a>';
1181                 } elseif(!$this->table) {
1182                         $cells['edit'] = $this->spaceIcon;
1183                 }
1184
1185                         // "Move" wizard link for pages/tt_content elements:
1186                 if (($table=="tt_content" && $permsEdit) || ($table=='pages'))  {
1187                         $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) . '">' .
1188                                                 ($table == 'tt_content' ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
1189                                         '</a>';
1190                 } elseif(!$this->table) {
1191                         $cells['move'] = $this->spaceIcon;
1192                 }
1193
1194                         // If the extended control panel is enabled OR if we are seeing a single table:
1195                 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table)     {
1196
1197                                 // "Info": (All records)
1198                         $cells['viewBig']='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'" title="'.$LANG->getLL('showInfo', TRUE).'">'.
1199                                                 t3lib_iconWorks::getSpriteIcon('actions-document-info') .
1200                                         '</a>';
1201
1202                                 // If the table is NOT a read-only table, then show these links:
1203                         if (!$TCA[$table]['ctrl']['readOnly'])  {
1204
1205                                         // "Revert" link (history/undo)
1206                                 $cells['history']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'" title="'.$LANG->getLL('history', TRUE).'">'.
1207                                                         t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1208                                                 '</a>';
1209
1210                                         // Versioning:
1211                                 if (t3lib_extMgm::isLoaded('version'))  {
1212                                         $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row);
1213                                         if (is_array($vers))    {       // If table can be versionized.
1214                                                 $versionIcon = 'no-version';
1215                                                 if (count($vers) > 1) {
1216                                                         $versionIcon = count($vers) - 1;
1217                                                 }
1218
1219                                                 $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) . '">' .
1220                                                                 t3lib_iconWorks::getSpriteIcon('status-version-' . $versionIcon) .
1221                                                                 '</a>';
1222                                         } elseif(!$this->table) {
1223                                                 $cells['version'] = $this->spaceIcon;
1224                                         }
1225                                 }
1226
1227                                         // "Edit Perms" link:
1228                                 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm'))        {
1229                                         $cells['perms']='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'" title="'.$LANG->getLL('permissions', TRUE).'">'.
1230                                                                 t3lib_iconWorks::getSpriteIcon('status-status-locked') .
1231                                                         '</a>';
1232                                 } elseif(!$this->table && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1233                                         $cells['perms'] = $this->spaceIcon;
1234                                 }
1235
1236                                         // "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):
1237                                 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
1238                                         if (
1239                                                 ($table!='pages' && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
1240                                                 ($table=='pages' && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
1241                                                 )       {
1242                                                 if ($this->showNewRecLink($table))      {
1243                                                         $params='&edit['.$table.']['.(-($row['_MOVE_PLH']?$row['_MOVE_PLH_uid']:$row['uid'])).']=new';
1244                                                         $cells['new']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'), TRUE).'">'.
1245                                                                                 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
1246                                                                         '</a>';
1247                                                 }
1248                                         }
1249                                 } elseif(!$this->table) {
1250                                         $cells['new'] = $this->spaceIcon;
1251                                 }
1252
1253                                         // "Up/Down" links
1254                                 if ($permsEdit && $TCA[$table]['ctrl']['sortby']  && !$this->sortField && !$this->searchLevels) {
1255                                         if (isset($this->currentTable['prev'][$row['uid']]))    {       // Up
1256                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
1257                                                 $cells['moveUp']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveUp', TRUE) . '">' .
1258                                                                         t3lib_iconWorks::getSpriteIcon('actions-move-up') .
1259                                                                 '</a>';
1260                                         } else {
1261                                                 $cells['moveUp'] = $this->spaceIcon;
1262                                         }
1263                                         if ($this->currentTable['next'][$row['uid']])   {       // Down
1264                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
1265                                                 $cells['moveDown']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveDown', TRUE) . '">' .
1266                                                                         t3lib_iconWorks::getSpriteIcon('actions-move-down') .
1267                                                                 '</a>';
1268                                         } else {
1269                                                 $cells['moveDown'] = $this->spaceIcon;
1270                                         }
1271                                 } elseif(!$this->table) {
1272                                         $cells['moveUp']  = $this->spaceIcon;
1273                                         $cells['moveDown'] = $this->spaceIcon;
1274                                 }
1275
1276                                         // "Hide/Unhide" links:
1277                                 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1278                                 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
1279                                         if ($row[$hiddenField]) {
1280                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1281                                                 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('unHide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1282                                                                         t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1283                                                                 '</a>';
1284                                         } else {
1285                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1286                                                 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('hide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1287                                                                         t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1288                                                                 '</a>';
1289                                         }
1290                                 } elseif(!$this->table) {
1291                                         $cells['hide'] = $this->spaceIcon;
1292                                 }
1293
1294                                         // "Delete" link:
1295                                 if (($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))) {
1296                                         $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
1297                                         $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
1298                                         $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
1299
1300                                         $refCountMsg = t3lib_BEfunc::referenceCount(
1301                                                 $table,
1302                                                 $row['uid'],
1303                                                 ' ' . $GLOBALS['LANG']->sL(
1304                                                         'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
1305                                                 ),
1306                                                 $this->getReferenceCount($table, $row['uid'])
1307                                         ) .
1308                                                 t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
1309                                         $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) . '">' .
1310                                                         t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1311                                                         '</a>';
1312                                 } elseif(!$this->table) {
1313                                         $cells['delete'] = $this->spaceIcon;
1314                                 }
1315
1316                                         // "Levels" links: Moving pages into new levels...
1317                                 if ($permsEdit && $table=='pages' && !$this->searchLevels)      {
1318
1319                                                 // Up (Paste as the page right after the current parent page)
1320                                         if ($this->calcPerms&8) {
1321                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
1322                                                 $cells['moveLeft']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('prevLevel', TRUE).'">'.
1323                                                                         t3lib_iconWorks::getSpriteIcon('actions-move-left') .
1324                                                                 '</a>';
1325                                         }
1326                                                 // Down (Paste as subpage to the page right above)
1327                                         if ($this->currentTable['prevUid'][$row['uid']])        {
1328                                                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
1329                                                 if ($localCalcPerms&8)  {
1330                                                         $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
1331                                                         $cells['moveRight']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('nextLevel', TRUE).'">'.
1332                                                                                 t3lib_iconWorks::getSpriteIcon('actions-move-right') .
1333                                                                         '</a>';
1334                                                 } else {
1335                                                         $cells['moveRight'] = $this->spaceIcon;
1336                                                 }
1337                                         } else {
1338                                                 $cells['moveRight'] = $this->spaceIcon;
1339                                         }
1340                                 } elseif(!$this->table) {
1341                                         $cells['moveLeft'] = $this->spaceIcon;
1342                                         $cells['moveRight'] = $this->spaceIcon;
1343                                 }
1344                         }
1345                 }
1346
1347
1348                 /**
1349                  * @hook                        recStatInfoHooks: Allows to insert HTML before record icons on various places
1350                  * @date                        2007-09-22
1351                  * @request             Kasper Skaarhoj  <kasper2007@typo3.com>
1352                  */
1353                 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))     {
1354                         $stat='';
1355                         $_params = array($table,$row['uid']);
1356                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)     {
1357                                 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1358                         }
1359                         $cells['stat'] = $stat;
1360                 }
1361                 /**
1362                  * @hook                        makeControl: Allows to change control icons of records in list-module
1363                  * @date                        2007-11-20
1364                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
1365                  * @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.
1366                  */
1367                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1368                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1369                                 $hookObject = t3lib_div::getUserObj($classData);
1370                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
1371                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567840);
1372                                 }
1373                                 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1374                         }
1375                 }
1376
1377                         // Compile items into a DIV-element:
1378                 return '
1379                                                                                         <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
1380                                                                                         <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
1381         }
1382
1383         /**
1384          * Creates the clipboard panel for a single record in the listing.
1385          *
1386          * @param       string          The table
1387          * @param       array           The record for which to make the clipboard panel.
1388          * @return      string          HTML table with the clipboard panel (unless disabled)
1389          */
1390         function makeClip($table,$row)  {
1391                 global $TCA, $LANG, $TYPO3_CONF_VARS;
1392
1393                         // Return blank, if disabled:
1394                 if ($this->dontShowClipControlPanels)   return '';
1395                 $cells=array();
1396
1397                 $cells['pasteAfter'] = $cells['pasteInto'] = $this->spaceIcon;
1398                         //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1399                 $isL10nOverlay = $this->localizationView && $table != 'pages_language_overlay' && $row[$TCA[$table]['ctrl']['transOrigPointerField']] != 0;
1400                         // Return blank, if disabled:
1401                         // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1402                 if ($this->clipObj->current=='normal')  {       // For the "Normal" pad:
1403
1404                                 // Show copy/cut icons:
1405                         $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1406                         $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).'">'.
1407                                                 ((!$isSel=='copy') ? t3lib_iconWorks::getSpriteIcon('actions-edit-copy') : t3lib_iconWorks::getSpriteIcon('actions-edit-copy-release')) .
1408                                         '</a>';
1409                         $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).'">'.
1410                                                 ((!$isSel=='cut') ? t3lib_iconWorks::getSpriteIcon('actions-edit-cut') : t3lib_iconWorks::getSpriteIcon('actions-edit-cut-release')) .
1411                                         '</a>';
1412
1413                 } else {        // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1414
1415                                 // Setting name of the element in ->CBnames array:
1416                         $n=$table.'|'.$row['uid'];
1417                         $this->CBnames[]=$n;
1418
1419                                 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1420                         $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1421
1422                                 // If the "duplicateField" value is set then select all elements which are duplicates...
1423                         if ($this->duplicateField && isset($row[$this->duplicateField]))        {
1424                                 $checked='';
1425                                 if (in_array($row[$this->duplicateField], $this->duplicateStack))       {
1426                                         $checked=' checked="checked"';
1427                                 }
1428                                 $this->duplicateStack[] = $row[$this->duplicateField];
1429                         }
1430
1431                                 // Adding the checkbox to the panel:
1432                         $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1433                 }
1434
1435                         // Now, looking for selected elements from the current table:
1436                 $elFromTable = $this->clipObj->elFromTable($table);
1437                 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby'])      {       // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1438                         $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).'">'.
1439                                                 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
1440                                         '</a>';
1441                 }
1442
1443                         // Now, looking for elements in general:
1444                 $elFromTable = $this->clipObj->elFromTable('');
1445                 if ($table=='pages' && count($elFromTable))     {
1446                         $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).'">'.
1447                                                 t3lib_iconWorks::getSpriteIcon('actions-document-paste-into') .
1448                                         '</a>';
1449                 }
1450
1451                 /*
1452                  * @hook                        makeClip: Allows to change clip-icons of records in list-module
1453                  * @date                        2007-11-20
1454                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
1455                  * @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.
1456                  */
1457                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1458                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1459                                 $hookObject = t3lib_div::getUserObj($classData);
1460                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
1461                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567845);
1462                                 }
1463                                 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1464                         }
1465                 }
1466
1467                         // Compile items into a DIV-element:
1468                 return '                                                        <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1469                                                                                         <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1470         }
1471
1472         /**
1473          * Make reference count
1474          *
1475          * @param       string          Table name
1476          * @param       integer         UID of record
1477          * @return      string          HTML-table
1478          *
1479          * @deprecated since 4.4: Use getReferenceHTML() instead
1480          */
1481         function makeRef($table,$uid)   {
1482                 t3lib_div::logDeprecatedFunction();
1483
1484                         // Compile information for title tag:
1485                 $infoData=array();
1486                 if (is_array($this->references)) {
1487                         foreach ($this->references as $row) {
1488                                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1489                         }
1490                 }
1491
1492                 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>' : '';
1493         }
1494
1495         /**
1496          * Creates the HTML for a reference count for the record with the UID $uid
1497          * in the table $tableName.
1498          *
1499          * @param string $tableName
1500          *        table name of the referenced record, must not be empty
1501          * @param integer $uid
1502          *        UID of the referenced record, must be > 0
1503          *
1504          * @return string HTML of reference a link, will be empty if there are no
1505          *                references to the corresponding record
1506          */
1507         protected function createReferenceHtml($tableName, $uid) {
1508                 $referenceCount = $this->getReferenceCount($tableName, $uid);
1509                 if ($referenceCount == 0) {
1510                         return '';
1511                 }
1512
1513                 $queryResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1514                         'tablename, recuid, field',
1515                         'sys_refindex',
1516                         'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
1517                                 $tableName, 'sys_refindex'
1518                         ) .
1519                                 ' AND ref_uid = ' . $uid .
1520                                 ' AND deleted = 0',
1521                         '',
1522                         '',
1523                         '0,20'
1524                 );
1525
1526                 $referenceTitles = array();
1527
1528                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
1529                         $referenceTitles[] = $row['tablename'] . ':' . $row['recuid'] .
1530                                 ':' . $row['field'];
1531                         if (strlen(implode(' / ', $referenceTitles)) >= 100) {
1532                                 break;
1533                         }
1534                 }
1535                 $GLOBALS['TYPO3_DB']->sql_free_result($queryResult);
1536
1537                 return '<a href="#" ' .
1538                         'onclick="' . htmlspecialchars(
1539                                 'top.launchView(\'' . $tableName . '\', \'' . $uid .
1540                                 '\'); return false;'
1541                         ) . '" ' .
1542                         'title="' . htmlspecialchars(
1543                                 t3lib_div::fixed_lgd_cs(implode(' / ', $referenceTitles), 100)
1544                         ) . '">' . $referenceCount . '</a>';
1545         }
1546
1547         /**
1548          * Creates the localization panel
1549          *
1550          * @param       string          The table
1551          * @param       array           The record for which to make the localization panel.
1552          * @return      array           Array with key 0/1 with content for column 1 and 2
1553          */
1554         function makeLocalizationPanel($table,$row)     {
1555                 global $TCA,$LANG;
1556
1557                 $out = array(
1558                         0 => '',
1559                         1 => '',
1560                 );
1561
1562                 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
1563                 $this->translations = $translations['translations'];
1564
1565                         // Language title and icon:
1566                 $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
1567
1568                 if (is_array($translations))    {
1569
1570                                 // Traverse page translations and add icon for each language that does NOT yet exist:
1571                         $lNew = '';
1572                         foreach($this->pageOverlays as $lUid_OnPage => $lsysRec)        {
1573                                 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage))      {
1574                                         $href = $this->backPath . $GLOBALS['TBE_TEMPLATE']->issueCommand(
1575                                                 '&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage,
1576                                                 $this->listURL().'&justLocalized='.rawurlencode($table.':'.$row['uid'].':'.$lUid_OnPage)
1577                                         );
1578                                         $language = t3lib_BEfunc::getRecord('sys_language', $lUid_OnPage, 'title');
1579                                         $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$lUid_OnPage]['flagIcon'].'" class="absmiddle" alt="" />' : $this->languageIconTitles[$lUid_OnPage]['title']);
1580                                         $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
1581
1582                                         $lNew.=$lC;
1583                                 }
1584                         }
1585
1586                         if ($lNew)      $out[1].= $lNew;
1587                 } else {
1588                         $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
1589                 }
1590
1591
1592                 return $out;
1593         }
1594
1595         /**
1596          * Create the selector box for selecting fields to display from a table:
1597          *
1598          * @param       string          Table name
1599          * @param       boolean         If true, form-fields will be wrapped around the table.
1600          * @return      string          HTML table with the selector box (name: displayFields['.$table.'][])
1601          */
1602         function fieldSelectBox($table,$formFields=1)   {
1603                 global $TCA, $LANG;
1604
1605                         // Init:
1606                 t3lib_div::loadTCA($table);
1607                 $formElements=array('','');
1608                 if ($formFields)        {
1609                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1610                 }
1611
1612                         // Load already selected fields, if any:
1613                 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1614
1615                         // Request fields from table:
1616                 $fields = $this->makeFieldList($table, false, true);
1617
1618                         // Add pseudo "control" fields
1619                 $fields[]='_PATH_';
1620                 $fields[]='_REF_';
1621                 $fields[]='_LOCALIZATION_';
1622                 $fields[]='_CONTROL_';
1623                 $fields[]='_CLIPBOARD_';
1624
1625                         // Create an option for each field:
1626                 $opt=array();
1627                 $opt[] = '<option value=""></option>';
1628                 foreach($fields as $fN) {
1629                         $fL = is_array($TCA[$table]['columns'][$fN]) ? rtrim($LANG->sL($TCA[$table]['columns'][$fN]['label']),':') : '['.$fN.']';       // Field label
1630                         $opt[] = '
1631                                                                                         <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1632                 }
1633
1634                         // Compile the options into a multiple selector box:
1635                 $lMenu = '
1636                                                                                 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1637                                                                                 </select>
1638                                 ';
1639
1640                         // Table with the field selector::
1641                 $content.= '
1642                         '.$formElements[0].'
1643
1644                                 <!--
1645                                         Field selector for extended table view:
1646                                 -->
1647                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
1648                                         <tr>
1649                                                 <td>'.$lMenu.'</td>
1650                                                 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
1651                                         </tr>
1652                                 </table>
1653                         '.$formElements[1];
1654                 return $content;
1655         }
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667         /*********************************
1668          *
1669          * Helper functions
1670          *
1671          *********************************/
1672
1673         /**
1674          * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1675          * Currently, this is used for setting elements / delete elements.
1676          *
1677          * @param       string          The HTML content to link (image/text)
1678          * @param       string          Table name
1679          * @param       string          Clipboard command (eg. "setCB" or "delete")
1680          * @param       string          Warning text, if any ("delete" uses this for confirmation)
1681          * @return      string          <a> tag wrapped link.
1682          */
1683         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
1684                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1685                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1686                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1687         }
1688
1689         /**
1690          * Returns true if a numeric clipboard pad is selected/active
1691          *
1692          * @return      boolean
1693          */
1694         function clipNumPane()  {
1695                 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1696         }
1697
1698         /**
1699          * Creates a sort-by link on the input string ($code).
1700          * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1701          * Also some fields will not be possible to sort (including if single-table-view is disabled).
1702          *
1703          * @param       string          The string to link (text)
1704          * @param       string          The fieldname represented by the title ($code)
1705          * @param       string          Table name
1706          * @return      string          Linked $code variable
1707          */
1708         function addSortLink($code,$field,$table)       {
1709
1710                         // Certain circumstances just return string right away (no links):
1711                 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView)       return $code;
1712
1713                         // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1714                 if ($field=='_PATH_')   $field=pid;
1715
1716                         //       Create the sort link:
1717                 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1718                 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1719
1720                         // Return linked field:
1721                 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1722                                 $sortArrow.
1723                                 '</a>';
1724         }
1725
1726         /**
1727          * Returns the path for a certain pid
1728          * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1729          *
1730          * @param       integer         The page id for which to get the path
1731          * @return      string          The path.
1732          */
1733         function recPath($pid)  {
1734                 if (!isset($this->recPath_cache[$pid])) {
1735                         $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1736                 }
1737                 return $this->recPath_cache[$pid];
1738         }
1739
1740         /**
1741          * Returns true if a link for creating new records should be displayed for $table
1742          *
1743          * @param       string          Table name
1744          * @return      boolean         Returns true if a link for creating new records should be displayed for $table
1745          * @see         SC_db_new::showNewRecLink
1746          */
1747         function showNewRecLink($table) {
1748                         // No deny/allow tables are set:
1749                 if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
1750                         return true;
1751                         // If table is not denied (which takes precedence over allowed tables):
1752                 } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
1753                         return true;
1754                         // If table is denied or allowed tables are set, but table is not part of:
1755                 } else {
1756                         return false;
1757                 }
1758         }
1759
1760         /**
1761          * 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.
1762          * Uses REQUEST_URI as value.
1763          *
1764          * @return      string
1765          */
1766         function makeReturnUrl()        {
1767                 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1768         }
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780         /************************************
1781          *
1782          * CSV related functions
1783          *
1784          ************************************/
1785
1786         /**
1787          * Initializes internal csvLines array with the header of field names
1788          *
1789          * @return      void
1790          */
1791         function initCSV()      {
1792
1793                         // Reset:
1794                 $this->csvLines=array();
1795
1796                         // Getting header line with field names:
1797                 $csvRow = array();
1798                 foreach ($this->fieldArray as $fN) {
1799                         if ($fN == '_CONTROL_' || $fN == '_CLIPBOARD_') {
1800                                         continue;
1801                         }
1802                         $csvRow[] = $fN;
1803                 }
1804
1805                         // Set the header + an empty row:
1806                 $this->setCsvRow($csvRow);
1807                 $this->csvLines[] = '';
1808         }
1809
1810
1811         /**
1812          * Adds the content of input array $row to the CSV list:
1813          *
1814          * @param       array           Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1815          * @param       string          Table name
1816          * @return      void
1817          */
1818         function addToCSV($row,$table)  {
1819
1820                         // Traversing fields, adding values from $row:
1821                 $csvRow = array();
1822                 foreach ($this->fieldArray as $fN) {
1823                         switch ($fN) {
1824                                 case '_PATH_':
1825                                         $csvRow[] = $this->recPath($row['pid']);
1826                                         break;
1827
1828                                 case '_REF_':
1829                                         $csvRow[] = $this->createReferenceHtml($table, $row['uid']);
1830                                         break;
1831
1832                                         // remove these columns from the CSV view
1833                                 case '_CONTROL_':
1834                                 case '_CLIPBOARD_':
1835                                         continue;
1836                                         break;
1837
1838                                 default:
1839                                         $csvRow[] = $row[$fN];
1840                         }
1841                 }
1842
1843                         // Set the values in the CSV list
1844                 $this->setCsvRow($csvRow);
1845         }
1846
1847
1848         /**
1849          * Adds input row of values to the internal csvLines array as a CSV formatted line
1850          *
1851          * @param       array           Array with values to be listed.
1852          * @return      void
1853          */
1854         function setCsvRow($csvRow)     {
1855                 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1856         }
1857
1858         /**
1859          * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1860          * This function exits!
1861          *
1862          * @param       string          Filename prefix:
1863          * @return      void            EXITS php execusion!
1864          */
1865         function outputCSV($prefix)     {
1866
1867                         // Setting filename:
1868                 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1869
1870                         // Creating output header:
1871                 $mimeType = 'application/octet-stream';
1872                 Header('Content-Type: '.$mimeType);
1873                 Header('Content-Disposition: attachment; filename='.$filename);
1874
1875                         // Printing the content of the CSV lines:
1876                 echo implode(chr(13).chr(10),$this->csvLines);
1877
1878                         // Exits:
1879                 exit;
1880         }
1881 }
1882
1883
1884
1885 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])   {
1886         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1887 }
1888
1889 ?>