/src/typo3_src-4.2.0alpha1/t3lib/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 ***************************************************************/
00076 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00077 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
00078 require_once (PATH_t3lib.'class.t3lib_parsehtml_proc.php');
00079 require_once (PATH_t3lib.'class.t3lib_flexformtools.php');
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00099 class t3lib_transferData {
00100                 // External, static:
00101         var $lockRecords=0;                                     // If set, the records requested are locked.
00102         var $disableRTE=0;                                      // Is set externally if RTE is disabled.
00103         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.
00104         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.
00105         var $addRawData = FALSE;                        // If set, the processed data is overlaid the raw record.
00106 
00107                 // Internal, dynamic
00108         var $regTableItems = Array();           // Used to register, which items are already loaded!!
00109         var $regTableItems_data = Array();      // This stores the record data of the loaded records
00110         var $loadModules='';                            // Contains loadModules object, if used. (for reuse internally)
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121         /***********************************************
00122          *
00123          * Getting record content, ready for display in TCEforms
00124          *
00125          ***********************************************/
00126 
00138         function fetchRecord($table,$idList,$operation) {
00139                 global $TCA;
00140 
00141                 if ((string)$idList == 'prev')  {$idList = $this->prevPageID;}
00142 
00143                 if ($TCA[$table])       {
00144                         t3lib_div::loadTCA($table);
00145 
00146                                 // For each ID value (integer) we
00147                         $ids = t3lib_div::trimExplode(',',$idList,1);
00148                         foreach($ids as $id)    {
00149                                 if (strcmp($id,''))     {       // If ID is not blank:
00150 
00151                                                 // For new records to be created, find default values:
00152                                         if ($operation=='new')  {
00153 
00154                                                         // Default values:
00155                                                 $newRow = Array();      // Used to store default values as found here:
00156 
00157                                                         // Default values as set in userTS:
00158                                                 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
00159                                                 if (is_array($TCAdefaultOverride[$table.'.']))  {
00160                                                         foreach($TCAdefaultOverride[$table.'.'] as $theF => $theV)      {
00161                                                                 if (isset($TCA[$table]['columns'][$theF]))      {
00162                                                                         $newRow[$theF]=$theV;
00163                                                                 }
00164                                                         }
00165                                                 }
00166 
00167                                                 $pageTS = t3lib_beFunc::getPagesTSconfig($id, true);
00168                                                 if (isset($pageTS['TCAdefaults.'])) {
00169                                                         $TCAPageTSOverride  = $pageTS['TCAdefaults.'];
00170                                                         if (is_array($TCAPageTSOverride[$table.'.']))   {
00171                                                                 foreach($TCAPageTSOverride[$table.'.'] as $theF => $theV)       {
00172                                                                         if (isset($TCA[$table]['columns'][$theF]))      {
00173                                                                                 $newRow[$theF]=$theV;
00174                                                                         }
00175                                                                 }
00176                                                         }
00177                                                 }
00178 
00179                                                         // Default values as submitted:
00180                                                 if (is_array($this->defVals[$table]))   {
00181                                                         foreach($this->defVals[$table] as $theF => $theV)       {
00182                                                                 if (isset($TCA[$table]['columns'][$theF]))      {
00183                                                                         $newRow[$theF]=$theV;
00184                                                                 }
00185                                                         }
00186                                                 }
00187 
00188                                                         // Fetch default values if a previous record exists
00189                                                 if ($id<0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues'])        {
00190                                                                 // Fetches the previous record:
00191                                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.abs($id).t3lib_BEfunc::deleteClause($table));
00192                                                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00193                                                                         // Gets the list of fields to copy from the previous record.
00194                                                                 $fArr=t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues'],1);
00195                                                                 while(list(,$theF)=each($fArr)) {
00196                                                                         if (isset($TCA[$table]['columns'][$theF]))      {
00197                                                                                 $newRow[$theF]=$row[$theF];
00198                                                                         }
00199                                                                 }
00200                                                         }
00201                                                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
00202                                                 }
00203 
00204                                                         // Finally, call renderRecord:
00205                                                 $this->renderRecord($table, uniqid('NEW'), $id, $newRow);
00206                                         } else {
00207                                                 $id=intval($id);
00208 
00209                                                         // Fetch database values
00210                                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.intval($id).t3lib_BEfunc::deleteClause($table));
00211                                                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00212                                                         t3lib_BEfunc::fixVersioningPid($table,$row);
00213                                                         $this->renderRecord($table, $id, $row['pid'], $row);
00214                                                         $contentTable = $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'];
00215                                                         $this->lockRecord($table, $id, $contentTable==$table?$row['pid']:0);    // Locking the pid if the table edited is the content table.
00216                                                 }
00217                                                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00218                                         }
00219                                 }
00220                         }
00221                 }
00222         }
00223 
00237         function renderRecord($table, $id, $pid, $row)  {
00238                 global $TCA;
00239 
00240                         // Init:
00241                 $uniqueItemRef = $table.'_'.$id;
00242                 t3lib_div::loadTCA($table);
00243 
00244                         // Fetches the true PAGE TSconfig pid to use later, if needed. (Until now, only for the RTE, but later..., who knows?)
00245                 list($tscPID)=t3lib_BEfunc::getTSCpid($table,$id,$pid);
00246                 $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($table,array_merge($row,array('uid'=>$id,'pid'=>$pid)));
00247 
00248                         // If the record has not already been loaded (in which case we DON'T do it again)...
00249                 if (!$this->regTableItems[$uniqueItemRef])      {
00250                         $this->regTableItems[$uniqueItemRef] = 1;       // set "loaded" flag.
00251 
00252                                 // If the table is pages, set the previous page id internally.
00253                         if ($table == 'pages')  {$this->prevPageID = $id;}
00254 
00255                         $this->regTableItems_data[$uniqueItemRef] = $this->renderRecordRaw($table, $id, $pid, $row, $TSconfig, $tscPID);
00256 
00257                                 // 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!
00258                         if ($this->addRawData && is_array($row) && is_array($this->regTableItems_data[$uniqueItemRef])) {
00259                                 $this->regTableItems_data[$uniqueItemRef] = array_merge($row, $this->regTableItems_data[$uniqueItemRef]);
00260                         }
00261                 }
00262         }
00263 
00264 
00265 
00281         function renderRecordRaw($table, $id, $pid, $row, $TSconfig='', $tscPID=0)      {
00282                 global $TCA;
00283 
00284                 if(!is_array($TSconfig)) {
00285                         $TSconfig = array();
00286                 }
00287 
00288                         // Create blank accumulation array:
00289                 $totalRecordContent=array();
00290 
00291                         // Traverse the configured columns for the table (TCA):
00292                         // For each column configured, we will perform processing if needed based on the type (eg. for "group" and "select" types this is needed)
00293                 t3lib_div::loadTCA($table);
00294                 $copyOfColumns = $TCA[$table]['columns'];
00295                 foreach($copyOfColumns as $field => $fieldConfig)       {
00296                                 // Set $data variable for the field, either inputted value from $row - or if not found, the default value as defined in the "config" array
00297                         if (isset($row[$field]))        {
00298                                 $data = $row[$field];
00299                         } else {
00300                                 $data = $fieldConfig['config']['default'];
00301                         }
00302 
00303                         $data = $this->renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field);
00304 
00305                                 // Set the field in the accumulation array IF the $data variabel is set:
00306                         $totalRecordContent[$field] = isset($data) ? $data : '';
00307                 }
00308 
00309                         // 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).
00310                         // For instance this could be processing instructions for the Rich Text Editor.
00311                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$totalRecordContent);
00312                 if (is_array($types_fieldConfig))       {
00313                         $totalRecordContent = $this->renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid);
00314                 }
00315 
00316                         // Register items, mostly for external use (overriding the regItem() function)
00317                 foreach($totalRecordContent as $field => $data) {
00318                         $this->regItem($table,$id,$field,$data);
00319                 }
00320 
00321                         // Finally, store the result:
00322                 reset($totalRecordContent);
00323 
00324                 return $totalRecordContent;
00325 
00326         }
00327 
00339         function renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00340                 switch((string)$fieldConfig['config']['type'])  {
00341                         case 'group':
00342                                 $data = $this->renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00343                         break;
00344                         case 'select':
00345                                 $data = $this->renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00346                         break;
00347                         case 'flex':
00348                                 $data = $this->renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00349                         break;
00350                         case 'inline':
00351                                 $data = $this->renderRecord_inlineProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00352                         break;
00353                 }
00354 
00355                 return $data;
00356         }
00357 
00371         function renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field)        {
00372                 switch ($fieldConfig['config']['internal_type'])        {
00373                         case 'file':
00374                                         // Init array used to accumulate the files:
00375                                 $dataAcc=array();
00376 
00377                                         // Now, load the files into the $dataAcc array, whether stored by MM or as a list of filenames:
00378                                 if ($fieldConfig['config']['MM'])       {
00379                                         $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00380                                         $loadDB->start('', 'files', $fieldConfig['config']['MM'], $row['uid']); // Setting dummy startup
00381 
00382                                         foreach($loadDB->itemArray as $value)   {
00383                                                 if ($value['id'])       {
00384                                                         $dataAcc[]=rawurlencode($value['id']).'|'.rawurlencode($value['id']);
00385                                                 }
00386                                         }
00387                                 } else {
00388                                         $fileList = t3lib_div::trimExplode(',',$data,1);
00389                                         foreach($fileList as $value)    {
00390                                                 if ($value)     {
00391                                                         $dataAcc[]=rawurlencode($value).'|'.rawurlencode($value);
00392                                                 }
00393                                         }
00394                                 }
00395                                         // Implode the accumulation array to a comma separated string:
00396                                 $data = implode(',',$dataAcc);
00397                         break;
00398                         case 'db':
00399                                 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00400                                 $loadDB->start($data, $fieldConfig['config']['allowed'], $fieldConfig['config']['MM'], $row['uid'], $table, $fieldConfig['config']);
00401                                 $loadDB->getFromDB();
00402                                 $data = $loadDB->readyForInterface();
00403                         break;
00404                 }
00405 
00406                 return $data;
00407         }
00408 
00422         function renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00423                 global $TCA;
00424 
00425                         // Initialize:
00426                 $elements = t3lib_div::trimExplode(',',$data,1);        // Current data set.
00427                 $dataAcc=array();       // New data set, ready for interface (list of values, rawurlencoded)
00428 
00429                         // For list selectors (multi-value):
00430                 if (intval($fieldConfig['config']['maxitems'])>1)       {
00431 
00432                                 // Add regular elements:
00433                         if (is_array($fieldConfig['config']['items']))  {
00434                                 $fieldConfig['config']['items'] = $this->procesItemArray($fieldConfig['config']['items'], $fieldConfig['config'], $TSconfig[$field], $table, $row, $field);
00435                                 foreach($fieldConfig['config']['items'] as $pvpv)       {
00436                                         foreach($elements as $eKey => $value)   {
00437                                                 if (!strcmp($value,$pvpv[1]))   {
00438                                                         $dataAcc[$eKey]=rawurlencode($pvpv[1]).'|'.rawurlencode($this->sL($pvpv[0]));
00439                                                 }
00440                                         }
00441                                 }
00442                         }
00443 
00444                                 // Add "special"
00445                         if ($fieldConfig['config']['special'])  {
00446                                 $dataAcc = $this->selectAddSpecial($dataAcc, $elements, $fieldConfig['config']['special']);
00447                         }
00448 
00449                                 // Add "foreign table" stuff:
00450                         if ($TCA[$fieldConfig['config']['foreign_table']])      {
00451                                 $dataAcc = $this->selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row, $table);
00452                         }
00453 
00454                                 // Always keep the native order for display in interface:
00455                         ksort($dataAcc);
00456                 } else {        // Normal, <= 1 -> value without title on it
00457                         if ($TCA[$fieldConfig['config']['foreign_table']])      {
00458                                 // Getting the data
00459                                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table);
00460 
00461                                 if (!count($dataIds))   $dataIds = array(0);
00462                                 $dataAcc[]=$dataIds[0];
00463                         } else {
00464                                 $dataAcc[]=$elements[0];
00465                         }
00466                 }
00467 
00468                 return implode(',',$dataAcc);
00469         }
00470 
00485         function renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field) {
00486                 global $TCA;
00487 
00488                         // Convert the XML data to PHP array:
00489                 $currentValueArray = t3lib_div::xml2array($data);
00490                 if (is_array($currentValueArray))       {
00491 
00492                                 // Get current value array:
00493                         $dataStructArray = t3lib_BEfunc::getFlexFormDS($fieldConfig['config'],$row,$table);
00494                         if (is_array($dataStructArray)) {
00495                                 $currentValueArray['data'] = $this->renderRecord_flexProc_procInData($currentValueArray['data'],$dataStructArray,array($data,$fieldConfig,$TSconfig,$table,$row,$field));
00496 
00497                                 $flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
00498                                 $data = $flexObj->flexArray2Xml($currentValueArray, TRUE);
00499                         }
00500                 }
00501 
00502                 return $data;
00503         }
00504 
00516         function renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid)     {
00517                 foreach($types_fieldConfig as $vconf)   {
00518 
00519                                 // Find file to write to, if configured:
00520                         $eFile = t3lib_parsehtml_proc::evalWriteFile($vconf['spec']['static_write'],$totalRecordContent);
00521 
00522                                 // Write file configuration:
00523                         if (is_array($eFile))   {
00524                                 if ($eFile['loadFromFileField'] && $totalRecordContent[$eFile['loadFromFileField']])    {
00525                                                 // Read the external file, and insert the content between the ###TYPO3_STATICFILE_EDIT### markers:
00526                                         $SW_fileContent = t3lib_div::getUrl($eFile['editFile']);
00527                                         $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
00528                                         $parseHTML->init('','');
00529 
00530                                         $totalRecordContent[$vconf['field']] = $parseHTML->getSubpart(
00531                                                 $SW_fileContent,
00532                                                 $eFile['markerField']&&trim($totalRecordContent[$eFile['markerField']])
00533                                                         ? trim($totalRecordContent[$eFile['markerField']])
00534                                                         : '###TYPO3_STATICFILE_EDIT###'
00535                                         );
00536                                 }
00537                         }
00538                 }
00539 
00540                 return $totalRecordContent;
00541         }
00542 
00557         function renderRecord_inlineProc($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00558                 global $TCA;
00559 
00560                         // Initialize:
00561                 $elements = t3lib_div::trimExplode(',',$data);  // Current data set.
00562                 $dataAcc=array();       // New data set, ready for interface (list of values, rawurlencoded)
00563 
00564                         // At this point all records that CAN be selected is found in $recordList
00565                         // Now, get the data from loadDBgroup based on the input list of values.
00566                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table);
00567 
00568                         // After this we can traverse the loadDBgroup values and match values with the list of possible values in $recordList:
00569                 foreach($dataIds as $theId)     {
00570                         if ($fieldConfig['config']['MM'] || $fieldConfig['config']['foreign_field'])    {
00571                                 $dataAcc[]=$theId;
00572                         } else {
00573                                 foreach($elements as $eKey => $value)   {
00574                                         if (!strcmp($theId,$value))     {
00575                                                 $dataAcc[$eKey]=$theId;
00576                                         }
00577                                 }
00578                         }
00579                 }
00580 
00581                 return implode(',',$dataAcc);
00582         }
00583 
00584 
00585 
00586 
00587 
00588 
00589 
00590 
00591 
00592 
00593 
00594 
00595         /***********************************************
00596          *
00597          * FlexForm processing functions
00598          *
00599          ***********************************************/
00600 
00611         function renderRecord_flexProc_procInData($dataPart,$dataStructArray,$pParams)  {
00612                 if (is_array($dataPart))        {
00613                         foreach($dataPart as $sKey => $sheetDef)        {
00614                                 list ($dataStruct,$actualSheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sKey);
00615 
00616                                 if (is_array($dataStruct) && $actualSheet==$sKey && is_array($sheetDef))        {
00617                                         foreach($sheetDef as $lKey => $lData)   {
00618                                                 $this->renderRecord_flexProc_procInData_travDS(
00619                                                         $dataPart[$sKey][$lKey],
00620                                                         $dataStruct['ROOT']['el'],
00621                                                         $pParams
00622                                                 );
00623                                         }
00624                                 }
00625                         }
00626                 }
00627 
00628                 return $dataPart;
00629         }
00630 
00640         function renderRecord_flexProc_procInData_travDS(&$dataValues,$DSelements,$pParams)             {
00641                 if (is_array($DSelements))      {
00642 
00643                                 // For each DS element:
00644                         foreach($DSelements as $key => $dsConf) {
00645 
00646                                                 // Array/Section:
00647                                 if ($DSelements[$key]['type']=='array') {
00648                                         if (is_array($dataValues[$key]['el']))  {
00649                                                 if ($DSelements[$key]['section'])       {
00650                                                         foreach($dataValues[$key]['el'] as $ik => $el)  {
00651                                                                 $theKey = key($el);
00652                                                                 if (is_array($dataValues[$key]['el'][$ik][$theKey]['el']))      {
00653                                                                         $this->renderRecord_flexProc_procInData_travDS(
00654                                                                                         $dataValues[$key]['el'][$ik][$theKey]['el'],
00655                                                                                         $DSelements[$key]['el'][$theKey]['el'],
00656                                                                                         $pParams
00657                                                                                 );
00658                                                                 }
00659                                                         }
00660                                                 } else {
00661                                                         if (!isset($dataValues[$key]['el']))    $dataValues[$key]['el']=array();
00662                                                         $this->renderRecord_flexProc_procInData_travDS(
00663                                                                         $dataValues[$key]['el'],
00664                                                                         $DSelements[$key]['el'],
00665                                                                         $pParams
00666                                                                 );
00667                                                 }
00668                                         }
00669                                 } else {
00670                                         if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key]))     {
00671                                                 foreach($dataValues[$key] as $vKey => $data)    {
00672 
00673                                                                 // $data,$fieldConfig,$TSconfig,$table,$row,$field
00674                                                         list(,,$CVTSconfig,$CVtable,$CVrow,$CVfield) = $pParams;
00675 
00676                                                                 // Set default value:
00677                                                         if (!isset($dataValues[$key][$vKey]))   {
00678                                                                 $dataValues[$key][$vKey] = $dsConf['TCEforms']['config']['default'];
00679                                                         }
00680 
00681                                                                 // Process value:
00682                                                         $dataValues[$key][$vKey] = $this->renderRecord_SW($dataValues[$key][$vKey],$dsConf['TCEforms'],$CVTSconfig,$CVtable,$CVrow,'');
00683                                                 }
00684                                         }
00685                                 }
00686                         }
00687                 }
00688         }
00689 
00690 
00691 
00692 
00693 
00694 
00695 
00696 
00697 
00698 
00699 
00700 
00701         /***********************************************
00702          *
00703          * Selector box processing functions
00704          *
00705          ***********************************************/
00706 
00717         function selectAddSpecial($dataAcc, $elements, $specialKey)     {
00718                 global $TCA;
00719 
00720                         // Special select types:
00721                 switch ((string)$specialKey)    {
00722                         case 'tables':          // Listing all tables from $TCA:
00723                                 $tNames = array_keys($TCA);
00724                                 foreach($tNames as $tableName)  {
00725                                         foreach($elements as $eKey => $value)   {
00726                                                 if (!strcmp($tableName,$value)) {
00727                                                         $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($this->sL($TCA[$value]['ctrl']['title']));
00728                                                 }
00729                                         }
00730                                 }
00731                         break;
00732                         case 'pagetypes':       // Listing all page types (doktype)
00733                                 $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
00734                                 if (is_array($theTypes))        {
00735                                         foreach($theTypes as $theTypesArrays)   {
00736                                                 foreach($elements as $eKey => $value)   {
00737                                                         if (!strcmp($theTypesArrays[1],$value)) {
00738                                                                 $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($this->sL($theTypesArrays[0]));
00739                                                         }
00740                                                 }
00741                                         }
00742                                 }
00743                         break;
00744                         case 'exclude':         // Listing exclude fields.
00745                                 $theExcludeFields = t3lib_BEfunc::getExcludeFields();
00746 
00747                                 if (is_array($theExcludeFields))        {
00748                                         foreach($theExcludeFields as $theExcludeFieldsArrays)   {
00749                                                 foreach($elements as $eKey => $value)   {
00750                                                         if (!strcmp($theExcludeFieldsArrays[1],$value)) {
00751                                                                 $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode(ereg_replace(':$','',$theExcludeFieldsArrays[0]));
00752                                                         }
00753                                                 }
00754                                         }
00755                                 }
00756                         break;
00757                         case 'explicitValues':
00758                                 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
00759 
00760                                 foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
00761                                         if (is_array($theTypeArrays['items']))  {
00762                                                 foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
00763                                                         foreach($elements as $eKey => $value)   {
00764                                                                 if (!strcmp($tableFieldKey.':'.$itemValue.':'.$itemContent[0], $value)) {
00765                                                                         $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode('['.$itemContent[2].'] '.$itemContent[1]);
00766                                                                 }
00767                                                         }
00768                                                 }
00769                                         }
00770                                 }
00771                         break;
00772                         case 'languages':
00773                                 $theLangs = t3lib_BEfunc::getSystemLanguages();
00774                                 foreach($theLangs as $lCfg)     {
00775                                         foreach($elements as $eKey => $value)   {
00776                                                 if (!strcmp($lCfg[1], $value))  {
00777                                                         $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode($lCfg[0]);
00778                                                 }
00779                                         }
00780                                 }
00781                         break;
00782                         case 'custom':
00783                                 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
00784 
00785                                 if (is_array($customOptions))   {
00786                                         foreach($customOptions as $coKey => $coValue) {
00787                                                 if (is_array($coValue['items']))        {
00788                                                                 // Traverse items:
00789                                                         foreach($coValue['items'] as $itemKey => $itemCfg)      {
00790                                                                 foreach($elements as $eKey => $value)   {
00791                                                                         if (!strcmp($coKey.':'.$itemKey, $value))       {
00792                                                                                 $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode($this->sL($itemCfg[0]));
00793                                                                         }
00794                                                                 }
00795                                                         }
00796                                                 }
00797                                         }
00798                                 }
00799                         break;
00800                         case 'modListGroup':    // Listing modules for GROUPS
00801                         case 'modListUser':             // Listing modules for USERS:
00802                                 if (!$this->loadModules)        {
00803                                         $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00804                                         $this->loadModules->load($GLOBALS['TBE_MODULES']);
00805                                 }
00806                                 $modList = ($specialKey=='modListUser') ? $this->loadModules->modListUser : $this->loadModules->modListGroup;
00807 
00808                                 foreach($modList as $theModName)        {
00809                                         foreach($elements as $eKey => $value)   {
00810                                                 $label = '';
00811                                                         // Add label for main module:
00812                                                 $pp = explode('_',$value);
00813                                                 if (count($pp)>1)       $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
00814                                                         // Add modules own label now:
00815                                                 $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
00816 
00817                                                 if (!strcmp($theModName,$value))        {
00818                                                         $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($label);
00819                                                 }
00820                                         }
00821                                 }
00822                         break;
00823                 }
00824 
00825                 return $dataAcc;
00826         }
00827 
00842         function selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row, $table)   {
00843                 global $TCA;
00844 
00845                         // Init:
00846                 $recordList = Array();
00847 
00848                         // foreign_table
00849                 $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig,$field,$TSconfig);
00850                 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres))        {
00851                         $recordList[$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['foreign_table'],$subrow);
00852                 }
00853 
00854                         // neg_foreign_table
00855                 if (is_array($TCA[$fieldConfig['config']['neg_foreign_table']]))        {
00856                         $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig,$field,$TSconfig,'neg_');
00857                         while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres))        {
00858                                 $recordList[-$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['neg_foreign_table'],$subrow);
00859                         }
00860                 }
00861 
00862                         // At this point all records that CAN be selected is found in $recordList
00863                         // Now, get the data from loadDBgroup based on the input list of values.
00864                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table);
00865                 if ($fieldConfig['config']['MM'])       $dataAcc=array();       // Reset, if MM (which cannot bear anything but real relations!)
00866 
00867                         // After this we can traverse the loadDBgroup values and match values with the list of possible values in $recordList:
00868                 foreach($dataIds as $theId)     {
00869                         if (isset($recordList[$theId])) {
00870                                 $lPrefix = $this->sL($fieldConfig['config'][($theId>0?'':'neg_').'foreign_table_prefix']);
00871                                 if ($fieldConfig['config']['MM'] || $fieldConfig['config']['foreign_field'])    {
00872                                         $dataAcc[]=rawurlencode($theId).'|'.rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix.strip_tags($recordList[$theId]),$GLOBALS['BE_USER']->uc['titleLen']));
00873                                 } else {
00874                                         foreach($elements as $eKey => $value)   {
00875                                                 if (!strcmp($theId,$value))     {
00876                                                         $dataAcc[$eKey]=rawurlencode($theId).'|'.rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix.strip_tags($recordList[$theId]),$GLOBALS['BE_USER']->uc['titleLen']));
00877                                                 }
00878                                         }
00879                                 }
00880                         }
00881                 }
00882 
00883                 return $dataAcc;
00884         }
00885 
00896         function getDataIdList($elements, $fieldConfig, $row, $table)   {
00897                 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00898                 $loadDB->registerNonTableValues=$fieldConfig['config']['allowNonIdValues'] ? 1 : 0;
00899                 $loadDB->start(implode(',',$elements),
00900                         $fieldConfig['config']['foreign_table'].','.$fieldConfig['config']['neg_foreign_table'],
00901                         $fieldConfig['config']['MM'],
00902                         $row['uid'],
00903                         $table,
00904                         $fieldConfig['config']
00905                 );
00906 
00907                 $idList = $loadDB->convertPosNeg($loadDB->getValueArray(),$fieldConfig['config']['foreign_table'],$fieldConfig['config']['neg_foreign_table']);
00908 
00909                 return $idList;
00910         }
00911 
00925         function procesItemArray($selItems,$config,$fieldTSConfig,$table,$row,$field)   {
00926                 $selItems = $this->addItems($selItems,$fieldTSConfig['addItems.']);
00927                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$fieldTSConfig['itemsProcFunc.'],$config,$table,$row,$field);
00928                 return $selItems;
00929         }
00930 
00940         function addItems($items,$iArray)       {
00941                 if (is_array($iArray))  {
00942                         foreach($iArray as $value => $label)    {
00943                                 $items[]=array($label,$value);
00944                         }
00945                 }
00946                 return $items;
00947         }
00948 
00962         function procItems($items,$itemsProcFuncTSconfig,$config,$table,$row,$field)    {
00963                 $params=array();
00964                 $params['items'] = &$items;
00965                 $params['config'] = $config;
00966                 $params['TSconfig'] = $itemsProcFuncTSconfig;
00967                 $params['table'] = $table;
00968                 $params['row'] = $row;
00969                 $params['field'] = $field;
00970 
00971                 t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
00972                 return $items;
00973         }
00974 
00975 
00976 
00977 
00978 
00979 
00980 
00981 
00982 
00983         /***********************************************
00984          *
00985          * Helper functions
00986          *
00987          ***********************************************/
00988 
00997         function lockRecord($table, $id, $pid=0)        {
00998                 if ($this->lockRecords) {
00999                         t3lib_BEfunc::lockRecords($table,$id,$pid);
01000                 }
01001         }
01002 
01014         function regItem($table, $id, $field, $content) {
01015         }
01016 
01024         function sL($in)        {
01025                 return $GLOBALS['LANG']->sL($in);
01026         }
01027 }
01028 
01029 
01030 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php'])      {
01031         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php']);
01032 }
01033 ?>

This documentation has been generated automatically from TYPO3 source code using Doxygen and is provided as is by Cast Iron Coding as a courtesy to other TYPO3 developers and users. Please consider Cast Iron Coding — a full-service web development agency in Portland, Oregon specializing in TYPO3 extension development — for all of your TYPO3 development and consulting needs!