* Added option "mod.web_list.clickTitleMode = edit/info/show" to determine alternativ...
[Packages/TYPO3.CMS.git] / typo3 / class.db_list.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2004 Kasper Skaarhoj (kasper@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 t3lib_recordList
29  * Shared between Web>List (db_list.php) and Web>Page (sysext/cms/layout/db_layout.php)
30  *
31  * $Id$
32  * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
33  * XHTML compliant
34  *
35  * @author      Kasper Skaarhoj <kasper@typo3.com>
36  */
37 /**
38  * [CLASS/FUNCTION INDEX of SCRIPT]
39  *
40  *
41  *
42  *   84: class recordList extends t3lib_recordList
43  *  140:     function start($id,$table,$pointer,$search="",$levels="",$showLimit=0)
44  *  186:     function generateList()
45  *  233:     function getSearchBox($formFields=1)
46  *  276:     function showSysNotesForPage()
47  *
48  *              SECTION: Various helper functions
49  *  353:     function setDispFields()
50  *  378:     function thumbCode($row,$table,$field)
51  *  391:     function makeQueryArray($table, $id, $addWhere="",$fieldList='*')
52  *  433:     function setTotalItems($queryParts)
53  *  449:     function makeSearchString($table)
54  *  488:     function linkWrapTable($table,$code)
55  *  505:     function linkWrapItems($table,$uid,$code,$row)
56  *  532:     function listURL($altId='',$table=-1,$exclList='')
57  *  551:     function requestUri()
58  *  562:     function makeFieldList($table,$dontCheckUser=0)
59  *  601:     function getTreeObject($id,$depth,$perms_clause)
60  *
61  * TOTAL FUNCTIONS: 15
62  * (This index is automatically created/updated by the extension "extdeveval")
63  *
64  */
65
66
67
68
69
70
71
72
73
74
75
76 /**
77  * Child class for rendering of Web > List (not the final class. see class.db_list_extra)
78  *
79  * @author      Kasper Skaarhoj <kasper@typo3.com>
80  * @package TYPO3
81  * @subpackage core
82  * @see localRecordList
83  */
84 class recordList extends t3lib_recordList {
85
86                 // External, static:
87         var $tableList='';                                              // Specify a list of tables which are the only ones allowed to be displayed.
88         var $returnUrl='';                                              // Return URL
89         var $thumbs = 0;                                                // Boolean. Thumbnails on records containing files (pictures)
90         var $itemsLimitPerTable = 20;                   // default Max items shown per table in "multi-table mode", may be overridden by tables.php
91         var $itemsLimitSingleTable = 100;               // default Max items shown per table in "single-table mode", may be overridden by tables.php
92         var $widthGif = '<img src="clear.gif" width="1" height="4" hspace="160" alt="" />';
93         var $script = 'db_list.php';                    // Current script name
94         var $allFields=0;                                               // Indicates if all available fields for a user should be selected or not.
95
96                 // Internal, static: GPvar:
97         var $csvOutput=FALSE;                   // If set, csvList is outputted.
98         var $sortField;                                 // Field, to sort list by
99         var $sortRev;                                   // Field, indicating to sort in reverse order.
100         var $displayFields;                             // Array, containing which fields to display in extended mode
101         var $duplicateField;                    // String, can contain the field name from a table which must have duplicate values marked.
102
103                 // Internal, static:
104         var $id;                                                // Page id
105         var $table='';                                  // Tablename if single-table mode
106         var $listOnlyInSingleTableMode=FALSE;   // If true, records are listed only if a specific table is selected.
107         var $firstElementNumber=0;              // Pointer for browsing list
108         var $searchString='';                   // Search string
109         var $searchLevels='';                   // Levels to search down.
110         var $showLimit=0;                               // Number of records to show
111         var $pidSelect='';                              // List of ids from which to select/search etc. (when search-levels are set high). See start()
112         var $perms_clause='';                   // Page select permissions
113         var $calcPerms=0;                               // Some permissions...
114         var $clickTitleMode = '';               // Mode for what happens when a user clicks the title of a record.
115
116                 // Internal, dynamic:
117         var $JScode = '';                               // JavaScript code accumulation
118         var $HTMLcode = '';                             // HTML output
119         var $iLimit=0;                                  // "LIMIT " in SQL...
120         var $eCounter=0;                                // Counting the elements no matter what...
121         var $totalItems='';                             // Set to the total number of items for a table when selecting.
122         var $recPath_cache=array();             // Cache for record path
123         var $setFields=array();                 // Fields to display for the current table
124         var $currentTable = array();    // Used for tracking next/prev uids
125         var $duplicateStack=array();    // Used for tracking duplicate values of fields
126
127
128
129
130
131         /**
132          * Initializes the list generation
133          *
134          * @param       integer         Page id for which the list is rendered. Must be >= 0
135          * @param       string          Tablename - if extended mode where only one table is listed at a time.
136          * @param       integer         Browsing pointer.
137          * @param       string          Search word, if any
138          * @param       integer         Number of levels to search down the page tree
139          * @param       integer         Limit of records to be listed.
140          * @return      void
141          */
142         function start($id,$table,$pointer,$search="",$levels="",$showLimit=0)  {
143                 global $TCA;
144
145                         // Setting internal variables:
146                 $this->id=intval($id);                                  // sets the parent id
147                 if ($TCA[$table])       $this->table=$table;            // Setting single table mode, if table exists:
148                 $this->firstElementNumber=$pointer;
149                 $this->searchString=trim($search);
150                 $this->searchLevels=trim($levels);
151                 $this->showLimit=t3lib_div::intInRange($showLimit,0,10000);
152
153                         // Setting GPvars:
154                 $this->csvOutput = t3lib_div::_GP('csv') ? TRUE : FALSE;
155                 $this->sortField = t3lib_div::_GP('sortField');
156                 $this->sortRev = t3lib_div::_GP('sortRev');
157                 $this->displayFields = t3lib_div::_GP('displayFields');
158                 $this->duplicateField = t3lib_div::_GP('duplicateField');
159
160                         // If thumbnails are disabled, set the "notfound" icon as default:
161                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
162                         $this->thumbScript='gfx/notfound_thumb.gif';
163                 }
164
165                         // Init dynamic vars:
166                 $this->counter=0;
167                 $this->JScode='';
168                 $this->HTMLcode='';
169
170                         // Set select levels:
171                 $sL=intval($this->searchLevels);
172                 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
173                 if ($sL>0)      {
174                         $tree = $this->getTreeObject($id,$sL,$this->perms_clause);
175                         $this->pidSelect = 'pid IN ('.implode($tree->ids,',').')';
176                 } else {
177                         $this->pidSelect = 'pid='.intval($id);
178                 }
179         }
180
181         /**
182          * Traverses the table(s) to be listed and renders the output code for each:
183          * The HTML is accumulated in $this->HTMLcode
184          * Finishes off with a stopper-gif
185          *
186          * @return      void
187          */
188         function generateList() {
189                 global $TCA;
190
191                         // Traverse the TCA table array:
192                 reset($TCA);
193                 while (list($tableName)=each($TCA))     {
194
195                                 // Checking if the table should be rendered:
196                         if ((!$this->table || $tableName==$this->table) && (!$this->tableList || t3lib_div::inList($this->tableList,$tableName)) && $GLOBALS['BE_USER']->check('tables_select',$tableName))     {               // Checks that we see only permitted/requested tables:
197
198                                         // Load full table definitions:
199                                 t3lib_div::loadTCA($tableName);
200
201                                         // iLimit is set depending on whether we're in single- or multi-table mode
202                                 if ($this->table)       {
203                                         $this->iLimit=(isset($TCA[$tableName]['interface']['maxSingleDBListItems'])?intval($TCA[$tableName]['interface']['maxSingleDBListItems']):$this->itemsLimitSingleTable);
204                                 } else {
205                                         $this->iLimit=(isset($TCA[$tableName]['interface']['maxDBListItems'])?intval($TCA[$tableName]['interface']['maxDBListItems']):$this->itemsLimitPerTable);
206                                 }
207                                 if ($this->showLimit)   $this->iLimit = $this->showLimit;
208
209                                         // Setting fields to select:
210                                 if ($this->allFields)   {
211                                         $fields = $this->makeFieldList($tableName);
212                                         $fields[]='_PATH_';
213                                         $fields[]='_CONTROL_';
214                                         if (is_array($this->setFields[$tableName]))     {
215                                                 $fields = array_intersect($fields,$this->setFields[$tableName]);
216                                         } else {
217                                                 $fields = array();
218                                         }
219                                 } else {
220                                         $fields = array();
221                                 }
222
223                                         // Finally, render the list:
224                                 $this->HTMLcode.=$this->getTable($tableName, $this->id,implode(',',$fields));
225                         }
226                 }
227         }
228
229         /**
230          * Creates the search box
231          *
232          * @param       boolean         If true, the search box is wrapped in its own form-tags
233          * @return      string          HTML for the search box
234          */
235         function getSearchBox($formFields=1)    {
236
237                         // Setting form-elements, if applicable:
238                 $formElements=array('','');
239                 if ($formFields)        {
240                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
241                 }
242
243                         // Make level selector:
244                 $opt=array();
245                 $parts = explode('|',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchLevels'));
246                 while(list($kv,$label)=each($parts))    {
247                         $opt[] = '<option value="'.$kv.'"'.($kv==intval($this->searchLevels)?' selected="selected"':'').'>'.htmlspecialchars($label).'</option>';
248                 }
249                 $lMenu = '<select name="search_levels">'.implode('',$opt).'</select>';
250
251                         // Table with the search box:
252                 $content.= '
253                         '.$formElements[0].'
254
255                                 <!--
256                                         Search box:
257                                 -->
258                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-search">
259                                         <tr>
260                                                 <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchString',1).'<input type="text" name="search_field" value="'.htmlspecialchars($this->searchString).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' /></td>
261                                                 <td>'.$lMenu.'</td>
262                                                 <td><input type="submit" name="search" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search',1).'" /></td>
263                                         </tr>
264                                         <tr>
265                                                 <td colspan="3">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showRecords',1).':<input type="text" name="showLimit" value="'.htmlspecialchars($this->showLimit?$this->showLimit:'').'"'.$GLOBALS['SOBE']->doc->formWidth(4).' /></td>
266                                         </tr>
267                                 </table>
268                         '.$formElements[1];
269                 return $content;
270         }
271
272         /**
273          * Creates the display of sys_notes for the page.
274          * Relies on the "sys_note" extension to be loaded.
275          *
276          * @return      string          HTML for the sys-notes (if any)
277          */
278         function showSysNotesForPage()  {
279                 global $TCA;
280
281                 $out='';
282
283                         // Checking if extension is loaded:
284                 if (!t3lib_extMgm::isLoaded('sys_note'))        return '';
285
286                         // Create query for selecting the notes:
287                 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','sys_note','pid IN ('.$this->id.') AND (!personal OR cruser="'.intval($GLOBALS['BE_USER']->user['uid']).'")'.t3lib_BEfunc::deleteClause('sys_note'));
288
289                         // Executing query:
290                 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
291
292                         // If some notes were found, render them:
293                 if ($dbCount)   {
294                         $cat = array();
295
296                                 // Load full table description:
297                         t3lib_div::loadTCA('sys_note');
298
299                                 // Traverse note-types and get labels:
300                         if ($TCA['sys_note'] && $TCA['sys_note']['columns']['category'] && is_array($TCA['sys_note']['columns']['category']['config']['items']))        {
301                                 foreach($TCA['sys_note']['columns']['category']['config']['items'] as $el)      {
302                                         $cat[$el[1]]=$GLOBALS['LANG']->sL($el[0]);
303                                 }
304                         }
305
306                                 // For each note found, make rendering:
307                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
308
309                                         // Create content:
310                                 $iconImg = t3lib_iconWorks::getIconImage('sys_note',$row,$this->backPath,'');
311                                 $subject = htmlspecialchars($row['subject']);
312                                 $fields = array();
313                                 $fields['Author:'] = htmlspecialchars($row['author'].($row['email'] && $row['author'] ? ', ':'').$row['email']);
314                                 $fields['Category:'] = htmlspecialchars($cat[$row['category']]);
315                                 $fields['Note:'] = nl2br(htmlspecialchars($row['message']));
316
317                                         // Compile content:
318                                 $out.='
319
320
321                                 <!--
322                                         Sys-notes for the db_list.php:
323                                 -->
324                                         <table border="0" cellpadding="1" cellspacing="1" id="typo3-dblist-sysnotes">
325                                                 <tr><td colspan="2" class="bgColor2">'.$iconImg.'<strong>'.$subject.'</strong></td></tr>
326                                                 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.category',1).'</td><td class="bgColor4">'.$fields['Category:'].'</td></tr>
327                                                 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.author',1).'</td><td class="bgColor4">'.$fields['Author:'].'</td></tr>
328                                                 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.note',1).'</td><td class="bgColor4">'.$fields['Note:'].'</td></tr>
329                                         </table>
330                                 ';
331                         }
332                 }
333                 return $out;
334         }
335
336
337
338
339
340
341
342
343         /******************************
344          *
345          * Various helper functions
346          *
347          ******************************/
348
349         /**
350          * Setting the field names to display in extended list.
351          * Sets the internal variable $this->setFields
352          *
353          * @return      void
354          */
355         function setDispFields()        {
356
357                         // Getting from session:
358                 $dispFields = $GLOBALS['BE_USER']->getModuleData('db_list.php/displayFields');
359
360                         // If fields has been inputted, then set those as the value and push it to session variable:
361                 if (is_array($this->displayFields))     {
362                         reset($this->displayFields);
363                         $tKey = key($this->displayFields);
364                         $dispFields[$tKey]=$this->displayFields[$tKey];
365                         $GLOBALS['BE_USER']->pushModuleData('db_list.php/displayFields',$dispFields);
366                 }
367
368                         // Setting result:
369                 $this->setFields=$dispFields;
370         }
371
372         /**
373          * Create thumbnail code for record/field
374          *
375          * @param       array           Record array
376          * @param       string          Table (record is from)
377          * @param       string          Field name for which thumbsnail are to be rendered.
378          * @return      string          HTML for thumbnails, if any.
379          */
380         function thumbCode($row,$table,$field)  {
381                 return t3lib_BEfunc::thumbCode($row,$table,$field,$this->backPath,$this->thumbScript);
382         }
383
384         /**
385          * Returns the SQL-query array to select the records from a table $table with pid = $id
386          *
387          * @param       string          Table name
388          * @param       integer         Page id (NOT USED! $this->pidSelect is used instead)
389          * @param       string          Additional part for where clause
390          * @param       string          Field list to select, * for all (for "SELECT [fieldlist] FROM ...")
391          * @return      array           Returns query array
392          */
393         function makeQueryArray($table, $id, $addWhere="",$fieldList='*')       {
394                 global $TCA;
395
396                         // Set ORDER BY:
397                 $orderBy = ($TCA[$table]['ctrl']['sortby']) ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
398                 if ($this->sortField)   {
399                         if (in_array($this->sortField,$this->makeFieldList($table,1)))  {
400                                 $orderBy = 'ORDER BY '.$this->sortField;
401                                 if ($this->sortRev)     $orderBy.=' DESC';
402                         }
403                 }
404
405                         // Set LIMIT:
406                 $limit = $this->iLimit ? ($this->firstElementNumber ? $this->firstElementNumber.',' : '').($this->iLimit+1) : '';
407
408                         // Filtering on displayable pages (permissions):
409                 $pC = ($table=='pages' && $this->perms_clause)?' AND '.$this->perms_clause:'';
410
411                         // Adding search constraints:
412                 $search = $this->makeSearchString($table);
413
414                         // Compiling query array:
415                 $queryParts = array(
416                         'SELECT' => $fieldList,
417                         'FROM' => $table,
418                         'WHERE' => $this->pidSelect.' '.$pC.t3lib_BEfunc::deleteClause($table).' '.$addWhere.' '.$search,
419                         'GROUPBY' => '',
420                         'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
421                         'LIMIT' => $limit
422                 );
423
424                         // Return query:
425                 return $queryParts;
426         }
427
428         /**
429          * Based on input query array (query for selecting count(*) from a table) it will select the number of records and set the value in $this->totalItems
430          *
431          * @param       array           Query array
432          * @return      void
433          * @see makeQueryArray()
434          */
435         function setTotalItems($queryParts)     {
436                 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
437                                         'count(*)',
438                                         $queryParts['FROM'],
439                                         $queryParts['WHERE']
440                                 );
441                 list($rCount) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
442                 $this->totalItems = $rCount;
443         }
444
445         /**
446          * Creates part of query for searching after a word ($this->searchString) fields in input table
447          *
448          * @param       string          Table, in which the fields are being searched.
449          * @return      string          Returns part of WHERE-clause for searching, if applicable.
450          */
451         function makeSearchString($table)       {
452                 global $TCA;
453
454                         // Make query, only if table is valid and a search string is actually defined:
455                 if ($TCA[$table] && $this->searchString)        {
456
457                                 // Loading full table description - we need to traverse fields:
458                         t3lib_div::loadTCA($table);
459
460                                 // Initialize field array:
461                         $sfields=array();
462                         $sfields[]='uid';       // Adding "uid" by default.
463
464                                 // Traverse the configured columns and add all columns that can be searched:
465                         foreach($TCA[$table]['columns'] as $fieldName => $info) {
466                                 if ($info['config']['type']=='text' || ($info['config']['type']=='input' && !ereg('date|time|int',$info['config']['eval'])))    {
467                                         $sfields[]=$fieldName;
468                                 }
469                         }
470
471                                 // If search-fields were defined (and there always are) we create the query:
472                         if (count($sfields))    {
473                                 $like=' LIKE "%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table).'%"';              // Free-text searching...
474                                 $queryPart = ' AND ('.implode($like.' OR ',$sfields).$like.')';
475
476                                         // Return query:
477                                 return $queryPart;
478                         }
479                 }
480         }
481
482         /**
483          * Returns the title (based on $code) of a table ($table) with the proper link around. For headers over tables.
484          * The link will cause the display of all extended mode or not for the table.
485          *
486          * @param       string          Table name
487          * @param       string          Table label
488          * @return      string          The linked table label
489          */
490         function linkWrapTable($table,$code)    {
491                 if ($this->table!=$table)       {
492                         return '<a href="'.htmlspecialchars($this->listURL('',$table)).'">'.$code.'</a>';
493                 } else {
494                         return '<a href="'.htmlspecialchars($this->listURL('','','sortField,sortRev,table')).'">'.$code.'</a>';
495                 }
496         }
497
498         /**
499          * Returns the title (based on $code) of a record (from table $table) with the proper link around (that is for 'pages'-records a link to the level of that record...)
500          *
501          * @param       string          Table name
502          * @param       integer         Item uid
503          * @param       string          Item title (not htmlspecialchars()'ed yet)
504          * @param       array           Item row
505          * @return      string          The item title. Ready for HTML output (is htmlspecialchars()'ed)
506          */
507         function linkWrapItems($table,$uid,$code,$row)  {
508                 global $TCA, $LANG;
509
510                         // If the title is blank, make a "no title" label:
511                 if (!strcmp($code,'')) {
512                         $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i> - '.htmlspecialchars(t3lib_BEfunc::getRecordTitle($table,$row));
513                 } else {
514                         $code = htmlspecialchars(t3lib_div::fixed_lgd($code,$this->fixedL));
515                 }
516
517                 switch((string)$this->clickTitleMode)   {
518                         case 'edit':
519                                         // If the listed table is 'pages' we have to request the permission settings for each page:
520                                 if ($table=='pages')    {
521                                         $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
522                                         $permsEdit = $localCalcPerms&2;
523                                 } else {
524                                         $permsEdit = $this->calcPerms&16;
525                                 }
526
527                                         // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
528                                 if ($permsEdit) {
529                                         $params='&edit['.$table.']['.$row['uid'].']=edit';
530                                         $code = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'" title="'.$LANG->getLL('edit',1).'">'.
531                                                         $code.
532                                                         '</a>';
533                                 }
534                         break;
535                         case 'show':
536                                         // "Show" link (only pages and tt_content elements)
537                                 if ($table=='pages' || $table=='tt_content')    {
538                                         $params = '&edit['.$table.']['.$row['uid'].']=edit';
539                                         $code = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'])).'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'">'.
540                                                         $code.
541                                                         '</a>';
542                                 }
543                         break;
544                         case 'info':
545                                 // "Info": (All records)
546                                 $code = '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'" title="'.$LANG->getLL('showInfo',1).'">'.
547                                         $code.
548                                         '</a>';
549                         break;
550                         default:
551                                         // Output the label now:
552                                 if ($table=='pages')    {
553                                         $code = '<a href="'.htmlspecialchars($this->listURL($uid,'')).'">'.$code.'</a>';
554                                 }
555                         break;
556                 }
557
558                 return $code;
559         }
560
561         /**
562          * Creates the URL to this script, including all relevant GPvars
563          * Fixed GPvars are id, table, imagemode, returlUrl, search_field, search_levels and showLimit
564          * The GPvars "sortField" and "sortRev" are also included UNLESS they are found in the $exclList variable.
565          *
566          * @param       string          Alternative id value. Enter blank string for the current id ($this->id)
567          * @param       string          Tablename to display. Enter "-1" for the current table.
568          * @param       string          Commalist of fields NOT to include ("sortField" or "sortRev")
569          * @return      string          URL
570          */
571         function listURL($altId='',$table=-1,$exclList='')      {
572                 return $this->script.
573                         '?id='.(strcmp($altId,'')?$altId:$this->id).
574                         '&table='.rawurlencode($table==-1?$this->table:$table).
575                         ($this->thumbs?'&imagemode='.$this->thumbs:'').
576                         ($this->returnUrl?'&returnUrl='.rawurlencode($this->returnUrl):'').
577                         ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
578                         ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
579                         ($this->showLimit?'&showLimit='.rawurlencode($this->showLimit):'').
580                         ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
581                         ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'')
582                         ;
583         }
584
585         /**
586          * Returns "requestUri" - which is basically listURL
587          *
588          * @return      string          Content of ->listURL()
589          */
590         function requestUri()   {
591                 return $this->listURL();
592         }
593
594         /**
595          * Makes the list of fields to select for a table
596          *
597          * @param       string          Table name
598          * @param       boolean         If set, users access to the field (non-exclude-fields) is NOT checked.
599          * @return      array           Array, where values are fieldnames to include in query
600          */
601         function makeFieldList($table,$dontCheckUser=0) {
602                 global $TCA,$BE_USER;
603
604                         // Init fieldlist array:
605                 $fieldListArr = array();
606
607                         // Check table:
608                 if (is_array($TCA[$table]))     {
609                         t3lib_div::loadTCA($table);
610
611                                 // Traverse configured columns and add them to field array, if available for user.
612                         foreach($TCA[$table]['columns'] as $fN => $fieldValue)  {
613                                 if ($dontCheckUser ||
614                                         ((!$fieldValue['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$fN)) && $fieldValue['config']['type']!='passthrough'))    {
615                                         $fieldListArr[]=$fN;
616                                 }
617                         }
618
619                                 // Add special fields:
620                         if ($dontCheckUser || $BE_USER->isAdmin())      {
621                                 $fieldListArr[]='uid';
622                                 $fieldListArr[]='pid';
623                                 if ($TCA[$table]['ctrl']['tstamp'])     $fieldListArr[]=$TCA[$table]['ctrl']['tstamp'];
624                                 if ($TCA[$table]['ctrl']['crdate'])     $fieldListArr[]=$TCA[$table]['ctrl']['crdate'];
625                                 if ($TCA[$table]['ctrl']['cruser_id'])  $fieldListArr[]=$TCA[$table]['ctrl']['cruser_id'];
626                                 if ($TCA[$table]['ctrl']['sortby'])     $fieldListArr[]=$TCA[$table]['ctrl']['sortby'];
627                         }
628                 }
629                 return $fieldListArr;
630         }
631
632         /**
633          * Creates an instance of t3lib_pageTree which will select a page tree to $depth and return the object. In that object we will find the ids of the tree.
634          *
635          * @param       integer         Page id.
636          * @param       integer         Depth to go down.
637          * @param       string          Select clause
638          * @return      object          t3lib_pageTree instance with created list of ids.
639          */
640         function getTreeObject($id,$depth,$perms_clause)        {
641                 $tree = t3lib_div::makeInstance('t3lib_pageTree');
642                 $tree->init('AND '.$perms_clause);
643                 $tree->makeHTML=0;
644                 $tree->fieldArray = Array('uid','php_tree_stop');
645                 if ($depth)     {
646                         $tree->getTree($id, $depth, '');
647                 }
648                 $tree->ids[]=$id;
649                 return $tree;
650         }
651
652 }
653
654
655 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']) {
656         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']);
657 }
658 ?>