00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00183 class t3lib_BEfunc {
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00204 function deleteClause($table,$tableAlias='') {
00205 global $TCA;
00206 if ($TCA[$table]['ctrl']['delete']) {
00207 return ' AND '.($tableAlias ? $tableAlias : $table).'.'.$TCA[$table]['ctrl']['delete'].'=0';
00208 } else {
00209 return '';
00210 }
00211 }
00212
00227 function getRecord($table,$uid,$fields='*',$where='') {
00228 if ($GLOBALS['TCA'][$table]) {
00229 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid='.intval($uid).t3lib_BEfunc::deleteClause($table).$where);
00230 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00231 return $row;
00232 }
00233 }
00234 }
00235
00245 function getRecordWSOL($table,$uid,$fields='*',$where='') {
00246 if ($fields !== '*') {
00247 $internalFields = t3lib_div::uniqueList($fields.',uid,pid'.($table == 'pages' ? ',t3ver_swapmode' : ''));
00248 $row = t3lib_BEfunc::getRecord($table,$uid,$internalFields,$where);
00249 t3lib_BEfunc::workspaceOL($table,$row);
00250
00251 if (is_array ($row)) {
00252 foreach (array_keys($row) as $key) {
00253 if (!t3lib_div::inList($fields, $key) && $key{0} !== '_') {
00254 unset ($row[$key]);
00255 }
00256 }
00257 }
00258 } else {
00259 $row = t3lib_BEfunc::getRecord($table,$uid,$fields,$where);
00260 t3lib_BEfunc::workspaceOL($table,$row);
00261 }
00262 return $row;
00263 }
00264
00278 function getRecordRaw($table,$where='',$fields='*') {
00279 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where);
00280 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00281 return $row;
00282 }
00283 }
00284
00300 function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='') {
00301 global $TCA;
00302 if (is_array($TCA[$theTable])) {
00303 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00304 '*',
00305 $theTable,
00306 $theField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($theValue, $theTable).
00307 t3lib_BEfunc::deleteClause($theTable).' '.
00308 t3lib_BEfunc::versioningPlaceholderClause($theTable).' '.
00309 $whereClause,
00310 $groupBy,
00311 $orderBy,
00312 $limit
00313 );
00314 $rows = array();
00315 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00316 $rows[] = $row;
00317 }
00318 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00319 if (count($rows)) return $rows;
00320 }
00321 }
00322
00333 function searchQuery($searchWords,$fields,$table='') {
00334 return $GLOBALS['TYPO3_DB']->searchQuery($searchWords,$fields,$table);
00335 }
00336
00348 function listQuery($field,$value) {
00349 return $GLOBALS['TYPO3_DB']->listQuery($field,$value,'');
00350 }
00351
00360 function splitTable_Uid($str) {
00361 list($uid,$table) = explode('_',strrev($str),2);
00362 return array(strrev($table),strrev($uid));
00363 }
00364
00375 function getSQLselectableList($in_list,$tablename,$default_tablename) {
00376 $list = Array();
00377 if ((string)trim($in_list)!='') {
00378 $tempItemArray = explode(',',trim($in_list));
00379 while(list($key,$val)=each($tempItemArray)) {
00380 $val = strrev($val);
00381 $parts = explode('_',$val,2);
00382 if ((string)trim($parts[0])!='') {
00383 $theID = intval(strrev($parts[0]));
00384 $theTable = trim($parts[1]) ? strrev(trim($parts[1])) : $default_tablename;
00385 if ($theTable==$tablename) {$list[]=$theID;}
00386 }
00387 }
00388 }
00389 return implode(',',$list);
00390 }
00391
00403 function BEenableFields($table,$inv=0) {
00404 $ctrl = $GLOBALS['TCA'][$table]['ctrl'];
00405 $query=array();
00406 $invQuery=array();
00407 if (is_array($ctrl)) {
00408 if (is_array($ctrl['enablecolumns'])) {
00409 if ($ctrl['enablecolumns']['disabled']) {
00410 $field = $table.'.'.$ctrl['enablecolumns']['disabled'];
00411 $query[]=$field.'=0';
00412 $invQuery[]=$field.'!=0';
00413 }
00414 if ($ctrl['enablecolumns']['starttime']) {
00415 $field = $table.'.'.$ctrl['enablecolumns']['starttime'];
00416 $query[]='('.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00417 $invQuery[]='('.$field.'!=0 AND '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00418 }
00419 if ($ctrl['enablecolumns']['endtime']) {
00420 $field = $table.'.'.$ctrl['enablecolumns']['endtime'];
00421 $query[]='('.$field.'=0 OR '.$field.'>'.$GLOBALS['SIM_EXEC_TIME'].')';
00422 $invQuery[]='('.$field.'!=0 AND '.$field.'<='.$GLOBALS['SIM_EXEC_TIME'].')';
00423 }
00424 }
00425 }
00426 $outQ = ' AND '.($inv ? '('.implode(' OR ',$invQuery).')' : implode(' AND ',$query));
00427
00428 return $outQ;
00429 }
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00467 function mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='') {
00468 $query = $GLOBALS['TYPO3_DB']->SELECTquery(
00469 $select,
00470 $local_table.','.$mm_table.($foreign_table?','.$foreign_table:''),
00471 $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').' '.
00472 $whereClause,
00473 $groupBy,
00474 $orderBy,
00475 $limit
00476 );
00477 return $query;
00478 }
00479
00489 function DBcompileInsert($table,$fields_values) {
00490 return $GLOBALS['TYPO3_DB']->INSERTquery($table, $fields_values);
00491 }
00492
00503 function DBcompileUpdate($table,$where,$fields_values) {
00504 return $GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fields_values);
00505 }
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00533 function BEgetRootLine($uid,$clause='',$workspaceOL=FALSE) {
00534 $loopCheck = 100;
00535 $theRowArray = Array();
00536 $output = Array();
00537 while ($uid!=0 && $loopCheck>0) {
00538 $loopCheck--;
00539 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00540 'pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,t3ver_stage',
00541 'pages',
00542 'uid='.intval($uid).' '.
00543 t3lib_BEfunc::deleteClause('pages').' '.
00544 $clause
00545 );
00546 if ($GLOBALS['TYPO3_DB']->sql_error()) {
00547 debug($GLOBALS['TYPO3_DB']->sql_error(),1);
00548 }
00549 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00550 if($workspaceOL) t3lib_BEfunc::workspaceOL('pages',$row);
00551 t3lib_BEfunc::fixVersioningPid('pages',$row);
00552 $uid = $row['pid'];
00553 $theRowArray[] = $row;
00554 } else {
00555 break;
00556 }
00557 }
00558 if ($uid==0) {$theRowArray[] = Array('uid'=>0,'title'=>'');}
00559 if (is_array($theRowArray)) {
00560 reset($theRowArray);
00561 $c=count($theRowArray);
00562 while(list($key,$val)=each($theRowArray)) {
00563 $c--;
00564 $output[$c]['uid'] = $val['uid'];
00565 $output[$c]['pid'] = $val['pid'];
00566 if (isset($val['_ORIG_pid'])) $output[$c]['_ORIG_pid'] = $val['_ORIG_pid'];
00567 $output[$c]['title'] = $val['title'];
00568 $output[$c]['TSconfig'] = $val['TSconfig'];
00569 $output[$c]['is_siteroot'] = $val['is_siteroot'];
00570 $output[$c]['storage_pid'] = $val['storage_pid'];
00571 $output[$c]['t3ver_oid'] = $val['t3ver_oid'];
00572 $output[$c]['t3ver_wsid'] = $val['t3ver_wsid'];
00573 $output[$c]['t3ver_state'] = $val['t3ver_state'];
00574 $output[$c]['t3ver_swapmode'] = $val['t3ver_swapmode'];
00575 $output[$c]['t3ver_stage'] = $val['t3ver_stage'];
00576 }
00577 }
00578
00579 return $output;
00580 }
00581
00589 function openPageTree($pid,$clearExpansion) {
00590 global $BE_USER;
00591
00592
00593 if ($clearExpansion) {
00594 $expandedPages = array();
00595 } else {
00596 $expandedPages = unserialize($BE_USER->uc['browseTrees']['browsePages']);
00597 }
00598
00599
00600 $rL = t3lib_BEfunc::BEgetRootLine($pid);
00601
00602
00603 $mountIndex = 0;
00604 $mountKeys = array_flip($BE_USER->returnWebmounts());
00605 foreach($rL as $rLDat) {
00606 if (isset($mountKeys[$rLDat['uid']])) {
00607 $mountIndex = $mountKeys[$rLDat['uid']];
00608 break;
00609 }
00610 }
00611
00612
00613 foreach($rL as $rLDat) {
00614 $expandedPages[$mountIndex][$rLDat['uid']] = 1;
00615 }
00616
00617
00618 $BE_USER->uc['browseTrees']['browsePages'] = serialize($expandedPages);
00619 $BE_USER->writeUC();
00620 }
00621
00634 function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0) {
00635 if (!$titleLimit) { $titleLimit=1000; }
00636
00637 $loopCheck = 100;
00638 $output = $fullOutput = '/';
00639 while ($uid!=0 && $loopCheck>0) {
00640 $loopCheck--;
00641 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00642 'uid,pid,title,t3ver_oid,t3ver_wsid,t3ver_swapmode',
00643 'pages',
00644 'uid='.intval($uid).
00645 t3lib_BEfunc::deleteClause('pages').
00646 (strlen(trim($clause)) ? ' AND '.$clause : '')
00647 );
00648 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00649 t3lib_BEfunc::workspaceOL('pages',$row);
00650 t3lib_BEfunc::fixVersioningPid('pages',$row);
00651
00652 if ($row['_ORIG_pid'] && $row['t3ver_swapmode']>0) {
00653 $output = ' [#VEP#]'.$output;
00654 }
00655 $uid = $row['pid'];
00656 $output = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$titleLimit).$output;
00657 if ($fullTitleLimit) $fullOutput = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$fullTitleLimit).$fullOutput;
00658 } else {
00659 break;
00660 }
00661 }
00662
00663 if ($fullTitleLimit) {
00664 return array($output, $fullOutput);
00665 } else {
00666 return $output;
00667 }
00668 }
00669
00677 function getExcludeFields() {
00678 global $TCA;
00679
00680 $theExcludeArray = Array();
00681 $tc_keys = array_keys($TCA);
00682 foreach($tc_keys as $table) {
00683
00684 t3lib_div::loadTCA($table);
00685
00686 if (is_array($TCA[$table]['columns'])) {
00687 $f_keys = array_keys($TCA[$table]['columns']);
00688 foreach($f_keys as $field) {
00689 if ($TCA[$table]['columns'][$field]['exclude']) {
00690
00691 $Fname=$GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
00692
00693 $theExcludeArray[] = Array($Fname , $table.':'.$field);
00694 }
00695 }
00696 }
00697 }
00698 return $theExcludeArray;
00699 }
00700
00707 function getExplicitAuthFieldValues() {
00708 global $TCA;
00709
00710
00711 $adLabel = array(
00712 'ALLOW' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.allow'),
00713 'DENY' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.deny'),
00714 );
00715
00716
00717 $allowDenyOptions = Array();
00718 $tc_keys = array_keys($TCA);
00719 foreach($tc_keys as $table) {
00720
00721
00722 t3lib_div::loadTCA($table);
00723
00724
00725 if (is_array($TCA[$table]['columns'])) {
00726 $f_keys = array_keys($TCA[$table]['columns']);
00727 foreach($f_keys as $field) {
00728 $fCfg = $TCA[$table]['columns'][$field]['config'];
00729 if ($fCfg['type']=='select' && $fCfg['authMode']) {
00730
00731
00732 if (is_array($fCfg['items'])) {
00733
00734 $allowDenyOptions[$table.':'.$field]['tableFieldLabel'] = $GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']).': '.$GLOBALS['LANG']->sl($TCA[$table]['columns'][$field]['label']);
00735
00736
00737 foreach($fCfg['items'] as $iVal) {
00738 if (strcmp($iVal[1],'')) {
00739
00740
00741 $iMode = '';
00742 switch((string)$fCfg['authMode']) {
00743 case 'explicitAllow':
00744 $iMode = 'ALLOW';
00745 break;
00746 case 'explicitDeny':
00747 $iMode = 'DENY';
00748 break;
00749 case 'individual':
00750 if (!strcmp($iVal[4],'EXPL_ALLOW')) {
00751 $iMode = 'ALLOW';
00752 } elseif (!strcmp($iVal[4],'EXPL_DENY')) {
00753 $iMode = 'DENY';
00754 }
00755 break;
00756 }
00757
00758
00759 if ($iMode) {
00760 $allowDenyOptions[$table.':'.$field]['items'][$iVal[1]] = array($iMode, $GLOBALS['LANG']->sl($iVal[0]), $adLabel[$iMode]);
00761 }
00762 }
00763 }
00764 }
00765 }
00766 }
00767 }
00768 }
00769
00770 return $allowDenyOptions;
00771 }
00772
00778 function getSystemLanguages() {
00779
00780
00781 $sysLanguages = array();
00782 $sysLanguages[] = array('Default language', 0);
00783
00784
00785 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,flag','sys_language','pid=0'.t3lib_BEfunc::deleteClause('sys_language'));
00786 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00787 $sysLanguages[] = array($row['title'].' ['.$row['uid'].']', $row['uid'], ($row['flag'] ? 'flags/'.$row['flag'] : ''));
00788 }
00789
00790 return $sysLanguages;
00791 }
00792
00803 function readPageAccess($id,$perms_clause) {
00804 if ((string)$id!='') {
00805 $id = intval($id);
00806 if (!$id) {
00807 if ($GLOBALS['BE_USER']->isAdmin()) {
00808 $path = '/';
00809 $pageinfo['_thePath'] = $path;
00810 return $pageinfo;
00811 }
00812 } else {
00813 $pageinfo = t3lib_BEfunc::getRecord('pages',$id,'*',($perms_clause ? ' AND '.$perms_clause : ''));
00814 if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause)) {
00815 t3lib_BEfunc::workspaceOL('pages', $pageinfo);
00816 t3lib_BEfunc::fixVersioningPid('pages', $pageinfo);
00817 list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
00818 return $pageinfo;
00819 }
00820 }
00821 }
00822 return false;
00823 }
00824
00834 function getTCAtypes($table,$rec,$useFieldNameAsKey=0) {
00835 global $TCA;
00836
00837 t3lib_div::loadTCA($table);
00838 if ($TCA[$table]) {
00839
00840
00841 $fieldValue = t3lib_BEfunc::getTCAtypeValue($table,$rec);
00842
00843
00844 $typesConf = $TCA[$table]['types'][$fieldValue];
00845
00846
00847 $fieldList = explode(',', $typesConf['showitem']);
00848 $altFieldList = array();
00849
00850
00851 foreach($fieldList as $k => $v) {
00852 list($pFieldName, $pAltTitle, $pPalette, $pSpec) = t3lib_div::trimExplode(';', $v);
00853 $defaultExtras = is_array($TCA[$table]['columns'][$pFieldName]) ? $TCA[$table]['columns'][$pFieldName]['defaultExtras'] : '';
00854 $specConfParts = t3lib_BEfunc::getSpecConfParts($pSpec, $defaultExtras);
00855
00856 $fieldList[$k]=array(
00857 'field' => $pFieldName,
00858 'title' => $pAltTitle,
00859 'palette' => $pPalette,
00860 'spec' => $specConfParts,
00861 'origString' => $v
00862 );
00863 if ($useFieldNameAsKey) {
00864 $altFieldList[$fieldList[$k]['field']] = $fieldList[$k];
00865 }
00866 }
00867 if ($useFieldNameAsKey) {
00868 $fieldList = $altFieldList;
00869 }
00870
00871
00872 return $fieldList;
00873 }
00874 }
00875
00887 function getTCAtypeValue($table,$rec) {
00888 global $TCA;
00889
00890
00891 t3lib_div::loadTCA($table);
00892 if ($TCA[$table]) {
00893 $field = $TCA[$table]['ctrl']['type'];
00894 $fieldValue = $field ? ($rec[$field] ? $rec[$field] : 0) : 0;
00895 if (!is_array($TCA[$table]['types'][$fieldValue])) $fieldValue = 1;
00896 return $fieldValue;
00897 }
00898 }
00899
00910 function getSpecConfParts($str, $defaultExtras) {
00911
00912
00913 $specConfParts = t3lib_div::trimExplode(':', $defaultExtras.':'.$str, 1);
00914
00915 $reg = array();
00916 if (count($specConfParts)) {
00917 foreach($specConfParts as $k2 => $v2) {
00918 unset($specConfParts[$k2]);
00919 if (ereg('(.*)\[(.*)\]',$v2,$reg)) {
00920 $specConfParts[trim($reg[1])] = array(
00921 'parameters' => t3lib_div::trimExplode('|', $reg[2], 1)
00922 );
00923 } else {
00924 $specConfParts[trim($v2)] = 1;
00925 }
00926 }
00927 } else {
00928 $specConfParts = array();
00929 }
00930 return $specConfParts;
00931 }
00932
00941 function getSpecConfParametersFromArray($pArr) {
00942 $out=array();
00943 if (is_array($pArr)) {
00944 reset($pArr);
00945 while(list($k,$v)=each($pArr)) {
00946 $parts=explode('=',$v,2);
00947 if (count($parts)==2) {
00948 $out[trim($parts[0])]=trim($parts[1]);
00949 } else {
00950 $out[$k]=$v;
00951 }
00952 }
00953 }
00954 return $out;
00955 }
00956
00969 function getFlexFormDS($conf,$row,$table,$fieldName='',$WSOL=TRUE) {
00970 global $TYPO3_CONF_VARS;
00971
00972
00973 $ds_pointerField = $conf['ds_pointerField'];
00974 $ds_array = $conf['ds'];
00975 $ds_tableField = $conf['ds_tableField'];
00976 $ds_searchParentField = $conf['ds_pointerField_searchParent'];
00977
00978
00979 $dataStructArray='';
00980 if (is_array($ds_array)) {
00981
00982 if ($ds_pointerField) {
00983 $srcPointer = $row[$ds_pointerField];
00984 $srcPointer = isset($ds_array[$srcPointer]) ? $srcPointer : 'default';
00985 } else $srcPointer='default';
00986
00987
00988 if (substr($ds_array[$srcPointer],0,5)=='FILE:') {
00989 $file = t3lib_div::getFileAbsFileName(substr($ds_array[$srcPointer],5));
00990 if ($file && @is_file($file)) {
00991 $dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
00992 } else $dataStructArray = 'The file "'.substr($ds_array[$srcPointer],5).'" in ds-array key "'.$srcPointer.'" was not found ("'.$file.'")';
00993 } else {
00994 $dataStructArray = t3lib_div::xml2array($ds_array[$srcPointer]);
00995 }
00996
00997 } elseif ($ds_pointerField) {
00998
00999 $srcPointer = $row[$ds_pointerField];
01000
01001
01002 if ($ds_searchParentField && !$srcPointer) {
01003 $rr = t3lib_BEfunc::getRecord($table,$row['uid'],'uid,'.$ds_searchParentField);
01004 if ($WSOL) {
01005 t3lib_BEfunc::workspaceOL($table,$rr);
01006 t3lib_BEfunc::fixVersioningPid($table,$rr,TRUE);
01007 }
01008 $uidAcc=array();
01009 $subFieldPointer = $conf['ds_pointerField_searchParent_subField'];
01010 while(!$srcPointer) {
01011 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01012 'uid,'.$ds_pointerField.','.$ds_searchParentField.($subFieldPointer?','.$subFieldPointer:''),
01013 $table,
01014 'uid='.intval($rr[$ds_searchParentField]).t3lib_BEfunc::deleteClause($table)
01015 );
01016 $rr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
01017
01018
01019 if (!is_array($rr) || isset($uidAcc[$rr['uid']])) break;
01020 $uidAcc[$rr['uid']]=1;
01021
01022 if ($WSOL) {
01023 t3lib_BEfunc::workspaceOL($table,$rr);
01024 t3lib_BEfunc::fixVersioningPid($table,$rr,TRUE);
01025 }
01026 $srcPointer = ($subFieldPointer && $rr[$subFieldPointer]) ? $rr[$subFieldPointer] : $rr[$ds_pointerField];
01027 }
01028 }
01029
01030
01031 if ($srcPointer) {
01032 if (t3lib_div::testInt($srcPointer)) {
01033 list($tName,$fName) = explode(':',$ds_tableField,2);
01034 if ($tName && $fName && is_array($GLOBALS['TCA'][$tName])) {
01035 $dataStructRec = t3lib_BEfunc::getRecord($tName, $srcPointer);
01036 if ($WSOL) {
01037 t3lib_BEfunc::workspaceOL($tName,$dataStructRec);
01038 }
01039 $dataStructArray = t3lib_div::xml2array($dataStructRec[$fName]);
01040 } else $dataStructArray = 'No tablename ('.$tName.') or fieldname ('.$fName.') was found an valid!';
01041 } else {
01042 $file = t3lib_div::getFileAbsFileName($srcPointer);
01043 if ($file && @is_file($file)) {
01044 $dataStructArray = t3lib_div::xml2array(t3lib_div::getUrl($file));
01045 } else $dataStructArray='The file "'.$srcPointer.'" was not found ("'.$file.'")';
01046 }
01047 } else $dataStructArray='No source value in fieldname "'.$ds_pointerField.'"';
01048 } else $dataStructArray='No proper configuration!';
01049
01050
01051 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'])) {
01052 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'] as $classRef) {
01053 $hookObj = &t3lib_div::getUserObj($classRef);
01054 if (method_exists($hookObj, 'getFlexFormDS_postProcessDS')) {
01055 $hookObj->getFlexFormDS_postProcessDS($dataStructArray, $conf, $row, $table, $fieldName);
01056 }
01057 }
01058 }
01059
01060 return $dataStructArray;
01061 }
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01096 function storeHash($hash,$data,$ident) {
01097 $insertFields = array(
01098 'hash' => $hash,
01099 'content' => $data,
01100 'ident' => $ident,
01101 'tstamp' => time()
01102 );
01103 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
01104 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
01105 }
01106
01116 function getHash($hash,$expTime=0) {
01117
01118 $expTime = intval($expTime);
01119 if ($expTime) {
01120 $whereAdd = ' AND tstamp > '.(time()-$expTime);
01121 }
01122 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').$whereAdd);
01123 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01124 return $row['content'];
01125 }
01126 }
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01152 function getPagesTSconfig($id,$rootLine='',$returnPartArray=0) {
01153 $id=intval($id);
01154 if (!is_array($rootLine)) {
01155 $rootLine = t3lib_BEfunc::BEgetRootLine($id,'',TRUE);
01156 }
01157 ksort($rootLine);
01158 $TSdataArray = array();
01159 $TSdataArray['defaultPageTSconfig']=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
01160 foreach($rootLine as $k => $v) {
01161 $TSdataArray['uid_'.$v['uid']]=$v['TSconfig'];
01162 }
01163 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
01164 if ($returnPartArray) {
01165 return $TSdataArray;
01166 }
01167
01168
01169 $userTS = implode($TSdataArray,chr(10).'[GLOBAL]'.chr(10));
01170 $hash = md5('pageTS:'.$userTS);
01171 $cachedContent = t3lib_BEfunc::getHash($hash,0);
01172 $TSconfig = array();
01173 if (isset($cachedContent)) {
01174 $TSconfig = unserialize($cachedContent);
01175 } else {
01176 $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
01177 $parseObj->parse($userTS);
01178 $TSconfig = $parseObj->setup;
01179 t3lib_BEfunc::storeHash($hash,serialize($TSconfig),'PAGES_TSconfig');
01180 }
01181
01182
01183 $userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
01184 if (is_array($userTSconfig)) {
01185 $TSconfig = t3lib_div::array_merge_recursive_overrule($TSconfig, $userTSconfig);
01186 }
01187 return $TSconfig;
01188 }
01189
01208 function updatePagesTSconfig($id,$pageTS,$TSconfPrefix,$impParams='') {
01209 $id=intval($id);
01210 if (is_array($pageTS) && $id>0) {
01211 if (!is_array($impParams)) {
01212 $impParams =t3lib_BEfunc::implodeTSParams(t3lib_BEfunc::getPagesTSconfig($id));
01213 }
01214 reset($pageTS);
01215 $set=array();
01216 while(list($f,$v)=each($pageTS)) {
01217 $f = $TSconfPrefix.$f;
01218 if ((!isset($impParams[$f])&&trim($v)) || strcmp(trim($impParams[$f]),trim($v))) {
01219 $set[$f]=trim($v);
01220 }
01221 }
01222 if (count($set)) {
01223
01224 $pRec = t3lib_befunc::getRecord('pages',$id);
01225 $TSlines = explode(chr(10),$pRec['TSconfig']);
01226 $TSlines = array_reverse($TSlines);
01227
01228 reset($set);
01229 while(list($f,$v)=each($set)) {
01230 reset($TSlines);
01231 $inserted=0;
01232 while(list($ki,$kv)=each($TSlines)) {
01233 if (substr($kv,0,strlen($f)+1)==$f.'=') {
01234 $TSlines[$ki]=$f.'='.$v;
01235 $inserted=1;
01236 break;
01237 }
01238 }
01239 if (!$inserted) {
01240 $TSlines = array_reverse($TSlines);
01241 $TSlines[]=$f.'='.$v;
01242 $TSlines = array_reverse($TSlines);
01243 }
01244 }
01245 $TSlines = array_reverse($TSlines);
01246
01247
01248 $TSconf = implode(chr(10),$TSlines);
01249
01250 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid='.intval($id), array('TSconfig' => $TSconf));
01251 }
01252 }
01253 }
01254
01263 function implodeTSParams($p,$k='') {
01264 $implodeParams=array();
01265 if (is_array($p)) {
01266 reset($p);
01267 while(list($kb,$val)=each($p)) {
01268 if (is_array($val)) {
01269 $implodeParams = array_merge($implodeParams,t3lib_BEfunc::implodeTSParams($val,$k.$kb));
01270 } else {
01271 $implodeParams[$k.$kb]=$val;
01272 }
01273 }
01274 }
01275 return $implodeParams;
01276 }
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01300 function getUserNames($fields='username,usergroup,usergroup_cached_list,uid',$where='') {
01301 $be_user_Array=Array();
01302
01303 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_users', 'pid=0 '.$where.t3lib_BEfunc::deleteClause('be_users'), '', 'username');
01304 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01305 $be_user_Array[$row['uid']]=$row;
01306 }
01307 return $be_user_Array;
01308 }
01309
01318 function getGroupNames($fields='title,uid', $where='') {
01319 $be_group_Array = Array();
01320 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'be_groups', 'pid=0 '.$where.t3lib_BEfunc::deleteClause('be_groups'), '', 'title');
01321 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01322 $be_group_Array[$row['uid']] = $row;
01323 }
01324 return $be_group_Array;
01325 }
01326
01335 function getListGroupNames($fields='title,uid') {
01336 $exQ=' AND hide_in_lists=0';
01337 if (!$GLOBALS['BE_USER']->isAdmin()) {
01338 $exQ.=' AND uid IN ('.($GLOBALS['BE_USER']->user['usergroup_cached_list']?$GLOBALS['BE_USER']->user['usergroup_cached_list']:0).')';
01339 }
01340 return t3lib_BEfunc::getGroupNames($fields,$exQ);
01341 }
01342
01354 function blindUserNames($usernames,$groupArray,$excludeBlindedFlag=0) {
01355 if (is_array($usernames) && is_array($groupArray)) {
01356 while(list($uid,$row)=each($usernames)) {
01357 $userN=$uid;
01358 $set=0;
01359 if ($row['uid']!=$GLOBALS['BE_USER']->user['uid']) {
01360 reset($groupArray);
01361 while(list(,$v)=each($groupArray)) {
01362 if ($v && t3lib_div::inList($row['usergroup_cached_list'],$v)) {
01363 $userN = $row['username'];
01364 $set=1;
01365 }
01366 }
01367 } else {
01368 $userN = $row['username'];
01369 $set=1;
01370 }
01371 $usernames[$uid]['username']=$userN;
01372 if ($excludeBlindedFlag && !$set) {unset($usernames[$uid]);}
01373 }
01374 }
01375 return $usernames;
01376 }
01377
01387 function blindGroupNames($groups,$groupArray,$excludeBlindedFlag=0) {
01388 if (is_array($groups) && is_array($groupArray)) {
01389 while(list($uid,$row)=each($groups)) {
01390 $groupN=$uid;
01391 $set=0;
01392 if (t3lib_div::inArray($groupArray,$uid)) {
01393 $groupN=$row['title'];
01394 $set=1;
01395 }
01396 $groups[$uid]['title']=$groupN;
01397 if ($excludeBlindedFlag && !$set) {unset($groups[$uid]);}
01398 }
01399 }
01400 return $groups;
01401 }
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01428 function daysUntil($tstamp) {
01429 $delta_t = $tstamp-$GLOBALS['EXEC_TIME'];
01430 return ceil($delta_t/(3600*24));
01431 }
01432
01440 function date($tstamp) {
01441 return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp);
01442 }
01443
01451 function datetime($value) {
01452 return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $value);
01453 }
01454
01463 function time($value) {
01464 $hh = floor($value/3600);
01465 $min = floor(($value-$hh*3600)/60);
01466 $sec = $value-$hh*3600-$min*60;
01467 $l = sprintf('%02d',$hh).':'.sprintf('%02d',$min).':'.sprintf('%02d',$sec);
01468 return $l;
01469 }
01470
01479 function calcAge($seconds,$labels = 'min|hrs|days|yrs') {
01480 $labelArr = explode('|',$labels);
01481 $prefix='';
01482 if ($seconds<0) {$prefix='-'; $seconds=abs($seconds);}
01483 if ($seconds<3600) {
01484 $seconds = round ($seconds/60).' '.trim($labelArr[0]);
01485 } elseif ($seconds<24*3600) {
01486 $seconds = round ($seconds/3600).' '.trim($labelArr[1]);
01487 } elseif ($seconds<365*24*3600) {
01488 $seconds = round ($seconds/(24*3600)).' '.trim($labelArr[2]);
01489 } else {
01490 $seconds = round ($seconds/(365*24*3600)).' '.trim($labelArr[3]);
01491 }
01492 return $prefix.$seconds;
01493 }
01494
01505 function dateTimeAge($tstamp,$prefix=1,$date='') {
01506 return $tstamp ?
01507 ($date=='date' ? t3lib_BEfunc::date($tstamp) : t3lib_BEfunc::datetime($tstamp)).
01508 ' ('.t3lib_BEfunc::calcAge($prefix*(time()-$tstamp),$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')).')' : '';
01509 }
01510
01523 function titleAttrib($content='',$hsc=0) {
01524 global $CLIENT;
01525 $attrib= ($CLIENT['BROWSER']=='net'&&$CLIENT['VERSION']<5)||$CLIENT['BROWSER']=='konqu' ? 'alt' : 'title';
01526 return strcmp($content,'')?' '.$attrib.'="'.($hsc?htmlspecialchars($content):$content).'"' : $attrib;
01527 }
01528
01536 function titleAltAttrib($content) {
01537 $out='';
01538 $out.=' alt="'.htmlspecialchars($content).'"';
01539 $out.=' title="'.htmlspecialchars($content).'"';
01540 return $out;
01541 }
01542
01560 function thumbCode($row,$table,$field,$backPath,$thumbScript='',$uploaddir=NULL,$abs=0,$tparams='',$size='') {
01561 global $TCA;
01562
01563 t3lib_div::loadTCA($table);
01564
01565
01566 $uploaddir = (is_null($uploaddir)) ? $TCA[$table]['columns'][$field]['config']['uploadfolder'] : $uploaddir;
01567 $uploaddir = preg_replace('#/$#','',$uploaddir);
01568
01569
01570 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
01571 $thumbScript='gfx/notfound_thumb.gif';
01572 } elseif(!$thumbScript) {
01573 $thumbScript='thumbs.php';
01574 }
01575
01576 $sizeParts=array();
01577 if ($size = trim($size)) {
01578 $sizeParts = explode('x', $size.'x'.$size);
01579 if(!intval($sizeParts[0])) $size='';
01580 }
01581
01582
01583 $thumbs = explode(',', $row[$field]);
01584 $thumbData='';
01585 while(list(,$theFile)=each($thumbs)) {
01586 if (trim($theFile)) {
01587 $fI = t3lib_div::split_fileref($theFile);
01588 $ext = $fI['fileext'];
01589
01590 $max=0;
01591 if (t3lib_div::inList('gif,jpg,png',$ext)) {
01592 $imgInfo=@getimagesize(PATH_site.$uploaddir.'/'.$theFile);
01593 if (is_array($imgInfo)) {$max = max($imgInfo[0],$imgInfo[1]);}
01594 }
01595
01596 if ($max && $max<=(count($sizeParts)&&max($sizeParts)?max($sizeParts):56)) {
01597 $theFile = $url = ($abs?'':'../').($uploaddir?$uploaddir.'/':'').trim($theFile);
01598 $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
01599 $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.$backPath.$url.'" '.$imgInfo[3].' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';
01600
01601 } elseif ($ext=='ttf' || t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$ext)) {
01602 $theFile = ($abs?'':'../').($uploaddir?$uploaddir.'/':'').trim($theFile);
01603 $params = '&file='.rawurlencode($theFile);
01604 $params .= $size?'&size='.$size:'';
01605 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
01606 $onClick='top.launchView(\''.$theFile.'\',\'\',\''.$backPath.'\');return false;';
01607 $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.htmlspecialchars($backPath.$url).'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /></a> ';
01608 } else {
01609 $icon = t3lib_BEfunc::getFileIcon($ext);
01610 $url = 'gfx/fileicons/'.$icon;
01611 $thumbData.='<img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /> ';
01612 }
01613 }
01614 }
01615 return $thumbData;
01616 }
01617
01628 function getThumbNail($thumbScript,$theFile,$tparams='',$size='') {
01629 $params = '&file='.rawurlencode($theFile);
01630 $params .= trim($size)?'&size='.trim($size):'';
01631 $url = $thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
01632 $th='<img src="'.htmlspecialchars($url).'" title="'.trim(basename($theFile)).'"'.($tparams?" ".$tparams:"").' alt="" />';
01633 return $th;
01634 }
01635
01645 function titleAttribForPages($row,$perms_clause='',$includeAttrib=1) {
01646 global $TCA,$LANG;
01647 $parts=array();
01648 $parts[] = 'id='.$row['uid'];
01649 if ($row['alias']) $parts[]=$LANG->sL($TCA['pages']['columns']['alias']['label']).' '.$row['alias'];
01650 if ($row['pid']<0) $parts[] = 'v#1.'.$row['t3ver_id'];
01651 if ($row['t3ver_state']==1) $parts[] = 'PLH WSID#'.$row['t3ver_wsid'];
01652 if ($row['t3ver_state']==-1) $parts[] = 'New element!';
01653
01654 if ($row['doktype']=='3') {
01655 $parts[]=$LANG->sL($TCA['pages']['columns']['url']['label']).' '.$row['url'];
01656 } elseif ($row['doktype']=='4') {
01657 if ($perms_clause) {
01658 $label = t3lib_BEfunc::getRecordPath(intval($row['shortcut']),$perms_clause,20);
01659 } else {
01660 $lRec = t3lib_BEfunc::getRecordWSOL('pages',intval($row['shortcut']),'title');
01661 $label = $lRec['title'];
01662 }
01663 if ($row['shortcut_mode']>0) {
01664 $label.=', '.$LANG->sL($TCA['pages']['columns']['shortcut_mode']['label']).' '.
01665 $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('pages','shortcut_mode',$row['shortcut_mode']));
01666 }
01667 $parts[]=$LANG->sL($TCA['pages']['columns']['shortcut']['label']).' '.$label;
01668 } elseif ($row['doktype']=='7') {
01669 if ($perms_clause) {
01670 $label = t3lib_BEfunc::getRecordPath(intval($row['mount_pid']),$perms_clause,20);
01671 } else {
01672 $lRec = t3lib_BEfunc::getRecordWSOL('pages',intval($row['mount_pid']),'title');
01673 $label = $lRec['title'];
01674 }
01675 $parts[]=$LANG->sL($TCA['pages']['columns']['mount_pid']['label']).' '.$label;
01676 if ($row['mount_pid_ol']) {
01677 $parts[] = $LANG->sL($TCA['pages']['columns']['mount_pid_ol']['label']);
01678 }
01679 }
01680 if ($row['nav_hide']) $parts[] = ereg_replace(':$','',$LANG->sL($TCA['pages']['columns']['nav_hide']['label']));
01681 if ($row['hidden']) $parts[] = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.hidden');
01682 if ($row['starttime']) $parts[] = $LANG->sL($TCA['pages']['columns']['starttime']['label']).' '.t3lib_BEfunc::dateTimeAge($row['starttime'],-1,'date');
01683 if ($row['endtime']) $parts[] = $LANG->sL($TCA['pages']['columns']['endtime']['label']).' '.t3lib_BEfunc::dateTimeAge($row['endtime'],-1,'date');
01684 if ($row['fe_group']) {
01685 if ($row['fe_group']<0) {
01686 $label = $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('pages','fe_group',$row['fe_group']));
01687 } else {
01688 $lRec = t3lib_BEfunc::getRecordWSOL('fe_groups',$row['fe_group'],'title');
01689 $label = $lRec['title'];
01690 }
01691 $parts[] = $LANG->sL($TCA['pages']['columns']['fe_group']['label']).' '.$label;
01692 }
01693 $out = htmlspecialchars(implode(' - ',$parts));
01694 return $includeAttrib ? 'title="'.$out.'"' : $out;
01695 }
01696
01707 function getRecordIconAltText($row,$table='pages') {
01708 if ($table=='pages') {
01709 $out = t3lib_BEfunc::titleAttribForPages($row,'',0);
01710 } else {
01711 $ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
01712
01713 $out='id='.$row['uid'];
01714 if ($table=='pages' && $row['alias']) {
01715 $out.=' / '.$row['alias'];
01716 }
01717 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS'] && $row['pid']<0) {
01718 $out.=' - v#1.'.$row['t3ver_id'];
01719 }
01720 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
01721 if ($row['t3ver_state']==1) $out.= ' - PLH WSID#'.$row['t3ver_wsid'];
01722 if ($row['t3ver_state']==-1) $out.= ' - New element!';
01723 }
01724
01725 if ($ctrl['disabled']) {
01726 $out.=($row[$ctrl['disabled']]?' - '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.hidden'):'');
01727 }
01728 if ($ctrl['starttime']) {
01729 if ($row[$ctrl['starttime']] > $GLOBALS['EXEC_TIME']) {
01730 $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').')';
01731 }
01732 }
01733 if ($row[$ctrl['endtime']]) {
01734 $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').')';
01735 }
01736 }
01737 return htmlspecialchars($out);
01738 }
01739
01749 function getLabelFromItemlist($table,$col,$key) {
01750 global $TCA;
01751
01752 t3lib_div::loadTCA($table);
01753
01754
01755 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]) && is_array($TCA[$table]['columns'][$col]['config']['items'])) {
01756
01757 reset($TCA[$table]['columns'][$col]['config']['items']);
01758 while(list($k,$v)=each($TCA[$table]['columns'][$col]['config']['items'])) {
01759
01760 if (!strcmp($v[1],$key)) return $v[0];
01761 }
01762 }
01763 }
01764
01775 function getItemLabel($table,$col,$printAllWrap='') {
01776 global $TCA;
01777
01778 t3lib_div::loadTCA($table);
01779
01780 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col])) {
01781
01782 return $TCA[$table]['columns'][$col]['label'];
01783 }
01784 if ($printAllWrap) {
01785 $parts = explode('|',$printAllWrap);
01786 return $parts[0].$col.$parts[1];
01787 }
01788 }
01789
01800 function getRecordTitle($table,$row,$prep=0) {
01801 global $TCA;
01802 if (is_array($TCA[$table])) {
01803 $t = $row[$TCA[$table]['ctrl']['label']];
01804 if ($TCA[$table]['ctrl']['label_alt'] && ($TCA[$table]['ctrl']['label_alt_force'] || !strcmp($t,''))) {
01805 $altFields=t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
01806 $tA=array();
01807 $tA[]=$t;
01808 while(list(,$fN)=each($altFields)) {
01809 $t = $tA[] = trim(strip_tags($row[$fN]));
01810 if (strcmp($t,'') && !$TCA[$table]['ctrl']['label_alt_force']) break;
01811 }
01812 if ($TCA[$table]['ctrl']['label_alt_force']) $t=implode(', ',$tA);
01813 }
01814 if ($prep) {
01815 $t = htmlspecialchars(t3lib_div::fixed_lgd_cs($t,$GLOBALS['BE_USER']->uc['titleLen']));
01816 if (!strcmp(trim($t),'')) $t='<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</em>';
01817 }
01818 return $t;
01819 }
01820 }
01821
01838 function getProcessedValue($table,$col,$value,$fixed_lgd_chars=0,$defaultPassthrough=0,$noRecordLookup=FALSE,$uid=0) {
01839 global $TCA;
01840 global $TYPO3_CONF_VARS;
01841
01842 t3lib_div::loadTCA($table);
01843
01844 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col])) {
01845
01846 $theColConf = $TCA[$table]['columns'][$col]['config'];
01847
01848
01849
01850
01851 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['preProcessValue'])) {
01852 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['preProcessValue'] as $_funcRef) {
01853 t3lib_div::callUserFunction($_funcRef,$theColConf,$this);
01854 }
01855 }
01856
01857 $l='';
01858 switch((string)$theColConf['type']) {
01859 case 'radio':
01860 $l=t3lib_BEfunc::getLabelFromItemlist($table,$col,$value);
01861 $l=$GLOBALS['LANG']->sL($l);
01862 break;
01863 case 'select':
01864 if ($theColConf['MM']) {
01865
01866 $MMfield = $noRecordLookup?'uid':$TCA[$theColConf['foreign_table']]['ctrl']['label'];
01867 $MMres = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
01868 $theColConf['foreign_table'].'.'.$MMfield,
01869 ($table!=$theColConf['foreign_table']?$table:''),
01870 $theColConf['MM'],
01871 $theColConf['foreign_table'],
01872 'AND '.$theColConf['MM'].'.uid_local ='.intval($uid).t3lib_BEfunc::deleteClause($theColConf['foreign_table'])
01873 );
01874 if ($MMres) {
01875 while($MMrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($MMres)) {
01876 $mmlA[] = $MMrow[$MMfield];
01877 }
01878 if (is_array($mmlA)) {
01879 $l=implode(', ',$mmlA);
01880 } else {
01881 $l = '';
01882 }
01883 } else {
01884 $l = 'n/A';
01885 }
01886 } else {
01887 $l = t3lib_BEfunc::getLabelFromItemlist($table,$col,$value);
01888 $l = $GLOBALS['LANG']->sL($l);
01889 if ($theColConf['foreign_table'] && !$l && $TCA[$theColConf['foreign_table']]) {
01890 if ($noRecordLookup) {
01891 $l = $value;
01892 } else {
01893 $rParts = t3lib_div::trimExplode(',',$value,1);
01894 reset($rParts);
01895 $lA = array();
01896 while(list(,$rVal)=each($rParts)) {
01897 $rVal = intval($rVal);
01898 if ($rVal>0) {
01899 $r=t3lib_BEfunc::getRecordWSOL($theColConf['foreign_table'],$rVal);
01900 } else {
01901 $r=t3lib_BEfunc::getRecordWSOL($theColConf['neg_foreign_table'],-$rVal);
01902 }
01903 if (is_array($r)) {
01904 $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);
01905 } else {
01906 $lA[]=$rVal?'['.$rVal.'!]':'';
01907 }
01908 }
01909 $l = implode(', ',$lA);
01910 }
01911 }
01912 }
01913 break;
01914 case 'group':
01915 $l = implode(', ',t3lib_div::trimExplode(',',$value,1));
01916 break;
01917 case 'check':
01918 if (!is_array($theColConf['items']) || count($theColConf['items'])==1) {
01919 $l = $value ? 'Yes' : '';
01920 } else {
01921 reset($theColConf['items']);
01922 $lA=Array();
01923 while(list($key,$val)=each($theColConf['items'])) {
01924 if ($value & pow(2,$key)) {$lA[]=$GLOBALS['LANG']->sL($val[0]);}
01925 }
01926 $l = implode(', ',$lA);
01927 }
01928 break;
01929 case 'input':
01930 if ($value) {
01931 if (t3lib_div::inList($theColConf['eval'],'date')) {
01932 $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')).')';
01933 } elseif (t3lib_div::inList($theColConf['eval'],'time')) {
01934 $l = t3lib_BEfunc::time($value);
01935 } elseif (t3lib_div::inList($theColConf['eval'],'datetime')) {
01936 $l = t3lib_BEfunc::datetime($value);
01937 } else {
01938 $l = $value;
01939 }
01940 }
01941 break;
01942 case 'flex':
01943 $l = strip_tags($value);
01944 break;
01945 default:
01946 if ($defaultPassthrough) {
01947 $l=$value;
01948 } elseif ($theColConf['MM']) {
01949 $l='N/A';
01950 } elseif ($value) {
01951 $l=t3lib_div::fixed_lgd_cs(strip_tags($value),200);
01952 }
01953 break;
01954 }
01955
01956
01957
01958
01959 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['postProcessValue'])) {
01960 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['postProcessValue'] as $_funcRef) {
01961 $params = array(
01962 'value' => $l,
01963 'colConf' => $theColConf
01964 );
01965 $l = t3lib_div::callUserFunction($_funcRef,$params,$this);
01966 }
01967 }
01968
01969 if ($fixed_lgd_chars) {
01970 return t3lib_div::fixed_lgd_cs($l,$fixed_lgd_chars);
01971 } else {
01972 return $l;
01973 }
01974 }
01975 }
01976
01989 function getProcessedValueExtra($table,$fN,$fV,$fixed_lgd_chars=0,$uid=0) {
01990 global $TCA;
01991 $fVnew = t3lib_BEfunc::getProcessedValue($table,$fN,$fV,$fixed_lgd_chars,0,0,$uid);
01992 if (!isset($fVnew)) {
01993 if (is_array($TCA[$table])) {
01994 if ($fN==$TCA[$table]['ctrl']['tstamp'] || $fN==$TCA[$table]['ctrl']['crdate']) {
01995 $fVnew = t3lib_BEfunc::datetime($fV);
01996 } elseif ($fN=='pid'){
01997 $fVnew = t3lib_BEfunc::getRecordPath($fV,'1=1',20);
01998 } else {
01999 $fVnew = $fV;
02000 }
02001 }
02002 }
02003 return $fVnew;
02004 }
02005
02013 function getFileIcon($ext) {
02014 return $GLOBALS['FILEICONS'][$ext] ? $GLOBALS['FILEICONS'][$ext] : $GLOBALS['FILEICONS']['default'];
02015 }
02016
02027 function getCommonSelectFields($table,$prefix='') {
02028 global $TCA;
02029 $fields = array();
02030 $fields[] = $prefix.'uid';
02031 $fields[] = $prefix.$TCA[$table]['ctrl']['label'];
02032
02033 if ($TCA[$table]['ctrl']['label_alt']) {
02034 $secondFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1);
02035 foreach($secondFields as $fieldN) {
02036 $fields[] = $prefix.$fieldN;
02037 }
02038 }
02039 if ($TCA[$table]['ctrl']['versioningWS']) {
02040 $fields[] = $prefix.'t3ver_id';
02041 $fields[] = $prefix.'t3ver_state';
02042 $fields[] = $prefix.'t3ver_wsid';
02043 $fields[] = $prefix.'t3ver_count';
02044 }
02045
02046 if ($TCA[$table]['ctrl']['selicon_field']) $fields[] = $prefix.$TCA[$table]['ctrl']['selicon_field'];
02047 if ($TCA[$table]['ctrl']['typeicon_column']) $fields[] = $prefix.$TCA[$table]['ctrl']['typeicon_column'];
02048
02049 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
02050 if ($TCA[$table]['ctrl']['enablecolumns']['disabled']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['disabled'];
02051 if ($TCA[$table]['ctrl']['enablecolumns']['starttime']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['starttime'];
02052 if ($TCA[$table]['ctrl']['enablecolumns']['endtime']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['endtime'];
02053 if ($TCA[$table]['ctrl']['enablecolumns']['fe_group']) $fields[] = $prefix.$TCA[$table]['ctrl']['enablecolumns']['fe_group'];
02054 }
02055
02056 return implode(',', array_unique($fields));
02057 }
02058
02070 function makeConfigForm($configArray,$defaults,$dataPrefix) {
02071 $params = $defaults;
02072 if (is_array($configArray)) {
02073 reset($configArray);
02074 $lines=array();
02075 while(list($fname,$config)=each($configArray)) {
02076 if (is_array($config)) {
02077 $lines[$fname]='<strong>'.htmlspecialchars($config[1]).'</strong><br />';
02078 $lines[$fname].=$config[2].'<br />';
02079 switch($config[0]) {
02080 case 'string':
02081 case 'short':
02082 $formEl = '<input type="text" name="'.$dataPrefix.'['.$fname.']" value="'.$params[$fname].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth($config[0]=='short'?24:48).' />';
02083 break;
02084 case 'check':
02085 $formEl = '<input type="hidden" name="'.$dataPrefix.'['.$fname.']" value="0" /><input type="checkbox" name="'.$dataPrefix.'['.$fname.']" value="1"'.($params[$fname]?' checked="checked"':'').' />';
02086 break;
02087 case 'comment':
02088 $formEl = '';
02089 break;
02090 case 'select':
02091 reset($config[3]);
02092 $opt=array();
02093 while(list($k,$v)=each($config[3])) {
02094 $opt[]='<option value="'.htmlspecialchars($k).'"'.($params[$fname]==$k?' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
02095 }
02096 $formEl = '<select name="'.$dataPrefix.'['.$fname.']">'.implode('',$opt).'</select>';
02097 break;
02098 default:
02099 debug($config);
02100 break;
02101 }
02102 $lines[$fname].=$formEl;
02103 $lines[$fname].='<br /><br />';
02104 } else {
02105 $lines[$fname]='<hr />';
02106 if ($config) $lines[$fname].='<strong>'.strtoupper(htmlspecialchars($config)).'</strong><br />';
02107 if ($config) $lines[$fname].='<br />';
02108 }
02109 }
02110 }
02111 $out = implode('',$lines);
02112 $out.='<input type="submit" name="submit" value="Update configuration" />';
02113 return $out;
02114 }
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02145 function helpTextIcon($table,$field,$BACK_PATH,$force=0) {
02146 global $TCA_DESCR,$BE_USER;
02147 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && ($BE_USER->uc['edit_showFieldHelp']=='icon' || $force)) {
02148 $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;';
02149 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
02150 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="typo3-csh-icon" alt="" />'.
02151 '</a>';
02152 }
02153 }
02154
02167 function helpText($table,$field,$BACK_PATH,$styleAttrib='') {
02168 global $TCA_DESCR,$BE_USER;
02169 if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && $BE_USER->uc['edit_showFieldHelp']=='text') {
02170 $fDat = $TCA_DESCR[$table]['columns'][$field];
02171
02172
02173 $editIcon = t3lib_BEfunc::helpTextIcon(
02174 $table,
02175 $field,
02176 $BACK_PATH,
02177 TRUE
02178 );
02179
02180 $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;';
02181 $text =
02182 ($fDat['alttitle'] ? '<h4><a href="#" onclick="'.htmlspecialchars($onClick).'">'.$fDat['alttitle'].'</a></h4>' : '').
02183 $fDat['description'];
02184
02185
02186 if ($fDat['image_descr'] || $fDat['seeAlso'] || $fDat['details'] || $fDat['syntax']) {
02187 $text.=' <a href="#" onclick="'.htmlspecialchars($onClick).'">'.
02188 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/rel_db.gif','width="13" height="12"').' class="absmiddle typo3-csh-more" alt="" />'.
02189 '</a>';
02190 }
02191
02192
02193 $params = $styleAttrib ? ' style="'.$styleAttrib.'"' : '';
02194
02195
02196 return '<table border="0" cellpadding="2" cellspacing="0" class="typo3-csh-inline"'.$params.'>
02197 <tr>
02198 <td valign="top" width="14">'.$editIcon.'</td>
02199 <td valign="top">'.$text.'</td>
02200 </tr>
02201 </table>';
02202 }
02203 }
02204
02219 function cshItem($table,$field,$BACK_PATH,$wrap='',$onlyIconMode=FALSE, $styleAttrib='') {
02220 global $TCA_DESCR, $LANG, $BE_USER;
02221 if ($BE_USER->uc['edit_showFieldHelp']) {
02222 $LANG->loadSingleTableDescription($table);
02223
02224 if (is_array($TCA_DESCR[$table])) {
02225
02226 $fullText = t3lib_BEfunc::helpText($table,$field,$BACK_PATH,$styleAttrib);
02227 $icon = t3lib_BEfunc::helpTextIcon($table,$field,$BACK_PATH,$onlyIconMode);
02228
02229 if ($fullText && !$onlyIconMode) {
02230 $output = $GLOBALS['LANG']->hscAndCharConv($fullText, false);
02231 } else {
02232 #$output = '<span style="position:absolute; filter: alpha(opacity=50); -moz-opacity: 0.50;">'.$icon.'</span>';
02233 $output = $icon;
02234
02235 if ($output && $wrap) {
02236 $wrParts = explode('|',$wrap);
02237 $output = $wrParts[0].$output.$wrParts[1];
02238 }
02239 }
02240
02241 return $output;
02242 }
02243 }
02244 }
02245
02257 function editOnClick($params,$backPath='',$requestUri='') {
02258 $retUrl = 'returnUrl='.($requestUri==-1?"'+T3_THIS_LOCATION+'":rawurlencode($requestUri?$requestUri:t3lib_div::getIndpEnv('REQUEST_URI')));
02259 return "window.location.href='".$backPath."alt_doc.php?".$retUrl.$params."'; return false;";
02260 }
02261
02276 function viewOnClick($id,$backPath='',$rootLine='',$anchor='',$altUrl='',$addGetVars='',$switchFocus=TRUE) {
02277 if ($altUrl) {
02278 $url = $altUrl;
02279 } else {
02280
02281 if ($GLOBALS['BE_USER']->workspace!=0) {
02282 $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir.'mod/user/ws/wsol_preview.php?id='.$id.$addGetVars.$anchor;
02283 } else {
02284 if ($rootLine) {
02285 $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
02286 if (t3lib_BEfunc::getDomainStartPage($parts['host'],$parts['path'])) {
02287 $preUrl_temp = t3lib_BEfunc::firstDomainRecord($rootLine);
02288 }
02289 }
02290 $preUrl = $preUrl_temp ? (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https:
02291 $url = $preUrl.'/index.php?id='.$id.$addGetVars.$anchor;
02292 }
02293 }
02294
02295 return "previewWin=window.open('".$url."','newTYPO3frontendWindow');".
02296 ($switchFocus ? 'previewWin.focus();' : '');
02297 }
02298
02308 function getModTSconfig($id,$TSref) {
02309 $pageTS_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref,t3lib_BEfunc::getPagesTSconfig($id));
02310 $BE_USER_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref);
02311 $modTSconfig = t3lib_div::array_merge_recursive_overrule($pageTS_modOptions,$BE_USER_modOptions);
02312 return $modTSconfig;
02313 }
02314
02329 function getFuncMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
02330 if (is_array($menuItems)) {
02331 if (!is_array($mainParams)) {
02332 $mainParams = array('id' => $mainParams);
02333 }
02334 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02335
02336 if (!$script) { $script=basename(PATH_thisScript); }
02337
02338 $options = array();
02339 foreach($menuItems as $value => $label) {
02340 $options[] = '<option value="'.htmlspecialchars($value).'"'.(!strcmp($currentValue,$value)?' selected="selected"':'').'>'.
02341 t3lib_div::deHSCentities(htmlspecialchars($label)).
02342 '</option>';
02343 }
02344 if (count($options)) {
02345 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+this.options[this.selectedIndex].value,this);';
02346 return '
02347
02348 <!-- Function Menu of module -->
02349 <select name="'.$elementName.'" onchange="'.htmlspecialchars($onChange).'">
02350 '.implode('
02351 ',$options).'
02352 </select>
02353 ';
02354 }
02355 }
02356 }
02357
02372 function getFuncCheck($mainParams,$elementName,$currentValue,$script='',$addparams='',$tagParams='') {
02373 if (!is_array($mainParams)) {
02374 $mainParams = array('id' => $mainParams);
02375 }
02376 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02377
02378 if (!$script) {basename(PATH_thisScript);}
02379 $onClick = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+(this.checked?1:0),this);';
02380 return '<input type="checkbox" name="'.$elementName.'"'.($currentValue?' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'"'.($tagParams?' '.$tagParams:'').' />';
02381 }
02382
02397 function getFuncInput($mainParams,$elementName,$currentValue,$size=10,$script="",$addparams="") {
02398 if (!is_array($mainParams)) {
02399 $mainParams = array('id' => $mainParams);
02400 }
02401 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
02402
02403 if (!$script) {basename(PATH_thisScript);}
02404 $onChange = 'jumpToUrl(\''.$script.'?'.$mainParams.$addparams.'&'.$elementName.'=\'+escape(this.value),this);';
02405 return '<input type="text"'.$GLOBALS['TBE_TEMPLATE']->formWidth($size).' name="'.$elementName.'" value="'.htmlspecialchars($currentValue).'" onchange="'.htmlspecialchars($onChange).'" />';
02406 }
02407
02418 function unsetMenuItems($modTSconfig,$itemArray,$TSref) {
02419
02420 $conf = $GLOBALS['BE_USER']->getTSConfig($TSref,$modTSconfig);
02421 if (is_array($conf['properties'])) {
02422 reset($conf['properties']);
02423 while(list($key,$val)=each($conf['properties'])) {
02424 if (!$val) {
02425 unset($itemArray[$key]);
02426 }
02427 }
02428 }
02429 return $itemArray;
02430 }
02431
02441 function getSetUpdateSignal($set='') {
02442 global $BE_USER;
02443 $key = 't3lib_BEfunc::getSetUpdateSignal';
02444 $out='';
02445 if ($set) {
02446 $modData=array();
02447 $modData['set']=$set;
02448 $BE_USER->pushModuleData($key,$modData);
02449 } else {
02450 $modData = $BE_USER->getModuleData($key,'ses');
02451 if (trim($modData['set'])) {
02452 $l=explode(',',$modData['set']);
02453 while(list(,$v)=each($l)) {
02454 switch($v) {
02455 case 'updatePageTree':
02456 case 'updateFolderTree':
02457 $out.='
02458 <script type="text/javascript">
02459
02460 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
02461 top.content.nav_frame.refresh_nav();
02462 }
02463
02464 </script>';
02465 break;
02466 }
02467 }
02468 $modData=array();
02469 $modData['set']='';
02470 $BE_USER->pushModuleData($key,$modData);
02471 }
02472 }
02473 return $out;
02474 }
02475
02476
02492 function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='') {
02493
02494 if ($modName && is_string($modName)) {
02495
02496 $settings = $GLOBALS['BE_USER']->getModuleData($modName,$type);
02497
02498 $changed=0;
02499 if (!is_array($settings)) {
02500 $changed=1;
02501 $settings=array();
02502 }
02503 if (is_array($MOD_MENU)) {
02504 foreach ($MOD_MENU as $key=>$var) {
02505
02506 if (is_array($CHANGED_SETTINGS) && isset($CHANGED_SETTINGS[$key]) && strcmp($settings[$key],$CHANGED_SETTINGS[$key])) {
02507 $settings[$key] = (string)$CHANGED_SETTINGS[$key];
02508 $changed=1;
02509 }
02510
02511 if (is_array($var) && (!$dontValidateList || !t3lib_div::inList($dontValidateList,$key))) {
02512
02513 if (is_array($settings[$key]) || !isset($MOD_MENU[$key][$settings[$key]])) {
02514 $settings[$key]=(string)key($var);
02515 $changed=1;
02516 }
02517 }
02518 if ($setDefaultList && !is_array($var)) {
02519 if (t3lib_div::inList($setDefaultList,$key) && !isset($settings[$key])) {
02520 $settings[$key]=$var;
02521 }
02522 }
02523 }
02524 } else {die ('No menu!');}
02525
02526 if ($changed) {
02527 $GLOBALS['BE_USER']->pushModuleData($modName,$settings);
02528 }
02529
02530 return $settings;
02531 } else {die ('Wrong module name: "'.$modName.'"');}
02532 }
02533
02534
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549
02550
02551
02565 function compilePreviewKeyword($getVarsStr, $beUserUid, $ttl=172800) {
02566 $field_array = array(
02567 'keyword' => md5(uniqid(microtime())),
02568 'tstamp' => time(),
02569 'endtime' => time()+$ttl,
02570 'config' => serialize(array(
02571 'getVars' => $getVarsStr,
02572 'BEUSER_uid' => $beUserUid
02573 ))
02574 );
02575
02576 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_preview', $field_array);
02577
02578 return $field_array['keyword'];
02579 }
02580
02593 function lockRecords($table='',$uid=0,$pid=0) {
02594 $user_id = intval($GLOBALS['BE_USER']->user['uid']);
02595 if ($table && $uid) {
02596 $fields_values = array(
02597 'userid' => $user_id,
02598 'tstamp' => $GLOBALS['EXEC_TIME'],
02599 'record_table' => $table,
02600 'record_uid' => $uid,
02601 'username' => $GLOBALS['BE_USER']->user['username'],
02602 'record_pid' => $pid
02603 );
02604
02605 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords', $fields_values);
02606 } else {
02607 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'userid='.intval($user_id));
02608 }
02609 }
02610
02622 function isRecordLocked($table,$uid) {
02623 global $LOCKED_RECORDS;
02624 if (!is_array($LOCKED_RECORDS)) {
02625 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
02626 '*',
02627 'sys_lockedrecords',
02628 'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user['uid']).'
02629 AND sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
02630 );
02631 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
02632 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]=$row;
02633 $LOCKED_RECORDS[$row['record_table'].':'.$row['record_uid']]['msg']=sprintf(
02634 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord'),
02635 $row['username'],
02636 t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
02637 );
02638 if ($row['record_pid'] && !isset($LOCKED_RECORDS[$row['record_table'].':'.$row['record_pid']])) {
02639 $LOCKED_RECORDS['pages:'.$row['record_pid']]['msg']=sprintf(
02640 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.lockedRecord_content'),
02641 $row['username'],
02642 t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME']-$row['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'))
02643 );
02644 }
02645 }
02646 }
02647 return $LOCKED_RECORDS[$table.':'.$uid];
02648 }
02649
02662 function exec_foreign_table_where_query($fieldValue,$field='',$TSconfig=array(),$prefix='') {
02663 global $TCA;
02664 $foreign_table = $fieldValue['config'][$prefix.'foreign_table'];
02665 $rootLevel = $TCA[$foreign_table]['ctrl']['rootLevel'];
02666
02667 $fTWHERE = $fieldValue['config'][$prefix.'foreign_table_where'];
02668 if (strstr($fTWHERE,'###REC_FIELD_')) {
02669 $fTWHERE_parts = explode('###REC_FIELD_',$fTWHERE);
02670 while(list($kk,$vv)=each($fTWHERE_parts)) {
02671 if ($kk) {
02672 $fTWHERE_subpart = explode('###',$vv,2);
02673 $fTWHERE_parts[$kk]=$TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]].$fTWHERE_subpart[1];
02674 }
02675 }
02676 $fTWHERE = implode('',$fTWHERE_parts);
02677 }
02678
02679 $fTWHERE = str_replace('###CURRENT_PID###',intval($TSconfig['_CURRENT_PID']),$fTWHERE);
02680 $fTWHERE = str_replace('###THIS_UID###',intval($TSconfig['_THIS_UID']),$fTWHERE);
02681 $fTWHERE = str_replace('###THIS_CID###',intval($TSconfig['_THIS_CID']),$fTWHERE);
02682 $fTWHERE = str_replace('###STORAGE_PID###',intval($TSconfig['_STORAGE_PID']),$fTWHERE);
02683 $fTWHERE = str_replace('###SITEROOT###',intval($TSconfig['_SITEROOT']),$fTWHERE);
02684 $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###',intval($TSconfig[$field]['PAGE_TSCONFIG_ID']),$fTWHERE);
02685 $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###',$GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']),$fTWHERE);
02686 $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###',$GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$field]['PAGE_TSCONFIG_STR'], $foreign_table),$fTWHERE);
02687
02688
02689 $wgolParts = $GLOBALS['TYPO3_DB']->splitGroupOrderLimit($fTWHERE);
02690 if ($rootLevel) {
02691 $queryParts = array(
02692 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02693 'FROM' => $foreign_table,
02694 'WHERE' => $foreign_table.'.pid=0 '.
02695 t3lib_BEfunc::deleteClause($foreign_table).' '.
02696 $wgolParts['WHERE'],
02697 'GROUPBY' => $wgolParts['GROUPBY'],
02698 'ORDERBY' => $wgolParts['ORDERBY'],
02699 'LIMIT' => $wgolParts['LIMIT']
02700 );
02701 } else {
02702 $pageClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
02703 if ($foreign_table!='pages') {
02704 $queryParts = array(
02705 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02706 'FROM' => $foreign_table.',pages',
02707 'WHERE' => 'pages.uid='.$foreign_table.'.pid
02708 AND pages.deleted=0 '.
02709 t3lib_BEfunc::deleteClause($foreign_table).
02710 ' AND '.$pageClause.' '.
02711 $wgolParts['WHERE'],
02712 'GROUPBY' => $wgolParts['GROUPBY'],
02713 'ORDERBY' => $wgolParts['ORDERBY'],
02714 'LIMIT' => $wgolParts['LIMIT']
02715 );
02716 } else {
02717 $queryParts = array(
02718 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'),
02719 'FROM' => 'pages',
02720 'WHERE' => 'pages.deleted=0
02721 AND '.$pageClause.' '.
02722 $wgolParts['WHERE'],
02723 'GROUPBY' => $wgolParts['GROUPBY'],
02724 'ORDERBY' => $wgolParts['ORDERBY'],
02725 'LIMIT' => $wgolParts['LIMIT']
02726 );
02727 }
02728 }
02729
02730 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
02731 }
02732
02743 function getTCEFORM_TSconfig($table,$row) {
02744 t3lib_BEfunc::fixVersioningPid($table,$row);
02745
02746 $res = array();
02747 $typeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
02748
02749
02750 list($TScID,$cPid) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']);
02751
02752 $rootLine = t3lib_BEfunc::BEgetRootLine($TScID,'',TRUE);
02753 if ($TScID>=0) {
02754 $tempConf = $GLOBALS['BE_USER']->getTSConfig('TCEFORM.'.$table,t3lib_BEfunc::getPagesTSconfig($TScID,$rootLine));
02755 if (is_array($tempConf['properties'])) {
02756 while(list($key,$val)=each($tempConf['properties'])) {
02757 if (is_array($val)) {
02758 $fieldN = substr($key,0,-1);
02759 $res[$fieldN] = $val;
02760 unset($res[$fieldN]['types.']);
02761 if (strcmp($typeVal,'') && is_array($val['types.'][$typeVal.'.'])) {
02762 $res[$fieldN] = t3lib_div::array_merge_recursive_overrule($res[$fieldN],$val['types.'][$typeVal.'.']);
02763 }
02764 }
02765 }
02766 }
02767 }
02768 $res['_CURRENT_PID']=$cPid;
02769 $res['_THIS_UID']=$row['uid'];
02770 $res['_THIS_CID']=$row['cid'];
02771 $res['_THIS_ROW']=$row;
02772
02773 reset($rootLine);
02774 while(list(,$rC)=each($rootLine)) {
02775 if (!$res['_STORAGE_PID']) $res['_STORAGE_PID']=intval($rC['storage_pid']);
02776 if (!$res['_SITEROOT']) $res['_SITEROOT']=$rC['is_siteroot']?intval($rC['uid']):0;
02777 }
02778
02779 return $res;
02780 }
02781
02794 function getTSconfig_pidValue($table,$uid,$pid) {
02795
02796 if (t3lib_div::testInt($pid)) {
02797 $thePidValue = intval($pid);
02798 if ($thePidValue<0) {
02799 $pidRec = t3lib_BEfunc::getRecord($table,abs($thePidValue),'pid');
02800 $thePidValue = is_array($pidRec) ? $pidRec['pid'] : -2;
02801 }
02802
02803 } else {
02804 $rr = t3lib_BEfunc::getRecord($table,$uid,'pid');
02805 if (is_array($rr)) {
02806 $thePidValue = $rr['pid'];
02807 } else $thePidValue=-1;
02808 }
02809
02810 return $thePidValue;
02811 }
02812
02824 function getPidForModTSconfig($table,$uid,$pid) {
02825 $retVal = ($table=='pages' && t3lib_div::testInt($uid)) ? $uid : $pid;
02826 return $retVal;
02827 }
02828
02840 function getTSCpid($table,$uid,$pid) {
02841
02842 $cPid = t3lib_BEfunc::getTSconfig_pidValue($table,$uid,$pid);
02843
02844 $TScID = t3lib_BEfunc::getPidForModTSconfig($table,$uid,$cPid);
02845
02846 return array($TScID,$cPid);
02847 }
02848
02856 function firstDomainRecord($rootLine) {
02857 if (t3lib_extMgm::isLoaded('cms')) {
02858 reset($rootLine);
02859 while(list(,$row)=each($rootLine)) {
02860 $dRec = t3lib_BEfunc::getRecordsByField('sys_domain','pid',$row['uid'],' AND redirectTo=\'\' AND hidden=0', '', 'sorting');
02861 if (is_array($dRec)) {
02862 reset($dRec);
02863 $dRecord = current($dRec);
02864 return ereg_replace('\/$','',$dRecord['domainName']);
02865 }
02866 }
02867 }
02868 }
02869
02878 function getDomainStartPage($domain, $path='') {
02879 if (t3lib_extMgm::isLoaded('cms')) {
02880 $domain = explode(':',$domain);
02881 $domain = strtolower(ereg_replace('\.$','',$domain[0]));
02882
02883 $path = trim(ereg_replace('\/[^\/]*$','',$path));
02884
02885 $domain.=$path;
02886
02887 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_domain.*', 'pages,sys_domain', '
02888 pages.uid=sys_domain.pid
02889 AND sys_domain.hidden=0
02890 AND (sys_domain.domainName='.$GLOBALS['TYPO3_DB']->fullQuoteStr($domain, 'sys_domain').' or sys_domain.domainName='.$GLOBALS['TYPO3_DB']->fullQuoteStr($domain.'/', 'sys_domain').')'.
02891 t3lib_BEfunc::deleteClause('pages'),
02892 '', '', '1');
02893 return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
02894 }
02895 }
02896
02908 function RTEsetup($RTEprop,$table,$field,$type='') {
02909 $thisConfig = is_array($RTEprop['default.']) ? $RTEprop['default.'] : array();
02910 $thisFieldConf = $RTEprop['config.'][$table.'.'][$field.'.'];
02911 if (is_array($thisFieldConf)) {
02912 unset($thisFieldConf['types.']);
02913 $thisConfig = t3lib_div::array_merge_recursive_overrule($thisConfig,$thisFieldConf);
02914 }
02915 if ($type && is_array($RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.'])) {
02916 $thisConfig = t3lib_div::array_merge_recursive_overrule($thisConfig,$RTEprop['config.'][$table.'.'][$field.'.']['types.'][$type.'.']);
02917 }
02918 return $thisConfig;
02919 }
02920
02927 function &RTEgetObj() {
02928
02929
02930 if (!isset($GLOBALS['T3_VAR']['RTEobj'])) {
02931
02932
02933 $GLOBALS['T3_VAR']['RTEobj'] = array();
02934
02935
02936 if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg'])) {
02937 foreach($GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_reg'] as $extKey => $rteObjCfg) {
02938 $rteObj = &t3lib_div::getUserObj($rteObjCfg['objRef']);
02939 if (is_object($rteObj)) {
02940 if ($rteObj->isAvailable()) {
02941 $GLOBALS['T3_VAR']['RTEobj'] = &$rteObj;
02942 break;
02943 } else {
02944 $GLOBALS['T3_VAR']['RTEobj'] = array_merge($GLOBALS['T3_VAR']['RTEobj'], $rteObj->errorLog);
02945 }
02946 }
02947 }
02948 }
02949
02950 if (!count($GLOBALS['T3_VAR']['RTEobj'])) {
02951 $GLOBALS['T3_VAR']['RTEobj'][] = 'No RTEs configured at all';
02952 }
02953 }
02954
02955
02956 return $GLOBALS['T3_VAR']['RTEobj'];
02957 }
02958
02966 function &softRefParserObj($spKey) {
02967
02968
02969 if (!isset($GLOBALS['T3_VAR']['softRefParser'][$spKey])) {
02970
02971
02972 $GLOBALS['T3_VAR']['softRefParser'][$spKey] = '';
02973
02974
02975 $objRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser'][$spKey] ?
02976 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser'][$spKey] :
02977 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'][$spKey];
02978 if ($objRef) {
02979 $softRefParserObj = &t3lib_div::getUserObj($objRef,'');
02980 if (is_object($softRefParserObj)) {
02981 $GLOBALS['T3_VAR']['softRefParser'][$spKey] = &$softRefParserObj;
02982 }
02983 }
02984 }
02985
02986
02987 return $GLOBALS['T3_VAR']['softRefParser'][$spKey];
02988 }
02989
02998 function explodeSoftRefParserList($parserList) {
02999
03000
03001 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])) {
03002 $parserList = implode(',',array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])).','.$parserList;
03003 }
03004
03005
03006 if (!strlen($parserList)) return FALSE;
03007
03008
03009 $keyList = t3lib_div::trimExplode(',', $parserList, 1);
03010 $output = array();
03011
03012 foreach($keyList as $val) {
03013 $reg = array();
03014 if (ereg('^([[:alnum:]_-]+)\[(.*)\]$', $val, $reg)) {
03015 $output[$reg[1]] = t3lib_div::trimExplode(';', $reg[2], 1);
03016 } else {
03017 $output[$val] = '';
03018 }
03019 }
03020 return $output;
03021 }
03022
03030 function isModuleSetInTBE_MODULES($modName) {
03031 reset($GLOBALS['TBE_MODULES']);
03032 $loaded=array();
03033 while(list($mkey,$list)=each($GLOBALS['TBE_MODULES'])) {
03034 $loaded[$mkey]=1;
03035 if (trim($list)) {
03036 $subList = t3lib_div::trimExplode(',',$list,1);
03037 while(list(,$skey)=each($subList)) {
03038 $loaded[$mkey.'_'.$skey]=1;
03039 }
03040 }
03041 }
03042 return $modName && isset($loaded[$modName]);
03043 }
03044
03053 function referenceCount($table,$ref,$msg='') {
03054
03055 if ($table=='_FILE') {
03056
03057 if (t3lib_div::isFirstPartOfStr($ref,PATH_site)) {
03058 $ref = substr($ref,strlen(PATH_site));
03059 } else return '';
03060
03061
03062 list($res) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
03063 'count(*) as count',
03064 'sys_refindex',
03065 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
03066 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($ref,'sys_refindex').
03067 ' AND deleted=0'
03068 );
03069
03070 } else {
03071
03072 list($res) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
03073 'count(*) as count',
03074 'sys_refindex',
03075 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
03076 ' AND ref_uid='.intval($ref).
03077 ' AND deleted=0'
03078 );
03079 }
03080
03081 return $res['count'] ? ($msg ? sprintf($msg,$res['count']) : $res['count']) : '';
03082 }
03083
03084
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03112 function selectVersionsOfRecord($table, $uid, $fields='*', $workspace=0) {
03113 global $TCA;
03114
03115 if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS']) {
03116
03117
03118 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
03119 $fields,
03120 $table,
03121 '((t3ver_oid='.intval($uid).($workspace!=0?' AND t3ver_wsid='.intval($workspace):'').') OR uid='.intval($uid).')'.
03122 t3lib_BEfunc::deleteClause($table),
03123 '',
03124 't3ver_id DESC'
03125 );
03126
03127
03128 $realPid = 0;
03129 $outputRows = array();
03130 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
03131 if ($uid==$row['uid']) {
03132 $row['_CURRENT_VERSION']=TRUE;
03133 $realPid = $row['pid'];
03134 }
03135 $outputRows[] = $row;
03136 }
03137
03138
03139 foreach($outputRows as $idx => $oRow) {
03140 $outputRows[$idx]['_REAL_PID'] = $realPid;
03141 }
03142
03143 return $outputRows;
03144 }
03145 }
03146
03160 function fixVersioningPid($table,&$rr,$ignoreWorkspaceMatch=FALSE) {
03161 global $TCA;
03162
03163
03164 if (is_array($rr) && $rr['pid']==-1 && $TCA[$table]['ctrl']['versioningWS']) {
03165
03166
03167 if (isset($rr['t3ver_oid']) && isset($rr['t3ver_wsid'])) {
03168 $oid = $rr['t3ver_oid'];
03169 $wsid = $rr['t3ver_wsid'];
03170 } else {
03171 $newPidRec = t3lib_BEfunc::getRecord($table,$rr['uid'],'t3ver_oid,t3ver_wsid');
03172 if (is_array($newPidRec)) {
03173 $oid = $newPidRec['t3ver_oid'];
03174 $wsid = $newPidRec['t3ver_wsid'];
03175 }
03176 }
03177
03178
03179 if ($oid && ($ignoreWorkspaceMatch || !strcmp((int)$wsid,$GLOBALS['BE_USER']->workspace))) {
03180 $oidRec = t3lib_BEfunc::getRecord($table,$oid,'pid');
03181 if (is_array($oidRec)) {
03182 $rr['_ORIG_pid'] = $rr['pid'];
03183 $rr['pid'] = $oidRec['pid'];
03184 }
03185 }
03186 }
03187 }
03188
03200 function workspaceOL($table,&$row,$wsid=-99) {
03201
03202
03203 if ($wsid == -99) $wsid = $GLOBALS['BE_USER']->workspace;
03204
03205
03206 if ($wsid!==0 && is_array($row)) {
03207 $wsAlt = t3lib_BEfunc::getWorkspaceVersionOfRecord($wsid, $table, $row['uid'], implode(',',array_keys($row)));
03208
03209
03210 if (is_array($wsAlt)) {
03211
03212
03213 if (isset($wsAlt['pid'])) {
03214 $wsAlt['_ORIG_pid'] = $wsAlt['pid'];
03215 $wsAlt['pid'] = $row['pid'];
03216 }
03217
03218
03219 if ($table!=='pages' || $wsAlt['t3ver_swapmode']<=0) {
03220 $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
03221 $wsAlt['uid'] = $row['uid'];
03222
03223
03224 $wsAlt['_CSSCLASS'] = $table==='pages' && $wsAlt['t3ver_swapmode']==0 ? 'ver-page' : 'ver-element';
03225 } else {
03226 $wsAlt['_ONLINE_uid'] = $row['uid'];
03227
03228
03229 $wsAlt['_CSSCLASS'] = 'ver-branchpoint';
03230 $wsAlt['_SUBCSSCLASS'] = 'ver-branch';
03231 }
03232
03233
03234 $row = $wsAlt;
03235 }
03236 }
03237 }
03238
03248 function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields='*') {
03249 global $TCA;
03250
03251 if ($workspace!==0 && $TCA[$table] && $TCA[$table]['ctrl']['versioningWS']) {
03252
03253
03254 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
03255 $fields,
03256 $table,
03257 'pid=-1 AND
03258 t3ver_oid='.intval($uid).' AND
03259 t3ver_wsid='.intval($workspace).
03260 t3lib_BEfunc::deleteClause($table)
03261 );
03262
03263 if (is_array($rows[0])) return $rows[0];
03264 }
03265
03266 return FALSE;
03267 }
03268
03277 function getLiveVersionOfRecord($table,$uid,$fields='*') {
03278 global $TCA;
03279
03280
03281 if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS']) {
03282 $rec = t3lib_BEfunc::getRecord($table,$uid,'pid,t3ver_oid');
03283
03284 if ($rec['pid']==-1) {
03285 return t3lib_BEfunc::getRecord($table,$rec['t3ver_oid'],$fields);
03286 }
03287 }
03288 }
03289
03299 function isPidInVersionizedBranch($pid, $table='',$returnStage=FALSE) {
03300 $rl = t3lib_BEfunc::BEgetRootLine($pid);
03301 $c = 0;
03302
03303 foreach($rl as $rec) {
03304 if ($rec['_ORIG_pid']==-1) {
03305
03306 if ($rec['t3ver_swapmode']>0) {
03307 return $returnStage ? (int)$rec['t3ver_stage'] : 'branchpoint';
03308 } elseif ($c==0 && $rec['t3ver_swapmode']==0 && $table && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages']) {
03309 return $returnStage ? (int)$rec['t3ver_stage'] : 'first';
03310 }
03311 }
03312 $c++;
03313 }
03314 }
03315
03322 function versioningPlaceholderClause($table) {
03323 if ($GLOBALS['BE_USER']->workspace!==0 && $GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
03324 return ' AND ('.$table.'.t3ver_state!=1 OR '.$table.'.t3ver_wsid='.intval($GLOBALS['BE_USER']->workspace).')';
03325 }
03326 }
03327
03336 function countVersionsOfRecordsOnPage($workspace,$pageId, $allTables=FALSE) {
03337 $output = array();
03338 if ($workspace!=0) {
03339 foreach($GLOBALS['TCA'] as $tableName => $cfg) {
03340 if ($tableName!='pages' && $cfg['ctrl']['versioningWS'] && ($cfg['ctrl']['versioning_followPages'] || $allTables)) {
03341
03342
03343
03344 $output[$tableName] = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows (
03345 'B.uid as live_uid, A.uid as offline_uid',
03346 $tableName.' A,'.$tableName.' B',
03347 'A.pid=-1'.
03348 ' AND B.pid='.intval($pageId).
03349 ' AND A.t3ver_wsid='.intval($workspace).
03350 ' AND A.t3ver_oid=B.uid'.
03351 t3lib_BEfunc::deleteClause($tableName,'A').
03352 t3lib_BEfunc::deleteClause($tableName,'B')
03353 );
03354
03355 if (!is_array($output[$tableName]) || !count($output[$tableName])) {
03356 unset($output[$tableName]);
03357 }
03358 }
03359 }
03360 }
03361 return $output;
03362 }
03363
03371 function wsMapId($table,$uid) {
03372 if ($wsRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace,$table,$uid,'uid')) {
03373 return $wsRec['uid'];
03374 } else {
03375 return $uid;
03376 }
03377 }
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390
03401 function typo3PrintError($header,$text,$js='',$head=1) {
03402
03403
03404 if ($js) {
03405 echo "alert('".t3lib_div::slashJS($header.'\n'.$text)."');";
03406 } else {
03407 echo $head?'<html>
03408 <head>
03409 <title>Error!</title>
03410 </head>
03411 <body bgcolor="white" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">':'';
03412 echo '<div align="center">
03413 <table border="0" cellspacing="0" cellpadding="0" width="333">
03414 <tr>
03415 <td align="center">'.
03416 ($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="123" height="34" vspace="10" />').
03417 '</td>
03418 </tr>
03419 <tr>
03420 <td bgcolor="black">
03421 <table width="100%" border="0" cellspacing="1" cellpadding="10">
03422 <tr>
03423 <td bgcolor="#F4F0E8">
03424 <font face="verdana,arial,helvetica" size="2">';
03425 echo '<b><center><font size="+1">'.$header.'</font></center></b><br />'.$text;
03426 echo ' </font>
03427 </td>
03428 </tr>
03429 </table>
03430 </td>
03431 </tr>
03432 </table>
03433 </div>';
03434 echo $head?'
03435 </body>
03436 </html>':'';
03437 }
03438 }
03439
03445 function TYPO3_copyRightNotice() {
03446 global $TYPO3_CONF_VARS;
03447
03448
03449 $loginCopyrightWarrantyProvider = strip_tags(trim($TYPO3_CONF_VARS['SYS']['loginCopyrightWarrantyProvider']));
03450 $loginCopyrightWarrantyURL = strip_tags(trim($TYPO3_CONF_VARS['SYS']['loginCopyrightWarrantyURL']));
03451
03452 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10) {
03453 $warrantyNote='Warranty is supplied by '.htmlspecialchars($loginCopyrightWarrantyProvider).'; <a href="'.htmlspecialchars($loginCopyrightWarrantyURL).'" target="_blank">click for details.</a>';
03454 } else {
03455 $warrantyNote='TYPO3 comes with ABSOLUTELY NO WARRANTY; <a href="http://typo3.com/1316.0.html" target="_blank">click for details.</a>';
03456 }
03457 $cNotice = '<a href="http://typo3.com/" target="_blank"><img src="gfx/loginlogo_transp.gif" width="75" vspace="2" hspace="4" height="19" alt="TYPO3 logo" align="left" />TYPO3 CMS ver. '.htmlspecialchars(TYPO3_version).'</a>. Copyright © '.htmlspecialchars(TYPO3_copyright_year).' Kasper Skårhøj. Extensions are copyright of their respective owners. Go to <a href="http://typo3.com/" target="_blank">http:
03458 '.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.';
03459
03460 return $cNotice;
03461 }
03462
03469 function displayWarningMessages() {
03470 if($GLOBALS['BE_USER']->isAdmin()) {
03471 $warnings = array();
03472
03473
03474 if($GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']==md5('joh316')) {
03475 $warnings[] = 'The password of your Install Tool is still using the default value "joh316"';
03476 }
03477
03478
03479 $where_clause = 'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr('admin','be_users').' AND password='.$GLOBALS['TYPO3_DB']->fullQuoteStr('5f4dcc3b5aa765d61d8327deb882cf99','be_users').t3lib_BEfunc::deleteClause('be_users');
03480 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('username, password', 'be_users', $where_clause);
03481 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
03482 $warnings[] = 'The backend user "admin" with password "password" is still existing';
03483 }
03484
03485
03486 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] == '') {
03487 $url = 'install/index.php?redirect_url=index.php'.urlencode('?TYPO3_INSTALL[type]=config#set_encryptionKey');
03488 $warnings[] = 'The encryption key is not set! Set it in <a href="'.$url.'">$TYPO3_CONF_VARS[SYS][encryptionKey]</a>';
03489 }
03490
03491
03492 if (!t3lib_div::compat_version(TYPO3_branch)) {
03493 $url = 'install/index.php?redirect_url=index.php'.urlencode('?TYPO3_INSTALL[type]=update');
03494 $warnings[] = 'This installation is not configured for the TYPO3 version it is running. You probably did so by intention, in this case you can safely ignore this message. If unsure, visit the <a href="'.$url.'" target="_blank">Update Wizard</a> in the Install Tool to see which changes would be affected.';
03495 }
03496
03497
03498 if (is_object($GLOBALS['TYPO3_DB'])) {
03499 list($count) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('count(*) as rcount','sys_refindex','1=1');
03500 if (!$count['rcount']) {
03501 $warnings[] = 'The Reference Index table is empty which is likely to be the case because you just upgraded your TYPO3 source. Please go to Tools>DB Check and update the reference index.';
03502 }
03503 }
03504
03505 if(count($warnings)) {
03506 $content = '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
03507 $GLOBALS['TBE_TEMPLATE']->icons(3).'Important notice!<br />'.
03508 '- '.implode('<br />- ', $warnings).'<br /><br />'.
03509 'It is highly recommended that you change this immediately.'.
03510 '</td></tr></table>';
03511
03512 unset($warnings);
03513 return $content;
03514 }
03515 }
03516 return '<p> </p>';
03517 }
03518
03526 function getPathType_web_nonweb($path) {
03527 return t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')) ? 'web' : '';
03528 }
03529
03538 function ADMCMD_previewCmds($pageinfo) {
03539 if ($pageinfo['fe_group']>0) {
03540 $simUser = '&ADMCMD_simUser='.$pageinfo['fe_group'];
03541 }
03542 if ($pageinfo['starttime']>time()) {
03543 $simTime = '&ADMCMD_simTime='.$pageinfo['starttime'];
03544 }
03545 if ($pageinfo['endtime']<time() && $pageinfo['endtime']!=0) {
03546 $simTime = '&ADMCMD_simTime='.($pageinfo['endtime']-1);
03547 }
03548 return $simUser.$simTime;
03549 }
03550
03560 function processParams($params) {
03561 $paramArr=array();
03562 $lines=explode(chr(10),$params);
03563 while(list(,$val)=each($lines)) {
03564 $val = trim($val);
03565 if ($val) {
03566 $pair = explode('=',$val,2);
03567 $paramArr[trim($pair[0])] = trim($pair[1]);
03568 }
03569 }
03570 return $paramArr;
03571 }
03572
03586 function getListOfBackendModules($name,$perms_clause,$backPath='',$script='index.php') {
03587 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'doktype!=255 AND module IN (\''.implode('\',\'',$name).'\') AND'.$perms_clause.t3lib_BEfunc::deleteClause('pages'));
03588 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) return false;
03589
03590 $out='';
03591 $theRows=array();
03592 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
03593 $theRows[]=$row;
03594 $out.='<span class="nobr"><a href="'.htmlspecialchars($script.'?id='.$row['uid']).'">'.
03595 t3lib_iconWorks::getIconImage('pages',$row,$backPath,'title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath($row['uid'],$perms_clause,20)).'" align="top"').
03596 htmlspecialchars($row['title']).
03597 '</a></span><br />';
03598 }
03599 return array('rows'=>$theRows,'list'=>$out);
03600 }
03601 }
03602 ?>