"TYPO3 4.0.1: typo3_src-4.0.1/t3lib/class.t3lib_transferdata.php Source File", "datetime" => "Sat Dec 2 19:22:19 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

class.t3lib_transferdata.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2006 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 ***************************************************************/
00075 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00076 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
00077 require_once (PATH_t3lib.'class.t3lib_parsehtml_proc.php');
00078 require_once (PATH_t3lib.'class.t3lib_flexformtools.php');
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00098 class t3lib_transferData {
00099                 // External, static:
00100         var $lockRecords=0;                                     // If set, the records requested are locked.
00101         var $disableRTE=0;                                      // Is set externally if RTE is disabled.
00102         var $prevPageID = '';                           // If the pid in the command is 'prev' then $prevPageID is used as pid for the record. This is used to attach new records to other previous records eg. new pages.
00103         var $defVals=array();                                           // Can be set with an array of default values for tables. First key is table name, second level keys are field names. Originally this was a GLOBAL array used internally.
00104         var $addRawData = FALSE;                        // If set, the processed data is overlaid the raw record.
00105 
00106                 // Internal, dynamic
00107         var $regTableItems = Array();           // Used to register, which items are already loaded!!
00108         var $regTableItems_data = Array();      // This stores the record data of the loaded records
00109         var $loadModules='';                            // Contains loadModules object, if used. (for reuse internally)
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120         /***********************************************
00121          *
00122          * Getting record content, ready for display in TCEforms
00123          *
00124          ***********************************************/
00125 
00137         function fetchRecord($table,$idList,$operation) {
00138                 global $TCA;
00139 
00140                 if ((string)$idList == 'prev')  {$idList = $this->prevPageID;}
00141 
00142                 if ($TCA[$table])       {
00143                         t3lib_div::loadTCA($table);
00144 
00145                                 // For each ID value (integer) we
00146                         $ids = t3lib_div::trimExplode(',',$idList,1);
00147                         foreach($ids as $id)    {
00148                                 if (strcmp($id,''))     {       // If ID is not blank:
00149 
00150                                                 // For new records to be created, find default values:
00151                                         if ($operation=='new')  {
00152 
00153                                                         // Default values:
00154                                                 $newRow = Array();      // Used to store default values as found here:
00155 
00156                                                         // Default values as set in userTS:
00157                                                 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
00158                                                 if (is_array($TCAdefaultOverride[$table.'.']))  {
00159                                                         foreach($TCAdefaultOverride[$table.'.'] as $theF => $theV)      {
00160                                                                 if (isset($TCA[$table]['columns'][$theF]))      {
00161                                                                         $newRow[$theF]=$theV;
00162                                                                 }
00163                                                         }
00164                                                 }
00165 
00166                                                         // Default values as submitted:
00167                                                 if (is_array($this->defVals[$table]))   {
00168                                                         foreach($this->defVals[$table] as $theF => $theV)       {
00169                                                                 if (isset($TCA[$table]['columns'][$theF]))      {
00170                                                                         $newRow[$theF]=$theV;
00171                                                                 }
00172                                                         }
00173                                                 }
00174 
00175                                                         // Fetch default values if a previous record exists
00176                                                 if ($id<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues'])        {
00177                                                                 // Fetches the previous record:
00178                                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($id).t3lib_BEfunc::deleteClause($table));
00179                                                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00180                                                                         // Gets the list of fields to copy from the previous record.
00181                                                                 $fArr=t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues'],1);
00182                                                                 while(list(,$theF)=each($fArr)) {
00183                                                                         if (isset($TCA[$table]['columns'][$theF]))      {
00184                                                                                 $newRow[$theF]=$row[$theF];
00185                                                                         }
00186                                                                 }
00187                                                         }
00188                                                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
00189                                                 }
00190 
00191                                                         // Finally, call renderRecord:
00192                                                 $this->renderRecord($table, uniqid('NEW'), $id, $newRow);
00193                                         } else {
00194                                                 $id=intval($id);
00195 
00196                                                         // Fetch database values
00197                                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.intval($id).t3lib_BEfunc::deleteClause($table));
00198                                                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00199                                                         t3lib_BEfunc::fixVersioningPid($table,$row);
00200                                                         $this->renderRecord($table, $id, $row['pid'], $row);
00201                                                         $contentTable = $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'];
00202                                                         $this->lockRecord($table, $id, $contentTable==$table?$row['pid']:0);    // Locking the pid if the table edited is the content table.
00203                                                 }
00204                                                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00205                                         }
00206                                 }
00207                         }
00208                 }
00209         }
00210 
00224         function renderRecord($table, $id, $pid, $row)  {
00225                 global $TCA;
00226 
00227                         // Init:
00228                 $uniqueItemRef = $table.'_'.$id;
00229                 t3lib_div::loadTCA($table);
00230 
00231                         // Fetches the true PAGE TSconfig pid to use later, if needed. (Until now, only for the RTE, but later..., who knows?)
00232                 list($tscPID)=t3lib_BEfunc::getTSCpid($table,$id,$pid);
00233                 $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($table,array_merge($row,array('uid'=>$id,'pid'=>$pid)));
00234 
00235                         // If the record has not already been loaded (in which case we DON'T do it again)...
00236                 if (!$this->regTableItems[$uniqueItemRef])      {
00237                         $this->regTableItems[$uniqueItemRef] = 1;       // set "loaded" flag.
00238 
00239                                 // If the table is pages, set the previous page id internally.
00240                         if ($table == 'pages')  {$this->prevPageID = $id;}
00241 
00242                         $this->regTableItems_data[$uniqueItemRef] = $this->renderRecordRaw($table, $id, $pid, $row, $TSconfig, $tscPID);
00243 
00244                                 // Merges the processed array on-top of the raw one - this is done because some things in TCEforms may need access to other fields than those in the columns configuration!
00245                         if ($this->addRawData && is_array($row) && is_array($this->regTableItems_data[$uniqueItemRef])) {
00246                                 $this->regTableItems_data[$uniqueItemRef] = array_merge($row, $this->regTableItems_data[$uniqueItemRef]);
00247                         }
00248                 }
00249         }
00250 
00251 
00252 
00268         function renderRecordRaw($table, $id, $pid, $row, $TSconfig='', $tscPID=0)      {
00269                 global $TCA;
00270 
00271                 if(!is_array($TSconfig)) {
00272                         $TSconfig = array();
00273                 }
00274 
00275                         // Create blank accumulation array:
00276                 $totalRecordContent=array();
00277 
00278                         // Traverse the configured columns for the table (TCA):
00279                         // For each column configured, we will perform processing if needed based on the type (eg. for "group" and "select" types this is needed)
00280                 t3lib_div::loadTCA($table);
00281                 $copyOfColumns = $TCA[$table]['columns'];
00282                 foreach($copyOfColumns as $field => $fieldConfig)       {
00283                                 // Set $data variable for the field, either inputted value from $row - or if not found, the default value as defined in the "config" array
00284                         if (isset($row[$field]))        {
00285                                 $data = $row[$field];
00286                         } else {
00287                                 $data = $fieldConfig['config']['default'];
00288                         }
00289 
00290                         $data = $this->renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field);
00291 
00292                                 // Set the field in the accumulation array IF the $data variabel is set:
00293                         $totalRecordContent[$field] = isset($data) ? $data : '';
00294                 }
00295 
00296                         // Further processing may apply for each field in the record depending on the settings in the "types" configuration (the list of fields to currently display for a record in TCEforms).
00297                         // For instance this could be processing instructions for the Rich Text Editor.
00298                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$totalRecordContent);
00299                 if (is_array($types_fieldConfig))       {
00300                         $totalRecordContent = $this->renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid);
00301                 }
00302 
00303                         // Register items, mostly for external use (overriding the regItem() function)
00304                 foreach($totalRecordContent as $field => $data) {
00305                         $this->regItem($table,$id,$field,$data);
00306                 }
00307 
00308                         // Finally, store the result:
00309                 reset($totalRecordContent);
00310 
00311                 return $totalRecordContent;
00312 
00313         }
00314 
00326         function renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00327 
00328                 switch((string)$fieldConfig['config']['type'])  {
00329                         case 'group':
00330                                 $data = $this->renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00331                         break;
00332                         case 'select':
00333                                 $data = $this->renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00334                         break;
00335                         case 'flex':
00336                                 $data = $this->renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00337                         break;
00338                 }
00339 
00340                 return $data;
00341         }
00342 
00356         function renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field)        {
00357                 switch ($fieldConfig['config']['internal_type'])        {
00358                         case 'file':
00359                                         // Init array used to accumulate the files:
00360                                 $dataAcc=array();
00361 
00362                                         // Now, load the files into the $dataAcc array, whether stored by MM or as a list of filenames:
00363                                 if ($fieldConfig['config']['MM'])       {
00364                                         $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00365                                         $loadDB->start('', 'files', $fieldConfig['config']['MM'], $row['uid']); // Setting dummy startup
00366 
00367                                         foreach($loadDB->itemArray as $value)   {
00368                                                 if ($value['id'])       {
00369                                                         $dataAcc[]=rawurlencode($value['id']).'|'.rawurlencode($value['id']);
00370                                                 }
00371                                         }
00372                                 } else {
00373                                         $fileList = t3lib_div::trimExplode(',',$data,1);
00374                                         foreach($fileList as $value)    {
00375                                                 if ($value)     {
00376                                                         $dataAcc[]=rawurlencode($value).'|'.rawurlencode($value);
00377                                                 }
00378                                         }
00379                                 }
00380                                         // Implode the accumulation array to a comma separated string:
00381                                 $data = implode(',',$dataAcc);
00382                         break;
00383                         case 'db':
00384                                 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00385                                 $loadDB->start($data, $fieldConfig['config']['allowed'], $fieldConfig['config']['MM'], $row['uid']);
00386                                 $loadDB->getFromDB();
00387                                 $data = $loadDB->readyForInterface();
00388                         break;
00389                 }
00390 
00391                 return $data;
00392         }
00393 
00407         function renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00408                 global $TCA;
00409 
00410                         // Initialize:
00411                 $elements = t3lib_div::trimExplode(',',$data,1);        // Current data set.
00412                 $dataAcc=array();       // New data set, ready for interface (list of values, rawurlencoded)
00413 
00414                         // For list selectors (multi-value):
00415                 if (intval($fieldConfig['config']['maxitems'])>1)       {
00416 
00417                                 // Add regular elements:
00418                         if (is_array($fieldConfig['config']['items']))  {
00419                                 $fieldConfig['config']['items'] = $this->procesItemArray($fieldConfig['config']['items'], $fieldConfig['config'], $TSconfig[$field], $table, $row, $field);
00420                                 foreach($fieldConfig['config']['items'] as $pvpv)       {
00421                                         foreach($elements as $eKey => $value)   {
00422                                                 if (!strcmp($value,$pvpv[1]))   {
00423                                                         $dataAcc[$eKey]=rawurlencode($pvpv[1]).'|'.rawurlencode($this->sL($pvpv[0]));
00424                                                 }
00425                                         }
00426                                 }
00427                         }
00428 
00429                                 // Add "special"
00430                         if ($fieldConfig['config']['special'])  {
00431                                 $dataAcc = $this->selectAddSpecial($dataAcc, $elements, $fieldConfig['config']['special']);
00432                         }
00433 
00434                                 // Add "foreign table" stuff:
00435                         if ($TCA[$fieldConfig['config']['foreign_table']])      {
00436                                 $dataAcc = $this->selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row);
00437                         }
00438 
00439                                 // Always keep the native order for display in interface:
00440                         ksort($dataAcc);
00441                 } else {        // Normal, <= 1 -> value without title on it
00442                         if ($TCA[$fieldConfig['config']['foreign_table']])      {
00443                                 // Getting the data
00444                                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row);
00445 
00446                                 if (!count($dataIds))   $dataIds = array(0);
00447                                 $dataAcc[]=$dataIds[0];
00448                         } else {
00449                                 $dataAcc[]=$elements[0];
00450                         }
00451                 }
00452 
00453                 return implode(',',$dataAcc);
00454         }
00455 
00470         function renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field) {
00471                 global $TCA;
00472 
00473                         // Convert the XML data to PHP array:
00474                 $currentValueArray = t3lib_div::xml2array($data);
00475                 if (is_array($currentValueArray))       {
00476 
00477                                 // Get current value array:
00478                         $dataStructArray = t3lib_BEfunc::getFlexFormDS($fieldConfig['config'],$row,$table);
00479                         if (is_array($dataStructArray)) {
00480                                 $currentValueArray['data'] = $this->renderRecord_flexProc_procInData($currentValueArray['data'],$dataStructArray,array($data,$fieldConfig,$TSconfig,$table,$row,$field));
00481 
00482                                 $flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
00483                                 $data = $flexObj->flexArray2Xml($currentValueArray, TRUE);
00484                         }
00485                 }
00486 
00487                 return $data;
00488         }
00489 
00501         function renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid)     {
00502                 foreach($types_fieldConfig as $vconf)   {
00503 
00504                                 // Find file to write to, if configured:
00505                         $eFile = t3lib_parsehtml_proc::evalWriteFile($vconf['spec']['static_write'],$totalRecordContent);
00506 
00507                                 // Write file configuration:
00508                         if (is_array($eFile))   {
00509                                 if ($eFile['loadFromFileField'] && $totalRecordContent[$eFile['loadFromFileField']])    {
00510                                                 // Read the external file, and insert the content between the ###TYPO3_STATICFILE_EDIT### markers:
00511                                         $SW_fileContent = t3lib_div::getUrl($eFile['editFile']);
00512                                         $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
00513                                         $parseHTML->init('','');
00514 
00515                                         $totalRecordContent[$vconf['field']] = $parseHTML->getSubpart(
00516                                                 $SW_fileContent,
00517                                                 $eFile['markerField']&&trim($totalRecordContent[$eFile['markerField']])
00518                                                         ? trim($totalRecordContent[$eFile['markerField']])
00519                                                         : '###TYPO3_STATICFILE_EDIT###'
00520                                         );
00521                                 }
00522                         }
00523                 }
00524 
00525                 return $totalRecordContent;
00526         }
00527 
00528 
00529 
00530 
00531 
00532 
00533 
00534 
00535 
00536 
00537 
00538 
00539 
00540 
00541         /***********************************************
00542          *
00543          * FlexForm processing functions
00544          *
00545          ***********************************************/
00546 
00557         function renderRecord_flexProc_procInData($dataPart,$dataStructArray,$pParams)  {
00558                 if (is_array($dataPart))        {
00559                         foreach($dataPart as $sKey => $sheetDef)        {
00560                                 list ($dataStruct,$actualSheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sKey);
00561 
00562                                 if (is_array($dataStruct) && $actualSheet==$sKey && is_array($sheetDef))        {
00563                                         foreach($sheetDef as $lKey => $lData)   {
00564                                                 $this->renderRecord_flexProc_procInData_travDS(
00565                                                         $dataPart[$sKey][$lKey],
00566                                                         $dataStruct['ROOT']['el'],
00567                                                         $pParams
00568                                                 );
00569                                         }
00570                                 }
00571                         }
00572                 }
00573 
00574                 return $dataPart;
00575         }
00576 
00586         function renderRecord_flexProc_procInData_travDS(&$dataValues,$DSelements,$pParams)             {
00587                 if (is_array($DSelements))      {
00588 
00589                                 // For each DS element:
00590                         foreach($DSelements as $key => $dsConf) {
00591 
00592                                                 // Array/Section:
00593                                 if ($DSelements[$key]['type']=='array') {
00594                                         if (is_array($dataValues[$key]['el']))  {
00595                                                 if ($DSelements[$key]['section'])       {
00596                                                         foreach($dataValues[$key]['el'] as $ik => $el)  {
00597                                                                 $theKey = key($el);
00598                                                                 if (is_array($dataValues[$key]['el'][$ik][$theKey]['el']))      {
00599                                                                         $this->renderRecord_flexProc_procInData_travDS(
00600                                                                                         $dataValues[$key]['el'][$ik][$theKey]['el'],
00601                                                                                         $DSelements[$key]['el'][$theKey]['el'],
00602                                                                                         $pParams
00603                                                                                 );
00604                                                                 }
00605                                                         }
00606                                                 } else {
00607                                                         if (!isset($dataValues[$key]['el']))    $dataValues[$key]['el']=array();
00608                                                         $this->renderRecord_flexProc_procInData_travDS(
00609                                                                         $dataValues[$key]['el'],
00610                                                                         $DSelements[$key]['el'],
00611                                                                         $pParams
00612                                                                 );
00613                                                 }
00614                                         }
00615                                 } else {
00616                                         if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key]))     {
00617                                                 foreach($dataValues[$key] as $vKey => $data)    {
00618 
00619                                                                 // $data,$fieldConfig,$TSconfig,$table,$row,$field
00620                                                         list(,,$CVTSconfig,$CVtable,$CVrow,$CVfield) = $pParams;
00621 ;
00622                                                                 // Set default value:
00623                                                         if (!isset($dataValues[$key][$vKey]))   {
00624                                                                 $dataValues[$key][$vKey] = $dsConf['TCEforms']['config']['default'];
00625                                                         }
00626 
00627                                                                 // Process value:
00628                                                         $dataValues[$key][$vKey] = $this->renderRecord_SW($dataValues[$key][$vKey],$dsConf['TCEforms'],$CVTSconfig,$CVtable,$CVrow,'');
00629                                                 }
00630                                         }
00631                                 }
00632                         }
00633                 }
00634         }
00635 
00636 
00637 
00638 
00639 
00640 
00641 
00642 
00643 
00644 
00645 
00646 
00647         /***********************************************
00648          *
00649          * Selector box processing functions
00650          *
00651          ***********************************************/
00652 
00663         function selectAddSpecial($dataAcc, $elements, $specialKey)     {
00664                 global $TCA;
00665 
00666                         // Special select types:
00667                 switch ((string)$specialKey)    {
00668                         case 'tables':          // Listing all tables from $TCA:
00669                                 $tNames = array_keys($TCA);
00670                                 foreach($tNames as $tableName)  {
00671                                         foreach($elements as $eKey => $value)   {
00672                                                 if (!strcmp($tableName,$value)) {
00673                                                         $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($this->sL($TCA[$value]['ctrl']['title']));
00674                                                 }
00675                                         }
00676                                 }
00677                         break;
00678                         case 'pagetypes':       // Listing all page types (doktype)
00679                                 $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
00680                                 if (is_array($theTypes))        {
00681                                         foreach($theTypes as $theTypesArrays)   {
00682                                                 foreach($elements as $eKey => $value)   {
00683                                                         if (!strcmp($theTypesArrays[1],$value)) {
00684                                                                 $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($this->sL($theTypesArrays[0]));
00685                                                         }
00686                                                 }
00687                                         }
00688                                 }
00689                         break;
00690                         case 'exclude':         // Listing exclude fields.
00691                                 $theExcludeFields = t3lib_BEfunc::getExcludeFields();
00692 
00693                                 if (is_array($theExcludeFields))        {
00694                                         foreach($theExcludeFields as $theExcludeFieldsArrays)   {
00695                                                 foreach($elements as $eKey => $value)   {
00696                                                         if (!strcmp($theExcludeFieldsArrays[1],$value)) {
00697                                                                 $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode(ereg_replace(':$','',$theExcludeFieldsArrays[0]));
00698                                                         }
00699                                                 }
00700                                         }
00701                                 }
00702                         break;
00703                         case 'explicitValues':
00704                                 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
00705 
00706                                 foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
00707                                         if (is_array($theTypeArrays['items']))  {
00708                                                 foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
00709                                                         foreach($elements as $eKey => $value)   {
00710                                                                 if (!strcmp($tableFieldKey.':'.$itemValue.':'.$itemContent[0], $value)) {
00711                                                                         $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode('['.$itemContent[2].'] '.$itemContent[1]);
00712                                                                 }
00713                                                         }
00714                                                 }
00715                                         }
00716                                 }
00717                         break;
00718                         case 'languages':
00719                                 $theLangs = t3lib_BEfunc::getSystemLanguages();
00720                                 foreach($theLangs as $lCfg)     {
00721                                         foreach($elements as $eKey => $value)   {
00722                                                 if (!strcmp($lCfg[1], $value))  {
00723                                                         $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode($lCfg[0]);
00724                                                 }
00725                                         }
00726                                 }
00727                         break;
00728                         case 'custom':
00729                                 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
00730 
00731                                 if (is_array($customOptions))   {
00732                                         foreach($customOptions as $coKey => $coValue) {
00733                                                 if (is_array($coValue['items']))        {
00734                                                                 // Traverse items:
00735                                                         foreach($coValue['items'] as $itemKey => $itemCfg)      {
00736                                                                 foreach($elements as $eKey => $value)   {
00737                                                                         if (!strcmp($coKey.':'.$itemKey, $value))       {
00738                                                                                 $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode($this->sL($itemCfg[0]));
00739                                                                         }
00740                                                                 }
00741                                                         }
00742                                                 }
00743                                         }
00744                                 }
00745                         break;
00746                         case 'modListGroup':    // Listing modules for GROUPS
00747                         case 'modListUser':             // Listing modules for USERS:
00748                                 if (!$this->loadModules)        {
00749                                         $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00750                                         $this->loadModules->load($GLOBALS['TBE_MODULES']);
00751                                 }
00752                                 $modList = ($specialKey=='modListUser') ? $this->loadModules->modListUser : $this->loadModules->modListGroup;
00753 
00754                                 foreach($modList as $theModName)        {
00755                                         foreach($elements as $eKey => $value)   {
00756                                                 $label = '';
00757                                                         // Add label for main module:
00758                                                 $pp = explode('_',$value);
00759                                                 if (count($pp)>1)       $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
00760                                                         // Add modules own label now:
00761                                                 $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
00762 
00763                                                 if (!strcmp($theModName,$value))        {
00764                                                         $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($label);
00765                                                 }
00766                                         }
00767                                 }
00768                         break;
00769                 }
00770 
00771                 return $dataAcc;
00772         }
00773 
00787         function selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row)   {
00788                 global $TCA;
00789 
00790                         // Init:
00791                 $recordList = Array();
00792 
00793                         // foreign_table
00794                 $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig,$field,$TSconfig);
00795                 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres))        {
00796                         $recordList[$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['foreign_table'],$subrow);
00797                 }
00798 
00799                         // neg_foreign_table
00800                 if (is_array($TCA[$fieldConfig['config']['neg_foreign_table']]))        {
00801                         $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig,$field,$TSconfig,'neg_');
00802                         while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres))        {
00803                                 $recordList[-$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['neg_foreign_table'],$subrow);
00804                         }
00805                 }
00806 
00807                         // At this point all records that CAN be selected is found in $recordList
00808                         // Now, get the data from loadDBgroup based on the input list of values.
00809                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row);
00810                 if ($fieldConfig['config']['MM'])       $dataAcc=array();       // Reset, if MM (which cannot bear anything but real relations!)
00811 
00812                         // After this we can traverse the loadDBgroup values and match values with the list of possible values in $recordList:
00813                 foreach($dataIds as $theId)     {
00814                         if (isset($recordList[$theId])) {
00815                                 $lPrefix = $this->sL($fieldConfig['config'][($theId>0?'':'neg_').'foreign_table_prefix']);
00816                                 if ($fieldConfig['config']['MM'])       {
00817                                         $dataAcc[]=rawurlencode($theId).'|'.rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix.strip_tags($recordList[$theId]),$GLOBALS['BE_USER']->uc['titleLen']));
00818                                 } else {
00819                                         foreach($elements as $eKey => $value)   {
00820                                                 if (!strcmp($theId,$value))     {
00821                                                         $dataAcc[$eKey]=rawurlencode($theId).'|'.rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix.strip_tags($recordList[$theId]),$GLOBALS['BE_USER']->uc['titleLen']));
00822                                                 }
00823                                         }
00824                                 }
00825                         }
00826                 }
00827 
00828                 return $dataAcc;
00829         }
00830 
00840         function getDataIdList($elements, $fieldConfig, $row)   {
00841                 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00842                 $loadDB->registerNonTableValues=$fieldConfig['config']['allowNonIdValues'] ? 1 : 0;
00843                 $loadDB->start(implode(',',$elements), $fieldConfig['config']['foreign_table'].','.$fieldConfig['config']['neg_foreign_table'], $fieldConfig['config']['MM'], $row['uid']);
00844 
00845                 $idList = $loadDB->convertPosNeg($loadDB->getValueArray(),$fieldConfig['config']['foreign_table'],$fieldConfig['config']['neg_foreign_table']);
00846 
00847                 return $idList;
00848         }
00849 
00863         function procesItemArray($selItems,$config,$fieldTSConfig,$table,$row,$field)   {
00864                 $selItems = $this->addItems($selItems,$fieldTSConfig['addItems.']);
00865                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$fieldTSConfig['itemsProcFunc.'],$config,$table,$row,$field);
00866                 return $selItems;
00867         }
00868 
00878         function addItems($items,$iArray)       {
00879                 if (is_array($iArray))  {
00880                         foreach($iArray as $value => $label)    {
00881                                 $items[]=array($label,$value);
00882                         }
00883                 }
00884                 return $items;
00885         }
00886 
00900         function procItems($items,$itemsProcFuncTSconfig,$config,$table,$row,$field)    {
00901                 $params=array();
00902                 $params['items'] = &$items;
00903                 $params['config'] = $config;
00904                 $params['TSconfig'] = $itemsProcFuncTSconfig;
00905                 $params['table'] = $table;
00906                 $params['row'] = $row;
00907                 $params['field'] = $field;
00908 
00909                 t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
00910                 return $items;
00911         }
00912 
00913 
00914 
00915 
00916 
00917 
00918 
00919 
00920 
00921         /***********************************************
00922          *
00923          * Helper functions
00924          *
00925          ***********************************************/
00926 
00935         function lockRecord($table, $id, $pid=0)        {
00936                 if ($this->lockRecords) {
00937                         t3lib_BEfunc::lockRecords($table,$id,$pid);
00938                 }
00939         }
00940 
00952         function regItem($table, $id, $field, $content) {
00953         }
00954 
00962         function sL($in)        {
00963                 return $GLOBALS['LANG']->sL($in);
00964         }
00965 }
00966 
00967 
00968 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php'])      {
00969         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php']);
00970 }
00971 ?>