Documentation TYPO3 par Ameos

class.t3lib_befunc.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00171 class t3lib_BEfunc      {
00172 
00173 
00174 
00175         /*******************************************
00176          *
00177          * SQL-related, selecting records, searching
00178          *
00179          *******************************************/
00180 
00181 
00191         function deleteClause($table)   {
00192                 global $TCA;
00193                 if ($TCA[$table]['ctrl']['delete'])     {
00194                         return ' AND '.$table.'.'.$TCA[$table]['ctrl']['delete'].'=0';
00195                 } else {
00196                         return '';
00197                 }
00198         }
00199 
00214         function getRecord($table,$uid,$fields='*',$where='')   {
00215                 if ($GLOBALS['TCA'][$table])    {
00216                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid='.intval($uid).t3lib_BEfunc::deleteClause($table).$where);
00217                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00218                                 return $row;
00219                         }
00220                 }
00221         }
00222 
00236         function getRecordRaw($table,$where='',$fields='*')     {
00237                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
00238                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00239                         return $row;
00240                 }
00241         }
00242 
00258         function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='')     {
00259                 global $TCA;
00260                 if (is_array($TCA[$theTable])) {
00261                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00262                                                 '*',
00263                                                 $theTable,
00264                                                 $theField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($theValue, $theTable).
00265                                                         t3lib_BEfunc::deleteClause($theTable).' '.
00266                                                         $whereClause,   // whereClauseMightContainGroupOrderBy
00267                                                 $groupBy,
00268                                                 $orderBy,
00269                                                 $limit
00270                                         );
00271                         $rows = array();
00272                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00273                                 $rows[] = $row;
00274                         }
00275                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
00276                         if (count($rows))       return $rows;
00277                 }
00278         }
00279 
00289         function fixVersioningPid($table,&$rr)  {
00290                 global $TCA;
00291 
00292                 if ($rr['pid']==-1 && $TCA[$table]['ctrl']['versioning'])       {
00293                         if ($rr['t3ver_oid']>0) {       // If "t3ver_oid" is already a field, just set this:
00294                                 $oid = $rr['t3ver_oid'];
00295                         } else {        // Otherwise we have to expect "uid" to be in the record and look up based on this:
00296                                 $newPidRec = t3lib_BEfunc::getRecord($table,$rr['uid'],'t3ver_oid');
00297                                 if (is_array($newPidRec))       {
00298                                         $oid = $newPidRec['t3ver_oid'];
00299                                 }
00300                         }
00301 
00302                                 // If ID of current online version is found, look up the PID value of that:
00303                         if ($oid)       {
00304                                 $oidRec = t3lib_BEfunc::getRecord($table,$oid,'pid');
00305                                 if (is_array($oidRec))  {
00306                                         $rr['_ORIG_pid'] = $rr['pid'];
00307                                         $rr['pid'] = $oidRec['pid'];
00308                                 }
00309                         }
00310                 }
00311         }
00312 
00323         function searchQuery($searchWords,$fields,$table='')    {
00324                 return $GLOBALS['TYPO3_DB']->searchQuery($searchWords,$fields,$table);
00325         }
00326 
00338         function listQuery($field,$value)       {
00339                 return $GLOBALS['TYPO3_DB']->listQuery($field,$value,'');
00340         }
00341 
00350         function splitTable_Uid($str)   {
00351                 list($uid,$table) = explode('_',strrev($str),2);
00352                 return array(strrev($table),strrev($uid));
00353         }
00354 
00365         function getSQLselectableList($in_list,$tablename,$default_tablename)   {
00366                 $list = Array();
00367                 if ((string)trim($in_list)!='') {
00368                         $tempItemArray = explode(',',trim($in_list));
00369                         while(list($key,$val)=each($tempItemArray))     {
00370                                 $val = strrev($val);
00371                                 $parts = explode('_',$val,2);
00372                                 if ((string)trim($parts[0])!='')        {
00373                                         $theID = intval(strrev($parts[0]));
00374                                         $theTable = trim($parts[1]) ? strrev(trim($parts[1])) : $default_tablename;
00375                                         if ($theTable==$tablename)      {$list[]=$theID;}
00376                                 }
00377                         }
00378                 }
00379                 return implode(',',$list);
00380         }
00381 
00393         function BEenableFields($table,$inv=0)  {
00394                 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
00395                 $query=array();
00396                 $invQuery=array();
00397                 if (is_array($ctrl))    {
00398                         if (is_array($ctrl['enablecolumns']))   {
00399                                 if ($ctrl['enablecolumns']['disabled']) {
00400                                         $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
00401                                         $query[]=$field.'=0';
00402                                         $invQuery[]=$field.'!=0';
00403                                 }
00404                                 if ($ctrl['enablecolumns']['starttime'])        {
00405                                         $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
00406                                         $query[]='('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00407                                         $invQuery[]='('.$field.'!=0 AND '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00408                                 }
00409                                 if ($ctrl['enablecolumns']['endtime'])  {
00410                                         $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
00411                                         $query[]='('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00412                                         $invQuery[]='('.$field.'!=0 AND '.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00413                                 }
00414                         }
00415                 }
00416                 $outQ = ' AND '.($inv ? '('.implode(' OR ',$invQuery).')' : implode(' AND ',$query));
00417 
00418                 return $outQ;
00419         }
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430         /*******************************************
00431          *
00432          * SQL-related, DEPRECIATED functions
00433          * (use t3lib_DB functions instead)
00434          *
00435          *******************************************/
00436 
00437 
00457         function mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')      {
00458                 $query = $GLOBALS['TYPO3_DB']->SELECTquery(
00459                                         $select,
00460                                         $local_table.','.$mm_table.($foreign_table?','.$foreign_table:''),
00461                                         $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').' '.
00462                                                 $whereClause,   // whereClauseMightContainGroupOrderBy
00463                                         $groupBy,
00464                                         $orderBy,
00465                                         $limit
00466                                 );
00467                 return $query;
00468         }
00469 
00479         function DBcompileInsert($table,$fields_values) {
00480                 return $GLOBALS['TYPO3_DB']->INSERTquery($table, $fields_values);
00481         }
00482 
00493         function DBcompileUpdate($table,$where,$fields_values)  {
00494                 return $GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fields_values);
00495         }
00496 
00497 
00498 
00499 
00500 
00501 
00502 
00503 
00504 
00505 
00506         /*******************************************
00507          *
00508          * Page tree, TCA related
00509          *
00510          *******************************************/
00511 
00522         function BEgetRootLine($uid,$clause='') {
00523                 $loopCheck = 100;
00524                 $theRowArray = Array();
00525                 $output = Array();
00526                 while ($uid!=0 && $loopCheck>0) {
00527                         $loopCheck--;
00528                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00529                                                         'pid,uid,title,TSconfig,is_siteroot,storage_pid',
00530                                                         'pages',
00531                                                         'uid='.intval($uid).' '.
00532                                                                 t3lib_BEfunc::deleteClause('pages').' '.
00533                                                                 $clause         // whereClauseMightContainGroupOrderBy
00534                                                 );
00535                         if ($GLOBALS['TYPO3_DB']->sql_error())  {
00536                                 debug($GLOBALS['TYPO3_DB']->sql_error(),1);
00537                         }
00538                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00539                                 t3lib_BEfunc::fixVersioningPid('pages',$row);
00540                                 $uid = $row['pid'];
00541                                 $theRowArray[]=$row;
00542                         } else {
00543                                 break;
00544                         }
00545                 }
00546                 if ($uid==0) {$theRowArray[] = Array('uid'=>0,'title'=>'');}
00547                 if (is_array($theRowArray))     {
00548                         reset($theRowArray);
00549                         $c=count($theRowArray);
00550                         while(list($key,$val)=each($theRowArray))       {
00551                                 $c--;
00552                                 $output[$c]['uid'] = $val['uid'];
00553                                 $output[$c]['pid'] = $val['pid'];
00554                                 if (isset($val['_ORIG_pid'])) $output[$c]['_ORIG_pid'] = $val['_ORIG_pid'];
00555                                 $output[$c]['title'] = $val['title'];
00556                                 $output[$c]['TSconfig'] = $val['TSconfig'];
00557                                 $output[$c]['is_siteroot'] = $val['is_siteroot'];
00558                                 $output[$c]['storage_pid'] = $val['storage_pid'];
00559                         }
00560                 }
00561                 return $output;
00562         }
00563 
00571         function openPageTree($pid,$clearExpansion)     {
00572                 global $BE_USER;
00573 
00574                         // Get current expansion data:
00575                 if ($clearExpansion)    {
00576                         $expandedPages = array();
00577                 } else {
00578                         $expandedPages = unserialize($BE_USER->uc['browseTrees']['browsePages']);
00579                 }
00580 
00581                         // Get rootline:
00582                 $rL = t3lib_BEfunc::BEgetRootLine($pid);
00583 
00584                         // First, find out what mount index to use (if more than one DB mount exists):
00585                 $mountIndex = 0;
00586                 $mountKeys = array_flip($BE_USER->returnWebmounts());
00587                 foreach($rL as $rLDat)  {
00588                         if (isset($mountKeys[$rLDat['uid']]))   {
00589                                 $mountIndex = $mountKeys[$rLDat['uid']];
00590                                 break;
00591                         }
00592                 }
00593 
00594                         // Traverse rootline and open paths:
00595                 foreach($rL as $rLDat)  {
00596                         $expandedPages[$mountIndex][$rLDat['uid']] = 1;
00597                 }
00598 
00599                         // Write back:
00600                 $BE_USER->uc['browseTrees']['browsePages'] = serialize($expandedPages);
00601                 $BE_USER->writeUC();
00602         }
00603 
00616         function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)   {
00617                 if (!$titleLimit) { $titleLimit=1000; }
00618 
00619                 $loopCheck = 100;
00620                 $output = $fullOutput = '/';
00621                 while ($uid!=0 && $loopCheck>0) {
00622                         $loopCheck--;
00623                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00624                                                 'uid,pid,title',
00625                                                 'pages',
00626                                                 'uid='.intval($uid).
00627                                                         t3lib_BEfunc::deleteClause('pages').
00628                                                         (strlen(trim($clause)) ? ' AND '.$clause : '')
00629                                         );
00630                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00631                                 t3lib_BEfunc::fixVersioningPid('pages',$row);
00632 
00633                                 if ($row['_ORIG_pid'])  {
00634                                         $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...
00635                                 }
00636                                 $uid = $row['pid'];
00637                                 $output = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$titleLimit).$output;
00638                                 if ($fullTitleLimit)    $fullOutput = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$fullTitleLimit).$fullOutput;
00639                         } else {
00640                                 break;
00641                         }
00642                 }
00643 
00644                 if ($fullTitleLimit)    {
00645                         return array($output, $fullOutput);
00646                 } else {
00647                         return $output;
00648                 }
00649         }
00650 
00658         function getExcludeFields()     {
00659                 global $TCA;
00660                         // All TCA keys:
00661                 $theExcludeArray = Array();
00662                 $tc_keys = array_keys($TCA);
00663                 foreach($tc_keys as $table)     {
00664                                 // Load table
00665                         t3lib_div::loadTCA($table);
00666                                 // All field names configured:
00667                         if (is_array($TCA[$table]['columns']))  {
00668                                 $f_keys = array_keys($TCA[$table]['columns']);
00669                                 foreach($f_keys as $field)      {
00670                                         if ($TCA[$table]['columns'][$field]['exclude']) {
00671                                                         // Get Human Readable names of fields and table:
00672                                                 $Fname=$GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
00673                                                         // add entry:
00674                                                 $theExcludeArray[] = Array($Fname , $table.':'.$field);
00675                                         }
00676                                 }
00677                         }
00678                 }
00679                 return $theExcludeArray;
00680         }
00681 
00688         function getExplicitAuthFieldValues()   {
00689                 global $TCA;
00690 
00691                         // Initialize:
00692                 $adLabel = array(
00693                         'ALLOW' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.allow'),
00694                         'DENY' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.deny'),
00695                 );
00696 
00697                         // All TCA keys:
00698                 $allowDenyOptions = Array();
00699                 $tc_keys = array_keys($TCA);
00700                 foreach($tc_keys as $table)     {
00701 
00702                                 // Load table
00703                         t3lib_div::loadTCA($table);
00704 
00705                                 // All field names configured:
00706                         if (is_array($TCA[$table]['columns']))  {
00707                                 $f_keys = array_keys($TCA[$table]['columns']);
00708                                 foreach($f_keys as $field)      {
00709                                         $fCfg = $TCA[$table]['columns'][$field]['config'];
00710                                         if ($fCfg['type']=='select' && $fCfg['authMode'])       {
00711 
00712                                                         // Check for items:
00713                                                 if (is_array($fCfg['items']))   {
00714                                                                 // Get Human Readable names of fields and table:
00715                                                         $allowDenyOptions[$table.':'.$field]['tableFieldLabel'] = $GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
00716 
00717                                                                 // Check for items:
00718                                                         foreach($fCfg['items'] as $iVal)        {
00719                                                                 if (strcmp($iVal[1],''))        {       // Values '' is not controlled by this setting.
00720 
00721                                                                                 // Find iMode:
00722                                                                         $iMode = '';
00723                                                                         switch((string)$fCfg['authMode'])       {
00724                                                                                 case 'explicitAllow':
00725                                                                                         $iMode = 'ALLOW';
00726                                                                                 break;
00727                                                                                 case 'explicitDeny':
00728                                                                                         $iMode = 'DENY';
00729                                                                                 break;
00730                                                                                 case 'individual':
00731                                                                                         if (!strcmp($iVal[4],'EXPL_ALLOW'))     {
00732                                                                                                 $iMode = 'ALLOW';
00733                                                                                         } elseif (!strcmp($iVal[4],'EXPL_DENY'))        {
00734                                                                                                 $iMode = 'DENY';
00735                                                                                         }
00736                                                                                 break;
00737                                                                         }
00738 
00739                                                                                 // Set iMode:
00740                                                                         if ($iMode)     {
00741                                                                                 $allowDenyOptions[$table.':'.$field]['items'][$iVal[1]] = array($iMode, $GLOBALS['LANG']->sl($iVal[0]), $adLabel[$iMode]);
00742                                                                         }
00743                                                                 }
00744                                                         }
00745                                                 }
00746                                         }
00747                                 }
00748                         }
00749                 }
00750 
00751                 return $allowDenyOptions;
00752         }
00753 
00759         function getSystemLanguages()   {
00760 
00761                         // Initialize, add default language:
00762                 $sysLanguages = array();
00763                 $sysLanguages[] = array('Default language', 0);
00764 
00765                         // Traverse languages
00766                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,flag','sys_language','pid=0'.t3lib_BEfunc::deleteClause('sys_language'));
00767                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00768                         $sysLanguages[] = array($row['title'].' ['.$row['uid'].']', $row['uid'], ($row['flag'] ? '../t3lib/gfx/flags/'.$row['flag'] : ''));
00769                 }
00770 
00771                 return $sysLanguages;
00772         }
00773 
00784         function readPageAccess($id,$perms_clause)      {
00785                 if ((string)$id!='')    {
00786                         $id = intval($id);
00787                         if (!$id)       {
00788                                 if ($GLOBALS['BE_USER']->isAdmin())     {
00789                                         $path = '/';
00790                                         $pageinfo['_thePath'] = $path;
00791                                         return $pageinfo;
00792                                 }
00793                         } else {
00794                                 $pageinfo = t3lib_BEfunc::getRecord('pages',$id,'*',($perms_clause ? ' AND '.$perms_clause : ''));
00795                                 if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause))   {
00796                                         list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
00797                                         return $pageinfo;
00798                                 }
00799                         }
00800                 }
00801                 return false;
00802         }
00803 
00813         function getTCAtypes($table,$rec,$useFieldNameAsKey=0)  {
00814                 global $TCA;
00815 
00816                 t3lib_div::loadTCA($table);
00817                 if ($TCA[$table])       {
00818 
00819                                 // Get type value:
00820                         $fieldValue = t3lib_BEfunc::getTCAtypeValue($table,$rec);
00821 
00822                                 // Get typesConf
00823                         $typesConf = $TCA[$table]['types'][$fieldValue];
00824 
00825                                 // Get fields list and traverse it
00826                         $fieldList = explode(',', $typesConf['showitem']);
00827                         $altFieldList = array();
00828 
00829                                 // Traverse fields in types config and parse the configuration into a nice array:
00830                         foreach($fieldList as $k => $v) {
00831                                 list($pFieldName, $pAltTitle, $pPalette, $pSpec) = t3lib_div::trimExplode(';', $v);
00832                                 $defaultExtras = is_array($TCA[$table]['columns'][$pFieldName]) ? $TCA[$table]['columns'][$pFieldName]['defaultExtras'] : '';
00833                                 $specConfParts = t3lib_BEfunc::getSpecConfParts($pSpec, $defaultExtras);
00834 
00835                                 $fieldList[$k]=array(
00836                                         'field' => $pFieldName,
00837                                         'title' => $pAltTitle,
00838                                         'palette' => $pPalette,
00839                                         'spec' => $specConfParts,
00840                                         'origString' => $v
00841                                 );
00842                                 if ($useFieldNameAsKey) {
00843                                         $altFieldList[$fieldList[$k]['field']] = $fieldList[$k];
00844                                 }
00845                         }
00846                         if ($useFieldNameAsKey) {
00847                                 $fieldList = $altFieldList;
00848                         }
00849 
00850                                 // Return array:
00851                         return $fieldList;
00852                 }
00853         }
00854 
00866         function getTCAtypeValue($table,$rec)   {
00867                 global $TCA;
00868 
00869                         // 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.
00870                 t3lib_div::loadTCA($table);
00871                 if ($TCA[$table])       {
00872                         $field = $TCA[$table]['ctrl']['type'];
00873                         $fieldValue = $field ? ($rec[$field] ? $rec[$field] : 0) : 0;
00874                         if (!is_array($TCA[$table]['types'][$fieldValue]))      $fieldValue = 1;
00875                         return $fieldValue;
00876                 }
00877         }
00878 
00889         function getSpecConfParts($str, $defaultExtras) {
00890 
00891                         // Add defaultExtras:
00892                 $specConfParts = t3lib_div::trimExplode(':', $defaultExtras.':'.$str, 1);
00893 
00894                 if (count($specConfParts))      {
00895                         foreach($specConfParts as $k2 => $v2)   {
00896                                 unset($specConfParts[$k2]);
00897                                 if (ereg('(.*)\[(.*)\]',$v2,$reg))      {
00898                                         $specConfParts[trim($reg[1])] = array(
00899                                                 'parameters' => t3lib_div::trimExplode('|', $reg[2], 1)
00900                                         );
00901                                 } else {
00902                                         $specConfParts[trim($v2)] = 1;
00903                                 }
00904                         }
00905                 } else {
00906                         $specConfParts = array();
00907                 }
00908                 return $specConfParts;
00909         }
00910 
00919         function getSpecConfParametersFromArray($pArr)  {
00920                 $out=array();
00921                 if (is_array($pArr))    {
00922                         reset($pArr);
00923                         while(list($k,$v)=each($pArr))  {
00924                                 $parts=explode('=',$v,2);
00925                                 if (count($parts)==2)   {
00926                                         $out[trim($parts[0])]=trim($parts[1]);
00927                                 } else {
00928                                         $out[$k]=$v;
00929                                 }
00930                         }
00931                 }
00932                 return $out;
00933         }
00934 
00945         function getFlexFormDS($conf,$row,$table, $fieldName = '')      {
00946                 global $TYPO3_CONF_VARS;
00947 
00948                         // Get pointer field etc from TCA-config:
00949                 $ds_pointerField =      $conf['ds_pointerField'];
00950                 $ds_array =             $conf['ds'];
00951                 $ds_tableField =        $conf['ds_tableField'];
00952                 $ds_searchParentField =         $conf['ds_pointerField_searchParent'];
00953 
00954                         // Find source value:
00955                 $dataStructArray='';
00956                 if (is_array($ds_array))        {       // If there is a data source array, that takes precedence
00957                                 // If a pointer field is set, take the value from that field in the $row array and use as key.
00958                         if ($ds_pointerField)   {
00959                                 $srcPointer = $row[$ds_pointerField];
00960                                 $srcPointer = isset($ds_array[$srcPointer]) ? $srcPointer : 'default';
00961                         } else $srcPointer='default';
00962 
00963                                 // 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.
00964                         if (substr($ds_array[$srcPointer],0,5)=='FILE:')        {
00965                                 $file = t3lib_div::getFileAbsFileName(substr($ds_array[$srcPointer],5));
00966                                 if ($file && @is_file($file))   {
00967                                         $dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
00968                                 } else $dataStructArray = 'The file "'.substr($dsSrc,5).'" in ds-array key "'.$srcPointer.'" was not found ("'.$file.'")';      // Error message.
00969                         } else {
00970                                 $dataStructArray = t3lib_div::xml2array($ds_array[$srcPointer]);
00971                         }
00972 
00973                 } elseif ($ds_pointerField) {   // If pointer field AND possibly a table/field is set:
00974                                 // Value of field pointed to:
00975                         $srcPointer = $row[$ds_pointerField];
00976 
00977                                 // Searching recursively back if 'ds_pointerField_searchParent' is defined (typ. a page rootline, or maybe a tree-table):
00978                         if ($ds_searchParentField && !$srcPointer)      {
00979                                 $rr = t3lib_BEfunc::getRecord($table,$row['uid'],'uid,'.$ds_searchParentField); // Get the "pid" field - we cannot know that it is in the input record!
00980                                 t3lib_BEfunc::fixVersioningPid($table,$rr);
00981                                 $uidAcc=array();        // Used to avoid looping, if any should happen.
00982                                 $subFieldPointer = $conf['ds_pointerField_searchParent_subField'];
00983                                 while(!$srcPointer)             {
00984                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00985                                                                         'uid,'.$ds_pointerField.','.$ds_searchParentField.($subFieldPointer?','.$subFieldPointer:''),
00986                                                                         $table,
00987                                                                         'uid='.intval($rr[$ds_searchParentField]).t3lib_BEfunc::deleteClause($table)
00988                                                                 );
00989                                         $rr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00990 
00991                                                 // break if no result from SQL db or if looping...
00992                                         if (!is_array($rr) || isset($uidAcc[$rr['uid']]))       break;
00993                                         $uidAcc[$rr['uid']]=1;
00994 
00995                                         t3lib_BEfunc::fixVersioningPid($table,$rr);
00996                                         $srcPointer = ($subFieldPointer && $rr[$subFieldPointer]) ? $rr[$subFieldPointer] : $rr[$ds_pointerField];
00997                                 }
00998                         }
00999 
01000                                 // If there is a srcPointer value:
01001                         if ($srcPointer)        {
01002                                 if (t3lib_div::testInt($srcPointer))    {       // If integer, then its a record we will look up:
01003                                         list($tName,$fName) = explode(':',$ds_tableField,2);
01004                                         if ($tName && $fName && is_array($GLOBALS['TCA'][$tName]))      {
01005                                                 $dataStructRec = t3lib_BEfunc::getRecord($tName, $srcPointer);
01006                                                 $dataStructArray = t3lib_div::xml2array($dataStructRec[$fName]);
01007                                         } else $dataStructArray = 'No tablename ('.$tName.') or fieldname ('.$fName.') was found an valid!';
01008                                 } else {        // Otherwise expect it to be a file:
01009                                         $file = t3lib_div::getFileAbsFileName($srcPointer);
01010                                         if ($file && @is_file($file))   {
01011                                                 $dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
01012                                         } else $dataStructArray='The file "'.$srcPointer.'" was not found ("'.$file.'")';       // Error message.
01013                                 }
01014                         } else $dataStructArray='No source value in fieldname "'.$ds_pointerField.'"';  // Error message.
01015                 } else $dataStructArray='No proper configuration!';
01016 
01017                         // Hook for post-processing the Flexform DS. Introduces the possibility to configure Flexforms via TSConfig
01018                 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'])) {
01019                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'] as $classRef) {
01020                                 $hookObj = &t3lib_div::getUserObj($classRef);
01021                                 if (method_exists($hookObj, 'getFlexFormDS_postProcessDS')) {
01022                                         $hookObj->getFlexFormDS_postProcessDS($dataStructArray, $conf, $row, $table, $fieldName);
01023                                 }
01024                         }
01025                 }
01026 
01027                 return $dataStructArray;
01028         }
01029 
01030 
01031 
01032 
01033 
01034 
01035 
01036 
01037 
01038 
01039 
01040 
01041 
01042 
01043 
01044 
01045 
01046 
01047         /*******************************************
01048          *
01049          * Caching related
01050          *
01051          *******************************************/
01052 
01063         function storeHash($hash,$data,$ident)  {
01064                 $insertFields = array(
01065                         'hash' => $hash,
01066                         'content' => $data,
01067                         'ident' => $ident,
01068                         'tstamp' => time()
01069                 );
01070                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
01071                 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
01072         }
01073 
01083         function getHash($hash,$expTime=0)      {
01084                         // if expTime is not set, the hash will never expire
01085                 $expTime = intval($expTime);
01086                 if ($expTime)   {
01087                         $whereAdd = ' AND tstamp > '.(time()-$expTime);
01088                 }
01089                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').$whereAdd);
01090                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01091                         return $row['content'];
01092                 }
01093         }
01094 
01095 
01096 
01097 
01098 
01099 
01100 
01101 
01102         /*******************************************
01103          *
01104          * TypoScript related
01105          *
01106          *******************************************/
01107 
01119         function getPagesTSconfig($id,$rootLine='',$returnPartArray=0)  {
01120                 $id=intval($id);
01121                 if (!is_array($rootLine))       {
01122                         $rootLine = t3lib_BEfunc::BEgetRootLine($id,'');
01123                 }
01124                 ksort($rootLine);       // Order correctly, changed 030102
01125                 reset($rootLine);
01126                 $TSdataArray = array();
01127                 $TSdataArray['defaultPageTSconfig']=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];   // Setting default configuration:
01128                 while(list($k,$v)=each($rootLine))      {
01129                         $TSdataArray['uid_'.$v['uid']]=$v['TSconfig'];
01130                 }
01131                 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
01132                 if ($returnPartArray)   {
01133                         return $TSdataArray;
01134                 }
01135 
01136                         // Parsing the user TS (or getting from cache)
01137                 $userTS = implode($TSdataArray,chr(10).'[GLOBAL]'.chr(10));
01138                 $hash = md5('pageTS:'.$userTS);
01139                 $cachedContent = t3lib_BEfunc::getHash($hash,0);
01140                 $TSconfig = array();
01141                 if (isset($cachedContent))      {
01142                         $TSconfig = unserialize($cachedContent);
01143                 } else {
01144                         $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
01145                         $parseObj->parse($userTS);
01146                         $TSconfig = $parseObj->setup;
01147                         t3lib_BEfunc::storeHash($hash,serialize($TSconfig),'PAGES_TSconfig');
01148                 }
01149                 return $TSconfig;
01150         }
01151 
01170         function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='')   {
01171                 $id=intval($id);
01172                 if (is_array($pageTS) && $id>0) {
01173                         if (!is_array($impParams))      {
01174                                 $impParams =t3lib_BEfunc::implodeTSParams(t3lib_BEfunc::getPagesTSconfig($id));
01175                         }
01176                         reset($pageTS);
01177                         $set=array();
01178                         while(list($f,$v)=each($pageTS))        {
01179                                 $f = $TSconfPrefix.$f;
01180                                 if ((!isset($impParams[$f])&&trim($v)) || strcmp(trim($impParams[$f]),trim($v)))        {
01181                                         $set[$f]=trim($v);
01182                                 }
01183                         }
01184                         if (count($set))        {
01185                                         // Get page record and TS config lines
01186                                 $pRec = t3lib_befunc::getRecord('pages',$id);
01187                                 $TSlines = explode(chr(10),$pRec['TSconfig']);
01188                                 $TSlines = array_reverse($TSlines);
01189                                         // Reset the set of changes.
01190                                 reset($set);
01191                                 while(list($f,$v)=each($set))   {
01192                                         reset($TSlines);
01193                                         $inserted=0;
01194                                         while(list($ki,$kv)=each($TSlines))     {
01195                                                 if (substr($kv,0,strlen($f)+1)==$f.'=') {
01196                                                         $TSlines[$ki]=$f.'='.$v;
01197                                                         $inserted=1;
01198                                                         break;
01199                                                 }
01200                                         }
01201                                         if (!$inserted) {
01202                                                 $TSlines = array_reverse($TSlines);
01203                                                 $TSlines[]=$f.'='.$v;
01204                                                 $TSlines = array_reverse($TSlines);
01205                                         }
01206                                 }
01207                                 $TSlines = array_reverse($TSlines);
01208 
01209                                         // store those changes
01210                                 $TSconf = implode(chr(10),$TSlines);
01211 
01212                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($id), array('TSconfig' => $TSconf));
01213                         }
01214                 }
01215         }
01216 
01225         function implodeTSParams($p,$k='')      {
01226                 $implodeParams=array();
01227                 if (is_array($p))       {
01228                         reset($p);
01229                         while(list($kb,$val)=each($p))  {
01230                                 if (is_array($val))     {
01231                                         $implodeParams = array_merge($implodeParams,t3lib_BEfunc::implodeTSParams($val,$k.$kb));
01232                                 } else {
01233                                         $implodeParams[$k.$kb]=$val;
01234                                 }
01235                         }
01236                 }
01237                 return $implodeParams;
01238         }
01239 
01240 
01241 
01242 
01243 
01244 
01245 
01246 
01247         /*******************************************
01248          *
01249          * Users / Groups related
01250          *
01251          *******************************************/
01252 
01262         function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='') {
01263                 $be_user_Array=Array();
01264 
01265                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_users', 'pid=0 '.$where.t3lib_BEfunc::deleteClause('be_users'), '', 'username');
01266                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
01267                         $be_user_Array[$row['uid']]=$row;
01268                 }
01269                 return $be_user_Array;
01270         }
01271 
01280         function getGroupNames($fields='title,uid', $where='')  {
01281                 $be_group_Array = Array();
01282                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_groups', 'pid=0 '.$where.t3lib_BEfunc::deleteClause('be_groups'), '', 'title');
01283                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
01284                         $be_group_Array[$row['uid']] = $row;
01285                 }
01286                 return $be_group_Array;
01287         }
01288 
01297         function getListGroupNames($fields='title,uid') {
01298                 $exQ=' AND hide_in_lists=0';
01299                 if (!$GLOBALS['BE_USER']->isAdmin())    {
01300                         $exQ.=' AND uid IN ('.($GLOBALS['BE_USER']->user['usergroup_cached_list']?$GLOBALS['BE_USER']->user['usergroup_cached_list']:0).')';
01301                 }
01302                 return t3lib_BEfunc::getGroupNames($fields,$exQ);
01303         }
01304 
01316         function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0)   {
01317                 if (is_array($usernames) && is_array($groupArray))      {
01318                         while(list($uid,$row)=each($usernames)) {
01319                                 $userN=$uid;
01320                                 $set=0;
01321                                 if ($row['uid']!=$GLOBALS['BE_USER']->user['uid'])      {
01322                                         reset($groupArray);
01323                                         while(list(,$v)=each($groupArray))      {
01324                                                 if ($v && t3lib_div::inList($row['usergroup_cached_list'],$v))  {
01325                                                         $userN = $row['username'];
01326                                                         $set=1;
01327                                                 }
01328                                         }
01329                                 } else {
01330                                         $userN = $row['username'];
01331                                         $set=1;
01332                                 }
01333                                 $usernames[$uid]['username']=$userN;
01334                                 if ($excludeBlindedFlag && !$set) {unset($usernames[$uid]);}
01335                         }
01336                 }
01337                 return $usernames;
01338         }
01339 
01349         function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0)     {
01350                 if (is_array($groups) && is_array($groupArray)) {
01351                         while(list($uid,$row)=each($groups))    {
01352                                 $groupN=$uid;
01353                                 $set=0;
01354                                 if (t3lib_div::inArray($groupArray,$uid))       {
01355                                         $groupN=$row['title'];
01356                                         $set=1;
01357                                 }
01358                                 $groups[$uid]['title']=$groupN;
01359                                 if ($excludeBlindedFlag && !$set) {unset($groups[$uid]);}
01360                         }
01361                 }
01362                 return $groups;
01363         }
01364 
01365 
01366 
01367 
01368 
01369 
01370 
01371 
01372 
01373 
01374 
01375 
01376 
01377         /*******************************************
01378          *
01379          * Output related
01380          *
01381          *******************************************/
01382 
01390         function daysUntil($tstamp)     {
01391                 $delta_t = $tstamp-$GLOBALS['EXEC_TIME'];
01392                 return ceil($delta_t/(3600*24));
01393         }
01394 
01402         function date($tstamp)  {
01403                 return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp);
01404         }
01405 
01413         function datetime($value)       {
01414                 return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $value);
01415         }
01416 
01425         function time($value)   {
01426                 $hh = floor($value/3600);
01427                 $min = floor(($value-$hh*3600)/60);
01428                 $sec = $value-$hh*3600-$min*60;
01429                 $l = sprintf('%02d',$hh).':'.sprintf('%02d',$min).':'.sprintf('%02d',$sec);
01430                 return $l;
01431         }
01432 
01441         function calcAge($seconds,$labels = 'min|hrs|days|yrs') {
01442                 $labelArr = explode('|',$labels);
01443                 $prefix='';
01444                 if ($seconds<0) {$prefix='-'; $seconds=abs($seconds);}
01445                 if ($seconds<3600)      {
01446                         $seconds = round ($seconds/60).' '.trim($labelArr[0]);
01447                 } elseif ($seconds<24*3600)     {
01448                         $seconds = round ($seconds/3600).' '.trim($labelArr[1]);
01449                 } elseif ($seconds<365*24*3600) {
01450                         $seconds = round ($seconds/(24*3600)).' '.trim($labelArr[2]);
01451                 } else {
01452                         $seconds = round ($seconds/(365*24*3600)).' '.trim($labelArr[3]);
01453                 }
01454                 return $prefix.$seconds;
01455         }
01456 
01467         function dateTimeAge($tstamp,$prefix=1,$date='')        {
01468                 return $tstamp ?
01469                                 ($date=='date' ? t3lib_BEfunc::date($tstamp) : t3lib_BEfunc::datetime($tstamp)).
01470                                 ' ('.t3lib_BEfunc::calcAge($prefix*(time()-$tstamp),$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')' : '';
01471         }
01472 
01485         function titleAttrib($content='',$hsc=0)        {
01486                 global $CLIENT;
01487                 $attrib= ($CLIENT['BROWSER']=='net'&&$CLIENT['VERSION']<5)||$CLIENT['BROWSER']=='konqu' ? 'alt' : 'title';
01488                 return strcmp($content,'')?' '.$attrib.'="'.($hsc?htmlspecialchars($content):$content).'"' : $attrib;
01489         }
01490 
01498         function titleAltAttrib($content)       {
01499                 $out='';
01500                 $out.=' alt="'.htmlspecialchars($content).'"';
01501                 $out.=' title="'.htmlspecialchars($content).'"';
01502                 return $out;
01503         }
01504 
01522         function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir=NULL,$abs=0,$tparams='',$size='')    {
01523                 global $TCA;
01524                         // Load table.
01525                 t3lib_div::loadTCA($table);
01526 
01527                         // Find uploaddir automatically
01528                 $uploaddir = (is_null($uploaddir)) ? $TCA[$table]['columns'][$field]['config']['uploadfolder'] : $uploaddir;
01529                 $uploaddir = preg_replace('#/$#','',$uploaddir);
01530 
01531                         // Set thumbs-script:
01532                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
01533                         $thumbScript='gfx/notfound_thumb.gif';
01534                 } elseif(!$thumbScript) {
01535                         $thumbScript='thumbs.php';
01536                 }
01537                         // Check and parse the size parameter
01538                 $sizeParts=array();
01539                 if ($size = trim($size)) {
01540                         $sizeParts = explode('x', $size.'x'.$size);
01541                         if(!intval($sizeParts[0])) $size='';
01542                 }
01543 
01544                         // Traverse files:
01545                 $thumbs = explode(',', $row[$field]);
01546                 $thumbData='';
01547                 while(list(,$theFile)=each($thumbs))    {
01548                         if (trim($theFile))     {
01549                                 $fI = t3lib_div::split_fileref($theFile);
01550                                 $ext = $fI['fileext'];
01551                                                 // New 190201 start
01552                                 $max=0;
01553                                 if (t3lib_div::inList('gif,jpg,png',$ext)) {
01554                                         $imgInfo=@getimagesize(PATH_site.$uploaddir.'/'.$theFile);
01555                                         if (is_array($imgInfo)) {$max = max($imgInfo[0],$imgInfo[1]);}
01556                                 }
01557                                         // use the original image if it's size fits to the thumbnail size
01558                                 if ($max && $max<=(count($sizeParts)&&max($sizeParts)?max($sizeParts):56))      {
01559                                         $url = $uploaddir.'/'.trim($theFile);
01560                                         $theFile = '../'.$url;
01561                                         $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
01562                                         $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="../'.$backPath.$url.'" '.$imgInfo[3].' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';
01563                                                 // New 190201 stop
01564                                 } elseif ($ext=='ttf' || t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$ext)) {
01565                                         $theFile = ($abs?'':'../').($uploaddir?$uploaddir.'/':'').trim($theFile);
01566                                         $params = '&file='.rawurlencode($theFile);
01567                                         $params .= $size?'&size='.$size:'';
01568                                         $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
01569                                         $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
01570                                         $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.htmlspecialchars($backPath.$url).'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /></a> ';
01571                                 } else {
01572                                         $icon = t3lib_BEfunc::getFileIcon($ext);
01573                                         $url = 'gfx/fileicons/'.$icon;
01574                                         $thumbData.='<img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /> ';
01575                                 }
01576                         }
01577                 }
01578                 return $thumbData;
01579         }
01580 
01591         function getThumbNail($thumbScript,$theFile,$tparams='',$size='')       {
01592                 $params = '&file='.rawurlencode($theFile);
01593                 $params .= trim($size)?'&size='.trim($size):'';
01594                 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
01595                 $th='<img src="'.htmlspecialchars($url).'" title="'.trim(basename($theFile)).'"'.($tparams?" ".$tparams:"").' alt="" />';
01596                 return $th;
01597         }
01598 
01608         function titleAttribForPages($row,$perms_clause='',$includeAttrib=1)    {
01609                 global $TCA,$LANG;
01610                 $parts=array();
01611                 $parts[] = 'id='.$row['uid'];
01612                 if ($row['alias'])      $parts[]=$LANG->sL($TCA['pages']['columns']['alias']['label']).' '.$row['alias'];
01613                 if ($row['t3ver_id'])   $parts[] = 'v#'.$row['t3ver_id'];
01614                 if ($row['doktype']=='3')       {
01615                         $parts[]=$LANG->sL($TCA['pages']['columns']['url']['label']).' '.$row['url'];
01616                 } elseif ($row['doktype']=='4') {
01617                         if ($perms_clause)      {
01618                                 $label = t3lib_BEfunc::getRecordPath(intval($row['shortcut']),$perms_clause,20);
01619                         } else {
01620                                 $lRec = t3lib_BEfunc::getRecord('pages',intval($row['shortcut']),'title');
01621                                 $label = $lRec['title'];
01622                         }
01623                         if ($row['shortcut_mode']>0)    {
01624                                 $label.=', '.$LANG->sL($TCA['pages']['columns']['shortcut_mode']['label']).' '.
01625                                                         $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('pages','shortcut_mode',$row['shortcut_mode']));
01626                         }
01627                         $parts[]=$LANG->sL($TCA['pages']['columns']['shortcut']['label']).' '.$label;
01628                 } elseif ($row['doktype']=='7') {
01629                         if ($perms_clause)      {
01630                                 $label = t3lib_BEfunc::getRecordPath(intval($row['mount_pid']),$perms_clause,20);
01631                         } else {
01632                                 $lRec = t3lib_BEfunc::getRecord('pages',intval($row['mount_pid']),'title');
01633                                 $label = $lRec['title'];
01634                         }
01635                         $parts[]=$LANG->sL($TCA['pages']['columns']['mount_pid']['label']).' '.$label;
01636                         if ($row['mount_pid_ol'])       {
01637                                 $parts[] = $LANG->sL($TCA['pages']['columns']['mount_pid_ol']['label']);
01638                         }
01639                 }
01640                 if ($row['nav_hide'])   $parts[] = ereg_replace(':$','',$LANG->sL($TCA['pages']['columns']['nav_hide']['label']));
01641                 if ($row['hidden'])     $parts[] = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.hidden');
01642                 if ($row['starttime'])  $parts[] = $LANG->sL($TCA['pages']['columns']['starttime']['label']).' '.t3lib_BEfunc::dateTimeAge($row['starttime'],-1,'date');
01643                 if ($row['endtime'])    $parts[] = $LANG->sL($TCA['pages']['columns']['endtime']['label']).' '.t3lib_BEfunc::dateTimeAge($row['endtime'],-1,'date');
01644                 if ($row['fe_group'])   {
01645                         if ($row['fe_group']<0) {
01646                                 $label = $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('pages','fe_group',$row['fe_group']));
01647                         } else {
01648                                 $lRec = t3lib_BEfunc::getRecord('fe_groups',$row['fe_group'],'title');
01649                                 $label = $lRec['title'];
01650                         }
01651                         $parts[] = $LANG->sL($TCA['pages']['columns']['fe_group']['label']).' '.$label;
01652                 }
01653                 $out = htmlspecialchars(implode(' - ',$parts));
01654                 return $includeAttrib ? 'title="'.$out.'"' : $out;
01655         }
01656 
01667         function getRecordIconAltText($row,$table='pages')      {
01668                 if ($table=='pages')    {
01669                         $out = t3lib_BEfunc::titleAttribForPages($row,'',0);
01670                 } else {
01671                         $ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
01672 
01673                         $out='id='.$row['uid']; // Uid is added
01674                         if ($table=='pages' && $row['alias'])   {
01675                                 $out.=' / '.$row['alias'];
01676                         }
01677                         if ($GLOBALS['TCA'][$table]['ctrl']['versioning'] && $row['t3ver_id'])  {
01678                                 $out.=' - v#'.$row['t3ver_id'];
01679                         }
01680                         if ($ctrl['disabled'])  {               // Hidden ...
01681                                 $out.=($row[$ctrl['disabled']]?' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.hidden'):'');
01682                         }
01683                         if ($ctrl['starttime']) {
01684                                 if ($row[$ctrl['starttime']] > $GLOBALS['EXEC_TIME'])   {
01685                                         $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').')';
01686                                 }
01687                         }
01688                         if ($row[$ctrl['endtime']])     {
01689                                 $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').')';
01690                         }
01691                 }
01692                 return htmlspecialchars($out);
01693         }
01694 
01704         function getLabelFromItemlist($table,$col,$key) {
01705                 global $TCA;
01706                         // Load full TCA for $table
01707                 t3lib_div::loadTCA($table);
01708 
01709                         // Check, if there is an "items" array:
01710                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]) && is_array($TCA[$table]['columns'][$col]['config']['items']))    {
01711                                 // Traverse the items-array...
01712                         reset($TCA[$table]['columns'][$col]['config']['items']);
01713                         while(list($k,$v)=each($TCA[$table]['columns'][$col]['config']['items']))       {
01714                                         // ... and return the first found label where the value was equal to $key
01715                                 if (!strcmp($v[1],$key))        return $v[0];
01716                         }
01717                 }
01718         }
01719 
01730         function getItemLabel($table,$col,$printAllWrap='')     {
01731                 global $TCA;
01732                         // Load full TCA for $table
01733                 t3lib_div::loadTCA($table);
01734                         // Check if column exists
01735                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]))  {
01736                                 // Re
01737                         return $TCA[$table]['columns'][$col]['label'];
01738                 }
01739                 if ($printAllWrap)      {
01740                         $parts = explode('|',$printAllWrap);
01741                         return $parts[0].$col.$parts[1];
01742                 }
01743         }
01744 
01755         function getRecordTitle($table,$row,$prep=0)    {
01756                 global $TCA;
01757                 if (is_array($TCA[$table]))     {
01758                         $t = $row[$TCA[$table]['ctrl']['label']];
01759                         if ($TCA[$table]['ctrl']['label_alt'] && ($TCA[$table]['ctrl']['label_alt_force'] || !strcmp($t,'')))   {
01760                                 $altFields=t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
01761                                 $tA=array();
01762                                 $tA[]=$t;
01763                                 while(list(,$fN)=each($altFields))      {
01764                                         $t = $tA[] = trim(strip_tags($row[$fN]));
01765                                         if (strcmp($t,'') && !$TCA[$table]['ctrl']['label_alt_force'])  break;
01766                                 }
01767                                 if ($TCA[$table]['ctrl']['label_alt_force'])    $t=implode(', ',$tA);
01768                         }
01769                         if ($prep)      {
01770                                 $t = htmlspecialchars(t3lib_div::fixed_lgd_cs($t,$GLOBALS['BE_USER']->uc['titleLen']));
01771                                 if (!strcmp(trim($t),''))       $t='<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</em>';
01772                         }
01773                         return $t;
01774                 }
01775         }
01776 
01793         function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0,$noRecordLookup=FALSE,$uid=0)    {
01794                 global $TCA;
01795                         // Load full TCA for $table
01796                 t3lib_div::loadTCA($table);
01797                         // Check if table and field is configured:
01798                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]))  {
01799                                 // Depending on the fields configuration, make a meaningful output value.
01800                         $theColConf = $TCA[$table]['columns'][$col]['config'];
01801                         $l='';
01802                         switch((string)$theColConf['type'])     {
01803                                 case 'radio':
01804                                         $l=t3lib_BEfunc::getLabelFromItemlist($table,$col,$value);
01805                                         $l=$GLOBALS['LANG']->sL($l);
01806                                 break;
01807                                 case 'select':
01808                                         if ($theColConf['MM'])  {
01809                                                         // Display the title of MM related records in lists
01810                                                 $MMres = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
01811                                                                 $theColConf['foreign_table'].'.'.$TCA[$theColConf['foreign_table']]['ctrl']['label'],
01812                                                                 $table,
01813                                                                 $theColConf['MM'],
01814                                                                 $theColConf['foreign_table'],
01815                                                                 'AND '.$table.'.uid ='.intval($uid).t3lib_BEfunc::deleteClause($theColConf['foreign_table'])
01816                                                         );
01817                                                 if ($MMres) {
01818                                                         while($MMrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($MMres))   {
01819                                                                 $mmlA[] = $MMrow[$TCA[$theColConf['foreign_table']]['ctrl']['label']];
01820                                                         }
01821                                                         if (is_array($mmlA)) {
01822                                                                 $l=implode(', ',$mmlA);
01823                                                         } else {
01824                                                                 $l = '';
01825                                                         }
01826                                                 } else {
01827                                                         $l = 'n/A';
01828                                                 }
01829                                         } else {
01830                                                 $l = t3lib_BEfunc::getLabelFromItemlist($table,$col,$value);
01831                                                 $l = $GLOBALS['LANG']->sL($l);
01832                                                 if ($theColConf['foreign_table'] && !$l && $TCA[$theColConf['foreign_table']])  {
01833                                                         if ($noRecordLookup)    {
01834                                                                 $l = $value;
01835                                                         } else {
01836                                                                 $rParts = t3lib_div::trimExplode(',',$value,1);
01837                                                                 reset($rParts);
01838                                                                 $lA = array();
01839                                                                 while(list(,$rVal)=each($rParts))       {
01840                                                                         $rVal = intval($rVal);
01841                                                                         if ($rVal>0) {
01842                                                                                 $r=t3lib_BEfunc::getRecord($theColConf['foreign_table'],$rVal);
01843                                                                         } else {
01844                                                                                 $r=t3lib_BEfunc::getRecord($theColConf['neg_foreign_table'],-$rVal);
01845                                                                         }
01846                                                                         if (is_array($r))       {
01847                                                                                 $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);
01848                                                                         } else {
01849                                                                                 $lA[]=$rVal?'['.$rVal.'!]':'';
01850                                                                         }
01851                                                                 }
01852                                                                 $l = implode(',',$lA);
01853                                                         }
01854                                                 }
01855                                         }
01856                                 break;
01857                                 case 'check':
01858                                         if (!is_array($theColConf['items']) || count($theColConf['items'])==1)  {
01859                                                 $l = $value ? 'Yes' : '';
01860                                         } else {
01861                                                 reset($theColConf['items']);
01862                                                 $lA=Array();
01863                                                 while(list($key,$val)=each($theColConf['items']))       {
01864                                                         if ($value & pow(2,$key))       {$lA[]=$GLOBALS['LANG']->sL($val[0]);}
01865                                                 }
01866                                                 $l = implode($lA,', ');
01867                                         }
01868                                 break;
01869                                 case 'input':
01870                                         if ($value)     {
01871                                                 if (t3lib_div::inList($theColConf['eval'],'date'))      {
01872                                                         $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')).')';
01873                                                 } elseif (t3lib_div::inList($theColConf['eval'],'time'))        {
01874                                                         $l = t3lib_BEfunc::time($value);
01875                                                 } elseif (t3lib_div::inList($theColConf['eval'],'datetime'))    {
01876                                                         $l = t3lib_BEfunc::datetime($value);
01877                                                 } else {
01878                                                         $l = $value;
01879                                                 }
01880                                         }
01881                                 break;
01882                                 default:
01883                                         if ($defaultPassthrough)        {
01884                                                 $l=$value;
01885                                         } elseif ($theColConf['MM'])    {
01886                                                 $l='N/A';
01887                                         } elseif ($value)       {
01888                                                 $l=t3lib_div::fixed_lgd_cs(strip_tags($value),200);
01889                                         }
01890                                 break;
01891                         }
01892                         if ($fixed_lgd_chars)   {
01893                                 return t3lib_div::fixed_lgd_cs($l,$fixed_lgd_chars);
01894                         } else {
01895                                 return $l;
01896                         }
01897                 }
01898         }
01899 
01912         function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0,$uid=0)       {
01913                 global $TCA;
01914                 $fVnew = t3lib_BEfunc::getProcessedValue($table,$fN,$fV,$fixed_lgd_chars,0,0,$uid);
01915                 if (!isset($fVnew))     {
01916                         if (is_array($TCA[$table]))     {
01917                                 if ($fN==$TCA[$table]['ctrl']['tstamp'] || $fN==$TCA[$table]['ctrl']['crdate']) {
01918                                         $fVnew = t3lib_BEfunc::datetime($fV);
01919                                 } elseif ($fN=='pid'){
01920                                         $fVnew = t3lib_BEfunc::getRecordPath($fV,'1=1',20);     // Fetches the path with no regard to the users permissions to select pages.
01921                                 } else {
01922                                         $fVnew = $fV;
01923                                 }
01924                         }
01925                 }
01926                 return $fVnew;
01927         }
01928 
01936         function getFileIcon($ext)      {
01937                 return $GLOBALS['FILEICONS'][$ext] ? $GLOBALS['FILEICONS'][$ext] : $GLOBALS['FILEICONS']['default'];
01938         }
01939 
01950         function getCommonSelectFields($table,$prefix)  {
01951                 global $TCA;
01952                 $fields = array();
01953                 $fields[] = $prefix.'uid';
01954                 $fields[] = $prefix.$TCA[$table]['ctrl']['label'];
01955 
01956                 if ($TCA[$table]['ctrl']['label_alt'])  {
01957                         $secondFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
01958                         foreach($secondFields as $fieldN)       {
01959                                 $fields[] = $prefix.$fieldN;
01960                         }
01961                 }
01962                 if ($TCA[$table]['ctrl']['versioning']) {
01963                         $fields[] = $prefix.'t3ver_id';
01964                 }
01965 
01966                 if ($TCA[$table]['ctrl']['selicon_field'])      $fields[] = $prefix.$TCA[$table]['ctrl']['selicon_field'];
01967                 if ($TCA[$table]['ctrl']['typeicon_column'])    $fields[] = $prefix.$TCA[$table]['ctrl']['typeicon_column'];
01968 
01969                 if (is_array($TCA[$table]['ctrl']['enablecolumns']))            {
01970                         if ($TCA[$table]['ctrl']['enablecolumns']['disabled'])  $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['disabled'];
01971                         if ($TCA[$table]['ctrl']['enablecolumns']['starttime']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['starttime'];
01972                         if ($TCA[$table]['ctrl']['enablecolumns']['endtime'])   $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['endtime'];
01973                         if ($TCA[$table]['ctrl']['enablecolumns']['fe_group'])  $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['fe_group'];
01974                 }
01975 
01976                 return implode(',',array_unique($fields));
01977         }
01978 
01990         function makeConfigForm($configArray,$defaults,$dataPrefix)     {
01991                 $params = $defaults;
01992                 if (is_array($configArray))     {
01993                         reset($configArray);
01994                         $lines=array();
01995                         while(list($fname,$config)=each($configArray))  {
01996                                 if (is_array($config))  {
01997                                         $lines[$fname]='<strong>'.htmlspecialchars($config[1]).'</strong><br />';
01998                                         $lines[$fname].=$config[2].'<br />';
01999                                         switch($config[0])      {
02000                                                 case 'string':
02001                                                 case 'short':
02002                                                         $formEl = '<input type="text" name="'.$dataPrefix.'['.$fname.']" value="'.$params[$fname].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($config[0]=='short'?24:48).' />';
02003                                                 break;
02004                                                 case 'check':
02005                                                         $formEl = '<input type="hidden" name="'.$dataPrefix.'['.$fname.']" value="0" /><input type="checkbox" name="'.$dataPrefix.'['.$fname.']" value="1"'.($params[$fname]?' checked="checked"':'').' />';
02006                                                 break;
02007                                                 case 'comment':
02008                                                         $formEl = '';
02009                                                 break;
02010                                                 case 'select':
02011                                                         reset($config[3]);
02012                                                         $opt=array();
02013                                                         while(list($k,$v)=each($config[3]))     {
02014                                                                 $opt[]='<option value="'.htmlspecialchars($k).'"'.($params[$fname]==$k?' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
02015                                                         }
02016                                                         $formEl = '<select name="'.$dataPrefix.'['.$fname.']">'.implode('',$opt).'</select>';
02017                                                 break;
02018                                                 default:
02019                                                         debug($config);
02020                                                 break;
02021                                         }
02022                                         $lines[$fname].=$formEl;
02023                                         $lines[$fname].='<br /><br />';
02024                                 } else {
02025                                         $lines[$fname]='<hr />';
02026                                         if ($config)    $lines[$fname].='<strong>'.strtoupper(htmlspecialchars($config)).'</strong><br />';
02027                                         if ($config)    $lines[$fname].='<br />';
02028                                 }
02029                         }
02030                 }
02031                 $out = implode('',$lines);
02032                 $out.='<input type="submit" name="submit" value="Update configuration" />';
02033                 return $out;
02034         }
02035 
02036 
02037 
02038 
02039 
02040 
02041 
02042 
02043 
02044 
02045 
02046 
02047 
02048         /*******************************************
02049          *
02050          * Backend Modules API functions
02051          *
02052          *******************************************/
02053 
02065         function helpTextIcon($table,$field,$BACK_PATH,$force=0)        {
02066                 global $TCA_DESCR,$BE_USER;
02067                 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && ($BE_USER->uc['edit_showFieldHelp']=='icon' || $force))  {
02068                         $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;';
02069                         return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
02070                                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="typo3-csh-icon" alt="" />'.
02071                                         '</a>';
02072                 }
02073         }
02074 
02087         function helpText($table,$field,$BACK_PATH,$styleAttrib='')     {
02088                 global $TCA_DESCR,$BE_USER;
02089                 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && $BE_USER->uc['edit_showFieldHelp']=='text')      {
02090                         $fDat = $TCA_DESCR[$table]['columns'][$field];
02091 
02092                                 // Get Icon:
02093                         $editIcon = t3lib_BEfunc::helpTextIcon(
02094                                                                         $table,
02095                                                                         $field,
02096                                                                         $BACK_PATH,
02097                                                                         TRUE
02098                                                                 );
02099                                 // Add title?
02100                         $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;';
02101                         $text =
02102                                         ($fDat['alttitle'] ? '<h4><a href="#" onclick="'.htmlspecialchars($onClick).'">'.$fDat['alttitle'].'</a></h4>' : '').
02103                                         $fDat['description'];
02104 
02105                                 // More information to get?
02106                         if ($fDat['image_descr'] || $fDat['seeAlso'] || $fDat['details'] || $fDat['syntax'])    { // || $fDat['image'];
02107                                 $text.=' <a href="#" onclick="'.htmlspecialchars($onClick).'">'.
02108                                                 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/rel_db.gif','width="13" height="12"').' class="absmiddle typo3-csh-more" alt="" />'.
02109                                                 '</a>';
02110                         }
02111 
02112                                 // Additional styles?
02113                         $params = $styleAttrib ? ' style="'.$styleAttrib.'"' : '';
02114 
02115                                 // Compile table with CSH information:
02116                         return '<table border="0" cellpadding="2" cellspacing="0" class="typo3-csh-inline"'.$params.'>
02117                                                 <tr>
02118                                                         <td valign="top" width="14">'.$editIcon.'</td>
02119                                                         <td valign="top">'.$text.'</td>
02120                                                 </tr>
02121                                         </table>';
02122                 }
02123         }
02124 
02139         function cshItem($table,$field,$BACK_PATH,$wrap='',$onlyIconMode=FALSE, $styleAttrib='')        {
02140                 global $TCA_DESCR, $LANG, $BE_USER;
02141                 if ($BE_USER->uc['edit_showFieldHelp']) {
02142                         $LANG->loadSingleTableDescription($table);
02143 
02144                         if (is_array($TCA_DESCR[$table]))       {
02145                                         // Creating CSH icon and short description:
02146                                 $fullText = t3lib_BEfunc::helpText($table,$field,$BACK_PATH,$styleAttrib);
02147                                 $icon = t3lib_BEfunc::helpTextIcon($table,$field,$BACK_PATH,$onlyIconMode);
02148 
02149                                 if ($fullText && !$onlyIconMode)        {
02150                                         $output = $fullText;
02151                                 } else {
02152                                         #$output = '<span style="position:absolute; filter: alpha(opacity=50); -moz-opacity: 0.50;">'.$icon.'</span>';
02153                                         $output = $icon;
02154 
02155                                         if ($output && $wrap)   {
02156                                                 $wrParts = explode('|',$wrap);
02157                                                 $output = $wrParts[0].$output.$wrParts[1];
02158                                         }
02159                                 }
02160 
02161                                 return $output;
02162                         }
02163                 }
02164         }
02165 
02177         function editOnClick($params,$backPath='',$requestUri='')       {
02178                 $retUrl = 'returnUrl='.($requestUri==-1?"'+T3_THIS_LOCATION+'":rawurlencode($requestUri?$requestUri:t3lib_div::getIndpEnv('REQUEST_URI')));
02179                 return "document.location='".$backPath."alt_doc.php?".$retUrl.$params."'; return false;";
02180         }
02181 
02196         function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='',$addGetVars='',$switchFocus=TRUE)      {
02197                 if ($altUrl)    {
02198                         $url = $altUrl;
02199                 } else {
02200                         if ($rootLine)  {
02201                                 $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
02202                                 if (t3lib_BEfunc::getDomainStartPage($parts['host'],$parts['path']))    {
02203                                         $preUrl_temp = t3lib_BEfunc::firstDomainRecord($rootLine);
02204                                 }
02205                         }
02206                         $preUrl = $preUrl_temp ? (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').$preUrl_temp : $backPath.'..';
02207                         $url = $preUrl.'/index.php?id='.$id.$addGetVars.$anchor;
02208                 }
02209 
02210                 return "previewWin=window.open('".$url."','newTypo3FrontendWindow','status=1,menubar=1,resizable=1,location=1,scrollbars=1,toolbar=1');".
02211                                 ($switchFocus ? 'previewWin.focus();' : '');
02212         }
02213 
02223         function getModTSconfig($id,$TSref)     {
02224                 $pageTS_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref,t3lib_BEfunc::getPagesTSconfig($id));
02225                 $BE_USER_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref);
02226                 $modTSconfig = t3lib_div::array_merge_recursive_overrule($pageTS_modOptions,$BE_USER_modOptions);
02227                 return $modTSconfig;
02228         }
02229 
02244         function getFuncMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')        {
02245                 if (is_array($menuItems))       {
02246                         if (!is_array($mainParams)) {
02247                                 $mainParams = array('id' => $mainParams);
02248                         }
02249                         $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02250 
02251                         if (!$script) { $script=basename(PATH_thisScript); }
02252 
02253                         $options = array();
02254                         foreach($menuItems as $value => $label) {
02255                                 $options[] = '<option value="'.htmlspecialchars($value).'"'.(!strcmp($currentValue,$value)?' selected="selected"':'').'>'.
02256                                                                 t3lib_div::deHSCentities(htmlspecialchars($label)).
02257                                                                 '</option>';
02258                         }
02259                         if (count($options))    {
02260                                 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+this.options[this.selectedIndex].value,this);';
02261                                 return '
02262 
02263                                         <!-- Function Menu of module -->
02264                                         <select name="'.$elementName.'" onchange="'.htmlspecialchars($onChange).'">
02265                                                 '.implode('
02266                                                 ',$options).'
02267                                         </select>
02268                                                         ';
02269                         }
02270                 }
02271         }
02272 
02287         function getFuncCheck($mainParams,$elementName,$currentValue,$script='',$addparams='',$tagParams='')    {
02288                 if (!is_array($mainParams)) {
02289                         $mainParams = array('id' => $mainParams);
02290                 }
02291                 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02292 
02293                 if (!$script) {basename(PATH_thisScript);}
02294                 $onClick = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+(this.checked?1:0),this);';
02295                 return '<input type="checkbox" name="'.$elementName.'"'.($currentValue?' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'"'.($tagParams?' '.$tagParams:'').' />';
02296         }
02297 
02312         function getFuncInput($mainParams,$elementName,$currentValue,$size=10,$script="",$addparams="") {
02313                 if (!is_array($mainParams)) {
02314                         $mainParams = array('id' => $mainParams);
02315                 }
02316                 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02317 
02318                 if (!$script) {basename(PATH_thisScript);}
02319                 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+escape(this.value),this);';
02320                 return '<input type="text"'.$GLOBALS['TBE_TEMPLATE']->formWidth($size).' name="'.$elementName.'" value="'.htmlspecialchars($currentValue).'" onchange="'.htmlspecialchars($onChange).'" />';
02321         }
02322 
02333         function unsetMenuItems($modTSconfig,$itemArray,$TSref) {
02334                         // Getting TS-config options for this module for the Backend User:
02335                 $conf = $GLOBALS['BE_USER']->getTSConfig($TSref,$modTSconfig);
02336                 if (is_array($conf['properties']))      {
02337                         reset($conf['properties']);
02338                         while(list($key,$val)=each($conf['properties']))        {
02339                                 if (!$val)      {
02340                                         unset($itemArray[$key]);
02341                                 }
02342                         }
02343                 }
02344                 return $itemArray;
02345         }
02346 
02356         function getSetUpdateSignal($set='')    {
02357                 global $BE_USER;
02358                 $key = 't3lib_BEfunc::getSetUpdateSignal';
02359                 $out='';
02360                 if ($set)       {
02361                         $modData=array();
02362                         $modData['set']=$set;
02363                         $BE_USER->pushModuleData($key,$modData);
02364                 } else {
02365                         $modData = $BE_USER->getModuleData($key,'ses');
02366                         if (trim($modData['set']))      {
02367                                 $l=explode(',',$modData['set']);
02368                                 while(list(,$v)=each($l))       {
02369                                         switch($v)      {
02370                                                 case 'updatePageTree':
02371                                                 case 'updateFolderTree':
02372                                                         $out.='
02373                                         <script type="text/javascript">
02374                                         /*<![CDATA[*/
02375                                                         if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)  {
02376                                                                 top.content.nav_frame.refresh_nav();
02377                                                         }
02378                                         /*]]>*/
02379                                         </script>';
02380                                                 break;
02381                                         }
02382                                 }
02383                                 $modData=array();
02384                                 $modData['set']='';
02385                                 $BE_USER->pushModuleData($key,$modData);
02386                         }
02387                 }
02388                 return $out;
02389         }
02390 
02391 
02407         function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')      {
02408 
02409                 if ($modName && is_string($modName))    {
02410                                         // GETTING stored user-data from this module:
02411                         $settings = $GLOBALS['BE_USER']->getModuleData($modName,$type);
02412 
02413                         $changed=0;
02414                         if (!is_array($settings))       {
02415                                 $changed=1;
02416                                 $settings=array();
02417                         }
02418                         if (is_array($MOD_MENU))        {
02419                                 reset($MOD_MENU);
02420                                 while(list($key,$var)=each($MOD_MENU))  {
02421                                                 // If a global var is set before entering here. eg if submitted, then it's substituting the current value the array.
02422                                         if (is_array($CHANGED_SETTINGS) && isset($CHANGED_SETTINGS[$key]) && strcmp($settings[$key],$CHANGED_SETTINGS[$key]))   {
02423                                                 $settings[$key] = (string)$CHANGED_SETTINGS[$key];
02424                                                 $changed=1;
02425                                         }
02426                                                 // If the $var is an array, which denotes the existence of a menu, we check if the value is permitted
02427                                         if (is_array($var) && (!$dontValidateList || !t3lib_div::inList($dontValidateList,$key)))       {
02428                                                         // If the setting is an array or not present in the menu-array, MOD_MENU, then the default value is inserted.
02429                                                 if (is_array($settings[$key]) || !isset($MOD_MENU[$key][$settings[$key]]))      {
02430                                                         $settings[$key]=(string)key($var);
02431                                                         $changed=1;
02432                                                 }
02433                                         }
02434                                         if ($setDefaultList && !is_array($var)) {       // Sets default values (only strings/checkboxes, not menus)
02435                                                 if (t3lib_div::inList($setDefaultList,$key) && !isset($settings[$key])) {
02436                                                         $settings[$key]=$var;
02437                                                 }
02438                                         }
02439                                 }
02440                         } else {die ('No menu!');}
02441 
02442                         if ($changed)   {
02443                                 $GLOBALS['BE_USER']->pushModuleData($modName,$settings);
02444                         }
02445 
02446                         return  $settings;
02447                 } else {die ('Wrong module name: "'.$modName.'"');}
02448         }
02449 
02450 
02451 
02452 
02453 
02454 
02455 
02456 
02457 
02458 
02459 
02460 
02461 
02462         /*******************************************
02463          *
02464          * Core
02465          *
02466          *******************************************/
02467 
02468 
02469 
02482         function lockRecords($table='',$uid=0,$pid=0)   {
02483                 $user_id = intval($GLOBALS['BE_USER']->user['uid']);
02484                 if ($table && $uid)     {
02485                         $fields_values = array(
02486                                 'userid' => $user_id,
02487                                 'tstamp' => $GLOBALS['EXEC_TIME'],
02488                                 'record_table' => $table,
02489                                 'record_uid' => $uid,
02490                                 'username' => $GLOBALS['BE_USER']->user['username'],
02491                                 'record_pid' => $pid
02492                         );
02493 
02494                         $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
02495                 } else {
02496                         $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'userid='.intval($user_id));
02497                 }
02498         }
02499 
02511         function isRecordLocked($table,$uid)    {
02512                 global $LOCKED_RECORDS;
02513                 if (!is_array($LOCKED_RECORDS)) {
02514                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
02515                                                         '*',
02516                                                         'sys_lockedrecords',
02517                                                         'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user['uid']).'
02518                                                                 AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
02519                                                 );
02520                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
02521                                 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
02522                                 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
02523                                         $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'),
02524                                         $row['username'],
02525                                         t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
02526                                 );
02527                                 if ($row['record_pid'] && !isset($LOCKED_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
02528                                         $LOCKED_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
02529                                                 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content'),
02530                                                 $row['username'],
02531                                                 t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
02532                                         );
02533                                 }
02534                         }
02535                 }
02536                 return $LOCKED_RECORDS[$table.':'.$uid];
02537         }
02538 
02551         function exec_foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='')     {
02552                 global $TCA;
02553                 $foreign_table = $fieldValue['config'][$prefix.'foreign_table'];
02554                 $rootLevel = $TCA[$foreign_table]['ctrl']['rootLevel'];
02555 
02556                 $fTWHERE = $fieldValue['config'][$prefix.'foreign_table_where'];
02557                 if (strstr($fTWHERE,'###REC_FIELD_'))   {
02558                         $fTWHERE_parts = explode('###REC_FIELD_',$fTWHERE);
02559                         while(list($kk,$vv)=each($fTWHERE_parts))       {
02560                                 if ($kk)        {
02561                                         $fTWHERE_subpart = explode('###',$vv,2);
02562                                         $fTWHERE_parts[$kk]=$TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]].$fTWHERE_subpart[1];
02563                                 }
02564                         }
02565                         $fTWHERE = implode('',$fTWHERE_parts);
02566                 }
02567 
02568                 $fTWHERE = str_replace('###CURRENT_PID###',intval($TSconfig['_CURRENT_PID']),$fTWHERE);
02569                 $fTWHERE = str_replace('###THIS_UID###',intval($TSconfig['_THIS_UID']),$fTWHERE);
02570                 $fTWHERE = str_replace('###THIS_CID###',intval($TSconfig['_THIS_CID']),$fTWHERE);
02571                 $fTWHERE = str_replace('###STORAGE_PID###',intval($TSconfig['_STORAGE_PID']),$fTWHERE);
02572                 $fTWHERE = str_replace('###SITEROOT###',intval($TSconfig['_SITEROOT']),$fTWHERE);
02573                 $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###',intval($TSconfig[$field]['PAGE_TSCONFIG_ID']),$fTWHERE);
02574                 $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###',$GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']),$fTWHERE);
02575                 $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###',$GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$field]['PAGE_TSCONFIG_STR'], $foreign_table),$fTWHERE);
02576 
02577                         // rootLevel = -1 is not handled 'properly' here - it goes as if it was rootLevel = 1 (that is pid=0)
02578                 $wgolParts = $GLOBALS['TYPO3_DB']->splitGroupOrderLimit($fTWHERE);
02579                 if ($rootLevel) {
02580                         $queryParts = array(
02581                                 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02582                                 'FROM' => $foreign_table,
02583                                 'WHERE' => $foreign_table.'.pid=0 '.
02584                                                         t3lib_BEfunc::deleteClause($foreign_table).' '.
02585                                                         $wgolParts['WHERE'],
02586                                 'GROUPBY' => $wgolParts['GROUPBY'],
02587                                 'ORDERBY' => $wgolParts['ORDERBY'],
02588                                 'LIMIT' => $wgolParts['LIMIT']
02589                         );
02590                 } else {
02591                         $pageClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
02592                         if ($foreign_table!='pages')    {
02593                                 $queryParts = array(
02594                                         'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02595                                         'FROM' => $foreign_table.',pages',
02596                                         'WHERE' => 'pages.uid='.$foreign_table.'.pid
02597                                                                 AND pages.deleted=0 '.
02598                                                                 t3lib_BEfunc::deleteClause($foreign_table).
02599                                                                 ' AND '.$pageClause.' '.
02600                                                                 $wgolParts['WHERE'],
02601                                         'GROUPBY' => $wgolParts['GROUPBY'],
02602                                         'ORDERBY' => $wgolParts['ORDERBY'],
02603                                         'LIMIT' => $wgolParts['LIMIT']
02604                                 );
02605                         } else {
02606                                 $queryParts = array(
02607                                         'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02608                                         'FROM' => 'pages',
02609                                         'WHERE' => 'pages.deleted=0
02610                                                                 AND '.$pageClause.' '.
02611                                                                 $wgolParts['WHERE'],
02612                                         'GROUPBY' => $wgolParts['GROUPBY'],
02613                                         'ORDERBY' => $wgolParts['ORDERBY'],
02614                                         'LIMIT' => $wgolParts['LIMIT']
02615                                 );
02616                         }
02617                 }
02618 
02619                 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
02620         }
02621 
02632         function getTCEFORM_TSconfig($table,$row) {
02633                 $res = array();
02634                 $typeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
02635 
02636                         // Get main config for the table
02637                 list($TScID,$cPid) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']);
02638 
02639                 $rootLine = t3lib_BEfunc::BEgetRootLine($TScID,'');
02640                 if ($TScID>=0)  {
02641                         $tempConf = $GLOBALS['BE_USER']->getTSConfig('TCEFORM.'.$table,t3lib_BEfunc::getPagesTSconfig($TScID,$rootLine));
02642                         if (is_array($tempConf['properties']))  {
02643                                 while(list($key,$val)=each($tempConf['properties']))    {
02644                                         if (is_array($val))     {
02645                                                 $fieldN = substr($key,0,-1);
02646                                                 $res[$fieldN] = $val;
02647                                                 unset($res[$fieldN]['types.']);
02648                                                 if (strcmp($typeVal,'') && is_array($val['types.'][$typeVal.'.']))      {
02649                                                         $res[$fieldN] = t3lib_div::array_merge_recursive_overrule($res[$fieldN],$val['types.'][$typeVal.'.']);
02650                                                 }
02651                                         }
02652                                 }
02653                         }
02654                 }
02655                 $res['_CURRENT_PID']=$cPid;
02656                 $res['_THIS_UID']=$row['uid'];
02657                 $res['_THIS_CID']=$row['cid'];
02658                 $res['_THIS_ROW']=$row; // So the row will be passed to foreign_table_where_query()
02659                 reset($rootLine);
02660                 while(list(,$rC)=each($rootLine))       {
02661                         if (!$res['_STORAGE_PID'])      $res['_STORAGE_PID']=intval($rC['storage_pid']);
02662                         if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?intval($rC['uid']):0;
02663                 }
02664 
02665                 return $res;
02666         }
02667 
02679         function getTSconfig_pidValue($table,$uid,$pid) {
02680                 if (t3lib_div::testInt($pid))   {       // If pid is an integer this takes precedence in our lookup.
02681                         $thePidValue = intval($pid);
02682                         if ($thePidValue<0)     {       // If ref to another record, look that record up.
02683                                 $pidRec = t3lib_BEfunc::getRecord($table,abs($thePidValue),'pid');
02684                                 $thePidValue= is_array($pidRec) ? $pidRec['pid'] : -2;  // Returns -2 if the record did not exist.
02685                         }
02686                         // ... else the pos/zero pid is just returned here.
02687                 } else {        // No integer pid and we are forced to look up the $pid
02688                         $rr = t3lib_BEfunc::getRecord($table,$uid,'pid');       // Try to fetch the record pid from uid. If the uid is 'NEW...' then this will of course return nothing...
02689                         if (is_array($rr))      {
02690                                 $thePidValue = $rr['pid'];      // Returning the 'pid' of the record
02691                         } else $thePidValue=-1; // Returns -1 if the record with the pid was not found.
02692                 }
02693                 return $thePidValue;
02694         }
02695 
02707         function getPidForModTSconfig($table,$uid,$pid) {
02708                 $retVal = ($table=='pages' && t3lib_div::testInt($uid)) ? $uid : $pid;
02709                 return $retVal;
02710         }
02711 
02723         function getTSCpid($table,$uid,$pid)    {
02724                         // If pid is negative (referring to another record) the pid of the other record is fetched and returned.
02725                 $cPid = t3lib_BEfunc::getTSconfig_pidValue($table,$uid,$pid);
02726                         // $TScID is the id of $table=pages, else it's the pid of the record.
02727                 $TScID = t3lib_BEfunc::getPidForModTSconfig($table,$uid,$cPid);
02728 
02729                 return array($TScID,$cPid);
02730         }
02731 
02739         function firstDomainRecord($rootLine)   {
02740                 if (t3lib_extMgm::isLoaded('cms'))      {
02741                         reset($rootLine);
02742                         while(list(,$row)=each($rootLine))      {
02743                                 $dRec = t3lib_BEfunc::getRecordsByField('sys_domain','pid',$row['uid'],' AND redirectTo=\'\' AND hidden=0', '', 'sorting');
02744                                 if (is_array($dRec))    {
02745                                         reset($dRec);
02746                                         $dRecord = current($dRec);
02747                                         return ereg_replace('\/$','',$dRecord['domainName']);
02748                                 }
02749                         }
02750                 }
02751         }
02752 
02761         function getDomainStartPage($domain, $path='')  {
02762                 if (t3lib_extMgm::isLoaded('cms'))      {
02763                         $domain = explode(':',$domain);
02764                         $domain = strtolower(ereg_replace('\.$','',$domain[0]));
02765                                 // path is calculated.
02766                         $path = trim(ereg_replace('\/[^\/]*$','',$path));
02767                                 // stuff:
02768                         $domain.=$path;
02769 
02770                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_domain.*', 'pages,sys_domain', '
02771                                 pages.uid=sys_domain.pid
02772                                 AND sys_domain.hidden=0
02773                                 AND (sys_domain.domainName='.$GLOBALS['TYPO3_DB']->fullQuoteStr($domain, 'sys_domain').' or sys_domain.domainName='.$GLOBALS['TYPO3_DB']->fullQuoteStr($domain.'/', 'sys_domain').')'.
02774                                 t3lib_BEfunc::deleteClause('pages'),
02775                                 '', '', '1');
02776                         return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
02777                 }
02778         }
02779 
02788         function selectVersionsOfRecord($table, $uid, $fields='*')      {
02789                 global $TCA;
02790 
02791                 if ($TCA[$table] && $TCA[$table]['ctrl']['versioning']) {
02792 
02793                                 // Select all versions of record:
02794                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
02795                                 $fields,
02796                                 $table,
02797                                 '(t3ver_oid='.intval($uid).' || uid='.intval($uid).')'.
02798                                         t3lib_BEfunc::deleteClause($table),
02799                                 '',
02800                                 't3ver_id DESC'
02801                         );
02802 
02803                                 // Add rows to output array:
02804                         $realPid = 0;
02805                         $outputRows = array();
02806                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
02807                                 if ($uid==$row['uid'])  {
02808                                         $row['_CURRENT_VERSION']=TRUE;
02809                                         $realPid = $row['pid'];
02810                                 }
02811                                 $outputRows[] = $row;
02812                         }
02813 
02814                                 // Set real-pid:
02815                         foreach($outputRows as $idx => $oRow)   {
02816                                 $outputRows[$idx]['_REAL_PID'] = $realPid;
02817                         }
02818 
02819                         return $outputRows;
02820                 }
02821         }
02822 
02834         function RTEsetup($RTEprop,$table,$field,$type='')      {
02835                 $thisConfig = is_array($RTEprop['default.']) ? $RTEprop['default.'] : array();
02836                 $thisFieldConf = $RTEprop['config.'][$table.'.'][$field.'.'];
02837                 if (is_array($thisFieldConf))   {
02838                         unset($thisFieldConf['types.']);
02839                         $thisConfig = t3lib_div::array_merge_recursive_overrule($thisConfig,$thisFieldConf);
02840                 }
02841                 if ($type && is_array($RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.']))        {
02842                         $thisConfig = t3lib_div::array_merge_recursive_overrule($thisConfig,$RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.']);
02843                 }
02844                 return $thisConfig;
02845         }
02846 
02853         function &RTEgetObj()   {
02854 
02855                         // If no RTE object has been set previously, try to create it:
02856                 if (!isset($GLOBALS['T3_VAR']['RTEobj']))       {
02857 
02858                                 // Set the object string to blank by default:
02859                         $GLOBALS['T3_VAR']['RTEobj'] = array();
02860 
02861                                 // Traverse registered RTEs:
02862                         if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg']))     {
02863                                 foreach($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg'] as $extKey => $rteObjCfg)  {
02864                                         $rteObj = &t3lib_div::getUserObj($rteObjCfg['objRef']);
02865                                         if (is_object($rteObj)) {
02866                                                 if ($rteObj->isAvailable())     {
02867                                                         $GLOBALS['T3_VAR']['RTEobj'] = &$rteObj;
02868                                                         break;
02869                                                 } else {
02870                                                         $GLOBALS['T3_VAR']['RTEobj'] = array_merge($GLOBALS['T3_VAR']['RTEobj'], $rteObj->errorLog);
02871                                                 }
02872                                         }
02873                                 }
02874                         }
02875 
02876                         if (!count($GLOBALS['T3_VAR']['RTEobj']))       {
02877                                 $GLOBALS['T3_VAR']['RTEobj'][] = 'No RTEs configured at all';
02878                         }
02879                 }
02880 
02881                         // Return RTE object (if any!)
02882                 return $GLOBALS['T3_VAR']['RTEobj'];
02883         }
02884 
02892         function &softRefParserObj($spKey)      {
02893 
02894                         // If no softRef parser object has been set previously, try to create it:
02895                 if (!isset($GLOBALS['T3_VAR']['softRefParser'][$spKey]))        {
02896 
02897                                 // Set the object string to blank by default:
02898                         $GLOBALS['T3_VAR']['softRefParser'][$spKey] = '';
02899 
02900                                 // Now, try to create parser object:
02901                         $objRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser'][$spKey] ?
02902                                                         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser'][$spKey] :
02903                                                         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'][$spKey];
02904                         if ($objRef)    {
02905                                 $softRefParserObj = &t3lib_div::getUserObj($objRef,'');
02906                                 if (is_object($softRefParserObj))       {
02907                                         $GLOBALS['T3_VAR']['softRefParser'][$spKey] = &$softRefParserObj;
02908                                 }
02909                         }
02910                 }
02911 
02912                         // Return RTE object (if any!)
02913                 return $GLOBALS['T3_VAR']['softRefParser'][$spKey];
02914         }
02915 
02924         function explodeSoftRefParserList($parserList, $table, $field)  {
02925 
02926                         // Looking for global parsers:
02927                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL']))  {
02928                         $parserList = implode(',',array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])).','.$parserList;
02929                 }
02930 
02931                         // Return immediately if list is blank:
02932                 if (!strlen($parserList))       return FALSE;
02933 
02934                         // Otherwise parse the list:
02935                 $keyList = t3lib_div::trimExplode(',', $parserList, 1);
02936                 $output = array();
02937 
02938                 foreach($keyList as $val)       {
02939                         $reg = array();
02940                         if (ereg('^([[:alnum:]_-]+)\[(.*)\]$', $val, $reg))     {
02941                                 $output[$reg[1]] = t3lib_div::trimExplode(';', $reg[2], 1);
02942                         } else {
02943                                 $output[$val] = '';
02944                         }
02945                 }
02946                 return $output;
02947         }
02948 
02956         function isModuleSetInTBE_MODULES($modName)     {
02957                 reset($GLOBALS['TBE_MODULES']);
02958                 $loaded=array();
02959                 while(list($mkey,$list)=each($GLOBALS['TBE_MODULES']))  {
02960                         $loaded[$mkey]=1;
02961                         if (trim($list))        {
02962                                 $subList = t3lib_div::trimExplode(',',$list,1);
02963                                 while(list(,$skey)=each($subList))      {
02964                                         $loaded[$mkey.'_'.$skey]=1;
02965                                 }
02966                         }
02967                 }
02968                 return $modName && isset($loaded[$modName]);
02969         }
02970 
02971 
02972 
02973 
02974 
02975 
02976 
02977 
02978 
02979 
02980 
02981 
02982 
02983 
02984 
02985 
02986 
02987 
02988         /*******************************************
02989          *
02990          * Miscellaneous
02991          *
02992          *******************************************/
02993 
02994 
03005         function typo3PrintError($header,$text,$js='',$head=1)  {
03006                         // This prints out a TYPO3 error message.
03007                         // If $js is set the message will be output in JavaScript
03008                 if ($js)        {
03009                         echo "alert('".t3lib_div::slashJS($header.'\n'.$text)."');";
03010                 } else {
03011                         echo $head?'<html>
03012                                 <head>
03013                                         <title>Error!</title>
03014                                 </head>
03015                                 <body bgcolor="white" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">':'';
03016                         echo '<div align="center">
03017                                         <table border="0" cellspacing="0" cellpadding="0" width="333">
03018                                                 <tr>
03019                                                         <td align="center">'.
03020                                                                 ($GLOBALS['TBE_STYLES']['logo_login']?'<img src="'.$GLOBALS['BACK_PATH'].$GLOBALS['TBE_STYLES']['logo_login'].'" alt="" />':'<img src="'.$GLOBALS['BACK_PATH'].'gfx/typo3logo.gif" width="333" height="43" vspace="10" />').
03021                                                         '</td>
03022                                                 </tr>
03023                                                 <tr>
03024                                                         <td bgcolor="black">
03025                                                                 <table width="100%" border="0" cellspacing="1" cellpadding="10">
03026                                                                         <tr>
03027                                                                                 <td bgcolor="#F4F0E8">
03028                                                                                         <font face="verdana,arial,helvetica" size="2">';
03029                         echo '<b><center><font size="+1">'.$header.'</font></center></b><br />'.$text;
03030                         echo '                                                  </font>
03031                                                                                 </td>
03032                                                                         </tr>
03033                                                                 </table>
03034                                                         </td>
03035                                                 </tr>
03036                                         </table>
03037                                 </div>';
03038                         echo $head?'
03039                                 </body>
03040                         </html>':'';
03041                 }
03042         }
03043 
03049         function TYPO3_copyRightNotice()        {
03050                 global $TYPO3_CONF_VARS;
03051 
03052                         // COPYRIGHT NOTICE:
03053                 $loginCopyrightWarrantyProvider = strip_tags(trim($TYPO3_CONF_VARS['SYS']['loginCopyrightWarrantyProvider']));
03054                 $loginCopyrightWarrantyURL = strip_tags(trim($TYPO3_CONF_VARS['SYS']['loginCopyrightWarrantyURL']));
03055 
03056                 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10)       {
03057                         $warrantyNote='Warranty is supplied by '.htmlspecialchars($loginCopyrightWarrantyProvider).'; <a href="'.htmlspecialchars($loginCopyrightWarrantyURL).'" target="_blank">click for details.</a>';
03058                 } else {
03059                         $warrantyNote='TYPO3 comes with ABSOLUTELY NO WARRANTY; <a href="http://typo3.com/1316.0.html" target="_blank">click for details.</a>';
03060                 }
03061                 $cNotice = '<a href="http://typo3.com/" target="_blank"><img src="gfx/loginlogo_transp.gif" width="75" vspace="2" height="19" alt="TYPO3 logo" align="left" />TYPO3 CMS ver. '.htmlspecialchars($GLOBALS['TYPO_VERSION']).'</a>. Copyright &copy; 1998-2005 Kasper Sk&aring;rh&oslash;j. Extensions are copyright of their respective owners. Go to <a href="http://typo3.com/" target="_blank">http://typo3.com/</a> for details.
03062                 '.strip_tags($warrantyNote,'<a>').' This is free software, and you are welcome to redistribute it under certain conditions; <a href="http://typo3.com/1316.0.html" target="_blank">click for details</a>. Obstructing the appearance of this notice is prohibited by law.';
03063 
03064                 return $cNotice;
03065         }
03066 
03073         function displayWarningMessages()       {
03074                 if($GLOBALS['BE_USER']->isAdmin())      {
03075                         $warnings = array();
03076 
03077                                 // Check if the Install Tool Password is still default: joh316
03078                         if($GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']==md5('joh316'))     {
03079                                 $warnings[] = 'The password of your Install Tool is still using the default value "joh316"';
03080                         }
03081 
03082                                 // Check if there is still a default user 'admin' with password 'password' (MD5sum = 5f4dcc3b5aa765d61d8327deb882cf99)
03083                         $where_clause = 'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr('admin','be_users').' AND password='.$GLOBALS['TYPO3_DB']->fullQuoteStr('5f4dcc3b5aa765d61d8327deb882cf99','be_users').t3lib_BEfunc::deleteClause('be_users');
03084                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('username, password', 'be_users', $where_clause);
03085                         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
03086                                 $warnings[] = 'The backend user "admin" with password "password" is still existing';
03087                         }
03088 
03089                                 // Check if the encryption key is empty
03090                         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] == '')  {
03091                                 $url = 'install/index.php?redirect_url=index.php'.urlencode('?TYPO3_INSTALL[type]=config#set_encryptionKey');
03092                                 $warnings[] = 'The encryption key is not set! Set it in <a href="'.$url.'">$TYPO3_CONF_VARS[SYS][encryptionKey]</a>';
03093                         }
03094 
03095                         if(count($warnings))    {
03096                                 $content = '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
03097                                         $GLOBALS['TBE_TEMPLATE']->icons(3).'Security warning!<br />'.
03098                                         '- '.implode('<br />- ', $warnings).'<br /><br />'.
03099                                         'It is highly recommended that you change this immediately.'.
03100                                         '</td></tr></table>';
03101 
03102                                 unset($warnings);
03103                                 return $content;
03104                         }
03105                 }
03106                 return '<p>&nbsp;</p>';
03107         }
03108 
03116         function getPathType_web_nonweb($path)  {
03117                 return t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')) ? 'web' : '';
03118         }
03119 
03128         function ADMCMD_previewCmds($pageinfo)  {
03129                 if ($pageinfo['fe_group']>0)    {
03130                         $simUser = '&ADMCMD_simUser='.$pageinfo['fe_group'];
03131                 }
03132                 if ($pageinfo['starttime']>time())      {
03133                         $simTime = '&ADMCMD_simTime='.$pageinfo['starttime'];
03134                 }
03135                 if ($pageinfo['endtime']<time() && $pageinfo['endtime']!=0)     {
03136                         $simTime = '&ADMCMD_simTime='.($pageinfo['endtime']-1);
03137                 }
03138                 return $simUser.$simTime;
03139         }
03140 
03150         function processParams($params) {
03151                 $paramArr=array();
03152                 $lines=explode(chr(10),$params);
03153                 while(list(,$val)=each($lines)) {
03154                         $val = trim($val);
03155                         if ($val)       {
03156                                 $pair = explode('=',$val,2);
03157                                 $paramArr[trim($pair[0])] = trim($pair[1]);
03158                         }
03159                 }
03160                 return $paramArr;
03161         }
03162 
03176         function getListOfBackendModules($name,$perms_clause,$backPath='',$script='index.php')  {
03177                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'doktype!=255 AND module IN (\''.implode('\',\'',$name).'\') AND'.$perms_clause.t3lib_BEfunc::deleteClause('pages'));
03178                 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  return false;
03179 
03180                 $out='';
03181                 $theRows=array();
03182                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
03183                         $theRows[]=$row;
03184                         $out.='<span class="nobr"><a href="'.htmlspecialchars($script.'?id='.$row['uid']).'">'.
03185                                         t3lib_iconWorks::getIconImage('pages',$row,$backPath,'title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath($row['uid'],$perms_clause,20)).'" align="top"').
03186                                         htmlspecialchars($row['title']).
03187                                         '</a></span><br />';
03188                 }
03189                 return array('rows'=>$theRows,'list'=>$out);
03190         }
03191 }
03192 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6