irre_Localized_2007-09-27.diff

Administrator Admin, 2007-09-27 01:10

Download (11.5 KB)

View differences:

TYPO3core.irreLocalized/t3lib/class.t3lib_tceforms_inline.php 2007-09-27 00:18:20.890323871 +0200
138 138
	 */
139 139
	function getSingleField_typeInline($table,$field,$row,&$PA) {
140 140
			// check the TCA configuration - if false is returned, something was wrong
141
		if ($this->checkConfiguration($PA['fieldConf']['config']) === false) return false;
141
		if ($this->checkConfiguration($PA['fieldConf']['config'], $row) === false) return false;
142 142

  
143 143
			// count the number of processed inline elements
144 144
		$this->inlineCount++;
......
183 183
			// e.g. inline[<pid>][<table1>][<uid1>][<field1>][<table2>][<uid2>][<field2>]
184 184
		$nameObject = $this->inlineNames['object'];
185 185
			// get the records related to this inline record
186
		$recordList = $this->getRelatedRecords($table,$field,$row,$PA,$config);
186
		$parentLangField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
187
		$langField = $GLOBALS['TCA'][$foreign_table]['ctrl']['languageField'];
188
		$langParent = $GLOBALS['TCA'][$foreign_table]['ctrl']['transOrigPointerField'];
189
			// When either "original" or "inherit" mode is set and we are processing an alternate
190
			// language record ($row[$parentLangField] / $row['sys_languge_uid'] is set) we do not
191
			// use the ID's of the records of the current IRRE container but rather those of it's
192
			// language parent.
193
		if (($config['languageMode']=='original'||$config['languageMode']=='inherit')&&$langField&&$parentLangField&&$row[$parentLangField]&&$row[$langParent])	{
194
				// Fetch language parent
195
			$parentRec = $this->getRecord(0, $table, $row[$langParent]);
196
			if ($parentRec)	{
197
				$cpPA = $PA;
198
				$cpPA['itemFormElValue'] = $parentRec[$field];
199
				$recordList = $this->getRelatedRecords($table,$field,$row,$cpPA,$config);
200
					// When inherit mode is set, set a flag in $config so the buttons for
201
					// creating new, deleteing, and moving around IRRE records get disables
202
					// The sort-order and everything else is defined in the main-language
203
				if ($config['languageMode']=='inherit')	{
204
					$config['appearance']['isInherited'] = 1;
205
				}
206
			}
207
			// How shall we handle the case when a translated record has a l18n_parent set but the referenced
208
			// record is not available any more ???
209
		} else	{
210
			$recordList = $this->getRelatedRecords($table,$field,$row,$PA,$config);
211
		}
187 212
			// set the first and last record to the config array
188 213
		$config['inline']['first'] = $recordList[0]['uid'];
189 214
		$config['inline']['last'] = $recordList[count($recordList)-1]['uid'];
......
467 492
		$isPagesTable = $foreign_table == 'pages' ? true : false;
468 493
		$isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
469 494
		$enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || (!$isOnSymmetricSide && $config['foreign_sortby']) || ($isOnSymmetricSide && $config['symmetric_sortby']) ? true : false;
495
		$enableManualSorting &= !$config['appearance']['isInherited'];
470 496

  
471 497
		$nameObjectFt = $this->inlineNames['object'].'['.$foreign_table.']';
472 498
		$nameObjectFtId = $nameObjectFt.'['.$rec['uid'].']';
......
530 556

  
531 557
				// "Hide/Unhide" links:
532 558
			$hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
533
			if ($permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$foreign_table.':'.$hiddenField)))	{
559
			if (!$config['appearance']['isInherited'] && $permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$foreign_table.':'.$hiddenField)))	{
534 560
				$onClick = "return inline.enableDisableRecord('".$nameObjectFtId."')";
535 561
				if ($rec[$hiddenField])	{
536 562
					$cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
......
544 570
			}
545 571

  
546 572
				// "Delete" link:
547
			if (
548
				($isPagesTable && ($localCalcPerms&4)) || (!$isPagesTable && ($calcPerms&16))
549
				)	{
573
			if ( !$config['appearance']['isInherited'] && (($isPagesTable && ($localCalcPerms&4)) || (!$isPagesTable && ($calcPerms&16))))	{
550 574
				$onClick = "inline.deleteRecord('".$nameObjectFtId."');";
551 575
				$cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')).')) {	'.$onClick.' } return false;').'">'.
552 576
						'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:delete',1).'" alt="" />'.
