Feature #16323 » 6039_v4_new_internal_type.patch

Administrator Admin, 2008-03-12 21:51

View differences:

class.t3lib_refindex.php (working copy)
204 204
 						case 'db':
205 205
 							$this->createEntryData_dbRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']);
206 206
 						break;
207
						case 'file_reference':
207 208
 						case 'file':
208 209
 							$this->createEntryData_fileRels($table,$uid,$fieldname,'',$deleted,$dat['newValueFiles']);
209 210
 						break;
......
341 342
								 	list($tableName,$recordId) = explode(':',$el['subst']['recordRef']);
342 343
								 	$this->relations[] = $this->createEntryData($table,$uid,$fieldname,$flexpointer,$deleted,$tableName,$recordId,'',-1,$spKey,$subKey);
343 344
								 break;
345
								 case 'file_reference':
344 346
								 case 'file':
345 347
								 	$this->relations[] = $this->createEntryData($table,$uid,$fieldname,$flexpointer,$deleted,'_FILE',0,$el['subst']['relFileName'],-1,$spKey,$subKey);
346 348
								 break;
......
536 538
	 */
537 539
	function getRelations_procFiles($value, $conf, $uid)	{
538 540
			// Take care of files...
539
		if ($conf['type']=='group' && $conf['internal_type']=='file')	{
541
		if ($conf['type']=='group' && ($conf['internal_type']=='file' || $conf['internal_type']=='file_reference'))	{
540 542

  
541 543
				// Collect file values in array:
542 544
			if ($conf['MM'])	{
......
554 556
			}
555 557

  
556 558
				// Traverse the files and add them:
557
			$uploadFolder = $conf['uploadfolder'];
559
			$uploadFolder = $conf['internal_type']=='file' ? $conf['uploadfolder'] : '';
558 560
			$dest = $this->destPathFromUploadFolder($uploadFolder);
559 561
			$newValue = array();
560 562
			$newValueFiles = array();
......
564 566
					$realFile = $dest.'/'.trim($file);
565 567
#					if (@is_file($realFile))	{		// Now, the refernece index should NOT look if files exist - just faithfully include them if they are in the records!
566 568
						$newValueFiles[] = array(
567
							'filename' => $file,
569
							'filename' => basename($file),
568 570
							'ID' => md5($realFile),
569 571
							'ID_absFile' => $realFile
570 572
						);	// the order should be preserved here because.. (?)
......
667 669
		 							$error = $this->setReferenceValue_dbRels($refRec,$dat['itemArray'],$newValue,$dataArray);
668 670
									if ($error)	return $error;
669 671
		 						break;
672
								case 'file_reference':
670 673
		 						case 'file':
671 674
		 							$this->setReferenceValue_fileRels($refRec,$dat['newValueFiles'],$newValue,$dataArray);
672 675
									if ($error)	return $error;
......
974 977
	 * @return	string		Input folder prefixed with PATH_site. No checking for existence is done. Output must be a folder without trailing slash.
975 978
	 */
976 979
	function destPathFromUploadFolder($folder)	{
980
		if (!$folder) {
981
			return substr(PATH_site, 0, -1);
982
		}
977 983
		return PATH_site.$folder;
978 984
	}
979 985

  
class.t3lib_tceforms.php (working copy)
1967 1967

  
1968 1968
			// Acting according to either "file" or "db" type:
1969 1969
		switch((string)$config['internal_type'])	{
1970
			case 'file_reference':
1971
				$config['uploadfolder'] = '';
1970 1972
			case 'file':	// If the element is of the internal type "file":
1971 1973

  
1972 1974
					// Creating string showing allowed types:
......
2033 2035

  
2034 2036
				if(!$disabled && !(isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'upload'))) {
2035 2037
						// Adding the upload field:
2036
					if ($this->edit_docModuleUpload)	$item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
2038
					if ($this->edit_docModuleUpload && $config['uploadfolder']) {
2039
						$item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
2040
					}
2037 2041
				}
2038 2042
			break;
2039 2043
			case 'folder':	// If the element is of the internal type "folder":
......
3335 3339
						}
3336 3340
					}
3337 3341
				break;
3342
				case 'file_reference':
3338 3343
				case 'file':
3339 3344
				case 'folder':
3340 3345
					while(list(,$pp)=each($itemArray))	{
3341 3346
						$pParts = explode('|',$pp);
3342 3347
						$uidList[]=$pUid=$pTitle = $pParts[0];
3343
						$opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
3348
						$opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(basename(rawurldecode($pParts[0]))).'</option>';
3344 3349
					}
3345 3350
				break;
3346 3351
				default:
......
3378 3383
				}
3379 3384
				$aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|'.$aOnClickInline).'\'); return false;';
3380 3385
				$icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
3381
						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert3.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_'.($mode=='file'?'file':'db'))).' />'.
3386
						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert3.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_'.($mode=='db'?'db':'file'))).' />'.
3382 3387
						'</a>';
3383 3388
			}
