0006365.patch

Administrator Admin, 2007-09-18 19:41

Download (10.4 KB)

View differences:

t3lib/class.t3lib_tceforms.php (Arbeitskopie)
816 816
		t3lib_div::loadTCA($table);
817 817

  
818 818
			// Get the TCA configuration for the current field:
819
		$PA['fieldConf'] = $TCA[$table]['columns'][$field];
819
		$PA['fieldConf'] = t3lib_div::getFieldConfiguration($table, $field, $row);
820 820
		$PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];	// Using "form_type" locally in this script
821 821

  
822 822
		$skipThisField = $this->inline->skipField($table, $field, $row, $PA['fieldConf']['config']);
......
2698 2698
	 * @param	string		The table name. MUST be in $TCA
2699 2699
	 * @param	array		The row from the table, should contain at least the "type" field, if applicable.
2700 2700
	 * @return	string		Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
2701
	 * @deprecated			This method was moved to t3lib_div::getRTypeNum in TYPO3 4.2.0.
2701 2702
	 */
2702 2703
	function getRTypeNum($table,$row)	{
2703
		global $TCA;
2704
			// If there is a "type" field configured...
2705
		if ($TCA[$table]['ctrl']['type'])	{
2706
			$typeFieldName = $TCA[$table]['ctrl']['type'];
2707
			$typeNum=$row[$typeFieldName];	// Get value of the row from the record which contains the type value.
2708
			if (!strcmp($typeNum,''))	$typeNum=0;			// If that value is an empty string, set it to "0" (zero)
2709
		} else {
2710
			$typeNum = 0;	// If no "type" field, then set to "0" (zero)
2711
		}
2712

  
2713
		$typeNum = (string)$typeNum;		// Force to string. Necessary for eg '-1' to be recognized as a type value.
2714
		if (!$TCA[$table]['types'][$typeNum])	{	// However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
2715
			$typeNum = 1;
2716
		}
2717

  
2718
		return $typeNum;
2704
		return t3lib_div::getRTypeNum($table, $row);
2719 2705
	}
2720 2706

  
2721 2707
	/**
......
3031 3017
	function renderDefaultLanguageContent($table,$field,$row,$item)	{
3032 3018
		if (is_array($this->defaultLanguageData[$table.':'.$row['uid']]))	{
3033 3019
			$dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1);
3034
			$fCfg = $GLOBALS['TCA'][$table]['columns'][$field];
3020
			$fCfg = $this->getFieldConfiguration($table, $field, $row);
3035 3021

  
3036 3022
			if (strcmp($dLVal,''))	{
3037 3023
				$item.='<div class="typo3-TCEforms-originalLanguageValue">'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($dLVal,$fCfg).'&nbsp;</div>';
t3lib/class.t3lib_div.php (Arbeitskopie)
1753 1753
		}
1754 1754
		return $out;
1755 1755
	}
1756
	
1757
	/**
1758
	 * Walk a path through an array to a sub-part/sub-key.
1759
	 * Example:
1760
	 * $array = array('first' => array('second' => 1));
1761
	 * $path = 'first/second';
1762
	 * -> This would return '1'
1763
	 *
1764
	 * @param	array		$array: The array to walk through
1765
	 * @param	string		$path: The path (=keys) to walk in the array, delimited by a slash ('/')
1766
	 * @return	mixed		The value found at the given path - returns false if something went wrong
1767
	 */
1768
	function arrayWalkByPath($array, $path) {
1769
		$result = false;
1770
		if (is_array($array) && count($array)) {
1771
				// If path contains only one element (thus, not really a path):
1772
			if (!strpos($path, '/')) {
1773
				$result = (isset($array[$path]) ? $array[$path] : false);
1774
				// If path contains more elements delimited by slashes:
1775
			} else {
1776
				$steps = self::trimExplode('/');
1777
				if (count($steps)) {
1778
					$result = $array;
1779
					foreach ($steps as $step) {
1780
						if (isset($result[$step])) {
1781
							$result =& $result[$step];
1782
						} else {
1783
							$result = false;
1784
							break;
1785
						}
1786
					}
1787
				}
1788
			}
1789
		}
1790
		return $result;
1791
	}
