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