some cleanup (all non-functional)
[Packages/TYPO3.CMS.git] / typo3 / class.db_list_extra.inc
1 <?php
2 /*************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2007 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 $newWizards=FALSE;                                  // If true, the control panel will contain links to the create-new wizards for pages and tt_content elements (normally, the link goes to just creating a new element without the wizards!).
96
97         var $dontShowClipControlPanels=FALSE;   // If true, will disable the rendering of clipboard + control panels.
98         var $showClipboard=FALSE;                               // If true, will show the clipboard in the field list.
99         var $noControlPanels = FALSE;                   // If true, will DISABLE all control panels in lists. (Takes precedence)
100         var $clickMenuEnabled = TRUE;                   // If true, clickmenus will be rendered
101
102
103
104
105                 // Internal:
106         var $pageRow=array();                                   // Set to the page record (see writeTop())
107
108         var $csvLines=array();                                  // Used to accumulate CSV lines in for CSV export.
109         var $csvOutput=FALSE;                                   // If set, the listing is returned as CSV instead.
110
111         var $clipObj;                                                   // Clipboard object
112         var $CBnames=array();                                   // Tracking names of elements (for clipboard use)
113         var $duplicateStack=array();                    // Used to track which elements has duplicates and how many
114
115
116         /**
117          * Writes the top of the full listing
118          *
119          * @param       array           Current page record
120          * @return      void            (Adds content to internal variable, $this->HTMLcode)
121          */
122         function writeTop($row) {
123                 global $LANG;
124
125                         // Makes the code for the pageicon in the top
126                 $this->pageRow = $row;
127                 $this->counter++;
128                 $alttext = t3lib_BEfunc::getRecordIconAltText($row,'pages');
129                 $iconImg = t3lib_iconWorks::getIconImage('pages',$row,$this->backPath,'class="absmiddle" title="'.htmlspecialchars($alttext).'"');
130                 $titleCol = 'test';     // pseudo title column name
131                 $this->fieldArray = Array($titleCol,'up');              // Setting the fields to display in the list (this is of course "pseudo fields" since this is the top!)
132
133
134                         // Filling in the pseudo data array:
135                 $theData = Array();
136                 $theData[$titleCol] = $this->widthGif;
137
138                         // Get users permissions for this row:
139                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($row);
140
141                 $theData['up']=array();
142
143                         // Initialize control panel for currect page ($this->id):
144                         // Some of the controls are added only if $this->id is set - since they make sense only on a real page, not root level.
145                 $theCtrlPanel =array();
146
147                         // "View page" icon is added:
148                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,$this->backPath,t3lib_BEfunc::BEgetRootLine($this->id))).'">'.
149                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
150                                                 '</a>';
151
152                         // If edit permissions are set (see class.t3lib_userauthgroup.php)
153                 if ($localCalcPerms&2)  {
154
155                                 // Adding "Edit page" icon:
156                         if ($this->id)  {
157                                 $params='&edit[pages]['.$row['uid'].']=edit';
158                                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
159                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editPage',1).'" alt="" />'.
160                                                                 '</a>';
161                         }
162
163                                 // Adding "New record" icon:
164                         if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink'])        {
165                                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'' . htmlspecialchars($this->backPath . 'db_new.php?id='.$this->id).'\');').'">'.
166                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' title="'.$LANG->getLL('newRecordGeneral',1).'" alt="" />'.
167                                                                 '</a>';
168                         }
169
170                                 // Adding "Hide/Unhide" icon:
171                         if ($this->id)  {
172                                 if ($row['hidden'])     {
173                                         $params='&data[pages]['.$row['uid'].'][hidden]=0';
174                                         $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
175                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHidePage',1).'" alt="" />'.
176                                                                         '</a>';
177                                 } else {
178                                         $params='&data[pages]['.$row['uid'].'][hidden]=1';
179                                         $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
180                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hidePage',1).'" alt="" />'.
181                                                                         '</a>';
182                                 }
183                         }
184
185                                 // Adding "move page" button:
186                         if ($this->id)  {
187                                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table=pages&uid='.$row['uid'].'\');').'">'.
188                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($this->table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_page',1).'" alt="" />'.
189                                                                 '</a>';
190                         }
191                 }
192
193                         // "Paste into page" link:
194                 if (($localCalcPerms&8) || ($localCalcPerms&16))        {
195                         $elFromTable = $this->clipObj->elFromTable('');
196                         if (count($elFromTable))        {
197                                 $theCtrlPanel[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
198                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
199                                                                 '</a>';
200                         }
201                 }
202
203                         // Finally, compile all elements of the control panel into table cells:
204                 if (count($theCtrlPanel))       {
205                         $theData['up'][]='
206
207                                 <!--
208                                         Control panel for page
209                                 -->
210                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-ctrltop">
211                                         <tr>
212                                                 <td>'.implode('</td>
213                                                 <td>',$theCtrlPanel).'</td>
214                                         </tr>
215                                 </table>';
216                 }
217
218
219                         // Add "clear-cache" link:
220                 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&clear_cache=1').'">'.
221                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clear_cache.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache',1).'" alt="" />'.
222                                                 '</a>';
223
224                         // Add "CSV" link, if a specific table is shown:
225                 if ($this->table)       {
226                         $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&csv=1').'">'.
227                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/csv.gif','width="27" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv',1).'" alt="" />'.
228                                                         '</a>';
229                 }
230
231                         // Add "Export" link, if a specific table is shown:
232                 if ($this->table && t3lib_extMgm::isLoaded('impexp'))   {
233                         $theData['up'][]='<a href="'.htmlspecialchars($this->backPath.'mod.php?M=xMOD_tximpexp&tx_impexp[action]=export&tx_impexp[list][]='.rawurlencode($this->table.':'.$this->id)).'">'.
234                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,t3lib_extMgm::extRelPath('impexp').'export.gif',' width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export',1).'" alt="" />'.
235                                                         '</a>';
236                 }
237
238                         // Add "refresh" link:
239                 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL()).'">'.
240                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'.
241                                                 '</a>';
242
243
244                         // Add icon with clickmenu, etc:
245                 if ($this->id)  {       // If there IS a real page...:
246
247                                 // Setting title of page + the "Go up" link:
248                         $theData[$titleCol].='<br /><span title="'.htmlspecialchars($row['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['_thePath'],-$this->fixedL)).'</span>';
249                         $theData['up'][]='<a href="'.htmlspecialchars($this->listURL($row['pid'])).'" onclick="setHighlight('.$row['pid'].')">'.
250                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />'.
251                                                         '</a>';
252
253                                 // Make Icon:
254                         $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,'pages',$this->id) : $iconImg;
255                 } else {        // On root-level of page tree:
256
257                                 // Setting title of root (sitename):
258                         $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],-$this->fixedL));
259
260                                 // Make Icon:
261                         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />';
262                 }
263
264                         // If there is a returnUrl given, add a back-link:
265                 if ($this->returnUrl)   {
266                         $theData['up'][]='<a href="'.htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl,array('id'=>$this->id))).'" class="typo3-goBack">'.
267                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/goback.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack',1).'" alt="" />'.
268                                                         '</a>';
269                 }
270
271                         // Finally, the "up" pseudo field is compiled into a table - has been accumulated in an array:
272                 $theData['up']='
273                         <table border="0" cellpadding="0" cellspacing="0">
274                                 <tr>
275                                         <td>'.implode('</td>
276                                         <td>',$theData['up']).'</td>
277                                 </tr>
278                         </table>';
279
280                         // ... and the element row is created:
281                 $out.=$this->addelement(1,$theIcon,$theData,'',$this->leftMargin);
282
283                         // ... and wrapped into a table and added to the internal ->HTMLcode variable:
284                 $this->HTMLcode.='
285
286
287                 <!--
288                         Page header for db_list:
289                 -->
290                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-top">
291                                 '.$out.'
292                         </table>';
293         }
294
295         /**
296          * Creates the listing of records from a single table
297          *
298          * @param       string          Table name
299          * @param       integer         Page id
300          * @param       string          List of fields to show in the listing. Pseudo fields will be added including the record header.
301          * @return      string          HTML table with the listing for the record.
302          */
303         function getTable($table,$id,$rowlist)  {
304                 global $TCA;
305
306                         // Loading all TCA details for this table:
307                 t3lib_div::loadTCA($table);
308
309                         // Init
310                 $addWhere = '';
311                 $titleCol = $TCA[$table]['ctrl']['label'];
312                 $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
313                 $l10nEnabled = $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'];
314
315                         // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
316                 $this->fieldArray=array();
317                 $this->fieldArray[] = $titleCol;        // Add title column
318                 if ($this->localizationView && $l10nEnabled)    {
319                         $this->fieldArray[] = '_LOCALIZATION_';
320                         $this->fieldArray[] = '_LOCALIZATION_b';
321                         $addWhere.=' AND (
322                                 '.$TCA[$table]['ctrl']['languageField'].'<=0
323                                 OR
324                                 '.$TCA[$table]['ctrl']['transOrigPointerField'].' = 0
325                         )';
326                 }
327                 if (!t3lib_div::inList($rowlist,'_CONTROL_'))   {
328                         $this->fieldArray[] = '_CONTROL_';
329                 }
330                 if ($this->showClipboard)       {
331                         $this->fieldArray[] = '_CLIPBOARD_';
332                 }
333                 if (!$this->dontShowClipControlPanels)  {
334                         $this->fieldArray[]='_REF_';
335                 }
336                 if ($this->searchLevels)        {
337                         $this->fieldArray[]='_PATH_';
338                 }
339                         // Cleaning up:
340                 $this->fieldArray=array_unique(array_merge($this->fieldArray,t3lib_div::trimExplode(',',$rowlist,1)));
341                 if ($this->noControlPanels)     {
342                         $tempArray = array_flip($this->fieldArray);
343                         unset($tempArray['_CONTROL_']);
344                         unset($tempArray['_CLIPBOARD_']);
345                         $this->fieldArray = array_keys($tempArray);
346                 }
347
348                         // Creating the list of fields to include in the SQL query:
349                 $selectFields = $this->fieldArray;
350                 $selectFields[] = 'uid';
351                 $selectFields[] = 'pid';
352                 if ($thumbsCol) $selectFields[] = $thumbsCol;   // adding column for thumbnails
353                 if ($table=='pages')    {
354                         if (t3lib_extMgm::isLoaded('cms'))      {
355                                 $selectFields[] = 'module';
356                                 $selectFields[] = 'extendToSubpages';
357                         }
358                         $selectFields[] = 'doktype';
359                 }
360                 if (is_array($TCA[$table]['ctrl']['enablecolumns']))    {
361                         $selectFields = array_merge($selectFields,$TCA[$table]['ctrl']['enablecolumns']);
362                 }
363                 if ($TCA[$table]['ctrl']['type'])       {
364                         $selectFields[] = $TCA[$table]['ctrl']['type'];
365                 }
366                 if ($TCA[$table]['ctrl']['typeicon_column'])    {
367                         $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
368                 }
369                 if ($TCA[$table]['ctrl']['versioningWS'])       {
370                         $selectFields[] = 't3ver_id';
371                         $selectFields[] = 't3ver_state';
372                         $selectFields[] = 't3ver_wsid';
373                         $selectFields[] = 't3ver_swapmode';             // Filtered out when pages in makeFieldList()
374                 }
375                 if ($l10nEnabled)       {
376                         $selectFields[] = $TCA[$table]['ctrl']['languageField'];
377                         $selectFields[] = $TCA[$table]['ctrl']['transOrigPointerField'];
378                 }
379                 if ($TCA[$table]['ctrl']['label_alt'])  {
380                         $selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
381                 }
382                 $selectFields = array_unique($selectFields);            // Unique list!
383                 $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));          // Making sure that the fields in the field-list ARE in the field-list from TCA!
384                 $selFieldList = implode(',',$selectFields);             // implode it into a list of fields for the SQL-statement.
385
386                         // Create the SQL query for selecting the elements in the listing:
387                 $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
388                 $this->setTotalItems($queryParts);              // Finding the total amount of records on the page (API function from class.db_list.inc)
389
390                         // Init:
391                 $dbCount = 0;
392                 $out = '';
393
394                         // If the count query returned any number of records, we perform the real query, selecting records.
395                 if ($this->totalItems)  {
396                         $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
397                         $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
398                 }
399
400                 $LOISmode = $this->listOnlyInSingleTableMode && !$this->table;
401
402                         // If any records was selected, render the list:
403                 if ($dbCount)   {
404
405                                 // Half line is drawn between tables:
406                         if (!$LOISmode) {
407                                 $theData = Array();
408                                 if (!$this->table && !$rowlist) {
409                                         $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
410                                         if (in_array('_CONTROL_',$this->fieldArray))    $theData['_CONTROL_']='';
411                                         if (in_array('_CLIPBOARD_',$this->fieldArray))  $theData['_CLIPBOARD_']='';
412                                 }
413                                 $out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
414                         }
415
416                                 // Header line is drawn
417                         $theData = Array();
418                         if ($this->disableSingleTableView)      {
419                                 $theData[$titleCol] = '<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.')';
420                         } else {
421                                 $theData[$titleCol] = $this->linkWrapTable($table,'<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.') <img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/'.($this->table?'minus':'plus').'bullet_list.gif','width="18" height="12"').' hspace="10" class="absmiddle" title="'.$GLOBALS['LANG']->getLL(!$this->table?'expandView':'contractView',1).'" alt="" />');
422                         }
423
424                                 // CSH:
425                         $theData[$titleCol].= t3lib_BEfunc::cshItem($table,'',$this->backPath,'',FALSE,'margin-bottom:0px; white-space: normal;');
426
427                         if ($LOISmode)  {
428                                 $out.='
429                                         <tr>
430                                                 <td class="c-headLineTable" style="width:95%;">'.$theData[$titleCol].'</td>
431                                         </tr>';
432
433                                 if ($GLOBALS['BE_USER']->uc["edit_showFieldHelp"])      {
434                                         $GLOBALS['LANG']->loadSingleTableDescription($table);
435                                         if (isset($GLOBALS['TCA_DESCR'][$table]['columns']['']))        {
436                                                 $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$table.'.\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
437                                                 $out.='
438                                         <tr>
439                                                 <td class="c-tableDescription">'.t3lib_BEfunc::helpTextIcon($table,'',$this->backPath,TRUE).$GLOBALS['TCA_DESCR'][$table]['columns']['']['description'].'</td>
440                                         </tr>';
441                                         }
442                                 }
443                         } else {
444                                 $theUpIcon = ($table=='pages'&&$this->id&&isset($this->pageRow['pid'])) ? '<a href="'.htmlspecialchars($this->listURL($this->pageRow['pid'])).'" onclick="setHighlight('.$this->pageRow['pid'].')"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" /></a>':'';
445                                 $out.=$this->addelement(1,$theUpIcon,$theData,' class="c-headLineTable"','');
446                         }
447
448                         If (!$LOISmode) {
449                                         // Fixing a order table for sortby tables
450                                 $this->currentTable = array();
451                                 $currentIdList = array();
452                                 $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
453
454                                 $prevUid = 0;
455                                 $prevPrevUid = 0;
456                                 $accRows = array();     // Accumulate rows here
457                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
458                                         $accRows[] = $row;
459                                         $currentIdList[] = $row['uid'];
460                                         if ($doSort)    {
461                                                 if ($prevUid)   {
462                                                         $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
463                                                         $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
464                                                         $this->currentTable['prevUid'][$row['uid']] = $prevUid;
465                                                 }
466                                                 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
467                                                 $prevUid=$row['uid'];
468                                         }
469                                 }
470                                 $GLOBALS['TYPO3_DB']->sql_free_result($result);
471
472                                         // CSV initiated
473                                 if ($this->csvOutput) $this->initCSV();
474
475                                         // Render items:
476                                 $this->CBnames=array();
477                                 $this->duplicateStack=array();
478                                 $this->eCounter=$this->firstElementNumber;
479
480                                 $iOut = '';
481                                 $cc = 0;
482                                 foreach($accRows as $row)       {
483
484                                                 // Forward/Backwards navigation links:
485                                         list($flag,$code) = $this->fwd_rwd_nav($table);
486                                         $iOut.=$code;
487
488                                                 // If render item, increment counter and call function
489                                         if ($flag)      {
490                                                 $cc++;
491                                                 $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
492
493                                                         // 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:
494                                                 if ($this->localizationView && $l10nEnabled)    {
495
496                                                                 // Look for translations of this record:
497                                                         $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
498                                                                 $selFieldList,
499                                                                 $table,
500                                                                 'pid='.$row['pid'].
501                                                                         ' AND '.$TCA[$table]['ctrl']['languageField'].'>0'.
502                                                                         ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
503                                                                         t3lib_BEfunc::deleteClause($table).
504                                                                         t3lib_BEfunc::versioningPlaceholderClause($table)
505                                                         );
506
507                                                                 // For each available translation, render the record:
508                                                         if (is_array($translations)) {
509                                                                 foreach($translations as $lRow) {
510                                                                         if ($GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']]))     {
511                                                                                 $currentIdList[] = $lRow['uid'];
512                                                                                 $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
513                                                                         }
514                                                                 }
515                                                         }
516                                                 }
517                                         }
518
519                                                 // Counter of total rows incremented:
520                                         $this->eCounter++;
521                                 }
522
523                                         // The header row for the table is now created:
524                                 $out.=$this->renderListHeader($table,$currentIdList);
525                         }
526
527                                 // The list of records is added after the header:
528                         $out.=$iOut;
529
530                                 // ... and it is all wrapped in a table:
531                         $out='
532
533
534
535                         <!--
536                                 DB listing of elements: "'.htmlspecialchars($table).'"
537                         -->
538                                 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($LOISmode?' typo3-dblist-overview':'').'">
539                                         '.$out.'
540                                 </table>';
541
542                                 // Output csv if...
543                         if ($this->csvOutput)   $this->outputCSV($table);       // This ends the page with exit.
544                 }
545
546                         // Return content:
547                 return $out;
548         }
549
550         /**
551          * Rendering a single row for the list
552          *
553          * @param       string          Table name
554          * @param       array           Current record
555          * @param       integer         Counter, counting for each time an element is rendered (used for alternating colors)
556          * @param       string          Table field (column) where header value is found
557          * @param       string          Table field (column) where (possible) thumbnails can be found
558          * @param       integer         Indent from left.
559          * @return      string          Table row for the element
560          * @access private
561          * @see getTable()
562          */
563         function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0)  {
564                 $iOut = '';
565
566                 if (strlen($this->searchString))        {       // If in search mode, make sure the preview will show the correct page
567                         $id_orig = $this->id;
568                         $this->id = $row['pid'];
569                 }
570
571                         // In offline workspace, look for alternative record:
572                 t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace);
573
574                         // Background color, if any:
575                 $row_bgColor=
576                         $this->alternateBgColors ?
577                         (($cc%2)?'' :' class="db_list_alt"') :
578                         '';
579
580                         // Overriding with versions background color if any:
581                 $row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
582
583                         // Incr. counter.
584                 $this->counter++;
585
586                         // The icon with link
587                 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
588                 $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($alttext).'"'.($indent ? ' style="margin-left: '.$indent.'px;"' : ''));
589                 $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
590
591                         // Preparing and getting the data-array
592                 $theData = Array();
593                 foreach($this->fieldArray as $fCol)     {
594                         if ($fCol==$titleCol)   {
595                                 $recTitle = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
596                                 $theData[$fCol] = $this->linkWrapItems($table,$row['uid'],$recTitle,$row);
597                         } elseif ($fCol=='pid') {
598                                 $theData[$fCol]=$row[$fCol];
599                         } elseif ($fCol=='_PATH_') {
600                                 $theData[$fCol]=$this->recPath($row['pid']);
601                         } elseif ($fCol=='_REF_') {
602                                 $theData[$fCol]=$this->makeRef($table,$row['uid']);
603                         } elseif ($fCol=='_CONTROL_') {
604                                 $theData[$fCol]=$this->makeControl($table,$row);
605                         } elseif ($fCol=='_CLIPBOARD_') {
606                                 $theData[$fCol]=$this->makeClip($table,$row);
607 #                               $t3lib_transl8tools = new t3lib_transl8tools;
608 #                               $theData[$fCol].=t3lib_div::view_array($t3lib_transl8tools->translationInfo($table,$row['uid']));
609                         } elseif ($fCol=='_LOCALIZATION_') {
610                                 list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
611                                 $theData[$fCol] = $lC1;
612                                 $theData[$fCol.'b'] = $lC2;
613                         } elseif ($fCol=='_LOCALIZATION_b') {
614                                 // Do nothing, has been done above.
615                         } else {
616                                 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars(t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100,$row['uid'])),$row[$fCol]);
617                         }
618                 }
619
620                 if (strlen($this->searchString))        {       // Reset the ID if it was overwritten
621                         $this->id = $id_orig;
622                 }
623
624                         // Add row to CSV list:
625                 if ($this->csvOutput) $this->addToCSV($row,$table);
626
627                         // Create element in table cells:
628                 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
629
630                         // Render thumbsnails if a thumbnail column exists and there is content in it:
631                 if ($this->thumbs && trim($row[$thumbsCol]))    {
632                         $iOut.=$this->addelement(4,'', Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)),$row_bgColor);
633                 }
634
635                         // Finally, return table row element:
636                 return $iOut;
637         }
638
639         /**
640          * Rendering the header row for a table
641          *
642          * @param       string          Table name
643          * @param       array           Array of the currectly displayed uids of the table
644          * @return      string          Header table row
645          * @access private
646          * @see getTable()
647          */
648         function renderListHeader($table,$currentIdList)        {
649                 global $TCA, $LANG;
650
651                         // Init:
652                 $theData = Array();
653
654                         // Traverse the fields:
655                 foreach($this->fieldArray as $fCol)     {
656
657                                 // Calculate users permissions to edit records in the table:
658                         $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
659
660                         switch((string)$fCol)   {
661                                 case '_PATH_':                  // Path
662                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
663                                 break;
664                                 case '_REF_':                   // References
665                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_',1).']</i>';
666                                 break;
667                                 case '_LOCALIZATION_':                  // Path
668                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_',1).']</i>';
669                                 break;
670                                 case '_LOCALIZATION_b':                 // Path
671                                         $theData[$fCol] = $LANG->getLL('Localize',1);
672                                 break;
673                                 case '_CLIPBOARD_':             // Clipboard:
674                                         $cells=array();
675
676                                                 // If there are elements on the clipboard for this table, then display the "paste into" icon:
677                                         $elFromTable = $this->clipObj->elFromTable($table);
678                                         if (count($elFromTable))        {
679                                                 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
680                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
681                                                                 '</a>';
682                                         }
683
684                                                 // If the numeric clipboard pads are enabled, display the control icons for that:
685                                         if ($this->clipObj->current!='normal')  {
686
687                                                         // The "select" link:
688                                                 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_copy.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_selectMarked',1).'" alt="" />',$table,'setCB');
689
690                                                         // The "edit marked" link:
691                                                 $editIdList = implode(',',$currentIdList);
692                                                 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
693                                                 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
694                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
695                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_editMarked',1).'" alt="" />'.
696                                                                 '</a>';
697
698                                                         // The "Delete marked" link:
699                                                 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_deleteMarked',1).'" alt="" />',$table,'delete',sprintf($LANG->getLL('clip_deleteMarkedWarning'),$LANG->sL($TCA[$table]['ctrl']['title'])));
700
701                                                         // The "Select all" link:
702                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;').'">'.
703                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_select.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_markRecords',1).'" alt="" />'.
704                                                                 '</a>';
705                                         } else {
706                                                 $cells[]='';
707                                         }
708                                         $theData[$fCol]=implode('',$cells);
709                                 break;
710                                 case '_CONTROL_':               // Control panel:
711                                         if (!$TCA[$table]['ctrl']['readOnly'])  {
712
713                                                         // If new records can be created on this page, add links:
714                                                 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table))   {
715                                                         if ($table=="tt_content" && $this->newWizards)  {
716                                                                         //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
717                                                                 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
718                                                                 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
719                                                                 $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';
720
721                                                                 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'">'.
722                                                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
723                                                                                                 '</a>';
724                                                         } elseif ($table=='pages' && $this->newWizards) {
725                                                                 $theData[$fCol]='<a href="'.htmlspecialchars($this->backPath.'db_new.php?id='.$this->id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
726                                                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
727                                                                                                 '</a>';
728                                                         } else {
729                                                                 $params='&edit['.$table.']['.$this->id.']=new';
730                                                                 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
731                                                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
732                                                                                                 '</a>';
733                                                         }
734                                                 }
735
736                                                         // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
737                                                 if ($permsEdit && $this->table && is_array($currentIdList))     {
738                                                         $editIdList = implode(',',$currentIdList);
739                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
740                                                         $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
741                                                         $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
742                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editShownColumns',1).'" alt="" />'.
743                                                                                         '</a>';
744                                                 }
745                                         }
746                                 break;
747                                 default:                        // Regular fields header:
748                                         $theData[$fCol]='';
749                                         if ($this->table && is_array($currentIdList))   {
750
751                                                         // If the numeric clipboard pads are selected, show duplicate sorting link:
752                                                 if ($this->clipNumPane()) {
753                                                         $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'">'.
754                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/select_duplicates.gif','width="11" height="11"').' title="'.$LANG->getLL('clip_duplicates',1).'" alt="" />'.
755                                                                                         '</a>';
756                                                 }
757
758                                                         // If the table can be edited, add link for editing THIS field for all listed records:
759                                                 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol])  {
760                                                         $editIdList = implode(',',$currentIdList);
761                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
762                                                         $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
763                                                         $iTitle = sprintf($LANG->getLL('editThisColumn'),ereg_replace(':$','',trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol)))));
764                                                         $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
765                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
766                                                                                         '</a>';
767                                                 }
768                                         }
769                                         $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
770                                 break;
771                         }
772                 }
773
774                         // Create and return header table row:
775                 return $this->addelement(1,'',$theData,' class="c-headLine"','');
776         }
777
778
779
780
781
782
783         /*********************************
784          *
785          * Rendering of various elements
786          *
787          *********************************/
788
789         /**
790          * Creates the control panel for a single record in the listing.
791          *
792          * @param       string          The table
793          * @param       array           The record for which to make the control panel.
794          * @return      string          HTML table with the control panel (unless disabled)
795          */
796         function makeControl($table,$row)       {
797                 global $TCA, $LANG, $SOBE;
798                 if ($this->dontShowClipControlPanels)   return '';
799
800                         // Initialize:
801                 t3lib_div::loadTCA($table);
802                 $cells=array();
803
804                         // If the listed table is 'pages' we have to request the permission settings for each page:
805                 if ($table=='pages')    {
806                         $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
807                 }
808
809                         // This expresses the edit permissions for this particular element:
810                 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
811
812                         // "Show" link (only pages and tt_content elements)
813                 if ($table=='pages' || $table=='tt_content')    {
814                         $params='&edit['.$table.']['.$row['uid'].']=edit';
815                         $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'], $this->backPath)).'">'.
816                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
817                                         '</a>';
818                 }
819
820                         // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
821                 if ($permsEdit) {
822                         $params='&edit['.$table.']['.$row['uid'].']=edit';
823                         $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
824                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif','width="11" height="12"').' title="'.$LANG->getLL('edit',1).'" alt="" />'.
825                                         '</a>';
826                 }
827
828                         // "Move" wizard link for pages/tt_content elements:
829                 if (($table=="tt_content" && $permsEdit) || ($table=='pages'))  {
830                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'">'.
831                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_'.($table=='tt_content'?'record':'page'),1).'" alt="" />'.
832                                         '</a>';
833                 }
834
835                         // If the extended control panel is enabled OR if we are seeing a single table:
836                 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table)     {
837
838                                 // "Info": (All records)
839                         $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
840                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'.
841                                         '</a>';
842
843                                 // If the table is NOT a read-only table, then show these links:
844                         if (!$TCA[$table]['ctrl']['readOnly'])  {
845
846                                         // "Revert" link (history/undo)
847                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'">'.
848                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history2.gif','width="13" height="12"').' title="'.$LANG->getLL('history',1).'" alt="" />'.
849                                                 '</a>';
850
851                                         // Versioning:
852                                 if (t3lib_extMgm::isLoaded('version'))  {
853                                         $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace);
854                                         if (is_array($vers))    {       // If table can be versionized.
855                                                 if (count($vers)>1)     {
856                                                         $st = 'background-color: #FFFF00; font-weight: bold;';
857                                                         $lab = count($vers)-1;
858                                                 } else {
859                                                         $st = 'background-color: #9999cc; font-weight: bold;';
860                                                         $lab = 'V';
861                                                 }
862
863                                                 $cells[]='<a href="'.htmlspecialchars($this->backPath.t3lib_extMgm::extRelPath('version')).'cm1/index.php?table='.rawurlencode($table).'&uid='.rawurlencode($row['uid']).'" style="'.htmlspecialchars($st).'">'.
864                                                                 $lab.
865                                                                 '</a>';
866                                         }
867                                 }
868
869                                         // "Edit Perms" link:
870                                 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm'))        {
871                                         $cells[]='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'">'.
872                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'.
873                                                         '</a>';
874                                 }
875
876                                         // "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):
877                                 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
878                                         if (
879                                                 ($table!='pages' && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
880                                                 ($table=='pages' && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
881                                                 )       {
882                                                 if ($this->showNewRecLink($table))      {
883                                                         $params='&edit['.$table.']['.(-$row['uid']).']=new';
884                                                         $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
885                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'),1).'" alt="" />'.
886                                                                         '</a>';
887                                                 }
888                                         }
889                                 }
890
891                                         // "Up/Down" links
892                                 if ($permsEdit && $TCA[$table]['ctrl']['sortby']  && !$this->sortField && !$this->searchLevels) {
893                                         if (isset($this->currentTable['prev'][$row['uid']]))    {       // Up
894                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
895                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
896                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$LANG->getLL('moveUp',1).'" alt="" />'.
897                                                                 '</a>';
898                                         } else {
899                                                 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
900                                         }
901                                         if ($this->currentTable['next'][$row['uid']])   {       // Down
902                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
903                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
904                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$LANG->getLL('moveDown',1).'" alt="" />'.
905                                                                 '</a>';
906                                         } else {
907                                                 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
908                                         }
909                                 }
910
911                                         // "Hide/Unhide" links:
912                                 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
913                                 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
914                                         if ($row[$hiddenField]) {
915                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
916                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
917                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHide'.($table=='pages'?'Page':''),1).'" alt="" />'.
918                                                                 '</a>';
919                                         } else {
920                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
921                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
922                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hide'.($table=='pages'?'Page':''),1).'" alt="" />'.
923                                                                 '</a>';
924                                         }
925                                 }
926
927                                         // "Delete" link:
928                                 if (
929                                         ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))
930                                         )       {
931                                         $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
932                                         $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').t3lib_BEfunc::referenceCount($table,$row['uid'],' (There are %s reference(s) to this record!)')).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'">'.
933                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
934                                                         '</a>';
935                                 }
936
937                                         // "Levels" links: Moving pages into new levels...
938                                 if ($permsEdit && $table=='pages' && !$this->searchLevels)      {
939
940                                                 // Up (Paste as the page right after the current parent page)
941                                         if ($this->calcPerms&8) {
942                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
943                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
944                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_left.gif','width="11" height="10"').' title="'.$LANG->getLL('prevLevel',1).'" alt="" />'.
945                                                                 '</a>';
946                                         }
947                                                 // Down (Paste as subpage to the page right above)
948                                         if ($this->currentTable['prevUid'][$row['uid']])        {
949                                                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
950                                                 if ($localCalcPerms&8)  {
951                                                         $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
952                                                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
953                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"').' title="'.$LANG->getLL('nextLevel',1).'" alt="" />'.
954                                                                         '</a>';
955                                                 } else {
956                                                         $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
957                                                 }
958                                         } else {
959                                                 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
960                                         }
961                                 }
962                         }
963                 }
964
965                         // If the record is edit-locked by another user, we will show a little warning sign:
966                 if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
967                         $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
968                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
969                                         '</a>';
970                 }
971
972
973                         // Compile items into a DIV-element:
974                 return '
975                                                                                         <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
976                                                                                         <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
977         }
978
979         /**
980          * Creates the clipboard panel for a single record in the listing.
981          *
982          * @param       string          The table
983          * @param       array           The record for which to make the clipboard panel.
984          * @return      string          HTML table with the clipboard panel (unless disabled)
985          */
986         function makeClip($table,$row)  {
987                 global $TCA, $LANG;
988
989                         // Return blank, if disabled:
990                 if ($this->dontShowClipControlPanels)   return '';
991                 $cells=array();
992
993
994                         // Return blank, if disabled:
995                         // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
996                 if ($this->clipObj->current=='normal')  {       // For the "Normal" pad:
997
998                                 // Show copy/cut icons:
999                         $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1000                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'">'.
1001                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_copy'.($isSel=='copy'?'_h':'').'.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.copy',1).'" alt="" />'.
1002                                         '</a>';
1003                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'">'.
1004                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_cut'.($isSel=='cut'?'_h':'').'.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.cut',1).'" alt="" />'.
1005                                         '</a>';
1006
1007                 } else {        // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1008
1009                                 // Setting name of the element in ->CBnames array:
1010                         $n=$table.'|'.$row['uid'];
1011                         $this->CBnames[]=$n;
1012
1013                                 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1014                         $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1015
1016                                 // If the "duplicateField" value is set then select all elements which are duplicates...
1017                         if ($this->duplicateField && isset($row[$this->duplicateField]))        {
1018                                 $checked='';
1019                                 if (in_array($row[$this->duplicateField], $this->duplicateStack))       {
1020                                         $checked=' checked="checked"';
1021                                 }
1022                                 $this->duplicateStack[] = $row[$this->duplicateField];
1023                         }
1024
1025                                 // Adding the checkbox to the panel:
1026                         $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1027                 }
1028
1029                         // Now, looking for selected elements from the current table:
1030                 $elFromTable = $this->clipObj->elFromTable($table);
1031                 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby'])      {       // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1032                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'">'.
1033                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteAfter',1).'" alt="" />'.
1034                                         '</a>';
1035                 }
1036
1037                         // Now, looking for elements in general:
1038                 $elFromTable = $this->clipObj->elFromTable('');
1039                 if ($table=='pages' && count($elFromTable))     {
1040                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'">'.
1041                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteInto',1).'" alt="" />'.
1042                                         '</a>';
1043                 }
1044
1045                         // Compile items into a DIV-element:
1046                 return '                                                        <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1047                                                                                         <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1048         }
1049
1050         /**
1051          * Make reference count
1052          *
1053          * @param       string          Table name
1054          * @param       integer         UID of record
1055          * @return      string          HTML-table
1056          */
1057         function makeRef($table,$uid)   {
1058
1059                         // Look up the path:
1060                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1061                         '*',
1062                         'sys_refindex',
1063                         'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
1064                                 ' AND ref_uid='.intval($uid).
1065                                 ' AND deleted=0'
1066                 );
1067
1068                         // Compile information for title tag:
1069                 $infoData=array();
1070                 if (is_array($rows)) {
1071                         foreach($rows as $row)  {
1072                                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1073                         }
1074                 }
1075
1076                 return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$uid.'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
1077         }
1078
1079         /**
1080          * Creates the localization panel
1081          *
1082          * @param       string          The table
1083          * @param       array           The record for which to make the localization panel.
1084          * @return      array           Array with key 0/1 with content for column 1 and 2
1085          */
1086         function makeLocalizationPanel($table,$row)     {
1087                 global $TCA,$LANG;
1088
1089                 $out = array(
1090                         0 => '',
1091                         1 => '',
1092                 );
1093
1094                 $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
1095                 $translations = $t8Tools->translationInfo($table,$row['uid']);
1096
1097                         // Language title and icon:
1098                 $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
1099
1100                 if (is_array($translations))    {
1101
1102                                 // Traverse page translations and add icon for each language that does NOT yet exist:
1103                         $lNew = '';
1104                         foreach($this->pageOverlays as $lUid_OnPage => $lsysRec)        {
1105                                 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage))      {
1106                                         $href = $GLOBALS['TBE_TEMPLATE']->issueCommand(
1107                                                 '&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage,
1108                                                 $this->listURL().'&justLocalized='.rawurlencode($table.':'.$row['uid'].':'.$lUid_OnPage)
1109                                         );
1110
1111                                         $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$lUid_OnPage]['flagIcon'].'" class="absmiddle" alt="" />' : $this->languageIconTitles[$lUid_OnPage]['title']);
1112                                         $lC = '<a href="'.htmlspecialchars($href).'">'.$lC.'</a> ';
1113
1114                                         $lNew.=$lC;
1115                                 }
1116                         }
1117
1118                         if ($lNew)      $out[1].= $lNew;
1119                 } else {
1120                         $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
1121                 }
1122
1123
1124                 return $out;
1125         }
1126
1127         /**
1128          * Create the selector box for selecting fields to display from a table:
1129          *
1130          * @param       string          Table name
1131          * @param       boolean         If true, form-fields will be wrapped around the table.
1132          * @return      string          HTML table with the selector box (name: displayFields['.$table.'][])
1133          */
1134         function fieldSelectBox($table,$formFields=1)   {
1135                 global $TCA, $LANG;
1136
1137                         // Init:
1138                 t3lib_div::loadTCA($table);
1139                 $formElements=array('','');
1140                 if ($formFields)        {
1141                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1142                 }
1143
1144                         // Load already selected fields, if any:
1145                 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1146
1147                         // Request fields from table:
1148                 $fields = $this->makeFieldList($table);
1149
1150                         // Add pseudo "control" fields
1151                 $fields[]='tstamp';
1152                 $fields[]='crdate';
1153                 $fields[]='_PATH_';
1154                 $fields[]='_REF_';
1155                 $fields[]='_LOCALIZATION_';
1156                 $fields[]='_CONTROL_';
1157                 $fields[]='_CLIPBOARD_';
1158
1159                         // Create an option for each field:
1160                 $opt=array();
1161                 $opt[] = '<option value=""></option>';
1162                 foreach($fields as $fN) {
1163                         $fL = is_array($TCA[$table]['columns'][$fN]) ? ereg_replace(':$','',$LANG->sL($TCA[$table]['columns'][$fN]['label'])) : '['.$fN.']';    // Field label
1164                         $opt[] = '
1165                                                                                         <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1166                 }
1167
1168                         // Compile the options into a multiple selector box:
1169                 $lMenu = '
1170                                                                                 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1171                                                                                 </select>
1172                                 ';
1173
1174                         // Table with the field selector::
1175                 $content.= '
1176                         '.$formElements[0].'
1177
1178                                 <!--
1179                                         Field selector for extended table view:
1180                                 -->
1181                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
1182                                         <tr>
1183                                                 <td>'.$lMenu.'</td>
1184                                                 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
1185                                         </tr>
1186                                 </table>
1187                         '.$formElements[1];
1188                 return $content;
1189         }
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201         /*********************************
1202          *
1203          * Helper functions
1204          *
1205          *********************************/
1206
1207         /**
1208          * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1209          * Currently, this is used for setting elements / delete elements.
1210          *
1211          * @param       string          The HTML content to link (image/text)
1212          * @param       string          Table name
1213          * @param       string          Clipboard command (eg. "setCB" or "delete")
1214          * @param       string          Warning text, if any ("delete" uses this for confirmation)
1215          * @return      string          <a> tag wrapped link.
1216          */
1217         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
1218                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1219                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1220                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1221         }
1222
1223         /**
1224          * Returns true if a numeric clipboard pad is selected/active
1225          *
1226          * @return      boolean
1227          */
1228         function clipNumPane()  {
1229                 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1230         }
1231
1232         /**
1233          * Creates a sort-by link on the input string ($code).
1234          * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1235          * Also some fields will not be possible to sort (including if single-table-view is disabled).
1236          *
1237          * @param       string          The string to link (text)
1238          * @param       string          The fieldname represented by the title ($code)
1239          * @param       string          Table name
1240          * @return      string          Linked $code variable
1241          */
1242         function addSortLink($code,$field,$table)       {
1243
1244                         // Certain circumstances just return string right away (no links):
1245                 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView)       return $code;
1246
1247                         // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1248                 if ($field=='_PATH_')   $field=pid;
1249
1250                         //       Create the sort link:
1251                 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1252                 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1253
1254                         // Return linked field:
1255                 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1256                                 $sortArrow.
1257                                 '</a>';
1258         }
1259
1260         /**
1261          * Returns the path for a certain pid
1262          * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1263          *
1264          * @param       integer         The page id for which to get the path
1265          * @return      string          The path.
1266          */
1267         function recPath($pid)  {
1268                 if (!isset($this->recPath_cache[$pid])) {
1269                         $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1270                 }
1271                 return $this->recPath_cache[$pid];
1272         }
1273
1274         /**
1275          * Returns true if a link for creating new records should be displayed for $table
1276          *
1277          * @param       string          Table name
1278          * @return      boolean
1279          */
1280         function showNewRecLink($table) {
1281                 return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
1282         }
1283
1284         /**
1285          * 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.
1286          * Uses REQUEST_URI as value.
1287          *
1288          * @return      string
1289          */
1290         function makeReturnUrl()        {
1291                 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1292         }
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304         /************************************
1305          *
1306          * CSV related functions
1307          *
1308          ************************************/
1309
1310         /**
1311          * Initializes internal csvLines array with the header of field names
1312          *
1313          * @return      void
1314          */
1315         function initCSV()      {
1316
1317                         // Reset:
1318                 $this->csvLines=array();
1319
1320                         // Getting header line with field names:
1321                 $csvRow=array();
1322                 foreach($this->fieldArray as $fN)       {
1323                         $csvRow[]=$fN;
1324                 }
1325
1326                         // Set the header + an empty row:
1327                 $this->setCsvRow($csvRow);
1328                 $this->csvLines[]='';
1329         }
1330
1331         /**
1332          * Adds the content of input array $row to the CSV list:
1333          *
1334          * @param       array           Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1335          * @param       string          Table name
1336          * @return      void
1337          */
1338         function addToCSV($row,$table)  {
1339
1340                         // Traversing fields, adding values from $row:
1341                 $csvRow=array();
1342                 foreach($this->fieldArray as $fN)       {
1343                         if ($fN=='_PATH_')      {
1344                                 $csvRow[]=$this->recPath($row['pid']);
1345                         } elseif ($fN=='_REF_') {
1346                                 $csvRow[]=$this->makeRef($table, $row['uid']);
1347                         } else {
1348                                 $csvRow[]=$row[$fN];
1349                         }
1350                 }
1351
1352                         // Set the values in the CSV list
1353                 $this->setCsvRow($csvRow);
1354         }
1355
1356         /**
1357          * Adds input row of values to the internal csvLines array as a CSV formatted line
1358          *
1359          * @param       array           Array with values to be listed.
1360          * @return      void
1361          */
1362         function setCsvRow($csvRow)     {
1363                 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1364         }
1365
1366         /**
1367          * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1368          * This function exits!
1369          *
1370          * @param       string          Filename prefix:
1371          * @return      void            EXITS php execusion!
1372          */
1373         function outputCSV($prefix)     {
1374
1375                         // Setting filename:
1376                 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1377
1378                         // Creating output header:
1379                 $mimeType = 'application/octet-stream';
1380                 Header('Content-Type: '.$mimeType);
1381                 Header('Content-Disposition: attachment; filename='.$filename);
1382
1383                         // Printing the content of the CSV lines:
1384                 echo implode(chr(13).chr(10),$this->csvLines);
1385
1386                         // Exits:
1387                 exit;
1388         }
1389 }
1390
1391
1392
1393 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])   {
1394         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1395 }
1396 ?>