Initial revision
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_page.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (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 * Contains a class with "Page functions" mainly for the frontend
29 *
30 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
31 * XHTML-trans compliant
32 *
33 * @author Kasper Skårhøj <kasper@typo3.com>
34 * @package TYPO3
35 * @subpackage t3lib
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 *
41 *
42 * 100: class t3lib_pageSelect
43 * 116: function init($show_hidden)
44 *
45 * SECTION: Selecting page records
46 * 155: function getPage($uid)
47 * 171: function getPage_noCheck($uid)
48 * 187: function getFirstWebPage($uid)
49 * 203: function getPageIdFromAlias($alias)
50 * 219: function getPageOverlay($pageInput,$lUid=-1)
51 *
52 * SECTION: Page related: Menu, Domain record, Root line
53 * 287: function getMenu($uid,$fields='*',$sortField='sorting',$addWhere='')
54 * 307: function getDomainStartPage($domain, $path='',$request_uri='')
55 * 349: function getRootLine($uid,$MP='')
56 * 409: function getPathFromRootline($rl,$len=20)
57 * 430: function getExtURL($pagerow,$disable=0)
58 *
59 * SECTION: Selecting records in general
60 * 471: function checkRecord($table,$uid,$checkPage=0)
61 * 503: function getRawRecord($table,$uid,$fields='*')
62 * 524: function getRecordsByField($theTable,$theField,$theValue,$endClause='')
63 *
64 * SECTION: Caching and standard clauses
65 * 566: function getHash($hash,$expTime=0)
66 * 588: function storeHash($hash,$data,$ident)
67 * 600: function deleteClause($table)
68 * 615: function enableFields($table,$show_hidden=-1,$ignore_array=array())
69 *
70 * TOTAL FUNCTIONS: 18
71 * (This index is automatically created/updated by the extension "extdeveval")
72 *
73 */
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 /**
93 * Page functions, a lot of sql/pages-related functions
94 * Mainly used in the frontend but also in some cases in the backend.
95 * It's important to set the right $where_hid_del in the object so that the functions operate properly
96 *
97 * @author Kasper Skårhøj <kasper@typo3.com>
98 * @see tslib_fe::fetch_the_id()
99 */
100 class t3lib_pageSelect {
101 var $urltypes = Array('','http://','ftp://','mailto:');
102 var $where_hid_del = ' AND NOT pages.deleted'; // This is not the final clauses. There will normally be conditions for the hidden,starttime and endtime fields as well. You MUST initialize the object by the init() function
103 var $sys_language_uid=0;
104
105
106
107
108 /**
109 * init() MUST be run directly after creating a new template-object
110 * This sets the internal variable $this->where_hid_del to the correct where clause for page records taking deleted/hidden/starttime/endtime into account
111 *
112 * @param boolean If $show_hidden is true, the hidden-field is ignored!! Normally this should be false. Is used for previewing.
113 * @return void
114 * @see tslib_fe::fetch_the_id(), tx_tstemplateanalyzer::initialize_editor()
115 */
116 function init($show_hidden) {
117 $this->where_hid_del = ' AND NOT pages.deleted ';
118 if (!$show_hidden) {
119 $this->where_hid_del.= 'AND NOT pages.hidden ';
120 }
121 $this->where_hid_del.= 'AND (pages.starttime<='.$GLOBALS['SIM_EXEC_TIME'].') AND (pages.endtime=0 OR pages.endtime>'.$GLOBALS['SIM_EXEC_TIME'].') ';
122 }
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 /*******************************************
141 *
142 * Selecting page records
143 *
144 ******************************************/
145
146 /**
147 * Returns the $row for the page with uid = $uid (observing ->where_hid_del)
148 * Any pages_language_overlay will be applied before the result is returned.
149 * If no page is found an empty array is returned.
150 *
151 * @param integer The page id to look up.
152 * @return array The page row with overlayed localized fields. Empty it no page.
153 * @see getPage_noCheck()
154 */
155 function getPage($uid) {
156 $query='SELECT * FROM pages WHERE uid='.intval($uid).$this->where_hid_del;
157 $res = mysql(TYPO3_db, $query);
158 if ($row = mysql_fetch_assoc($res)) {
159 return $this->getPageOverlay($row);
160 }
161 return Array();
162 }
163
164 /**
165 * Return the $row for the page with uid = $uid WITHOUT checking for ->where_hid_del (start- and endtime or hidden). Only "deleted" is checked!
166 *
167 * @param integer The page id to look up
168 * @return array The page row with overlayed localized fields. Empty it no page.
169 * @see getPage()
170 */
171 function getPage_noCheck($uid) {
172 $query='SELECT * FROM pages WHERE uid='.intval($uid).' AND NOT pages.deleted';
173 $res = mysql(TYPO3_db, $query);
174 if ($row = mysql_fetch_assoc($res)) {
175 return $this->getPageOverlay($row);
176 }
177 return Array();
178 }
179
180 /**
181 * Returns the $row of the first web-page in the tree (for the default menu...)
182 *
183 * @param integer The page id for which to fetch first subpages (PID)
184 * @return mixed If found: The page record (with overlayed localized fields, if any). If NOT found: blank value (not array!)
185 * @see tslib_fe::fetch_the_id()
186 */
187 function getFirstWebPage($uid) {
188 $output='';
189 $res = mysql(TYPO3_db, 'SELECT * FROM pages WHERE pid='.intval($uid).$this->where_hid_del.' ORDER BY sorting LIMIT 1');
190 if ($row = mysql_fetch_assoc($res)) {
191 $output=$this->getPageOverlay($row);
192 }
193 return $output;
194 }
195
196 /**
197 * Returns a pagerow for the page with alias $alias
198 *
199 * @param string The alias to look up the page uid for.
200 * @return integer Returns page uid (integer) if found, otherwise 0 (zero)
201 * @see tslib_fe::checkAndSetAlias(), tslib_cObj::typoLink()
202 */
203 function getPageIdFromAlias($alias) {
204 $alias=strtolower($alias);
205 $res = mysql(TYPO3_db, 'SELECT uid FROM pages WHERE alias="'.addslashes($alias).'" AND NOT pages.deleted');
206 if ($row = mysql_fetch_assoc($res)) {
207 return $row['uid'];
208 }
209 return 0;
210 }
211
212 /**
213 * Returns the relevant page overlay record fields
214 *
215 * @param mixed If $pageInput is an integer, it's the pid of the pageOverlay record and thus the page overlay record is returned. If $pageInput is an array, it's a page-record and based on this page record the language record is found and OVERLAYED before the page record is returned.
216 * @param integer Language UID if you want to set an alternative value to $this->sys_language_uid which is default. Should be >=0
217 * @return array Page row which is overlayed with language_overlay record (or the overlay record alone)
218 */
219 function getPageOverlay($pageInput,$lUid=-1) {
220 if ($lUid<0) $lUid=$this->sys_language_uid;
221 unset($row);
222 if ($lUid) {
223 $fieldArr=explode(',',$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
224 if (is_array($pageInput)) {
225 $page_id=$pageInput['uid']; // Was the whole record
226 $fieldArr=array_intersect($fieldArr,array_keys($pageInput)); // Make sure that only fields which exist in the incoming record are overlaid!
227 } else {
228 $page_id=$pageInput; // Was the id
229 }
230
231 if (count($fieldArr)) {
232 $query = 'SELECT '.implode(',',$fieldArr).'
233 FROM pages_language_overlay
234 WHERE pid='.intval($page_id).'
235 AND sys_language_uid='.intval($lUid).
236 $this->enableFields('pages_language_overlay').' LIMIT 1';
237 /*
238 NOTE to enabledFields('pages_language_overlay'):
239 Currently the showHiddenRecords of TSFE set will allow pages_language_overlay records to be selected as they are child-records of a page.
240 However you may argue that the showHiddenField flag should determine this. But that's not how it's done right now.
241 */
242 $res = mysql(TYPO3_db,$query);
243 $row = mysql_fetch_assoc($res);
244 }
245 }
246
247 if (is_array($pageInput)) {
248 return is_array($row) ? array_merge($pageInput,$row) : $pageInput; // If the input was an array, simply overlay the newfound array and return...
249 } else {
250 return is_array($row) ? $row : array(); // always an array in return
251 }
252 }
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271 /*******************************************
272 *
273 * Page related: Menu, Domain record, Root line
274 *
275 ******************************************/
276
277 /**
278 * Returns an array with pagerows for subpages with pid=$uid (which is pid here!). This is used for menus.
279 *
280 * @param integer The page id for which to fetch subpages (PID)
281 * @param string List of fields to select. Default is "*" = all
282 * @param string The field to sort by. Default is "sorting"
283 * @param string Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
284 * @return array Array with key/value pairs; keys are page-uid numbers. values are the corresponding page records (with overlayed localized fields, if any)
285 * @see tslib_fe::getPageShortcut(), tslib_menu::makeMenu(), tx_wizardcrpages_webfunc_2, tx_wizardsortpages_webfunc_2
286 */
287 function getMenu($uid,$fields='*',$sortField='sorting',$addWhere='') {
288 $output = Array();
289 $query = 'SELECT '.$fields.' FROM pages WHERE pid='.intval($uid).$this->where_hid_del.' '.$addWhere.' ORDER BY '.$sortField;
290 $res = mysql(TYPO3_db, $query);
291 while ($row = mysql_fetch_assoc($res)) {
292 $output[$row['uid']]=$this->getPageOverlay($row);
293 }
294 return $output;
295 }
296
297 /**
298 * Will find the page carrying the domain record matching the input domain.
299 * Might exit after sending a redirect-header IF a found domain record instructs to do so.
300 *
301 * @param string Domain name to search for. Eg. "www.typo3.com". Typical the HTTP_HOST value.
302 * @param string Path for the current script in domain. Eg. "/somedir/subdir". Typ. supplied by t3lib_div::getIndpEnv('SCRIPT_NAME')
303 * @param string Request URI: Used to get parameters from if they should be appended. Typ. supplied by t3lib_div::getIndpEnv('REQUEST_URI')
304 * @return mixed If found, returns integer with page UID where found. Otherwise blank. Might exit if location-header is sent, see description.
305 * @see tslib_fe::findDomainRecord()
306 */
307 function getDomainStartPage($domain, $path='',$request_uri='') {
308 $domain = explode(':',$domain);
309 $domain = strtolower(ereg_replace('\.$','',$domain[0]));
310 // Removing extra trailing slashes
311 $path = trim(ereg_replace('\/[^\/]*$','',$path));
312 // Appending to domain string
313 $domain.=$path;
314
315 $res = mysql(TYPO3_db, 'SELECT pages.uid,sys_domain.redirectTo,sys_domain.prepend_params
316 FROM pages,sys_domain
317 WHERE pages.uid=sys_domain.pid
318 AND NOT sys_domain.hidden
319 AND (sys_domain.domainName="'.addSlashes($domain).'" OR sys_domain.domainName="'.addSlashes($domain.'/').'") '.
320 $this->where_hid_del.' LIMIT 1');
321 echo mysql_error();
322 if ($row = mysql_fetch_assoc($res)) {
323 if ($row['redirectTo']) {
324 $rURL = $row['redirectTo'];
325 if ($row['prepend_params']) {
326 $rURL = ereg_replace('\/$','',$rURL);
327 $prependStr = ereg_replace('^\/','',substr($request_uri,strlen($path)));
328 $rURL.='/'.$prependStr;
329 }
330 Header('Location: '.t3lib_div::locationHeaderUrl($rURL));
331 exit;
332 } else {
333 return $row['uid'];
334 }
335 }
336 }
337
338 /**
339 * Returns array with fields of the pages from here ($uid) and back to the root
340 * NOTICE: This function only takes deleted pages into account! So hidden, starttime and endtime restricted pages are included no matter what.
341 * Further: If any "recycler" page is found (doktype=255) then it will also block for the rootline)
342 * If you want more fields in the rootline records than default such can be added by listing them in $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']
343 *
344 * @param integer The page uid for which to seek back to the page tree root.
345 * @param string Commalist of MountPoint parameters, eg. "1-2,3-4" etc. Normally this value comes from the GET var, MP
346 * @return array Array with page records from the root line as values. The array is ordered with the outer records first and root record in the bottom. The keys are numeric but in reverse order. So if you traverse/sort the array by the numeric keys order you will get the order from root and out. If an error is found (like eternal looping or invalid mountpoint) it will return an empty array.
347 * @see tslib_fe::getPageAndRootline()
348 */
349 function getRootLine($uid,$MP='') {
350 $selFields = t3lib_div::uniqueList('pid,uid,title,nav_title,media,layout,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,TSconfig,storage_pid,is_siteroot,mount_pid,'.$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']);
351
352 // Splitting the $MP parameters if present
353 $MPA=array();
354 if ($MP) {
355 $MPA=explode(',',$MP);
356 reset($MPA);
357 while(list($MPAk)=each($MPA)) {
358 $MPA[$MPAk]=explode('-',$MPA[$MPAk]);
359 }
360 }
361
362 // Max 20 levels in the page tree.
363 $loopCheck = 20;
364 $theRowArray = Array();
365 $output=Array();
366 $uid = intval($uid); // added 010800
367 while ($uid!=0 && $loopCheck>0) {
368 $loopCheck--;
369 $res = mysql(TYPO3_db, 'SELECT '.$selFields.' FROM pages WHERE uid='.intval($uid).' AND NOT pages.deleted AND pages.doktype!=255');
370 if ($row = mysql_fetch_assoc($res)) {
371 if (count($MPA)) {
372 $curMP=end($MPA);
373 if (!strcmp($row['uid'],$curMP[0])) {
374 array_pop($MPA);
375 $res = mysql(TYPO3_db, 'SELECT '.$selFields.' FROM pages WHERE uid='.intval($curMP[1]).' AND NOT pages.deleted AND pages.doktype!=255');
376 $row = mysql_fetch_assoc($res);
377 $row['_MOUNTED_FROM']=$curMP[0];
378 if (!is_array($row)) return array(); // error - no page...
379 }
380 }
381 $uid = $row['pid'];
382 $theRowArray[]=$this->getPageOverlay($row);
383 } else {
384 $theRowArray='';
385 break;
386 }
387 }
388
389 if (is_array($theRowArray) && !count($MPA)) {
390 $c=count($theRowArray);
391 reset($theRowArray);
392 while(list($key,$val)=each($theRowArray)) {
393 $c--;
394 $output[$c]=$val;
395 }
396 }
397 return $output;
398 }
399
400 /**
401 * Creates a "path" string for the input root line array titles.
402 * Used for writing statistics.
403 *
404 * @param array A rootline array!
405 * @param integer The max length of each title from the rootline.
406 * @return string The path in the form "/page title/This is another pageti.../Another page"
407 * @see tslib_fe::getConfigArray()
408 */
409 function getPathFromRootline($rl,$len=20) {
410 if (is_array($rl)) {
411 $c=count($rl);
412 $path = '';
413 for ($a=0;$a<$c;$a++) {
414 if ($rl[$a]['uid']) {
415 $path.='/'.t3lib_div::fixed_lgd(strip_tags($rl[$a]['title']),$len);
416 }
417 }
418 return $path;
419 }
420 }
421
422 /**
423 * Returns the URL type for the input page row IF the doktype is 3 and not disabled.
424 *
425 * @param array The page row to return URL type for
426 * @param boolean A flag to simply disable any output from here.
427 * @return string The URL type from $this->urltypes array. Blank if not found or disabled.
428 * @see tslib_fe::checkJumpUrl()
429 */
430 function getExtURL($pagerow,$disable=0) {
431 if ($pagerow['doktype']==3 && !$disable) {
432 return $this->urltypes[$pagerow['urltype']].$pagerow['url'];
433 }
434 }
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456 /*********************************
457 *
458 * Selecting records in general
459 *
460 **********************************/
461
462 /**
463 * Checks if a record exists and is accessible.
464 * The row is returned if everything's OK.
465 *
466 * @param string The table name to search
467 * @param integer The uid to look up in $table
468 * @param boolean If checkPage is set, it's also required that the page on which the record resides is accessible
469 * @return mixed Returns array (the record) if OK, otherwise blank/0 (zero)
470 */
471 function checkRecord($table,$uid,$checkPage=0) {
472 global $TCA;
473 $uid=intval($uid);
474 if (is_array($TCA[$table])) {
475 $query = 'SELECT * FROM '.$table.' WHERE uid='.intval($uid).$this->enableFields($table);
476 $res = mysql(TYPO3_db, $query);
477 if ($row = mysql_fetch_assoc($res)) {
478 if ($checkPage) {
479 $pid=$row['pid'];
480 $query='SELECT uid FROM pages WHERE uid='.intval($pid).$this->enableFields('pages');
481 $res = mysql(TYPO3_db, $query);
482 if (mysql_num_rows($res)) {
483 return $row;
484 } else {
485 return 0;
486 }
487 } else {
488 return $row;
489 }
490 }
491 }
492 }
493
494 /**
495 * Returns record no matter what - except if record is deleted
496 *
497 * @param string The table name to search
498 * @param integer The uid to look up in $table
499 * @param string The fields to select, default is "*"
500 * @return mixed Returns array (the record) if found, otherwise blank/0 (zero)
501 * @see getPage_noCheck()
502 */
503 function getRawRecord($table,$uid,$fields='*') {
504 global $TCA;
505 $uid=intval($uid);
506 if (is_array($TCA[$table])) {
507 $query = 'SELECT '.$fields.' FROM '.$table.' WHERE uid='.intval($uid).$this->deleteClause($table);
508 $res = mysql(TYPO3_db, $query);
509 if ($row = mysql_fetch_assoc($res)) {
510 return $row;
511 }
512 }
513 }
514
515 /**
516 * Selects records based on matching a field (ei. other than UID) with a value
517 *
518 * @param string The table name to search, eg. "pages" or "tt_content"
519 * @param string The fieldname to match, eg. "uid" or "alias"
520 * @param string The value that fieldname must match, eg. "123" or "frontpage"
521 * @param string Additional WHERE clauses put in the end of the query meaning that also LIMIT, ORDER BY and GROUP BY could be added. (Dont use LIMIT though since this may break portability to DBAL later)
522 * @return mixed Returns array (the record) if found, otherwise blank/0 (zero)
523 */
524 function getRecordsByField($theTable,$theField,$theValue,$endClause='') {
525 global $TCA;
526 if (is_array($TCA[$theTable])) {
527 $query = 'SELECT * FROM '.$theTable.' WHERE '.$theField.'="'.addslashes($theValue).'"'.$this->deleteClause($theTable).' '.$endClause;
528 $res = mysql(TYPO3_db, $query);
529 $rows=array();
530 while($row = mysql_fetch_assoc($res)) {
531 $rows[] = $row;
532 }
533 if (count($rows)) return $rows;
534 }
535 }
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550 /*********************************
551 *
552 * Caching and standard clauses
553 *
554 **********************************/
555
556 /**
557 * Returns string value stored for the hash string in the table "cache_hash"
558 * Can be used to retrieved a cached value
559 * Can be used from your frontend plugins if you like. Is also used to store the parsed TypoScript template structures. You can call it directly like t3lib_pageSelect::getHash()
560 *
561 * @param string The hash-string which was used to store the data value
562 * @param integer Allowed expiretime in seconds. Basically a record is selected only if it is not older than this value in seconds. If expTime is not set, the hashed value will never expire.
563 * @return string The "content" field of the "cache_hash" table row.
564 * @see tslib_TStemplate::start(), storeHash()
565 */
566 function getHash($hash,$expTime=0) {
567 //
568 $expTime = intval($expTime);
569 if ($expTime) {
570 $whereAdd = ' AND tstamp > '.(time()-$expTime);
571 }
572 $res = mysql (TYPO3_db, 'SELECT content FROM cache_hash WHERE hash="'.$hash.'"'.$whereAdd);
573 if ($row=mysql_fetch_assoc($res)) {
574 return $row['content'];
575 }
576 }
577
578 /**
579 * Stores a string value in the cache_hash table identified by $hash.
580 * Can be used from your frontend plugins if you like. You can call it directly like t3lib_pageSelect::storeHash()
581 *
582 * @param string 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)
583 * @param string The data string. If you want to store an array, then just serialize it first.
584 * @param string $ident is just a textual identification in order to inform about the content! May be 20 characters long.
585 * @return void
586 * @see tslib_TStemplate::start(), getHash()
587 */
588 function storeHash($hash,$data,$ident) {
589 $res = mysql (TYPO3_db, 'DELETE FROM cache_hash WHERE hash="'.$hash.'"');
590 $res = mysql (TYPO3_db, 'INSERT INTO cache_hash (hash, content, ident, tstamp) VALUES ("'.$hash.'","'.addSlashes($data).'","'.addSlashes($ident).'","'.time().'")');
591 }
592
593 /**
594 * Returns the "AND NOT deleted" clause for the tablename given IF $TCA configuration points to such a field.
595 *
596 * @param string Tablename
597 * @return string
598 * @see enableFields()
599 */
600 function deleteClause($table) {
601 global $TCA;
602 return $TCA[$table]['ctrl']['delete'] ? ' AND NOT '.$TCA[$table]['ctrl']['delete'] : '';
603 }
604
605 /**
606 * Returns a part of a WHERE clause which will filter out records with start/end times or hidden/fe_groups fields set to values that should de-select them according to the current time, preview settings or user login. Definitely a frontend function.
607 * Is using the $TCA arrays "ctrl" part where the key "enablefields" determines for each table which of these features applies to that table.
608 *
609 * @param string Table name found in the $TCA array
610 * @param integer If $show_hidden is set (0/1), any hidden-fields in records are ignored. NOTICE: If you call this function, consider what to do with the show_hidden parameter. Maybe it should be set? See tslib_cObj->enableFields where it's implemented correctly.
611 * @param array Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc.
612 * @return string The clause starting like " AND ...=... AND ...=..."
613 * @see tslib_cObj::enableFields(), deleteClause()
614 */
615 function enableFields($table,$show_hidden=-1,$ignore_array=array()) {
616 if ($show_hidden==-1 && is_object($GLOBALS['TSFE'])) { // If show_hidden was not set from outside and if TSFE is an object, set it based on showHiddenPage and showHiddenRecords from TSFE
617 $show_hidden = $table=='pages' ? $GLOBALS['TSFE']->showHiddenPage : $GLOBALS['TSFE']->showHiddenRecords;
618 }
619 if ($show_hidden==-1) $show_hidden=0; // If show_hidden was not changed during the previous evaluation, do it here.
620
621 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
622 $query='';
623 if (is_array($ctrl)) {
624 if ($ctrl['delete']) {
625 $query.=' AND NOT '.$table.'.'.$ctrl['delete'];
626 }
627 if (is_array($ctrl['enablecolumns'])) {
628 if ($ctrl['enablecolumns']['disabled'] && !$show_hidden && !$ignore_array['disabled']) {
629 $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
630 $query.=' AND NOT '.$field;
631 }
632 if ($ctrl['enablecolumns']['starttime'] && !$ignore_array['starttime']) {
633 $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
634 $query.=' AND ('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
635 }
636 if ($ctrl['enablecolumns']['endtime'] && !$ignore_array['endtime']) {
637 $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
638 $query.=' AND ('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
639 }
640 if ($ctrl['enablecolumns']['fe_group'] && !$ignore_array['fe_group']) {
641 $field = $table.'.'.$ctrl['enablecolumns']['fe_group'];
642 $gr_list = $GLOBALS['TSFE']->gr_list;
643 if (!strcmp($gr_list,'')) $gr_list=0;
644 $query.=' AND '.$field.' IN ('.$gr_list.')';
645 }
646 }
647 } else {
648 die ('NO entry in the $TCA-array for the table "'.$table.'". This means that the function enableFields() is called with an invalid table name as argument.');
649 }
650
651 return $query;
652 }
653 }
654
655
656
657 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_page.php']) {
658 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_page.php']);
659 }
660 ?>