|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (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 ***************************************************************/ 00027 /** 00028 * Contains class for getting and transforming data for display in backend forms (TCEforms) 00029 * 00030 * $Id: class.t3lib_transferdata.php 10121 2011-01-18 20:15:30Z ohader $ 00031 * Revised for TYPO3 3.6 September/2003 by Kasper Skårhøj 00032 * 00033 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00034 */ 00035 /** 00036 * [CLASS/FUNCTION INDEX of SCRIPT] 00037 * 00038 * 00039 * 00040 * 99: class t3lib_transferData 00041 * 00042 * SECTION: Getting record content, ready for display in TCEforms 00043 * 138: function fetchRecord($table,$idList,$operation) 00044 * 225: function renderRecord($table, $id, $pid, $row) 00045 * 269: function renderRecordRaw($table, $id, $pid, $row, $TSconfig='', $tscPID=0) 00046 * 327: function renderRecord_SW($data,$fieldConfig,$TSconfig,$table,$row,$field) 00047 * 359: function renderRecord_groupProc($data,$fieldConfig,$TSconfig,$table,$row,$field) 00048 * 410: function renderRecord_selectProc($data,$fieldConfig,$TSconfig,$table,$row,$field) 00049 * 473: function renderRecord_flexProc($data,$fieldConfig,$TSconfig,$table,$row,$field) 00050 * 504: function renderRecord_typesProc($totalRecordContent,$types_fieldConfig,$tscPID,$table,$pid) 00051 * 545: function renderRecord_inlineProc($data,$fieldConfig,$TSconfig,$table,$row,$field) 00052 * 00053 * SECTION: FlexForm processing functions 00054 * 632: function renderRecord_flexProc_procInData($dataPart,$dataStructArray,$pParams) 00055 * 661: function renderRecord_flexProc_procInData_travDS(&$dataValues,$DSelements,$pParams) 00056 * 00057 * SECTION: Selector box processing functions 00058 * 738: function selectAddSpecial($dataAcc, $elements, $specialKey) 00059 * 863: function selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row, $table) 00060 * 917: function getDataIdList($elements, $fieldConfig, $row, $table) 00061 * 946: function procesItemArray($selItems,$config,$fieldTSConfig,$table,$row,$field) 00062 * 961: function addItems($items,$iArray) 00063 * 983: function procItems($items,$itemsProcFuncTSconfig,$config,$table,$row,$field) 00064 * 00065 * SECTION: Helper functions 00066 * 1018: function lockRecord($table, $id, $pid=0) 00067 * 1035: function regItem($table, $id, $field, $content) 00068 * 1045: function sL($in) 00069 * 00070 * TOTAL FUNCTIONS: 20 00071 * (This index is automatically created/updated by the extension "extdeveval") 00072 * 00073 */ 00074 00075 00076 /** 00077 * Class for getting and transforming data for display in backend forms (TCEforms) 00078 * 00079 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00080 * @package TYPO3 00081 * @subpackage t3lib 00082 */ 00083 class t3lib_transferData { 00084 // External, static: 00085 var $lockRecords = 0; // If set, the records requested are locked. 00086 var $disableRTE = 0; // Is set externally if RTE is disabled. 00087 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. 00088 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. 00089 var $addRawData = FALSE; // If set, the processed data is overlaid the raw record. 00090 00091 // Internal, dynamic 00092 var $regTableItems = array(); // Used to register, which items are already loaded!! 00093 var $regTableItems_data = array(); // This stores the record data of the loaded records 00094 var $loadModules = ''; // Contains loadModules object, if used. (for reuse internally) 00095 00096 00097 /*********************************************** 00098 * 00099 * Getting record content, ready for display in TCEforms 00100 * 00101 ***********************************************/ 00102 00103 /** 00104 * A function which can be used for load a batch of records from $table into internal memory of this object. 00105 * The function is also used to produce proper default data for new records 00106 * Ultimately the function will call renderRecord() 00107 * 00108 * @param string Table name, must be found in $TCA 00109 * @param string Comma list of id values. If $idList is "prev" then the value from $this->prevPageID is used. NOTICE: If $operation is "new", then negative ids are meant to point to a "previous" record and positive ids are PID values for new records. Otherwise (for existing records that is) it is straight forward table/id pairs. 00110 * @param string If "new", then a record with default data is returned. Further, the $id values are meant to be PID values (or if negative, pointing to a previous record). If NOT new, then the table/ids are just pointing to an existing record! 00111 * @return void 00112 * @see renderRecord() 00113 */ 00114 function fetchRecord($table, $idList, $operation) { 00115 global $TCA; 00116 00117 if ((string) $idList == 'prev') { 00118 $idList = $this->prevPageID; 00119 } 00120 00121 if ($TCA[$table]) { 00122 t3lib_div::loadTCA($table); 00123 00124 // For each ID value (integer) we 00125 $ids = t3lib_div::trimExplode(',', $idList, 1); 00126 foreach ($ids as $id) { 00127 if (strcmp($id, '')) { // If ID is not blank: 00128 00129 // For new records to be created, find default values: 00130 if ($operation == 'new') { 00131 00132 // Default values: 00133 $newRow = array(); // Used to store default values as found here: 00134 00135 // Default values as set in userTS: 00136 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults'); 00137 if (is_array($TCAdefaultOverride[$table . '.'])) { 00138 foreach ($TCAdefaultOverride[$table . '.'] as $theF => $theV) { 00139 if (isset($TCA[$table]['columns'][$theF])) { 00140 $newRow[$theF] = $theV; 00141 } 00142 } 00143 } 00144 00145 if ($id < 0) { 00146 $record = t3lib_beFunc::getRecord($table, abs($id), 'pid'); 00147 $pid = $record['pid']; 00148 unset($record); 00149 } else { 00150 $pid = intval($id); 00151 } 00152 00153 $pageTS = t3lib_beFunc::getPagesTSconfig($pid); 00154 00155 if (isset($pageTS['TCAdefaults.'])) { 00156 $TCAPageTSOverride = $pageTS['TCAdefaults.']; 00157 if (is_array($TCAPageTSOverride[$table . '.'])) { 00158 foreach ($TCAPageTSOverride[$table . '.'] as $theF => $theV) { 00159 if (isset($TCA[$table]['columns'][$theF])) { 00160 $newRow[$theF] = $theV; 00161 } 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 foreach ($fArr as $theF) { 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 00211 /** 00212 * This function performs processing on the input $row array and stores internally a corresponding array which contains processed values, ready to pass on to the TCEforms rendering in the frontend! 00213 * The objective with this function is to prepare the content for handling in TCEforms. 00214 * Default values from outside/TSconfig is added by fetchRecord(). In this function default values from TCA is used if a field is NOT defined in $row. 00215 * The resulting, processed row is stored in $this->regTableItems_data[$uniqueItemRef], where $uniqueItemRef is "[tablename]_[id-value]" 00216 * 00217 * @param string The table name 00218 * @param string The uid value of the record (integer). Can also be a string (NEW-something) if the record is a NEW record. 00219 * @param integer The pid integer. For existing records this is of course the row's "pid" field. For new records it can be either a page id (positive) or a pointer to another record from the SAME table (negative) after which the record should be inserted (or on same page) 00220 * @param array The row of the current record. If NEW record, then it may be loaded with default values (by eg. fetchRecord()). 00221 * @return void 00222 * @see fetchRecord() 00223 */ 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') { 00241 $this->prevPageID = $id; 00242 } 00243 00244 $this->regTableItems_data[$uniqueItemRef] = $this->renderRecordRaw($table, $id, $pid, $row, $TSconfig, $tscPID); 00245 00246 // 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! 00247 if ($this->addRawData && is_array($row) && is_array($this->regTableItems_data[$uniqueItemRef])) { 00248 $this->regTableItems_data[$uniqueItemRef] = array_merge($row, $this->regTableItems_data[$uniqueItemRef]); 00249 } 00250 } 00251 } 00252 00253 00254 /** 00255 * This function performs processing on the input $row array and stores internally a corresponding array which contains processed values, ready to pass on to the TCEforms rendering in the frontend! 00256 * The objective with this function is to prepare the content for handling in TCEforms. 00257 * In opposite to renderRecord() this function do not prepare things like fetching TSconfig and others. 00258 * The resulting, processed row will be returned. 00259 * 00260 * @param string The table name 00261 * @param string The uid value of the record (integer). Can also be a string (NEW-something) if the record is a NEW record. 00262 * @param integer The pid integer. For existing records this is of course the row's "pid" field. For new records it can be either a page id (positive) or a pointer to another record from the SAME table (negative) after which the record should be inserted (or on same page) 00263 * @param array The row of the current record. If NEW record, then it may be loaded with default values (by eg. fetchRecord()). 00264 * @param array Tsconfig array 00265 * @param integer PAGE TSconfig pid 00266 * @return array Processed record data 00267 * @see renderRecord() 00268 */ 00269 function renderRecordRaw($table, $id, $pid, $row, $TSconfig = '', $tscPID = 0) { 00270 global $TCA; 00271 00272 if (!is_array($TSconfig)) { 00273 $TSconfig = array(); 00274 } 00275 00276 // Create blank accumulation array: 00277 $totalRecordContent = array(); 00278 00279 // Traverse the configured columns for the table (TCA): 00280 // For each column configured, we will perform processing if needed based on the type (eg. for "group" and "select" types this is needed) 00281 t3lib_div::loadTCA($table); 00282 $copyOfColumns = $TCA[$table]['columns']; 00283 foreach ($copyOfColumns as $field => $fieldConfig) { 00284 // Set $data variable for the field, either inputted value from $row - or if not found, the default value as defined in the "config" array 00285 if (isset($row[$field])) { 00286 $data = $row[$field]; 00287 } else { 00288 $data = $fieldConfig['config']['default']; 00289 } 00290 00291 $data = $this->renderRecord_SW($data, $fieldConfig, $TSconfig, $table, $row, $field); 00292 00293 // Set the field in the accumulation array IF the $data variabel is set: 00294 $totalRecordContent[$field] = isset($data) ? $data : ''; 00295 } 00296 00297 // 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). 00298 // For instance this could be processing instructions for the Rich Text Editor. 00299 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table, $totalRecordContent); 00300 if (is_array($types_fieldConfig)) { 00301 $totalRecordContent = $this->renderRecord_typesProc($totalRecordContent, $types_fieldConfig, $tscPID, $table, $pid); 00302 } 00303 00304 // Register items, mostly for external use (overriding the regItem() function) 00305 foreach ($totalRecordContent as $field => $data) { 00306 $this->regItem($table, $id, $field, $data); 00307 } 00308 00309 // Finally, store the result: 00310 reset($totalRecordContent); 00311 00312 return $totalRecordContent; 00313 00314 } 00315 00316 /** 00317 * Function with the switch() construct which triggers functions for processing of the data value depending on the TCA-config field type. 00318 * 00319 * @param string Value to process 00320 * @param array TCA/columns array for field (independant of TCA for flexforms - coming from XML then) 00321 * @param array TSconfig (blank for flexforms for now) 00322 * @param string Table name 00323 * @param array The row array, always of the real record (also for flexforms) 00324 * @param string The field (empty for flexforms!) 00325 * @return string Modified $value 00326 */ 00327 function renderRecord_SW($data, $fieldConfig, $TSconfig, $table, $row, $field) { 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 case 'inline': 00339 $data = $this->renderRecord_inlineProc($data, $fieldConfig, $TSconfig, $table, $row, $field); 00340 break; 00341 } 00342 00343 return $data; 00344 } 00345 00346 /** 00347 * Processing of the data value in case the field type is "group" 00348 * 00349 * @param string The field value 00350 * @param array TCA field config 00351 * @param array TCEform TSconfig for the record 00352 * @param string Table name 00353 * @param array The row 00354 * @param string Field name 00355 * @return string The processed input field value ($data) 00356 * @access private 00357 * @see renderRecord() 00358 */ 00359 function renderRecord_groupProc($data, $fieldConfig, $TSconfig, $table, $row, $field) { 00360 switch ($fieldConfig['config']['internal_type']) { 00361 case 'file': 00362 // Init array used to accumulate the files: 00363 $dataAcc = array(); 00364 00365 // Now, load the files into the $dataAcc array, whether stored by MM or as a list of filenames: 00366 if ($fieldConfig['config']['MM']) { 00367 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup'); 00368 $loadDB->start('', 'files', $fieldConfig['config']['MM'], $row['uid']); // Setting dummy startup 00369 00370 foreach ($loadDB->itemArray as $value) { 00371 if ($value['id']) { 00372 $dataAcc[] = rawurlencode($value['id']) . '|' . rawurlencode($value['id']); 00373 } 00374 } 00375 } else { 00376 $fileList = t3lib_div::trimExplode(',', $data, 1); 00377 foreach ($fileList as $value) { 00378 if ($value) { 00379 $dataAcc[] = rawurlencode($value) . '|' . rawurlencode($value); 00380 } 00381 } 00382 } 00383 // Implode the accumulation array to a comma separated string: 00384 $data = implode(',', $dataAcc); 00385 break; 00386 case 'db': 00387 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup'); 00388 /* @var $loadDB t3lib_loadDBGroup */ 00389 $loadDB->start($data, $fieldConfig['config']['allowed'], $fieldConfig['config']['MM'], $row['uid'], $table, $fieldConfig['config']); 00390 $loadDB->getFromDB(); 00391 $data = $loadDB->readyForInterface(); 00392 break; 00393 } 00394 00395 return $data; 00396 } 00397 00398 /** 00399 * Processing of the data value in case the field type is "select" 00400 * 00401 * @param string The field value 00402 * @param array TCA field config 00403 * @param array TCEform TSconfig for the record 00404 * @param string Table name 00405 * @param array The row 00406 * @param string Field name 00407 * @return string The processed input field value ($data) 00408 * @access private 00409 * @see renderRecord() 00410 */ 00411 function renderRecord_selectProc($data, $fieldConfig, $TSconfig, $table, $row, $field) { 00412 global $TCA; 00413 00414 // Initialize: 00415 $elements = t3lib_div::trimExplode(',', $data, 1); // Current data set. 00416 $dataAcc = array(); // New data set, ready for interface (list of values, rawurlencoded) 00417 00418 // For list selectors (multi-value): 00419 if (intval($fieldConfig['config']['maxitems']) > 1) { 00420 00421 // Add regular elements: 00422 if (!is_array($fieldConfig['config']['items'])) { 00423 $fieldConfig['config']['items'] = array(); 00424 } 00425 $fieldConfig['config']['items'] = $this->procesItemArray($fieldConfig['config']['items'], $fieldConfig['config'], $TSconfig[$field], $table, $row, $field); 00426 foreach ($fieldConfig['config']['items'] as $pvpv) { 00427 foreach ($elements as $eKey => $value) { 00428 if (!strcmp($value, $pvpv[1])) { 00429 $dataAcc[$eKey] = rawurlencode($pvpv[1]) . '|' . rawurlencode($this->sL($pvpv[0])); 00430 } 00431 } 00432 } 00433 00434 // Add "special" 00435 if ($fieldConfig['config']['special']) { 00436 $dataAcc = $this->selectAddSpecial($dataAcc, $elements, $fieldConfig['config']['special']); 00437 } 00438 00439 // Add "foreign table" stuff: 00440 if ($TCA[$fieldConfig['config']['foreign_table']]) { 00441 $dataAcc = $this->selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row, $table); 00442 } 00443 00444 // Always keep the native order for display in interface: 00445 ksort($dataAcc); 00446 } else { // Normal, <= 1 -> value without title on it 00447 if ($TCA[$fieldConfig['config']['foreign_table']]) { 00448 // Getting the data 00449 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table); 00450 00451 if (!count($dataIds)) { 00452 $dataIds = array(0); 00453 } 00454 $dataAcc[] = $dataIds[0]; 00455 } else { 00456 $dataAcc[] = $elements[0]; 00457 } 00458 } 00459 00460 return implode(',', $dataAcc); 00461 } 00462 00463 /** 00464 * Processing of the data value in case the field type is "flex" 00465 * MUST NOT be called in case of already INSIDE a flexform! 00466 * 00467 * @param string The field value 00468 * @param array TCA field config 00469 * @param array TCEform TSconfig for the record 00470 * @param string Table name 00471 * @param array The row 00472 * @param string Field name 00473 * @return string The processed input field value ($data) 00474 * @access private 00475 * @see renderRecord() 00476 */ 00477 function renderRecord_flexProc($data, $fieldConfig, $TSconfig, $table, $row, $field) { 00478 global $TCA; 00479 00480 // Convert the XML data to PHP array: 00481 $currentValueArray = t3lib_div::xml2array($data); 00482 if (is_array($currentValueArray)) { 00483 00484 // Get current value array: 00485 $dataStructArray = t3lib_BEfunc::getFlexFormDS($fieldConfig['config'], $row, $table); 00486 00487 // Manipulate Flexform DS via TSConfig and group access lists 00488 if (is_array($dataStructArray)) { 00489 $flexFormHelper = t3lib_div::makeInstance('t3lib_TCEforms_Flexforms'); 00490 $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $fieldConfig); 00491 unset($flexFormHelper); 00492 } 00493 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 00505 /** 00506 * Processing of the content in $totalRecordcontent based on settings in the types-configuration 00507 * 00508 * @param array The array of values which has been processed according to their type (eg. "group" or "select") 00509 * @param array The "types" configuration for the current display of fields. 00510 * @param integer PAGE TSconfig PID 00511 * @param string Table name 00512 * @param integer PID value 00513 * @return array The processed version of $totalRecordContent 00514 * @access private 00515 */ 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 00543 /** 00544 * Processing of the data value in case the field type is "inline" 00545 * In some parts nearly the same as type "select" 00546 * 00547 * @param string The field value 00548 * @param array TCA field config 00549 * @param array TCEform TSconfig for the record 00550 * @param string Table name 00551 * @param array The row 00552 * @param string Field name 00553 * @return string The processed input field value ($data) 00554 * @access private 00555 * @see renderRecord() 00556 */ 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 * FlexForm processing functions 00588 * 00589 ***********************************************/ 00590 00591 /** 00592 * Function traversing sheets/languages for flex form data structures 00593 * 00594 * @param array Data array 00595 * @param array Data Structure array 00596 * @param array Various parameters to pass-through 00597 * @return array Modified $dataPart array. 00598 * @access private 00599 * @see t3lib_TCEmain::checkValue_flex_procInData(), renderRecord_flexProc_procInData_travDS() 00600 */ 00601 function renderRecord_flexProc_procInData($dataPart, $dataStructArray, $pParams) { 00602 if (is_array($dataPart)) { 00603 foreach ($dataPart as $sKey => $sheetDef) { 00604 list ($dataStruct, $actualSheet) = t3lib_div::resolveSheetDefInDS($dataStructArray, $sKey); 00605 00606 if (is_array($dataStruct) && $actualSheet == $sKey && is_array($sheetDef)) { 00607 foreach ($sheetDef as $lKey => $lData) { 00608 $this->renderRecord_flexProc_procInData_travDS( 00609 $dataPart[$sKey][$lKey], 00610 $dataStruct['ROOT']['el'], 00611 $pParams 00612 ); 00613 } 00614 } 00615 } 00616 } 00617 00618 return $dataPart; 00619 } 00620 00621 /** 00622 * Traverse data array / structure 00623 * 00624 * @param array Data array passed by reference. 00625 * @param array Data structure 00626 * @param array Various parameters pass-through. 00627 * @return void 00628 * @see renderRecord_flexProc_procInData(), t3lib_TCEmain::checkValue_flex_procInData_travDS() 00629 */ 00630 function renderRecord_flexProc_procInData_travDS(&$dataValues, $DSelements, $pParams) { 00631 if (is_array($DSelements)) { 00632 00633 // For each DS element: 00634 foreach ($DSelements as $key => $dsConf) { 00635 00636 // Array/Section: 00637 if ($DSelements[$key]['type'] == 'array') { 00638 if (is_array($dataValues[$key]['el'])) { 00639 if ($DSelements[$key]['section']) { 00640 foreach ($dataValues[$key]['el'] as $ik => $el) { 00641 if (is_array($el)) { 00642 $theKey = key($el); 00643 if (is_array($dataValues[$key]['el'][$ik][$theKey]['el'])) { 00644 $this->renderRecord_flexProc_procInData_travDS( 00645 $dataValues[$key]['el'][$ik][$theKey]['el'], 00646 $DSelements[$key]['el'][$theKey]['el'], 00647 $pParams 00648 ); 00649 } 00650 } 00651 } 00652 } else { 00653 if (!isset($dataValues[$key]['el'])) { 00654 $dataValues[$key]['el'] = array(); 00655 } 00656 $this->renderRecord_flexProc_procInData_travDS( 00657 $dataValues[$key]['el'], 00658 $DSelements[$key]['el'], 00659 $pParams 00660 ); 00661 } 00662 } 00663 } else { 00664 if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key])) { 00665 foreach ($dataValues[$key] as $vKey => $data) { 00666 00667 // $data,$fieldConfig,$TSconfig,$table,$row,$field 00668 list(, , $CVTSconfig, $CVtable, $CVrow, $CVfield) = $pParams; 00669 00670 // Set default value: 00671 if (!isset($dataValues[$key][$vKey])) { 00672 $dataValues[$key][$vKey] = $dsConf['TCEforms']['config']['default']; 00673 } 00674 00675 // Process value: 00676 $dataValues[$key][$vKey] = $this->renderRecord_SW($dataValues[$key][$vKey], $dsConf['TCEforms'], $CVTSconfig, $CVtable, $CVrow, ''); 00677 } 00678 } 00679 } 00680 } 00681 } 00682 } 00683 00684 00685 /*********************************************** 00686 * 00687 * Selector box processing functions 00688 * 00689 ***********************************************/ 00690 00691 /** 00692 * Adding "special" types to the $dataAcc array of selector items 00693 * 00694 * @param array Array with numeric keys, containing values for the selector box, prepared for interface. We are going to add elements to this array as needed. 00695 * @param array The array of original elements - basically the field value exploded by "," 00696 * @param string The "special" key from the TCA config of the field. Determines the type of processing in here. 00697 * @return array Modified $dataAcc array 00698 * @access private 00699 * @see renderRecord_selectProc() 00700 */ 00701 function selectAddSpecial($dataAcc, $elements, $specialKey) { 00702 global $TCA; 00703 00704 // Special select types: 00705 switch ((string) $specialKey) { 00706 case 'tables': // Listing all tables from $TCA: 00707 $tNames = array_keys($TCA); 00708 foreach ($tNames as $tableName) { 00709 foreach ($elements as $eKey => $value) { 00710 if (!strcmp($tableName, $value)) { 00711 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode($this->sL($TCA[$value]['ctrl']['title'])); 00712 } 00713 } 00714 } 00715 break; 00716 case 'pagetypes': // Listing all page types (doktype) 00717 $theTypes = $TCA['pages']['columns']['doktype']['config']['items']; 00718 if (is_array($theTypes)) { 00719 foreach ($theTypes as $theTypesArrays) { 00720 foreach ($elements as $eKey => $value) { 00721 if (!strcmp($theTypesArrays[1], $value)) { 00722 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode($this->sL($theTypesArrays[0])); 00723 } 00724 } 00725 } 00726 } 00727 break; 00728 case 'exclude': // Listing exclude fields. 00729 $theExcludeFields = t3lib_BEfunc::getExcludeFields(); 00730 00731 if (is_array($theExcludeFields)) { 00732 foreach ($theExcludeFields as $theExcludeFieldsArrays) { 00733 foreach ($elements as $eKey => $value) { 00734 if (!strcmp($theExcludeFieldsArrays[1], $value)) { 00735 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode(rtrim($theExcludeFieldsArrays[0], ':')); 00736 } 00737 } 00738 } 00739 } 00740 break; 00741 case 'explicitValues': 00742 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues(); 00743 00744 foreach ($theTypes as $tableFieldKey => $theTypeArrays) { 00745 if (is_array($theTypeArrays['items'])) { 00746 foreach ($theTypeArrays['items'] as $itemValue => $itemContent) { 00747 foreach ($elements as $eKey => $value) { 00748 if (!strcmp($tableFieldKey . ':' . $itemValue . ':' . $itemContent[0], $value)) { 00749 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode('[' . $itemContent[2] . '] ' . $itemContent[1]); 00750 } 00751 } 00752 } 00753 } 00754 } 00755 break; 00756 case 'languages': 00757 $theLangs = t3lib_BEfunc::getSystemLanguages(); 00758 foreach ($theLangs as $lCfg) { 00759 foreach ($elements as $eKey => $value) { 00760 if (!strcmp($lCfg[1], $value)) { 00761 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode($lCfg[0]); 00762 } 00763 } 00764 } 00765 break; 00766 case 'custom': 00767 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions']; 00768 00769 if (is_array($customOptions)) { 00770 foreach ($customOptions as $coKey => $coValue) { 00771 if (is_array($coValue['items'])) { 00772 // Traverse items: 00773 foreach ($coValue['items'] as $itemKey => $itemCfg) { 00774 foreach ($elements as $eKey => $value) { 00775 if (!strcmp($coKey . ':' . $itemKey, $value)) { 00776 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode($this->sL($itemCfg[0])); 00777 } 00778 } 00779 } 00780 } 00781 } 00782 } 00783 break; 00784 case 'modListGroup': // Listing modules for GROUPS 00785 case 'modListUser': // Listing modules for USERS: 00786 if (!$this->loadModules) { 00787 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules'); 00788 $this->loadModules->load($GLOBALS['TBE_MODULES']); 00789 } 00790 $modList = ($specialKey == 'modListUser') ? $this->loadModules->modListUser : $this->loadModules->modListGroup; 00791 00792 foreach ($modList as $theModName) { 00793 foreach ($elements as $eKey => $value) { 00794 $label = ''; 00795 // Add label for main module: 00796 $pp = explode('_', $value); 00797 if (count($pp) > 1) { 00798 $label .= $GLOBALS['LANG']->moduleLabels['tabs'][$pp[0] . '_tab'] . '>'; 00799 } 00800 // Add modules own label now: 00801 $label .= $GLOBALS['LANG']->moduleLabels['tabs'][$value . '_tab']; 00802 00803 if (!strcmp($theModName, $value)) { 00804 $dataAcc[$eKey] = rawurlencode($value) . '|' . rawurlencode($label); 00805 } 00806 } 00807 } 00808 break; 00809 } 00810 00811 return $dataAcc; 00812 } 00813 00814 /** 00815 * Adds the foreign record elements to $dataAcc, if any 00816 * 00817 * @param array Array with numeric keys, containing values for the selector box, prepared for interface. We are going to add elements to this array as needed. 00818 * @param array The array of original elements - basically the field value exploded by "," 00819 * @param array Field configuration from TCA 00820 * @param string The field name 00821 * @param array TSconfig for the record 00822 * @param array The record 00823 * @param array The current table 00824 * @return array Modified $dataAcc array 00825 * @access private 00826 * @see renderRecord_selectProc() 00827 */ 00828 function selectAddForeign($dataAcc, $elements, $fieldConfig, $field, $TSconfig, $row, $table) { 00829 global $TCA; 00830 00831 // Init: 00832 $recordList = array(); 00833 00834 // foreign_table 00835 $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig, $field, $TSconfig); 00836 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres)) { 00837 $recordList[$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['foreign_table'], $subrow); 00838 } 00839 00840 // neg_foreign_table 00841 if (is_array($TCA[$fieldConfig['config']['neg_foreign_table']])) { 00842 $subres = t3lib_BEfunc::exec_foreign_table_where_query($fieldConfig, $field, $TSconfig, 'neg_'); 00843 while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres)) { 00844 $recordList[-$subrow['uid']] = t3lib_BEfunc::getRecordTitle($fieldConfig['config']['neg_foreign_table'], $subrow); 00845 } 00846 } 00847 00848 // At this point all records that CAN be selected is found in $recordList 00849 // Now, get the data from loadDBgroup based on the input list of values. 00850 $dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table); 00851 if ($fieldConfig['config']['MM']) { 00852 $dataAcc = array(); 00853 } // Reset, if MM (which cannot bear anything but real relations!) 00854 00855 // After this we can traverse the loadDBgroup values and match values with the list of possible values in $recordList: 00856 foreach ($dataIds as $theId) { 00857 if (isset($recordList[$theId])) { 00858 $lPrefix = $this->sL($fieldConfig['config'][($theId > 0 ? '' : 'neg_') . 'foreign_table_prefix']); 00859 if ($fieldConfig['config']['MM'] || $fieldConfig['config']['foreign_field']) { 00860 $dataAcc[] = rawurlencode($theId) . '|' . rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix . strip_tags($recordList[$theId]), $GLOBALS['BE_USER']->uc['titleLen'])); 00861 } else { 00862 foreach ($elements as $eKey => $value) { 00863 if (!strcmp($theId, $value)) { 00864 $dataAcc[$eKey] = rawurlencode($theId) . '|' . rawurlencode(t3lib_div::fixed_lgd_cs($lPrefix . strip_tags($recordList[$theId]), $GLOBALS['BE_USER']->uc['titleLen'])); 00865 } 00866 } 00867 } 00868 } 00869 } 00870 00871 return $dataAcc; 00872 } 00873 00874 /** 00875 * Returning the id-list processed by loadDBgroup for the foreign tables. 00876 * 00877 * @param array The array of original elements - basically the field value exploded by "," 00878 * @param array Field configuration from TCA 00879 * @param array The data array, currently. Used to set the "local_uid" for selecting MM relation records. 00880 * @param string Current table name. passed on to t3lib_loadDBGroup 00881 * @return array An array with ids of the records from the input elements array. 00882 * @access private 00883 */ 00884 function getDataIdList($elements, $fieldConfig, $row, $table) { 00885 $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup'); 00886 $loadDB->registerNonTableValues = $fieldConfig['config']['allowNonIdValues'] ? 1 : 0; 00887 $loadDB->start(implode(',', $elements), 00888 $fieldConfig['config']['foreign_table'] . ',' . $fieldConfig['config']['neg_foreign_table'], 00889 $fieldConfig['config']['MM'], 00890 $row['uid'], 00891 $table, 00892 $fieldConfig['config'] 00893 ); 00894 00895 $idList = $loadDB->convertPosNeg($loadDB->getValueArray(), $fieldConfig['config']['foreign_table'], $fieldConfig['config']['neg_foreign_table']); 00896 00897 return $idList; 00898 } 00899 00900 /** 00901 * Processing of selector box items. This includes the automated adding of elements plus user-function processing. 00902 * 00903 * @param array The elements to process 00904 * @param array TCA/columns configuration 00905 * @param array TSconfig for the field 00906 * @param string The table name 00907 * @param array The current row 00908 * @param string The field name 00909 * @return array The modified input $selItems array 00910 * @access private 00911 * @see renderRecord_selectProc() 00912 */ 00913 function procesItemArray($selItems, $config, $fieldTSConfig, $table, $row, $field) { 00914 $selItems = $this->addItems($selItems, $fieldTSConfig['addItems.']); 00915 if ($config['itemsProcFunc']) { 00916 $selItems = $this->procItems($selItems, $fieldTSConfig['itemsProcFunc.'], $config, $table, $row, $field); 00917 } 00918 return $selItems; 00919 } 00920 00921 /** 00922 * Adding items from $iArray to $items array 00923 * 00924 * @param array The array of selector box items to which key(value) / value(label) pairs from $iArray will be added. 00925 * @param array The array of elements to add. The keys will become values. The value will become the label. 00926 * @return array The modified input $items array 00927 * @access private 00928 * @see procesItemArray() 00929 */ 00930 function addItems($items, $iArray) { 00931 if (is_array($iArray)) { 00932 foreach ($iArray as $value => $label) { 00933 $items[] = array($label, $value); 00934 } 00935 } 00936 return $items; 00937 } 00938 00939 /** 00940 * User processing of a selector box array of values. 00941 * 00942 * @param array The array of selector box items 00943 * @param array TSconfig for the fields itemProcFunc 00944 * @param array TCA/columns configuration 00945 * @param string The table name 00946 * @param array The current row 00947 * @param string The field name 00948 * @return array The modified input $items array 00949 * @access private 00950 * @see procesItemArray() 00951 */ 00952 function procItems($items, $itemsProcFuncTSconfig, $config, $table, $row, $field) { 00953 $params = array(); 00954 $params['items'] = &$items; 00955 $params['config'] = $config; 00956 $params['TSconfig'] = $itemsProcFuncTSconfig; 00957 $params['table'] = $table; 00958 $params['row'] = $row; 00959 $params['field'] = $field; 00960 00961 t3lib_div::callUserFunction($config['itemsProcFunc'], $params, $this); 00962 return $items; 00963 } 00964 00965 00966 /*********************************************** 00967 * 00968 * Helper functions 00969 * 00970 ***********************************************/ 00971 00972 /** 00973 * Sets the lock for a record from table/id, IF $this->lockRecords is set! 00974 * 00975 * @param string The table name 00976 * @param integer The id of the record 00977 * @param integer The pid of the record 00978 * @return void 00979 */ 00980 function lockRecord($table, $id, $pid = 0) { 00981 if ($this->lockRecords) { 00982 t3lib_BEfunc::lockRecords($table, $id, $pid); 00983 } 00984 } 00985 00986 /** 00987 * Dummy function, can be used to "register" records. Used by eg. the "show_item" script. 00988 * 00989 * @param string Table name 00990 * @param integer Record id 00991 * @param string Field name 00992 * @param string Field content. 00993 * @return void 00994 * @access private 00995 * @see renderRecord() 00996 */ 00997 function regItem($table, $id, $field, $content) { 00998 } 00999 01000 /** 01001 * Local wrapper function for LANG->sL (returning language labels) 01002 * 01003 * @param string Language label key 01004 * @return string Localized label value. 01005 * @access private 01006 */ 01007 function sL($in) { 01008 return $GLOBALS['LANG']->sL($in); 01009 } 01010 } 01011 01012 01013 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php'])) { 01014 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transferdata.php']); 01015 } 01016 01017 ?>
1.8.0