Index: t3lib/class.t3lib_refindex.php =================================================================== --- t3lib/class.t3lib_refindex.php (revision 3417) +++ t3lib/class.t3lib_refindex.php (working copy) @@ -204,6 +204,7 @@ case 'db': $this->createEntryData_dbRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']); break; + case 'file_reference': case 'file': $this->createEntryData_fileRels($table,$uid,$fieldname,'',$deleted,$dat['newValueFiles']); break; @@ -341,6 +342,7 @@ list($tableName,$recordId) = explode(':',$el['subst']['recordRef']); $this->relations[] = $this->createEntryData($table,$uid,$fieldname,$flexpointer,$deleted,$tableName,$recordId,'',-1,$spKey,$subKey); break; + case 'file_reference': case 'file': $this->relations[] = $this->createEntryData($table,$uid,$fieldname,$flexpointer,$deleted,'_FILE',0,$el['subst']['relFileName'],-1,$spKey,$subKey); break; @@ -536,7 +538,7 @@ */ function getRelations_procFiles($value, $conf, $uid) { // Take care of files... - if ($conf['type']=='group' && $conf['internal_type']=='file') { + if ($conf['type']=='group' && ($conf['internal_type']=='file' || $conf['internal_type']=='file_reference')) { // Collect file values in array: if ($conf['MM']) { @@ -554,7 +556,7 @@ } // Traverse the files and add them: - $uploadFolder = $conf['uploadfolder']; + $uploadFolder = $conf['internal_type']=='file' ? $conf['uploadfolder'] : ''; $dest = $this->destPathFromUploadFolder($uploadFolder); $newValue = array(); $newValueFiles = array(); @@ -564,7 +566,7 @@ $realFile = $dest.'/'.trim($file); # if (@is_file($realFile)) { // Now, the refernece index should NOT look if files exist - just faithfully include them if they are in the records! $newValueFiles[] = array( - 'filename' => $file, + 'filename' => basename($file), 'ID' => md5($realFile), 'ID_absFile' => $realFile ); // the order should be preserved here because.. (?) @@ -667,6 +669,7 @@ $error = $this->setReferenceValue_dbRels($refRec,$dat['itemArray'],$newValue,$dataArray); if ($error) return $error; break; + case 'file_reference': case 'file': $this->setReferenceValue_fileRels($refRec,$dat['newValueFiles'],$newValue,$dataArray); if ($error) return $error; @@ -974,6 +977,9 @@ * @return string Input folder prefixed with PATH_site. No checking for existence is done. Output must be a folder without trailing slash. */ function destPathFromUploadFolder($folder) { + if (!$folder) { + return substr(PATH_site, 0, -1); + } return PATH_site.$folder; } Index: t3lib/class.t3lib_tceforms.php =================================================================== --- t3lib/class.t3lib_tceforms.php (revision 3417) +++ t3lib/class.t3lib_tceforms.php (working copy) @@ -1967,6 +1967,8 @@ // Acting according to either "file" or "db" type: switch((string)$config['internal_type']) { + case 'file_reference': + $config['uploadfolder'] = ''; case 'file': // If the element is of the internal type "file": // Creating string showing allowed types: @@ -2033,7 +2035,9 @@ if(!$disabled && !(isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'upload'))) { // Adding the upload field: - if ($this->edit_docModuleUpload) $item.='formWidth().' size="60" />'; + if ($this->edit_docModuleUpload && $config['uploadfolder']) { + $item.='formWidth().' size="60" />'; + } } break; case 'folder': // If the element is of the internal type "folder": @@ -3335,12 +3339,13 @@ } } break; + case 'file_reference': case 'file': case 'folder': while(list(,$pp)=each($itemArray)) { $pParts = explode('|',$pp); $uidList[]=$pUid=$pTitle = $pParts[0]; - $opt[]=''; + $opt[]=''; } break; default: @@ -3378,7 +3383,7 @@ } $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|'.$aOnClickInline).'\'); return false;'; $icons['R'][]=''. - 'backPath,'gfx/insert3.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_'.($mode=='file'?'file':'db'))).' />'. + 'backPath,'gfx/insert3.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_'.($mode=='db'?'db':'file'))).' />'. ''; } if (!$params['dontShowMoveIcons']) { @@ -3405,12 +3410,12 @@ $aOnClick = ''; # $counter = 0; foreach($clipElements as $elValue) { - if ($mode=='file') { - $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')'; - } else { // 'db' mode assumed + if ($mode=='db') { list($itemTable,$itemUid) = explode('|', $elValue); $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid))); $elValue = $itemTable.'_'.$itemUid; + } else { // 'file' mode assumed + $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')'; } $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');'; @@ -3419,7 +3424,7 @@ } $aOnClick.= 'return false;'; $icons['R'][]=''. - 'backPath,'gfx/insert5.png','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_'.($mode=='file'?'file':'db')),count($clipElements))).' />'. + 'backPath,'gfx/insert5.png','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_'.($mode=='db'?'db':'file')),count($clipElements))).' />'. ''; } $rOnClick = $rOnClickInline.'setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false'; @@ -3473,6 +3478,7 @@ if (is_object($this->clipObj)) { switch($mode) { + case 'file_reference': case 'file': $elFromTable = $this->clipObj->elFromTable('_FILE'); $allowedExts = t3lib_div::trimExplode(',', $allowed, 1); @@ -5746,7 +5752,12 @@ * @return string HTML formatted output */ function previewFieldValue($value, $config) { - if ($config['config']['type']==='group' && $config['config']['internal_type'] === 'file') { + if ($config['config']['type']==='group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) { + // Ignore uploadfolder if internal_type is file_reference + if ($config['config']['internal_type'] === 'file_reference') { + $config['config']['uploadfolder'] = ''; + } + $show_thumbs = TRUE; $table = 'tt_content'; Index: t3lib/class.t3lib_tcemain.php =================================================================== --- t3lib/class.t3lib_tcemain.php (revision 3417) +++ t3lib/class.t3lib_tcemain.php (working copy) @@ -1479,6 +1479,7 @@ // For group types: if ($tcaFieldConf['type']=='group') { switch($tcaFieldConf['internal_type']) { + case 'file_reference': case 'file': $valueArray = $this->checkValue_group_select_file( $valueArray, @@ -1563,7 +1564,7 @@ } // If there is an upload folder defined: - if ($tcaFieldConf['uploadfolder']) { + if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') { if (!$this->bypassFileHandling) { // If filehandling should NOT be bypassed, do processing: // For logging.. $propArr = $this->getRecordProperties($table,$id); @@ -1696,6 +1697,15 @@ } $valueArray = $dbAnalysis->countItems(); } + //store path relative to site root (if uploadfolder is not set or internal_type is file_reference) + } else { + if (count($valueArray)){ + foreach($valueArray as &$theFile){ + if (t3lib_div::isFirstPartOfStr($theFile,PATH_site)) { + $theFile = substr($theFile,strlen(PATH_site)); + } + } + } } return $valueArray; @@ -3103,7 +3113,7 @@ function copyRecord_procFilesRefs($conf, $uid, $value) { // Prepend absolute paths to files: - if ($conf['type']=='group' && $conf['internal_type']=='file') { + if ($conf['type']=='group' && ($conf['internal_type']=='file' || $conf['internal_type']=='file_reference')) { // Get an array with files as values: if ($conf['MM']) { @@ -3123,7 +3133,7 @@ } // Traverse this array of files: - $uploadFolder = $conf['uploadfolder']; + $uploadFolder = $conf['internal_type']=='file' ? $conf['uploadfolder'] : ''; $dest = $this->destPathFromUploadFolder($uploadFolder); $newValue = array(); @@ -6428,7 +6438,7 @@ if ($TCA[$table]['columns']) { reset($TCA[$table]['columns']); while (list($field,$configArr)=each($TCA[$table]['columns'])) { - if ($configArr['config']['type']=='group' && $configArr['config']['internal_type']=='file') { + if ($configArr['config']['type']=='group' && ($configArr['config']['internal_type']=='file' || $configArr['config']['internal_type']=='file_reference')) { $listArr[]=$field; } } @@ -6597,7 +6607,7 @@ global $TCA; t3lib_div::loadTCA($table); $uploadFolder = $TCA[$table]['columns'][$field]['config']['uploadfolder']; - if ($uploadFolder && trim($filelist)) { + if ($uploadFolder && trim($filelist) && $TCA[$table]['columns'][$field]['config']['internal_type'] == 'file') { $uploadPath = $this->destPathFromUploadFolder($uploadFolder); $fileArray = explode(',',$filelist); while (list(,$theFile)=each($fileArray)) {