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