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