......
849 873
			$record[$config['foreign_selector']] .= $foreignUid;
850 874
		}
851 875

  
876
			// Get some values into local variables
877
		$parentLangField = $GLOBALS['TCA'][$parent['table']]['ctrl']['languageField'];
878
		$langField = $GLOBALS['TCA'][$current['table']]['ctrl']['languageField'];
879
		$langMode = $config['languageMode'];
880

  
881
			// When records get created in "separate" mode additionally set the languagePointer fields
882
			// (usualy "sys_language_uid") of the newly created record to the correct langauge.
883
		if ($langField && ($langMode=='separate') && $parentLangField)	{
884
			$parentRec = $this->getRecord(0, $parent['table'], $parent['uid']);
885
			$record[$langField] = $parentRec[$parentLangField];
886
		}
887

  
888
			// We will never create records this way when IRRE records are set to be inherited - they
889
			// get created by the "localize" method of TCEmain
890
		if ($langField && ($langMode=='inherit') && $parentLangField)	{
891
			$parentRec = $this->getRecord(0, $parent['table'], $parent['uid']);
892
			if ($parentRec[$parentLangField])	{
893
				$jsonArray = array(
894
					'data'	=> 'Access denied',
895
					'scriptCall' => array(
896
						"alert('Access denied');",
897
					)
898
				);
899
				return t3lib_div::array2json($jsonArray);
900
			}
901
		}
902

  
852 903
			// the HTML-object-id's prefix of the dynamically created record
853 904
		$objectPrefix = $this->inlineNames['object'].'['.$current['table'].']';
854 905
		$objectId = $objectPrefix.'['.$record['uid'].']';
......
979 1030

  
980 1031
			// Perform modification of the selected items array:
981 1032
		$itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
1033

  
1034
		$ftable = $config['foreign_table'];
1035
		$parentLangField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
1036

  
1037
		$langField = $GLOBALS['TCA'][$ftable]['ctrl']['languageField'];
1038
		$langParent = $GLOBALS['TCA'][$ftable]['ctrl']['transOrigPointerField'];
1039

  
1040
		$langMode = $config['languageMode'];
1041

  
982 1042
		foreach($itemArray as $tk => $tv) {
983 1043
			$tvP = explode('|',$tv,2);
984 1044
				// get the records for this uid using t3lib_transferdata
985
			$records[] = $this->getRecord($row['pid'], $config['foreign_table'], $tvP[0]);
1045
			$rec = $this->getRecord($row['pid'], $ftable, $tvP[0]);
1046
			if (!($langField && $langMode && $parentLangField))	{
1047
					// No translation at all
1048
				$records[] = $rec;
1049
			} else	{
1050
				switch ($langMode)	{
1051
					case 'original':
1052
							// Return the record if it is default language or for ALL
1053
						if ($rec[$langField]<=0)	{
1054
							$records[] = $rec;
1055
						}
1056
					break;
1057
					case 'inherit':
1058
						if ($rec[$langField]==-1)	{
1059
								// Return the record if it is for ALL
1060
							$records[] = $rec;
1061
						} elseif ($rec[$langField]==0)	{
1062
							if ($row[$parentLangField]==0)	{
1063
									// Return the record if it is for default languge
1064
									// and its container is also default language
1065
								$records[] = $rec;
1066
							} else	{
1067
									// When the container is an alternative language
1068
									// then fetch the translated record for the current one
1069
 	 							list($transRec) = t3lib_BEfunc::getRecordsByField($ftable, $langParent, $rec['uid']);
1070
								if (is_array($transRec))	{
1071
									$records[] = $transRec;
1072
								} else	{
1073
										// When there is no translated record for the current one - then
1074
										// localize it from the current one.
1075
									$cmd = array();
1076
									$cmd[$ftable][$rec['uid']]['localize'] = $row['sys_language_uid'];
1077
									$tcemain = t3lib_div::makeInstance('t3lib_TCEmain');
1078
									$tcemain->start(array(), $cmd);
1079
									$tcemain->process_cmdmap();
1080
 	 								list($transRec) = t3lib_BEfunc::getRecordsByField($ftable, $langParent, $rec['uid']);
1081
									if (is_array($transRec))	{
1082
										$records[] = $transRec;
1083
									}
1084
								}
1085
							}
1086
						}
1087
					break;
1088

  
1089
					case 'separate':
1090
					default:
1091
							// Return IRRE record Only if the currently prcesses records language is
1092
							// the same as the language of the container it is in
1093
						if (($rec[$langField]==$row[$parentLangField])||($rec[$langField]==-1))	{
1094
							$records[] = $rec;
1095
						}
1096
					break;
1097
				}
1098
			}
986 1099
		}
