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