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