Documentation TYPO3 par Ameos

class.t3lib_transferdata.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
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 
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                                                         $this->renderRecord($table, $id, $row['pid'], $row);
00200                                                         $contentTable = $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'];
00201                                                         $this->lockRecord($table, $id, $contentTable==$table?$row['pid']:0);    // Locking the pid if the table edited is the content table.
00202                                                 }
00203                                                 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00204                                         }
00205                                 }
00206                         }
00207                 }
00208         }
00209 
00223         function renderRecord($table, $id, $pid, $row)  {
00224                 global $TCA;
00225 
00226                         // Init:
00227                 $uniqueItemRef = $table.'_'.$id;
00228                 t3lib_div::loadTCA($table);
00229 
00230                         // Fetches the true PAGE TSconfig pid to use later, if needed. (Until now, only for the RTE, but later..., who knows?)
00231                 list($tscPID)=t3lib_BEfunc::getTSCpid($table,$id,$pid);
00232                 $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($table,array_merge($row,array('uid'=>$id,'pid'=>$pid)));
00233 
00234                         // If the record has not already been loaded (in which case we DON'T do it again)...
00235                 if (!$this->regTableItems[$uniqueItemRef])      {
00236                         $this->regTableItems[$uniqueItemRef] = 1;       // set "loaded" flag.
00237 
00238                                 // If the table is pages, set the previous page id internally.
00239                         if ($table == 'pages')  {$this->prevPageID = $id;}
00240 
00241                         $this->regTableItems_data[$uniqueItemRef] = $this->renderRecordRaw($table, $id, $pid, $row, $TSconfig, $tscPID);
00242 
00243                                 // 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!
00244                         if ($this->addRawData && is_array($row) && is_array($this->regTableItems_data[$uniqueItemRef])) {
00245                                 $this->regTableItems_data[$uniqueItemRef] = array_merge($row, $this->regTableItems_data[$uniqueItemRef]);
00246                         }
00247                 }
00248         }
00249 
00250 
00251 
00267         function renderRecordRaw($table, $id, $pid, $row, $TSconfig='', $tscPID=0)      {
00268                 global $TCA;
00269 
00270                 if(!is_array($TSconfig)) {
00271                         $TSconfig = array();
00272                 }
00273 
00274                         // Create blank accumulation array:
00275                 $totalRecordContent=array();
00276 
00277                         // Traverse the configured columns for the table (TCA):
00278                         // For each column configured, we will perform processing if needed based on the type (eg. for "group" and "select" types this is needed)
00279                 t3lib_div::loadTCA($table);
00280                 $copyOfColumns = $TCA[$table]['columns'];
00281                 foreach($copyOfColumns as $field => $fieldConfig)       {
00282                                 // Set $data variable for the field, either inputted value from $row - or if not found, the default value as defined in the "config" array
00283                         if (isset($row[$field]))        {
00284                                 $data = $row[$field];
00285                         } else {
00286                                 $data = $fieldConfig['config']['default'];
00287                         }
00288 
00289                         $data = $this->renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field);
00290 
00291                                 // Set the field in the accumulation array IF the $data variabel is set:
00292                         $totalRecordContent[$field] = isset($data) ? $data : '';
00293                 }
00294 
00295                         // 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).
00296                         // For instance this could be processing instructions for the Rich Text Editor.
00297                 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$totalRecordContent);
00298                 if (is_array($types_fieldConfig))       {
00299                         $totalRecordContent = $this->renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid);
00300                 }
00301 
00302                         // Register items, mostly for external use (overriding the regItem() function)
00303                 foreach($totalRecordContent as $field => $data) {
00304                         $this->regItem($table,$id,$field,$data);
00305                 }
00306 
00307                         // Finally, store the result:
00308                 reset($totalRecordContent);
00309 
00310                 return $totalRecordContent;
00311 
00312         }
00313 
00325         function renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00326 
00327                 switch((string)$fieldConfig['config']['type'])  {
00328                         case 'group':
00329                                 $data = $this->renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00330                         break;
00331                         case 'select':
00332                                 $data = $this->renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00333                         break;
00334                         case 'flex':
00335                                 $data = $this->renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field);
00336                         break;
00337                 }
00338 
00339                 return $data;
00340         }
00341 
00355         function renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field)        {
00356                 switch ($fieldConfig['config']['internal_type'])        {
00357                         case 'file':
00358                                         // Init array used to accumulate the files:
00359                                 $dataAcc=array();
00360 
00361                                         // Now, load the files into the $dataAcc array, whether stored by MM or as a list of filenames:
00362                                 if ($fieldConfig['config']['MM'])       {
00363                                         $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00364                                         $loadDB->start('', 'files', $fieldConfig['config']['MM'], $row['uid']); // Setting dummy startup
00365 
00366                                         foreach($loadDB->itemArray as $value)   {
00367                                                 if ($value['id'])       {
00368                                                         $dataAcc[]=rawurlencode($value['id']).'|'.rawurlencode($value['id']);
00369                                                 }
00370                                         }
00371                                 } else {
00372                                         $fileList = t3lib_div::trimExplode(',',$data,1);
00373                                         foreach($fileList as $value)    {
00374                                                 if ($value)     {
00375                                                         $dataAcc[]=rawurlencode($value).'|'.rawurlencode($value);
00376                                                 }
00377                                         }
00378                                 }
00379                                         // Implode the accumulation array to a comma separated string:
00380                                 $data = implode(',',$dataAcc);
00381                         break;
00382                         case 'db':
00383                                 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00384                                 $loadDB->start($data, $fieldConfig['config']['allowed'], $fieldConfig['config']['MM'], $row['uid']);
00385                                 $loadDB->getFromDB();
00386                                 $data = $loadDB->readyForInterface();
00387                         break;
00388                 }
00389 
00390                 return $data;
00391         }
00392 
00406         function renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field)       {
00407                 global $TCA;
00408 
00409                         // Initialize:
00410                 $elements = t3lib_div::trimExplode(',',$data,1);        // Current data set.
00411                 $dataAcc=array();       // New data set, ready for interface (list of values, rawurlencoded)
00412 
00413                         // For list selectors (multi-value):
00414                 if (intval($fieldConfig['config']['maxitems'])>1)       {
00415 
00416                                 // Add regular elements:
00417                         if (is_array($fieldConfig['config']['items']))  {
00418                                 $fieldConfig['config']['items'] = $this->procesItemArray($fieldConfig['config']['items'], $fieldConfig['config'], $TSconfig[$field], $table, $row, $field);
00419                                 foreach($fieldConfig['config']['items'] as $pvpv)       {
00420                                         foreach($elements as $eKey => $value)   {
00421                                                 if (!strcmp($value,$pvpv[1]))   {
00422                                                         $dataAcc[$eKey]=rawurlencode($pvpv[1]).'|'.rawurlencode($pvpv[0]);
00423                                                 }
00424                                         }
00425                                 }
00426                         }
00427 
00428                                 // Add "special"
00429                         if ($fieldConfig['config']['special'])  {
00430                                 $dataAcc = $this->selectAddSpecial($dataAcc, $elements, $fieldConfig['config']['special']);
00431                         }
00432 
00433                                 // Add "foreign table" stuff:
00434                         if ($TCA[$fieldConfig['config']['foreign_table']])      {
00435                                 $dataAcc = $this->selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row);
00436                         }
00437 
00438                                 // Always keep the native order for display in interface:
00439                         ksort($dataAcc);
00440                 } else {        // Normal, <= 1 -> value without title on it
00441                         if ($TCA[$fieldConfig['config']['foreign_table']])      {
00442                                 // Getting the data
00443                                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row);
00444 
00445                                 if (!count($dataIds))   $dataIds = array(0);
00446                                 $dataAcc[]=$dataIds[0];
00447                         } else {
00448                                 $dataAcc[]=$elements[0];
00449                         }
00450                 }
00451 
00452                 return implode(',',$dataAcc);
00453         }
00454 
00469         function renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field) {
00470                 global $TCA;
00471 
00472                         // Convert the XML data to PHP array:
00473                 $currentValueArray = t3lib_div::xml2array($data);
00474                 if (is_array($currentValueArray))       {
00475 
00476                                 // Get current value array:
00477                         $dataStructArray = t3lib_BEfunc::getFlexFormDS($fieldConfig['config'],$row,$table);
00478                         if (is_array($dataStructArray)) {
00479                                 $currentValueArray['data'] = $this->renderRecord_flexProc_procInData($currentValueArray['data'],$dataStructArray,array($data,$fieldConfig,$TSconfig,$table,$row,$field));
00480                                 $data = t3lib_div::array2xml($currentValueArray);
00481                         }
00482                 }
00483 
00484                 return $data;
00485         }
00486 
00498         function renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid)     {
00499                 foreach($types_fieldConfig as $vconf)   {
00500 
00501                                 // Find file to write to, if configured:
00502                         $eFile = t3lib_parsehtml_proc::evalWriteFile($vconf['spec']['static_write'],$totalRecordContent);
00503 
00504                                 // Write file configuration:
00505                         if (is_array($eFile))   {
00506                                 if ($eFile['loadFromFileField'] && $totalRecordContent[$eFile['loadFromFileField']])    {
00507                                                 // Read the external file, and insert the content between the ###TYPO3_STATICFILE_EDIT### markers:
00508                                         $SW_fileContent = t3lib_div::getUrl($eFile['editFile']);
00509                                         $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
00510                                         $parseHTML->init('','');
00511 
00512                                         $totalRecordContent[$vconf['field']] = $parseHTML->getSubpart(
00513                                                 $SW_fileContent,
00514                                                 $eFile['markerField']&&trim($totalRecordContent[$eFile['markerField']])
00515                                                         ? trim($totalRecordContent[$eFile['markerField']])
00516                                                         : '###TYPO3_STATICFILE_EDIT###'
00517                                         );
00518                                 }
00519                         }
00520                 }
00521 
00522                 return $totalRecordContent;
00523         }
00524 
00525 
00526 
00527 
00528 
00529 
00530 
00531 
00532 
00533 
00534 
00535 
00536 
00537 
00538         /***********************************************
00539          *
00540          * FlexForm processing functions
00541          *
00542          ***********************************************/
00543 
00554         function renderRecord_flexProc_procInData($dataPart,$dataStructArray,$pParams)  {
00555                 if (is_array($dataPart))        {
00556                         foreach($dataPart as $sKey => $sheetDef)        {
00557                                 list ($dataStruct,$actualSheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sKey);
00558 
00559                                 if (is_array($dataStruct) && $actualSheet==$sKey && is_array($sheetDef))        {
00560                                         foreach($sheetDef as $lKey => $lData)   {
00561                                                 $this->renderRecord_flexProc_procInData_travDS(
00562                                                         $dataPart[$sKey][$lKey],
00563                                                         $dataStruct['ROOT']['el'],
00564                                                         $pParams
00565                                                 );
00566                                         }
00567                                 }
00568                         }
00569                 }
00570 
00571                 return $dataPart;
00572         }
00573 
00583         function renderRecord_flexProc_procInData_travDS(&$dataValues,$DSelements,$pParams)             {
00584                 if (is_array($DSelements))      {
00585 
00586                                 // For each DS element:
00587                         foreach($DSelements as $key => $dsConf) {
00588 
00589                                                 // Array/Section:
00590                                 if ($DSelements[$key]['type']=='array') {
00591                                         if (is_array($dataValues[$key]['el']))  {
00592                                                 if ($DSelements[$key]['section'])       {
00593                                                         foreach($dataValues[$key]['el'] as $ik => $el)  {
00594                                                                 $theKey = key($el);
00595                                                                 if (is_array($dataValues[$key]['el'][$ik][$theKey]['el']))      {
00596                                                                         $this->renderRecord_flexProc_procInData_travDS(
00597                                                                                         $dataValues[$key]['el'][$ik][$theKey]['el'],
00598                                                                                         $DSelements[$key]['el'][$theKey]['el'],
00599                                                                                         $pParams
00600                                                                                 );
00601                                                                 }
00602                                                         }
00603                                                 } else {
00604                                                         if (!isset($dataValues[$key]['el']))    $dataValues[$key]['el']=array();
00605                                                         $this->renderRecord_flexProc_procInData_travDS(
00606                                                                         $dataValues[$key]['el'],
00607                                                                         $DSelements[$key]['el'],
00608                                                                         $pParams
00609                                                                 );
00610                                                 }
00611                                         }
00612                                 } else {
00613                                         if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key]))     {
00614                                                 foreach($dataValues[$key] as $vKey => $data)    {
00615 
00616                                                                 // $data,$fieldConfig,$TSconfig,$table,$row,$field
00617                                                         list(,,$CVTSconfig,$CVtable,$CVrow,$CVfield) = $pParams;
00618 ;
00619                                                                 // Set default value:
00620                                                         if (!isset($dataValues[$key][$vKey]))   {
00621                                                                 $dataValues[$key][$vKey] = $dsConf['TCEforms']['config']['default'];
00622                                                         }
00623 
00624                                                                 // Process value:
00625                                                         $dataValues[$key][$vKey] = $this->renderRecord_SW($dataValues[$key][$vKey],$dsConf['TCEforms'],$CVTSconfig,$CVtable,$CVrow,'');
00626                                                 }
00627                                         }
00628                                 }
00629                         }
00630                 }
00631         }
00632 
00633 
00634 
00635 
00636 
00637 
00638 
00639 
00640 
00641 
00642 
00643 
00644         /***********************************************
00645          *
00646          * Selector box processing functions
00647          *
00648          ***********************************************/
00649 
00660         function selectAddSpecial($dataAcc, $elements, $specialKey)     {
00661                 global $TCA;
00662 
00663                         // Special select types:
00664                 switch ((string)$specialKey)    {
00665                         case 'tables':          // Listing all tables from $TCA:
00666                                 $tNames = array_keys($TCA);
00667                                 foreach($tNames as $tableName)  {
00668                                         foreach($elements as $eKey => $value)   {
00669                                                 if (!strcmp($tableName,$value)) {
00670                                                         $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($this->sL($TCA[$value]['ctrl']['title']));
00671                                                 }
00672                                         }
00673                                 }
00674                         break;
00675                         case 'pagetypes':       // Listing all page types (doktype)
00676                                 $theTypes = $TCA['pages']['columns']['doktype']['config']['items'];
00677                                 if (is_array($theTypes))        {
00678                                         foreach($theTypes as $theTypesArrays)   {
00679                                                 foreach($elements as $eKey => $value)   {
00680                                                         if (!strcmp($theTypesArrays[1],$value)) {
00681                                                                 $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($this->sL($theTypesArrays[0]));
00682                                                         }
00683                                                 }
00684                                         }
00685                                 }
00686                         break;
00687                         case 'exclude':         // Listing exclude fields.
00688                                 $theExcludeFields = t3lib_BEfunc::getExcludeFields();
00689 
00690                                 if (is_array($theExcludeFields))        {
00691                                         foreach($theExcludeFields as $theExcludeFieldsArrays)   {
00692                                                 foreach($elements as $eKey => $value)   {
00693                                                         if (!strcmp($theExcludeFieldsArrays[1],$value)) {
00694                                                                 $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode(ereg_replace(':$','',$theExcludeFieldsArrays[0]));
00695                                                         }
00696                                                 }
00697                                         }
00698                                 }
00699                         break;
00700                         case 'explicitValues':
00701                                 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
00702 
00703                                 foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
00704                                         if (is_array($theTypeArrays['items']))  {
00705                                                 foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
00706                                                         foreach($elements as $eKey => $value)   {
00707                                                                 if (!strcmp($tableFieldKey.':'.$itemValue.':'.$itemContent[0], $value)) {
00708                                                                         $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode('['.$itemContent[2].'] '.$itemContent[1]);
00709                                                                 }
00710                                                         }
00711                                                 }
00712                                         }
00713                                 }
00714                         break;
00715                         case 'languages':
00716                                 $theLangs = t3lib_BEfunc::getSystemLanguages();
00717                                 foreach($theLangs as $lCfg)     {
00718                                         foreach($elements as $eKey => $value)   {
00719                                                 if (!strcmp($lCfg[1], $value))  {
00720                                                         $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode($lCfg[0]);
00721                                                 }
00722                                         }
00723                                 }
00724                         break;
00725                         case 'custom':
00726                                 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
00727 
00728                                 if (is_array($customOptions))   {
00729                                         foreach($customOptions as $coKey => $coValue) {
00730                                                 if (is_array($coValue['items']))        {
00731                                                                 // Traverse items:
00732                                                         foreach($coValue['items'] as $itemKey => $itemCfg)      {
00733                                                                 foreach($elements as $eKey => $value)   {
00734                                                                         if (!strcmp($coKey.':'.$itemKey, $value))       {
00735                                                                                 $dataAcc[$eKey] = rawurlencode($value).'|'.rawurlencode($GLOBALS['LANG']->sl($itemCfg[0]));
00736                                                                         }
00737                                                                 }
00738                                                         }
00739                                                 }
00740                                         }
00741                                 }
00742                         break;
00743                         case 'modListGroup':    // Listing modules for GROUPS
00744                         case 'modListUser':             // Listing modules for USERS:
00745                                 if (!$this->loadModules)        {
00746                                         $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00747                                         $this->loadModules->load($GLOBALS['TBE_MODULES']);
00748                                 }
00749                                 $modList = ($specialKey=='modListUser') ? $this->loadModules->modListUser : $this->loadModules->modListGroup;
00750 
00751                                 foreach($modList as $theModName)        {
00752                                         foreach($elements as $eKey => $value)   {
00753                                                 $label = '';
00754                                                         // Add label for main module:
00755                                                 $pp = explode('_',$value);
00756                                                 if (count($pp)>1)       $label.=$GLOBALS['LANG']->moduleLabels['tabs'][$pp[0].'_tab'].'>';
00757                                                         // Add modules own label now:
00758                                                 $label.= $GLOBALS['LANG']->moduleLabels['tabs'][$value.'_tab'];
00759 
00760                                                 if (!strcmp($theModName,$value))        {
00761                                                         $dataAcc[$eKey]=rawurlencode($value).'|'.rawurlencode($label);
00762                                                 }
00763                                         }
00764                                 }
00765                         break;
00766                 }
00767 
00768                 return $dataAcc;
00769         }
00770 
00784         function selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row)   {
00785                 global $TCA;
00786 
00787                         // Init:
00788                 $recordList = Array();
00789 
00790                         // foreign_table
00791                 $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig,$field,$TSconfig);
00792                 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres))        {
00793                         $recordList[$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['foreign_table'],$subrow);
00794                 }
00795 
00796                         // neg_foreign_table
00797                 if (is_array($TCA[$fieldConfig['config']['neg_foreign_table']]))        {
00798                         $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig,$field,$TSconfig,'neg_');
00799                         while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres))        {
00800                                 $recordList[-$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['neg_foreign_table'],$subrow);
00801                         }
00802                 }
00803 
00804                         // At this point all records that CAN be selected is found in $recordList
00805                         // Now, get the data from loadDBgroup based on the input list of values.
00806                 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row);
00807                 if ($fieldConfig['config']['MM'])       $dataAcc=array();       // Reset, if MM (which cannot bear anything but real relations!)
00808 
00809                         // After this we can traverse the loadDBgroup values and match values with the list of possible values in $recordList:
00810                 foreach($dataIds as $theId)     {
00811                         if (isset($recordList[$theId])) {
00812                                 $lPrefix = $this->sL($fieldConfig['config'][($theId>0?'':'neg_').'foreign_table_prefix']);
00813                                 if ($fieldConfig['config']['MM'])       {
00814                                         $dataAcc[]=rawurlencode($theId).'|'.rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix.strip_tags($recordList[$theId]),$GLOBALS['BE_USER']->uc['titleLen']));
00815                                 } else {
00816                                         foreach($elements as $eKey => $value)   {
00817                                                 if (!strcmp($theId,$value))     {
00818                                                         $dataAcc[$eKey]=rawurlencode($theId).'|'.rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix.strip_tags($recordList[$theId]),$GLOBALS['BE_USER']->uc['titleLen']));
00819                                                 }
00820                                         }
00821                                 }
00822                         }
00823                 }
00824 
00825                 return $dataAcc;
00826         }
00827 
00837         function getDataIdList($elements, $fieldConfig, $row)   {
00838                 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup');
00839                 $loadDB->registerNonTableValues=$fieldConfig['config']['allowNonIdValues'] ? 1 : 0;
00840                 $loadDB->start(implode(',',$elements), $fieldConfig['config']['foreign_table'].','.$fieldConfig['config']['neg_foreign_table'], $fieldConfig['config']['MM'], $row['uid']);
00841 
00842                 $idList = $loadDB->convertPosNeg($loadDB->getValueArray(),$fieldConfig['config']['foreign_table'],$fieldConfig['config']['neg_foreign_table']);
00843 
00844                 return $idList;
00845         }
00846 
00860         function procesItemArray($selItems,$config,$fieldTSConfig,$table,$row,$field)   {
00861                 $selItems = $this->addItems($selItems,$fieldTSConfig['addItems.']);
00862                 if ($config['itemsProcFunc']) $selItems = $this->procItems($selItems,$fieldTSConfig['itemsProcFunc.'],$config,$table,$row,$field);
00863                 return $selItems;
00864         }
00865 
00875         function addItems($items,$iArray)       {
00876                 if (is_array($iArray))  {
00877                         foreach($iArray as $value => $label)    {
00878                                 $items[]=array($label,$value);
00879                         }
00880                 }
00881                 return $items;
00882         }
00883 
00897         function procItems($items,$itemsProcFuncTSconfig,$config,$table,$row,$field)    {
00898                 $params=array();
00899                 $params['items'] = &$items;
00900                 $params['config'] = $config;
00901                 $params['TSconfig'] = $itemsProcFuncTSconfig;
00902                 $params['table'] = $table;
00903                 $params['row'] = $row;
00904                 $params['field'] = $field;
00905 
00906                 t3lib_div::callUserFunction($config['itemsProcFunc'],$params,$this);
00907                 return $items;
00908         }
00909 
00910 
00911 
00912 
00913 
00914 
00915 
00916 
00917 
00918         /***********************************************
00919          *
00920          * Helper functions
00921          *
00922          ***********************************************/
00923 
00932         function lockRecord($table, $id, $pid=0)        {
00933                 if ($this->lockRecords) {
00934                         t3lib_BEfunc::lockRecords($table,$id,$pid);
00935                 }
00936         }
00937 
00949         function regItem($table, $id, $field, $content) {
00950         }
00951 
00959         function sL($in)        {
00960                 return $GLOBALS['LANG']->sL($in);
00961         }
00962 }
00963 
00964 
00965 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php'])      {
00966         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php']);
00967 }
00968 ?>


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