Added feature #4911: Add an option to add alternative external URL or shortcut for...
[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                                                                 if ($table == 'pages_language_overlay') {
796                                                                         $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
797                                                                 }
798                                                                 $icon   = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
799                                                                                                 '<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="" />'.
800                                                                                                 '</a>';
801                                                         }
802                                                 }
803
804                                                         // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
805                                                 if ($permsEdit && $this->table && is_array($currentIdList))     {
806                                                         $editIdList = implode(',',$currentIdList);
807                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
808                                                         $params = '&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
809                                                         $icon  .= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
810                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editShownColumns',1).'" alt="" />'.
811                                                                                         '</a>';
812                                                 }
813                                                         // add an empty entry, so column count fits again after moving this into $icon
814                                                 $theData[$fCol] = '&nbsp;';
815                                         }
816                                 break;
817                                 case '_AFTERCONTROL_':  // space column
818                                 case '_AFTERREF_':      // space column
819                                         $theData[$fCol] = '&nbsp;';
820                                 break;
821                                 default:                        // Regular fields header:
822                                         $theData[$fCol]='';
823                                         if ($this->table && is_array($currentIdList))   {
824
825                                                         // If the numeric clipboard pads are selected, show duplicate sorting link:
826                                                 if ($this->clipNumPane()) {
827                                                         $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'">'.
828                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/select_duplicates.gif','width="11" height="11"').' title="'.$LANG->getLL('clip_duplicates',1).'" alt="" />'.
829                                                                                         '</a>';
830                                                 }
831
832                                                         // If the table can be edited, add link for editing THIS field for all listed records:
833                                                 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol])  {
834                                                         $editIdList = implode(',',$currentIdList);
835                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
836                                                         $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
837                                                         $iTitle = sprintf($LANG->getLL('editThisColumn'),ereg_replace(':$','',trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol)))));
838                                                         $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
839                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
840                                                                                         '</a>';
841                                                 }
842                                         }
843                                         $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
844                                 break;
845                         }
846
847                 }
848
849                 /**
850                  * @hook                        renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
851                  * @date                        2007-11-20
852                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
853                  * @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.
854                  */
855                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions']))        {
856                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData)       {
857                                 $hookObject = &t3lib_div::getUserObj($classData);
858                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
859                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567855);
860                                 }
861                                 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
862                         }
863                 }
864
865                         // Create and return header table row:
866                 return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
867         }
868
869
870
871
872
873
874         /*********************************
875          *
876          * Rendering of various elements
877          *
878          *********************************/
879
880         /**
881          * Creates the control panel for a single record in the listing.
882          *
883          * @param       string          The table
884          * @param       array           The record for which to make the control panel.
885          * @return      string          HTML table with the control panel (unless disabled)
886          */
887         function makeControl($table,$row)       {
888                 global $TCA, $LANG, $SOBE, $TYPO3_CONF_VARS;
889
890                 if ($this->dontShowClipControlPanels)   return '';
891
892                         // Initialize:
893                 t3lib_div::loadTCA($table);
894                 $cells=array();
895
896                         // If the listed table is 'pages' we have to request the permission settings for each page:
897                 if ($table=='pages')    {
898                         $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
899                 }
900
901                         // This expresses the edit permissions for this particular element:
902                 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
903
904                         // "Show" link (only pages and tt_content elements)
905                 if ($table=='pages' || $table=='tt_content')    {
906                         $params='&edit['.$table.']['.$row['uid'].']=edit';
907                         $cells['view']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'], $this->backPath)).'">'.
908                                         '<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="" />'.
909                                         '</a>';
910                 } elseif(!$this->table) {
911                         $cells['view'] = $this->spaceIcon;
912                 }
913
914                         // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
915                 if ($permsEdit) {
916                         $params='&edit['.$table.']['.$row['uid'].']=edit';
917                         $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
918                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif','width="11" height="12"').' title="'.$LANG->getLL('edit',1).'" alt="" />'.
919                                         '</a>';
920                 } elseif(!$this->table) {
921                         $cells['edit'] = $this->spaceIcon;
922                 }
923
924                         // "Move" wizard link for pages/tt_content elements:
925                 if (($table=="tt_content" && $permsEdit) || ($table=='pages'))  {
926                         $cells['move']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'">'.
927                                         '<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="" />'.
928                                         '</a>';
929                 } elseif(!$this->table) {
930                         $cells['move'] = $this->spaceIcon;
931                 }
932
933                         // If the extended control panel is enabled OR if we are seeing a single table:
934                 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table)     {
935
936                                 // "Info": (All records)
937                         $cells['viewBig']='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
938                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'.
939                                         '</a>';
940
941                                 // If the table is NOT a read-only table, then show these links:
942                         if (!$TCA[$table]['ctrl']['readOnly'])  {
943
944                                         // "Revert" link (history/undo)
945                                 $cells['history']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'">'.
946                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history2.gif','width="13" height="12"').' title="'.$LANG->getLL('history',1).'" alt="" />'.
947                                                 '</a>';
948
949                                         // Versioning:
950                                 if (t3lib_extMgm::isLoaded('version'))  {
951                                         $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace);
952                                         if (is_array($vers))    {       // If table can be versionized.
953                                                 if (count($vers)>1)     {
954                                                         $st = 'background-color: #FFFF00; font-weight: bold;';
955                                                         $lab = count($vers)-1;
956                                                 } else {
957                                                         $st = 'background-color: #9999cc; font-weight: bold;';
958                                                         $lab = 'V';
959                                                 }
960
961                                                 $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).'">'.
962                                                                 $lab.
963                                                                 '</a>';
964                                         } elseif(!$this->table) {
965                                                 $cells['version'] = '<span class="typo3-ctrl-versioning" style="font-weight: bold; visibility: hidden;">V</span>';
966                                         }
967                                 }
968
969                                         // "Edit Perms" link:
970                                 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm'))        {
971                                         $cells['perms']='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'">'.
972                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'.
973                                                         '</a>';
974                                 } elseif(!$this->table && $GLOBALS['BE_USER']->check('modules','web_perm')) {
975                                         $cells['perms'] = $this->spaceIcon;
976                                 }
977
978                                         // "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):
979                                 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
980                                         if (
981                                                 ($table!='pages' && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
982                                                 ($table=='pages' && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
983                                                 )       {
984                                                 if ($this->showNewRecLink($table))      {
985                                                         $params='&edit['.$table.']['.(-($row['_MOVE_PLH']?$row['_MOVE_PLH_uid']:$row['uid'])).']=new';
986                                                         $cells['new']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
987                                                                         '<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="" />'.
988                                                                         '</a>';
989                                                 }
990                                         }
991                                 } elseif(!$this->table) {
992                                         $cells['new'] = $this->spaceIcon;
993                                 }
994
995                                         // "Up/Down" links
996                                 if ($permsEdit && $TCA[$table]['ctrl']['sortby']  && !$this->sortField && !$this->searchLevels) {
997                                         if (isset($this->currentTable['prev'][$row['uid']]))    {       // Up
998                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
999                                                 $cells['moveUp']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
1000                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$LANG->getLL('moveUp',1).'" alt="" />'.
1001                                                                 '</a>';
1002                                         } else {
1003                                                 $cells['moveUp'] = $this->spaceIcon;
1004                                         }
1005                                         if ($this->currentTable['next'][$row['uid']])   {       // Down
1006                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
1007                                                 $cells['moveDown']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
1008                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$LANG->getLL('moveDown',1).'" alt="" />'.
1009                                                                 '</a>';
1010                                         } else {
1011                                                 $cells['moveDown'] = $this->spaceIcon;
1012                                         }
1013                                 } elseif(!$this->table) {
1014                                         $cells['moveUp']  = $this->spaceIcon;
1015                                         $cells['moveDown'] = $this->spaceIcon;
1016                                 }
1017
1018                                         // "Hide/Unhide" links:
1019                                 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1020                                 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
1021                                         if ($row[$hiddenField]) {
1022                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1023                                                 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
1024                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHide'.($table=='pages'?'Page':''),1).'" alt="" />'.
1025                                                                 '</a>';
1026                                         } else {
1027                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1028                                                 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
1029                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hide'.($table=='pages'?'Page':''),1).'" alt="" />'.
1030                                                                 '</a>';
1031                                         }
1032                                 } elseif(!$this->table) {
1033                                         $cells['hide'] = $this->spaceIcon;
1034                                 }
1035
1036                                         // "Delete" link:
1037                                 if (
1038                                         ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))
1039                                         )       {
1040                                         $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
1041                                         $titleLength = $GLOBALS['BE_USER']->uc['titleLen'];
1042                                         if (!$titleLength || !t3lib_div::testInt($titleLength) || $titleLength < 0) {
1043                                                 $titleLength = 30;
1044                                         }
1045                                         $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $titleLength),1);
1046                                         $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
1047                                         $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;').'">'.
1048                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
1049                                                         '</a>';
1050                                 } elseif(!$this->table) {
1051                                         $cells['delete'] = $this->spaceIcon;
1052                                 }
1053
1054                                         // "Levels" links: Moving pages into new levels...
1055                                 if ($permsEdit && $table=='pages' && !$this->searchLevels)      {
1056
1057                                                 // Up (Paste as the page right after the current parent page)
1058                                         if ($this->calcPerms&8) {
1059                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
1060                                                 $cells['moveLeft']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
1061                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_left.gif','width="11" height="10"').' title="'.$LANG->getLL('prevLevel',1).'" alt="" />'.
1062                                                                 '</a>';
1063                                         }
1064                                                 // Down (Paste as subpage to the page right above)
1065                                         if ($this->currentTable['prevUid'][$row['uid']])        {
1066                                                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
1067                                                 if ($localCalcPerms&8)  {
1068                                                         $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
1069                                                         $cells['moveRight']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
1070                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"').' title="'.$LANG->getLL('nextLevel',1).'" alt="" />'.
1071                                                                         '</a>';
1072                                                 } else {
1073                                                         $cells['moveRight'] = $this->spaceIcon;
1074                                                 }
1075                                         } else {
1076                                                 $cells['moveRight'] = $this->spaceIcon;
1077                                         }
1078                                 } elseif(!$this->table) {
1079                                         $cells['moveLeft'] = $this->spaceIcon;
1080                                         $cells['moveRight'] = $this->spaceIcon;
1081                                 }
1082                         }
1083                 }
1084
1085
1086                 /**
1087                  * @hook                        recStatInfoHooks: Allows to insert HTML before record icons on various places
1088                  * @date                        2007-09-22
1089                  * @request             Kasper Skaarhoj  <kasper2007@typo3.com>
1090                  */
1091                 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))     {
1092                         $stat='';
1093                         $_params = array($table,$row['uid']);
1094                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)     {
1095                                 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1096                         }
1097                         $cells['stat'] = $stat;
1098                 }
1099                 /**
1100                  * @hook                        makeControl: Allows to change control icons of records in list-module
1101                  * @date                        2007-11-20
1102                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
1103                  * @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.
1104                  */
1105                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1106                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1107                                 $hookObject = &t3lib_div::getUserObj($classData);
1108                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
1109                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567840);
1110                                 }
1111                                 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1112                         }
1113                 }
1114
1115                         // Compile items into a DIV-element:
1116                 return '
1117                                                                                         <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
1118                                                                                         <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
1119         }
1120
1121         /**
1122          * Creates the clipboard panel for a single record in the listing.
1123          *
1124          * @param       string          The table
1125          * @param       array           The record for which to make the clipboard panel.
1126          * @return      string          HTML table with the clipboard panel (unless disabled)
1127          */
1128         function makeClip($table,$row)  {
1129                 global $TCA, $LANG, $TYPO3_CONF_VARS;
1130
1131                         // Return blank, if disabled:
1132                 if ($this->dontShowClipControlPanels)   return '';
1133                 $cells=array();
1134
1135                 $cells['pasteAfter'] = $cells['pasteInto'] = $this->spaceIcon;
1136
1137                         // Return blank, if disabled:
1138                         // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1139                 if ($this->clipObj->current=='normal')  {       // For the "Normal" pad:
1140
1141                                 // Show copy/cut icons:
1142                         $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1143                         $cells['copy']='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'">'.
1144                                         '<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="" />'.
1145                                         '</a>';
1146                         $cells['cut']='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'">'.
1147                                         '<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="" />'.
1148                                         '</a>';
1149
1150                 } else {        // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1151
1152                                 // Setting name of the element in ->CBnames array:
1153                         $n=$table.'|'.$row['uid'];
1154                         $this->CBnames[]=$n;
1155
1156                                 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1157                         $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1158
1159                                 // If the "duplicateField" value is set then select all elements which are duplicates...
1160                         if ($this->duplicateField && isset($row[$this->duplicateField]))        {
1161                                 $checked='';
1162                                 if (in_array($row[$this->duplicateField], $this->duplicateStack))       {
1163                                         $checked=' checked="checked"';
1164                                 }
1165                                 $this->duplicateStack[] = $row[$this->duplicateField];
1166                         }
1167
1168                                 // Adding the checkbox to the panel:
1169                         $cells['select']='<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1170                 }
1171
1172                         // Now, looking for selected elements from the current table:
1173                 $elFromTable = $this->clipObj->elFromTable($table);
1174                 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby'])      {       // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1175                         $cells['pasteAfter']='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'">'.
1176                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteAfter',1).'" alt="" />'.
1177                                         '</a>';
1178                 }
1179
1180                         // Now, looking for elements in general:
1181                 $elFromTable = $this->clipObj->elFromTable('');
1182                 if ($table=='pages' && count($elFromTable))     {
1183                         $cells['pasteInto']='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'">'.
1184                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteInto',1).'" alt="" />'.
1185                                         '</a>';
1186                 }
1187
1188                 /*
1189                  * @hook                        makeClip: Allows to change clip-icons of records in list-module
1190                  * @date                        2007-11-20
1191                  * @request             Bernhard Kraft  <krafbt@kraftb.at>
1192                  * @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.
1193                  */
1194                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1195                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1196                                 $hookObject = &t3lib_div::getUserObj($classData);
1197                                 if(!($hookObject instanceof localRecordList_actionsHook))       {
1198                                         throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567845);
1199                                 }
1200                                 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1201                         }
1202                 }
1203
1204                         // Compile items into a DIV-element:
1205                 return '                                                        <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1206                                                                                         <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1207         }
1208
1209         /**
1210          * Make reference count
1211          *
1212          * @param       string          Table name
1213          * @param       integer         UID of record
1214          * @return      string          HTML-table
1215          */
1216         function makeRef($table,$uid)   {
1217
1218                         // Look up the path:
1219                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1220                         '*',
1221                         'sys_refindex',
1222                         'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
1223                                 ' AND ref_uid='.intval($uid).
1224                                 ' AND deleted=0'
1225                 );
1226
1227                         // Compile information for title tag:
1228                 $infoData=array();
1229                 if (is_array($rows)) {
1230                         foreach($rows as $row)  {
1231                                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1232                         }
1233                 }
1234
1235                 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>' : '';
1236         }
1237
1238         /**
1239          * Creates the localization panel
1240          *
1241          * @param       string          The table
1242          * @param       array           The record for which to make the localization panel.
1243          * @return      array           Array with key 0/1 with content for column 1 and 2
1244          */
1245         function makeLocalizationPanel($table,$row)     {
1246                 global $TCA,$LANG;
1247
1248                 $out = array(
1249                         0 => '',
1250                         1 => '',
1251                 );
1252
1253                 $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools');
1254                 $translations = $t8Tools->translationInfo($table,$row['uid']);
1255
1256                         // Language title and icon:
1257                 $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
1258
1259                 if (is_array($translations))    {
1260
1261                                 // Traverse page translations and add icon for each language that does NOT yet exist:
1262                         $lNew = '';
1263                         foreach($this->pageOverlays as $lUid_OnPage => $lsysRec)        {
1264                                 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage))      {
1265                                         $href = $GLOBALS['TBE_TEMPLATE']->issueCommand(
1266                                                 '&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage,
1267                                                 $this->listURL().'&justLocalized='.rawurlencode($table.':'.$row['uid'].':'.$lUid_OnPage)
1268                                         );
1269
1270                                         $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$lUid_OnPage]['flagIcon'].'" class="absmiddle" alt="" />' : $this->languageIconTitles[$lUid_OnPage]['title']);
1271                                         $lC = '<a href="'.htmlspecialchars($href).'">'.$lC.'</a> ';
1272
1273                                         $lNew.=$lC;
1274                                 }
1275                         }
1276
1277                         if ($lNew)      $out[1].= $lNew;
1278                 } else {
1279                         $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
1280                 }
1281
1282
1283                 return $out;
1284         }
1285
1286         /**
1287          * Create the selector box for selecting fields to display from a table:
1288          *
1289          * @param       string          Table name
1290          * @param       boolean         If true, form-fields will be wrapped around the table.
1291          * @return      string          HTML table with the selector box (name: displayFields['.$table.'][])
1292          */
1293         function fieldSelectBox($table,$formFields=1)   {
1294                 global $TCA, $LANG;
1295
1296                         // Init:
1297                 t3lib_div::loadTCA($table);
1298                 $formElements=array('','');
1299                 if ($formFields)        {
1300                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1301                 }
1302
1303                         // Load already selected fields, if any:
1304                 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1305
1306                         // Request fields from table:
1307                 $fields = $this->makeFieldList($table, false, true);
1308
1309                         // Add pseudo "control" fields
1310                 $fields[]='_PATH_';
1311                 $fields[]='_REF_';
1312                 $fields[]='_LOCALIZATION_';
1313                 $fields[]='_CONTROL_';
1314                 $fields[]='_CLIPBOARD_';
1315
1316                         // Create an option for each field:
1317                 $opt=array();
1318                 $opt[] = '<option value=""></option>';
1319                 foreach($fields as $fN) {
1320                         $fL = is_array($TCA[$table]['columns'][$fN]) ? ereg_replace(':$','',$LANG->sL($TCA[$table]['columns'][$fN]['label'])) : '['.$fN.']';    // Field label
1321                         $opt[] = '
1322                                                                                         <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1323                 }
1324
1325                         // Compile the options into a multiple selector box:
1326                 $lMenu = '
1327                                                                                 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1328                                                                                 </select>
1329                                 ';
1330
1331                         // Table with the field selector::
1332                 $content.= '
1333                         '.$formElements[0].'
1334
1335                                 <!--
1336                                         Field selector for extended table view:
1337                                 -->
1338                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
1339                                         <tr>
1340                                                 <td>'.$lMenu.'</td>
1341                                                 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
1342                                         </tr>
1343                                 </table>
1344                         '.$formElements[1];
1345                 return $content;
1346         }
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358         /*********************************
1359          *
1360          * Helper functions
1361          *
1362          *********************************/
1363
1364         /**
1365          * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1366          * Currently, this is used for setting elements / delete elements.
1367          *
1368          * @param       string          The HTML content to link (image/text)
1369          * @param       string          Table name
1370          * @param       string          Clipboard command (eg. "setCB" or "delete")
1371          * @param       string          Warning text, if any ("delete" uses this for confirmation)
1372          * @return      string          <a> tag wrapped link.
1373          */
1374         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
1375                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1376                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1377                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1378         }
1379
1380         /**
1381          * Returns true if a numeric clipboard pad is selected/active
1382          *
1383          * @return      boolean
1384          */
1385         function clipNumPane()  {
1386                 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1387         }
1388
1389         /**
1390          * Creates a sort-by link on the input string ($code).
1391          * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1392          * Also some fields will not be possible to sort (including if single-table-view is disabled).
1393          *
1394          * @param       string          The string to link (text)
1395          * @param       string          The fieldname represented by the title ($code)
1396          * @param       string          Table name
1397          * @return      string          Linked $code variable
1398          */
1399         function addSortLink($code,$field,$table)       {
1400
1401                         // Certain circumstances just return string right away (no links):
1402                 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView)       return $code;
1403
1404                         // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1405                 if ($field=='_PATH_')   $field=pid;
1406
1407                         //       Create the sort link:
1408                 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1409                 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1410
1411                         // Return linked field:
1412                 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1413                                 $sortArrow.
1414                                 '</a>';
1415         }
1416
1417         /**
1418          * Returns the path for a certain pid
1419          * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1420          *
1421          * @param       integer         The page id for which to get the path
1422          * @return      string          The path.
1423          */
1424         function recPath($pid)  {
1425                 if (!isset($this->recPath_cache[$pid])) {
1426                         $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1427                 }
1428                 return $this->recPath_cache[$pid];
1429         }
1430
1431         /**
1432          * Returns true if a link for creating new records should be displayed for $table
1433          *
1434          * @param       string          Table name
1435          * @return      boolean         Returns true if a link for creating new records should be displayed for $table
1436          * @see         SC_db_new::showNewRecLink
1437          */
1438         function showNewRecLink($table) {
1439                         // No deny/allow tables are set:
1440                 if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
1441                         return true;
1442                         // If table is not denied (which takes precedence over allowed tables):
1443                 } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
1444                         return true;
1445                         // If table is denied or allowed tables are set, but table is not part of:
1446                 } else {
1447                         return false;
1448                 }
1449         }
1450
1451         /**
1452          * 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.
1453          * Uses REQUEST_URI as value.
1454          *
1455          * @return      string
1456          */
1457         function makeReturnUrl()        {
1458                 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1459         }
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471         /************************************
1472          *
1473          * CSV related functions
1474          *
1475          ************************************/
1476
1477         /**
1478          * Initializes internal csvLines array with the header of field names
1479          *
1480          * @return      void
1481          */
1482         function initCSV()      {
1483
1484                         // Reset:
1485                 $this->csvLines=array();
1486
1487                         // Getting header line with field names:
1488                 $csvRow = array();
1489                 foreach ($this->fieldArray as $fN) {
1490                         if ($fN == '_CONTROL_' || $fN == '_CLIPBOARD_') {
1491                                         continue;
1492                         }
1493                         $csvRow[] = $fN;
1494                 }
1495
1496                         // Set the header + an empty row:
1497                 $this->setCsvRow($csvRow);
1498                 $this->csvLines[] = '';
1499         }
1500
1501
1502         /**
1503          * Adds the content of input array $row to the CSV list:
1504          *
1505          * @param       array           Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1506          * @param       string          Table name
1507          * @return      void
1508          */
1509         function addToCSV($row,$table)  {
1510
1511                         // Traversing fields, adding values from $row:
1512                 $csvRow = array();
1513                 foreach ($this->fieldArray as $fN) {
1514                         switch ($fN) {
1515                                 case '_PATH':
1516                                         $csvRow[] = $this->recPath($row['pid']);
1517                                         break;
1518
1519                                 case '_REF_':
1520                                         $csvRow[] = $this->makeRef($table, $row['uid']);
1521                                         break;
1522
1523                                         // remove these columns from the CSV view
1524                                 case '_CONTROL_':
1525                                 case '_CLIPBOARD_':
1526                                         continue;
1527                                         break;
1528
1529                                 default:
1530                                         $csvRow[] = $row[$fN];
1531                         }
1532                 }
1533
1534                         // Set the values in the CSV list
1535                 $this->setCsvRow($csvRow);
1536         }
1537
1538
1539         /**
1540          * Adds input row of values to the internal csvLines array as a CSV formatted line
1541          *
1542          * @param       array           Array with values to be listed.
1543          * @return      void
1544          */
1545         function setCsvRow($csvRow)     {
1546                 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1547         }
1548
1549         /**
1550          * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1551          * This function exits!
1552          *
1553          * @param       string          Filename prefix:
1554          * @return      void            EXITS php execusion!
1555          */
1556         function outputCSV($prefix)     {
1557
1558                         // Setting filename:
1559                 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1560
1561                         // Creating output header:
1562                 $mimeType = 'application/octet-stream';
1563                 Header('Content-Type: '.$mimeType);
1564                 Header('Content-Disposition: attachment; filename='.$filename);
1565
1566                         // Printing the content of the CSV lines:
1567                 echo implode(chr(13).chr(10),$this->csvLines);
1568
1569                         // Exits:
1570                 exit;
1571         }
1572 }
1573
1574
1575
1576 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])   {
1577         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1578 }
1579
1580 ?>