3384 3389
			if (!$params['dontShowMoveIcons'])	{
......
3405 3410
				$aOnClick = '';
3406 3411
	#			$counter = 0;
3407 3412
				foreach($clipElements as $elValue)	{
3408
					if ($mode=='file')	{
3409
						$itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
3410
					} else {	// 'db' mode assumed
3413
					if ($mode=='db')	{
3411 3414
						list($itemTable,$itemUid) = explode('|', $elValue);
3412 3415
						$itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid)));
3413 3416
						$elValue = $itemTable.'_'.$itemUid;
3417
					} else {	// 'file' mode assumed
3418
						$itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
3414 3419
					}
3415 3420
					$aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
3416 3421

  
......
3419 3424
				}
3420 3425
				$aOnClick.= 'return false;';
3421 3426
				$icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
3422
						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert5.png','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_'.($mode=='file'?'file':'db')),count($clipElements))).' />'.
3427
						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert5.png','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_'.($mode=='db'?'db':'file')),count($clipElements))).' />'.
3423 3428
						'</a>';
3424 3429
			}
3425 3430
			$rOnClick = $rOnClickInline.'setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false';
......
3473 3478

  
3474 3479
		if (is_object($this->clipObj))	{
3475 3480
			switch($mode)	{
3481
				case 'file_reference':
3476 3482
				case 'file':
3477 3483
					$elFromTable = $this->clipObj->elFromTable('_FILE');
3478 3484
					$allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
......
5746 5752
	 * @return 	string		HTML formatted output
5747 5753
	 */
5748 5754
	function previewFieldValue($value, $config)	{
5749
		if ($config['config']['type']==='group' && $config['config']['internal_type'] === 'file')	{
5755
		if ($config['config']['type']==='group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference'))	{
5756
				// Ignore uploadfolder if internal_type is file_reference
5757
			if ($config['config']['internal_type'] === 'file_reference') {
5758
				$config['config']['uploadfolder'] = '';
5759
			}
5760
			
5750 5761
			$show_thumbs = TRUE;
5751 5762
			$table = 'tt_content';
5752 5763

  
class.t3lib_tcemain.php (working copy)
1479 1479
			// For group types:
1480 1480
		if ($tcaFieldConf['type']=='group')	{
1481 1481
			switch($tcaFieldConf['internal_type'])	{
1482
				case 'file_reference':
1482 1483
				case 'file':
1483 1484
					$valueArray = $this->checkValue_group_select_file(
1484 1485
						$valueArray,
......
1563 1564
		}
1564 1565

  
1565 1566
			// If there is an upload folder defined:
1566
		if ($tcaFieldConf['uploadfolder'])	{
1567
		if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file')	{
1567 1568
			if (!$this->bypassFileHandling)	{	// If filehandling should NOT be bypassed, do processing:
1568 1569
					// For logging..
1569 1570
				$propArr = $this->getRecordProperties($table,$id);
......
1696 1697
				}
1697 1698
				$valueArray = $dbAnalysis->countItems();
1698 1699
			}
1700
		//store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
1701
		} else {
1702
			if (count($valueArray)){
1703
				foreach($valueArray as &$theFile){
1704
					if (t3lib_div::isFirstPartOfStr($theFile,PATH_site))	{
1705
						$theFile = substr($theFile,strlen(PATH_site));
1706
					}
1707
				}
1708
			}
1699 1709
		}
1700 1710

  
1701 1711
		return $valueArray;
......
3103 3113
	function copyRecord_procFilesRefs($conf, $uid, $value)	{
3104 3114

  
3105 3115
			// Prepend absolute paths to files:
3106
		if ($conf['type']=='group' && $conf['internal_type']=='file')	{
3116
		if ($conf['type']=='group' && ($conf['internal_type']=='file' || $conf['internal_type']=='file_reference'))	{
3107 3117

  
3108 3118
				// Get an array with files as values:
3109 3119
			if ($conf['MM'])	{
......
3123 3133
			}
3124 3134

  
3125 3135
				// Traverse this array of files:
3126
			$uploadFolder = $conf['uploadfolder'];
3136
			$uploadFolder = $conf['internal_type']=='file' ? $conf['uploadfolder'] : '';
3127 3137
			$dest = $this->destPathFromUploadFolder($uploadFolder);
3128 3138
			$newValue = array();
3129 3139

  
......
6428 6438
		if ($TCA[$table]['columns'])	{
6429 6439
			reset($TCA[$table]['columns']);
6430 6440
			while (list($field,$configArr)=each($TCA[$table]['columns']))	{
6431
				if ($configArr['config']['type']=='group' && $configArr['config']['internal_type']=='file')	{
6441
				if ($configArr['config']['type']=='group' && ($configArr['config']['internal_type']=='file' || $configArr['config']['internal_type']=='file_reference'))	{
6432 6442
					$listArr[]=$field;
6433 6443
				}
6434 6444
			}
......
6597 6607
		global $TCA;
6598 6608
		t3lib_div::loadTCA($table);
6599 6609
		$uploadFolder = $TCA[$table]['columns'][$field]['config']['uploadfolder'];
6600
		if ($uploadFolder && trim($filelist))	{
6610
		if ($uploadFolder && trim($filelist) && $TCA[$table]['columns'][$field]['config']['internal_type'] == 'file')	{
6601 6611
			$uploadPath = $this->destPathFromUploadFolder($uploadFolder);
6602 6612
			$fileArray = explode(',',$filelist);
6603 6613
			while (list(,$theFile)=each($fileArray))	{
(4-4/15)