1756 1792

  
1757 1793

  
1758 1794

  
......
3840 3876
	}
3841 3877

  
3842 3878
	/**
3879
	 * Calculate and return the current "types" pointer value for a record
3880
	 *
3881
	 * @param	string		$table: The table name. MUST be in $TCA
3882
	 * @param	array		$row: The row from the table, should contain at least the "type" field, if applicable.
3883
	 * @return	string		Return the "type" value for this record, ready to pick a "types" configuration from the $TCA array.
3884
	 */
3885
	public function getRTypeNum($table, $row) {
3886
		global $TCA;
3887
		self::loadTCA($table);
3888
			// If there is a "type" field configured...
3889
		if ($TCA[$table]['ctrl']['type'])	{
3890
			$typeFieldName = $TCA[$table]['ctrl']['type'];
3891
			$typeNum=$row[$typeFieldName];	// Get value of the row from the record which contains the type value.
3892
			if (!strcmp($typeNum,''))	$typeNum=0;			// If that value is an empty string, set it to "0" (zero)
3893
		} else {
3894
			$typeNum = 0;	// If no "type" field, then set to "0" (zero)
3895
		}
3896

  
3897
		$typeNum = (string)$typeNum;		// Force to string. Necessary for eg '-1' to be recognized as a type value.
3898
		if (!$TCA[$table]['types'][$typeNum])	{	// However, if the type "0" is not found in the "types" array, then default to "1" (for historical reasons)
3899
			$typeNum = 1;
3900
		}
3901

  
3902
		return $typeNum;
3903
	}
3904

  
3905
	/**
3906
	 * Get the configuration of a field defined in $TCA ($TCA[<table>]['columns'][<field>]).
3907
	 * The configuration will be merged with a overrideColumns setting for the current type and field, if any.
3908
	 *
3909
	 * @param	string		$table: The table name
3910
	 * @param	string		$field: The field name
3911
	 * @param	string		$row: The record to edit from the database table
3912
	 * @param	string		$returnProperty: Return only a specified property (e.g. 'config' or 'config/type')
3913
	 * @return	array		The (overriden) field configuration found in $TCA[<table>]['columns'][<field>].
3914
	 */
3915
	public function getFieldConfiguration($table, $field, $row, $returnProperty=null) {
3916
		self::loadTCA($table);
3917
		$fieldConf = $GLOBALS['TCA'][$table]['columns'][$field];
3918
		$typeNum = self::getRTypeNum($table, $row);
3919
		if (isset($GLOBALS['TCA'][$table]['types'][$typeNum]['overrideColumns'][$field])) {
3920
			$overrideField =& $GLOBALS['TCA'][$table]['types'][$typeNum]['overrideColumns'][$field];
3921
			if (is_array($overrideField)) {
3922
					// The type of a field cannot be changed, since it might have negative side-effects:
3923
				if (isset($overrideField['config']['type'])) {
3924
					unset($overrideField['config']['type']);
3925
				}
3926
					// Override the field configuration:
3927
				$fieldConf = t3lib_div::array_merge_recursive_overrule($fieldConf, $overrideField);
3928
			}
3929
		}
3930
		if ($returnProperty) {
3931
			$fieldConf = self::arrayWalkByPath($fieldConf, $returnProperty);
3932
		}
3933
		return $fieldConf;
3934
	}