987 1100

  
988 1101
		return $records;
......
1294 1407
	 * @param	array		$config: Reference to the TCA field configuration
1295 1408
	 * @return	boolean		If critical configuration errors were found, false is returned
1296 1409
	 */
1297
	function checkConfiguration(&$config) {
1410
	function checkConfiguration(&$config, $row) {
1298 1411
		$foreign_table = $config['foreign_table'];
1299 1412

  
1300 1413
			// An inline field must have a foreign_table, if not, stop all further inline actions for this field:
......
1306 1419
			$config['appearance'] = array();
1307 1420
		}
1308 1421
			// Set the position/appearance of the "Create new record" link:
1309
		if ($config['foreign_selector'] && !$config['appearance']['useCombination']) {
1422
		if (($row['sys_language_uid'] && $config['languageMode']=='inherit') || ($config['foreign_selector'] && !$config['appearance']['useCombination'])) {
1310 1423
			$config['appearance']['newRecordLinkPosition'] = 'none';
1311 1424
		} elseif (!in_array($config['appearance']['newRecordLinkPosition'], array('top', 'bottom', 'both', 'none'))) {
1312 1425
			$config['appearance']['newRecordLinkPosition'] = 'top';
TYPO3core.irreLocalized/t3lib/class.t3lib_tceforms.php 2007-09-26 22:08:26.262133324 +0200
642 642
			foreach ($out_array as $idx => $sheetContent)	{
643 643
				$resstr = implode('', $sheetContent);
644 644
				if ($resstr) {
645
					$parts[] = array(
645
					$parts[$idx] = array(
646 646
						'label' => $out_array_meta[$idx]['title'],
647 647
						'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
648 648
								$resstr.
TYPO3core.irreLocalized/t3lib/class.t3lib_tcemain.php 2007-09-27 00:14:38.741664340 +0200
2099 2099
			if ($tcaFieldConf['foreign_field']) {
2100 2100
					// if the record was imported, sorting was also imported, so skip this
2101 2101
				$skipSorting = $this->callFromImpExp ? true : false;
2102
					// When IRRE langugae mode is set to "original" and we have a translated
2103
					// container then set the ID to the UID of the containers l18n_parent.
2104
				if ($tcaFieldConf['languageMode']=='original')	{
2105
					$langField = $GLOBALS['TCA'][$currentTable]['ctrl']['languageField'];
2106
					$langParent = $GLOBALS['TCA'][$currentTable]['ctrl']['transOrigPointerField'];
2107
					$origRec = t3lib_BEfunc::getRecordWSOL($currentTable, $id);
2108
					if ($origRec[$langField]&&$origRec[$langParent])	{
2109
						$id = $origRec[$langParent];
2110
					}
2111
				}
2102 2112
					// update record in intermediate table (sorting & pointer uid to parent record)
2103 2113
				$dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
2104 2114
				$valueArray = $dbAnalysis->countItems();