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