2 /***************************************************************
5 * (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@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 <kasperYYYY@typo3.com>
42 * [CLASS/FUNCTION INDEX of SCRIPT]
46 * 185: class t3lib_BEfunc
48 * SECTION: SQL-related, selecting records, searching
49 * 206: function deleteClause($table,$tableAlias='')
50 * 230: function getRecord($table,$uid,$fields='*',$where='',$useDeleteClause=true)
51 * 253: function getRecordWSOL($table,$uid,$fields='*',$where='',$useDeleteClause=true)
52 * 286: function getRecordRaw($table,$where='',$fields='*')
53 * 309: function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='',$useDeleteClause=true)
54 * 342: function searchQuery($searchWords,$fields,$table='')
55 * 357: function listQuery($field,$value)
56 * 369: function splitTable_Uid($str)
57 * 384: function getSQLselectableList($in_list,$tablename,$default_tablename)
58 * 412: function BEenableFields($table,$inv=0)
60 * SECTION: SQL-related, DEPRECATED functions
61 * 476: function mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
62 * 498: function DBcompileInsert($table,$fields_values)
63 * 512: function DBcompileUpdate($table,$where,$fields_values)
65 * SECTION: Page tree, TCA related
66 * 542: function BEgetRootLine($uid,$clause='',$workspaceOL=FALSE)
67 * 598: function openPageTree($pid,$clearExpansion)
68 * 643: function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
69 * 686: function getExcludeFields()
70 * 716: function getExplicitAuthFieldValues()
71 * 787: function getSystemLanguages()
72 * 812: function readPageAccess($id,$perms_clause)
73 * 843: function getTCAtypes($table,$rec,$useFieldNameAsKey=0)
74 * 896: function getTCAtypeValue($table,$rec)
75 * 919: function getSpecConfParts($str, $defaultExtras)
76 * 950: function getSpecConfParametersFromArray($pArr)
77 * 978: function getFlexFormDS($conf,$row,$table,$fieldName='',$WSOL=TRUE)
79 * SECTION: Caching related
80 * 1105: function storeHash($hash,$data,$ident)
81 * 1125: function getHash($hash,$expTime=0)
83 * SECTION: TypoScript related
84 * 1161: function getPagesTSconfig($id,$rootLine='',$returnPartArray=0)
85 * 1217: function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='')
86 * 1272: function implodeTSParams($p,$k='')
88 * SECTION: Users / Groups related
89 * 1309: function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='')
90 * 1327: function getGroupNames($fields='title,uid', $where='')
91 * 1344: function getListGroupNames($fields='title,uid')
92 * 1363: function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0)
93 * 1396: function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0)
95 * SECTION: Output related
96 * 1437: function daysUntil($tstamp)
97 * 1449: function date($tstamp)
98 * 1460: function datetime($value)
99 * 1472: function time($value)
100 * 1488: function calcAge($seconds,$labels = 'min|hrs|days|yrs')
101 * 1514: function dateTimeAge($tstamp,$prefix=1,$date='')
102 * 1532: function titleAttrib($content='',$hsc=0)
103 * 1545: function titleAltAttrib($content)
104 * 1569: function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir=NULL,$abs=0,$tparams='',$size='')
105 * 1637: function getThumbNail($thumbScript,$theFile,$tparams='',$size='')
106 * 1654: function titleAttribForPages($row,$perms_clause='',$includeAttrib=1)
107 * 1716: function getRecordIconAltText($row,$table='pages')
108 * 1758: function getLabelFromItemlist($table,$col,$key)
109 * 1784: function getItemLabel($table,$col,$printAllWrap='')
110 * 1809: function getRecordTitle($table,$row,$prep=0)
111 * 1847: function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0,$noRecordLookup=FALSE,$uid=0)
112 * 2009: function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0,$uid=0)
113 * 2033: function getFileIcon($ext)
114 * 2047: function getCommonSelectFields($table,$prefix='')
115 * 2090: function makeConfigForm($configArray,$defaults,$dataPrefix)
117 * SECTION: Backend Modules API functions
118 * 2165: function helpTextIcon($table,$field,$BACK_PATH,$force=0)
119 * 2187: function helpText($table,$field,$BACK_PATH,$styleAttrib='')
120 * 2239: function cshItem($table,$field,$BACK_PATH,$wrap='',$onlyIconMode=FALSE, $styleAttrib='')
121 * 2277: function editOnClick($params,$backPath='',$requestUri='')
122 * 2296: function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='',$addGetVars='',$switchFocus=TRUE)
123 * 2328: function getModTSconfig($id,$TSref)
124 * 2349: function getFuncMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')
125 * 2392: function getFuncCheck($mainParams,$elementName,$currentValue,$script='',$addparams='',$tagParams='')
126 * 2417: function getFuncInput($mainParams,$elementName,$currentValue,$size=10,$script="",$addparams="")
127 * 2438: function unsetMenuItems($modTSconfig,$itemArray,$TSref)
128 * 2461: function getSetUpdateSignal($set='')
129 * 2512: function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
132 * 2585: function compilePreviewKeyword($getVarsStr, $beUserUid, $ttl=172800)
133 * 2613: function lockRecords($table='',$uid=0,$pid=0)
134 * 2642: function isRecordLocked($table,$uid)
135 * 2682: function exec_foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='')
136 * 2763: function getTCEFORM_TSconfig($table,$row)
137 * 2814: function getTSconfig_pidValue($table,$uid,$pid)
138 * 2844: function getPidForModTSconfig($table,$uid,$pid)
139 * 2860: function getTSCpid($table,$uid,$pid)
140 * 2876: function firstDomainRecord($rootLine)
141 * 2898: function getDomainStartPage($domain, $path='')
142 * 2928: function RTEsetup($RTEprop,$table,$field,$type='')
143 * 2947: function &RTEgetObj()
144 * 2986: function &softRefParserObj($spKey)
145 * 3018: function explodeSoftRefParserList($parserList)
146 * 3050: function isModuleSetInTBE_MODULES($modName)
147 * 3073: function referenceCount($table,$ref,$msg='')
149 * SECTION: Workspaces / Versioning
150 * 3132: function selectVersionsOfRecord($table, $uid, $fields='*', $workspace=0)
151 * 3180: function fixVersioningPid($table,&$rr,$ignoreWorkspaceMatch=FALSE)
152 * 3220: function workspaceOL($table,&$row,$wsid=-99)
153 * 3268: function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields='*')
154 * 3297: function getLiveVersionOfRecord($table,$uid,$fields='*')
155 * 3319: function isPidInVersionizedBranch($pid, $table='',$returnStage=FALSE)
156 * 3342: function versioningPlaceholderClause($table)
157 * 3356: function countVersionsOfRecordsOnPage($workspace,$pageId, $allTables=FALSE)
158 * 3391: function wsMapId($table,$uid)
160 * SECTION: Miscellaneous
161 * 3421: function typo3PrintError($header,$text,$js='',$head=1)
162 * 3465: function TYPO3_copyRightNotice()
163 * 3489: function displayWarningMessages()
164 * 3546: function getPathType_web_nonweb($path)
165 * 3558: function ADMCMD_previewCmds($pageinfo)
166 * 3580: function processParams($params)
167 * 3606: function getListOfBackendModules($name,$perms_clause,$backPath='',$script='index.php')
169 * TOTAL FUNCTIONS: 99
170 * (This index is automatically created/updated by the extension "extdeveval")
174 require_once (PATH_t3lib
.'class.t3lib_loaddbgroup.php');
178 * Standard functions available for the TYPO3 backend.
179 * Don't instantiate - call functions with "t3lib_BEfunc::" prefixed the function name.
181 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
189 /*******************************************
191 * SQL-related, selecting records, searching
193 *******************************************/
197 * Returns the WHERE clause " AND NOT [tablename].[deleted-field]" if a deleted-field is configured in $TCA for the tablename, $table
198 * 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!)
199 * 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.
202 * @param string Table name present in $TCA
203 * @param string Table alias if any
204 * @return string WHERE clause for filtering out deleted records, eg " AND tablename.deleted=0"
206 function deleteClause($table,$tableAlias='') {
208 if ($TCA[$table]['ctrl']['delete']) {
209 return ' AND '.($tableAlias ?
$tableAlias : $table).'.'.$TCA[$table]['ctrl']['delete'].'=0';
216 * Gets record with uid=$uid from $table
217 * You can set $field to a list of fields (default is '*')
218 * Additional WHERE clauses can be added by $where (fx. ' AND blabla=1')
219 * Will automatically check if records has been deleted and if so, not return anything.
220 * $table must be found in $TCA
223 * @param string Table name present in $TCA
224 * @param integer UID of record
225 * @param string List of fields to select
226 * @param string Additional WHERE clause, eg. " AND blablabla=0"
227 * @param boolean Use the deleteClause to check if a record is deleted (default true)
228 * @return array Returns the row if found, otherwise nothing
230 function getRecord($table,$uid,$fields='*',$where='',$useDeleteClause=true) {
231 if ($GLOBALS['TCA'][$table]) {
232 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
235 'uid='.intval($uid).($useDeleteClause ? t3lib_BEfunc
::deleteClause($table) : '').$where
237 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
238 $GLOBALS['TYPO3_DB']->sql_free_result($res);
246 * Like getRecord(), but overlays workspace version if any.
248 * @param string Table name present in $TCA
249 * @param integer UID of record
250 * @param string List of fields to select
251 * @param string Additional WHERE clause, eg. " AND blablabla=0"
252 * @param boolean Use the deleteClause to check if a record is deleted (default true)
253 * @return array Returns the row if found, otherwise nothing
255 function getRecordWSOL($table,$uid,$fields='*',$where='',$useDeleteClause=true) {
256 if ($fields !== '*') {
257 $internalFields = t3lib_div
::uniqueList($fields.',uid,pid'.($table == 'pages' ?
',t3ver_swapmode' : ''));
258 $row = t3lib_BEfunc
::getRecord($table,$uid,$internalFields,$where,$useDeleteClause);
259 t3lib_BEfunc
::workspaceOL($table,$row);
261 if (is_array ($row)) {
262 foreach (array_keys($row) as $key) {
263 if (!t3lib_div
::inList($fields, $key) && $key{0} !== '_') {
269 $row = t3lib_BEfunc
::getRecord($table,$uid,$fields,$where);
270 t3lib_BEfunc
::workspaceOL($table,$row);
276 * Returns the first record found from $table with $where as WHERE clause
277 * This function does NOT check if a record has the deleted flag set.
278 * $table does NOT need to be configured in $TCA
279 * The query used is simply this:
280 * $query='SELECT '.$fields.' FROM '.$table.' WHERE '.$where;
281 * Usage: 5 (ext: sys_todos)
283 * @param string Table name (not necessarily in TCA)
284 * @param string WHERE clause
285 * @param string $fields is a list of fields to select, default is '*'
286 * @return array First row found, if any, FALSE otherwise
288 function getRecordRaw($table,$where='',$fields='*') {
290 if (FALSE !== ($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where, '', '', '1'))) {
291 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
292 $GLOBALS['TYPO3_DB']->sql_free_result($res);
298 * Returns records from table, $theTable, where a field ($theField) equals the value, $theValue
299 * The records are returned in an array
300 * If no records were selected, the function returns nothing
303 * @param string Table name present in $TCA
304 * @param string Field to select on
305 * @param string Value that $theField must match
306 * @param string Optional additional WHERE clauses put in the end of the query. DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
307 * @param string Optional GROUP BY field(s), if none, supply blank string.
308 * @param string Optional ORDER BY field(s), if none, supply blank string.
309 * @param string Optional LIMIT value ([begin,]max), if none, supply blank string.
310 * @param boolean Use the deleteClause to check if a record is deleted (default true)
311 * @return mixed Multidimensional array with selected records (if any is selected)
313 function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='',$useDeleteClause=true) {
315 if (is_array($TCA[$theTable])) {
316 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
319 $theField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($theValue, $theTable).
320 ($useDeleteClause ? t3lib_BEfunc
::deleteClause($theTable).' ' : '').
321 t3lib_BEfunc
::versioningPlaceholderClause($theTable).' '.
322 $whereClause, // whereClauseMightContainGroupOrderBy
328 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
331 $GLOBALS['TYPO3_DB']->sql_free_result($res);
332 if (count($rows)) return $rows;
337 * 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.
340 * @param array Array of search words
341 * @param array Array of fields
342 * @param string Table in which we are searching (for DBAL detection of quoteStr() method)
343 * @return string WHERE clause for search
344 * @deprecated Use $GLOBALS['TYPO3_DB']->searchQuery() directly!
346 function searchQuery($searchWords,$fields,$table='') {
347 return $GLOBALS['TYPO3_DB']->searchQuery($searchWords,$fields,$table);
351 * Returns a WHERE clause that can find a value ($value) in a list field ($field)
352 * 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).
353 * Is nice to look up list-relations to records or files in TYPO3 database tables.
356 * @param string Table field name
357 * @param string Value to find in list
358 * @return string WHERE clause for a query
359 * @deprecated Use $GLOBALS['TYPO3_DB']->listQuery() directly!
361 function listQuery($field,$value) {
362 return $GLOBALS['TYPO3_DB']->listQuery($field,$value,'');
366 * Makes an backwards explode on the $str and returns an array with ($table,$uid).
367 * Example: tt_content_45 => array('tt_content',45)
370 * @param string [tablename]_[uid] string to explode
373 function splitTable_Uid($str) {
374 list($uid,$table) = explode('_',strrev($str),2);
375 return array(strrev($table),strrev($uid));
379 * Returns a list of pure integers based on $in_list being a list of records with table-names prepended.
380 * 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.
381 * Usage: 1 (t3lib_userauthgroup)
383 * @param string Input list
384 * @param string Table name from which ids is returned
385 * @param string $default_tablename denotes what table the number '45' is from (if nothing is prepended on the value)
386 * @return string List of ids
388 function getSQLselectableList($in_list,$tablename,$default_tablename) {
390 if ((string)trim($in_list)!='') {
391 $tempItemArray = explode(',',trim($in_list));
392 while(list($key,$val)=each($tempItemArray)) {
394 $parts = explode('_',$val,2);
395 if ((string)trim($parts[0])!='') {
396 $theID = intval(strrev($parts[0]));
397 $theTable = trim($parts[1]) ?
strrev(trim($parts[1])) : $default_tablename;
398 if ($theTable==$tablename) {$list[]=$theID;}
402 return implode(',',$list);
406 * Backend implementation of enableFields()
407 * Notice that "fe_groups" is not selected for - only disabled, starttime and endtime.
408 * Notice that deleted-fields are NOT filtered - you must ALSO call deleteClause in addition.
409 * $GLOBALS["SIM_EXEC_TIME"] is used for date.
412 * @param string $table is the table from which to return enableFields WHERE clause. Table name must have a 'ctrl' section in $TCA.
413 * @param boolean $inv means that the query will select all records NOT VISIBLE records (inverted selection)
414 * @return string WHERE clause part
416 function BEenableFields($table,$inv=0) {
417 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
420 if (is_array($ctrl)) {
421 if (is_array($ctrl['enablecolumns'])) {
422 if ($ctrl['enablecolumns']['disabled']) {
423 $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
424 $query[]=$field.'=0';
425 $invQuery[]=$field.'!=0';
427 if ($ctrl['enablecolumns']['starttime']) {
428 $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
429 $query[]='('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
430 $invQuery[]='('.$field.'!=0 AND '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
432 if ($ctrl['enablecolumns']['endtime']) {
433 $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
434 $query[]='('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
435 $invQuery[]='('.$field.'!=0 AND '.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
439 $outQ = ' AND '.($inv ?
'('.implode(' OR ',$invQuery).')' : implode(' AND ',$query));
453 /*******************************************
455 * SQL-related, DEPRECATED functions
456 * (use t3lib_DB functions instead)
458 *******************************************/
462 * Returns a SELECT query, selecting fields ($select) from two/three tables joined
463 * $local_table and $mm_table is mandatory. $foreign_table is optional.
464 * The JOIN is done with [$local_table].uid <--> [$mm_table].uid_local / [$mm_table].uid_foreign <--> [$foreign_table].uid
465 * 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.
466 * DEPRECATED - Use $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query() instead since that will return the result pointer while this returns the query. Using this function may make your application less fitted for DBAL later.
468 * @param string Field list for SELECT
469 * @param string Tablename, local table
470 * @param string Tablename, relation table
471 * @param string Tablename, foreign table
472 * @param string Optional additional WHERE clauses put in the end of the query. DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
473 * @param string Optional GROUP BY field(s), if none, supply blank string.
474 * @param string Optional ORDER BY field(s), if none, supply blank string.
475 * @param string Optional LIMIT value ([begin,]max), if none, supply blank string.
476 * @return string Full SQL query
478 * @see t3lib_DB::exec_SELECT_mm_query()
480 function mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='') {
481 $query = $GLOBALS['TYPO3_DB']->SELECTquery(
483 $local_table.','.$mm_table.($foreign_table?
','.$foreign_table:''),
484 $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?
' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').' '.
485 $whereClause, // whereClauseMightContainGroupOrderBy
494 * Creates an INSERT SQL-statement for $table from the array with field/value pairs $fields_values.
495 * DEPRECATED - $GLOBALS['TYPO3_DB']->INSERTquery() directly instead! But better yet, use $GLOBALS['TYPO3_DB']->exec_INSERTquery()
497 * @param string Table name
498 * @param array Field values as key=>value pairs.
499 * @return string Full SQL query for INSERT
502 function DBcompileInsert($table,$fields_values) {
503 return $GLOBALS['TYPO3_DB']->INSERTquery($table, $fields_values);
507 * Creates an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values.
508 * DEPRECATED - $GLOBALS['TYPO3_DB']->UPDATEquery() directly instead! But better yet, use $GLOBALS['TYPO3_DB']->exec_UPDATEquery()
510 * @param string Database tablename
511 * @param string WHERE clause, eg. "uid=1"
512 * @param array Field values as key=>value pairs.
513 * @return string Full SQL query for UPDATE
516 function DBcompileUpdate($table,$where,$fields_values) {
517 return $GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fields_values);
529 /*******************************************
531 * Page tree, TCA related
533 *******************************************/
536 * 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.
537 * By default deleted pages are filtered.
538 * 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.
541 * @param integer Page id for which to create the root line.
542 * @param string $clause can be used to select other criteria. It would typically be where-clauses that stops the process if we meet a page, the user has no reading access to.
543 * @param boolean If true, version overlay is applied. This must be requested specifically because it is usually only wanted when the rootline is used for visual output while for permission checking you want the raw thing!
544 * @return array Root line array, all the way to the page tree root (or as far as $clause allows!)
546 function BEgetRootLine($uid,$clause='',$workspaceOL=FALSE) {
547 if (is_array($GLOBALS['T3_VAR']['BEgetRootLine_cache'][$uid][$clause][$workspaceOL?
1:0])) {
548 return $GLOBALS['T3_VAR']['BEgetRootLine_cache'][$uid][$clause][$workspaceOL?
1:0];
552 $theRowArray = Array();
554 while ($uid!=0 && $loopCheck>0) {
556 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
557 'pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,t3ver_stage',
559 'uid='.intval($uid).' '.
560 t3lib_BEfunc
::deleteClause('pages').' '.
561 $clause // whereClauseMightContainGroupOrderBy
563 if ($GLOBALS['TYPO3_DB']->sql_error()) {
564 debug($GLOBALS['TYPO3_DB']->sql_error(),1);
566 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
567 if($workspaceOL) t3lib_BEfunc
::workspaceOL('pages',$row);
568 if (is_array($row)) {
569 t3lib_BEfunc
::fixVersioningPid('pages',$row);
571 $theRowArray[] = $row;
577 if ($uid==0) {$theRowArray[] = Array('uid'=>0,'title'=>'');}
578 if (is_array($theRowArray)) {
580 $c=count($theRowArray);
581 while(list($key,$val)=each($theRowArray)) {
583 $output[$c]['uid'] = $val['uid'];
584 $output[$c]['pid'] = $val['pid'];
585 if (isset($val['_ORIG_pid'])) $output[$c]['_ORIG_pid'] = $val['_ORIG_pid'];
586 $output[$c]['title'] = $val['title'];
587 $output[$c]['TSconfig'] = $val['TSconfig'];
588 $output[$c]['is_siteroot'] = $val['is_siteroot'];
589 $output[$c]['storage_pid'] = $val['storage_pid'];
590 $output[$c]['t3ver_oid'] = $val['t3ver_oid'];
591 $output[$c]['t3ver_wsid'] = $val['t3ver_wsid'];
592 $output[$c]['t3ver_state'] = $val['t3ver_state'];
593 $output[$c]['t3ver_swapmode'] = $val['t3ver_swapmode'];
594 $output[$c]['t3ver_stage'] = $val['t3ver_stage'];
597 $GLOBALS['T3_VAR']['BEgetRootLine_cache'][$pid][$clause][$workspaceOL?
1:0] = $output;
603 * Opens the page tree to the specified page id
605 * @param integer Page id.
606 * @param boolean If set, then other open branches are closed.
609 function openPageTree($pid,$clearExpansion) {
612 // Get current expansion data:
613 if ($clearExpansion) {
614 $expandedPages = array();
616 $expandedPages = unserialize($BE_USER->uc
['browseTrees']['browsePages']);
620 $rL = t3lib_BEfunc
::BEgetRootLine($pid);
622 // First, find out what mount index to use (if more than one DB mount exists):
624 $mountKeys = array_flip($BE_USER->returnWebmounts());
625 foreach($rL as $rLDat) {
626 if (isset($mountKeys[$rLDat['uid']])) {
627 $mountIndex = $mountKeys[$rLDat['uid']];
632 // Traverse rootline and open paths:
633 foreach($rL as $rLDat) {
634 $expandedPages[$mountIndex][$rLDat['uid']] = 1;
638 $BE_USER->uc
['browseTrees']['browsePages'] = serialize($expandedPages);
643 * Returns the path (visually) of a page $uid, fx. "/First page/Second page/Another subpage"
644 * Each part of the path will be limited to $titleLimit characters
645 * Deleted pages are filtered out.
648 * @param integer Page uid for which to create record path
649 * @param string $clause is additional where clauses, eg. "
650 * @param integer Title limit
651 * @param integer Title limit of Full title (typ. set to 1000 or so)
652 * @return mixed Path of record (string) OR array with short/long title if $fullTitleLimit is set.
654 function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0) {
655 if (!$titleLimit) { $titleLimit=1000; }
658 $output = $fullOutput = '/';
659 while ($uid!=0 && $loopCheck>0) {
661 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
662 'uid,pid,title,t3ver_oid,t3ver_wsid,t3ver_swapmode',
665 t3lib_BEfunc
::deleteClause('pages').
666 (strlen(trim($clause)) ?
' AND '.$clause : '')
668 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
669 t3lib_BEfunc
::workspaceOL('pages',$row);
670 if (is_array($row)) {
671 t3lib_BEfunc
::fixVersioningPid('pages',$row);
673 if ($row['_ORIG_pid'] && $row['t3ver_swapmode']>0) { // Branch points
674 $output = ' [#VEP#]'.$output; // Adding visual token - Versioning Entry Point - that tells that THIS position was where the versionized branch got connected to the main tree. I will have to find a better name or something...
677 $output = '/'.t3lib_div
::fixed_lgd_cs(strip_tags($row['title']),$titleLimit).$output;
678 if ($fullTitleLimit) $fullOutput = '/'.t3lib_div
::fixed_lgd_cs(strip_tags($row['title']),$fullTitleLimit).$fullOutput;
685 if ($fullTitleLimit) {
686 return array($output, $fullOutput);
693 * Returns an array with the exclude-fields as defined in TCA
694 * Used for listing the exclude-fields in be_groups forms
695 * Usage: 2 (t3lib_tceforms + t3lib_transferdata)
697 * @return array Array of arrays with excludeFields (fieldname, table:fieldname) from all TCA entries
699 function getExcludeFields() {
702 $theExcludeArray = Array();
703 $tc_keys = array_keys($TCA);
704 foreach($tc_keys as $table) {
706 t3lib_div
::loadTCA($table);
707 // All field names configured:
708 if (is_array($TCA[$table]['columns'])) {
709 $f_keys = array_keys($TCA[$table]['columns']);
710 foreach($f_keys as $field) {
711 if ($TCA[$table]['columns'][$field]['exclude']) {
712 // Get Human Readable names of fields and table:
713 $Fname=$GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
715 $theExcludeArray[] = Array($Fname , $table.':'.$field);
720 return $theExcludeArray;
724 * Returns an array with explicit Allow/Deny fields.
725 * Used for listing these field/value pairs in be_groups forms
727 * @return array Array with information from all of $TCA
729 function getExplicitAuthFieldValues() {
734 'ALLOW' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.allow'),
735 'DENY' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.deny'),
739 $allowDenyOptions = Array();
740 $tc_keys = array_keys($TCA);
741 foreach($tc_keys as $table) {
744 t3lib_div
::loadTCA($table);
746 // All field names configured:
747 if (is_array($TCA[$table]['columns'])) {
748 $f_keys = array_keys($TCA[$table]['columns']);
749 foreach($f_keys as $field) {
750 $fCfg = $TCA[$table]['columns'][$field]['config'];
751 if ($fCfg['type']=='select' && $fCfg['authMode']) {
754 if (is_array($fCfg['items'])) {
755 // Get Human Readable names of fields and table:
756 $allowDenyOptions[$table.':'.$field]['tableFieldLabel'] = $GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
759 foreach($fCfg['items'] as $iVal) {
760 if (strcmp($iVal[1],'')) { // Values '' is not controlled by this setting.
764 switch((string)$fCfg['authMode']) {
765 case 'explicitAllow':
772 if (!strcmp($iVal[4],'EXPL_ALLOW')) {
774 } elseif (!strcmp($iVal[4],'EXPL_DENY')) {
782 $allowDenyOptions[$table.':'.$field]['items'][$iVal[1]] = array($iMode, $GLOBALS['LANG']->sl($iVal[0]), $adLabel[$iMode]);
792 return $allowDenyOptions;
796 * Returns an array with system languages:
798 * @return array Array with languages
800 function getSystemLanguages() {
802 // Initialize, add default language:
803 $sysLanguages = array();
804 $sysLanguages[] = array('Default language', 0);
806 // Traverse languages
807 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,flag','sys_language','pid=0'.t3lib_BEfunc
::deleteClause('sys_language'));
808 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
809 $sysLanguages[] = array($row['title'].' ['.$row['uid'].']', $row['uid'], ($row['flag'] ?
'flags/'.$row['flag'] : ''));
812 return $sysLanguages;
816 * 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. Thus is works as an access check that returns a page record if access was granted, otherwise not.
817 * If $id is zero a pseudo root-page with "_thePath" set is returned IF the current BE_USER is admin.
818 * In any case ->isInWebMount must return true for the user (regardless of $perms_clause)
821 * @param integer Page uid for which to check read-access
822 * @param string $perms_clause is typically a value generated with $BE_USER->getPagePermsClause(1);
823 * @return array Returns page record if OK, otherwise false.
825 function readPageAccess($id,$perms_clause) {
826 if ((string)$id!='') {
829 if ($GLOBALS['BE_USER']->isAdmin()) {
831 $pageinfo['_thePath'] = $path;
835 $pageinfo = t3lib_BEfunc
::getRecord('pages',$id,'*',($perms_clause ?
' AND '.$perms_clause : ''));
836 if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause)) {
837 t3lib_BEfunc
::workspaceOL('pages', $pageinfo);
838 if (is_array($pageinfo)) {
839 t3lib_BEfunc
::fixVersioningPid('pages', $pageinfo);
840 list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc
::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
850 * Returns the "types" configuration parsed into an array for the record, $rec, from table, $table
853 * @param string Table name (present in TCA)
854 * @param array Record from $table
855 * @param boolean If $useFieldNameAsKey is set, then the fieldname is associative keys in the return array, otherwise just numeric keys.
858 function getTCAtypes($table,$rec,$useFieldNameAsKey=0) {
861 t3lib_div
::loadTCA($table);
865 $fieldValue = t3lib_BEfunc
::getTCAtypeValue($table,$rec);
868 $typesConf = $TCA[$table]['types'][$fieldValue];
870 // Get fields list and traverse it
871 $fieldList = explode(',', $typesConf['showitem']);
872 $altFieldList = array();
874 // Traverse fields in types config and parse the configuration into a nice array:
875 foreach($fieldList as $k => $v) {
876 list($pFieldName, $pAltTitle, $pPalette, $pSpec) = t3lib_div
::trimExplode(';', $v);
877 $defaultExtras = is_array($TCA[$table]['columns'][$pFieldName]) ?
$TCA[$table]['columns'][$pFieldName]['defaultExtras'] : '';
878 $specConfParts = t3lib_BEfunc
::getSpecConfParts($pSpec, $defaultExtras);
880 $fieldList[$k]=array(
881 'field' => $pFieldName,
882 'title' => $pAltTitle,
883 'palette' => $pPalette,
884 'spec' => $specConfParts,
887 if ($useFieldNameAsKey) {
888 $altFieldList[$fieldList[$k]['field']] = $fieldList[$k];
891 if ($useFieldNameAsKey) {
892 $fieldList = $altFieldList;
901 * Returns the "type" value of $rec from $table which can be used to look up the correct "types" rendering section in $TCA
902 * If no "type" field is configured in the "ctrl"-section of the $TCA for the table, zero is used.
903 * 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)
906 * @param string Table name present in TCA
907 * @param array Record from $table
908 * @return string Field value
911 function getTCAtypeValue($table,$rec) {
914 // 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.
915 t3lib_div
::loadTCA($table);
917 $field = $TCA[$table]['ctrl']['type'];
918 $fieldValue = $field ?
($rec[$field] ?
$rec[$field] : 0) : 0;
919 if (!is_array($TCA[$table]['types'][$fieldValue])) $fieldValue = 1;
925 * Parses a part of the field lists in the "types"-section of $TCA arrays, namely the "special configuration" at index 3 (position 4)
926 * Elements are splitted by ":" and within those parts, parameters are splitted by "|".
927 * 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
930 * @param string Content from the "types" configuration of TCA (the special configuration) - see description of function
931 * @param string The ['defaultExtras'] value from field configuration
934 function getSpecConfParts($str, $defaultExtras) {
936 // Add defaultExtras:
937 $specConfParts = t3lib_div
::trimExplode(':', $defaultExtras.':'.$str, 1);
940 if (count($specConfParts)) {
941 foreach($specConfParts as $k2 => $v2) {
942 unset($specConfParts[$k2]);
943 if (ereg('(.*)\[(.*)\]',$v2,$reg)) {
944 $specConfParts[trim($reg[1])] = array(
945 'parameters' => t3lib_div
::trimExplode('|', $reg[2], 1)
948 $specConfParts[trim($v2)] = 1;
952 $specConfParts = array();
954 return $specConfParts;
958 * Takes an array of "[key]=[value]" strings and returns an array with the keys set as keys pointing to the value.
959 * Better see it in action! Find example in Inside TYPO3
962 * @param array Array of "[key]=[value]" strings to convert.
965 function getSpecConfParametersFromArray($pArr) {
967 if (is_array($pArr)) {
969 while(list($k,$v)=each($pArr)) {
970 $parts=explode('=',$v,2);
971 if (count($parts)==2) {
972 $out[trim($parts[0])]=trim($parts[1]);
982 * Finds the Data Structure for a FlexForm field
983 * NOTE ON data structures for deleted records: This function may fail to deliver the data structure for a record for a few reasons: a) The data structure could be deleted (either with deleted-flagged or hard-deleted), b) the data structure is fetched using the ds_pointerField_searchParent in which case any deleted record on the route to the final location of the DS will make it fail. In theory, we can solve the problem in the case where records that are deleted-flagged keeps us from finding the DS - this is done at the markers ###NOTE_A### where we make sure to also select deleted records. However, we generally want the DS lookup to fail for deleted records since for the working website we expect a deleted-flagged record to be as inaccessible as one that is completely deleted from the DB. Any way we look at it, this may lead to integrity problems of the reference index and even lost files if attached. However, that is not really important considering that a single change to a data structure can instantly invalidate large amounts of the reference index which we do accept as a cost for the flexform features. Other than requiring a reference index update, deletion of/changes in data structure or the failure to look them up when completely deleting records may lead to lost files in the uploads/ folders since those are now without a proper reference.
986 * @param array Field config array
987 * @param array Record data
988 * @param string The table name
989 * @param string Optional fieldname passed to hook object
990 * @param boolean Boolean; If set, workspace overlay is applied to records. This is correct behaviour for all presentation and export, but NOT if you want a true reflection of how things are in the live workspace.
991 * @param integer SPECIAL CASES: Use this, if the DataStructure may come from a parent record and the INPUT row doesn't have a uid yet (hence, the pid cannot be looked up). Then it is necessary to supply a PID value to search recursively in for the DS (used from TCEmain)
992 * @return mixed If array, the data structure was found and returned as an array. Otherwise (string) it is an error message.
993 * @see t3lib_TCEforms::getSingleField_typeFlex()
995 function getFlexFormDS($conf,$row,$table,$fieldName='',$WSOL=TRUE,$newRecordPidValue=0) {
996 global $TYPO3_CONF_VARS;
998 // Get pointer field etc from TCA-config:
999 $ds_pointerField = $conf['ds_pointerField'];
1000 $ds_array = $conf['ds'];
1001 $ds_tableField = $conf['ds_tableField'];
1002 $ds_searchParentField = $conf['ds_pointerField_searchParent'];
1004 // Find source value:
1005 $dataStructArray='';
1006 if (is_array($ds_array)) { // If there is a data source array, that takes precedence
1007 // If a pointer field is set, take the value from that field in the $row array and use as key.
1008 if ($ds_pointerField) {
1010 // Up to two pointer fields can be specified in a comma separated list.
1011 $pointerFields = t3lib_div
::trimExplode(',', $ds_pointerField);
1012 if(count($pointerFields) == 2) { // If we have two pointer fields, the array keys should contain both field values separated by comma. The asterisk "*" catches all values. For backwards compatibility, it's also possible to specify only the value of the first defined ds_pointerField.
1013 if($ds_array[$row[$pointerFields[0]].','.$row[$pointerFields[1]]]) { // Check if we have a DS for the combination of both pointer fields values
1014 $srcPointer = $row[$pointerFields[0]].','.$row[$pointerFields[1]];
1015 } elseif($ds_array[$row[$pointerFields[1]].',*']) { // Check if we have a DS for the value of the first pointer field suffixed with ",*"
1016 $srcPointer = $row[$pointerFields[1]].',*';
1017 } elseif($ds_array['*,'.$row[$pointerFields[1]]]) { // Check if we have a DS for the value of the second pointer field prefixed with "*,"
1018 $srcPointer = '*,'.$row[$pointerFields[1]];
1019 } elseif($ds_array[$row[$pointerFields[0]]]) { // Check if we have a DS for just the value of the first pointer field (mainly for backwards compatibility)
1020 $srcPointer = $row[$pointerFields[0]];
1023 $srcPointer = $row[$pointerFields[0]];
1026 $srcPointer = isset($ds_array[$srcPointer]) ?
$srcPointer : 'default';
1027 } else $srcPointer='default';
1029 // 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.
1030 if (substr($ds_array[$srcPointer],0,5)=='FILE:') {
1031 $file = t3lib_div
::getFileAbsFileName(substr($ds_array[$srcPointer],5));
1032 if ($file && @is_file
($file)) {
1033 $dataStructArray = t3lib_div
::xml2array(t3lib_div
::getUrl($file));
1034 } else $dataStructArray = 'The file "'.substr($ds_array[$srcPointer],5).'" in ds-array key "'.$srcPointer.'" was not found ("'.$file.'")'; // Error message.
1036 $dataStructArray = t3lib_div
::xml2array($ds_array[$srcPointer]);
1039 } elseif ($ds_pointerField) { // If pointer field AND possibly a table/field is set:
1040 // Value of field pointed to:
1041 $srcPointer = $row[$ds_pointerField];
1043 // Searching recursively back if 'ds_pointerField_searchParent' is defined (typ. a page rootline, or maybe a tree-table):
1044 if ($ds_searchParentField && !$srcPointer) {
1045 $rr = t3lib_BEfunc
::getRecord($table,$row['uid'],'uid,'.$ds_searchParentField); // Get the "pid" field - we cannot know that it is in the input record! ###NOTE_A###
1047 t3lib_BEfunc
::workspaceOL($table,$rr);
1048 t3lib_BEfunc
::fixVersioningPid($table,$rr,TRUE); // Added "TRUE" 23/03/06 before 4.0. (Also to similar call below!). Reason: When t3lib_refindex is scanning the system in Live workspace all Pages with FlexForms will not find their inherited datastructure. Thus all references from workspaces are removed! Setting TRUE means that versioning PID doesn't check workspace of the record. I can't see that this should give problems anywhere. See more information inside t3lib_refindex!
1050 $uidAcc=array(); // Used to avoid looping, if any should happen.
1051 $subFieldPointer = $conf['ds_pointerField_searchParent_subField'];
1052 while(!$srcPointer) {
1054 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1055 'uid,'.$ds_pointerField.','.$ds_searchParentField.($subFieldPointer?
','.$subFieldPointer:''),
1057 'uid='.intval($newRecordPidValue ?
$newRecordPidValue : $rr[$ds_searchParentField]).t3lib_BEfunc
::deleteClause($table) ###NOTE_A###
1059 $newRecordPidValue = 0;
1060 $rr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
1062 // break if no result from SQL db or if looping...
1063 if (!is_array($rr) ||
isset($uidAcc[$rr['uid']])) break;
1064 $uidAcc[$rr['uid']]=1;
1067 t3lib_BEfunc
::workspaceOL($table,$rr);
1068 t3lib_BEfunc
::fixVersioningPid($table,$rr,TRUE);
1070 $srcPointer = ($subFieldPointer && $rr[$subFieldPointer]) ?
$rr[$subFieldPointer] : $rr[$ds_pointerField];
1074 // If there is a srcPointer value:
1076 if (t3lib_div
::testInt($srcPointer)) { // If integer, then its a record we will look up:
1077 list($tName,$fName) = explode(':',$ds_tableField,2);
1078 if ($tName && $fName && is_array($GLOBALS['TCA'][$tName])) {
1079 $dataStructRec = t3lib_BEfunc
::getRecord($tName, $srcPointer);
1081 t3lib_BEfunc
::workspaceOL($tName,$dataStructRec);
1083 $dataStructArray = t3lib_div
::xml2array($dataStructRec[$fName]);
1084 } else $dataStructArray = 'No tablename ('.$tName.') or fieldname ('.$fName.') was found an valid!';
1085 } else { // Otherwise expect it to be a file:
1086 $file = t3lib_div
::getFileAbsFileName($srcPointer);
1087 if ($file && @is_file
($file)) {
1088 $dataStructArray = t3lib_div
::xml2array(t3lib_div
::getUrl($file));
1089 } else $dataStructArray='The file "'.$srcPointer.'" was not found ("'.$file.'")'; // Error message.
1091 } else $dataStructArray='No source value in fieldname "'.$ds_pointerField.'"'; // Error message.
1092 } else $dataStructArray='No proper configuration!';
1094 // Hook for post-processing the Flexform DS. Introduces the possibility to configure Flexforms via TSConfig
1095 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'])) {
1096 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'] as $classRef) {
1097 $hookObj = &t3lib_div
::getUserObj($classRef);
1098 if (method_exists($hookObj, 'getFlexFormDS_postProcessDS')) {
1099 $hookObj->getFlexFormDS_postProcessDS($dataStructArray, $conf, $row, $table, $fieldName);
1104 return $dataStructArray;
1124 /*******************************************
1128 *******************************************/
1131 * Stores the string value $data in the 'cache_hash' table with the hash key, $hash, and visual/symbolic identification, $ident
1132 * IDENTICAL to the function by same name found in t3lib_page:
1135 * @param string 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)
1136 * @param string The data string. If you want to store an array, then just serialize it first.
1137 * @param string $ident is just a textual identification in order to inform about the content! May be 20 characters long.
1140 function storeHash($hash,$data,$ident) {
1141 $insertFields = array(
1147 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
1148 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
1152 * Returns string value stored for the hash string in the table "cache_hash"
1153 * Can be used to retrieved a cached value
1154 * IDENTICAL to the function by same name found in t3lib_page
1157 * @param string Hash key, 32 bytes hex
1158 * @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.
1161 function getHash($hash,$expTime=0) {
1162 // if expTime is not set, the hash will never expire
1163 $expTime = intval($expTime);
1165 $whereAdd = ' AND tstamp > '.(time()-$expTime);
1167 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').$whereAdd);
1168 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
1169 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1171 return (is_array($row) ?
$row['content'] : null);
1181 /*******************************************
1183 * TypoScript related
1185 *******************************************/
1188 * Returns the Page TSconfig for page with id, $id
1189 * Requires class "t3lib_TSparser"
1190 * Usage: 26 (spec. in ext info_pagetsconfig)
1192 * @param integer Page uid for which to create Page TSconfig
1193 * @param array If $rootLine is an array, that is used as rootline, otherwise rootline is just calculated
1194 * @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.
1195 * @return array Page TSconfig
1196 * @see t3lib_TSparser
1198 function getPagesTSconfig($id,$rootLine='',$returnPartArray=0) {
1200 if (!is_array($rootLine)) {
1201 $rootLine = t3lib_BEfunc
::BEgetRootLine($id,'',TRUE);
1203 ksort($rootLine); // Order correctly
1204 $TSdataArray = array();
1205 $TSdataArray['defaultPageTSconfig']=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']; // Setting default configuration:
1206 foreach($rootLine as $k => $v) {
1207 $TSdataArray['uid_'.$v['uid']]=$v['TSconfig'];
1209 $TSdataArray = t3lib_TSparser
::checkIncludeLines_array($TSdataArray);
1210 if ($returnPartArray) {
1211 return $TSdataArray;
1214 // Parsing the user TS (or getting from cache)
1215 $userTS = implode($TSdataArray,chr(10).'[GLOBAL]'.chr(10));
1216 $hash = md5('pageTS:'.$userTS);
1217 $cachedContent = t3lib_BEfunc
::getHash($hash,0);
1218 $TSconfig = array();
1219 if (isset($cachedContent)) {
1220 $TSconfig = unserialize($cachedContent);
1222 $parseObj = t3lib_div
::makeInstance('t3lib_TSparser');
1223 $parseObj->parse($userTS);
1224 $TSconfig = $parseObj->setup
;
1225 t3lib_BEfunc
::storeHash($hash,serialize($TSconfig),'PAGES_TSconfig');
1228 // get User TSconfig overlay
1229 $userTSconfig = $GLOBALS['BE_USER']->userTS
['page.'];
1230 if (is_array($userTSconfig)) {
1231 $TSconfig = t3lib_div
::array_merge_recursive_overrule($TSconfig, $userTSconfig);
1237 * Updates Page TSconfig for a page with $id
1238 * 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.
1239 * $impParams can be supplied as already known Page TSconfig, otherwise it's calculated.
1241 * THIS DOES NOT CHECK ANY PERMISSIONS. SHOULD IT?
1242 * More documentation is needed.
1244 * Usage: 1 (ext. direct_mail)
1246 * @param integer Page id
1247 * @param array Page TS array to write
1248 * @param string Prefix for object paths
1249 * @param array [Description needed.]
1252 * @see implodeTSParams(), getPagesTSconfig()
1254 function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='') {
1256 if (is_array($pageTS) && $id>0) {
1257 if (!is_array($impParams)) {
1258 $impParams =t3lib_BEfunc
::implodeTSParams(t3lib_BEfunc
::getPagesTSconfig($id));
1262 while(list($f,$v)=each($pageTS)) {
1263 $f = $TSconfPrefix.$f;
1264 if ((!isset($impParams[$f])&&trim($v)) ||
strcmp(trim($impParams[$f]),trim($v))) {
1269 // Get page record and TS config lines
1270 $pRec = t3lib_befunc
::getRecord('pages',$id);
1271 $TSlines = explode(chr(10),$pRec['TSconfig']);
1272 $TSlines = array_reverse($TSlines);
1273 // Reset the set of changes.
1275 while(list($f,$v)=each($set)) {
1278 while(list($ki,$kv)=each($TSlines)) {
1279 if (substr($kv,0,strlen($f)+
1)==$f.'=') {
1280 $TSlines[$ki]=$f.'='.$v;
1286 $TSlines = array_reverse($TSlines);
1287 $TSlines[]=$f.'='.$v;
1288 $TSlines = array_reverse($TSlines);
1291 $TSlines = array_reverse($TSlines);
1293 // store those changes
1294 $TSconf = implode(chr(10),$TSlines);
1296 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($id), array('TSconfig' => $TSconf));
1302 * Implodes a multi dimensional TypoScript array, $p, into a one-dimentional array (return value)
1305 * @param array TypoScript structure
1306 * @param string Prefix string
1307 * @return array Imploded TypoScript objectstring/values
1309 function implodeTSParams($p,$k='') {
1310 $implodeParams=array();
1313 while(list($kb,$val)=each($p)) {
1314 if (is_array($val)) {
1315 $implodeParams = array_merge($implodeParams,t3lib_BEfunc
::implodeTSParams($val,$k.$kb));
1317 $implodeParams[$k.$kb]=$val;
1321 return $implodeParams;
1331 /*******************************************
1333 * Users / Groups related
1335 *******************************************/
1338 * Returns an array with be_users records of all user NOT DELETED sorted by their username
1339 * Keys in the array is the be_users uid
1340 * Usage: 14 (spec. ext. "beuser" and module "web_perm")
1342 * @param string Optional $fields list (default: username,usergroup,usergroup_cached_list,uid) can be used to set the selected fields
1343 * @param string Optional $where clause (fx. "AND username='pete'") can be used to limit query
1346 function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='') {
1347 $be_user_Array=Array();
1349 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_users', 'pid=0 '.$where.t3lib_BEfunc
::deleteClause('be_users'), '', 'username');
1350 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1351 $be_user_Array[$row['uid']]=$row;
1353 return $be_user_Array;
1357 * Returns an array with be_groups records (title, uid) of all groups NOT DELETED sorted by their title
1358 * Usage: 8 (spec. ext. "beuser" and module "web_perm")
1360 * @param string Field list
1361 * @param string WHERE clause
1364 function getGroupNames($fields='title,uid', $where='') {
1365 $be_group_Array = Array();
1366 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_groups', 'pid=0 '.$where.t3lib_BEfunc
::deleteClause('be_groups'), '', 'title');
1367 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1368 $be_group_Array[$row['uid']] = $row;
1370 return $be_group_Array;
1374 * Returns an array with be_groups records (like ->getGroupNames) but:
1375 * - 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.
1376 * Usage: 2 (module "web_perm" and ext. taskcenter)
1378 * @param string Field list; $fields specify the fields selected (default: title,uid)
1381 function getListGroupNames($fields='title,uid') {
1382 $exQ=' AND hide_in_lists=0';
1383 if (!$GLOBALS['BE_USER']->isAdmin()) {
1384 $exQ.=' AND uid IN ('.($GLOBALS['BE_USER']->user
['usergroup_cached_list']?
$GLOBALS['BE_USER']->user
['usergroup_cached_list']:0).')';
1386 return t3lib_BEfunc
::getGroupNames($fields,$exQ);
1390 * Returns the array $usernames with the names of all users NOT IN $groupArray changed to the uid (hides the usernames!).
1391 * If $excludeBlindedFlag is set, then these records are unset from the array $usernames
1392 * Takes $usernames (array made by t3lib_BEfunc::getUserNames()) and a $groupArray (array with the groups a certain user is member of) as input
1395 * @param array User names
1396 * @param array Group names
1397 * @param boolean If $excludeBlindedFlag is set, then these records are unset from the array $usernames
1398 * @return array User names, blinded
1400 function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0) {
1401 if (is_array($usernames) && is_array($groupArray)) {
1402 while(list($uid,$row)=each($usernames)) {
1405 if ($row['uid']!=$GLOBALS['BE_USER']->user
['uid']) {
1407 while(list(,$v)=each($groupArray)) {
1408 if ($v && t3lib_div
::inList($row['usergroup_cached_list'],$v)) {
1409 $userN = $row['username'];
1414 $userN = $row['username'];
1417 $usernames[$uid]['username']=$userN;
1418 if ($excludeBlindedFlag && !$set) {unset($usernames[$uid]);}
1425 * Corresponds to blindUserNames but works for groups instead
1426 * Usage: 2 (module web_perm)
1428 * @param array Group names
1429 * @param array Group names (reference)
1430 * @param boolean If $excludeBlindedFlag is set, then these records are unset from the array $usernames
1433 function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0) {
1434 if (is_array($groups) && is_array($groupArray)) {
1435 while(list($uid,$row)=each($groups)) {
1438 if (t3lib_div
::inArray($groupArray,$uid)) {
1439 $groupN=$row['title'];
1442 $groups[$uid]['title']=$groupN;
1443 if ($excludeBlindedFlag && !$set) {unset($groups[$uid]);}
1461 /*******************************************
1465 *******************************************/
1468 * Returns the difference in days between input $tstamp and $EXEC_TIME
1469 * Usage: 2 (class t3lib_BEfunc)
1471 * @param integer Time stamp, seconds
1474 function daysUntil($tstamp) {
1475 $delta_t = $tstamp-$GLOBALS['EXEC_TIME'];
1476 return ceil($delta_t/(3600*24));
1480 * Returns $tstamp formatted as "ddmmyy" (According to $TYPO3_CONF_VARS['SYS']['ddmmyy'])
1483 * @param integer Time stamp, seconds
1484 * @return string Formatted time
1486 function date($tstamp) {
1487 return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp);
1491 * Returns $tstamp formatted as "ddmmyy hhmm" (According to $TYPO3_CONF_VARS['SYS']['ddmmyy'] AND $TYPO3_CONF_VARS['SYS']['hhmm'])
1494 * @param integer Time stamp, seconds
1495 * @return string Formatted time
1497 function datetime($value) {
1498 return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $value);
1502 * Returns $value (in seconds) formatted as hh:mm:ss
1503 * For instance $value = 3600 + 60*2 + 3 should return "01:02:03"
1504 * Usage: 1 (class t3lib_BEfunc)
1506 * @param integer Time stamp, seconds
1507 * @param boolean Output hh:mm:ss. If false: hh:mm
1508 * @return string Formatted time
1510 function time($value, $withSeconds = TRUE) {
1511 $hh = floor($value/3600);
1512 $min = floor(($value-$hh*3600)/60);
1513 $sec = $value-$hh*3600-$min*60;
1514 $l = sprintf('%02d',$hh).':'.sprintf('%02d',$min);
1516 $l .= ':'.sprintf('%02d',$sec);
1522 * Returns the "age" in minutes / hours / days / years of the number of $seconds inputted.
1525 * @param integer $seconds could be the difference of a certain timestamp and time()
1526 * @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")
1527 * @return string Formatted time
1529 function calcAge($seconds,$labels = 'min|hrs|days|yrs') {
1530 $labelArr = explode('|',$labels);
1532 if ($seconds<0) {$prefix='-'; $seconds=abs($seconds);}
1533 if ($seconds<3600) {
1534 $seconds = round ($seconds/60).' '.trim($labelArr[0]);
1535 } elseif ($seconds<24*3600) {
1536 $seconds = round ($seconds/3600).' '.trim($labelArr[1]);
1537 } elseif ($seconds<365*24*3600) {
1538 $seconds = round ($seconds/(24*3600)).' '.trim($labelArr[2]);
1540 $seconds = round ($seconds/(365*24*3600)).' '.trim($labelArr[3]);
1542 return $prefix.$seconds;
1546 * Returns a formatted timestamp if $tstamp is set.
1547 * The date/datetime will be followed by the age in parenthesis.
1550 * @param integer Time stamp, seconds
1551 * @param integer 1/-1 depending on polarity of age.
1552 * @param string $date=="date" will yield "dd:mm:yy" formatting, otherwise "dd:mm:yy hh:mm"
1555 function dateTimeAge($tstamp,$prefix=1,$date='') {
1557 ($date=='date' ? t3lib_BEfunc
::date($tstamp) : t3lib_BEfunc
::datetime($tstamp)).
1558 ' ('.t3lib_BEfunc
::calcAge($prefix*(time()-$tstamp),$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')' : '';
1562 * Returns either title='' or alt='' attribute. This depends on the client browser and whether it supports title='' or not (which is the default)
1563 * If no $content is given only the attribute name is returned.
1564 * The returned attribute with content will have a leading space char.
1565 * Warning: Be careful to submit empty $content var - that will return just the attribute name!
1568 * @param string String to set as title-attribute. If no $content is given only the attribute name is returned.
1569 * @param boolean If $hsc is set, then content of the attribute is htmlspecialchar()'ed (which is good for XHTML and other reasons...)
1571 * @deprecated The idea made sense with older browsers, but now all browsers should support the "title" attribute - so just hardcode the title attribute instead!
1573 function titleAttrib($content='',$hsc=0) {
1575 $attrib= ($CLIENT['BROWSER']=='net'&&$CLIENT['VERSION']<5)||
$CLIENT['BROWSER']=='konqu' ?
'alt' : 'title';
1576 return strcmp($content,'')?
' '.$attrib.'="'.($hsc?
htmlspecialchars($content):$content).'"' : $attrib;
1580 * Returns alt="" and title="" attributes with the value of $content.
1583 * @param string Value for 'alt' and 'title' attributes (will be htmlspecialchars()'ed before output)
1586 function titleAltAttrib($content) {
1588 $out.=' alt="'.htmlspecialchars($content).'"';
1589 $out.=' title="'.htmlspecialchars($content).'"';
1594 * Returns a linked image-tag for thumbnail(s)/fileicons/truetype-font-previews from a database row with a list of image files in a field
1595 * All $TYPO3_CONF_VARS['GFX']['imagefile_ext'] extension are made to thumbnails + ttf file (renders font-example)
1596 * Thumbsnails are linked to the show_item.php script which will display further details.
1599 * @param array $row is the database row from the table, $table.
1600 * @param string Table name for $row (present in TCA)
1601 * @param string $field is pointing to the field with the list of image files
1602 * @param string Back path prefix for image tag src="" field
1603 * @param string Optional: $thumbScript os by default 'thumbs.php' if you don't set it otherwise
1604 * @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!)
1605 * @param boolean If set, uploaddir is NOT prepended with "../"
1606 * @param string Optional: $tparams is additional attributes for the image tags
1607 * @param integer Optional: $size is [w]x[h] of the thumbnail. 56 is default.
1608 * @return string Thumbnail image tag.
1610 function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir=NULL,$abs=0,$tparams='',$size='') {
1613 t3lib_div
::loadTCA($table);
1615 // Find uploaddir automatically
1616 $uploaddir = (is_null($uploaddir)) ?
$TCA[$table]['columns'][$field]['config']['uploadfolder'] : $uploaddir;
1617 $uploaddir = preg_replace('#/$#','',$uploaddir);
1619 // Set thumbs-script:
1620 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
1621 $thumbScript='gfx/notfound_thumb.gif';
1622 } elseif(!$thumbScript) {
1623 $thumbScript='thumbs.php';
1625 // Check and parse the size parameter
1627 if ($size = trim($size)) {
1628 $sizeParts = explode('x', $size.'x'.$size);
1629 if(!intval($sizeParts[0])) $size='';
1633 $thumbs = explode(',', $row[$field]);
1635 while(list(,$theFile)=each($thumbs)) {
1636 if (trim($theFile)) {
1637 $fI = t3lib_div
::split_fileref($theFile);
1638 $ext = $fI['fileext'];
1641 if (t3lib_div
::inList('gif,jpg,png',$ext)) {
1642 $imgInfo=@getimagesize
(PATH_site
.$uploaddir.'/'.$theFile);
1643 if (is_array($imgInfo)) {$max = max($imgInfo[0],$imgInfo[1]);}
1645 // use the original image if it's size fits to the thumbnail size
1646 if ($max && $max<=(count($sizeParts)&&max($sizeParts)?
max($sizeParts):56)) {
1647 $theFile = $url = ($abs?
'':'../').($uploaddir?
$uploaddir.'/':'').trim($theFile);
1648 $onClick = 'top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
1649 $thumbData.= '<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.$backPath.$url.'" '.$imgInfo[3].' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';
1651 } elseif ($ext=='ttf' || t3lib_div
::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$ext)) {
1652 $theFile_abs = PATH_site
.($uploaddir?
$uploaddir.'/':'').trim($theFile);
1653 $theFile = ($abs?
'':'../').($uploaddir?
$uploaddir.'/':'').trim($theFile);
1655 $check = basename($theFile_abs).':'.filemtime($theFile_abs).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
1656 $params = '&file='.rawurlencode($theFile);
1657 $params.= $size?
'&size='.$size:'';
1658 $params.= '&md5sum='.t3lib_div
::shortMD5($check);
1660 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
1661 $onClick = 'top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
1662 $thumbData.= '<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.htmlspecialchars($backPath.$url).'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /></a> ';
1664 $icon = t3lib_BEfunc
::getFileIcon($ext);
1665 $url = 'gfx/fileicons/'.$icon;
1666 $thumbData.= '<img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /> ';
1674 * Returns single image tag to thumbnail using a thumbnail script (like thumbs.php)
1677 * @param string $thumbScript must point to "thumbs.php" relative to the script position
1678 * @param string $theFile must be the proper reference to the file thumbs.php should show
1679 * @param string $tparams are additional attributes for the image tag
1680 * @param integer $size is the size of the thumbnail send along to "thumbs.php"
1681 * @return string Image tag
1683 function getThumbNail($thumbScript,$theFile,$tparams='',$size='') {
1684 $check = basename($theFile).':'.filemtime($theFile).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
1685 $params = '&file='.rawurlencode($theFile);
1686 $params.= trim($size)?
'&size='.trim($size):'';
1687 $params.= '&md5sum='.t3lib_div
::shortMD5($check);
1689 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
1690 $th='<img src="'.htmlspecialchars($url).'" title="'.trim(basename($theFile)).'"'.($tparams?
" ".$tparams:"").' alt="" />';
1695 * Returns title-attribute information for a page-record informing about id, alias, doktype, hidden, starttime, endtime, fe_group etc.
1698 * @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)
1699 * @param string $perms_clause is used to get the record path of the shortcut page, if any (and doktype==4)
1700 * @param boolean If $includeAttrib is set, then the 'title=""' attribute is wrapped about the return value, which is in any case htmlspecialchar()'ed already
1703 function titleAttribForPages($row,$perms_clause='',$includeAttrib=1) {
1706 $parts[] = 'id='.$row['uid'];
1707 if ($row['alias']) $parts[]=$LANG->sL($TCA['pages']['columns']['alias']['label']).' '.$row['alias'];
1708 if ($row['pid']<0) $parts[] = 'v#1.'.$row['t3ver_id'];
1710 switch($row['t3ver_state']) {
1712 $parts[] = 'PLH WSID#'.$row['t3ver_wsid'];
1715 $parts[] = 'Deleted element!';
1718 $parts[] = 'NEW LOCATION (PLH) WSID#'.$row['t3ver_wsid'];
1721 $parts[] = 'OLD LOCATION (PNT) WSID#'.$row['t3ver_wsid'];
1724 $parts[] = 'New element!';
1728 if ($row['doktype']=='3') {
1729 $parts[]=$LANG->sL($TCA['pages']['columns']['url']['label']).' '.$row['url'];
1730 } elseif ($row['doktype']=='4') {
1731 if ($perms_clause) {
1732 $label = t3lib_BEfunc
::getRecordPath(intval($row['shortcut']),$perms_clause,20);
1734 $lRec = t3lib_BEfunc
::getRecordWSOL('pages',intval($row['shortcut']),'title');
1735 $label = $lRec['title'];
1737 if ($row['shortcut_mode']>0) {
1738 $label.=', '.$LANG->sL($TCA['pages']['columns']['shortcut_mode']['label']).' '.
1739 $LANG->sL(t3lib_BEfunc
::getLabelFromItemlist('pages','shortcut_mode',$row['shortcut_mode']));
1741 $parts[]=$LANG->sL($TCA['pages']['columns']['shortcut']['label']).' '.$label;
1742 } elseif ($row['doktype']=='7') {
1743 if ($perms_clause) {
1744 $label = t3lib_BEfunc
::getRecordPath(intval($row['mount_pid']),$perms_clause,20);
1746 $lRec = t3lib_BEfunc
::getRecordWSOL('pages',intval($row['mount_pid']),'title');
1747 $label = $lRec['title'];
1749 $parts[]=$LANG->sL($TCA['pages']['columns']['mount_pid']['label']).' '.$label;
1750 if ($row['mount_pid_ol']) {
1751 $parts[] = $LANG->sL($TCA['pages']['columns']['mount_pid_ol']['label']);
1754 if ($row['nav_hide']) $parts[] = ereg_replace(':$','',$LANG->sL($TCA['pages']['columns']['nav_hide']['label']));
1755 if ($row['hidden']) $parts[] = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.hidden');
1756 if ($row['starttime']) $parts[] = $LANG->sL($TCA['pages']['columns']['starttime']['label']).' '.t3lib_BEfunc
::dateTimeAge($row['starttime'],-1,'date');
1757 if ($row['endtime']) $parts[] = $LANG->sL($TCA['pages']['columns']['endtime']['label']).' '.t3lib_BEfunc
::dateTimeAge($row['endtime'],-1,'date');
1758 if ($row['fe_group']) {
1759 $fe_groups = array();
1760 foreach (t3lib_div
::intExplode(',',$row['fe_group']) as $fe_group) {
1762 $fe_groups[] = $LANG->sL(t3lib_BEfunc
::getLabelFromItemlist('pages','fe_group',$fe_group));
1764 $lRec = t3lib_BEfunc
::getRecordWSOL('fe_groups',$fe_group,'title');
1765 $fe_groups[] = $lRec['title'];
1768 $label = implode(', ',$fe_groups);
1769 $parts[] = $LANG->sL($TCA['pages']['columns']['fe_group']['label']).' '.$label;
1771 $out = htmlspecialchars(implode(' - ',$parts));
1772 return $includeAttrib ?
'title="'.$out.'"' : $out;
1776 * Returns title-attribute information for ANY record (from a table defined in TCA of course)
1777 * 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.
1778 * "pages" table can be used as well and will return the result of ->titleAttribForPages() for that page.
1781 * @param array Table row; $row is a row from the table, $table
1782 * @param string Table name
1785 function getRecordIconAltText($row,$table='pages') {
1786 if ($table=='pages') {
1787 $out = t3lib_BEfunc
::titleAttribForPages($row,'',0);
1789 $ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
1791 $out='id='.$row['uid']; // Uid is added
1792 if ($table=='pages' && $row['alias']) {
1793 $out.=' / '.$row['alias'];
1795 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS'] && $row['pid']<0) {
1796 $out.=' - v#1.'.$row['t3ver_id'];
1798 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
1799 switch($row['t3ver_state']) {
1801 $out.= ' - PLH WSID#'.$row['t3ver_wsid'];
1804 $out.= ' - Deleted element!';
1807 $out.= ' - NEW LOCATION (PLH) WSID#'.$row['t3ver_wsid'];
1810 $out.= ' - OLD LOCATION (PNT) WSID#'.$row['t3ver_wsid'];
1813 $out.= ' - New element!';
1818 if ($ctrl['disabled']) { // Hidden ...
1819 $out.=($row[$ctrl['disabled']]?
' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.hidden'):'');
1821 if ($ctrl['starttime']) {
1822 if ($row[$ctrl['starttime']] > $GLOBALS['EXEC_TIME']) {
1823 $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').')';
1826 if ($row[$ctrl['endtime']]) {
1827 $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').')';
1830 return htmlspecialchars($out);
1834 * Returns the label of the first found entry in an "items" array from $TCA (tablename=$table/fieldname=$col) where the value is $key
1837 * @param string Table name, present in $TCA
1838 * @param string Field name, present in $TCA
1839 * @param string items-array value to match
1840 * @return string Label for item entry
1842 function getLabelFromItemlist($table,$col,$key) {
1844 // Load full TCA for $table
1845 t3lib_div
::loadTCA($table);
1847 // Check, if there is an "items" array:
1848 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]) && is_array($TCA[$table]['columns'][$col]['config']['items'])) {
1849 // Traverse the items-array...
1850 reset($TCA[$table]['columns'][$col]['config']['items']);
1851 while(list($k,$v)=each($TCA[$table]['columns'][$col]['config']['items'])) {
1852 // ... and return the first found label where the value was equal to $key
1853 if (!strcmp($v[1],$key)) return $v[0];
1859 * Returns the label-value for fieldname $col in table, $table
1860 * 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>'
1863 * @param string Table name, present in $TCA
1864 * @param string Field name
1865 * @param string Wrap value - set function description
1868 function getItemLabel($table,$col,$printAllWrap='') {
1870 // Load full TCA for $table
1871 t3lib_div
::loadTCA($table);
1872 // Check if column exists
1873 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col])) {
1875 return $TCA[$table]['columns'][$col]['label'];
1877 if ($printAllWrap) {
1878 $parts = explode('|',$printAllWrap);
1879 return $parts[0].$col.$parts[1];
1884 * Returns the "title"-value in record, $row, from table, $table
1885 * The field(s) from which the value is taken is determined by the "ctrl"-entries 'label', 'label_alt' and 'label_alt_force'
1888 * @param string Table name, present in TCA
1889 * @param array Row from table
1890 * @param boolean If set, result is prepared for output: The output is cropped to a limited lenght (depending on BE_USER->uc['titleLen']) and if no value is found for the title, '<em>[No title]</em>' is returned (localized). Further, the output is htmlspecialchars()'ed
1891 * @param boolean If set, the function always returns an output. If no value is found for the title, '[No title]' is returned (localized).
1894 function getRecordTitle($table,$row,$prep=FALSE,$forceResult=TRUE) {
1896 if (is_array($TCA[$table])) {
1898 // If configured, call userFunc
1899 if ($TCA[$table]['ctrl']['label_userFunc']) {
1900 $params['table'] = $table;
1901 $params['row'] = $row;
1902 $params['title'] = '';
1904 t3lib_div
::callUserFunction($TCA[$table]['ctrl']['label_userFunc'],$params,$this);
1905 $t = $params['title'];
1908 // No userFunc: Build label
1909 $t = t3lib_BEfunc
::getProcessedValue($table,$TCA[$table]['ctrl']['label'],$row[$TCA[$table]['ctrl']['label']],0,0,false,$row['uid'],$forceResult);
1910 if ($TCA[$table]['ctrl']['label_alt'] && ($TCA[$table]['ctrl']['label_alt_force'] ||
!strcmp($t,''))) {
1911 $altFields=t3lib_div
::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
1913 if (!empty($t)) $tA[] = $t;
1914 foreach ($altFields as $fN) {
1915 $t = trim(strip_tags($row[$fN]));
1916 if (strcmp($t,'')) {
1917 $t = t3lib_BEfunc
::getProcessedValue($table,$fN,$t,0,0,false,$row['uid']);
1918 if (!$TCA[$table]['ctrl']['label_alt_force']) {
1924 if ($TCA[$table]['ctrl']['label_alt_force']) {
1925 $t=implode(', ',$tA);
1930 // If the current result is empty, set it to '[No title]' (localized) and prepare for output if requested
1931 if ($prep ||
$forceResult) {
1933 $t = t3lib_BEfunc
::getRecordTitlePrep($t);
1935 if (!strcmp(trim($t),'')) {
1936 $t = t3lib_BEfunc
::getNoRecordTitle($prep);
1945 * Crops a title string to a limited lenght and if it really was cropped, wrap it in a <span title="...">|</span>,
1946 * which offers a tooltip with the original title when moving mouse over it.
1948 * @param string $title: The title string to be cropped
1949 * @param integer $titleLength: Crop title after this length - if not set, BE_USER->uc['titleLen'] is used
1950 * @return string The processed title string, wrapped in <span title="...">|</span> if cropped
1952 function getRecordTitlePrep($title, $titleLength=0) {
1953 // If $titleLength is not a valid positive integer, use BE_USER->uc['titleLen']:
1954 if (!$titleLength ||
!t3lib_div
::testInt($titleLength) ||
$titleLength < 0) {
1955 $titleLength = $GLOBALS['BE_USER']->uc
['titleLen'];
1957 $titleOrig = htmlspecialchars($title);
1958 $title = htmlspecialchars(t3lib_div
::fixed_lgd_cs($title, $titleLength));
1959 // If title was cropped, offer a tooltip:
1960 if ($titleOrig != $title) {
1961 $title = '<span title="'.$titleOrig.'">'.$title.'</span>';
1967 * Get a localized [No title] string, wrapped in <em>|</em> if $prep is true.
1969 * @param boolean $prep: Wrap result in <em>|</em>
1970 * @return string Localized [No title] string
1972 function getNoRecordTitle($prep=FALSE) {
1973 $noTitle = '['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']';
1974 if ($prep) $noTitle = '<em>'.$noTitle.'</em>';
1979 * Returns a human readable output of a value from a record
1980 * 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.
1981 * $table/$col is tablename and fieldname
1982 * REMEMBER to pass the output through htmlspecialchars() if you output it to the browser! (To protect it from XSS attacks and be XHTML compliant)
1985 * @param string Table name, present in TCA
1986 * @param string Field name, present in TCA
1987 * @param string $value is the value of that field from a selected record
1988 * @param integer $fixed_lgd_chars is the max amount of characters the value may occupy
1989 * @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")
1990 * @param boolean If set, no records will be looked up, UIDs are just shown.
1991 * @param integer uid of the current record
1992 * @param boolean If t3lib_BEfunc::getRecordTitle is used to process the value, this parameter is forwarded.
1995 function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0,$noRecordLookup=FALSE,$uid=0,$forceResult=TRUE) {
1997 global $TYPO3_CONF_VARS;
1998 // Load full TCA for $table
1999 t3lib_div
::loadTCA($table);
2000 // Check if table and field is configured:
2001 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col])) {
2002 // Depending on the fields configuration, make a meaningful output value.
2003 $theColConf = $TCA[$table]['columns'][$col]['config'];
2006 *HOOK: pre-processing the human readable output from a record
2008 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['preProcessValue'])) {
2009 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['preProcessValue'] as $_funcRef) {
2010 t3lib_div
::callUserFunction($_funcRef,$theColConf,$this);
2015 switch((string)$theColConf['type']) {
2017 $l=t3lib_BEfunc
::getLabelFromItemlist($table,$col,$value);
2018 $l=$GLOBALS['LANG']->sL($l);
2021 if ($theColConf['MM']) {
2022 // Display the title of MM related records in lists
2023 if ($noRecordLookup) {
2024 $MMfield = $theColConf['foreign_table'].'.uid';
2026 $MMfields = array($theColConf['foreign_table'].'.'.$TCA[$theColConf['foreign_table']]['ctrl']['label']);
2027 foreach (t3lib_div
::trimExplode(',', $TCA[$theColConf['foreign_table']]['ctrl']['label_alt'], 1) as $f) {
2028 $MMfields[] = $theColConf['foreign_table'].'.'.$f;
2030 $MMfield = join(',',$MMfields);
2033 $dbGroup = t3lib_div
::makeInstance('t3lib_loadDBGroup');
2034 $dbGroup->start($value, $theColConf['foreign_table'], $theColConf['MM'], $uid, $table, $theColConf);
2035 $selectUids = $dbGroup->tableArray
[$theColConf['foreign_table']];
2037 if (is_array($selectUids) && count($selectUids)>0) {
2038 $MMres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2040 $theColConf['foreign_table'],
2041 'uid IN ('.implode(',', $selectUids).')'
2043 while($MMrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($MMres)) {
2044 $mmlA[] = ($noRecordLookup?
$MMrow['uid']:t3lib_BEfunc
::getRecordTitle($theColConf['foreign_table'], $MMrow, FALSE, $forceResult));
2046 if (is_array($mmlA)) {
2047 $l=implode('; ',$mmlA);
2055 $l = t3lib_BEfunc
::getLabelFromItemlist($table,$col,$value);
2056 $l = $GLOBALS['LANG']->sL($l);
2057 if ($theColConf['foreign_table'] && !$l && $TCA[$theColConf['foreign_table']]) {
2058 if ($noRecordLookup) {
2061 $rParts = t3lib_div
::trimExplode(',',$value,1);
2064 while(list(,$rVal)=each($rParts)) {
2065 $rVal = intval($rVal);
2067 $r=t3lib_BEfunc
::getRecordWSOL($theColConf['foreign_table'],$rVal);
2069 $r=t3lib_BEfunc
::getRecordWSOL($theColConf['neg_foreign_table'],-$rVal);
2072 $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,FALSE,$forceResult);
2074 $lA[]=$rVal?
'['.$rVal.'!]':'';
2077 $l = implode(', ',$lA);
2083 $l = implode(', ',t3lib_div
::trimExplode(',',$value,1));
2086 if (!is_array($theColConf['items']) ||
count($theColConf['items'])==1) {
2087 $l = $value ?
'Yes' : '';
2089 reset($theColConf['items']);
2091 while(list($key,$val)=each($theColConf['items'])) {
2092 if ($value & pow(2,$key)) {$lA[]=$GLOBALS['LANG']->sL($val[0]);}
2094 $l = implode(', ',$lA);
2099 if (t3lib_div
::inList($theColConf['eval'],'date')) {
2100 $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')).')';
2101 } elseif (t3lib_div
::inList($theColConf['eval'],'time')) {
2102 $l = t3lib_BEfunc
::time($value, FALSE);
2103 } elseif (t3lib_div
::inList($theColConf['eval'],'timesec')) {
2104 $l = t3lib_BEfunc
::time($value);
2105 } elseif (t3lib_div
::inList($theColConf['eval'],'datetime')) {
2106 $l = t3lib_BEfunc
::datetime($value);
2113 $l = strip_tags($value);
2116 if ($defaultPassthrough) {
2118 } elseif ($theColConf['MM']) {
2121 $l=t3lib_div
::fixed_lgd_cs(strip_tags($value),200);
2127 *HOOK: post-processing the human readable output from a record
2129 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['postProcessValue'])) {
2130 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['postProcessValue'] as $_funcRef) {
2133 'colConf' => $theColConf
2135 $l = t3lib_div
::callUserFunction($_funcRef,$params,$this);
2139 if ($fixed_lgd_chars) {
2140 return t3lib_div
::fixed_lgd_cs($l,$fixed_lgd_chars);
2148 * 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.
2151 * @param string Table name, present in TCA
2152 * @param string Field name
2153 * @param string Field value
2154 * @param integer $fixed_lgd_chars is the max amount of characters the value may occupy
2155 * @param integer uid of the current record
2156 * @param boolean If t3lib_BEfunc::getRecordTitle is used to process the value, this parameter is forwarded.
2158 * @see getProcessedValue()
2160 function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0,$uid=0,$forceResult=TRUE) {
2162 $fVnew = t3lib_BEfunc
::getProcessedValue($table,$fN,$fV,$fixed_lgd_chars,0,0,$uid,$forceResult);
2163 if (!isset($fVnew)) {
2164 if (is_array($TCA[$table])) {
2165 if ($fN==$TCA[$table]['ctrl']['tstamp'] ||
$fN==$TCA[$table]['ctrl']['crdate']) {
2166 $fVnew = t3lib_BEfunc
::datetime($fV);
2167 } elseif ($fN=='pid'){
2168 $fVnew = t3lib_BEfunc
::getRecordPath($fV,'1=1',20); // Fetches the path with no regard to the users permissions to select pages.
2178 * Returns file icon name (from $FILEICONS) for the fileextension $ext
2181 * @param string File extension, lowercase
2182 * @return string File icon filename
2184 function getFileIcon($ext) {
2185 return $GLOBALS['FILEICONS'][$ext] ?
$GLOBALS['FILEICONS'][$ext] : $GLOBALS['FILEICONS']['default'];
2189 * Returns fields for a table, $table, which would typically be interesting to select
2190 * This includes uid, the fields defined for title, icon-field.
2191 * 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)
2194 * @param string Table name, present in TCA
2195 * @param string Table prefix
2196 * @param array Preset fields (must include prefix if that is used)
2197 * @return string List of fields.
2199 function getCommonSelectFields($table,$prefix='',$fields = array()) {
2201 $fields[] = $prefix.'uid';
2202 $fields[] = $prefix.$TCA[$table]['ctrl']['label'];
2204 if ($TCA[$table]['ctrl']['label_alt']) {
2205 $secondFields = t3lib_div
::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
2206 foreach($secondFields as $fieldN) {
2207 $fields[] = $prefix.$fieldN;
2210 if ($TCA[$table]['ctrl']['versioningWS']) {
2211 $fields[] = $prefix.'t3ver_id';
2212 $fields[] = $prefix.'t3ver_state';
2213 $fields[] = $prefix.'t3ver_wsid';
2214 $fields[] = $prefix.'t3ver_count';
2217 if ($TCA[$table]['ctrl']['selicon_field']) $fields[] = $prefix.$TCA[$table]['ctrl']['selicon_field'];
2218 if ($TCA[$table]['ctrl']['typeicon_column']) $fields[] = $prefix.$TCA[$table]['ctrl']['typeicon_column'];
2220 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
2221 if ($TCA[$table]['ctrl']['enablecolumns']['disabled']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['disabled'];
2222 if ($TCA[$table]['ctrl']['enablecolumns']['starttime']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['starttime'];
2223 if ($TCA[$table]['ctrl']['enablecolumns']['endtime']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['endtime'];
2224 if ($TCA[$table]['ctrl']['enablecolumns']['fe_group']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['fe_group'];
2227 return implode(',', array_unique($fields));
2231 * 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
2232 * <form>-tags must be supplied separately
2233 * 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.
2234 * Usage: 1 (ext. direct_mail)
2236 * @param array Field configuration code.
2237 * @param array Defaults
2238 * @param string Prefix for formfields
2239 * @return string HTML for a form.
2241 function makeConfigForm($configArray,$defaults,$dataPrefix) {
2242 $params = $defaults;
2243 if (is_array($configArray)) {
2244 reset($configArray);
2246 while(list($fname,$config)=each($configArray)) {
2247 if (is_array($config)) {
2248 $lines[$fname]='<strong>'.htmlspecialchars($config[1]).'</strong><br />';
2249 $lines[$fname].=$config[2].'<br />';
2250 switch($config[0]) {
2253 $formEl = '<input type="text" name="'.$dataPrefix.'['.$fname.']" value="'.$params[$fname].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($config[0]=='short'?
24:48).' />';
2256 $formEl = '<input type="hidden" name="'.$dataPrefix.'['.$fname.']" value="0" /><input type="checkbox" name="'.$dataPrefix.'['.$fname.']" value="1"'.($params[$fname]?
' checked="checked"':'').' />';
2264 while(list($k,$v)=each($config[3])) {
2265 $opt[]='<option value="'.htmlspecialchars($k).'"'.($params[$fname]==$k?
' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
2267 $formEl = '<select name="'.$dataPrefix.'['.$fname.']">'.implode('',$opt).'</select>';
2273 $lines[$fname].=$formEl;
2274 $lines[$fname].='<br /><br />';
2276 $lines[$fname]='<hr />';
2277 if ($config) $lines[$fname].='<strong>'.strtoupper(htmlspecialchars($config)).'</strong><br />';
2278 if ($config) $lines[$fname].='<br />';
2282 $out = implode('',$lines);
2283 $out.='<input type="submit" name="submit" value="Update configuration" />';
2299 /*******************************************
2301 * Backend Modules API functions
2303 *******************************************/
2306 * Returns help-text icon if configured for.
2307 * TCA_DESCR must be loaded prior to this function and $BE_USER must have 'edit_showFieldHelp' set to 'icon', otherwise nothing is returned
2310 * @param string Table name
2311 * @param string Field name
2312 * @param string Back path
2313 * @param boolean Force display of icon nomatter BE_USER setting for help
2314 * @return string HTML content for a help icon/text
2316 function helpTextIcon($table,$field,$BACK_PATH,$force=0) {
2317 global $TCA_DESCR,$BE_USER;
2319 $onClick = 'vHWin=window.open(\''.$BACK_PATH.'view_help.php?tfID='.($table.'.'.$field).'\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
2320 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && (isset($BE_USER->uc
['edit_showFieldHelp']) ||
$force)) {
2321 if ($BE_USER->uc
['edit_showFieldHelp'] == 'icon') {
2322 $text = t3lib_BEfunc
::helpText($table,$field,$BACK_PATH,'');
2323 $text = '<span class="typo3-csh-inline">'.$GLOBALS['LANG']->hscAndCharConv($text, false).'</span>';
2325 return '<a class="typo3-csh-link" href="#" onclick="'.htmlspecialchars($onClick).'"><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="typo3-csh-icon" alt="" />'.$text.'</a>';
2331 * Returns CSH help text (description), if configured for.
2332 * TCA_DESCR must be loaded prior to this function and $BE_USER must have "edit_showFieldHelp" set to "text",
2333 * otherwise nothing is returned
2334 * Will automatically call t3lib_BEfunc::helpTextIcon() to get the icon for the text.
2337 * @param string Table name
2338 * @param string Field name
2339 * @param string Back path
2340 * @param string DEPRECATED: Additional style-attribute content for wrapping table (now: only in function cshItem needed)
2341 * @return string HTML content for help text
2343 function helpText($table,$field,$BACK_PATH,$styleAttrib='') {
2344 global $TCA_DESCR,$BE_USER;
2347 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field])) {
2348 $data = $TCA_DESCR[$table]['columns'][$field];
2349 // add see also arrow
2350 if ($data['image_descr'] ||
$data['seeAlso'] ||
$data['details'] ||
$data['syntax']) {
2351 $arrow = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/rel_db.gif','width="13" height="12"').' class="absmiddle" alt="" />';
2353 // add description text
2354 if ($data['description'] ||
$arrow) {
2355 $output = '<span class="paragraph">'.nl2br(htmlspecialchars($data['description'])).$arrow.'</span>';
2358 // put header before the rest of the text
2359 if ($data['alttitle']) {
2360 $output = '<span class="header">'.$data['alttitle'].'</span><br />'.$output;
2368 * API for getting CSH icons/text for use in backend modules.
2369 * TCA_DESCR will be loaded if it isn't already
2372 * @param string Table name ('_MOD_'+module name)
2373 * @param string Field name (CSH locallang main key)
2374 * @param string Back path
2375 * @param string Wrap code for icon-mode, splitted by "|". Not used for full-text mode.
2376 * @param boolean If set, the full text will never be shown (only icon).
2377 * Useful for places where it will break the page if the table with full text is shown.
2378 * @param string Additional style-attribute content for wrapping table (full text mode only)
2379 * @return string HTML content for help text
2380 * @see helpText(), helpTextIcon()
2382 function cshItem($table,$field,$BACK_PATH,$wrap='',$onlyIconMode=FALSE, $styleAttrib='') {
2383 global $TCA_DESCR, $LANG, $BE_USER;
2385 if ($BE_USER->uc
['edit_showFieldHelp']) {
2386 $LANG->loadSingleTableDescription($table);
2388 if (is_array($TCA_DESCR[$table])) {
2389 // Creating CSH icon and short description:
2390 $fullText = t3lib_BEfunc
::helpText($table,$field,$BACK_PATH,'');
2391 $icon = t3lib_BEfunc
::helpTextIcon($table,$field,$BACK_PATH);
2393 if ($fullText && !$onlyIconMode && $BE_USER->uc
['edit_showFieldHelp'] == 'text') {
2395 // Additional styles?
2396 $params = $styleAttrib ?
' style="'.$styleAttrib.'"' : '';
2398 // Compile table with CSH information:
2399 $fullText = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-csh-inline"'.$params.'>
2401 <td valign="top" width="14">'.$icon.'</td>
2402 <td valign="top">'.$fullText.'</td>
2406 $output = $LANG->hscAndCharConv($fullText, false);
2410 if ($output && $wrap) {
2411 $wrParts = explode('|',$wrap);
2412 $output = $wrParts[0].$output.$wrParts[1];
2422 * 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.
2423 * REMEMBER to always htmlspecialchar() content in href-properties to ampersands get converted to entities (XHTML requirement and XSS precaution)
2426 * @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.
2427 * @param string $backPath must point back to the TYPO3_mainDir directory (where alt_doc.php is)
2428 * @param string $requestUri is an optional returnUrl you can set - automatically set to REQUEST_URI.
2430 * @see template::issueCommand()
2432 function editOnClick($params,$backPath='',$requestUri='') {
2433 $retUrl = 'returnUrl='.($requestUri==-1?
"'+T3_THIS_LOCATION+'":rawurlencode($requestUri?
$requestUri:t3lib_div
::getIndpEnv('REQUEST_URI')));
2434 return "window.location.href='".$backPath."alt_doc.php?".$retUrl.$params."'; return false;";
2438 * Returns a JavaScript string for viewing the page id, $id
2439 * It will detect the correct domain name if needed and provide the link with the right back path. Also it will re-use any window already open.
2442 * @param integer $id is page id
2443 * @param string $backpath must point back to TYPO3_mainDir (where the site is assumed to be one level above)
2444 * @param array If root line is supplied the function will look for the first found domain record and use that URL instead (if found)
2445 * @param string $anchor is optional anchor to the URL
2446 * @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!
2447 * @param string Additional GET variables.
2448 * @param boolean If true, then the preview window will gain the focus.
2451 function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='',$addGetVars='',$switchFocus=TRUE) {
2456 if ($GLOBALS['BE_USER']->workspace
!=0 && !$GLOBALS['BE_USER']->user
['workspace_preview']) {
2457 $url = t3lib_div
::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir
.'mod/user/ws/wsol_preview.php?id='.$id.$addGetVars.$anchor;
2460 $parts = parse_url(t3lib_div
::getIndpEnv('TYPO3_SITE_URL'));
2461 if (t3lib_BEfunc
::getDomainStartPage($parts['host'],$parts['path'])) {
2462 $preUrl_temp = t3lib_BEfunc
::firstDomainRecord($rootLine);
2465 $preUrl = $preUrl_temp ?
(t3lib_div
::getIndpEnv('TYPO3_SSL') ?
'https://' : 'http://').$preUrl_temp : $backPath.'..';
2466 $url = $preUrl.'/index.php?id='.$id.$addGetVars.$anchor;
2470 return "previewWin=window.open('".$url."','newTYPO3frontendWindow');".
2471 ($switchFocus ?
'previewWin.focus();' : '');
2475 * Returns the merged User/Page TSconfig for page id, $id.
2476 * Please read details about module programming elsewhere!
2479 * @param integer Page uid
2480 * @param string $TSref is an object string which determines the path of the TSconfig to return.
2483 function getModTSconfig($id,$TSref) {
2484 $pageTS_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref,t3lib_BEfunc
::getPagesTSconfig($id));
2485 $BE_USER_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref);
2486 $modTSconfig = t3lib_div
::array_merge_recursive_overrule($pageTS_modOptions,$BE_USER_modOptions);
2487 return $modTSconfig;
2491 * Returns a selector box "function menu" for a module
2492 * Requires the JS function jumpToUrl() to be available
2493 * See Inside TYPO3 for details about how to use / make Function menus
2496 * @param mixed $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
2497 * @param string $elementName it the form elements name, probably something like "SET[...]"
2498 * @param string $currentValue is the value to be selected currently.
2499 * @param array $menuItems is an array with the menu items for the selector box
2500 * @param string $script is the script to send the &id to, if empty it's automatically found
2501 * @param string $addParams is additional parameters to pass to the script.
2502 * @return string HTML code for selector box
2504 function getFuncMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
2505 if (is_array($menuItems)) {
2506 if (!is_array($mainParams)) {
2507 $mainParams = array('id' => $mainParams);
2509 $mainParams = t3lib_div
::implodeArrayForUrl('',$mainParams);
2512 $script = basename(PATH_thisScript
);
2513 $mainParams.= (t3lib_div
::_GET('M') ?
'&M='.rawurlencode(t3lib_div
::_GET('M')) : '');
2517 foreach($menuItems as $value => $label) {
2518 $options[] = '<option value="'.htmlspecialchars($value).'"'.(!strcmp($currentValue,$value)?
' selected="selected"':'').'>'.
2519 t3lib_div
::deHSCentities(htmlspecialchars($label)).
2522 if (count($options)) {
2523 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+this.options[this.selectedIndex].value,this);';
2526 <!-- Function Menu of module -->
2527 <select name="'.$elementName.'" onchange="'.htmlspecialchars($onChange).'">
2537 * Checkbox function menu.
2538 * Works like ->getFuncMenu() but takes no $menuItem array since this is a simple checkbox.
2541 * @param mixed $mainParams $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
2542 * @param string $elementName it the form elements name, probably something like "SET[...]"
2543 * @param string $currentValue is the value to be selected currently.
2544 * @param string $script is the script to send the &id to, if empty it's automatically found
2545 * @param string $addParams is additional parameters to pass to the script.
2546 * @param string Additional attributes for the checkbox input tag
2547 * @return string HTML code for checkbox
2548 * @see getFuncMenu()
2550 function getFuncCheck($mainParams,$elementName,$currentValue,$script='',$addparams='',$tagParams='') {
2551 if (!is_array($mainParams)) {
2552 $mainParams = array('id' => $mainParams);
2554 $mainParams = t3lib_div
::implodeArrayForUrl('',$mainParams);
2556 if (!$script) {basename(PATH_thisScript
);}
2557 $onClick = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+(this.checked?1:0),this);';
2558 return '<input type="checkbox" name="'.$elementName.'"'.($currentValue?
' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'"'.($tagParams?
' '.$tagParams:'').' />';
2562 * Input field function menu
2563 * Works like ->getFuncMenu() / ->getFuncCheck() but displays a input field instead which updates the script "onchange"
2566 * @param mixed $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
2567 * @param string $elementName it the form elements name, probably something like "SET[...]"
2568 * @param string $currentValue is the value to be selected currently.
2569 * @param integer Relative size of input field, max is 48
2570 * @param string $script is the script to send the &id to, if empty it's automatically found
2571 * @param string $addParams is additional parameters to pass to the script.
2572 * @return string HTML code for input text field.
2573 * @see getFuncMenu()
2575 function getFuncInput($mainParams,$elementName,$currentValue,$size=10,$script="",$addparams="") {
2576 if (!is_array($mainParams)) {
2577 $mainParams = array('id' => $mainParams);
2579 $mainParams = t3lib_div
::implodeArrayForUrl('',$mainParams);
2581 if (!$script) {basename(PATH_thisScript
);}
2582 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+escape(this.value),this);';
2583 return '<input type="text"'.$GLOBALS['TBE_TEMPLATE']->formWidth($size).' name="'.$elementName.'" value="'.htmlspecialchars($currentValue).'" onchange="'.htmlspecialchars($onChange).'" />';
2587 * Removes menu items from $itemArray if they are configured to be removed by TSconfig for the module ($modTSconfig)
2588 * See Inside TYPO3 about how to program modules and use this API.
2591 * @param array Module TS config array
2592 * @param array Array of items from which to remove items.
2593 * @param string $TSref points to the "object string" in $modTSconfig
2594 * @return array The modified $itemArray is returned.
2596 function unsetMenuItems($modTSconfig,$itemArray,$TSref) {
2597 // Getting TS-config options for this module for the Backend User:
2598 $conf = $GLOBALS['BE_USER']->getTSConfig($TSref,$modTSconfig);
2599 if (is_array($conf['properties'])) {
2600 reset($conf['properties']);
2601 while(list($key,$val)=each($conf['properties'])) {
2603 unset($itemArray[$key]);
2611 * Call to update the page tree frame (or something else..?) after
2612 * t3lib_BEfunc::getSetUpdateSignal('updatePageTree') -> will set the page tree to be updated.
2613 * t3lib_BEfunc::getSetUpdateSignal() -> will return some JavaScript that does the update (called in the typo3/template.php file, end() function)
2616 * @param string Whether to set or clear the update signal. When setting, this value contains strings telling WHAT to set. At this point it seems that the value "updatePageTree" is the only one it makes sense to set.
2617 * @return string HTML code (<script> section)
2619 function getSetUpdateSignal($set='') {
2621 $key = 't3lib_BEfunc::getSetUpdateSignal';
2625 $modData['set']=$set;
2626 $BE_USER->pushModuleData($key,$modData);
2628 $modData = $BE_USER->getModuleData($key,'ses');
2629 if (trim($modData['set'])) {
2630 $l=explode(',',$modData['set']);
2631 while(list(,$v)=each($l)) {
2633 case 'updatePageTree':
2634 case 'updateFolderTree':
2636 <script type="text/javascript">
2638 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
2639 top.content.nav_frame.refresh_nav();
2648 $BE_USER->pushModuleData($key,$modData);
2656 * Returns an array which is most backend modules becomes MOD_SETTINGS containing values from function menus etc. determining the function of the module.
2657 * This is kind of session variable management framework for the backend users.
2658 * 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
2659 * Ultimately, see Inside TYPO3 for how to use this function in relation to your modules.
2662 * @param array MOD_MENU is an array that defines the options in menus.
2663 * @param array CHANGED_SETTINGS represents the array used when passing values to the script from the menus.
2664 * @param string modName is the name of this module. Used to get the correct module data.
2665 * @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.
2666 * @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.
2667 * @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)
2668 * @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
2670 function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='') {
2672 if ($modName && is_string($modName)) {
2673 // GETTING stored user-data from this module:
2674 $settings = $GLOBALS['BE_USER']->getModuleData($modName,$type);
2677 if (!is_array($settings)) {
2681 if (is_array($MOD_MENU)) {
2682 foreach ($MOD_MENU as $key=>$var) {
2683 // If a global var is set before entering here. eg if submitted, then it's substituting the current value the array.
2684 if (is_array($CHANGED_SETTINGS) && isset($CHANGED_SETTINGS[$key]) && strcmp($settings[$key],$CHANGED_SETTINGS[$key])) {
2685 $settings[$key] = (string)$CHANGED_SETTINGS[$key];
2688 // If the $var is an array, which denotes the existence of a menu, we check if the value is permitted
2689 if (is_array($var) && (!$dontValidateList ||
!t3lib_div
::inList($dontValidateList,$key))) {
2690 // If the setting is an array or not present in the menu-array, MOD_MENU, then the default value is inserted.
2691 if (is_array($settings[$key]) ||
!isset($MOD_MENU[$key][$settings[$key]])) {
2692 $settings[$key] = (string)key($var);
2696 if ($setDefaultList && !is_array($var)) { // Sets default values (only strings/checkboxes, not menus)
2697 if (t3lib_div
::inList($setDefaultList,$key) && !isset($settings[$key])) {
2698 $settings[$key] = (string)$var;
2702 } else {die ('No menu!');}
2705 $GLOBALS['BE_USER']->pushModuleData($modName,$settings);
2709 } else {die ('Wrong module name: "'.$modName.'"');}
2724 /*******************************************
2728 *******************************************/
2731 * Set preview keyword, eg:
2732 * $previewUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.t3lib_BEfunc::compilePreviewKeyword('id='.$pageId.'&L='.$language.'&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS='.$this->workspace, $GLOBALS['BE_USER']->user['uid'], 120);
2734 * todo for sys_preview:
2735 * - Add a comment which can be shown to previewer in frontend in some way (plus maybe ability to write back, take other action?)
2736 * - Add possibility for the preview keyword to work in the backend as well: So it becomes a quick way to a certain action of sorts?
2738 * @param string Get variables to preview, eg. 'id=1150&L=0&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=8'
2739 * @param string 32 byte MD5 hash keyword for the URL: "?ADMCMD_prev=[keyword]"
2740 * @param integer Time-To-Live for keyword
2741 * @param integer Which workspace to preview. Workspace UID, -1 or >0. If set, the getVars is ignored in the frontend, so that string can be empty
2742 * @return string Returns keyword to use in URL for ADMCMD_prev=
2744 function compilePreviewKeyword($getVarsStr, $beUserUid, $ttl=172800,$fullWorkspace=NULL) {
2745 $field_array = array(
2746 'keyword' => md5(uniqid(microtime())),
2748 'endtime' => time()+
$ttl,
2749 'config' => serialize(array(
2750 'fullWorkspace' => $fullWorkspace,
2751 'getVars' => $getVarsStr,
2752 'BEUSER_uid' => $beUserUid
2756 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_preview', $field_array);
2758 return $field_array['keyword'];
2762 * Unlock or Lock a record from $table with $uid
2763 * If $table and $uid is not set, then all locking for the current BE_USER is removed!
2766 * @param string Table name
2767 * @param integer Record uid
2768 * @param integer Record pid
2771 * @see t3lib_transferData::lockRecord(), alt_doc.php, db_layout.php, db_list.php, wizard_rte.php
2773 function lockRecords($table='',$uid=0,$pid=0) {
2774 $user_id = intval($GLOBALS['BE_USER']->user
['uid']);
2775 if ($table && $uid) {
2776 $fields_values = array(
2777 'userid' => $user_id,
2778 'tstamp' => $GLOBALS['EXEC_TIME'],
2779 'record_table' => $table,
2780 'record_uid' => $uid,
2781 'username' => $GLOBALS['BE_USER']->user
['username'],
2782 'record_pid' => $pid
2785 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
2787 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'userid='.intval($user_id));
2792 * Returns information about whether the record from table, $table, with uid, $uid is currently locked (edited by another user - which should issue a warning).
2793 * 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.
2796 * @param string Table name
2797 * @param integer Record uid
2800 * @see class.db_layout.inc, alt_db_navframe.php, alt_doc.php, db_layout.php
2802 function isRecordLocked($table,$uid) {
2803 global $LOCKED_RECORDS;
2804 if (!is_array($LOCKED_RECORDS)) {
2805 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2807 'sys_lockedrecords',
2808 'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user
['uid']).'
2809 AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
2811 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
2812 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
2813 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
2814 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'),
2816 t3lib_BEfunc
::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
2818 if ($row['record_pid'] && !isset($LOCKED_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
2819 $LOCKED_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
2820 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content'),
2822 t3lib_BEfunc
::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
2827 return $LOCKED_RECORDS[$table.':'.$uid];
2831 * Returns select statement for MM relations (as used by TCEFORMs etc)
2834 * @param array Configuration array for the field, taken from $TCA
2835 * @param string Field name
2836 * @param array TSconfig array from which to get further configuration settings for the field name
2837 * @param string Prefix string for the key "*foreign_table_where" from $fieldValue array
2838 * @return string Part of query
2840 * @see t3lib_transferData::renderRecord(), t3lib_TCEforms::foreignTable()
2842 function exec_foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='') {
2845 t3lib_div
::loadTCA($foreign_table);
2846 $foreign_table = $fieldValue['config'][$prefix.'foreign_table'];
2847 $rootLevel = $TCA[$foreign_table]['ctrl']['rootLevel'];
2849 $fTWHERE = $fieldValue['config'][$prefix.'foreign_table_where'];
2850 if (strstr($fTWHERE,'###REC_FIELD_')) {
2851 $fTWHERE_parts = explode('###REC_FIELD_',$fTWHERE);
2852 while(list($kk,$vv)=each($fTWHERE_parts)) {
2854 $fTWHERE_subpart = explode('###',$vv,2);
2855 $fTWHERE_parts[$kk]=$TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]].$fTWHERE_subpart[1];
2858 $fTWHERE = implode('',$fTWHERE_parts);
2861 $fTWHERE = str_replace('###CURRENT_PID###',intval($TSconfig['_CURRENT_PID']),$fTWHERE);
2862 $fTWHERE = str_replace('###THIS_UID###',intval($TSconfig['_THIS_UID']),$fTWHERE);
2863 $fTWHERE = str_replace('###THIS_CID###',intval($TSconfig['_THIS_CID']),$fTWHERE);
2864 $fTWHERE = str_replace('###STORAGE_PID###',intval($TSconfig['_STORAGE_PID']),$fTWHERE);
2865 $fTWHERE = str_replace('###SITEROOT###',intval($TSconfig['_SITEROOT']),$fTWHERE);
2866 $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###',intval($TSconfig[$field]['PAGE_TSCONFIG_ID']),$fTWHERE);
2867 $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###',$GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']),$fTWHERE);
2868 $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###',$GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$field]['PAGE_TSCONFIG_STR'], $foreign_table),$fTWHERE);
2870 // rootLevel = -1 is not handled 'properly' here - it goes as if it was rootLevel = 1 (that is pid=0)
2871 $wgolParts = $GLOBALS['TYPO3_DB']->splitGroupOrderLimit($fTWHERE);
2873 $queryParts = array(
2874 'SELECT' => t3lib_BEfunc
::getCommonSelectFields($foreign_table,$foreign_table.'.'),
2875 'FROM' => $foreign_table,
2876 'WHERE' => $foreign_table.'.pid=0 '.
2877 t3lib_BEfunc
::deleteClause($foreign_table).' '.
2878 $wgolParts['WHERE'],
2879 'GROUPBY' => $wgolParts['GROUPBY'],
2880 'ORDERBY' => $wgolParts['ORDERBY'],
2881 'LIMIT' => $wgolParts['LIMIT']
2884 $pageClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2885 if ($foreign_table!='pages') {
2886 $queryParts = array(
2887 'SELECT' => t3lib_BEfunc
::getCommonSelectFields($foreign_table,$foreign_table.'.'),
2888 'FROM' => $foreign_table.',pages',
2889 'WHERE' => 'pages.uid='.$foreign_table.'.pid
2890 AND pages.deleted=0 '.
2891 t3lib_BEfunc
::deleteClause($foreign_table).
2892 ' AND '.$pageClause.' '.
2893 $wgolParts['WHERE'],
2894 'GROUPBY' => $wgolParts['GROUPBY'],
2895 'ORDERBY' => $wgolParts['ORDERBY'],
2896 'LIMIT' => $wgolParts['LIMIT']
2899 $queryParts = array(
2900 'SELECT' => t3lib_BEfunc
::getCommonSelectFields($foreign_table,$foreign_table.'.'),
2902 'WHERE' => 'pages.deleted=0
2903 AND '.$pageClause.' '.
2904 $wgolParts['WHERE'],
2905 'GROUPBY' => $wgolParts['GROUPBY'],
2906 'ORDERBY' => $wgolParts['ORDERBY'],
2907 'LIMIT' => $wgolParts['LIMIT']
2912 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
2916 * Returns TSConfig for the TCEFORM object in Page TSconfig.
2920 * @param string Table name present in TCA
2921 * @param array Row from table
2923 * @see t3lib_transferData::renderRecord(), t3lib_TCEforms::setTSconfig(), SC_wizard_list::main(), SC_wizard_add::main()
2925 function getTCEFORM_TSconfig($table,$row) {
2926 t3lib_BEfunc
::fixVersioningPid($table,$row);
2929 $typeVal = t3lib_BEfunc
::getTCAtypeValue($table,$row);
2931 // Get main config for the table
2932 list($TScID,$cPid) = t3lib_BEfunc
::getTSCpid($table,$row['uid'],$row