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