Documentation TYPO3 par Ameos

class.t3lib_befunc.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00168 class t3lib_BEfunc      {
00169 
00170 
00171 
00172         /*******************************************
00173          *
00174          * SQL-related, selecting records, searching
00175          *
00176          *******************************************/
00177 
00178 
00188         function deleteClause($table)   {
00189                 global $TCA;
00190                 if ($TCA[$table]['ctrl']['delete'])     {
00191                         return ' AND NOT '.$table.'.'.$TCA[$table]['ctrl']['delete'];
00192                 } else {
00193                         return '';
00194                 }
00195         }
00196 
00211         function getRecord($table,$uid,$fields='*',$where='')   {
00212                 if ($GLOBALS['TCA'][$table])    {
00213                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid='.intval($uid).t3lib_BEfunc::deleteClause($table).$where);
00214                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00215                                 return $row;
00216                         }
00217                 }
00218         }
00219 
00233         function getRecordRaw($table,$where='',$fields='*')     {
00234                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
00235                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00236                         return $row;
00237                 }
00238         }
00239 
00255         function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='')     {
00256                 global $TCA;
00257                 if (is_array($TCA[$theTable])) {
00258                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00259                                                 '*',
00260                                                 $theTable,
00261                                                 $theField.'="'.$GLOBALS['TYPO3_DB']->quoteStr($theValue, $theTable).'"'.
00262                                                         t3lib_BEfunc::deleteClause($theTable).' '.
00263                                                         $whereClause,   // whereClauseMightContainGroupOrderBy
00264                                                 $groupBy,
00265                                                 $orderBy,
00266                                                 $limit
00267                                         );
00268                         $rows = array();
00269                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00270                                 $rows[] = $row;
00271                         }
00272                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
00273                         if (count($rows))       return $rows;
00274                 }
00275         }
00276 
00286         function fixVersioningPid($table,&$rr)  {
00287                 global $TCA;
00288 
00289                 if ($rr['pid']==-1 && $TCA[$table]['ctrl']['versioning'])       {
00290                         if ($rr['t3ver_oid']>0) {       // If "t3ver_oid" is already a field, just set this:
00291                                 $oid = $rr['t3ver_oid'];
00292                         } else {        // Otherwise we have to expect "uid" to be in the record and look up based on this:
00293                                 $newPidRec = t3lib_BEfunc::getRecord($table,$rr['uid'],'t3ver_oid');
00294                                 if (is_array($newPidRec))       {
00295                                         $oid = $newPidRec['t3ver_oid'];
00296                                 }
00297                         }
00298 
00299                                 // If ID of current online version is found, look up the PID value of that:
00300                         if ($oid)       {
00301                                 $oidRec = t3lib_BEfunc::getRecord($table,$oid,'pid');
00302                                 if (is_array($oidRec))  {
00303                                         $rr['_ORIG_pid'] = $rr['pid'];
00304                                         $rr['pid'] = $oidRec['pid'];
00305                                 }
00306                         }
00307                 }
00308         }
00309 
00320         function searchQuery($searchWords,$fields,$table='')    {
00321                 return $GLOBALS['TYPO3_DB']->searchQuery($searchWords,$fields,$table);
00322         }
00323 
00335         function listQuery($field,$value)       {
00336                 return $GLOBALS['TYPO3_DB']->listQuery($field,$value,'');
00337         }
00338 
00347         function splitTable_Uid($str)   {
00348                 list($uid,$table) = explode('_',strrev($str),2);
00349                 return array(strrev($table),strrev($uid));
00350         }
00351 
00362         function getSQLselectableList($in_list,$tablename,$default_tablename)   {
00363                 $list = Array();
00364                 if ((string)trim($in_list)!='') {
00365                         $tempItemArray = explode(',',trim($in_list));
00366                         while(list($key,$val)=each($tempItemArray))     {
00367                                 $val = strrev($val);
00368                                 $parts = explode('_',$val,2);
00369                                 if ((string)trim($parts[0])!='')        {
00370                                         $theID = intval(strrev($parts[0]));
00371                                         $theTable = trim($parts[1]) ? strrev(trim($parts[1])) : $default_tablename;
00372                                         if ($theTable==$tablename)      {$list[]=$theID;}
00373                                 }
00374                         }
00375                 }
00376                 return implode(',',$list);
00377         }
00378 
00390         function BEenableFields($table,$inv=0)  {
00391                 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
00392                 $query=array();
00393                 $invQuery=array();
00394                 if (is_array($ctrl))    {
00395                         if (is_array($ctrl['enablecolumns']))   {
00396                                 if ($ctrl['enablecolumns']['disabled']) {
00397                                         $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
00398                                         $query[]='NOT '.$field;
00399                                         $invQuery[]=$field;
00400                                 }
00401                                 if ($ctrl['enablecolumns']['starttime'])        {
00402                                         $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
00403                                         $query[]='('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00404                                         $invQuery[]='('.$field.'!=0 AND '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00405                                 }
00406                                 if ($ctrl['enablecolumns']['endtime'])  {
00407                                         $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
00408                                         $query[]='('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00409                                         $invQuery[]='('.$field.'!=0 AND '.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00410                                 }
00411                         }
00412                 }
00413                 $outQ = ' AND '.($inv ? '('.implode(' OR ',$invQuery).')' : implode(' AND ',$query));
00414 
00415                 return $outQ;
00416         }
00417 
00418 
00419 
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427         /*******************************************
00428          *
00429          * SQL-related, DEPRECIATED functions
00430          * (use t3lib_DB functions instead)
00431          *
00432          *******************************************/
00433 
00434 
00454         function mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')      {
00455                 $query = $GLOBALS['TYPO3_DB']->SELECTquery(
00456                                         $select,
00457                                         $local_table.','.$mm_table.($foreign_table?','.$foreign_table:''),
00458                                         $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').' '.
00459                                                 $whereClause,   // whereClauseMightContainGroupOrderBy
00460                                         $groupBy,
00461                                         $orderBy,
00462                                         $limit
00463                                 );
00464                 return $query;
00465         }
00466 
00476         function DBcompileInsert($table,$fields_values) {
00477                 return $GLOBALS['TYPO3_DB']->INSERTquery($table, $fields_values);
00478         }
00479 
00490         function DBcompileUpdate($table,$where,$fields_values)  {
00491                 return $GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fields_values);
00492         }
00493 
00494 
00495 
00496 
00497 
00498 
00499 
00500 
00501 
00502 
00503         /*******************************************
00504          *
00505          * Page tree, TCA related
00506          *
00507          *******************************************/
00508 
00519         function BEgetRootLine($uid,$clause='') {
00520                 $loopCheck = 100;
00521                 $theRowArray = Array();
00522                 $output=Array();
00523                 while ($uid!=0 && $loopCheck>0) {
00524                         $loopCheck--;
00525                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00526                                                         'pid,uid,title,TSconfig,is_siteroot,storage_pid',
00527                                                         'pages',
00528                                                         'uid='.intval($uid).' '.
00529                                                                 t3lib_BEfunc::deleteClause('pages').' '.
00530                                                                 $clause         // whereClauseMightContainGroupOrderBy
00531                                                 );
00532                         if ($GLOBALS['TYPO3_DB']->sql_error())  {
00533                                 debug($GLOBALS['TYPO3_DB']->sql_error(),1);
00534                         }
00535                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00536                                 t3lib_BEfunc::fixVersioningPid('pages',$row);
00537                                 $uid = $row['pid'];
00538                                 $theRowArray[]=$row;
00539                         } else {
00540                                 break;
00541                         }
00542                 }
00543                 if ($uid==0) {$theRowArray[]=Array('uid'=>0,'title'=>'');}
00544                 if (is_array($theRowArray))     {
00545                         reset($theRowArray);
00546                         $c=count($theRowArray);
00547                         while(list($key,$val)=each($theRowArray))       {
00548                                 $c--;
00549                                 $output[$c]['uid'] = $val['uid'];
00550                                 $output[$c]['pid'] = $val['pid'];
00551                                 if (isset($val['_ORIG_pid'])) $output[$c]['_ORIG_pid'] = $val['_ORIG_pid'];
00552                                 $output[$c]['title'] = $val['title'];
00553                                 $output[$c]['TSconfig'] = $val['TSconfig'];
00554                                 $output[$c]['is_siteroot'] = $val['is_siteroot'];
00555                                 $output[$c]['storage_pid'] = $val['storage_pid'];
00556                         }
00557                 }
00558                 return $output;
00559         }
00560 
00568         function openPageTree($pid,$clearExpansion)     {
00569                 global $BE_USER;
00570 
00571                         // Get current expansion data:
00572                 if ($clearExpansion)    {
00573                         $expandedPages = array();
00574                 } else {
00575                         $expandedPages = unserialize($BE_USER->uc['browseTrees']['browsePages']);
00576                 }
00577 
00578                         // Get rootline:
00579                 $rL = t3lib_BEfunc::BEgetRootLine($pid);
00580 
00581                         // First, find out what mount index to use (if more than one DB mount exists):
00582                 $mountIndex = 0;
00583                 $mountKeys = array_flip($BE_USER->returnWebmounts());
00584                 foreach($rL as $rLDat)  {
00585                         if (isset($mountKeys[$rLDat['uid']]))   {
00586                                 $mountIndex = $mountKeys[$rLDat['uid']];
00587                                 break;
00588                         }
00589                 }
00590 
00591                         // Traverse rootline and open paths:
00592                 foreach($rL as $rLDat)  {
00593                         $expandedPages[$mountIndex][$rLDat['uid']] = 1;
00594                 }
00595 
00596                         // Write back:
00597                 $BE_USER->uc['browseTrees']['browsePages'] = serialize($expandedPages);
00598                 $BE_USER->writeUC();
00599         }
00600 
00613         function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)   {
00614                 if (!$titleLimit) { $titleLimit=1000; }
00615 
00616                 $loopCheck = 100;
00617                 $output = $fullOutput = '/';
00618                 while ($uid!=0 && $loopCheck>0) {
00619                         $loopCheck--;
00620                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00621                                                 'uid,pid,title',
00622                                                 'pages',
00623                                                 'uid='.intval($uid).
00624                                                         t3lib_BEfunc::deleteClause('pages').
00625                                                         (strlen(trim($clause)) ? ' AND '.$clause : '')
00626                                         );
00627                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00628                                 t3lib_BEfunc::fixVersioningPid('pages',$row);
00629 
00630                                 if ($row['_ORIG_pid'])  {
00631                                         $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...
00632                                 }
00633                                 $uid = $row['pid'];
00634                                 $output = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$titleLimit).$output;
00635                                 if ($fullTitleLimit)    $fullOutput = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$fullTitleLimit).$fullOutput;
00636                         } else {
00637                                 break;
00638                         }
00639                 }
00640 
00641                 if ($fullTitleLimit)    {
00642                         return array($output, $fullOutput);
00643                 } else {
00644                         return $output;
00645                 }
00646         }
00647 
00655         function getExcludeFields()     {
00656                 global $TCA;
00657                         // All TCA keys:
00658                 $theExcludeArray = Array();
00659                 $tc_keys = array_keys($TCA);
00660                 foreach($tc_keys as $table)     {
00661                                 // Load table
00662                         t3lib_div::loadTCA($table);
00663                                 // All field names configured:
00664                         if (is_array($TCA[$table]['columns']))  {
00665                                 $f_keys = array_keys($TCA[$table]['columns']);
00666                                 foreach($f_keys as $field)      {
00667                                         if ($TCA[$table]['columns'][$field]['exclude']) {
00668                                                         // Get Human Readable names of fields and table:
00669                                                 $Fname=$GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
00670                                                         // add entry:
00671                                                 $theExcludeArray[] = Array($Fname , $table.':'.$field);
00672                                         }
00673                                 }
00674                         }
00675                 }
00676                 return $theExcludeArray;
00677         }
00678 
00685         function getExplicitAuthFieldValues()   {
00686                 global $TCA;
00687 
00688                         // Initialize:
00689                 $adLabel = array(
00690                         'ALLOW' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.allow'),
00691                         'DENY' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.deny'),
00692                 );
00693 
00694                         // All TCA keys:
00695                 $allowDenyOptions = Array();
00696                 $tc_keys = array_keys($TCA);
00697                 foreach($tc_keys as $table)     {
00698 
00699                                 // Load table
00700                         t3lib_div::loadTCA($table);
00701 
00702                                 // All field names configured:
00703                         if (is_array($TCA[$table]['columns']))  {
00704                                 $f_keys = array_keys($TCA[$table]['columns']);
00705                                 foreach($f_keys as $field)      {
00706                                         $fCfg = $TCA[$table]['columns'][$field]['config'];
00707                                         if ($fCfg['type']=='select' && $fCfg['authMode'])       {
00708 
00709                                                         // Check for items:
00710                                                 if (is_array($fCfg['items']))   {
00711                                                                 // Get Human Readable names of fields and table:
00712                                                         $allowDenyOptions[$table.':'.$field]['tableFieldLabel'] = $GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
00713 
00714                                                                 // Check for items:
00715                                                         foreach($fCfg['items'] as $iVal)        {
00716                                                                 if (strcmp($iVal[1],''))        {       // Values '' is not controlled by this setting.
00717 
00718                                                                                 // Find iMode:
00719                                                                         $iMode = '';
00720                                                                         switch((string)$fCfg['authMode'])       {
00721                                                                                 case 'explicitAllow':
00722                                                                                         $iMode = 'ALLOW';
00723                                                                                 break;
00724                                                                                 case 'explicitDeny':
00725                                                                                         $iMode = 'DENY';
00726                                                                                 break;
00727                                                                                 case 'individual':
00728                                                                                         if (!strcmp($iVal[4],'EXPL_ALLOW'))     {
00729                                                                                                 $iMode = 'ALLOW';
00730                                                                                         } elseif (!strcmp($iVal[4],'EXPL_DENY'))        {
00731                                                                                                 $iMode = 'DENY';
00732                                                                                         }
00733                                                                                 break;
00734                                                                         }
00735 
00736                                                                                 // Set iMode:
00737                                                                         if ($iMode)     {
00738                                                                                 $allowDenyOptions[$table.':'.$field]['items'][$iVal[1]] = array($iMode, $GLOBALS['LANG']->sl($iVal[0]), $adLabel[$iMode]);
00739                                                                         }
00740                                                                 }
00741                                                         }
00742                                                 }
00743                                         }
00744                                 }
00745                         }
00746                 }
00747 
00748                 return $allowDenyOptions;
00749         }
00750 
00756         function getSystemLanguages()   {
00757 
00758                         // Initialize, add default language:
00759                 $sysLanguages = array();
00760                 $sysLanguages[] = array('Default language', 0);
00761 
00762                         // Traverse languages
00763                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,flag','sys_language','pid=0'.t3lib_BEfunc::deleteClause('sys_language'));
00764                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00765                         $sysLanguages[] = array($row['title'].' ['.$row['uid'].']', $row['uid'], ($row['flag'] ? '../t3lib/gfx/flags/'.$row['flag'] : ''));
00766                 }
00767 
00768                 return $sysLanguages;
00769         }
00770 
00781         function readPageAccess($id,$perms_clause)      {
00782                 if ((string)$id!='')    {
00783                         $id = intval($id);
00784                         if (!$id)       {
00785                                 if ($GLOBALS['BE_USER']->isAdmin())     {
00786                                         $path = '/';
00787                                         $pageinfo['_thePath'] = $path;
00788                                         return $pageinfo;
00789                                 }
00790                         } else {
00791                                 $pageinfo = t3lib_BEfunc::getRecord('pages',$id,'*',($perms_clause ? ' AND '.$perms_clause : ''));
00792                                 if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause))   {
00793                                         list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
00794                                         return $pageinfo;
00795                                 }
00796                         }
00797                 }
00798                 return false;
00799         }
00800 
00810         function getTCAtypes($table,$rec,$useFieldNameAsKey=0)  {
00811                 global $TCA;
00812 
00813                 t3lib_div::loadTCA($table);
00814                 if ($TCA[$table])       {
00815 
00816                                 // Get type value:
00817                         $fieldValue = t3lib_BEfunc::getTCAtypeValue($table,$rec);
00818 
00819                                 // Get typesConf
00820                         $typesConf = $TCA[$table]['types'][$fieldValue];
00821 
00822                                 // Get fields list and traverse it
00823                         $fieldList = explode(',', $typesConf['showitem']);
00824                         $altFieldList = array();
00825 
00826                                 // Traverse fields in types config and parse the configuration into a nice array:
00827                         foreach($fieldList as $k => $v) {
00828                                 list($pFieldName, $pAltTitle, $pPalette, $pSpec) = t3lib_div::trimExplode(';', $v);
00829                                 $defaultExtras = is_array($TCA[$table]['columns'][$pFieldName]) ? $TCA[$table]['columns'][$pFieldName]['defaultExtras'] : '';
00830                                 $specConfParts = t3lib_BEfunc::getSpecConfParts($pSpec, $defaultExtras);
00831 
00832                                 $fieldList[$k]=array(
00833                                         'field' => $pFieldName,
00834                                         'title' => $pAltTitle,
00835                                         'palette' => $pPalette,
00836                                         'spec' => $specConfParts,
00837                                         'origString' => $v
00838                                 );
00839                                 if ($useFieldNameAsKey) {
00840                                         $altFieldList[$fieldList[$k]['field']] = $fieldList[$k];
00841                                 }
00842                         }
00843                         if ($useFieldNameAsKey) {
00844                                 $fieldList = $altFieldList;
00845                         }
00846 
00847                                 // Return array:
00848                         return $fieldList;
00849                 }
00850         }
00851 
00863         function getTCAtypeValue($table,$rec)   {
00864                 global $TCA;
00865 
00866                         // 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.
00867                 t3lib_div::loadTCA($table);
00868                 if ($TCA[$table])       {
00869                         $field = $TCA[$table]['ctrl']['type'];
00870                         $fieldValue = $field ? ($rec[$field] ? $rec[$field] : 0) : 0;
00871                         if (!is_array($TCA[$table]['types'][$fieldValue]))      $fieldValue = 1;
00872                         return $fieldValue;
00873                 }
00874         }
00875 
00886         function getSpecConfParts($str, $defaultExtras) {
00887 
00888                         // Add defaultExtras:
00889                 $specConfParts = t3lib_div::trimExplode(':', $defaultExtras.':'.$str, 1);
00890 
00891                 if (count($specConfParts))      {
00892                         foreach($specConfParts as $k2 => $v2)   {
00893                                 unset($specConfParts[$k2]);
00894                                 if (ereg('(.*)\[(.*)\]',$v2,$reg))      {
00895                                         $specConfParts[trim($reg[1])] = array(
00896                                                 'parameters' => t3lib_div::trimExplode('|', $reg[2], 1)
00897                                         );
00898                                 } else {
00899                                         $specConfParts[trim($v2)] = 1;
00900                                 }
00901                         }
00902                 } else {
00903                         $specConfParts = array();
00904                 }
00905                 return $specConfParts;
00906         }
00907 
00916         function getSpecConfParametersFromArray($pArr)  {
00917                 $out=array();
00918                 if (is_array($pArr))    {
00919                         reset($pArr);
00920                         while(list($k,$v)=each($pArr))  {
00921                                 $parts=explode('=',$v,2);
00922                                 if (count($parts)==2)   {
00923                                         $out[trim($parts[0])]=trim($parts[1]);
00924                                 } else {
00925                                         $out[$k]=$v;
00926                                 }
00927                         }
00928                 }
00929                 return $out;
00930         }
00931 
00942         function getFlexFormDS($conf,$row,$table)       {
00943 
00944                         // Get pointer field etc from TCA-config:
00945                 $ds_pointerField =      $conf['ds_pointerField'];
00946                 $ds_array =             $conf['ds'];
00947                 $ds_tableField =        $conf['ds_tableField'];
00948                 $ds_searchParentField =         $conf['ds_pointerField_searchParent'];
00949 
00950                         // Find source value:
00951                 $dataStructArray='';
00952                 if (is_array($ds_array))        {       // If there is a data source array, that takes precedence
00953                                 // If a pointer field is set, take the value from that field in the $row array and use as key.
00954                         if ($ds_pointerField)   {
00955                                 $srcPointer = $row[$ds_pointerField];
00956                                 $srcPointer = isset($ds_array[$srcPointer]) ? $srcPointer : 'default';
00957                         } else $srcPointer='default';
00958 
00959                                 // 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.
00960                         if (substr($ds_array[$srcPointer],0,5)=='FILE:')        {
00961                                 $file = t3lib_div::getFileAbsFileName(substr($ds_array[$srcPointer],5));
00962                                 if ($file && @is_file($file))   {
00963                                         $dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
00964                                 } else $dataStructArray = 'The file "'.substr($dsSrc,5).'" in ds-array key "'.$srcPointer.'" was not found ("'.$file.'")';      // Error message.
00965                         } else {
00966                                 $dataStructArray = t3lib_div::xml2array($ds_array[$srcPointer]);
00967                         }
00968 
00969                 } elseif ($ds_pointerField) {   // If pointer field AND possibly a table/field is set:
00970                                 // Value of field pointed to:
00971                         $srcPointer = $row[$ds_pointerField];
00972 
00973                                 // Searching recursively back if 'ds_pointerField_searchParent' is defined (typ. a page rootline, or maybe a tree-table):
00974                         if ($ds_searchParentField && !$srcPointer)      {
00975                                 $rr = t3lib_BEfunc::getRecord($table,$row['uid'],'uid,'.$ds_searchParentField); // Get the "pid" field - we cannot know that it is in the input record!
00976                                 t3lib_BEfunc::fixVersioningPid($table,$rr);
00977                                 $uidAcc=array();        // Used to avoid looping, if any should happen.
00978                                 $subFieldPointer = $conf['ds_pointerField_searchParent_subField'];
00979                                 while(!$srcPointer)             {
00980                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00981                                                                         'uid,'.$ds_pointerField.','.$ds_searchParentField.($subFieldPointer?','.$subFieldPointer:''),
00982                                                                         $table,
00983                                                                         'uid='.intval($rr[$ds_searchParentField]).t3lib_BEfunc::deleteClause($table)
00984                                                                 );
00985                                         $rr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00986 
00987                                                 // break if no result from SQL db or if looping...
00988                                         if (!is_array($rr) || isset($uidAcc[$rr['uid']]))       break;
00989                                         $uidAcc[$rr['uid']]=1;
00990 
00991                                         t3lib_BEfunc::fixVersioningPid($table,$rr);
00992                                         $srcPointer = ($subFieldPointer && $rr[$subFieldPointer]) ? $rr[$subFieldPointer] : $rr[$ds_pointerField];
00993                                 }
00994                         }
00995 
00996                                 // If there is a srcPointer value:
00997                         if ($srcPointer)        {
00998                                 if (t3lib_div::testInt($srcPointer))    {       // If integer, then its a record we will look up:
00999                                         list($tName,$fName) = explode(':',$ds_tableField,2);
01000                                         if ($tName && $fName && is_array($GLOBALS['TCA'][$tName]))      {
01001                                                 $dataStructRec = t3lib_BEfunc::getRecord($tName, $srcPointer);
01002                                                 $dataStructArray = t3lib_div::xml2array($dataStructRec[$fName]);
01003                                         } else $dataStructArray = 'No tablename ('.$tName.') or fieldname ('.$fName.') was found an valid!';
01004                                 } else {        // Otherwise expect it to be a file:
01005                                         $file = t3lib_div::getFileAbsFileName($srcPointer);
01006                                         if ($file && @is_file($file))   {
01007                                                 $dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
01008                                         } else $dataStructArray='The file "'.$srcPointer.'" was not found ("'.$file.'")';       // Error message.
01009                                 }
01010                         } else $dataStructArray='No source value in fieldname "'.$ds_pointerField.'"';  // Error message.
01011                 } else $dataStructArray='No proper configuration!';
01012                 return $dataStructArray;
01013         }
01014 
01015 
01016 
01017 
01018 
01019 
01020 
01021 
01022 
01023 
01024 
01025 
01026 
01027 
01028 
01029 
01030 
01031 
01032         /*******************************************
01033          *
01034          * Caching related
01035          *
01036          *******************************************/
01037 
01048         function storeHash($hash,$data,$ident)  {
01049                 $insertFields = array(
01050                         'hash' => $hash,
01051                         'content' => $data,
01052                         'ident' => $ident,
01053                         'tstamp' => time()
01054                 );
01055                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'hash="'.$GLOBALS['TYPO3_DB']->quoteStr($hash, 'cache_hash').'"');
01056                 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
01057         }
01058 
01068         function getHash($hash,$expTime)        {
01069                         // if expTime is not set, the hash will never expire
01070                 $expTime = intval($expTime);
01071                 if ($expTime)   {
01072                         $whereAdd = ' AND tstamp > '.(time()-$expTime);
01073                 }
01074                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'hash="'.$GLOBALS['TYPO3_DB']->quoteStr($hash, 'cache_hash').'"'.$whereAdd);
01075                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01076                         return $row['content'];
01077                 }
01078         }
01079 
01080 
01081 
01082 
01083 
01084 
01085 
01086 
01087         /*******************************************
01088          *
01089          * TypoScript related
01090          *
01091          *******************************************/
01092 
01104         function getPagesTSconfig($id,$rootLine='',$returnPartArray=0)  {
01105                 $id=intval($id);
01106                 if (!is_array($rootLine))       {
01107                         $rootLine = t3lib_BEfunc::BEgetRootLine($id,'');
01108                 }
01109                 ksort($rootLine);       // Order correctly, changed 030102
01110                 reset($rootLine);
01111                 $TSdataArray = array();
01112                 $TSdataArray['defaultPageTSconfig']=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];   // Setting default configuration:
01113                 while(list($k,$v)=each($rootLine))      {
01114                         $TSdataArray['uid_'.$v['uid']]=$v['TSconfig'];
01115                 }
01116                 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
01117                 if ($returnPartArray)   {
01118                         return $TSdataArray;
01119                 }
01120 
01121                         // Parsing the user TS (or getting from cache)
01122                 $userTS = implode($TSdataArray,chr(10).'[GLOBAL]'.chr(10));
01123                 $hash = md5('pageTS:'.$userTS);
01124                 $cachedContent = t3lib_BEfunc::getHash($hash,0);
01125                 $TSconfig = array();
01126                 if (isset($cachedContent))      {
01127                         $TSconfig = unserialize($cachedContent);
01128                 } else {
01129                         $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
01130                         $parseObj->parse($userTS);
01131                         $TSconfig = $parseObj->setup;
01132                         t3lib_BEfunc::storeHash($hash,serialize($TSconfig),'PAGES_TSconfig');
01133                 }
01134                 return $TSconfig;
01135         }
01136 
01155         function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='')   {
01156                 $id=intval($id);
01157                 if (is_array($pageTS) && $id>0) {
01158                         if (!is_array($impParams))      {
01159                                 $impParams =t3lib_BEfunc::implodeTSParams(t3lib_BEfunc::getPagesTSconfig($id));
01160                         }
01161                         reset($pageTS);
01162                         $set=array();
01163                         while(list($f,$v)=each($pageTS))        {
01164                                 $f = $TSconfPrefix.$f;
01165                                 if ((!isset($impParams[$f])&&trim($v)) || strcmp(trim($impParams[$f]),trim($v)))        {
01166                                         $set[$f]=trim($v);
01167                                 }
01168                         }
01169                         if (count($set))        {
01170                                         // Get page record and TS config lines
01171                                 $pRec = t3lib_befunc::getRecord('pages',$id);
01172                                 $TSlines = explode(chr(10),$pRec['TSconfig']);
01173                                 $TSlines = array_reverse($TSlines);
01174                                         // Reset the set of changes.
01175                                 reset($set);
01176                                 while(list($f,$v)=each($set))   {
01177                                         reset($TSlines);
01178                                         $inserted=0;
01179                                         while(list($ki,$kv)=each($TSlines))     {
01180                                                 if (substr($kv,0,strlen($f)+1)==$f.'=') {
01181                                                         $TSlines[$ki]=$f.'='.$v;
01182                                                         $inserted=1;
01183                                                         break;
01184                                                 }
01185                                         }
01186                                         if (!$inserted) {
01187                                                 $TSlines = array_reverse($TSlines);
01188                                                 $TSlines[]=$f.'='.$v;
01189                                                 $TSlines = array_reverse($TSlines);
01190                                         }
01191                                 }
01192                                 $TSlines = array_reverse($TSlines);
01193 
01194                                         // store those changes
01195                                 $TSconf = implode(chr(10),$TSlines);
01196 
01197                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($id), array('TSconfig' => $TSconf));
01198                         }
01199                 }
01200         }
01201 
01210         function implodeTSParams($p,$k='')      {
01211                 $implodeParams=array();
01212                 if (is_array($p))       {
01213                         reset($p);
01214                         while(list($kb,$val)=each($p))  {
01215                                 if (is_array($val))     {
01216                                         $implodeParams = array_merge($implodeParams,t3lib_BEfunc::implodeTSParams($val,$k.$kb));
01217                                 } else {
01218                                         $implodeParams[$k.$kb]=$val;
01219                                 }
01220                         }
01221                 }
01222                 return $implodeParams;
01223         }
01224 
01225 
01226 
01227 
01228 
01229 
01230 
01231 
01232         /*******************************************
01233          *
01234          * Users / Groups related
01235          *
01236          *******************************************/
01237 
01247         function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='') {
01248                 $be_user_Array=Array();
01249 
01250                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_users', 'pid=0 '.$where.t3lib_BEfunc::deleteClause('be_users'), '', 'username');
01251                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
01252                         $be_user_Array[$row['uid']]=$row;
01253                 }
01254                 return $be_user_Array;
01255         }
01256 
01265         function getGroupNames($fields='title,uid', $where='')  {
01266                 $be_group_Array = Array();
01267                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_groups', 'pid=0 '.$where.t3lib_BEfunc::deleteClause('be_groups'), '', 'title');
01268                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
01269                         $be_group_Array[$row['uid']] = $row;
01270                 }
01271                 return $be_group_Array;
01272         }
01273 
01282         function getListGroupNames($fields='title,uid') {
01283                 $exQ=' AND hide_in_lists=0';
01284                 if (!$GLOBALS['BE_USER']->isAdmin())    {
01285                         $exQ.=' AND uid IN ('.($GLOBALS['BE_USER']->user['usergroup_cached_list']?$GLOBALS['BE_USER']->user['usergroup_cached_list']:0).')';
01286                 }
01287                 return t3lib_BEfunc::getGroupNames($fields,$exQ);
01288         }
01289 
01301         function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0)   {
01302                 if (is_array($usernames) && is_array($groupArray))      {
01303                         while(list($uid,$row)=each($usernames)) {
01304                                 $userN=$uid;
01305                                 $set=0;
01306                                 if ($row['uid']!=$GLOBALS['BE_USER']->user['uid'])      {
01307                                         reset($groupArray);
01308                                         while(list(,$v)=each($groupArray))      {
01309                                                 if ($v && t3lib_div::inList($row['usergroup_cached_list'],$v))  {
01310                                                         $userN = $row['username'];
01311                                                         $set=1;
01312                                                 }
01313                                         }
01314                                 } else {
01315                                         $userN = $row['username'];
01316                                         $set=1;
01317                                 }
01318                                 $usernames[$uid]['username']=$userN;
01319                                 if ($excludeBlindedFlag && !$set) {unset($usernames[$uid]);}
01320                         }
01321                 }
01322                 return $usernames;
01323         }
01324 
01334         function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0)     {
01335                 if (is_array($groups) && is_array($groupArray)) {
01336                         while(list($uid,$row)=each($groups))    {
01337                                 $groupN=$uid;
01338                                 $set=0;
01339                                 if (t3lib_div::inArray($groupArray,$uid))       {
01340                                         $groupN=$row['title'];
01341                                         $set=1;
01342                                 }
01343                                 $groups[$uid]['title']=$groupN;
01344                                 if ($excludeBlindedFlag && !$set) {unset($groups[$uid]);}
01345                         }
01346                 }
01347                 return $groups;
01348         }
01349 
01350 
01351 
01352 
01353 
01354 
01355 
01356 
01357 
01358 
01359 
01360 
01361 
01362         /*******************************************
01363          *
01364          * Output related
01365          *
01366          *******************************************/
01367 
01368 
01369 
01377         function daysUntil($tstamp)     {
01378                 $delta_t = $tstamp-$GLOBALS['EXEC_TIME'];
01379                 return ceil($delta_t/(3600*24));
01380         }
01381 
01389         function date($tstamp)  {
01390                 return Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp);
01391         }
01392 
01400         function datetime($value)       {
01401                 return Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$value);
01402         }
01403 
01412         function time($value)   {
01413                 $hh = floor($value/3600);
01414                 $min = floor(($value-$hh*3600)/60);
01415                 $sec = $value-$hh*3600-$min*60;
01416                 $l = sprintf('%02d',$hh).':'.sprintf('%02d',$min).':'.sprintf('%02d',$sec);
01417                 return $l;
01418         }
01419 
01428         function calcAge($seconds,$labels = 'min|hrs|days|yrs') {
01429                 $labelArr = explode('|',$labels);
01430                 $prefix='';
01431                 if ($seconds<0) {$prefix='-'; $seconds=abs($seconds);}
01432                 if ($seconds<3600)      {
01433                         $seconds = round ($seconds/60).' '.trim($labelArr[0]);
01434                 } elseif ($seconds<24*3600)     {
01435                         $seconds = round ($seconds/3600).' '.trim($labelArr[1]);
01436                 } elseif ($seconds<365*24*3600) {
01437                         $seconds = round ($seconds/(24*3600)).' '.trim($labelArr[2]);
01438                 } else {
01439                         $seconds = round ($seconds/(365*24*3600)).' '.trim($labelArr[3]);
01440                 }
01441                 return $prefix.$seconds;
01442         }
01443 
01454         function dateTimeAge($tstamp,$prefix=1,$date='')        {
01455                 return $tstamp ?
01456                                 ($date=='date' ? t3lib_BEfunc::date($tstamp) : t3lib_BEfunc::datetime($tstamp)).
01457                                 ' ('.t3lib_BEfunc::calcAge($prefix*(time()-$tstamp),$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')' : '';
01458         }
01459 
01472         function titleAttrib($content='',$hsc=0)        {
01473                 global $CLIENT;
01474                 $attrib= ($CLIENT['BROWSER']=='net'&&$CLIENT['VERSION']<5)||$CLIENT['BROWSER']=='konqu' ? 'alt' : 'title';
01475                 return strcmp($content,'')?' '.$attrib.'="'.($hsc?htmlspecialchars($content):$content).'"' : $attrib;
01476         }
01477 
01485         function titleAltAttrib($content)       {
01486                 $out='';
01487                 $out.=' alt="'.htmlspecialchars($content).'"';
01488                 $out.=' title="'.htmlspecialchars($content).'"';
01489                 return $out;
01490         }
01491 
01509         function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir=NULL,$abs=0,$tparams='',$size='')    {
01510                 global $TCA;
01511                         // Load table.
01512                 t3lib_div::loadTCA($table);
01513 
01514                         // Find uploaddir automatically
01515                 $uploaddir = (is_null($uploaddir)) ? $TCA[$table]['columns'][$field]['config']['uploadfolder'] : $uploaddir;
01516                 $uploaddir = preg_replace('#/$#','',$uploaddir);
01517 
01518                         // Set thumbs-script:
01519                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
01520                         $thumbScript='gfx/notfound_thumb.gif';
01521                 } elseif(!$thumbScript) {
01522                         $thumbScript='thumbs.php';
01523                 }
01524                         // Check and parse the size parameter
01525                 $sizeParts=array();
01526                 if ($size = trim($size)) {
01527                         $sizeParts = explode('x', $size.'x'.$size);
01528                         if(!intval($sizeParts[0])) $size='';
01529                 }
01530 
01531                         // Traverse files:
01532                 $thumbs = explode(',', $row[$field]);
01533                 $thumbData='';
01534                 while(list(,$theFile)=each($thumbs))    {
01535                         if (trim($theFile))     {
01536                                 $fI = t3lib_div::split_fileref($theFile);
01537                                 $ext = $fI['fileext'];
01538                                                 // New 190201 start
01539                                 $max=0;
01540                                 if (t3lib_div::inList('gif,jpg,png',$ext)) {
01541                                         $imgInfo=@getimagesize(PATH_site.$uploaddir.'/'.$theFile);
01542                                         if (is_array($imgInfo)) {$max = max($imgInfo[0],$imgInfo[1]);}
01543                                 }
01544                                         // use the original image if it's size fits to the thumbnail size
01545                                 if ($max && $max<=(count($sizeParts)&&max($sizeParts)?max($sizeParts):56))      {
01546                                         $url = $uploaddir.'/'.trim($theFile);
01547                                         $theFile = '../'.$url;
01548                                         $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
01549                                         $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="../'.$backPath.$url.'" '.$imgInfo[3].' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';
01550                                                 // New 190201 stop
01551                                 } elseif ($ext=='ttf' || t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$ext)) {
01552                                         $theFile = ($abs?'':'../').($uploaddir?$uploaddir.'/':'').trim($theFile);
01553                                         $params = '&file='.rawurlencode($theFile);
01554                                         $params .= $size?'&size='.$size:'';
01555                                         $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
01556                                         $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
01557                                         $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.htmlspecialchars($backPath.$url).'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /></a> ';
01558                                 } else {
01559                                         $icon = t3lib_BEfunc::getFileIcon($ext);
01560                                         $url = 'gfx/fileicons/'.$icon;
01561                                         $thumbData.='<img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /> ';
01562                                 }
01563                         }
01564                 }
01565                 return $thumbData;
01566         }
01567 
01578         function getThumbNail($thumbScript,$theFile,$tparams='',$size='')       {
01579                 $params = '&file='.rawurlencode($theFile);
01580                 $params .= trim($size)?'&size='.trim($size):'';
01581                 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
01582                 $th='<img src="'.htmlspecialchars($url).'" title="'.trim(basename($theFile)).'"'.($tparams?" ".$tparams:"").' alt="" />';
01583                 return $th;
01584         }
01585 
01595         function titleAttribForPages($row,$perms_clause='',$includeAttrib=1)    {
01596                 global $TCA,$LANG;
01597                 $parts=array();
01598                 $parts[] = 'id='.$row['uid'];
01599                 if ($row['alias'])      $parts[]=$LANG->sL($TCA['pages']['columns']['alias']['label']).' '.$row['alias'];
01600                 if ($row['t3ver_id'])   $parts[] = 'v#'.$row['t3ver_id'];
01601                 if ($row['doktype']=='3')       {
01602                         $parts[]=$LANG->sL($TCA['pages']['columns']['url']['label']).' '.$row['url'];
01603                 } elseif ($row['doktype']=='4') {
01604                         if ($perms_clause)      {
01605                                 $label = t3lib_BEfunc::getRecordPath(intval($row['shortcut']),$perms_clause,20);
01606                         } else {
01607                                 $lRec = t3lib_BEfunc::getRecord('pages',intval($row['shortcut']),'title');
01608                                 $label = $lRec['title'];
01609                         }
01610                         if ($row['shortcut_mode']>0)    {
01611                                 $label.=', '.$LANG->sL($TCA['pages']['columns']['shortcut_mode']['label']).' '.
01612                                                         $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('pages','shortcut_mode',$row['shortcut_mode']));
01613                         }
01614                         $parts[]=$LANG->sL($TCA['pages']['columns']['shortcut']['label']).' '.$label;
01615                 } elseif ($row['doktype']=='7') {
01616                         if ($perms_clause)      {
01617                                 $label = t3lib_BEfunc::getRecordPath(intval($row['mount_pid']),$perms_clause,20);
01618                         } else {
01619                                 $lRec = t3lib_BEfunc::getRecord('pages',intval($row['mount_pid']),'title');
01620                                 $label = $lRec['title'];
01621                         }
01622                         $parts[]=$LANG->sL($TCA['pages']['columns']['mount_pid']['label']).' '.$label;
01623                         if ($row['mount_pid_ol'])       {
01624                                 $parts[] = $LANG->sL($TCA['pages']['columns']['mount_pid_ol']['label']);
01625                         }
01626                 }
01627                 if ($row['nav_hide'])   $parts[] = ereg_replace(':$','',$LANG->sL($TCA['pages']['columns']['nav_hide']['label']));
01628                 if ($row['hidden'])     $parts[] = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.hidden');
01629                 if ($row['starttime'])  $parts[] = $LANG->sL($TCA['pages']['columns']['starttime']['label']).' '.t3lib_BEfunc::dateTimeAge($row['starttime'],-1,'date');
01630                 if ($row['endtime'])    $parts[] = $LANG->sL($TCA['pages']['columns']['endtime']['label']).' '.t3lib_BEfunc::dateTimeAge($row['endtime'],-1,'date');
01631                 if ($row['fe_group'])   {
01632                         if ($row['fe_group']<0) {
01633                                 $label = $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('pages','fe_group',$row['fe_group']));
01634                         } else {
01635                                 $lRec = t3lib_BEfunc::getRecord('fe_groups',$row['fe_group'],'title');
01636                                 $label = $lRec['title'];
01637                         }
01638                         $parts[] = $LANG->sL($TCA['pages']['columns']['fe_group']['label']).' '.$label;
01639                 }
01640                 $out = htmlspecialchars(implode(' - ',$parts));
01641                 return $includeAttrib ? 'title="'.$out.'"' : $out;
01642         }
01643 
01654         function getRecordIconAltText($row,$table='pages')      {
01655                 if ($table=='pages')    {
01656                         $out = t3lib_BEfunc::titleAttribForPages($row,'',0);
01657                 } else {
01658                         $ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
01659 
01660                         $out='id='.$row['uid']; // Uid is added
01661                         if ($table=='pages' && $row['alias'])   {
01662                                 $out.=' / '.$row['alias'];
01663                         }
01664                         if ($GLOBALS['TCA'][$table]['ctrl']['versioning'] && $row['t3ver_id'])  {
01665                                 $out.=' - v#'.$row['t3ver_id'];
01666                         }
01667                         if ($ctrl['disabled'])  {               // Hidden ...
01668                                 $out.=($row[$ctrl['disabled']]?' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.hidden'):'');
01669                         }
01670                         if ($ctrl['starttime']) {
01671                                 if ($row[$ctrl['starttime']] > $GLOBALS['EXEC_TIME'])   {
01672                                         $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').')';
01673                                 }
01674                         }
01675                         if ($row[$ctrl['endtime']])     {
01676                                 $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').')';
01677                         }
01678                 }
01679                 return htmlspecialchars($out);
01680         }
01681 
01691         function getLabelFromItemlist($table,$col,$key) {
01692                 global $TCA;
01693                         // Load full TCA for $table
01694                 t3lib_div::loadTCA($table);
01695 
01696                         // Check, if there is an "items" array:
01697                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]) && is_array($TCA[$table]['columns'][$col]['config']['items']))    {
01698                                 // Traverse the items-array...
01699                         reset($TCA[$table]['columns'][$col]['config']['items']);
01700                         while(list($k,$v)=each($TCA[$table]['columns'][$col]['config']['items']))       {
01701                                         // ... and return the first found label where the value was equal to $key
01702                                 if (!strcmp($v[1],$key))        return $v[0];
01703                         }
01704                 }
01705         }
01706 
01717         function getItemLabel($table,$col,$printAllWrap='')     {
01718                 global $TCA;
01719                         // Load full TCA for $table
01720                 t3lib_div::loadTCA($table);
01721                         // Check if column exists
01722                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]))  {
01723                                 // Re
01724                         return $TCA[$table]['columns'][$col]['label'];
01725                 }
01726                 if ($printAllWrap)      {
01727                         $parts = explode('|',$printAllWrap);
01728                         return $parts[0].$col.$parts[1];
01729                 }
01730         }
01731 
01742         function getRecordTitle($table,$row,$prep=0)    {
01743                 global $TCA;
01744                 if (is_array($TCA[$table]))     {
01745                         $t = $row[$TCA[$table]['ctrl']['label']];
01746                         if ($TCA[$table]['ctrl']['label_alt'] && ($TCA[$table]['ctrl']['label_alt_force'] || !strcmp($t,'')))   {
01747                                 $altFields=t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
01748                                 $tA=array();
01749                                 $tA[]=$t;
01750                                 while(list(,$fN)=each($altFields))      {
01751                                         $t = $tA[] = trim(strip_tags($row[$fN]));
01752                                         if (strcmp($t,'') && !$TCA[$table]['ctrl']['label_alt_force'])  break;
01753                                 }
01754                                 if ($TCA[$table]['ctrl']['label_alt_force'])    $t=implode(', ',$tA);
01755                         }
01756                         if ($prep)      {
01757                                 $t = htmlspecialchars(t3lib_div::fixed_lgd_cs($t,$GLOBALS['BE_USER']->uc['titleLen']));
01758                                 if (!strcmp(trim($t),''))       $t='<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</em>';
01759                         }
01760                         return $t;
01761                 }
01762         }
01763 
01778         function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0) {
01779                 global $TCA;
01780                         // Load full TCA for $table
01781                 t3lib_div::loadTCA($table);
01782                         // Check if table and field is configured:
01783                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]))  {
01784                                 // Depending on the fields configuration, make a meaningful output value.
01785                         $theColConf = $TCA[$table]['columns'][$col]['config'];
01786                         $l='';
01787                         switch((string)$theColConf['type'])     {
01788                                 case 'radio':
01789                                         $l=t3lib_BEfunc::getLabelFromItemlist($table,$col,$value);
01790                                 break;
01791                                 case 'select':
01792                                         if ($theColConf['MM'])  {
01793                                                 $l='N/A';
01794                                         } else {
01795                                                 $l=t3lib_BEfunc::getLabelFromItemlist($table,$col,$value);
01796                                                 $l=$GLOBALS['LANG']->sL($l);
01797                                                 if ($theColConf['foreign_table'] && !$l && $TCA[$theColConf['foreign_table']])  {
01798                                                         $rParts = t3lib_div::trimExplode(',',$value,1);
01799                                                         reset($rParts);
01800                                                         $lA=array();
01801                                                         while(list(,$rVal)=each($rParts))       {
01802                                                                 $rVal = intval($rVal);
01803                                                                 if ($rVal>0) {
01804                                                                         $r=t3lib_BEfunc::getRecord($theColConf['foreign_table'],$rVal);
01805                                                                 } else {
01806                                                                         $r=t3lib_BEfunc::getRecord($theColConf['neg_foreign_table'],-$rVal);
01807                                                                 }
01808                                                                 if (is_array($r))       {
01809                                                                         $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);
01810                                                                 } else {
01811                                                                         $lA[]=$rVal?'['.$rVal.'!]':'';
01812                                                                 }
01813                                                         }
01814                                                         $l=implode(',',$lA);
01815                                                 }
01816                                         }
01817                                 break;
01818                                 case 'check':
01819                                         if (!is_array($theColConf['items']) || count($theColConf['items'])==1)  {
01820                                                 $l = $value ? 'Yes' : '';
01821                                         } else {
01822                                                 reset($theColConf['items']);
01823                                                 $lA=Array();
01824                                                 while(list($key,$val)=each($theColConf['items']))       {
01825                                                         if ($value & pow(2,$key))       {$lA[]=$GLOBALS['LANG']->sL($val[0]);}
01826                                                 }
01827                                                 $l = implode($lA,', ');
01828                                         }
01829                                 break;
01830                                 case 'input':
01831                                         if ($value)     {
01832                                                 if (t3lib_div::inList($theColConf['eval'],'date'))      {
01833                                                         $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')).')';
01834                                                 } elseif (t3lib_div::inList($theColConf['eval'],'time'))        {
01835                                                         $l = t3lib_BEfunc::time($value);
01836                                                 } elseif (t3lib_div::inList($theColConf['eval'],'datetime'))    {
01837                                                         $l = t3lib_BEfunc::datetime($value);
01838                                                 } else {
01839                                                         $l = $value;
01840                                                 }
01841                                         }
01842                                 break;
01843                                 default:
01844                                         if ($defaultPassthrough)        {
01845                                                 $l=$value;
01846                                         } elseif ($theColConf['MM'])    {
01847                                                 $l='N/A';
01848                                         } elseif ($value)       {
01849                                                 $l=t3lib_div::fixed_lgd_cs(strip_tags($value),200);
01850                                         }
01851                                 break;
01852                         }
01853                         if ($fixed_lgd_chars)   {
01854                                 return t3lib_div::fixed_lgd_cs($l,$fixed_lgd_chars);
01855                         } else {
01856                                 return $l;
01857                         }
01858                 }
01859         }
01860 
01872         function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0)      {
01873                 global $TCA;
01874                 $fVnew = t3lib_BEfunc::getProcessedValue($table,$fN,$fV,$fixed_lgd_chars);
01875                 if (!isset($fVnew))     {
01876                         if (is_array($TCA[$table]))     {
01877                                 if ($fN==$TCA[$table]['ctrl']['tstamp'] || $fN==$TCA[$table]['ctrl']['crdate']) {
01878                                         $fVnew = t3lib_BEfunc::datetime($fV);
01879                                 } elseif ($fN=='pid'){
01880                                         $fVnew = t3lib_BEfunc::getRecordPath($fV,'1',20);       // Fetches the path with no regard to the users permissions to select pages.
01881                                 } else {
01882                                         $fVnew = $fV;
01883                                 }
01884                         }
01885                 }
01886                 return $fVnew;
01887         }
01888 
01896         function getFileIcon($ext)      {
01897                 return $GLOBALS['FILEICONS'][$ext] ? $GLOBALS['FILEICONS'][$ext] : $GLOBALS['FILEICONS']['default'];
01898         }
01899 
01910         function getCommonSelectFields($table,$prefix)  {
01911                 global $TCA;
01912                 $fields = array();
01913                 $fields[] = $prefix.'uid';
01914                 $fields[] = $prefix.$TCA[$table]['ctrl']['label'];
01915 
01916                 if ($TCA[$table]['ctrl']['label_alt'])  {
01917                         $secondFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
01918                         foreach($secondFields as $fieldN)       {
01919                                 $fields[] = $prefix.$fieldN;
01920                         }
01921                 }
01922                 if ($TCA[$table]['ctrl']['versioning']) {
01923                         $fields[] = $prefix.'t3ver_id';
01924                 }
01925 
01926                 if ($TCA[$table]['ctrl']['selicon_field'])      $fields[] = $prefix.$TCA[$table]['ctrl']['selicon_field'];
01927                 if ($TCA[$table]['ctrl']['typeicon_column'])    $fields[] = $prefix.$TCA[$table]['ctrl']['typeicon_column'];
01928 
01929                 if (is_array($TCA[$table]['ctrl']['enablecolumns']))            {
01930                         if ($TCA[$table]['ctrl']['enablecolumns']['disabled'])  $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['disabled'];
01931                         if ($TCA[$table]['ctrl']['enablecolumns']['starttime']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['starttime'];
01932                         if ($TCA[$table]['ctrl']['enablecolumns']['endtime'])   $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['endtime'];
01933                         if ($TCA[$table]['ctrl']['enablecolumns']['fe_group'])  $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['fe_group'];
01934                 }
01935 
01936                 return implode(',',array_unique($fields));
01937         }
01938 
01950         function makeConfigForm($configArray,$defaults,$dataPrefix)     {
01951                 $params = $defaults;
01952                 if (is_array($configArray))     {
01953                         reset($configArray);
01954                         $lines=array();
01955                         while(list($fname,$config)=each($configArray))  {
01956                                 if (is_array($config))  {
01957                                         $lines[$fname]='<strong>'.htmlspecialchars($config[1]).'</strong><br />';
01958                                         $lines[$fname].=$config[2].'<br />';
01959                                         switch($config[0])      {
01960                                                 case 'string':
01961                                                 case 'short':
01962                                                         $formEl = '<input type="text" name="'.$dataPrefix.'['.$fname.']" value="'.$params[$fname].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($config[0]=='short'?24:48).' />';
01963                                                 break;
01964                                                 case 'check':
01965                                                         $formEl = '<input type="hidden" name="'.$dataPrefix.'['.$fname.']" value="0" /><input type="checkbox" name="'.$dataPrefix.'['.$fname.']" value="1"'.($params[$fname]?' checked="checked"':'').' />';
01966                                                 break;
01967                                                 case 'comment':
01968                                                         $formEl = '';
01969                                                 break;
01970                                                 case 'select':
01971                                                         reset($config[3]);
01972                                                         $opt=array();
01973                                                         while(list($k,$v)=each($config[3]))     {
01974                                                                 $opt[]='<option value="'.htmlspecialchars($k).'"'.($params[$fname]==$k?' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
01975                                                         }
01976                                                         $formEl = '<select name="'.$dataPrefix.'['.$fname.']">'.implode('',$opt).'</select>';
01977                                                 break;
01978                                                 default:
01979                                                         debug($config);
01980                                                 break;
01981                                         }
01982                                         $lines[$fname].=$formEl;
01983                                         $lines[$fname].='<br /><br />';
01984                                 } else {
01985                                         $lines[$fname]='<hr />';
01986                                         if ($config)    $lines[$fname].='<strong>'.strtoupper(htmlspecialchars($config)).'</strong><br />';
01987                                         if ($config)    $lines[$fname].='<br />';
01988                                 }
01989                         }
01990                 }
01991                 $out = implode('',$lines);
01992                 $out.='<input type="submit" name="submit" value="Update configuration" />';
01993                 return $out;
01994         }
01995 
01996 
01997 
01998 
01999 
02000 
02001 
02002 
02003 
02004 
02005 
02006 
02007 
02008         /*******************************************
02009          *
02010          * Backend Modules API functions
02011          *
02012          *******************************************/
02013 
02025         function helpTextIcon($table,$field,$BACK_PATH,$force=0)        {
02026                 global $TCA_DESCR,$BE_USER;
02027                 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && ($BE_USER->uc['edit_showFieldHelp']=='icon' || $force))  {
02028                         $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;';
02029                         return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
02030                                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="typo3-csh-icon" alt="" />'.
02031                                         '</a>';
02032                 }
02033         }
02034 
02047         function helpText($table,$field,$BACK_PATH,$styleAttrib='')     {
02048                 global $TCA_DESCR,$BE_USER;
02049                 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && $BE_USER->uc['edit_showFieldHelp']=='text')      {
02050                         $fDat = $TCA_DESCR[$table]['columns'][$field];
02051 
02052                                 // Get Icon:
02053                         $editIcon = t3lib_BEfunc::helpTextIcon(
02054                                                                         $table,
02055                                                                         $field,
02056                                                                         $BACK_PATH,
02057                                                                         TRUE
02058                                                                 );
02059                                 // Add title?
02060                         $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;';
02061                         $text =
02062                                         ($fDat['alttitle'] ? '<h4><a href="#" onclick="'.htmlspecialchars($onClick).'">'.$fDat['alttitle'].'</a></h4>' : '').
02063                                         $fDat['description'];
02064 
02065                                 // More information to get?
02066                         if ($fDat['image_descr'] || $fDat['seeAlso'] || $fDat['details'] || $fDat['syntax'])    { // || $fDat['image'];
02067                                 $text.=' <a href="#" onclick="'.htmlspecialchars($onClick).'">'.
02068                                                 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/rel_db.gif','width="13" height="12"').' class="absmiddle typo3-csh-more" alt="" />'.
02069                                                 '</a>';
02070                         }
02071 
02072                                 // Additional styles?
02073                         $params = $styleAttrib ? ' style="'.$styleAttrib.'"' : '';
02074 
02075                                 // Compile table with CSH information:
02076                         return '<table border="0" cellpadding="2" cellspacing="0" class="typo3-csh-inline"'.$params.'>
02077                                                 <tr>
02078                                                         <td valign="top" width="14">'.$editIcon.'</td>
02079                                                         <td valign="top">'.$text.'</td>
02080                                                 </tr>
02081                                         </table>';
02082                 }
02083         }
02084 
02099         function cshItem($table,$field,$BACK_PATH,$wrap='',$onlyIconMode=FALSE, $styleAttrib='')        {
02100                 global $TCA_DESCR, $LANG, $BE_USER;
02101                 if ($BE_USER->uc['edit_showFieldHelp']) {
02102                         $LANG->loadSingleTableDescription($table);
02103 
02104                         if (is_array($TCA_DESCR[$table]))       {
02105                                         // Creating CSH icon and short description:
02106                                 $fullText = t3lib_BEfunc::helpText($table,$field,$BACK_PATH,$styleAttrib);
02107                                 $icon = t3lib_BEfunc::helpTextIcon($table,$field,$BACK_PATH,$onlyIconMode);
02108 
02109                                 if ($fullText && !$onlyIconMode)        {
02110                                         $output = $fullText;
02111                                 } else {
02112                                         #$output = '<span style="position:absolute; filter: alpha(opacity=50); -moz-opacity: 0.50;">'.$icon.'</span>';
02113                                         $output = $icon;
02114 
02115                                         if ($output && $wrap)   {
02116                                                 $wrParts = explode('|',$wrap);
02117                                                 $output = $wrParts[0].$output.$wrParts[1];
02118                                         }
02119                                 }
02120 
02121                                 return $output;
02122                         }
02123                 }
02124         }
02125 
02137         function editOnClick($params,$backPath='',$requestUri='')       {
02138                 $retUrl = 'returnUrl='.($requestUri==-1?"'+T3_THIS_LOCATION+'":rawurlencode($requestUri?$requestUri:t3lib_div::getIndpEnv('REQUEST_URI')));
02139                 return "document.location='".$backPath."alt_doc.php?".$retUrl.$params."'; return false;";
02140         }
02141 
02155         function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='',$addGetVars='')        {
02156                 if ($altUrl)    {
02157                         $url = $altUrl;
02158                 } else {
02159                         if ($rootLine)  {
02160                                 $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
02161                                 if (t3lib_BEfunc::getDomainStartPage($parts['host'],$parts['path']))    {
02162                                         $preUrl_temp = t3lib_BEfunc::firstDomainRecord($rootLine);
02163                                 }
02164                         }
02165                         $preUrl = $preUrl_temp ? 'http://'.$preUrl_temp : $backPath.'..';
02166                         $url = $preUrl.'/index.php?id='.$id.$addGetVars.$anchor;
02167                 }
02168 
02169                 return "previewWin=window.open('".$url."','newTypo3FrontendWindow','status=1,menubar=1,resizable=1,location=1,scrollbars=1,toolbar=1');previewWin.focus();";
02170         }
02171 
02181         function getModTSconfig($id,$TSref)     {
02182                 $pageTS_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref,t3lib_BEfunc::getPagesTSconfig($id));
02183                 $BE_USER_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref);
02184                 $modTSconfig = t3lib_div::array_merge_recursive_overrule($pageTS_modOptions,$BE_USER_modOptions);
02185                 return $modTSconfig;
02186         }
02187 
02202         function getFuncMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')        {
02203                 if (is_array($menuItems))       {
02204                         if (!is_array($mainParams)) {
02205                                 $mainParams = array('id' => $mainParams);
02206                         }
02207                         $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02208 
02209                         if (!$script) { $script=basename(PATH_thisScript); }
02210 
02211                         $options = array();
02212                         foreach($menuItems as $value => $label) {
02213                                 $options[] = '<option value="'.htmlspecialchars($value).'"'.(!strcmp($currentValue,$value)?' selected="selected"':'').'>'.
02214                                                                 t3lib_div::deHSCentities(htmlspecialchars($label)).
02215                                                                 '</option>';
02216                         }
02217                         if (count($options))    {
02218                                 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+this.options[this.selectedIndex].value,this);';
02219                                 return '
02220 
02221                                         <!-- Function Menu of module -->
02222                                         <select name="'.$elementName.'" onchange="'.htmlspecialchars($onChange).'">
02223                                                 '.implode('
02224                                                 ',$options).'
02225                                         </select>
02226                                                         ';
02227                         }
02228                 }
02229         }
02230 
02245         function getFuncCheck($mainParams,$elementName,$currentValue,$script='',$addparams='',$tagParams='')    {
02246                 if (!is_array($mainParams)) {
02247                         $mainParams = array('id' => $mainParams);
02248                 }
02249                 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02250 
02251                 if (!$script) {basename(PATH_thisScript);}
02252                 $onClick = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+(this.checked?1:0),this);';
02253                 return '<input type="checkbox" name="'.$elementName.'"'.($currentValue?' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'"'.($tagParams?' '.$tagParams:'').' />';
02254         }
02255 
02270         function getFuncInput($mainParams,$elementName,$currentValue,$size=10,$script="",$addparams="") {
02271                 if (!is_array($mainParams)) {
02272                         $mainParams = array('id' => $mainParams);
02273                 }
02274                 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02275 
02276                 if (!$script) {basename(PATH_thisScript);}
02277                 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+escape(this.value),this);';
02278                 return '<input type="text"'.$GLOBALS['TBE_TEMPLATE']->formWidth($size).' name="'.$elementName.'" value="'.htmlspecialchars($currentValue).'" onchange="'.htmlspecialchars($onChange).'" />';
02279         }
02280 
02291         function unsetMenuItems($modTSconfig,$itemArray,$TSref) {
02292                         // Getting TS-config options for this module for the Backend User:
02293                 $conf = $GLOBALS['BE_USER']->getTSConfig($TSref,$modTSconfig);
02294                 if (is_array($conf['properties']))      {
02295                         reset($conf['properties']);
02296                         while(list($key,$val)=each($conf['properties']))        {
02297                                 if (!$val)      {
02298                                         unset($itemArray[$key]);
02299                                 }
02300                         }
02301                 }
02302                 return $itemArray;
02303         }
02304 
02314         function getSetUpdateSignal($set='')    {
02315                 global $BE_USER;
02316                 $key = 't3lib_BEfunc::getSetUpdateSignal';
02317                 $out='';
02318                 if ($set)       {
02319                         $modData=array();
02320                         $modData['set']=$set;
02321                         $BE_USER->pushModuleData($key,$modData);
02322                 } else {
02323                         $modData = $BE_USER->getModuleData($key,'ses');
02324                         if (trim($modData['set']))      {
02325                                 $l=explode(',',$modData['set']);
02326                                 while(list(,$v)=each($l))       {
02327                                         switch($v)      {
02328                                                 case 'updatePageTree':
02329                                                 case 'updateFolderTree':
02330                                                         $out.='
02331                                         <script type="text/javascript">
02332                                         /*<![CDATA[*/
02333                                                         if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)  {
02334                                                                 top.content.nav_frame.refresh_nav();
02335                                                         }
02336                                         /*]]>*/
02337                                         </script>';
02338                                                 break;
02339                                         }
02340                                 }
02341                                 $modData=array();
02342                                 $modData['set']='';
02343                                 $BE_USER->pushModuleData($key,$modData);
02344                         }
02345                 }
02346                 return $out;
02347         }
02348 
02349 
02365         function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')      {
02366 
02367                 if ($modName && is_string($modName))    {
02368                                         // GETTING stored user-data from this module:
02369                         $settings = $GLOBALS['BE_USER']->getModuleData($modName,$type);
02370 
02371                         $changed=0;
02372                         if (!is_array($settings))       {
02373                                 $changed=1;
02374                                 $settings=array();
02375                         }
02376                         if (is_array($MOD_MENU))        {
02377                                 reset($MOD_MENU);
02378                                 while(list($key,$var)=each($MOD_MENU))  {
02379                                                 // If a global var is set before entering here. eg if submitted, then it's substituting the current value the array.
02380                                         if (is_array($CHANGED_SETTINGS) && isset($CHANGED_SETTINGS[$key]) && strcmp($settings[$key],$CHANGED_SETTINGS[$key]))   {
02381                                                 $settings[$key] = (string)$CHANGED_SETTINGS[$key];
02382                                                 $changed=1;
02383                                         }
02384                                                 // If the $var is an array, which denotes the existence of a menu, we check if the value is permitted
02385                                         if (is_array($var) && (!$dontValidateList || !t3lib_div::inList($dontValidateList,$key)))       {
02386                                                         // If the setting is an array or not present in the menu-array, MOD_MENU, then the default value is inserted.
02387                                                 if (is_array($settings[$key]) || !isset($MOD_MENU[$key][$settings[$key]]))      {
02388                                                         $settings[$key]=(string)key($var);
02389                                                         $changed=1;
02390                                                 }
02391                                         }
02392                                         if ($setDefaultList && !is_array($var)) {       // Sets default values (only strings/checkboxes, not menus)
02393                                                 if (t3lib_div::inList($setDefaultList,$key) && !isset($settings[$key])) {
02394                                                         $settings[$key]=$var;
02395                                                 }
02396                                         }
02397                                 }
02398                         } else {die ('No menu!');}
02399 
02400                         if ($changed)   {
02401                                 $GLOBALS['BE_USER']->pushModuleData($modName,$settings);
02402                         }
02403 
02404                         return  $settings;
02405                 } else {die ('Wrong module name: "'.$modName.'"');}
02406         }
02407 
02408 
02409 
02410 
02411 
02412 
02413 
02414 
02415 
02416 
02417 
02418 
02419 
02420         /*******************************************
02421          *
02422          * Core
02423          *
02424          *******************************************/
02425 
02426 
02427 
02440         function lockRecords($table='',$uid=0,$pid=0)   {
02441                 $user_id = intval($GLOBALS['BE_USER']->user['uid']);
02442                 if ($table && $uid)     {
02443                         $fields_values = array(
02444                                 'userid' => $user_id,
02445                                 'tstamp' => $GLOBALS['EXEC_TIME'],
02446                                 'record_table' => $table,
02447                                 'record_uid' => $uid,
02448                                 'username' => $GLOBALS['BE_USER']->user['username'],
02449                                 'record_pid' => $pid
02450                         );
02451 
02452                         $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
02453                 } else {
02454                         $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'userid='.intval($user_id));
02455                 }
02456         }
02457 
02469         function isRecordLocked($table,$uid)    {
02470                 global $LOCKED_RECORDS;
02471                 if (!is_array($LOCKED_RECORDS)) {
02472                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
02473                                                         '*',
02474                                                         'sys_lockedrecords',
02475                                                         'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user['uid']).'
02476                                                                 AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
02477                                                 );
02478                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
02479                                 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
02480                                 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
02481                                         $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'),
02482                                         $row['username'],
02483                                         t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
02484                                 );
02485                                 if ($row['record_pid'] && !isset($LOCKED_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
02486                                         $LOCKED_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
02487                                                 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content'),
02488                                                 $row['username'],
02489                                                 t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
02490                                         );
02491                                 }
02492                         }
02493                 }
02494                 return $LOCKED_RECORDS[$table.':'.$uid];
02495         }
02496 
02509         function exec_foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='')     {
02510                 global $TCA;
02511                 $foreign_table = $fieldValue['config'][$prefix.'foreign_table'];
02512                 $rootLevel = $TCA[$foreign_table]['ctrl']['rootLevel'];
02513 
02514                 $fTWHERE = $fieldValue['config'][$prefix.'foreign_table_where'];
02515                 if (strstr($fTWHERE,'###REC_FIELD_'))   {
02516                         $fTWHERE_parts = explode('###REC_FIELD_',$fTWHERE);
02517                         while(list($kk,$vv)=each($fTWHERE_parts))       {
02518                                 if ($kk)        {
02519                                         $fTWHERE_subpart = explode('###',$vv,2);
02520                                         $fTWHERE_parts[$kk]=$TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]].$fTWHERE_subpart[1];
02521                                 }
02522                         }
02523                         $fTWHERE = implode('',$fTWHERE_parts);
02524                 }
02525 
02526                 $fTWHERE = str_replace('###CURRENT_PID###',intval($TSconfig['_CURRENT_PID']),$fTWHERE);
02527                 $fTWHERE = str_replace('###THIS_UID###',intval($TSconfig['_THIS_UID']),$fTWHERE);
02528                 $fTWHERE = str_replace('###THIS_CID###',intval($TSconfig['_THIS_CID']),$fTWHERE);
02529                 $fTWHERE = str_replace('###STORAGE_PID###',intval($TSconfig['_STORAGE_PID']),$fTWHERE);
02530                 $fTWHERE = str_replace('###SITEROOT###',intval($TSconfig['_SITEROOT']),$fTWHERE);
02531                 $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###',intval($TSconfig[$field]['PAGE_TSCONFIG_ID']),$fTWHERE);
02532                 $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###',$GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']),$fTWHERE);
02533                 $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###',$GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$field]['PAGE_TSCONFIG_STR'], $foreign_table),$fTWHERE);
02534 
02535                         // rootLevel = -1 is not handled 'properly' here - it goes as if it was rootLevel = 1 (that is pid=0)
02536                 $wgolParts = $GLOBALS['TYPO3_DB']->splitGroupOrderLimit($fTWHERE);
02537                 if ($rootLevel) {
02538                         $queryParts = array(
02539                                 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02540                                 'FROM' => $foreign_table,
02541                                 'WHERE' => $foreign_table.'.pid=0 '.
02542                                                         t3lib_BEfunc::deleteClause($foreign_table).' '.
02543                                                         $wgolParts['WHERE'],
02544                                 'GROUPBY' => $wgolParts['GROUPBY'],
02545                                 'ORDERBY' => $wgolParts['ORDERBY'],
02546                                 'LIMIT' => $wgolParts['LIMIT']
02547                         );
02548                 } else {
02549                         $pageClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
02550                         if ($foreign_table!='pages')    {
02551                                 $queryParts = array(
02552                                         'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02553                                         'FROM' => $foreign_table.',pages',
02554                                         'WHERE' => 'pages.uid='.$foreign_table.'.pid
02555                                                                 AND NOT pages.deleted '.
02556                                                                 t3lib_BEfunc::deleteClause($foreign_table).
02557                                                                 ' AND '.$pageClause.' '.
02558                                                                 $wgolParts['WHERE'],
02559                                         'GROUPBY' => $wgolParts['GROUPBY'],
02560                                         'ORDERBY' => $wgolParts['ORDERBY'],
02561                                         'LIMIT' => $wgolParts['LIMIT']
02562                                 );
02563                         } else {
02564                                 $queryParts = array(
02565                                         'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02566                                         'FROM' => 'pages',
02567                                         'WHERE' => 'NOT pages.deleted
02568                                                                 AND '.$pageClause.' '.
02569                                                                 $wgolParts['WHERE'],
02570                                         'GROUPBY' => $wgolParts['GROUPBY'],
02571                                         'ORDERBY' => $wgolParts['ORDERBY'],
02572                                         'LIMIT' => $wgolParts['LIMIT']
02573                                 );
02574                         }
02575                 }
02576 
02577                 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
02578         }
02579 
02590         function getTCEFORM_TSconfig($table,$row) {
02591                 $res = array();
02592                 $typeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
02593 
02594                         // Get main config for the table
02595                 list($TScID,$cPid) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']);
02596 
02597                 $rootLine = t3lib_BEfunc::BEgetRootLine($TScID,'');
02598                 if ($TScID>=0)  {
02599                         $tempConf = $GLOBALS['BE_USER']->getTSConfig('TCEFORM.'.$table,t3lib_BEfunc::getPagesTSconfig($TScID,$rootLine));
02600                         if (is_array($tempConf['properties']))  {
02601                                 while(list($key,$val)=each($tempConf['properties']))    {
02602                                         if (is_array($val))     {
02603                                                 $fieldN = substr($key,0,-1);
02604                                                 $res[$fieldN] = $val;
02605                                                 unset($res[$fieldN]['types.']);
02606                                                 if (strcmp($typeVal,'') && is_array($val['types.'][$typeVal.'.']))      {
02607                                                         $res[$fieldN] = t3lib_div::array_merge_recursive_overrule($res[$fieldN],$val['types.'][$typeVal.'.']);
02608                                                 }
02609                                         }
02610                                 }
02611                         }
02612                 }
02613                 $res['_CURRENT_PID']=$cPid;
02614                 $res['_THIS_UID']=$row['uid'];
02615                 $res['_THIS_CID']=$row['cid'];
02616                 $res['_THIS_ROW']=$row; // So the row will be passed to foreign_table_where_query()
02617                 reset($rootLine);
02618                 while(list(,$rC)=each($rootLine))       {
02619                         if (!$res['_STORAGE_PID'])      $res['_STORAGE_PID']=intval($rC['storage_pid']);
02620                         if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?intval($rC['uid']):0;
02621                 }
02622 
02623                 return $res;
02624         }
02625 
02637         function getTSconfig_pidValue($table,$uid,$pid) {
02638                 if (t3lib_div::testInt($pid))   {       // If pid is an integer this takes precedence in our lookup.
02639                         $thePidValue = intval($pid);
02640                         if ($thePidValue<0)     {       // If ref to another record, look that record up.
02641                                 $pidRec = t3lib_BEfunc::getRecord($table,abs($thePidValue),'pid');
02642                                 $thePidValue= is_array($pidRec) ? $pidRec['pid'] : -2;  // Returns -2 if the record did not exist.
02643                         }
02644                         // ... else the pos/zero pid is just returned here.
02645                 } else {        // No integer pid and we are forced to look up the $pid
02646                         $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...
02647                         if (is_array($rr))      {
02648                                 $thePidValue = $rr['pid'];      // Returning the 'pid' of the record
02649                         } else $thePidValue=-1; // Returns -1 if the record with the pid was not found.
02650                 }
02651                 return $thePidValue;
02652         }
02653 
02665         function getPidForModTSconfig($table,$uid,$pid) {
02666                 $retVal = ($table=='pages' && t3lib_div::testInt($uid)) ? $uid : $pid;
02667                 return $retVal;
02668         }
02669 
02681         function getTSCpid($table,$uid,$pid)    {
02682                         // If pid is negative (referring to another record) the pid of the other record is fetched and returned.
02683                 $cPid = t3lib_BEfunc::getTSconfig_pidValue($table,$uid,$pid);
02684                         // $TScID is the id of $table=pages, else it's the pid of the record.
02685                 $TScID = t3lib_BEfunc::getPidForModTSconfig($table,$uid,$cPid);
02686 
02687                 return array($TScID,$cPid);
02688         }
02689 
02697         function firstDomainRecord($rootLine)   {
02698                 if (t3lib_extMgm::isLoaded('cms'))      {
02699                         reset($rootLine);
02700                         while(list(,$row)=each($rootLine))      {
02701                                 $dRec = t3lib_BEfunc::getRecordsByField('sys_domain','pid',$row['uid'],' AND redirectTo="" AND hidden=0', '', 'sorting');
02702                                 if (is_array($dRec))    {
02703                                         reset($dRec);
02704                                         $dRecord = current($dRec);
02705                                         return ereg_replace('\/$','',$dRecord['domainName']);
02706                                 }
02707                         }
02708                 }
02709         }
02710 
02719         function getDomainStartPage($domain, $path='')  {
02720                 if (t3lib_extMgm::isLoaded('cms'))      {
02721                         $domain = explode(':',$domain);
02722                         $domain = strtolower(ereg_replace('\.$','',$domain[0]));
02723                                 // path is calculated.
02724                         $path = trim(ereg_replace('\/[^\/]*$','',$path));
02725                                 // stuff:
02726                         $domain.=$path;
02727 
02728                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_domain.*', 'pages,sys_domain', '
02729                                 pages.uid=sys_domain.pid
02730                                 AND NOT sys_domain.hidden
02731                                 AND (sys_domain.domainName="'.$GLOBALS['TYPO3_DB']->quoteStr($domain, 'sys_domain').'" or sys_domain.domainName="'.$GLOBALS['TYPO3_DB']->quoteStr($domain.'/', 'sys_domain').'")'.
02732                                 t3lib_BEfunc::deleteClause('pages'),
02733                                 '', '', '1');
02734                         return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
02735                 }
02736         }
02737 
02746         function selectVersionsOfRecord($table, $uid, $fields='*')      {
02747                 global $TCA;
02748 
02749                 if ($TCA[$table] && $TCA[$table]['ctrl']['versioning']) {
02750 
02751                                 // Select all versions of record:
02752                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
02753                                 $fields,
02754                                 $table,
02755                                 '(t3ver_oid='.intval($uid).' || uid='.intval($uid).')'.
02756                                         t3lib_BEfunc::deleteClause($table),
02757                                 '',
02758                                 't3ver_id DESC'
02759                         );
02760 
02761                                 // Add rows to output array:
02762                         $realPid = 0;
02763                         $outputRows = array();
02764                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
02765                                 if ($uid==$row['uid'])  {
02766                                         $row['_CURRENT_VERSION']=TRUE;
02767                                         $realPid = $row['pid'];
02768                                 }
02769                                 $outputRows[] = $row;
02770                         }
02771 
02772                                 // Set real-pid:
02773                         foreach($outputRows as $idx => $oRow)   {
02774                                 $outputRows[$idx]['_REAL_PID'] = $realPid;
02775                         }
02776 
02777                         return $outputRows;
02778                 }
02779         }
02780 
02792         function RTEsetup($RTEprop,$table,$field,$type='')      {
02793                 $thisConfig = is_array($RTEprop['default.']) ? $RTEprop['default.'] : array();
02794                 $thisFieldConf = $RTEprop['config.'][$table.'.'][$field.'.'];
02795                 if (is_array($thisFieldConf))   {
02796                         unset($thisFieldConf['types.']);
02797                         $thisConfig = t3lib_div::array_merge_recursive_overrule($thisConfig,$thisFieldConf);
02798                 }
02799                 if ($type && is_array($RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.']))        {
02800                         $thisConfig = t3lib_div::array_merge_recursive_overrule($thisConfig,$RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.']);
02801                 }
02802                 return $thisConfig;
02803         }
02804 
02810         function &RTEgetObj()   {
02811 
02812                         // If no RTE object has been set previously, try to create it:
02813                 if (!isset($GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj']))    {
02814 
02815                                 // Set the object string to blank by default:
02816                         $GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'] = array();
02817 
02818                                 // Traverse registered RTEs:
02819                         if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg']))     {
02820                                 foreach($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg'] as $extKey => $rteObjCfg)  {
02821                                         $rteObj = &t3lib_div::getUserObj($rteObjCfg['objRef']);
02822                                         if (is_object($rteObj)) {
02823                                                 if ($rteObj->isAvailable())     {
02824                                                         $GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'] = &$rteObj;
02825                                                         break;
02826                                                 } else {
02827                                                         $GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'], $rteObj->errorLog);
02828                                                 }
02829                                         }
02830                                 }
02831                         }
02832 
02833                         if (!count($GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj']))    {
02834                                 $GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'][] = 'No RTEs configured at all';
02835                         }
02836                 }
02837 
02838                         // Return RTE object (if any!)
02839                 return $GLOBALS['TYPO3_CONF_VARS']['T3_VAR']['RTEobj'];
02840         }
02841 
02849         function isModuleSetInTBE_MODULES($modName)     {
02850                 reset($GLOBALS['TBE_MODULES']);
02851                 $loaded=array();
02852                 while(list($mkey,$list)=each($GLOBALS['TBE_MODULES']))  {
02853                         $loaded[$mkey]=1;
02854                         if (trim($list))        {
02855                                 $subList = t3lib_div::trimExplode(',',$list,1);
02856                                 while(list(,$skey)=each($subList))      {
02857                                         $loaded[$mkey.'_'.$skey]=1;
02858                                 }
02859                         }
02860                 }
02861                 return $modName && isset($loaded[$modName]);
02862         }
02863 
02864 
02865 
02866 
02867 
02868 
02869 
02870 
02871 
02872 
02873 
02874 
02875 
02876 
02877 
02878 
02879 
02880 
02881         /*******************************************
02882          *
02883          * Miscellaneous
02884          *
02885          *******************************************/
02886 
02887 
02898         function typo3PrintError($header,$text,$js='',$head=1)  {
02899                         // This prints out a TYPO3 error message.
02900                         // If $js is set the message will be output in JavaScript
02901                 if ($js)        {
02902                         echo "alert('".t3lib_div::slashJS($header.'\n'.$text)."');";
02903                 } else {
02904                         echo $head?'<html>
02905                                 <head>
02906                                         <title>Error!</title>
02907                                 </head>
02908                                 <body bgcolor="white" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">':'';
02909                         echo '<div align="center">
02910                                         <table border="0" cellspacing="0" cellpadding="0" width="333">
02911                                                 <tr>
02912                                                         <td align="center">'.
02913                                                                 ($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" />').
02914                                                         '</td>
02915                                                 </tr>
02916                                                 <tr>
02917                                                         <td bgcolor="black">
02918                                                                 <table width="100%" border="0" cellspacing="1" cellpadding="10">
02919                                                                         <tr>
02920                                                                                 <td bgcolor="#F4F0E8">
02921                                                                                         <font face="verdana,arial,helvetica" size="2">';
02922                         echo '<b><center><font size="+1">'.$header.'</font></center></b><br />'.$text;
02923                         echo '                                                  </font>
02924                                                                                 </td>
02925                                                                         </tr>
02926                                                                 </table>
02927                                                         </td>
02928                                                 </tr>
02929                                         </table>
02930                                 </div>';
02931                         echo $head?'
02932                                 </body>
02933                         </html>':'';
02934                 }
02935         }
02936 
02942         function TYPO3_copyRightNotice()        {
02943                 global $TYPO3_CONF_VARS;
02944 
02945                         // COPYRIGHT NOTICE:
02946                 $loginCopyrightWarrantyProvider = strip_tags(trim($TYPO3_CONF_VARS['SYS']['loginCopyrightWarrantyProvider']));
02947                 $loginCopyrightWarrantyURL = strip_tags(trim($TYPO3_CONF_VARS['SYS']['loginCopyrightWarrantyURL']));
02948 
02949                 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10)       {
02950                         $warrantyNote='Warranty is supplied by '.htmlspecialchars($loginCopyrightWarrantyProvider).'; <a href="'.htmlspecialchars($loginCopyrightWarrantyURL).'" target="_blank">click for details.</a>';
02951                 } else {
02952                         $warrantyNote='TYPO3 comes with ABSOLUTELY NO WARRANTY; <a href="http://typo3.com/1316.0.html" target="_blank">click for details.</a>';
02953                 }
02954                 $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-2004 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.
02955                 '.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.';
02956 
02957                 return $cNotice;
02958         }
02959 
02967         function getPathType_web_nonweb($path)  {
02968                 return t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')) ? 'web' : '';
02969         }
02970 
02979         function ADMCMD_previewCmds($pageinfo)  {
02980                 if ($pageinfo['fe_group']>0)    {
02981                         $simUser = '&ADMCMD_simUser='.$pageinfo['fe_group'];
02982                 }
02983                 if ($pageinfo['starttime']>time())      {
02984                         $simTime = '&ADMCMD_simTime='.$pageinfo['starttime'];
02985                 }
02986                 if ($pageinfo['endtime']<time() && $pageinfo['endtime']!=0)     {
02987                         $simTime = '&ADMCMD_simTime='.($pageinfo['endtime']-1);
02988                 }
02989                 return $simUser.$simTime;
02990         }
02991 
03001         function processParams($params) {
03002                 $paramArr=array();
03003                 $lines=explode(chr(10),$params);
03004                 while(list(,$val)=each($lines)) {
03005                         $val = trim($val);
03006                         if ($val)       {
03007                                 $pair = explode('=',$val,2);
03008                                 $paramArr[trim($pair[0])] = trim($pair[1]);
03009                         }
03010                 }
03011                 return $paramArr;
03012         }
03013 
03027         function getListOfBackendModules($name,$perms_clause,$backPath='',$script='index.php')  {
03028                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'doktype!=255 AND module IN ("'.implode('","',$name).'") AND'.$perms_clause.t3lib_BEfunc::deleteClause('pages'));
03029                 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  return false;
03030 
03031                 $out='';
03032                 $theRows=array();
03033                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
03034                         $theRows[]=$row;
03035                         $out.='<span class="nobr"><a href="'.htmlspecialchars($script.'?id='.$row['uid']).'">'.
03036                                         t3lib_iconWorks::getIconImage('pages',$row,$backPath,'title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath($row['uid'],$perms_clause,20)).'" align="top"').
03037                                         htmlspecialchars($row['title']).
03038                                         '</a></span><br />';
03039                 }
03040                 return array('rows'=>$theRows,'list'=>$out);
03041         }
03042 }
03043 ?>


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