dcc25a89b7921cb78d41fb26dc640bc429b9b668
2 /***************************************************************
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Standard functions available for the TYPO3 backend.
29 * You are encouraged to use this class in your own applications (Backend Modules)
31 * Call ALL methods without making an object!
32 * Eg. to get a page-record 51 do this: 't3lib_BEfunc::getRecord('pages',51)'
35 * Usage counts are based on search 22/2 2003 through whole backend source of typo3/
36 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
39 * @author Kasper Skaarhoj <kasper@typo3.com>
42 * [CLASS/FUNCTION INDEX of SCRIPT]
46 * 158: class t3lib_BEfunc
48 * SECTION: SQL-related, selecting records, searching
49 * 179: function deleteClause($table)
50 * 203: function getRecord($table,$uid,$fields='*',$where='')
51 * 228: function getRecordRaw($table,$where='',$fields='*')
52 * 249: function getRecordsByField($theTable,$theField,$theValue,$endClause='')
53 * 272: function searchQuery($searchWords,$fields)
54 * 294: function listQuery($field,$value)
55 * 309: function splitTable_Uid($str)
56 * 325: function getSQLselectableList ($in_list,$tablename,$default_tablename)
57 * 354: function BEenableFields($table,$inv=0)
58 * 398: function mm_query($select,$local_table,$mm_table,$foreign_table,$endClause='')
59 * 415: function DBcompileInsert($table,$fields_values,$slash=1)
60 * 434: function DBcompileUpdate($table,$where,$fields_values,$slash=1)
62 * SECTION: Page tree, TCA related
63 * 473: function BEgetRootLine ($uid,$clause='')
64 * 520: function getRecordPath($uid,$clause,$titleLimit)
65 * 547: function getExcludeFields()
66 * 580: function readPageAccess($id,$perms_clause)
67 * 610: function getTCAtypes($table,$rec,$useFieldNameAsKey=0)
68 * 656: function getTCAtypeValue($table,$rec)
69 * 679: function getSpecConfParts($str)
70 * 704: function getSpecConfParametersFromArray($pArr)
71 * 729: function getFlexFormDS($conf,$row,$table)
73 * SECTION: Caching related
74 * 833: function storeHash($hash,$data,$ident)
75 * 849: function getHash($hash,$expTime)
77 * SECTION: TypoScript related
78 * 886: function getPagesTSconfig($id,$rootLine='',$returnPartArray=0)
79 * 937: function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='')
80 * 992: function implodeTSParams($p,$k='')
82 * SECTION: Users / Groups related
83 * 1030: function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='')
84 * 1050: function getGroupNames($fields='title,uid',$where='')
85 * 1069: function getListGroupNames($fields='title,uid')
86 * 1089: function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0)
87 * 1123: function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0)
89 * SECTION: Output related
90 * 1167: function daysUntil($tstamp)
91 * 1180: function date($tstamp)
92 * 1192: function datetime($value)
93 * 1205: function time($value)
94 * 1222: function calcAge ($seconds,$labels)
95 * 1249: function dateTimeAge($tstamp,$prefix=1,$date='')
96 * 1268: function titleAttrib($content='',$hsc=0)
97 * 1280: function titleAltAttrib($content)
98 * 1305: function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir='',$abs=0,$tparams='',$size='')
99 * 1374: function getThumbNail($thumbScript,$theFile,$tparams='',$size='')
100 * 1392: function titleAttribForPages ($row,$perms_clause='',$includeAttrib=1)
101 * 1447: function getRecordIconAltText($row,$table='pages')
102 * 1482: function getLabelFromItemlist($table,$col,$key)
103 * 1509: function getItemLabel($table,$col,$printAllWrap='')
104 * 1535: function getRecordTitle($table,$row,$prep=0)
105 * 1571: function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0)
106 * 1666: function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0)
107 * 1691: function getFileIcon($ext)
108 * 1706: function getCommonSelectFields($table,$prefix)
109 * 1733: function makeConfigForm($configArray,$defaults,$dataPrefix)
111 * SECTION: Backend Modules API functions
112 * 1810: function helpTextIcon($table,$field,$BACK_PATH,$force=0)
113 * 1832: function helpText($table,$field,$BACK_PATH)
114 * 1853: function editOnClick($params,$backPath='',$requestUri='')
115 * 1870: function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='')
116 * 1897: function getModTSconfig($id,$TSref)
117 * 1919: function getFuncMenu($id,$elementName,$currentValue,$menuItems,$script='',$addparams='')
118 * 1949: function getFuncCheck($id,$elementName,$currentValue,$script='',$addparams='',$tagParams='')
119 * 1970: function getFuncInput($id,$elementName,$currentValue,$size=10,$script="",$addparams="")
120 * 1987: function unsetMenuItems($modTSconfig,$itemArray,$TSref)
121 * 2011: function getSetUpdateSignal($set='')
122 * 2061: function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
125 * 2138: function lockRecords($table='',$uid=0,$pid=0)
126 * 2169: function isRecordLocked($table,$uid)
127 * 2208: function foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='')
128 * 2261: function getTCEFORM_TSconfig($table,$row)
129 * 2309: function getTSconfig_pidValue($table,$uid,$pid)
130 * 2338: function getPidForModTSconfig($table,$uid,$pid)
131 * 2355: function getTSCpid($table,$uid,$pid)
132 * 2372: function firstDomainRecord($rootLine)
133 * 2395: function getDomainStartPage($domain, $path='')
134 * 2428: function RTEsetup($RTEprop,$table,$field,$type='')
135 * 2449: function isModuleSetInTBE_MODULES($modName)
137 * SECTION: Miscellaneous
138 * 2499: function typo3PrintError ($header,$text,$js='',$head=1)
139 * 2546: function getPathType_web_nonweb($path)
140 * 2559: function ADMCMD_previewCmds($pageinfo)
141 * 2582: function processParams($params)
142 * 2609: function getListOfBackendModules($name,$perms_clause,$backPath='',$script='index.php')
144 * TOTAL FUNCTIONS: 78
145 * (This index is automatically created/updated by the extension "extdeveval")
151 * Standard functions available for the TYPO3 backend.
152 * Don't instantiate - call functions with "t3lib_BEfunc::" prefixed the function name.
154 * @author Kasper Skaarhoj <kasper@typo3.com>
162 /*******************************************
164 * SQL-related, selecting records, searching
166 *******************************************/
170 * Returns the WHERE clause " AND NOT [tablename].[deleted-field]" if a deleted-field is configured in $TCA for the tablename, $table
171 * This function should ALWAYS be called in the backend for selection on tables which are configured in TCA since it will ensure consistent selection of records, even if they are marked deleted (in which case the system must always treat them as non-existent!)
172 * In the frontend a function, ->enableFields(), is known to filter hidden-field, start- and endtime and fe_groups as well. But that is a job of the frontend, not the backend. If you need filtering on those fields as well in the backend you can use ->BEenableFields() though.
176 * @param string Table name present in $TCA
177 * @return string WHERE clause for filtering out deleted records, eg " AND NOT tablename.deleted"
179 function deleteClause($table) {
181 if ($TCA[$table]['ctrl']['delete']) {
182 return ' AND NOT '.$table.'.'.$TCA[$table]['ctrl']['delete'];
189 * Gets record with uid=$uid from $table
190 * You can set $field to a list of fields (default is '*')
191 * Additional WHERE clauses can be added by $where (fx. ' AND blabla=1')
192 * Will automatically check if records has been deleted and if so, not return anything.
193 * $table must be found in $TCA
197 * @param string Table name present in $TCA
198 * @param integer UID of record
199 * @param string List of fields to select
200 * @param string Additional WHERE clause, eg. " AND blablabla=0"
201 * @return array Returns the row if found, otherwise nothing
203 function getRecord($table,$uid,$fields='*',$where='') {
204 if ($GLOBALS['TCA'][$table]) {
205 $del=t3lib_BEfunc
::deleteClause($table);
206 $query='SELECT '.$fields.' FROM '.$table.' WHERE uid='.intval($uid).$del.$where;
207 $res = mysql(TYPO3_db
, $query);
208 if ($row = mysql_fetch_assoc($res)) {
215 * Returns the first record found from $table with $where as WHERE clause
216 * This function does NOT check if a record has the deleted flag set.
217 * $table does NOT need to be configured in $TCA
218 * The query used is simply this:
219 * $query='SELECT '.$fields.' FROM '.$table.' WHERE '.$where;
221 * Usage: 5 (ext: sys_todos)
223 * @param string Table name (not necessarily in TCA)
224 * @param string WHERE clause
225 * @param string $fields is a list of fields to select, default is '*'
226 * @return array First row found, if any
228 function getRecordRaw($table,$where='',$fields='*') {
229 $query='SELECT '.$fields.' FROM '.$table.' WHERE '.$where;
230 $res = mysql(TYPO3_db
, $query);
231 if ($row = mysql_fetch_assoc($res)) {
237 * Returns records from table, $theTable, where a field ($theField) equals the value, $theValue
238 * The records are returned in an array
239 * If no records were selected, the function returns nothing
243 * @param string Table name present in $TCA
244 * @param string Field to select on
245 * @param string Value that $theField must match
246 * @param string $endClause is a string prepended to the SQL-statement. Can be additional where clauses, a "LIMIT" clause or whatever.
247 * @return array Multidimensional array with selected records
249 function getRecordsByField($theTable,$theField,$theValue,$endClause='') {
251 if (is_array($TCA[$theTable])) {
252 $del=t3lib_BEfunc
::deleteClause($theTable);
253 $query = 'SELECT * FROM '.$theTable.' WHERE '.$theField.'="'.addslashes($theValue).'"'.$del.' '.$endClause;
254 $res = mysql(TYPO3_db
, $query);
256 while($row = mysql_fetch_assoc($res)) {
259 if (count($rows)) return $rows;
264 * Returns a WHERE clause which will make an AND search for the words in the $searchWords array in any of the fields in array $fields.
266 * Usage: 1 (class t3lib_fullsearch)
268 * @param array Array of search words
269 * @param array Array of fields
270 * @return string WHERE clause for search
272 function searchQuery($searchWords,$fields) {
275 while(list(,$sw)=each($searchWords)) {
276 $like=' LIKE "%'.addslashes($sw).'%"';
277 $queryParts[] = implode($like.' OR ',$fields).$like;
279 $query = '('.implode(') AND (',$queryParts).')';
284 * Returns a WHERE clause that can find a value ($value) in a list field ($field)
285 * For instance a record in the database might contain a list of numbers, "34,234,5" (with no spaces between). This query would be able to select that record based on the value "34", "234" or "5" regardless of their positioni in the list (left, middle or right).
286 * Is nice to look up list-relations to records or files in TYPO3 database tables.
290 * @param string Table field name
291 * @param string Value to find in list
292 * @return string WHERE clause for a query
294 function listQuery($field,$value) {
295 $command=addslashes($value);
296 $where='('.$field.' LIKE "%,'.$command.',%" OR '.$field.' LIKE "'.$command.',%" OR '.$field.' LIKE "%,'.$command.'" OR '.$field.'="'.$command.'")';
301 * Makes an backwards explode on the $str and returns an array with ($table,$uid).
302 * Example: tt_content_45 => array('tt_content',45)
309 function splitTable_Uid($str) {
310 list($uid,$table)=explode('_',strrev($str),2);
311 return array(strrev($table),strrev($uid));
315 * Returns a list of pure integers based on $in_list being a list of records with table-names prepended.
316 * Ex: $in_list = "pages_4,tt_content_12,45" would result in a return value of "4,45" if $tablename is "pages" and $default_tablename is 'pages' as well.
318 * Usage: 1 (t3lib_userauthgroup)
320 * @param string Input list
321 * @param string Table name from which ids is returned
322 * @param string $default_tablename denotes what table the number '45' is from (if nothing is prepended on the value)
323 * @return string List of ids
325 function getSQLselectableList ($in_list,$tablename,$default_tablename) {
327 if ((string)trim($in_list)!='') {
328 $tempItemArray = explode(',',trim($in_list));
329 while(list($key,$val)=each($tempItemArray)) {
331 $parts = explode('_',$val,2);
332 if ((string)trim($parts[0])!='') {
333 $theID = intval(strrev($parts[0]));
334 $theTable = trim($parts[1]) ?
strrev(trim($parts[1])) : $default_tablename;
335 if ($theTable==$tablename) {$list[]=$theID;}
339 return implode(',',$list);
343 * Backend implementation of enableFields()
344 * Notice that "fe_groups" is not selected for - only disabled, starttime and endtime.
345 * Notice that deleted-fields are NOT filtered - you must ALSO call deleteClause in addition.
346 * $GLOBALS["SIM_EXEC_TIME"] is used for date.
350 * @param string $table is the table from which to return enableFields WHERE clause. Table name must have a 'ctrl' section in $TCA.
351 * @param boolean $inv means that the query will select all records NOT VISIBLE records (inverted selection)
352 * @return string WHERE clause part
354 function BEenableFields($table,$inv=0) {
355 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
358 if (is_array($ctrl)) {
359 if (is_array($ctrl['enablecolumns'])) {
360 if ($ctrl['enablecolumns']['disabled']) {
361 $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
362 $query[]='NOT '.$field;
365 if ($ctrl['enablecolumns']['starttime']) {
366 $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
367 $query[]='('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
368 $invQuery[]='('.$field.'!=0 AND '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
370 if ($ctrl['enablecolumns']['endtime']) {
371 $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
372 $query[]='('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
373 $invQuery[]='('.$field.'!=0 AND '.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
377 $outQ = ' AND '.($inv ?
'('.implode(' OR ',$invQuery).')' : implode(' AND ',$query));
383 * Returns a SELECT query, selecting fields ($select) from two/three tables joined
384 * $local_table and $mm_table is mandatory. $foreign_table is optional.
385 * The JOIN is done with [$local_table].uid <--> [$mm_table].uid_local / [$mm_table].uid_foreign <--> [$foreign_table].uid
386 * $endClause is additional WHERE clauses / LIMIT / GROUP / ORDER BY
387 * The function is very useful for selecting MM-relations between tables adhering to the MM-format used by TCE (TYPO3 Core Engine). See the section on $TCA in Inside TYPO3 for more details.
389 * Usage: 12 (spec. ext. sys_action, sys_messages, sys_todos)
391 * @param string Field list for SELECT
392 * @param string Tablename, local table
393 * @param string Tablename, relation table
394 * @param string Tablename, foreign table
395 * @param string Additional WHERE clause
396 * @return string Full SQL query
398 function mm_query($select,$local_table,$mm_table,$foreign_table,$endClause='') {
399 $query = 'SELECT '.$select.'
400 FROM '.$local_table.','.$mm_table.($foreign_table?
','.$foreign_table:'').'
401 WHERE '.$local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?
' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign ':' ').$endClause;
406 * Creates an INSERT SQL-statement for $table from the array with field/value pairs $fields_values.
410 * @param string Table name
411 * @param array Field values as key=>value pairs.
412 * @param boolean Set $slash=1 if values should be addslashes()'ed (default)
413 * @return string Full SQL query for INSERT
415 function DBcompileInsert($table,$fields_values,$slash=1) {
416 if (is_array($fields_values)) {
417 if ($slash) {$fields_values = t3lib_div
::slashArray($fields_values, 'add');}
418 $query = 'INSERT INTO '.$table.' ('.implode(',',array_keys($fields_values)).') VALUES ("'.implode('","',$fields_values).'")';
424 * Creates an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values.
428 * @param string Tablename
429 * @param string WHERE clause, eg. "uid=1"
430 * @param array Field values as key=>value pairs.
431 * @param boolean Set $slash=1 if values should be addslashes()'ed (default)
432 * @return string Full SQL query for UPDATE
434 function DBcompileUpdate($table,$where,$fields_values,$slash=1) {
435 if (is_array($fields_values)) {
436 if ($slash) {$fields_values = t3lib_div
::slashArray($fields_values, 'add');}
438 reset($fields_values);
439 while(list($k,$v)=each($fields_values)) {
440 $nArr[]=$k.'="'.$v.'"';
442 $query = 'UPDATE '.$table.' SET '.implode(',',$nArr).' WHERE '.$where;
456 /*******************************************
458 * Page tree, TCA related
460 *******************************************/
463 * Returns what is called the 'RootLine'. That is an array with information about the page records from a page id ($uid) and back to the root.
464 * By default deleted pages are filtered.
465 * This RootLine will follow the tree all the way to the root. This is opposite to another kind of root line known from the frontend where the rootline stops when a root-template is found.
469 * @param integer Page id
470 * @param string $clause can be used to select other criteria. It would typically be where-clauses that stops the proces if we meet a page, the user has no reading access to.
471 * @return array Root line array, all the way to the page tree root (or as far as $clause allows!)
473 function BEgetRootLine ($uid,$clause='') {
475 $theRowArray = Array();
477 while ($uid!=0 && $loopCheck>0) {
479 $query = 'SELECT pid,uid,title,TSconfig,is_siteroot,storage_pid from pages WHERE uid='.intval($uid).' '.t3lib_BEfunc
::deleteClause('pages').' '.$clause;
480 $res = mysql(TYPO3_db
, $query);
483 debug(mysql_error(),1);
485 if ($row = mysql_fetch_assoc($res)) {
492 if ($uid==0) {$theRowArray[]=Array('uid'=>0,'title'=>'');}
493 if (is_array($theRowArray)) {
495 $c=count($theRowArray);
496 while(list($key,$val)=each($theRowArray)) {
498 $output[$c]['uid']=$val['uid'];
499 $output[$c]['title']=$val['title'];
500 $output[$c]['TSconfig']=$val['TSconfig'];
501 $output[$c]['is_siteroot']=$val['is_siteroot'];
502 $output[$c]['storage_pid']=$val['storage_pid'];
509 * Returns the path (visually) of a page $uid, fx. "/First page/Second page/Another subpage"
510 * Each part of the path will be limited to $titleLimit characters
511 * Deleted pages are filtered out.
515 * @param integer Page uid
516 * @param string $clause is additional where clauses, eg. "
517 * @param integer Title limit
518 * @return string Path of record
520 function getRecordPath($uid,$clause,$titleLimit) {
521 if (!$titleLimit) {$titleLimit=1000;}
524 while ($uid!=0 && $loopCheck>0) {
526 $query='SELECT pid, title FROM pages WHERE uid='.intval($uid).t3lib_BEfunc
::deleteClause('pages').' AND '.$clause;
527 $res = mysql(TYPO3_db
, $query);
529 if ($row = mysql_fetch_assoc($res)) {
531 $output='/'.t3lib_div
::fixed_lgd(strip_tags($row['title']),$titleLimit).$output;
540 * Returns an array with the exclude-fields as defined in TCA
541 * Used for listing the exclude-fields in be_groups forms
543 * Usage: 2 (t3lib_tceforms + t3lib_transferdata)
545 * @return array Array of arrays with excludeFields (fieldname, table:fieldname) from all TCA entries
547 function getExcludeFields() {
550 $tc_keys = array_keys($TCA);
551 $theExcludeArray = Array();
552 while (list(,$table)=each($tc_keys)) {
554 t3lib_div
::loadTCA($table);
555 // All field names configured:
556 $f_keys = array_keys($TCA[$table]['columns']);
557 while (list(,$field)=each($f_keys)) {
558 if ($TCA[$table]['columns'][$field]['exclude']) {
559 // Get Human Readable names of fields and table:
560 $Fname=$GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
562 $theExcludeArray[] = Array($Fname , $table.':'.$field);
566 return $theExcludeArray;
570 * Returns a page record (of page with $id) with an extra field "_thePath" set to the record path IF the WHERE clause, $perms_clause, selects the record.
571 * If $id is zero a pseudo root-page with "_thePath" set is returned IF the current BE_USER is admin.
572 * In any case ->isInWebMount must return true for the user (regardless of $perms_clause)
576 * @param integer Page uid
577 * @param string $perms_clause is typically a value generated with $BE_USER->getPagePermsClause(1);
578 * @return array Returns page record if OK, otherwise false.
580 function readPageAccess($id,$perms_clause) {
581 if ((string)$id!='') {
584 if ($GLOBALS['BE_USER']->isAdmin()) {
586 $pageinfo['_thePath']=$path;
590 $pageinfo = t3lib_BEfunc
::getRecord('pages',$id,'*',($perms_clause?
' AND '.$perms_clause:''));
591 if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause)) {
592 $pageinfo['_thePath']=t3lib_BEfunc
::getRecordPath (intval($pageinfo['uid']),$perms_clause,15);
601 * Returns the "types" configuration parsed into an array for the record, $rec, from table, $table
605 * @param string Table name (present in TCA)
606 * @param array Record from $table
607 * @param boolean If $useFieldNameAsKey is set, then the fieldname is associative keys in the return array, otherwise just numeric keys.
610 function getTCAtypes($table,$rec,$useFieldNameAsKey=0) {
613 t3lib_div
::loadTCA($table);
616 $fieldValue = t3lib_BEfunc
::getTCAtypeValue($table,$rec);
619 $typesConf = $TCA[$table]['types'][$fieldValue];
621 // Get fields list and traverse it
622 $fieldList = explode(',',$typesConf['showitem']);
623 $altFieldList=array();
625 while(list($k,$v)=each($fieldList)) {
626 $vParts=explode(';',$v);
627 $specConfParts = t3lib_BEfunc
::getSpecConfParts($vParts[3]);
628 $fieldList[$k]=array(
629 'field'=>trim($vParts[0]),
630 'title'=>trim($vParts[1]),
631 'palette'=>trim($vParts[2]),
632 'spec'=>$specConfParts,
635 if ($useFieldNameAsKey) {
636 $altFieldList[$fieldList[$k]['field']]=$fieldList[$k];
639 if ($useFieldNameAsKey) $fieldList=$altFieldList;
645 * Returns the "type" value of $rec from $table which can be used to look up the correct "types" rendering section in $TCA
646 * If no "type" field is configured in the "ctrl"-section of the $TCA for the table, zero is used.
647 * If zero is not an index in the "types" section of $TCA for the table, then the $fieldValue returned will default to 1 (no matter if that is an index or not)
651 * @param string Table name present in TCA
652 * @param array Record from $table
653 * @return string Field value
656 function getTCAtypeValue($table,$rec) {
659 // If no field-value, set it to zero. If there is no type matching the field-value (which now may be zero...) test field-value '1' as default.
660 t3lib_div
::loadTCA($table);
662 $field=$TCA[$table]['ctrl']['type'];
663 $fieldValue = $field?
($rec[$field]?
$rec[$field]:0):0;
664 if (!is_array($TCA[$table]['types'][$fieldValue])) $fieldValue=1;
670 * Parses a part of the field lists in the "types"-section of $TCA arrays, namely the "special configuration" at index 3 (position 4)
671 * Elements are splitted by ":" and within those parts, parameters are splitted by "|".
672 * Everything is returned in an array and you should rather see it visually than listen to me anymore now... Check out example in Inside TYPO3
679 function getSpecConfParts($str) {
681 $specConfParts=explode(':',$str);
682 reset($specConfParts);
683 while(list($k2,$v2)=each($specConfParts)) {
684 if (ereg('(.*)\[(.*)\]',$v2,$reg)) {
685 unset($specConfParts[$k2]);
686 $specConfParts[$reg[1]]=array(
687 'parameters'=>explode('|',$reg[2])
691 } else {$specConfParts=array();}
692 return $specConfParts;
696 * Takes an array of "[key]=[value]" strings and returns an array with the keys set as keys pointing to the value.
697 * Better see it in action! Find example in Inside TYPO3
704 function getSpecConfParametersFromArray($pArr) {
706 if (is_array($pArr)) {
708 while(list($k,$v)=each($pArr)) {
709 $parts=explode('=',$v,2);
710 if (count($parts)==2) {
711 $out[trim($parts[0])]=trim($parts[1]);
721 * Finds the Data Structure for a FlexForm field
723 * @param array Field config array
724 * @param array Record data
725 * @param string The table name
726 * @return mixed If array, the data structure was found and returned as an array. Otherwise (string) it is an error message.
727 * @see t3lib_TCEforms::getSingleField_typeFlex()
729 function getFlexFormDS($conf,$row,$table) {
731 // Get pointer field etc from TCA-config:
732 $ds_pointerField = $conf['ds_pointerField'];
733 $ds_array = $conf['ds'];
734 $ds_tableField = $conf['ds_tableField'];
735 $ds_searchParentField = $conf['ds_pointerField_searchParent'];
738 // Find source value:
740 if (is_array($ds_array)) { // If there is a data source array, that takes precedence
741 // If a pointer field is set, take the value from that field in the $row array and use as key.
742 if ($ds_pointerField) {
743 $srcPointer = $row[$ds_pointerField];
744 $srcPointer = isset($ds_array[$srcPointer]) ?
$srcPointer : 'default';
745 } else $srcPointer='default';
747 // Get Data Source: Detect if it's a file reference and in that case read the file and parse as XML. Otherwise the value is expected to be XML.
748 if (substr($ds_array[$srcPointer],0,5)=='FILE:') {
749 $file = t3lib_div
::getFileAbsFileName(substr($ds_array[$srcPointer],5));
750 if ($file && @is_file
($file)) {
751 $dataStructArray = t3lib_div
::xml2array(t3lib_div
::getUrl($file));
752 } else $dataStructArray = 'The file "'.substr($dsSrc,5).'" in ds-array key "'.$srcPointer.'" was not found ("'.$file.'")'; // Error message.
754 $dataStructArray = t3lib_div
::xml2array($ds_array[$srcPointer]);
757 } elseif ($ds_pointerField) { // If pointer field AND possibly a table/field is set:
758 // Value of field pointed to:
759 $srcPointer = $row[$ds_pointerField];
761 // Searching recursively back if 'ds_pointerField_searchParent' is defined (typ. a page rootline, or maybe a tree-table):
762 if ($ds_searchParentField && !$srcPointer) {
763 $rr = t3lib_BEfunc
::getRecord($table,$row['uid'],$ds_searchParentField); // Get the "pid" field - we cannot know that it is in the input record!
764 $uidAcc=array(); // Used to avoid looping, if any should happen.
765 $subFieldPointer = $conf['ds_pointerField_searchParent_subField'];
766 while(!$srcPointer) {
767 $query = 'SELECT uid,'.$ds_pointerField.','.$ds_searchParentField.($subFieldPointer?
','.$subFieldPointer:'').'
768 FROM '.$table.' WHERE uid='.intval($rr[$ds_searchParentField]).
769 t3lib_BEfunc
::deleteClause($table);
770 $res = mysql(TYPO3_db
,$query);
771 $rr = mysql_fetch_assoc($res);
772 if (!is_array($rr) ||
isset($uidAcc[$rr['uid']])) break; // break if no result from MySQL or if looping...
773 $uidAcc[$rr['uid']]=1;
775 $srcPointer = ($subFieldPointer && $rr[$subFieldPointer]) ?
$rr[$subFieldPointer] : $rr[$ds_pointerField];
779 // If there is a srcPointer value:
781 if (t3lib_div
::testInt($srcPointer)) { // If integer, then its a record we will look up:
782 list($tName,$fName) = explode(':',$ds_tableField,2);
783 if ($tName && $fName && is_array($GLOBALS['TCA'][$tName])) {
784 $dataStructRec = t3lib_BEfunc
::getRecord($tName, $srcPointer);
785 $dataStructArray = t3lib_div
::xml2array($dataStructRec[$fName]);
786 } else $dataStructArray = 'No tablename ('.$tName.') or fieldname ('.$fName.') was found an valid!';
787 } else { // Otherwise expect it to be a file:
788 $file = t3lib_div
::getFileAbsFileName($srcPointer);
789 if ($file && @is_file
($file)) {
790 $dataStructArray = t3lib_div
::xml2array(t3lib_div
::getUrl($file));
791 } else $dataStructArray='The file "'.$srcPointer.'" was not found ("'.$file.'")'; // Error message.
793 } else $dataStructArray='No source value in fieldname "'.$ds_pointerField.'"'; // Error message.
794 } else $dataStructArray='No proper configuration!';
796 return $dataStructArray;
816 /*******************************************
820 *******************************************/
823 * Stores the string value $data in the 'cache_hash' table with the hash key, $hash, and visual/symbolic identification, $ident
824 * IDENTICAL to the function by same name found in t3lib_page:
828 * @param string Hash key, 32 bytes hex
829 * @param string $data must be serialized before function call
830 * @param string Visual/symbolic identification (informational only)
833 function storeHash($hash,$data,$ident) {
834 // $ident is just a textual identification in order to inform about the content! May be 20 characters long.
835 $res = mysql (TYPO3_db
, 'DELETE FROM cache_hash WHERE hash = "'.$hash.'"');
836 $res = mysql (TYPO3_db
, 'INSERT INTO cache_hash (hash, content, ident, tstamp) VALUES ("'.$hash.'","'.addSlashes($data).'","'.addSlashes($ident).'","'.time().'")');
840 * Retrieves the string content stored with hash key, $hash, in cache_hash
841 * IDENTICAL to the function by same name found in t3lib_page:
845 * @param string Hash key, 32 bytes hex
846 * @param integer $expTime represents the expire time in seconds. For instance a value of 3600 would allow cached content within the last hour, otherwise nothing is returned.
849 function getHash($hash,$expTime) {
850 // if expTime is not set, the hash will never expire
851 $expTime = intval($expTime);
853 $whereAdd = ' AND tstamp > '.(time()-$expTime);
855 $res = mysql (TYPO3_db
, 'SELECT content FROM cache_hash WHERE hash = "'.$hash.'"'.$whereAdd);
856 if ($row=mysql_fetch_assoc($res)) {
857 return $row['content'];
868 /*******************************************
872 *******************************************/
875 * Returns the Page TSconfig for page with id, $id
876 * Requires class "t3lib_TSparser"
878 * Usage: 26 (spec. in ext info_pagetsconfig)
880 * @param integer Page uid
881 * @param array If $rootLine is an array, that is used as rootline, otherwise rootline is just calculated
882 * @param boolean If $returnPartArray is set, then the array with accumulated Page TSconfig is returned non-parsed. Otherwise the output will be parsed by the TypoScript parser.
883 * @return array Page TSconfig
884 * @see t3lib_TSparser
886 function getPagesTSconfig($id,$rootLine='',$returnPartArray=0) {
888 if (!is_array($rootLine)) {
889 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,'');
891 ksort($rootLine); // Order correctly, changed 030102
893 $TSdataArray = array();
894 $TSdataArray['defaultPageTSconfig']=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']; // Setting default configuration:
895 while(list($k,$v)=each($rootLine)) {
896 $TSdataArray['uid_'.$v['uid']]=$v['TSconfig'];
898 $TSdataArray = t3lib_TSparser
::checkIncludeLines_array($TSdataArray);
899 if ($returnPartArray) {
903 // Parsing the user TS (or getting from cache)
904 $userTS = implode($TSdataArray,chr(10).'[GLOBAL]'.chr(10));
905 $hash = md5('pageTS:'.$userTS);
906 $cachedContent = t3lib_BEfunc
::getHash($hash,0);
908 if (isset($cachedContent)) {
909 $TSconfig = unserialize($cachedContent);
911 $parseObj = t3lib_div
::makeInstance('t3lib_TSparser');
912 $parseObj->parse($userTS);
913 $TSconfig = $parseObj->setup
;
914 t3lib_BEfunc
::storeHash($hash,serialize($TSconfig),'PAGES_TSconfig');
920 * Updates Page TSconfig for a page with $id
921 * The function seems to take $pageTS as an array with properties and compare the values with those that already exists for the "object string", $TSconfPrefix, for the page, then sets those values which were not present.
922 * $impParams can be supplied as already known Page TSconfig, otherwise it's calculated.
924 * THIS DOES NOT CHECK ANY PERMISSIONS. SHOULD IT?
925 * More documentation is needed.
927 * Usage: 1 (ext. direct_mail)
929 * @param integer Page id
930 * @param array Page TS array to write
931 * @param string Prefix
935 * @see implodeTSParams(), getPagesTSconfig()
937 function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='') {
939 if (is_array($pageTS) && $id>0) {
940 if (!is_array($impParams)) {
941 $impParams =t3lib_BEfunc
::implodeTSParams(t3lib_BEfunc
::getPagesTSconfig($id));
945 while(list($f,$v)=each($pageTS)) {
946 $f = $TSconfPrefix.$f;
947 if ((!isset($impParams[$f])&&trim($v)) ||
strcmp(trim($impParams[$f]),trim($v))) {
952 // Get page record and TS config lines
953 $pRec = t3lib_befunc
::getRecord('pages',$id);
954 $TSlines = explode(chr(10),$pRec['TSconfig']);
955 $TSlines = array_reverse($TSlines);
956 // Reset the set of changes.
958 while(list($f,$v)=each($set)) {
961 while(list($ki,$kv)=each($TSlines)) {
962 if (substr($kv,0,strlen($f)+
1)==$f.'=') {
963 $TSlines[$ki]=$f.'='.$v;
969 $TSlines = array_reverse($TSlines);
970 $TSlines[]=$f.'='.$v;
971 $TSlines = array_reverse($TSlines);
974 $TSlines = array_reverse($TSlines);
975 // store those changes
976 $TSconf = implode(chr(10),$TSlines);
977 $q=t3lib_befunc
::DBcompileUpdate('pages','uid='.$id,array('TSconfig'=>$TSconf));
978 $res=mysql(TYPO3_db
,$q);
984 * Implodes a multi dimensional TypoScript array, $p, into a one-dimentional array (return value)
988 * @param array TypoScript structure
990 * @return array Imploded TypoScript objectstring/values
992 function implodeTSParams($p,$k='') {
993 $implodeParams=array();
996 while(list($kb,$val)=each($p)) {
997 if (is_array($val)) {
998 $implodeParams = array_merge($implodeParams,t3lib_BEfunc
::implodeTSParams($val,$k.$kb));
1000 $implodeParams[$k.$kb]=$val;
1004 return $implodeParams;
1014 /*******************************************
1016 * Users / Groups related
1018 *******************************************/
1021 * Returns an array with be_users records of all user NOT DELETED sorted by their username
1022 * Keys in the array is the be_users uid
1024 * Usage: 14 (spec. ext. "beuser" and module "web_perm")
1026 * @param string Optional $fields list (default: username,usergroup,usergroup_cached_list,uid) can be used to set the selected fields
1027 * @param string Optional $where clause (fx. "AND username='pete'") can be used to limit query
1030 function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='') {
1031 $be_user_Array=Array();
1032 $query = 'SELECT '.$fields.' FROM be_users WHERE pid=0 '.$where.t3lib_BEfunc
::deleteClause('be_users').' ORDER BY username';
1033 $res = mysql(TYPO3_db
,$query);
1035 while($row=mysql_fetch_assoc($res)) {
1036 $be_user_Array[$row['uid']]=$row;
1038 return $be_user_Array;
1042 * Returns an array with be_groups records (title, uid) of all groups NOT DELETED sorted by their title
1044 * Usage: 8 (spec. ext. "beuser" and module "web_perm")
1046 * @param string Field list
1047 * @param string WHERE clause
1050 function getGroupNames($fields='title,uid',$where='') {
1051 $be_group_Array=Array();
1052 $query = 'SELECT title,uid FROM be_groups WHERE pid=0 '.$where.t3lib_BEfunc
::deleteClause('be_groups').' ORDER BY title';
1053 $res = mysql(TYPO3_db
,$query);
1054 while($row=mysql_fetch_assoc($res)) {
1055 $be_group_Array[$row['uid']]=$row;
1057 return $be_group_Array;
1061 * Returns an array with be_groups records (like ->getGroupNames) but:
1062 * - if the current BE_USER is admin, then all groups are returned, otherwise only groups that the current user is member of (usergroup_cached_list) will be returned.
1064 * Usage: 2 (module "web_perm" and ext. taskcenter)
1066 * @param string Field list; $fields specify the fields selected (default: title,uid)
1069 function getListGroupNames($fields='title,uid') {
1070 $exQ=' AND hide_in_lists=0';
1071 if (!$GLOBALS['BE_USER']->isAdmin()) {
1072 $exQ.=' AND uid IN ('.($GLOBALS['BE_USER']->user
['usergroup_cached_list']?
$GLOBALS['BE_USER']->user
['usergroup_cached_list']:0).')';
1074 return t3lib_BEfunc
::getGroupNames($fields,$exQ);
1078 * Returns the array $usernames with the names of all users NOT IN $groupArray changed to the uid (hides the usernames!).
1079 * If $excludeBlindedFlag is set, then these records are unset from the array $usernames
1080 * Takes $usernames (array made by t3lib_BEfunc::getUserNames()) and a $groupArray (array with the groups a certain user is member of) as input
1084 * @param array User names
1085 * @param array Group names
1086 * @param boolean If $excludeBlindedFlag is set, then these records are unset from the array $usernames
1087 * @return array User names, blinded
1089 function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0) {
1090 if (is_array($usernames) && is_array($groupArray)) {
1091 while(list($uid,$row)=each($usernames)) {
1094 if ($row['uid']!=$GLOBALS['BE_USER']->user
['uid']) {
1096 while(list(,$v)=each($groupArray)) {
1097 if ($v && t3lib_div
::inList($row['usergroup_cached_list'],$v)) {
1098 $userN = $row['username'];
1103 $userN = $row['username'];
1106 $usernames[$uid]['username']=$userN;
1107 if ($excludeBlindedFlag && !$set) {unset($usernames[$uid]);}
1114 * Corresponds to blindUserNames but works for groups instead
1116 * Usage: 2 (module web_perm)
1123 function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0) {
1124 if (is_array($groups) && is_array($groupArray)) {
1125 while(list($uid,$row)=each($groups)) {
1128 if (t3lib_div
::inArray($groupArray,$uid)) {
1129 $groupN=$row['title'];
1132 $groups[$uid]['title']=$groupN;
1133 if ($excludeBlindedFlag && !$set) {unset($groups[$uid]);}
1151 /*******************************************
1155 *******************************************/
1160 * Returns the difference in days between input $tstamp and $EXEC_TIME
1162 * Usage: 2 (class t3lib_BEfunc)
1164 * @param integer Time stamp, seconds
1167 function daysUntil($tstamp) {
1168 $delta_t = $tstamp-$GLOBALS['EXEC_TIME'];
1169 return ceil($delta_t/(3600*24));
1173 * Returns $tstamp formatted as "ddmmyy" (According to $TYPO3_CONF_VARS['SYS']['ddmmyy'])
1177 * @param integer Time stamp, seconds
1178 * @return string Formatted time
1180 function date($tstamp) {
1181 return Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp);
1185 * Returns $tstamp formatted as "ddmmyy hhmm" (According to $TYPO3_CONF_VARS['SYS']['ddmmyy'] AND $TYPO3_CONF_VARS['SYS']['hhmm'])
1189 * @param integer Time stamp, seconds
1190 * @return string Formatted time
1192 function datetime($value) {
1193 return Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$value);
1197 * Returns $value (in seconds) formatted as hh:mm:ss
1198 * For instance $value = 3600 + 60*2 + 3 should return "01:02:03"
1200 * Usage: 1 (class t3lib_BEfunc)
1202 * @param integer Time stamp, seconds
1203 * @return string Formatted time
1205 function time($value) {
1206 $hh = floor($value/3600);
1207 $min = floor(($value-$hh*3600)/60);
1208 $sec = $value-$hh*3600-$min*60;
1209 $l = sprintf('%02d',$hh).':'.sprintf('%02d',$min).':'.sprintf('%02d',$sec);
1214 * Returns the "age" of the number of $seconds inputted.
1218 * @param integer $seconds could be the difference of a certain timestamp and time()
1219 * @param string $labels should be something like ' min| hrs| days| yrs'. This value is typically delivered by this function call: $GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears")
1220 * @return string Formatted time
1222 function calcAge ($seconds,$labels) {
1223 $labelArr = explode('|',$labels);
1225 if ($seconds<0) {$prefix='-'; $seconds=abs($seconds);}
1226 if ($seconds<3600) {
1227 $seconds = round ($seconds/60).$labelArr[0];
1228 } elseif ($seconds<24*3600) {
1229 $seconds = round ($seconds/3600).$labelArr[1];
1230 } elseif ($seconds<365*24*3600) {
1231 $seconds = round ($seconds/(24*3600)).$labelArr[2];
1233 $seconds = round ($seconds/(365*24*3600)).$labelArr[3];
1235 return $prefix.$seconds;
1239 * Returns a formatted timestamp if $tstamp is set.
1240 * The date/datetime will be followed by the age in parenthesis.
1244 * @param integer Time stamp, seconds
1245 * @param integer 1/-1 depending on polarity of age.
1246 * @param string $date=="date" will yield "dd:mm:yy" formatting, otherwise "dd:mm:yy hh:mm"
1249 function dateTimeAge($tstamp,$prefix=1,$date='') {
1251 ($date=='date' ? t3lib_BEfunc
::date($tstamp) : t3lib_BEfunc
::datetime($tstamp)).
1252 ' ('.t3lib_BEfunc
::calcAge($prefix*(time()-$tstamp),$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')' : '';
1256 * Returns either title='' or alt='' attribute. This depends on the client browser and whether it supports title='' or not (which is the default)
1257 * If no $content is given only the attribute name is returned.
1258 * If $hsc is set, then content of the attribute is htmlspecialchar()'ed (which is good for XHTML and other reasons...)
1259 * The returned attribute with content will have a leading space char.
1260 * Warning: Be careful to submit empty $content var - that will return just the attribute name!
1268 function titleAttrib($content='',$hsc=0) {
1270 $attrib= ($CLIENT['BROWSER']=='net'&&$CLIENT['VERSION']<5)||
$CLIENT['BROWSER']=='konqu' ?
'alt' : 'title';
1271 return strcmp($content,'')?
' '.$attrib.'="'.($hsc?
htmlspecialchars($content):$content).'"' : $attrib;
1275 * Returns alt="" and title="" attributes with the value of $content.
1280 function titleAltAttrib($content) {
1282 $out.=' alt="'.htmlspecialchars($content).'"';
1283 $out.=' title="'.htmlspecialchars($content).'"';
1288 * Returns a linked image-tag for thumbnail(s) from a database row with a list of image files in a field
1289 * All $TYPO3_CONF_VARS['GFX']['imagefile_ext'] extension are made to thumbnails + ttf file (renders font-example)
1290 * Thumbsnails are linked to the show_item.php script which will display further details.
1294 * @param array $row is the database row from the table, $table.
1295 * @param string Table name for $row (present in TCA)
1296 * @param string $field is pointing to the field with the list of image files
1297 * @param string Back path prefix for image tag src="" field
1298 * @param string Optional: $thumbScript os by default 'thumbs.php' if you don't set it otherwise
1299 * @param string Optional: $uploaddir is the directory relative to PATH_site where the image files from the $field value is found (Is by default set to the entry in $TCA for that field! so you don't have to!)
1300 * @param boolean If set, uploaddir is NOT prepended with "../"
1301 * @param string Optional: $tparams is additional attributes for the image tags
1302 * @param integer Optional: $size is [w]x[h] of the thumbnail. 56 is default.
1303 * @return string Thumbnail image tag.
1305 function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir='',$abs=0,$tparams='',$size='') {
1308 t3lib_div
::loadTCA($table);
1310 // Find uploaddir automatically
1311 $uploaddir = $uploaddir ?
$uploaddir : $TCA[$table]['columns'][$field]['config']['uploadfolder'];
1313 // Set thumbs-script:
1314 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
1315 $thumbScript='gfx/notfound_thumb.gif';
1316 } elseif(!$thumbScript) {
1317 $thumbScript='thumbs.php';
1319 // Check and parse the size parameter
1321 if ($size = trim($size)) {
1322 $sizeParts = explode('x', $size.'x'.$size);
1323 if(!intval($sizeParts[0])) $size='';
1327 $thumbs = explode(',', $row[$field]);
1329 while(list(,$theFile)=each($thumbs)) {
1330 if (trim($theFile)) {
1331 $fI = t3lib_div
::split_fileref($theFile);
1332 $ext = $fI['fileext'];
1335 if (t3lib_div
::inList('gif,jpg,png',$ext)) {
1336 $imgInfo=@getimagesize
(PATH_site
.$uploaddir.'/'.$theFile);
1337 if (is_array($imgInfo)) {$max = max($imgInfo);}
1339 // use the original image if it's size fits to the thumbnail size
1340 if ($max && $max<=(count($sizeParts)&&max($sizeParts)?
max($sizeParts):56)) {
1341 $url = $uploaddir.'/'.trim($theFile);
1342 $theFile = '../'.$url;
1343 $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
1344 $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="../'.$backPath.$url.'" '.$imgInfo[3].' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';
1346 } elseif ($ext=='ttf' || t3lib_div
::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$ext)) {
1347 $theFile = ($abs?
'':'../').$uploaddir.'/'.trim($theFile);
1348 $params = '&file='.rawurlencode($theFile);
1349 $params .= $size?
'&size='.$size:'';
1350 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
1351 $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
1352 $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /></a> ';
1354 $icon = t3lib_BEfunc
::getFileIcon($ext);
1355 $url = 'gfx/fileicons/'.$icon;
1356 $thumbData.='<img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /> ';
1364 * Returns single image tag to thumbnail
1368 * @param string $thumbScript must point to "thumbs.php" relative to the script position
1369 * @param string $theFile must be the proper reference to the file thumbs.php should show
1370 * @param string $tparams are additional attributes for the image tag
1371 * @param integer $size is the size of the thumbnail send along to "thumbs.php"
1372 * @return string Image tag
1374 function getThumbNail($thumbScript,$theFile,$tparams='',$size='') {
1375 $params = '&file='.rawurlencode($theFile);
1376 $params .= trim($size)?
'&size='.trim($size):'';
1377 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
1378 $th='<img src="'.htmlspecialchars($url).'" title="'.trim(basename($theFile)).'"'.($tparams?
" ".$tparams:"").' alt="" />';
1383 * Returns title-attribute information for a page-record informing about id, alias, doktype, hidden, starttime, endtime, fe_group etc.
1387 * @param array Input must be a page row ($row) with the proper fields set (be sure - send the full range of fields for the table)
1388 * @param string $perms_clause is used to get the record path of the shortcut page, if any (and doktype==4)
1389 * @param boolean If $includeAttrib is set, then the 'title=""' attribute is wrapped about the return value, which is in any case htmlspecialchar()'ed already
1392 function titleAttribForPages ($row,$perms_clause='',$includeAttrib=1) {
1395 $parts[] = 'id='.$row['uid'];
1396 if ($row['alias']) $parts[]=$LANG->sL($TCA['pages']['columns']['alias']['label']).' '.$row['alias'];
1397 if ($row['doktype']=='3') {
1398 $parts[]=$LANG->sL($TCA['pages']['columns']['url']['label']).' '.$row['url'];
1399 } elseif ($row['doktype']=='4') {
1400 if ($perms_clause) {
1401 $label = t3lib_BEfunc
::getRecordPath(intval($row['shortcut']),$perms_clause,20);
1403 $lRec = t3lib_BEfunc
::getRecord('pages',intval($row['shortcut']),'title');
1404 $label = $lRec['title'];
1406 if ($row['shortcut_mode']>0) {
1407 $label.=', '.$LANG->sL($TCA['pages']['columns']['shortcut_mode']['label']).' '.
1408 $LANG->sL(t3lib_BEfunc
::getLabelFromItemlist('pages','shortcut_mode',$row['shortcut_mode']));
1410 $parts[]=$LANG->sL($TCA['pages']['columns']['shortcut']['label']).' '.$label;
1411 } elseif ($row['doktype']=='7') {
1412 if ($perms_clause) {
1413 $label = t3lib_BEfunc
::getRecordPath(intval($row['mount_pid']),$perms_clause,20);
1415 $lRec = t3lib_BEfunc
::getRecord('pages',intval($row['mount_pid']),'title');
1416 $label = $lRec['title'];
1418 $parts[]=$LANG->sL($TCA['pages']['columns']['mount_pid']['label']).' '.$label;
1420 if ($row['hidden']) $parts[]=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.hidden');
1421 if ($row['starttime']) $parts[]=$LANG->sL($TCA['pages']['columns']['starttime']['label']).' '.t3lib_BEfunc
::dateTimeAge($row['starttime'],-1,'date');
1422 if ($row['endtime']) $parts[]=$LANG->sL($TCA['pages']['columns']['endtime']['label']).' '.t3lib_BEfunc
::dateTimeAge($row['endtime'],-1,'date');
1423 if ($row['fe_group']) {
1424 if ($row['fe_group']<0) {
1425 $label = $LANG->sL(t3lib_BEfunc
::getLabelFromItemlist('pages','fe_group',$row['fe_group']));
1427 $lRec = t3lib_BEfunc
::getRecord('fe_groups',$row['fe_group'],'title');
1428 $label = $lRec['title'];
1430 $parts[]=$LANG->sL($TCA['pages']['columns']['fe_group']['label']).' '.$label;
1432 $out = htmlspecialchars(implode(' - ',$parts));
1433 return $includeAttrib ? t3lib_BEfunc
::titleAttrib().'="'.$out.'"' : $out;
1437 * Returns title-attribute information for ANY record (from a table defined in TCA of course)
1438 * The included information depends on features of the table, but if hidden, starttime, endtime and fe_group fields are configured for, information about the record status in regard to these features are is included.
1439 * "pages" table can be used as well and will return the result of ->titleAttribForPages() for that page.
1443 * @param array Table row; $row is a row from the table, $table
1444 * @param string Table name
1447 function getRecordIconAltText($row,$table='pages') {
1448 if ($table=='pages') {
1449 $out = t3lib_BEfunc
::titleAttribForPages($row,'',0);
1451 $ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
1453 $out='id='.$row['uid']; // Uid is added
1454 if ($table=='pages' && $row['alias']) {
1455 $out.=' / '.$row['alias'];
1457 if ($ctrl['disabled']) { // Hidden ...
1458 $out.=($row[$ctrl['disabled']]?
' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.hidden'):'');
1460 if ($ctrl['starttime']) {
1461 if ($row[$ctrl['starttime']] > $GLOBALS['EXEC_TIME']) {
1462 $out.=' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.starttime').':'.t3lib_BEfunc
::date($row[$ctrl['starttime']]).' ('.t3lib_BEfunc
::daysUntil($row[$ctrl['starttime']]).' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.days').')';
1465 if ($row[$ctrl['endtime']]) {
1466 $out.=' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.endtime').': '.t3lib_BEfunc
::date($row[$ctrl['endtime']]).' ('.t3lib_BEfunc
::daysUntil($row[$ctrl['endtime']]).' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.days').')';
1469 return htmlspecialchars($out);
1473 * Returns the label of the first found entry in an "items" array from $TCA (tablename=$table/fieldname=$col) where the value is $key
1477 * @param string Table name, present in $TCA
1478 * @param string Field name, present in $TCA
1479 * @param string items-array value to match
1480 * @return string Label for item entry
1482 function getLabelFromItemlist($table,$col,$key) {
1484 // Load full TCA for $table
1485 t3lib_div
::loadTCA($table);
1487 // Check, if there is an "items" array:
1488 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]) && is_array($TCA[$table]['columns'][$col]['config']['items'])) {
1489 // Traverse the items-array...
1490 reset($TCA[$table]['columns'][$col]['config']['items']);
1491 while(list($k,$v)=each($TCA[$table]['columns'][$col]['config']['items'])) {
1492 // ... and return the first found label where the value was equal to $key
1493 if (!strcmp($v[1],$key)) return $v[0];
1499 * Returns the label-value for fieldname $col in table, $table
1500 * If $printAllWrap is set (to a "wrap") then it's wrapped around the $col value IF THE COLUMN $col DID NOT EXIST in TCA!, eg. $printAllWrap='<b>|</b>' and the fieldname was 'not_found_field' then the return value would be '<b>not_found_field</b>'
1504 * @param string Table name, present in $TCA
1505 * @param string Field name
1506 * @param string Wrap
1509 function getItemLabel($table,$col,$printAllWrap='') {
1511 // Load full TCA for $table
1512 t3lib_div
::loadTCA($table);
1513 // Check if column exists
1514 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col])) {
1516 return stripslashes($TCA[$table]['columns'][$col]['label']);
1518 if ($printAllWrap) {
1519 $parts = explode('|',$printAllWrap);
1520 return $parts[0].$col.$parts[1];
1525 * Returns the "title"-value in record, $row, from table, $table
1526 * The field(s) from which the value is taken is determined by the "ctrl"-entries 'label', 'label_alt' and 'label_alt_force'
1530 * @param string Table name, present in TCA
1531 * @param array Row from table
1532 * @param boolean If set, result is prepared for output: The output is cropped to a limited lenghty (depending on BE_USER->uc['titleLen']) and if no value is found for the title, '<em>[No title]</em>' is returned (localized)
1535 function getRecordTitle($table,$row,$prep=0) {
1537 if (is_array($TCA[$table])) {
1538 $t = $row[$TCA[$table]['ctrl']['label']];
1539 if ($TCA[$table]['ctrl']['label_alt'] && ($TCA[$table]['ctrl']['label_alt_force'] ||
!strcmp($t,''))) {
1540 $altFields=t3lib_div
::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
1543 while(list(,$fN)=each($altFields)) {
1544 $t = $tA[] = trim(strip_tags($row[$fN]));
1545 if (strcmp($t,'') && !$TCA[$table]['ctrl']['label_alt_force']) break;
1547 if ($TCA[$table]['ctrl']['label_alt_force']) $t=implode(', ',$tA);
1550 $t=htmlspecialchars(t3lib_div
::fixed_lgd($t,$GLOBALS['BE_USER']->uc
['titleLen']));
1551 if (!strcmp(trim($t),'')) $t='<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']</em>';
1558 * Returns a human readable output of a value from a record
1559 * For instance a database record relation would be looked up to display the title-value of that record. A checkbox with a "1" value would be "Yes", etc.
1560 * $table/$col is tablename and fieldname
1564 * @param string Table name, present in TCA
1565 * @param string Field name, present in TCA
1566 * @param string $value is the value of that field from a selected record
1567 * @param integer $fixed_lgd_chars is the max amount of characters the value may occupy
1568 * @param boolean $defaultPassthrough flag means that values for columns that has no conversion will just be pass through directly (otherwise cropped to 200 chars or returned as "N/A")
1571 function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0) {
1573 // Load full TCA for $table
1574 t3lib_div
::loadTCA($table);
1575 // Check if table and field is configured:
1576 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col])) {
1577 // Depending on the fields configuration, make a meaningful output value.
1578 $theColConf = $TCA[$table]['columns'][$col]['config'];
1580 switch((string)$theColConf['type']) {
1582 $l=t3lib_BEfunc
::getLabelFromItemlist($table,$col,$value);
1585 if ($theColConf['MM']) {
1588 $l=t3lib_BEfunc
::getLabelFromItemlist($table,$col,$value);
1589 $l=$GLOBALS['LANG']->sL($l);
1590 if ($theColConf['foreign_table'] && !$l && $TCA[$theColConf['foreign_table']]) {
1591 $rParts = t3lib_div
::trimExplode(',',$value,1);
1594 while(list(,$rVal)=each($rParts)) {
1595 $rVal = intval($rVal);
1597 $r=t3lib_BEfunc
::getRecord($theColConf['foreign_table'],$rVal);
1599 $r=t3lib_BEfunc
::getRecord($theColConf['neg_foreign_table'],-$rVal);
1602 $lA[]=$GLOBALS['LANG']->sL($rVal>0?
$theColConf['foreign_table_prefix']:$theColConf['neg_foreign_table_prefix']).t3lib_BEfunc
::getRecordTitle($rVal>0?
$theColConf['foreign_table']:$theColConf['neg_foreign_table'],$r);
1604 $lA[]=$rVal?
'['.$rVal.'!]':'';
1607 $l=implode(',',$lA);
1612 if (!is_array($theColConf['items']) ||
count($theColConf['items'])==1) {
1613 $l = $value ?
'Yes' : '';
1615 reset($theColConf['items']);
1617 while(list($key,$val)=each($theColConf['items'])) {
1618 if ($value & pow(2,$key)) {$lA[]=$GLOBALS['LANG']->sL($val[0]);}
1620 $l = implode($lA,', ');
1625 if (t3lib_div
::inList($theColConf['eval'],'date')) {
1626 $l = t3lib_BEfunc
::date($value).' ('.(time()-$value>0?
'-':'').t3lib_BEfunc
::calcAge(abs(time()-$value), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')';
1627 } elseif (t3lib_div
::inList($theColConf['eval'],'time')) {
1628 $l = t3lib_BEfunc
::time($value);
1629 } elseif (t3lib_div
::inList($theColConf['eval'],'datetime')) {
1630 $l = t3lib_BEfunc
::datetime($value);
1637 if ($defaultPassthrough) {
1639 } elseif ($theColConf['MM']) {
1642 $l=t3lib_div
::fixed_lgd(strip_tags($value),200);
1646 if ($fixed_lgd_chars) {
1647 return t3lib_div
::fixed_lgd($l,$fixed_lgd_chars);
1655 * Same as ->getProcessedValue() but will go easy on fields like "tstamp" and "pid" which are not configured in TCA - they will be formatted by this function instead.
1659 * @param string Table name, present in TCA
1660 * @param string Field name
1661 * @param string Field value
1662 * @param integer $fixed_lgd_chars is the max amount of characters the value may occupy
1664 * @see getProcessedValue()
1666 function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0) {
1668 $fVnew = t3lib_BEfunc
::getProcessedValue($table,$fN,$fV,$fixed_lgd_chars);
1669 if (!isset($fVnew)) {
1670 if (is_array($TCA[$table])) {
1671 if ($fN==$TCA[$table]['ctrl']['tstamp'] ||
$fN==$TCA[$table]['ctrl']['crdate']) {
1672 $fVnew = t3lib_BEfunc
::datetime($fV);
1673 } elseif ($fN=='pid'){
1674 $fVnew = t3lib_BEfunc
::getRecordPath ($fV,'1',20); // Fetches the path with no regard to the users permissions to select pages.
1684 * Returns file icon name (from $FILEICONS) for the fileextension $ext
1688 * @param string File extension, lowercase
1689 * @return string File icon filename
1691 function getFileIcon($ext) {
1692 return $GLOBALS['FILEICONS'][$ext] ?
$GLOBALS['FILEICONS'][$ext] : $GLOBALS['FILEICONS']['default'];
1696 * Returns fields for a table, $table, which would typically be interesting to select
1697 * This includes uid, the fields defined for title, icon-field.
1698 * Returned as a list ready for query ($prefix can be set to eg. "pages." if you are selecting from the pages table and want the table name prefixed)
1702 * @param string Table name, present in TCA
1703 * @param string Table prefix
1704 * @return strign List of fields.
1706 function getCommonSelectFields($table,$prefix) {
1709 $fields[]=$prefix.'uid';
1710 $fields[]=$prefix.$TCA[$table]['ctrl']['label'];
1711 if ($TCA[$table]['ctrl']['label_alt']) {
1712 $secondFields = t3lib_div
::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
1713 while(list(,$fieldN)=each($secondFields)) {
1714 $fields[]=$prefix.$fieldN;
1717 if ($TCA[$table]['ctrl']['selicon_field']) $fields[]=$prefix.$TCA[$table]['ctrl']['selicon_field'];
1718 return implode(',',$fields);
1722 * Makes a form for configuration of some values based on configuration found in the array $configArray, with default values from $defaults and a data-prefix $dataPrefix
1723 * <form>-tags must be supplied separately
1724 * Needs more documentation and examples, in particular syntax for configuration array. See Inside TYPO3. That's were you can expect to find example, if anywhere.
1726 * Usage: 1 (ext. direct_mail)
1728 * @param array Field configuration code.
1729 * @param array Defaults
1730 * @param string Prefix for formfields
1731 * @return string HTML for a form.
1733 function makeConfigForm($configArray,$defaults,$dataPrefix) {
1734 $params = $defaults;
1735 if (is_array($configArray)) {
1736 reset($configArray);
1738 while(list($fname,$config)=each($configArray)) {
1739 if (is_array($config)) {
1740 $lines[$fname]='<strong>'.htmlspecialchars($config[1]).'</strong><br />';
1741 $lines[$fname].=$config[2].'<br />';
1742 switch($config[0]) {
1745 $formEl = '<input type="text" name="'.$dataPrefix.'['.$fname.']" value="'.$params[$fname].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($config[0]=='short'?
24:48).' />';
1748 $formEl = '<input type="hidden" name="'.$dataPrefix.'['.$fname.']" value="0" /><input type="checkbox" name="'.$dataPrefix.'['.$fname.']" value="1"'.($params[$fname]?
' checked="checked"':'').' />';
1756 while(list($k,$v)=each($config[3])) {
1757 $opt[]='<option value="'.htmlspecialchars($k).'"'.($params[$fname]==$k?
' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
1759 $formEl = '<select name="'.$dataPrefix.'['.$fname.']">'.implode('',$opt).'</select>';
1765 $lines[$fname].=$formEl;
1766 $lines[$fname].='<br /><br />';
1768 $lines[$fname]='<hr />';
1769 if ($config) $lines[$fname].='<strong>'.strtoupper(htmlspecialchars($config)).'</strong><br />';
1770 if ($config) $lines[$fname].='<br />';
1774 $out = implode('',$lines);
1775 $out.='<input type="submit" name="submit" value="Update configuration" />';
1791 /*******************************************
1793 * Backend Modules API functions
1795 *******************************************/
1799 * Returns help-text icon if configured for.
1800 * TCA_DESCR must be loaded prior to this function and $BE_USER must have 'edit_showFieldHelp' set to 'icon', otherwise nothing is returned
1804 * @param string Table name
1805 * @param string Field name
1806 * @param string Back path
1807 * @param boolean Force display of icon nomatter BE_USER setting for help
1808 * @return string HTML content for a help icon/text
1810 function helpTextIcon($table,$field,$BACK_PATH,$force=0) {
1811 global $TCA_DESCR,$BE_USER;
1812 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && ($BE_USER->uc
['edit_showFieldHelp']=='icon' ||
$force)) {
1813 $onClick = 'vHWin=window.open(\''.$BACK_PATH.'view_help.php?tfID='.($table.'.'.$field).'\',\'viewFieldHelp\',\'height=300,width=250,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
1814 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
1815 '<img src="'.$BACK_PATH.'gfx/helpbubble.gif" width="14" height="14" hspace="2" border="0" align="absmiddle"'.($GLOBALS['CLIENT']['FORMSTYLE']?
' style="cursor:help;"':'').' alt="" />'.
1821 * Returns CSH help text (description), if configured for.
1822 * TCA_DESCR must be loaded prior to this function and $BE_USER must have "edit_showFieldHelp" set to "text", otherwise nothing is returned
1823 * Will automatically call t3lib_BEfunc::helpTextIcon() to get the icon for the text.
1827 * @param string Table name
1828 * @param string Field name
1829 * @param string Back path
1830 * @return string HTML content for help text
1832 function helpText($table,$field,$BACK_PATH) {
1833 global $TCA_DESCR,$BE_USER;
1834 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && $BE_USER->uc
['edit_showFieldHelp']=='text') {
1835 $fDat = $TCA_DESCR[$table]['columns'][$field];
1836 return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">'.t3lib_BEfunc
::helpTextIcon($table,$field,$BACK_PATH,
1837 $fDat['details']||
$fDat['syntax']||
$fDat['image_descr']||
$fDat['image']||
$fDat['seeAlso']
1838 ).'</td><td valign="top">'.$fDat['description'].'</td></tr></table>';
1843 * Returns a JavaScript string (for an onClick handler) which will load the alt_doc.php script that shows the form for editing of the record(s) you have send as params.
1844 * REMEMBER to always htmlspecialchar() content in href-properties to ampersands get converted to entities (XHTML requirement and XSS precaution)
1848 * @param string $params is parameters sent along to alt_doc.php. This requires a much more details description which you must seek in Inside TYPO3s documentation of the alt_doc.php API. And example could be '&edit[pages][123]=edit' which will show edit form for page record 123.
1849 * @param string $backPath must point back to the TYPO3_mainDir directory (where alt_doc.php is)
1850 * @param string $requestUri is an optional returnUrl you can set - automatically set to REQUEST_URI.
1853 function editOnClick($params,$backPath='',$requestUri='') {
1854 $retUrl = 'returnUrl='.($requestUri==-1?
"'+T3_THIS_LOCATION+'":rawurlencode($requestUri?
$requestUri:t3lib_div
::getIndpEnv('REQUEST_URI')));
1855 return "document.location='".$backPath."alt_doc.php?".$retUrl.$params."'; return false;";
1859 * Returns a JavaScript string for viewing the page id, $id
1863 * @param integer $id is page id
1864 * @param string $backpath must point back to TYPO3_mainDir (where the site is assumed to be one level above)
1865 * @param array If root line is supplied the function will look for the first found domain record and use that URL instead (if found)
1866 * @param string $anchor is optional anchor to the URL
1867 * @param string $altUrl is an alternative URL which - if set - will make all other parameters ignored: The function will just return the window.open command wrapped around this URL!
1870 function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='') {
1875 $parts = parse_url(t3lib_div
::getIndpEnv('TYPO3_SITE_URL'));
1876 if (t3lib_BEfunc
::getDomainStartPage($parts['host'],$parts['path'])) {
1877 $preUrl_temp = t3lib_BEfunc
::firstDomainRecord($rootLine);
1880 $preUrl = $preUrl_temp ?
'http://'.$preUrl_temp : $backPath.'..';
1881 $url = $preUrl.'/index.php?id='.$id.$anchor;
1884 return "previewWin=window.open('".$url."','newTypo3FrontendWindow','status=1,menubar=1,resizable=1,location=1,scrollbars=1,toolbar=1');previewWin.focus();";
1888 * Returns the merged User/Page TSconfig for page id, $id.
1889 * Please read details about module programming elsewhere!
1893 * @param integer Page uid
1894 * @param string $TSref is an object string which determines the path of the TSconfig to return.
1897 function getModTSconfig($id,$TSref) {
1898 $pageTS_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref,t3lib_BEfunc
::getPagesTSconfig($id));
1899 $BE_USER_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref);
1900 $modTSconfig = t3lib_div
::array_merge_recursive_overrule($pageTS_modOptions,$BE_USER_modOptions);
1901 return $modTSconfig;
1905 * Returns a selector box "function menu" for a module
1906 * Requires the JS function jumpToUrl() to be available
1907 * See Inside TYPO3 for details about how to use / make Function menus
1911 * @param string $id is the "&id=" parameter value to be sent to the module
1912 * @param string $elementName it the form elements name, probably something like "SET[...]"
1913 * @param string $currentValue is the value to be selected currently.
1914 * @param array $menuItems is an array with the menu items for the selector box
1915 * @param string $script is the script to send the &id to, if empty it's automatically found
1916 * @param string $addParams is additional parameters to pass to the script.
1917 * @return string HTML code for selector box
1919 function getFuncMenu($id,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1920 if (is_array($menuItems)) {
1921 if (!$script) {basename(PATH_thisScript
);}
1924 while(list($value,$label)=each($menuItems)) {
1925 $options.='<option value="'.htmlspecialchars($value).'"'.(!strcmp($currentValue,$value)?
' selected="selected"':'').'>'.t3lib_div
::deHSCentities(htmlspecialchars($label)).'</option>';
1928 $onChange= 'jumpToUrl(\''.$script.'?id='.rawurlencode($id).$addparams.'&'.$elementName.'=\'+this.options[this.selectedIndex].value,this);';
1929 return '<select name="'.$elementName.'" onchange="'.htmlspecialchars($onChange).'">'.$options.'</select>';
1935 * Checkbox function menu.
1936 * Works like ->getFuncMenu() but takes no $menuItem array since this is a simple checkbox.
1940 * @param string $id is the "&id=" parameter value to be sent to the module
1941 * @param string $elementName it the form elements name, probably something like "SET[...]"
1942 * @param string $currentValue is the value to be selected currently.
1943 * @param string $script is the script to send the &id to, if empty it's automatically found
1944 * @param string $addParams is additional parameters to pass to the script.
1945 * @param string Additional attributes for the checkbox input tag
1946 * @return string HTML code for checkbox
1947 * @see getFuncMenu()
1949 function getFuncCheck($id,$elementName,$currentValue,$script='',$addparams='',$tagParams='') {
1950 if (!$script) {basename(PATH_thisScript
);}
1951 $onClick = 'jumpToUrl(\''.$script.'?id='.$id.$addparams.'&'.$elementName.'=\'+(this.checked?1:0),this);';
1952 return '<input type="checkbox" name="'.$elementName.'"'.($currentValue?
' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'"'.($tagParams?
' '.$tagParams:'').' />';
1956 * Input field function menu
1957 * Works like ->getFuncMenu() / ->getFuncCheck() but displays a input field instead which updates the script "onchange"
1961 * @param string $id is the "&id=" parameter value to be sent to the module
1962 * @param string $elementName it the form elements name, probably something like "SET[...]"
1963 * @param string $currentValue is the value to be selected currently.
1964 * @param integer Relative size of input field, max is 48
1965 * @param string $script is the script to send the &id to, if empty it's automatically found
1966 * @param string $addParams is additional parameters to pass to the script.
1967 * @return string HTML code for input text field.
1968 * @see getFuncMenu()
1970 function getFuncInput($id,$elementName,$currentValue,$size=10,$script="",$addparams="") {
1971 if (!$script) {basename(PATH_thisScript
);}
1972 $onChange = 'jumpToUrl(\''.$script.'?id='.$id.$addparams.'&'.$elementName.'=\'+escape(this.value),this);';
1973 return '<input type="text"'.$GLOBALS['TBE_TEMPLATE']->formWidth($size).' name="'.$elementName.'" value="'.htmlspecialchars($currentValue).'" onchange="'.htmlspecialchars($onChange).'" />';
1977 * Removes menu items from $itemArray if they are configured to be removed by TSconfig for the module ($modTSconfig)
1978 * See Inside TYPO3 about how to program modules and use this API.
1984 * @param string $TSref points to the "object string" in $modTSconfig
1985 * @return array The modified $itemArray is returned.
1987 function unsetMenuItems($modTSconfig,$itemArray,$TSref) {
1988 // Getting TS-config options for this module for the Backend User:
1989 $conf = $GLOBALS['BE_USER']->getTSConfig($TSref,$modTSconfig);
1990 if (is_array($conf['properties'])) {
1991 reset($conf['properties']);
1992 while(list($key,$val)=each($conf['properties'])) {
1994 unset($itemArray[$key]);
2002 * Call to update the page tree frame (or something else..?) after
2003 * t3lib_BEfunc::getSetUpdateSignal('updatePageTree') -> will set the page tree to be updated.
2004 * t3lib_BEfunc::getSetUpdateSignal() -> will return some JavaScript that does the update (called in the typo3/template.php file, end() function)
2009 * @return string HTML code (<script> section)
2011 function getSetUpdateSignal($set='') {
2013 $key = 't3lib_BEfunc::getSetUpdateSignal';
2017 $modData['set']=$set;
2018 $BE_USER->pushModuleData($key,$modData);
2020 $modData = $BE_USER->getModuleData($key,'ses');
2021 if (trim($modData['set'])) {
2022 $l=explode(',',$modData['set']);
2023 while(list(,$v)=each($l)) {
2025 case 'updatePageTree':
2027 <script type="text/javascript">
2029 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
2030 top.content.nav_frame.refresh_nav();
2039 $BE_USER->pushModuleData($key,$modData);
2047 * Returns an array which is most backend modules becomes MOD_SETTINGS containing values from function menus etc. determining the function of the module.
2048 * This is kind of session variable management framework for the backend users.
2049 * If a key from MOD_MENU is set in the CHANGED_SETTINGS array (eg. a value is passed to the script from the outside), this value is put into the settings-array
2050 * Ultimately, see Inside TYPO3 for how to use this function in relation to your modules.
2053 * @param array MOD_MENU is an array that defines the options in menus.
2054 * @param array CHANGED_SETTINGS represents the array used when passing values to the script from the menus.
2055 * @param string modName is the name of this module. Used to get the correct module data.
2056 * @param string If type is 'ses' then the data is stored as session-lasting data. This means that it'll be wiped out the next time the user logs in.
2057 * @param string dontValidateList can be used to list variables that should not be checked if their value is found in the MOD_MENU array. Used for dynamically generated menus.
2058 * @param string List of default values from $MOD_MENU to set in the output array (only if the values from MOD_MENU are not arrays)
2059 * @return array The array $settings, which holds a key for each MOD_MENU key and the values of each key will be within the range of values for each menuitem
2061 function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='') {
2063 if ($modName && is_string($modName)) {
2064 // GETTING stored user-data from this module:
2065 $settings = $GLOBALS['BE_USER']->getModuleData($modName,$type);
2068 if (!is_array($settings)) {
2072 if (is_array($MOD_MENU)) {
2074 while(list($key,$var)=each($MOD_MENU)) {
2075 // If a global var is set before entering here. eg if submitted, then it's substituting the current value the array.
2076 if (is_array($CHANGED_SETTINGS) && isset($CHANGED_SETTINGS[$key]) && strcmp($settings[$key],$CHANGED_SETTINGS[$key])) {
2077 $settings[$key] = (string)$CHANGED_SETTINGS[$key];
2080 // If the $var is an array, which denotes the existence of a menu, we check if the value is permitted
2081 if (is_array($var) && (!$dontValidateList ||
!t3lib_div
::inList($dontValidateList,$key))) {
2082 // If the setting is an array or not present in the menu-array, MOD_MENU, then the default value is inserted.
2083 if (is_array($settings[$key]) ||
!isset($MOD_MENU[$key][$settings[$key]])) {
2084 $settings[$key]=(string)key($var);
2088 if ($setDefaultList && !is_array($var)) { // Sets default values (only strings/checkboxes, not menus)
2089 if (t3lib_div
::inList($setDefaultList,$key) && !isset($settings[$key])) {
2090 $settings[$key]=$var;
2094 } else {die ('No menu!');}
2098 $GLOBALS['BE_USER']->pushModuleData($modName,$settings);
2102 } else {die ('Wrong module name: "'.$modName.'"');}
2117 /*******************************************
2121 *******************************************/
2126 * Unlock or Lock a record from $table with $uid
2127 * If $table and $uid is not set, then all locking for the current BE_USER is removed!
2131 * @param string Table name
2132 * @param integer Record uid
2133 * @param integer Record pid
2136 * @see t3lib_transferData::lockRecord(), alt_doc.php, db_layout.php, db_list.php, wizard_rte.php
2138 function lockRecords($table='',$uid=0,$pid=0) {
2139 $user_id = intval($GLOBALS['BE_USER']->user
['uid']);
2140 if ($table && $uid) {
2141 $fields_values=array(
2143 'tstamp'=>$GLOBALS['EXEC_TIME'],
2144 'record_table'=>$table,
2146 'username'=>$GLOBALS['BE_USER']->user
['username'],
2149 $query=t3lib_BEfunc
::DBcompileInsert('sys_lockedrecords',$fields_values);
2151 $query='DELETE FROM sys_lockedrecords WHERE userid='.$user_id;
2154 $res = mysql(TYPO3_db
,$query);
2158 * Returns information about whether the record from table, $table, with uid, $uid is currently locked (edited by another user - which should issue a warning).
2159 * Notice: Locking is not strictly carried out since locking is abandoned when other backend scripts are activated - which means that a user CAN have a record "open" without having it locked. So this just serves as a warning that counts well in 90% of the cases, which should be sufficient.
2163 * @param string Table name
2164 * @param integer Record uid
2167 * @see class.db_layout.inc, alt_db_navframe.php, alt_doc.php, db_layout.php
2169 function isRecordLocked($table,$uid) {
2170 global $LOCKED_RECORDS;
2171 if (!is_array($LOCKED_RECORDS)) {
2172 $query='SELECT * FROM sys_lockedrecords WHERE '.
2173 'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user
['uid']).
2174 ' AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600);
2175 $res = mysql(TYPO3_db
,$query);
2176 while($row=mysql_fetch_assoc($res)) {
2177 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
2178 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
2179 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'),
2181 t3lib_BEfunc
::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
2183 if ($row['record_pid'] && !isset($LOCKED_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
2184 $LOCKED_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
2185 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content'),
2187 t3lib_BEfunc
::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
2192 return $LOCKED_RECORDS[$table.':'.$uid];
2196 * Returns select statement for MM relations (as used by TCEFORMs etc)
2200 * @param array Configuration array for the field, taken from $TCA
2201 * @param string Field name
2202 * @param array TSconfig array from which to get further configuration settings for the field name
2203 * @param string Prefix string for the key "*foreign_table_where" from $fieldValue array
2204 * @return string Part of query
2206 * @see t3lib_transferData::renderRecord(), t3lib_TCEforms::foreignTable()
2208 function foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='') {
2210 $foreign_table = $fieldValue['config'][$prefix.'foreign_table'];
2211 $rootLevel = $TCA[$foreign_table]['ctrl']['rootLevel'];
2213 $fTWHERE = $fieldValue['config'][$prefix.'foreign_table_where'];
2214 if (strstr($fTWHERE,'###REC_FIELD_')) {
2215 $fTWHERE_parts = explode('###REC_FIELD_',$fTWHERE);
2216 while(list($kk,$vv)=each($fTWHERE_parts)) {
2218 $fTWHERE_subpart = explode('###',$vv,2);
2219 $fTWHERE_parts[$kk]=$TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]].$fTWHERE_subpart[1];
2222 $fTWHERE = implode('',$fTWHERE_parts);
2225 $fTWHERE = str_replace('###CURRENT_PID###',intval($TSconfig['_CURRENT_PID']),$fTWHERE);
2226 $fTWHERE = str_replace('###THIS_UID###',intval($TSconfig['_THIS_UID']),$fTWHERE);
2227 $fTWHERE = str_replace('###THIS_CID###',intval($TSconfig['_THIS_CID']),$fTWHERE);
2228 $fTWHERE = str_replace('###STORAGE_PID###',intval($TSconfig['_STORAGE_PID']),$fTWHERE);
2229 $fTWHERE = str_replace('###SITEROOT###',intval($TSconfig['_SITEROOT']),$fTWHERE);
2230 $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###',intval($TSconfig[$field]['PAGE_TSCONFIG_ID']),$fTWHERE);
2231 $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###',implode(',',t3lib_div
::intExplode(',',$TSconfig[$field]['PAGE_TSCONFIG_IDLIST'])),$fTWHERE);
2232 $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###',addslashes($TSconfig[$field]['PAGE_TSCONFIG_STR']),$fTWHERE);
2235 // rootLevel = -1 is not handled 'properly' here - it goes as if it was rootLevel = 1 (that is pid=0)
2237 $query = 'SELECT '.t3lib_BEfunc
::getCommonSelectFields($foreign_table,$foreign_table.'.').' FROM '.$foreign_table.' WHERE '.$foreign_table.'.pid=0 '.t3lib_BEfunc
::deleteClause($foreign_table).' '.$fTWHERE;
2239 $pageClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2240 if ($foreign_table!='pages') {
2241 $query = 'SELECT '.t3lib_BEfunc
::getCommonSelectFields($foreign_table,$foreign_table.'.').' FROM '.$foreign_table.',pages WHERE pages.uid='.$foreign_table.'.pid AND NOT pages.deleted '.t3lib_BEfunc
::deleteClause($foreign_table).' AND '.$pageClause.' '.$fTWHERE;
2243 $query = 'SELECT '.t3lib_BEfunc
::getCommonSelectFields($foreign_table,$foreign_table.'.').' FROM pages WHERE NOT pages.deleted AND '.$pageClause.' '.$fTWHERE;
2246 // debug(array($query));
2251 * Returns TSConfig for the TCEFORM object in Page TSconfig.
2256 * @param string Table name present in TCA
2257 * @param array Row from table
2259 * @see t3lib_transferData::renderRecord(), t3lib_TCEforms::setTSconfig(), SC_wizard_list::main(), SC_wizard_add::main()
2261 function getTCEFORM_TSconfig($table,$row) {
2263 $typeVal = t3lib_BEfunc
::getTCAtypeValue($table,$row);
2265 // Get main config for the table
2266 list($TScID,$cPid) = t3lib_BEfunc
::getTSCpid($table,$row['uid'],$row['pid']);
2268 $rootLine = t3lib_BEfunc
::BEgetRootLine($TScID,'');
2270 $tempConf = $GLOBALS['BE_USER']->getTSConfig('TCEFORM.'.$table,t3lib_BEfunc
::getPagesTSconfig($TScID,$rootLine));
2271 if (is_array($tempConf['properties'])) {
2272 while(list($key,$val)=each($tempConf['properties'])) {
2273 if (is_array($val)) {
2274 $fieldN = substr($key,0,-1);
2275 $res[$fieldN] = $val;
2276 unset($res[$fieldN]['types.']);
2277 if (strcmp($typeVal,'') && is_array($val['types.'][$typeVal.'.'])) {
2278 $res[$fieldN] = t3lib_div
::array_merge_recursive_overrule($res[$fieldN],$val['types.'][$typeVal.'.']);
2284 $res['_CURRENT_PID']=$cPid;
2285 $res['_THIS_UID']=$row['uid'];
2286 $res['_THIS_CID']=$row['cid'];
2287 $res['_THIS_ROW']=$row; // So the row will be passed to foreign_table_where_query()
2289 while(list(,$rC)=each($rootLine)) {
2290 if (!$res['_STORAGE_PID']) $res['_STORAGE_PID']=intval($rC['storage_pid']);
2291 if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?
intval($rC['uid']):0;
2298 * Find the real PID of the record (with $uid from $table). This MAY be impossible if the pid is set as a reference to the former record or a page (if two records are created at one time).
2302 * @param string Table name
2303 * @param integer Record uid
2304 * @param integer Record pid
2307 * @see t3lib_TCEmain::copyRecord(), getTSCpid()
2309 function getTSconfig_pidValue($table,$uid,$pid) {
2310 if (t3lib_div
::testInt($pid)) { // If pid is an integer this takes precedence in our lookup.
2311 $thePidValue = intval($pid);
2312 if ($thePidValue<0) { // If ref to another record, look that record up.
2313 $pidRec = t3lib_BEfunc
::getRecord($table,abs($thePidValue),'pid');
2314 $thePidValue= is_array($pidRec) ?
$pidRec['pid'] : -2; // Returns -2 if the record did not exist.
2316 // ... else the pos/zero pid is just returned here.
2317 } else { // No integer pid and we are forced to look up the $pid
2318 $rr = t3lib_BEfunc
::getRecord($table,$uid,'pid'); // Try to fetch the record pid from uid. If the uid is 'NEW...' then this will of course return nothing...
2319 if (is_array($rr)) {
2320 $thePidValue = $rr['pid']; // Returning the 'pid' of the record
2321 } else $thePidValue=-1; // Returns -1 if the record with the pid was not found.
2323 return $thePidValue;
2327 * Return $uid if $table is pages and $uid is integer - otherwise the $pid
2331 * @param string Table name
2332 * @param integer Record uid
2333 * @param integer Record pid
2336 * @see t3lib_TCEforms::getTSCpid()
2338 function getPidForModTSconfig($table,$uid,$pid) {
2339 $retVal = ($table=='pages' && t3lib_div
::testInt($uid)) ?
$uid : $pid;
2344 * Returns the REAL pid of the record, if possible. If both $uid and $pid is strings, then pid=-1 is returned as an error indication.
2348 * @param string Table name
2349 * @param integer Record uid
2350 * @param integer Record pid
2353 * @see t3lib_TCEmain::setHistory(), t3lib_TCEmain::process_datamap()
2355 function getTSCpid($table,$uid,$pid) {
2356 // If pid is negative (referring to another record) the pid of the other record is fetched and returned.
2357 $cPid = t3lib_BEfunc
::getTSconfig_pidValue($table,$uid,$pid);
2358 // $TScID is the id of $table=pages, else it's the pid of the record.
2359 $TScID = t3lib_BEfunc
::getPidForModTSconfig($table,$uid,$cPid);
2361 return array($TScID,$cPid);
2365 * Returns first found domain record "domainName" (without trailing slash) if found in the input $rootLine
2369 * @param array Root line array
2370 * @return string Domain name, if found.
2372 function firstDomainRecord($rootLine) {
2373 if (t3lib_extMgm
::isLoaded('cms')) {
2375 while(list(,$row)=each($rootLine)) {
2376 $dRec = t3lib_BEfunc
::getRecordsByField('sys_domain','pid',$row['uid'],' AND redirectTo="" AND hidden=0 ORDER BY sorting');
2377 if (is_array($dRec)) {
2379 $dRecord = current($dRec);
2380 return ereg_replace('\/$','',$dRecord['domainName']);
2387 * Returns the sys_domain record for $domain, optionally with $path appended.
2391 * @param string Domain name
2392 * @param string Appended path
2393 * @return array Domain record, if found
2395 function getDomainStartPage($domain, $path='') {
2396 if (t3lib_extMgm
::isLoaded('cms')) {
2397 $domain = explode(':',$domain);
2398 $domain = strtolower(ereg_replace('\.$','',$domain[0]));
2399 // path is calculated.
2400 $path = trim(ereg_replace('\/[^\/]*$','',$path));
2404 $query = 'SELECT sys_domain.*'.
2405 'FROM pages,sys_domain where pages.uid=sys_domain.pid
2406 AND NOT sys_domain.hidden
2407 AND (sys_domain.domainName="'.addSlashes($domain).'" or sys_domain.domainName="'.addSlashes($domain.'/').'") '.
2408 t3lib_BEfunc
::deleteClause('pages').
2410 $res = mysql(TYPO3_db
, $query);
2412 return mysql_fetch_assoc($res);
2417 * Returns overlayered RTE setup from an array with TSconfig. Used in TCEforms and TCEmain
2421 * @param array The properties of Page TSconfig in the key "RTE."
2422 * @param string Table name
2423 * @param string Field name
2424 * @param string Type value of the current record (like from CType of tt_content)
2425 * @return array Array with the configuration for the RTE
2428 function RTEsetup($RTEprop,$table,$field,$type='') {
2429 $thisConfig = is_array($RTEprop['default.']) ?
$RTEprop['default.'] : array();
2430 $thisFieldConf = $RTEprop['config.'][$table.'.'][$field.'.'];
2431 if (is_array($thisFieldConf)) {
2432 unset($thisFieldConf['types.']);
2433 $thisConfig = t3lib_div
::array_merge_recursive_overrule($thisConfig,$thisFieldConf);
2435 if ($type && is_array($RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.'])) {
2436 $thisConfig = t3lib_div
::array_merge_recursive_overrule($thisConfig,$RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.']);
2442 * Returns true if $modName is set and is found as a main- or submodule in $TBE_MODULES array
2446 * @param string Module name
2449 function isModuleSetInTBE_MODULES($modName) {
2450 reset($GLOBALS['TBE_MODULES']);
2452 while(list($mkey,$list)=each($GLOBALS['TBE_MODULES'])) {
2455 $subList = t3lib_div
::trimExplode(',',$list,1);
2456 while(list(,$skey)=each($subList)) {
2457 $loaded[$mkey.'_'.$skey]=1;
2461 return $modName && isset($loaded[$modName]);
2481 /*******************************************
2485 *******************************************/
2489 * Print error message with header, text etc.
2493 * @param string Header
2494 * @param string Content
2495 * @param boolean Will return an alert() with the content of header and text.
2496 * @param boolean Print header.
2499 function typo3PrintError ($header,$text,$js='',$head=1) {
2500 // This prints out a TYPO3 error message.
2501 // If $js is set the message will be output in JavaScript
2503 echo"alert('".t3lib_div
::slashJS($header.'\n'.$text)."');";
2507 <title>Error!</title>
2509 <body bgcolor="#cccccc" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">':'';
2510 echo '<div align="center">
2511 <table border="0" cellspacing="0" cellpadding="0" width="333">
2513 <td align="center">'.
2514 ($GLOBALS["TBE_STYLES"]["logo_login"]?
'<img src="'.$GLOBALS["BACK_PATH"].$GLOBALS["TBE_STYLES"]["logo_login"].'" alt="" />':'<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/typo3logo.gif" width="333" height="43" vspace="10" />').
2518 <td bgcolor="black">
2519 <table width="100%" border="0" cellspacing="1" cellpadding="10">
2521 <td bgcolor="#F4F0E8">
2522 <font face="verdana,arial,helvetica" size="2">';
2523 echo '<b><center><font size="+1">'.$header.'</font></center></b><br />'.$text;
2539 * Returns "web" if the $path (absolute) is within the DOCUMENT ROOT - and thereby qualifies as a "web" folder.
2543 * @param string Path
2546 function getPathType_web_nonweb($path) {
2547 return t3lib_div
::isFirstPartOfStr($path,t3lib_div
::getIndpEnv('TYPO3_DOCUMENT_ROOT')) ?
'web' : '';
2551 * Creates ADMCMD parameters for the "viewpage" extension / "cms" frontend
2555 * @param array Page record
2556 * @return string Query-parameters
2559 function ADMCMD_previewCmds($pageinfo) {
2560 if ($pageinfo['fe_group']>0) {
2561 $simUser = '&ADMCMD_simUser='.$pageinfo['fe_group'];
2563 if ($pageinfo['starttime']>time()) {
2564 $simTime = '&ADMCMD_simTime='.$pageinfo['starttime'];
2566 if ($pageinfo['endtime']<time() && $pageinfo['endtime']!=0) {
2567 $simTime = '&ADMCMD_simTime='.($pageinfo['endtime']-1);
2569 return $simUser.$simTime;
2573 * Returns an array with key=>values based on input text $params
2574 * $params is exploded by line-breaks and each line is supposed to be on the syntax [key] = [some value]
2575 * These pairs will be parsed into an array an returned.
2582 function processParams($params) {
2584 $lines=explode(chr(10),$params);
2585 while(list(,$val)=each($lines)) {
2588 $pair = explode('=',$val,2);
2589 $paramArr[trim($pair[0])] = trim($pair[1]);
2596 * Returns "list of backend modules". Most likely this will be obsolete soon / removed. Don't use.
2600 * @param string Module names list
2601 * @param string Perms clause for SQL query
2602 * @param string Backpath
2603 * @param string The URL/script to jump to (used in A tag)
2604 * @return array Two keys, rows and list
2609 function getListOfBackendModules($name,$perms_clause,$backPath='',$script='index.php') {
2610 $query = 'SELECT * FROM pages where doktype!=255 AND module IN ("'.$name.'") AND'.$perms_clause.t3lib_BEfunc
::deleteClause('pages');
2611 $res = mysql(TYPO3_db
,$query);
2612 if (!mysql_num_rows($res)) return false;
2615 while($row=mysql_fetch_assoc($res)) {
2617 $out.='<nobr><a href="'.htmlspecialchars($script.'?id='.$row['uid']).'"><img src="'.$backPath.t3lib_iconWorks
::getIcon('pages',$row).'" width="18" height="16" border="0" title="'.htmlspecialchars(t3lib_BEfunc
::getRecordPath($row['uid'],$perms_clause,20)).'" align="top" alt="" />'.$row['title'].'</a></nobr><br />';
2619 return array('rows'=>$theRows,'list'=>$out);