* Added Page TSconfig option "mod.web_list.listOnlyInSingleTableView = 1" which makes...
[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
115                 // Internal, dynamic:
116         var $JScode = '';                               // JavaScript code accumulation
117         var $HTMLcode = '';                             // HTML output
118         var $iLimit=0;                                  // "LIMIT " in SQL...
119         var $eCounter=0;                                // Counting the elements no matter what...
120         var $totalItems='';                             // Set to the total number of items for a table when selecting.
121         var $recPath_cache=array();             // Cache for record path
122         var $setFields=array();                 // Fields to display for the current table
123         var $currentTable = array();    // Used for tracking next/prev uids
124         var $duplicateStack=array();    // Used for tracking duplicate values of fields
125
126
127
128
129
130         /**
131          * Initializes the list generation
132          *
133          * @param       integer         Page id for which the list is rendered. Must be >= 0
134          * @param       string          Tablename - if extended mode where only one table is listed at a time.
135          * @param       integer         Browsing pointer.
136          * @param       string          Search word, if any
137          * @param       integer         Number of levels to search down the page tree
138          * @param       integer         Limit of records to be listed.
139          * @return      void
140          */
141         function start($id,$table,$pointer,$search="",$levels="",$showLimit=0)  {
142                 global $TCA;
143
144                         // Setting internal variables:
145                 $this->id=intval($id);                                  // sets the parent id
146                 if ($TCA[$table])       $this->table=$table;            // Setting single table mode, if table exists:
147                 $this->firstElementNumber=$pointer;
148                 $this->searchString=trim($search);
149                 $this->searchLevels=trim($levels);
150                 $this->showLimit=t3lib_div::intInRange($showLimit,0,10000);
151
152                         // Setting GPvars:
153                 $this->csvOutput = t3lib_div::_GP('csv') ? TRUE : FALSE;
154                 $this->sortField = t3lib_div::_GP('sortField');
155                 $this->sortRev = t3lib_div::_GP('sortRev');
156                 $this->displayFields = t3lib_div::_GP('displayFields');
157                 $this->duplicateField = t3lib_div::_GP('duplicateField');
158
159                         // If thumbnails are disabled, set the "notfound" icon as default:
160                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
161                         $this->thumbScript='gfx/notfound_thumb.gif';
162                 }
163
164                         // Init dynamic vars:
165                 $this->counter=0;
166                 $this->JScode='';
167                 $this->HTMLcode='';
168
169                         // Set select levels:
170                 $sL=intval($this->searchLevels);
171                 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
172                 if ($sL>0)      {
173                         $tree = $this->getTreeObject($id,$sL,$this->perms_clause);
174                         $this->pidSelect = 'pid IN ('.implode($tree->ids,',').')';
175                 } else {
176                         $this->pidSelect = 'pid='.intval($id);
177                 }
178         }
179
180         /**
181          * Traverses the table(s) to be listed and renders the output code for each:
182          * The HTML is accumulated in $this->HTMLcode
183          * Finishes off with a stopper-gif
184          *
185          * @return      void
186          */
187         function generateList() {
188                 global $TCA;
189
190                         // Traverse the TCA table array:
191                 reset($TCA);
192                 while (list($tableName)=each($TCA))     {
193
194                                 // Checking if the table should be rendered:
195                         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:
196
197                                         // Load full table definitions:
198                                 t3lib_div::loadTCA($tableName);
199
200                                         // iLimit is set depending on whether we're in single- or multi-table mode
201                                 if ($this->table)       {
202                                         $this->iLimit=(isset($TCA[$tableName]['interface']['maxSingleDBListItems'])?intval($TCA[$tableName]['interface']['maxSingleDBListItems']):$this->itemsLimitSingleTable);
203                                 } else {
204                                         $this->iLimit=(isset($TCA[$tableName]['interface']['maxDBListItems'])?intval($TCA[$tableName]['interface']['maxDBListItems']):$this->itemsLimitPerTable);
205                                 }
206                                 if ($this->showLimit)   $this->iLimit = $this->showLimit;
207
208                                         // Setting fields to select:
209                                 if ($this->allFields)   {
210                                         $fields = $this->makeFieldList($tableName);
211                                         $fields[]='_PATH_';
212                                         $fields[]='_CONTROL_';
213                                         if (is_array($this->setFields[$tableName]))     {
214                                                 $fields = array_intersect($fields,$this->setFields[$tableName]);
215                                         } else {
216                                                 $fields = array();
217                                         }
218                                 } else {
219                                         $fields = array();
220                                 }
221
222                                         // Finally, render the list:
223                                 $this->HTMLcode.=$this->getTable($tableName, $this->id,implode(',',$fields));
224                         }
225                 }
226         }
227
228         /**
229          * Creates the search box
230          *
231          * @param       boolean         If true, the search box is wrapped in its own form-tags
232          * @return      string          HTML for the search box
233          */
234         function getSearchBox($formFields=1)    {
235
236                         // Setting form-elements, if applicable:
237                 $formElements=array('','');
238                 if ($formFields)        {
239                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
240                 }
241
242                         // Make level selector:
243                 $opt=array();
244                 $parts = explode('|',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchLevels'));
245                 while(list($kv,$label)=each($parts))    {
246                         $opt[] = '<option value="'.$kv.'"'.($kv==intval($this->searchLevels)?' selected="selected"':'').'>'.htmlspecialchars($label).'</option>';
247                 }
248                 $lMenu = '<select name="search_levels">'.implode('',$opt).'</select>';
249
250                         // Table with the search box:
251                 $content.= '
252                         '.$formElements[0].'
253
254                                 <!--
255                                         Search box:
256                                 -->
257                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-search">
258                                         <tr>
259                                                 <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>
260                                                 <td>'.$lMenu.'</td>
261                                                 <td><input type="submit" name="search" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search',1).'" /></td>
262                                         </tr>
263                                         <tr>
264                                                 <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>
265                                         </tr>
266                                 </table>
267                         '.$formElements[1];
268                 return $content;
269         }
270
271         /**
272          * Creates the display of sys_notes for the page.
273          * Relies on the "sys_note" extension to be loaded.
274          *
275          * @return      string          HTML for the sys-notes (if any)
276          */
277         function showSysNotesForPage()  {
278                 global $TCA;
279
280                 $out='';
281
282                         // Checking if extension is loaded:
283                 if (!t3lib_extMgm::isLoaded('sys_note'))        return '';
284
285                         // Create query for selecting the notes:
286                 $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'));
287
288                         // Executing query:
289                 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
290
291                         // If some notes were found, render them:
292                 if ($dbCount)   {
293                         $cat = array();
294
295                                 // Load full table description:
296                         t3lib_div::loadTCA('sys_note');
297
298                                 // Traverse note-types and get labels:
299                         if ($TCA['sys_note'] && $TCA['sys_note']['columns']['category'] && is_array($TCA['sys_note']['columns']['category']['config']['items']))        {
300                                 foreach($TCA['sys_note']['columns']['category']['config']['items'] as $el)      {
301                                         $cat[$el[1]]=$GLOBALS['LANG']->sL($el[0]);
302                                 }
303                         }
304
305                                 // For each note found, make rendering:
306                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
307
308                                         // Create content:
309                                 $iconImg = t3lib_iconWorks::getIconImage('sys_note',$row,$this->backPath,'');
310                                 $subject = htmlspecialchars($row['subject']);
311                                 $fields = array();
312                                 $fields['Author:'] = htmlspecialchars($row['author'].($row['email'] && $row['author'] ? ', ':'').$row['email']);
313                                 $fields['Category:'] = htmlspecialchars($cat[$row['category']]);
314                                 $fields['Note:'] = nl2br(htmlspecialchars($row['message']));
315
316                                         // Compile content:
317                                 $out.='
318
319
320                                 <!--
321                                         Sys-notes for the db_list.php:
322                                 -->
323                                         <table border="0" cellpadding="1" cellspacing="1" id="typo3-dblist-sysnotes">
324                                                 <tr><td colspan="2" class="bgColor2">'.$iconImg.'<strong>'.$subject.'</strong></td></tr>
325                                                 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.category',1).'</td><td class="bgColor4">'.$fields['Category:'].'</td></tr>
326                                                 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.author',1).'</td><td class="bgColor4">'.$fields['Author:'].'</td></tr>
327                                                 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.note',1).'</td><td class="bgColor4">'.$fields['Note:'].'</td></tr>
328                                         </table>
329                                 ';
330                         }
331                 }
332                 return $out;
333         }
334
335
336
337
338
339
340
341
342         /******************************
343          *
344          * Various helper functions
345          *
346          ******************************/
347
348         /**
349          * Setting the field names to display in extended list.
350          * Sets the internal variable $this->setFields
351          *
352          * @return      void
353          */
354         function setDispFields()        {
355
356                         // Getting from session:
357                 $dispFields = $GLOBALS['BE_USER']->getModuleData('db_list.php/displayFields');
358
359                         // If fields has been inputted, then set those as the value and push it to session variable:
360                 if (is_array($this->displayFields))     {
361                         reset($this->displayFields);
362                         $tKey = key($this->displayFields);
363                         $dispFields[$tKey]=$this->displayFields[$tKey];
364                         $GLOBALS['BE_USER']->pushModuleData('db_list.php/displayFields',$dispFields);
365                 }
366
367                         // Setting result:
368                 $this->setFields=$dispFields;
369         }
370
371         /**
372          * Create thumbnail code for record/field
373          *
374          * @param       array           Record array
375          * @param       string          Table (record is from)
376          * @param       string          Field name for which thumbsnail are to be rendered.
377          * @return      string          HTML for thumbnails, if any.
378          */
379         function thumbCode($row,$table,$field)  {
380                 return t3lib_BEfunc::thumbCode($row,$table,$field,$this->backPath,$this->thumbScript);
381         }
382
383         /**
384          * Returns the SQL-query array to select the records from a table $table with pid = $id
385          *
386          * @param       string          Table name
387          * @param       integer         Page id (NOT USED! $this->pidSelect is used instead)
388          * @param       string          Additional part for where clause
389          * @param       string          Field list to select, * for all (for "SELECT [fieldlist] FROM ...")
390          * @return      array           Returns query array
391          */
392         function makeQueryArray($table, $id, $addWhere="",$fieldList='*')       {
393                 global $TCA;
394
395                         // Set ORDER BY:
396                 $orderBy = ($TCA[$table]['ctrl']['sortby']) ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
397                 if ($this->sortField)   {
398                         if (in_array($this->sortField,$this->makeFieldList($table,1)))  {
399                                 $orderBy = 'ORDER BY '.$this->sortField;
400                                 if ($this->sortRev)     $orderBy.=' DESC';
401                         }
402                 }
403
404                         // Set LIMIT:
405                 $limit = $this->iLimit ? ($this->firstElementNumber ? $this->firstElementNumber.',' : '').($this->iLimit+1) : '';
406
407                         // Filtering on displayable pages (permissions):
408                 $pC = ($table=='pages' && $this->perms_clause)?' AND '.$this->perms_clause:'';
409
410                         // Adding search constraints:
411                 $search = $this->makeSearchString($table);
412
413                         // Compiling query array:
414                 $queryParts = array(
415                         'SELECT' => $fieldList,
416                         'FROM' => $table,
417                         'WHERE' => $this->pidSelect.' '.$pC.t3lib_BEfunc::deleteClause($table).' '.$addWhere.' '.$search,
418                         'GROUPBY' => '',
419                         'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
420                         'LIMIT' => $limit
421                 );
422
423                         // Return query:
424                 return $queryParts;
425         }
426
427         /**
428          * 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
429          *
430          * @param       array           Query array
431          * @return      void
432          * @see makeQueryArray()
433          */
434         function setTotalItems($queryParts)     {
435                 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
436                                         'count(*)',
437                                         $queryParts['FROM'],
438                                         $queryParts['WHERE']
439                                 );
440                 list($rCount) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
441                 $this->totalItems = $rCount;
442         }
443
444         /**
445          * Creates part of query for searching after a word ($this->searchString) fields in input table
446          *
447          * @param       string          Table, in which the fields are being searched.
448          * @return      string          Returns part of WHERE-clause for searching, if applicable.
449          */
450         function makeSearchString($table)       {
451                 global $TCA;
452
453                         // Make query, only if table is valid and a search string is actually defined:
454                 if ($TCA[$table] && $this->searchString)        {
455
456                                 // Loading full table description - we need to traverse fields:
457                         t3lib_div::loadTCA($table);
458
459                                 // Initialize field array:
460                         $sfields=array();
461                         $sfields[]='uid';       // Adding "uid" by default.
462
463                                 // Traverse the configured columns and add all columns that can be searched:
464                         foreach($TCA[$table]['columns'] as $fieldName => $info) {
465                                 if ($info['config']['type']=='text' || ($info['config']['type']=='input' && !ereg('date|time|int',$info['config']['eval'])))    {
466                                         $sfields[]=$fieldName;
467                                 }
468                         }
469
470                                 // If search-fields were defined (and there always are) we create the query:
471                         if (count($sfields))    {
472                                 $like=' LIKE "%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table).'%"';              // Free-text searching...
473                                 $queryPart = ' AND ('.implode($like.' OR ',$sfields).$like.')';
474
475                                         // Return query:
476                                 return $queryPart;
477                         }
478                 }
479         }
480
481         /**
482          * Returns the title (based on $code) of a table ($table) with the proper link around. For headers over tables.
483          * The link will cause the display of all extended mode or not for the table.
484          *
485          * @param       string          Table name
486          * @param       string          Table label
487          * @return      string          The linked table label
488          */
489         function linkWrapTable($table,$code)    {
490                 if ($this->table!=$table)       {
491                         return '<a href="'.htmlspecialchars($this->listURL('',$table)).'">'.$code.'</a>';
492                 } else {
493                         return '<a href="'.htmlspecialchars($this->listURL('','','sortField,sortRev,table')).'">'.$code.'</a>';
494                 }
495         }
496
497         /**
498          * 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...)
499          *
500          * @param       string          Table name
501          * @param       integer         Item uid
502          * @param       string          Item title (not htmlspecialchars()'ed yet)
503          * @param       array           Item row
504          * @return      string          The item title. Ready for HTML output (is htmlspecialchars()'ed)
505          */
506         function linkWrapItems($table,$uid,$code,$row)  {
507
508                         // If the title is blank, make a "no title" label:
509                 if (!strcmp($code,'')) {
510                         $code='<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i> - '.htmlspecialchars(t3lib_BEfunc::getRecordTitle($table,$row));
511                 } else {
512                         $code=htmlspecialchars(t3lib_div::fixed_lgd($code,$this->fixedL));
513                 }
514
515                         // Output the label now:
516                 if ($table=='pages')    {
517                         return '<a href="'.htmlspecialchars($this->listURL($uid,'')).'">'.$code.'</a>';
518                 } else {
519                         return $code;
520                 }
521         }
522
523         /**
524          * Creates the URL to this script, including all relevant GPvars
525          * Fixed GPvars are id, table, imagemode, returlUrl, search_field, search_levels and showLimit
526          * The GPvars "sortField" and "sortRev" are also included UNLESS they are found in the $exclList variable.
527          *
528          * @param       string          Alternative id value. Enter blank string for the current id ($this->id)
529          * @param       string          Tablename to display. Enter "-1" for the current table.
530          * @param       string          Commalist of fields NOT to include ("sortField" or "sortRev")
531          * @return      string          URL
532          */
533         function listURL($altId='',$table=-1,$exclList='')      {
534                 return $this->script.
535                         '?id='.(strcmp($altId,'')?$altId:$this->id).
536                         '&table='.rawurlencode($table==-1?$this->table:$table).
537                         ($this->thumbs?'&imagemode='.$this->thumbs:'').
538                         ($this->returnUrl?'&returnUrl='.rawurlencode($this->returnUrl):'').
539                         ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
540                         ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
541                         ($this->showLimit?'&showLimit='.rawurlencode($this->showLimit):'').
542                         ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
543                         ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'')
544                         ;
545         }
546
547         /**
548          * Returns "requestUri" - which is basically listURL
549          *
550          * @return      string          Content of ->listURL()
551          */
552         function requestUri()   {
553                 return $this->listURL();
554         }
555
556         /**
557          * Makes the list of fields to select for a table
558          *
559          * @param       string          Table name
560          * @param       boolean         If set, users access to the field (non-exclude-fields) is NOT checked.
561          * @return      array           Array, where values are fieldnames to include in query
562          */
563         function makeFieldList($table,$dontCheckUser=0) {
564                 global $TCA,$BE_USER;
565
566                         // Init fieldlist array:
567                 $fieldListArr = array();
568
569                         // Check table:
570                 if (is_array($TCA[$table]))     {
571                         t3lib_div::loadTCA($table);
572
573                                 // Traverse configured columns and add them to field array, if available for user.
574                         foreach($TCA[$table]['columns'] as $fN => $fieldValue)  {
575                                 if ($dontCheckUser ||
576                                         ((!$fieldValue['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$fN)) && $fieldValue['config']['type']!='passthrough'))    {
577                                         $fieldListArr[]=$fN;
578                                 }
579                         }
580
581                                 // Add special fields:
582                         if ($dontCheckUser || $BE_USER->isAdmin())      {
583                                 $fieldListArr[]='uid';
584                                 $fieldListArr[]='pid';
585                                 if ($TCA[$table]['ctrl']['tstamp'])     $fieldListArr[]=$TCA[$table]['ctrl']['tstamp'];
586                                 if ($TCA[$table]['ctrl']['crdate'])     $fieldListArr[]=$TCA[$table]['ctrl']['crdate'];
587                                 if ($TCA[$table]['ctrl']['cruser_id'])  $fieldListArr[]=$TCA[$table]['ctrl']['cruser_id'];
588                                 if ($TCA[$table]['ctrl']['sortby'])     $fieldListArr[]=$TCA[$table]['ctrl']['sortby'];
589                         }
590                 }
591                 return $fieldListArr;
592         }
593
594         /**
595          * 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.
596          *
597          * @param       integer         Page id.
598          * @param       integer         Depth to go down.
599          * @param       string          Select clause
600          * @return      object          t3lib_pageTree instance with created list of ids.
601          */
602         function getTreeObject($id,$depth,$perms_clause)        {
603                 $tree = t3lib_div::makeInstance('t3lib_pageTree');
604                 $tree->init('AND '.$perms_clause);
605                 $tree->makeHTML=0;
606                 $tree->fieldArray = Array('uid','php_tree_stop');
607                 if ($depth)     {
608                         $tree->getTree($id, $depth, '');
609                 }
610                 $tree->ids[]=$id;
611                 return $tree;
612         }
613
614 }
615
616
617 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']) {
618         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']);
619 }
620 ?>