3935

  
3936
	/**
3843 3937
	 * Looks for a sheet-definition in the input data structure array. If found it will return the data structure for the sheet given as $sheet (if found).
3844 3938
	 * If the sheet definition is in an external file that file is parsed and the data structure inside of that is returned.
3845 3939
	 * Usage: 5
t3lib/class.t3lib_tcemain.php (Arbeitskopie)
1235 1235
		}
1236 1236

  
1237 1237
			// Get current value:
1238
		$curValueRec = $this->recordInfo($table,$id,$field);
1238
		$typeField = $TCA[$table]['ctrl']['type'];
1239
		$curValueRec = $this->recordInfo($table, $id, $field.($typeField ? ','.$typeField : ''));
1239 1240
		$curValue = $curValueRec[$field];
1240 1241

  
1241 1242
			// Getting config for the field
1242
		$tcaFieldConf = $TCA[$table]['columns'][$field]['config'];
1243
		$tcaFieldConf = t3lib_div::getFieldConfiguration($table, $field, $curValueRec, 'config');
1243 1244

  
1244 1245
			// Preform processing:
1245 1246
		$res = $this->checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$this->uploadedFileArray[$table][$id][$field],$tscPID);
......
2564 2565
						if (!in_array($field,$nonFields))	{
2565 2566

  
2566 2567
								// Get TCA configuration for the field:
2567
							$conf = $TCA[$table]['columns'][$field]['config'];
2568
							$conf = t3lib_div::getFieldConfiguration($table, $field, $row, 'config');
2568 2569

  
2569 2570
								// Preparation/Processing of the value:
2570 2571
							if ($field=='pid')	{	// "pid" is hardcoded of course:
......
2751 2752
						if (!in_array($field,$nonFields))	{
2752 2753

  
2753 2754
								// Get TCA configuration for the field:
2754
							$conf = $TCA[$table]['columns'][$field]['config'];
2755
							$conf = t3lib_div::getFieldConfiguration($table, $field, $row, 'config');
2755 2756
							if (is_array($conf))	{
2756 2757
									// Processing based on the TCA config field type (files, references, flexforms...)
2757 2758
								$value = $this->copyRecord_procBasedOnFieldType($table,$uid,$field,$value,$row,$conf,$pid);
......
3769 3770
						if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))	{
3770 3771
							$fArray = $fileFieldArr;
3771 3772
							foreach($fArray as $theField)	{	// MISSING: Support for MM file relations!
3772
								$this->extFileFunctions($table,$theField,$row[$theField],'deleteAll');		// This deletes files that belonged to this record.
3773
								$this->extFileFunctions($table,$theField,$row,'deleteAll');		// This deletes files that belonged to this record.
3773 3774
							}
3774 3775
						} else {
3775 3776
							$this->log($table,$uid,3,0,100,'Delete: Zero rows in result when trying to read filenames from record which should be deleted');
......
4782 4783
	function getVersionizedIncomingFieldArray($table, $id, &$incomingFieldArray, &$registerDBList) {
4783 4784
		if (is_array($registerDBList[$table][$id])) {
4784 4785
			foreach ($incomingFieldArray as $field => $value) {
4785
				$fieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
4786
				$fieldConf = t3lib_div::getFieldConfiguration($table, $field, $incomingFieldArray, 'config');
4786 4787
				if ($registerDBList[$table][$id][$field] && $foreignTable = $fieldConf['foreign_table']) {
4787 4788
					$newValueArray = array();
4788 4789
					$origValueArray = explode(',', $value);
......
6218 6219
	 *
6219 6220
	 * @param	string		Table name
6220 6221
	 * @param	string		Field name
6221
	 * @param	string		List of files to work on from field
6222
	 * @param	string		Record row
6222 6223
	 * @param	string		Function, eg. "deleteAll" which will delete all files listed.
6223 6224
	 * @return	void
6224 6225
	 */
6225
	function extFileFunctions($table,$field,$filelist,$func)	{
6226
	function extFileFunctions($table,$field,$row,$func)	{
6226 6227
		global $TCA;
6227 6228
		t3lib_div::loadTCA($table);
6228
		$uploadFolder = $TCA[$table]['columns'][$field]['config']['uploadfolder'];
6229
		$uploadFolder = t3lib_div::getFieldConfiguration($table, $field, $row, 'config/uploadfolder');
6230
		$filelist = $row[$field];
6229 6231
		if ($uploadFolder && trim($filelist))	{
6230 6232
			$uploadPath = $this->destPathFromUploadFolder($uploadFolder);
6231 6233
			$fileArray = explode(',',$filelist);