0016374_4-5.patch

Administrator Admin, 2010-11-13 19:11

Download (81.5 KB)

View differences:

t3lib/core_autoload.php (Arbeitskopie)
135 135
	't3lib_tceforms_suggest' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest.php',
136 136
	't3lib_tceforms_suggest_defaultreceiver' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php',
137 137
	't3lib_utility_client' => PATH_t3lib . 'utility/class.t3lib_utility_client.php',
138
	't3lib_utility_dependency' => PATH_t3lib . 'utility/class.t3lib_utility_dependency.php',
139
	't3lib_utility_dependency_callback' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_callback.php',
140
	't3lib_utility_dependency_element' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_element.php',
141
	't3lib_utility_dependency_factory' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_factory.php',
142
	't3lib_utility_dependency_reference' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_reference.php',
138 143
	't3lib_utility_http' => PATH_t3lib . 'utility/class.t3lib_utility_http.php',
139 144
	't3lib_utility_mail' => PATH_t3lib . 'utility/class.t3lib_utility_mail.php',
140 145
	't3lib_utility_phpoptions' => PATH_t3lib . 'utility/class.t3lib_utility_phpoptions.php',
t3lib/class.t3lib_tcemain.php (Arbeitskopie)
337 337
	var $copyMappingArray = Array();			// Used by the copy action to track the ids of new pages so subpages are correctly inserted! THIS is internally cleared for each executed copy operation! DO NOT USE THIS FROM OUTSIDE! Read from copyMappingArray_merged instead which is accumulating this information.
338 338
	var $remapStack = array();					// array used for remapping uids and values at the end of process_datamap
339 339
	var $remapStackRecords = array();			// array used for remapping uids and values at the end of process_datamap (e.g. $remapStackRecords[<table>][<uid>] = <index in $remapStack>)
340
	protected $remapStackChildIds = array();	// array used for checking whether new children need to be remapped
341
	protected $remapStackActions = array();		// array used for executing addition actions after remapping happened (sett processRemapStack())
342
	protected $remapStackRefIndex = array();	// array used for executing post-processing on the reference index
340 343
	var $updateRefIndexStack = array();			// array used for additional calls to $this->updateRefIndex
341 344
	var $callFromImpExp = false;				// tells, that this TCEmain was called from tx_impext - this variable is set by tx_impexp
342 345
	var $newIndexMap = array();					// Array for new flexform index mapping
......
911 914
											}
912 915
											$phShadowId = $this->insertDB($table,$id,$fieldArray,TRUE,0,TRUE);	// When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
913 916
											if ($phShadowId)	{
914
												$this->placeholderShadowing($table,$phShadowId);
917
													// Processes fields of the placeholder record:
918
												$this->triggerRemapAction(
919
													$table,
920
													$id,
921
													array($this, 'placeholderShadowing'),
922
													array($table, $phShadowId)
923
												);
915 924
													// Hold auto-versionized ids of placeholders:
916 925
												$this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
917 926
											}
......
1533 1542
				// check, if there is a NEW... id in the value, that should be substituded later
1534 1543
			if (strpos($value, 'NEW') !== false) {
1535 1544
				$this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
1545
				$this->addNewValuesToRemapStackChildIds($valueArray);
1536 1546
				$this->remapStack[] = array(
1537 1547
					'func' => 'checkValue_group_select_processDBdata',
1538 1548
					'args' => array($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field),
......
1957 1967
			// We need to decide whether we use the stack or can save the relation directly.
1958 1968
		if(strpos($value, 'NEW') !== false || !t3lib_div::testInt($id)) {
1959 1969
			$this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
1970
			$this->addNewValuesToRemapStackChildIds($valueArray);
1960 1971
			$this->remapStack[] = array(
1961 1972
				'func' => 'checkValue_inline_processDBdata',
1962 1973
				'args' => array($valueArray, $tcaFieldConf, $id, $status, $table, $field),
......
2664 2675
			// Finally, before exit, check if there are ID references to remap.
2665 2676
			// This might be the case if versioning or copying has taken place!
2666 2677
		$this->remapListedDBRecords();
2678
		$this->processRemapStack();
2667 2679

  
2668 2680
		foreach ($hookObjectsArr as $hookObj) {
2669 2681
			if (method_exists($hookObj, 'processCmdmap_afterFinish')) {
......
2809 2821
						if ($theNewSQLID) {
2810 2822
							$this->copyRecord_fixRTEmagicImages($table, t3lib_BEfunc::wsMapId($table, $theNewSQLID));
2811 2823
							$this->copyMappingArray[$table][$origUid] = $theNewSQLID;
2824
								// Keep automatically versionized record information:
2825
							if (isset($copyTCE->autoVersionIdMap[$table][$theNewSQLID])) {
2826
								$this->autoVersionIdMap[$table][$theNewSQLID] = $copyTCE->autoVersionIdMap[$table][$theNewSQLID];
2827
							}
2812 2828
						}
2813 2829

  
2814 2830
							// Copy back the cached TSconfig
......
3115 3131
					} else {
3116 3132
						if (!t3lib_div::testInt($realDestPid)) {
3117 3133
							$newId = $this->copyRecord($v['table'], $v['id'], -$v['id']);
3118
						} elseif ($realDestPid == -1) {
3119
							$newId = $this->versionizeRecord($v['table'], $v['id'], 'Auto-created for WS #'.$this->BE_USER->workspace);
3134
						} elseif ($realDestPid == -1 && t3lib_BEfunc::isTableWorkspaceEnabled($v['table'])) {
3135
							$workspaceVersion = t3lib_BEfunc::getWorkspaceVersionOfRecord(
3136
								$this->BE_USER->workspace, $v['table'], $v['id'], 'uid'
3137
							);
3138
								// If workspace version does not exist, create a new one:
3139
							if ($workspaceVersion === FALSE) {
3140
								$newId = $this->versionizeRecord($v['table'], $v['id'], 'Auto-created for WS #' . $this->BE_USER->workspace);
3141
								// If workspace version already exists, use it:
3142
							} else {
3143
								$newId = $workspaceVersion['uid'];
3144
							}
3120 3145
						} else {
3121 3146
							$newId = $this->copyRecord_raw($v['table'], $v['id'], $realDestPid);
3122 3147
						}
......
3761 3786

  
3762 3787
												// Execute the copy:
3763 3788
											$newId = $this->copyRecord($table, $uid, -$uid, 1, $overrideValues, implode(',', $excludeFields), $language);
3789
											$autoVersionNewId = $this->getAutoVersionId($table, $newId);
3790
											if (is_null($autoVersionNewId) === FALSE) {
3791
												$this->triggerRemapAction(
3792
													$table,
3793
													$newId,
3794
													array($this, 'placeholderShadowing'),
3795
													array($table, $autoVersionNewId),
3796
													TRUE
3797
												);
3798
											}
3764 3799
										} else {
3765 3800

  
3766 3801
												// Create new record:
......
3855 3890
						if (t3lib_div::testInt($type) && isset($elementsOriginal[$type])) {
3856 3891
							$item = $elementsOriginal[$type];
3857 3892
							$item['id'] = $this->localize($item['table'], $item['id'], $language);
3893
							$item['id'] = $this->overlayAutoVersionId($item['table'], $item['id']);
3858 3894
							$dbAnalysisCurrent->itemArray[] = $item;
3859 3895
						} elseif (t3lib_div::inList('localize,synchronize', $type)) {
3860 3896
							foreach ($elementsOriginal as $originalId => $item) {
3861 3897
								$item['id'] = $this->localize($item['table'], $item['id'], $language);
3898
								$item['id'] = $this->overlayAutoVersionId($item['table'], $item['id']);
3862 3899
								$dbAnalysisCurrent->itemArray[] = $item;
3863 3900
							}
3864 3901
						}
......
4794 4831
				$this->remapListedDBRecords_procDBRefs($conf, $value, $theUidToUpdate, $table);
4795 4832

  
4796 4833
			} elseif ($inlineType !== false) {
4834
				/** @var $dbAnalysis t3lib_loadDBGroup */
4797 4835
				$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
4798 4836
				$dbAnalysis->start($value, $conf['foreign_table'], '', 0, $table, $conf);
4799 4837

  
4838
					// Update child records if using pointer fields ('foreign_field'):
4839
				if ($inlineType == 'field') {
4840
					$dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
4841
				}
4842

  
4800 4843
					// If the current field is set on a page record, update the pid of related child records:
4801 4844
				if ($table == 'pages') {
4802 4845
					$thePidToUpdate = $theUidToUpdate;
......
4806 4849
					$thePidToUpdate = $this->copyMappingArray_merged['pages'][$thePidToUpdate];
4807 4850
				}
4808 4851

  
4809
					// Update child records if using pointer fields ('foreign_field'):
4810
				if ($inlineType == 'field') {
4811
					$dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
4812
				}
4813

  
4814
					// Update child records if change to pid is required:
4852
					// // Update child records if change to pid is required (only if the current record is not on a workspace):
4815 4853
				if ($thePidToUpdate) {
4816 4854
					$updateValues = array('pid' => $thePidToUpdate);
4817 4855
					foreach ($dbAnalysis->itemArray as $v) {
4818
						if ($v['id'] && $v['table']) {
4856
						if ($v['id'] && $v['table'] && is_null(t3lib_BEfunc::getLiveVersionIdOfRecord($v['table'], $v['id']))) {
4819 4857
							$GLOBALS['TYPO3_DB']->exec_UPDATEquery($v['table'], 'uid='.intval($v['id']), $updateValues);
4820 4858
						}
4821 4859
					}
......
4831 4869
	 * @return	void
4832 4870
	 */
4833 4871
	function processRemapStack() {
4872
			// Processes the remap stack:
4834 4873
		if(is_array($this->remapStack)) {
4835 4874
			foreach($this->remapStack as $remapAction) {
4836 4875
					// If no position index for the arguments was set, skip this remap action:
......
4900 4939
				}
4901 4940
			}
4902 4941
		}
4942
			// Processes the remap stack actions:
4943
		if ($this->remapStackActions) {
4944
			foreach ($this->remapStackActions as $action) {
4945
				if (isset($action['callback']) && isset($action['arguments'])) {
4946
					call_user_func_array(
4947
						$action['callback'],
4948
						$action['arguments']
4949
					);
4950
				}
4951
			}
4952
		}
4953
			// Processes the reference index updates of the remap stack:
4954
		foreach ($this->remapStackRefIndex as $table => $idArray) {
4955
			foreach ($idArray as $id) {
4956
				$this->updateRefIndex($table, $id);
4957
				unset($this->remapStackRefIndex[$table][$id]);
4958
			}
4959
		}
4903 4960
			// Reset:
4904 4961
		$this->remapStack = array();
4905 4962
		$this->remapStackRecords = array();
4963
		$this->remapStackActions = array();
4964
		$this->remapStackRefIndex = array();
4906 4965
	}
4907 4966

  
4967
 	/**
4968
	 * Triggers a remap action for a specific record.
4969
	 *
4970
	 * Some records are post-processed by the processRemapStack() method (e.g. IRRE children).
4971
	 * This method determines wether an action/modification is executed directly to a record
4972
	 * or is postponed to happen after remapping data.
4973
	 *
4974
	 * @param string $table Name of the table
4975
	 * @param string $id Id of the record (can also be a "NEW..." string)
4976
 	 * @param array $callback The method to be called
4977
	 * @param array $arguments The arguments to be submitted to the callback method
4978
	 * @param boolean $forceRemapStackActions Whether to force to use the stack
4979
	 * @return void
4980
	 *
4981
	 * @see processRemapStack
4982
	 */
4983
	protected function triggerRemapAction($table, $id, array $callback, array $arguments, $forceRemapStackActions = FALSE) {
4984
			// Check whether the affected record is marked to be remapped:
4985
		if (!$forceRemapStackActions && !isset($this->remapStackRecords[$table][$id]) && !isset($this->remapStackChildIds[$id])) {
4986
			call_user_func_array($callback, $arguments);
4987
		} else {
4988
			$this->remapStackActions[] = array(
4989
				'affects' => array(
4990
					'table' => $table,
4991
					'id' => $id,
4992
				),
4993
				'callback' => $callback,
4994
				'arguments' => $arguments,
4995
			);
4996
		}
4997
	}
4998

  
4908 4999
	/**
5000
	 * Adds a table-id-pair to the reference index remapping stack.
5001
	 *
5002
	 * @param string $table
5003
	 * @param integer $id
5004
	 * @return void
5005
	 */
5006
	public function addRemapStackRefIndex($table, $id) {
5007
		$this->remapStackRefIndex[$table][$id] = $id;
5008
	}
5009

  
5010
	/**
4909 5011
	 * If a parent record was versionized on a workspace in $this->process_datamap,
4910 5012
	 * it might be possible, that child records (e.g. on using IRRE) were affected.
4911 5013
	 * This function finds these relations and updates their uids in the $incomingFieldArray.
......
6921 7023
		}
6922 7024
		return $result;
6923 7025
	}
7026

  
7027
	/**
7028
	 * Gets the automatically versionized id of a record.
7029
	 *
7030
	 * @param string $table Name of the table
7031
	 * @param integer $id Uid of the record
7032
	 * @return integer
7033
	 */
7034
	protected function getAutoVersionId($table, $id) {
7035
		$result = NULL;
7036

  
7037
		if (isset($this->autoVersionIdMap[$table][$id])) {
7038
			$result = $this->autoVersionIdMap[$table][$id];
7039
		}
7040

  
7041
		return $result;
7042
	}
7043

  
7044
	/**
7045
	 * Overlays the automatically versionized id of a record.
7046
	 *
7047
	 * @param string $table Name of the table
7048
	 * @param integer $id Uid of the record
7049
	 * @return integer
7050
	 */
7051
	protected function overlayAutoVersionId($table, $id) {
7052
		$autoVersionId = $this->getAutoVersionId($table, $id);
7053

  
7054
		if (is_null($autoVersionId) === FALSE) {
7055
			$id = $autoVersionId;
7056
		}
7057

  
7058
		return $id;
7059
	}
7060

  
7061
	/**
7062
	 * Adds new values to the remapStackChildIds array.
7063
	 *
7064
	 * @param array $idValues uid values
7065
	 * @return void
7066
	 */
7067
	protected function addNewValuesToRemapStackChildIds(array $idValues) {
7068
		foreach ($idValues as $idValue) {
7069
			if (strpos($idValue, 'NEW') === 0) {
7070
				$this->remapStackChildIds[$idValue] = TRUE;
7071
			}
7072
		}
7073
	}
6924 7074
}
6925 7075

  
6926 7076

  
t3lib/utility/class.t3lib_utility_dependency.php (Revision 40160)
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2010 Oliver Hader <oliver@typo3.org>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Object to handle and determine dependent references of elements.
30
 */
31
class t3lib_utility_Dependency {
32
	/**
33
	 * @var t3lib_utility_Dependency_Factory
34
	 */
35
	protected $factory;
36

  
37
	/**
38
	 * @var array
39
	 */
40
	protected $elements = array();
41

  
42
	/**
43
	 * @var array
44
	 */
45
	protected $eventCallbacks = array();
46

  
47
	/**
48
	 * @var boolean
49
	 */
50
	protected $outerMostParentsRequireReferences = FALSE;
51

  
52
	/**
53
	 * @var array
54
	 */
55
	protected $outerMostParents;
56

  
57
	/**
58
	 * Sets a callback for a particular event.
59
	 *
60
	 * @param string $eventName
61
	 * @param t3lib_utility_Dependency_Callback $callback
62
	 * @return t3lib_utility_Dependency
63
	 */
64
	public function setEventCallback($eventName, t3lib_utility_Dependency_Callback $callback) {
65
		$this->eventCallbacks[$eventName] = $callback;
66
		return $this;
67
	}
68

  
69
	/**
70
	 * Executes a registered callback (if any) for a particular event.
71
	 *
72
	 * @param string $eventName
73
	 * @param object $caller
74
	 * @param array $callerArguments
75
	 * @return mixed
76
	 */
77
	public function executeEventCallback($eventName, $caller, array $callerArguments = array()) {
78
		if (isset($this->eventCallbacks[$eventName])) {
79
			/** @var $callback t3lib_utility_Dependency_Callback */
80
			$callback = $this->eventCallbacks[$eventName];
81
			return $callback->execute($callerArguments, $caller, $eventName);
82
		}
83
	}
84

  
85
	/**
86
	 * Sets the condition that outermost parents required at least one child or parent reference.
87
	 *
88
	 * @param boolean $outerMostParentsRequireReferences
89
	 * @return t3lib_utility_Dependency
90
	 */
91
	public function setOuterMostParentsRequireReferences($outerMostParentsRequireReferences) {
92
		$this->outerMostParentsRequireReferences = (bool)$outerMostParentsRequireReferences;
93
		return $this;
94
	}
95

  
96
	/**
97
	 * Adds an element to be checked for dependent references.
98
	 *
99
	 * @param string $table
100
	 * @param integer $id
101
	 * @param array $data
102
	 * @return t3lib_utility_Dependency_Element
103
	 */
104
	public function addElement($table, $id, array $data = array()) {
105
		$element = $this->getFactory()->getElement($table, $id, $data, $this);
106
		$elementName = $element->__toString();
107
		$this->elements[$elementName] = $element;
108
		return $element;
109
	}
110

  
111
	/**
112
	 * Gets the outermost parents that define complete dependent structure each.
113
	 *
114
	 * @return array
115
	 */
116
	public function getOuterMostParents() {
117
		if (!isset($this->outerMostParents)) {
118
			$this->outerMostParents = array();
119

  
120
			/** @var $element t3lib_utility_Dependency_Element */
121
			foreach ($this->elements as $element) {
122
				$this->processOuterMostParent($element);
123
			}
124
		}
125

  
126
		return $this->outerMostParents;
127
	}
128

  
129
	/**
130
	 * Processes and registers the outermost parents accordant to the registered elements.
131
	 *
132
	 * @param t3lib_utility_Dependency_Element $element
133
	 * @return void
134
	 */
135
	protected function processOuterMostParent(t3lib_utility_Dependency_Element $element) {
136
		if ($this->outerMostParentsRequireReferences === FALSE || $element->hasReferences()) {
137
			$outerMostParent = $element->getOuterMostParent();
138

  
139
			if ($outerMostParent !== FALSE) {
140
				$outerMostParentName = $outerMostParent->__toString();
141
				if (!isset($this->outerMostParents[$outerMostParentName])) {
142
					$this->outerMostParents[$outerMostParentName] = $outerMostParent;
143
				}
144
			}
145
		}
146
	}
147

  
148
	/**
149
	 * Gets all nested elements (including the parent) of a particular outermost parent element.
150
	 *
151
	 * @throws RuntimeException
152
	 * @param t3lib_utility_Dependency_Element $outerMostParent
153
	 * @return array
154
	 */
155
	public function getNestedElements(t3lib_utility_Dependency_Element $outerMostParent) {
156
		$outerMostParentName = $outerMostParent->__toString();
157

  
158
		if (!isset($this->outerMostParents[$outerMostParentName])) {
159
			throw new RuntimeException(
160
				'Element "' . $outerMostParentName . '" was detected as outermost parent.',
161
				1289318609
162
			);
163
		}
164

  
165
		$nestedStructure = array_merge(
166
			array($outerMostParentName => $outerMostParent),
167
			$outerMostParent->getNestedChildren()
168
		);
169

  
170
		return $nestedStructure;
171
	}
172

  
173
	/**
174
	 * Gets the registered elements.
175
	 *
176
	 * @return array
177
	 */
178
	public function getElements() {
179
		return $this->elements;
180
	}
181

  
182
	/**
183
	 * Gets an instance of the factory to keep track of element or reference entities.
184
	 *
185
	 * @return t3lib_utility_Dependency_Factory
186
	 */
187
	public function getFactory() {
188
		if (!isset($this->factory)) {
189
			$this->factory = t3lib_div::makeInstance('t3lib_utility_Dependency_Factory');
190
		}
191
		return $this->factory;
192
	}
193
}
t3lib/utility/dependency/class.t3lib_utility_dependency_factory.php (Revision 40160)
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2010 Oliver Hader <oliver@typo3.org>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Object to create and keep track of element or reference entities.
30
 */
31
class t3lib_utility_Dependency_Factory {
32
	/**
33
	 * @var array
34
	 */
35
	protected $elements = array();
36

  
37
	/**
38
	 * @var array
39
	 */
40
	protected $references = array();
41

  
42
	/**
43
	 * Gets and registers a new element.
44
	 *
45
	 * @param string $table
46
	 * @param integer $id
47
	 * @param array $data (optional)
48
	 * @param t3lib_utility_Dependency $dependency
49
	 * @return t3lib_utility_Dependency_Element
50
	 */
51
	public function getElement($table, $id, array $data = array(), t3lib_utility_Dependency $dependency) {
52
		$elementName = $table . ':' . $id;
53
		if (!isset($this->elements[$elementName])) {
54
			$this->elements[$elementName] = t3lib_div::makeInstance(
55
				't3lib_utility_Dependency_Element',
56
				$table, $id, $data, $dependency
57
			);
58
		}
59
		return $this->elements[$elementName];
60
	}
61

  
62
	/**
63
	 * Gets and registers a new reference.
64
	 *
65
	 * @param t3lib_utility_Dependency_Element $element
66
	 * @param string $field
67
	 * @return t3lib_utility_Dependency_Reference
68
	 */
69
	public function getReference(t3lib_utility_Dependency_Element $element, $field) {
70
		$referenceName = $element->__toString() . '.' . $field;
71
		if (!isset($this->references[$referenceName][$field])) {
72
			$this->references[$referenceName][$field] = t3lib_div::makeInstance(
73
				't3lib_utility_Dependency_Reference',
74
				$element, $field
75
			);
76
		}
77
		return $this->references[$referenceName][$field];
78
	}
79

  
80
	/**
81
	 * Gets and registers a new reference.
82
	 *
83
	 * @param string $table
84
	 * @param integer $id
85
	 * @param string $field
86
	 * @param array $data (optional
87
	 * @param t3lib_utility_Dependency $dependency
88
	 * @return t3lib_utility_Dependency_Reference
89
	 * @see getElement
90
	 * @see getReference
91
	 */
92
	public function getReferencedElement($table, $id, $field, array $data = array(), t3lib_utility_Dependency $dependency) {
93
		return $this->getReference(
94
			$this->getElement($table, $id, $data, $dependency),
95
			$field
96
		);
97
	}
98
}
t3lib/utility/dependency/class.t3lib_utility_dependency_element.php (Revision 40160)
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2010 Oliver Hader <oliver@typo3.org>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Object to hold information on a dependent database element in abstract.
30
 */
31
class t3lib_utility_Dependency_Element {
32
	const REFERENCES_ChildOf = 'childOf';
33
	const REFERENCES_ParentOf = 'parentOf';
34
	const EVENT_Construct = 't3lib_utility_Dependency_Element::construct';
35
	const EVENT_CreateChildReference = 't3lib_utility_Dependency_Element::createChildReference';
36
	const EVENT_CreateParentReference = 't3lib_utility_Dependency_Element::createParentReference';
37
	const RESPONSE_Skip = 't3lib_utility_Dependency_Element->skip';
38

  
39
	/**
40
	 * @var string
41
	 */
42
	protected $table;
43

  
44
	/**
45
	 * @var integer
46
	 */
47
	protected $id;
48

  
49
	/**
50
	 * @var array
51
	 */
52
	protected $data;
53

  
54
	/**
55
	 * @var t3lib_utility_Dependency
56
	 */
57
	protected $dependency;
58

  
59
	/**
60
	 * @var array
61
	 */
62
	protected $children;
63

  
64
	/**
65
	 * @var array
66
	 */
67
	protected $parents;
68

  
69
	/**
70
	 * @var boolean
71
	 */
72
	protected $traversingParents = FALSE;
73

  
74
	/**
75
	 * @var t3lib_utility_Dependency_Element
76
	 */
77
	protected $outerMostParent;
78

  
79
	/**
80
	 * @var array
81
	 */
82
	protected $nestedChildren;
83

  
84
	/**
85
	 * Creates this object.
86
	 *
87
	 * @param string $table
88
	 * @param integer $id
89
	 * @param array $data (optional)
90
	 * @param t3lib_utility_Dependency $dependency
91
	 */
92
	public function __construct($table, $id, array $data = array(), t3lib_utility_Dependency $dependency) {
93
		$this->table = $table;
94
		$this->id = intval($id);
95
		$this->data = $data;
96
		$this->dependency = $dependency;
97

  
98
		$this->dependency->executeEventCallback(self::EVENT_Construct, $this);
99
	}
100

  
101
	/**
102
	 * Gets the table.
103
	 *
104
	 * @return string
105
	 */
106
	public function getTable() {
107
		return $this->table;
108
	}
109

  
110
	/**
111
	 * Gets the id.
112
	 *
113
	 * @return integer
114
	 */
115
	public function getId() {
116
		return $this->id;
117
	}
118

  
119
	/**
120
	 * Gets the data.
121
	 *
122
	 * @return array
123
	 */
124
	public function getData() {
125
		return $this->data;
126
	}
127

  
128
	/**
129
	 * Gets a value for a particular key from the data.
130
	 *
131
	 * @param string $key
132
	 * @return mixed
133
	 */
134
	public function getDataValue($key) {
135
		$result = NULL;
136

  
137
		if ($this->hasDataValue($key)) {
138
			$result = $this->data[$key];
139
		}
140

  
141
		return $result;
142
	}
143

  
144
	/**
145
	 * Sets a value for a particular key in the data.
146
	 *
147
	 * @param string $key
148
	 * @param mixed $value
149
	 * @return void
150
	 */
151
	public function setDataValue($key, $value) {
152
		$this->data[$key] = $value;
153
	}
154

  
155
	/**
156
	 * Determines whether a particular key holds data.
157
	 *
158
	 * @param string $key
159
	 * @return
160
	 */
161
	public function hasDataValue($key) {
162
		return (isset($this->data[$key]));
163
	}
164

  
165
	/**
166
	 * Converts this object for string representation.
167
	 *
168
	 * @return string
169
	 */
170
	public function __toString() {
171
		return self::getIdentifier($this->table, $this->id);
172
	}
173

  
174
	/**
175
	 * Gets the parent dependency object.
176
	 *
177
	 * @return t3lib_utility_Dependency
178
	 */
179
	public function getDependency() {
180
		return $this->dependency;
181
	}
182

  
183
	/**
184
	 * Gets all child references.
185
	 *
186
	 * @return array
187
	 */
188
	public function getChildren() {
189
		if (!isset($this->children)) {
190
			$this->children = array();
191
			$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
192
				'*',
193
				'sys_refindex',
194
				'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->table, 'sys_refindex') .
195
					' AND recuid=' . $this->id
196
			);
197
			if (is_array($rows)) {
198
				foreach ($rows as $row) {
199
					$reference = $this->getDependency()->getFactory()->getReferencedElement(
200
						$row['ref_table'], $row['ref_uid'], $row['field'], array(), $this->getDependency()
201
					);
202
					$callbackResponse = $this->dependency->executeEventCallback(
203
						self::EVENT_CreateChildReference,
204
						$this, array('reference' => $reference)
205
					);
206
					if ($callbackResponse !== self::RESPONSE_Skip) {
207
						$this->children[] = $reference;
208
					}
209
				}
210
			}
211
		}
212
		return $this->children;
213
	}
214

  
215
	/**
216
	 * Gets all parent references.
217
	 *
218
	 * @return array
219
	 */
220
	public function getParents() {
221
		if (!isset($this->parents)) {
222
			$this->parents = array();
223
			$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
224
				'*',
225
				'sys_refindex',
226
				'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->table, 'sys_refindex') .
227
					' AND deleted=0 AND ref_uid=' . $this->id
228
			);
229
			if (is_array($rows)) {
230
				foreach ($rows as $row) {
231
					$reference = $this->getDependency()->getFactory()->getReferencedElement(
232
						$row['tablename'], $row['recuid'], $row['field'], array(), $this->getDependency()
233
					);
234
					$callbackResponse = $this->dependency->executeEventCallback(
235
						self::EVENT_CreateParentReference,
236
						$this, array('reference' => $reference)
237
					);
238
					if ($callbackResponse !== self::RESPONSE_Skip) {
239
						$this->parents[] = $reference;
240
					}
241
				}
242
			}
243
		}
244
		return $this->parents;
245
	}
246

  
247
	/**
248
	 * Determines whether there are child or parent references.
249
	 *
250
	 * @return boolean
251
	 */
252
	public function hasReferences() {
253
		return (count($this->getChildren()) > 0 || count($this->getParents()) > 0);
254
	}
255

  
256
	/**
257
	 * Gets the outermost parent element.
258
	 *
259
	 * @return t3lib_utility_Dependency_Element
260
	 */
261
	public function getOuterMostParent() {
262
		if (!isset($this->outerMostParent)) {
263
			$parents = $this->getParents();
264
			if (count($parents) === 0) {
265
				$this->outerMostParent = $this;
266
			} else {
267
				$this->outerMostParent = FALSE;
268
				/** @var $parent t3lib_utility_Dependency_Reference */
269
				foreach ($parents as $parent) {
270
					$outerMostParent = $parent->getElement()->getOuterMostParent();
271
					if ($outerMostParent instanceof t3lib_utility_Dependency_Element) {
272
						$this->outerMostParent = $outerMostParent;
273
						break;
274
					} elseif ($outerMostParent === FALSE) {
275
						break;
276
					}
277
				}
278
			}
279
		}
280

  
281
		return $this->outerMostParent;
282
	}
283

  
284
	/**
285
	 * Gets nested children accumulated.
286
	 *
287
	 * @return array
288
	 */
289
	public function getNestedChildren() {
290
		if (!isset($this->nestedChildren)) {
291
			$this->nestedChildren = array();
292
			$children = $this->getChildren();
293
			/** @var $child t3lib_utility_Dependency_Reference */
294
			foreach ($children as $child) {
295
				$this->nestedChildren = array_merge(
296
					$this->nestedChildren,
297
					array($child->getElement()->__toString() => $child->getElement()),
298
					$child->getElement()->getNestedChildren()
299
				);
300
			}
301
		}
302

  
303
		return $this->nestedChildren;
304
	}
305

  
306
	/**
307
	 * Converts the object for string representation.
308
	 *
309
	 * @param string $table
310
	 * @param integer $id
311
	 * @return string
312
	 */
313
	public static function getIdentifier($table, $id) {
314
		return $table . ':' . $id;
315
	}
316
}
t3lib/utility/dependency/class.t3lib_utility_dependency_callback.php (Revision 40160)
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2010 Oliver Hader <oliver@typo3.org>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Object to hold information on a callback to a defined object and method.
30
 */
31
class t3lib_utility_Dependency_Callback {
32
	/**
33
	 * @var object
34
	 */
35
	protected $object;
36

  
37
	/**
38
	 * @var string
39
	 */
40
	protected $method;
41

  
42
	/**
43
	 * @var array
44
	 */
45
	protected $targetArguments;
46

  
47
	/**
48
	 * Creates the objects.
49
	 *
50
	 * @param object $object
51
	 * @param string $method
52
	 * @param array $targetArguments (optional)
53
	 */
54
	public function __construct($object, $method, array $targetArguments = array()) {
55
		$this->object = $object;
56
		$this->method = $method;
57
		$this->targetArguments = $targetArguments;
58
		$this->targetArguments['target'] = $object;
59
	}
60

  
61
	/**
62
	 * Executes the callback.
63
	 *
64
	 * @param array $callerArguments
65
	 * @param object $caller
66
	 * @param string $eventName
67
	 * @return mixed
68
	 */
69
	public function execute(array $callerArguments = array(), $caller, $eventName) {
70
		return call_user_func_array(
71
			array($this->object, $this->method),
72
			array($callerArguments, $this->targetArguments, $caller, $eventName)
73
		);
74
	}
75
}
t3lib/utility/dependency/class.t3lib_utility_dependency_reference.php (Revision 40160)
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2010 Oliver Hader <oliver@typo3.org>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Object to hold reference information of a database field and one accordant element.
30
 */
31
class t3lib_utility_Dependency_Reference {
32
	/**
33
	 * @var t3lib_utility_Dependency_Element
34
	 */
35
	protected $element;
36

  
37
	/**
38
	 * @var string
39
	 */
40
	protected $field;
41

  
42
	/**
43
	 * Creates this object.
44
	 *
45
	 * @param t3lib_utility_Dependency_Element $element
46
	 * @param string $field
47
	 */
48
	public function __construct(t3lib_utility_Dependency_Element $element, $field) {
49
		$this->element = $element;
50
		$this->field = $field;
51
	}
52

  
53
	/**
54
	 * Gets the elements.
55
	 *
56
	 * @return t3lib_utility_Dependency_Element
57
	 */
58
	public function getElement() {
59
		return $this->element;
60
	}
61

  
62
	/**
63
	 * Gets the field.
64
	 *
65
	 * @return string
66
	 */
67
	public function getField() {
68
		return $this->field;
69
	}
70

  
71
	/**
72
	 * Converts this object for string representation.
73
	 *
74
	 * @return string
75
	 */
76
	public function __toString() {
77
		return $this->element . '.' . $this->field;
78
	}
79
}
t3lib/class.t3lib_befunc.php (Arbeitskopie)
4004 4004
	 * @return	array		If found, the record, otherwise nothing.
4005 4005
	 */
4006 4006
	public static function getLiveVersionOfRecord($table, $uid, $fields = '*') {
4007
		global $TCA;
4007
		$liveVersionId = self::getLiveVersionIdOfRecord($table, $uid);
4008 4008

  
4009
			// Check that table supports versioning:
4010
		if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS']) {
4011
			$rec = self::getRecord($table, $uid, 'pid,t3ver_oid');
4009
		if (is_null($liveVersionId) === FALSE) {
4010
			return self::getRecord($table, $liveVersionId, $fields);
4011
		}
4012
	}
4012 4013

  
4013
			if ($rec['pid']==-1) {
4014
				return self::getRecord($table, $rec['t3ver_oid'], $fields);
4014
	/**
4015
	 * Gets the id of the live version of a record.
4016
	 *
4017
	 * @param string $table Name of the table
4018
	 * @param integer $uid Uid of the offline/draft record
4019
	 * @return integer The id of the live version of the record (or NULL if nothing was found)
4020
	 */
4021
	public static function getLiveVersionIdOfRecord($table, $uid) {
4022
		$liveVersionId = NULL;
4023

  
4024
		if (self::isTableWorkspaceEnabled($table)) {
4025
			$currentRecord = self::getRecord($table, $uid, 'pid,t3ver_oid');
4026
			if (is_array($currentRecord) && $currentRecord['pid'] == -1) {
4027
				$liveVersionId = $currentRecord['t3ver_oid'];
4015 4028
			}
4016 4029
		}
4030

  
4031
		return $liveVersionId;
4017 4032
	}
4018 4033

  
4019 4034
	/**
......
4064 4079
	}
4065 4080

  
4066 4081
	/**
4082
	 * Get additional where clause to select records of a specific workspace (includes live as well).
4083
	 *
4084
	 * @param  $table
4085
	 * @param  $workspaceId
4086
	 * @return string
4087
	 */
4088
	public static function getWorkspaceWhereClause($table, $workspaceId = NULL) {
4089
		$whereClause = '';
4090

  
4091
		if (is_null($workspaceId)) {
4092
			$workspaceId = $GLOBALS['BE_USER']->workspace;
4093
		}
4094

  
4095
		if (self::isTableWorkspaceEnabled($table)) {
4096
			$workspaceId = intval($workspaceId);
4097
			$pidOperator = ($workspaceId === 0 ? '!=' : '=');
4098
			$whereClause = ' AND ' . $table . '.t3ver_wsid=' . $workspaceId . ' AND ' . $table . '.pid' . $pidOperator . '-1';
4099
		}
4100

  
4101
		return $whereClause;
4102
	}
4103

  
4104
	/**
4067 4105
	 * Count number of versions on a page
4068 4106
	 *
4069 4107
	 * @param	integer		Workspace ID
......
4510 4548

  
4511 4549
		return $script;
4512 4550
	}
4551

  
4552
	/**
4553
	 * Determines whether a table is enabled for workspaces.
4554
	 *
4555
	 * @param  $table Name of the table to be checked
4556
	 * @return boolean
4557
	 */
4558
	public static function isTableWorkspaceEnabled($table) {
4559
		return (isset($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']);
4560
	}
4561

  
4562
	/**
4563
	 * Gets the TCA configuration of a field.
4564
	 *
4565
	 * @param string $table Name of the table
4566
	 * @param string $field Name of the field
4567
	 * @return array
4568
	 */
4569
	public static function getTcaFieldConfiguration($table, $field) {
4570
		$configuration = array();
4571
		t3lib_div::loadTCA($table);
4572

  
4573
		if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config'])) {
4574
			$configuration = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
4575
		}
4576

  
4577
		return $configuration;
4578
	}
4513 4579
}
4514 4580
?>
t3lib/class.t3lib_loaddbgroup.php (Arbeitskopie)
101 101
	var $MM_insert_fields = array();	// array of fields and value pairs used for insert in MM table
102 102
	var $MM_table_where = ''; // extra MM table where
103 103

  
104
	/**
105
	 * @var boolean
106
	 */
107
	protected $updateReferenceIndex = TRUE;
104 108

  
105 109
	/**
106 110
	 * Initialization of the class.
......
190 194
	}
191 195

  
192 196
	/**
197
	 * Sets whether the reference index shall be updated.
198
	 *
199
	 * @param boolean $updateReferenceIndex Whether the reference index shall be updated
200
	 * @return void
201
	 */
202
	public function setUpdateReferenceIndex($updateReferenceIndex) {
203
		$this->updateReferenceIndex = (bool)$updateReferenceIndex;
204
	}
205

  
206
	/**
193 207
	 * Explodes the item list and stores the parts in the internal arrays itemArray and tableArray from MM records.
194 208
	 *
195 209
	 * @param	string		Item list
......
547 561
			$whereClause .= ' AND '.$foreign_table_field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->currentTable, $foreign_table);
548 562
		}
549 563

  
564
			// Select children in the same workspace:
565
		if (t3lib_BEfunc::isTableWorkspaceEnabled($this->currentTable) && t3lib_BEfunc::isTableWorkspaceEnabled($foreign_table)) {
566
			$currentRecord = t3lib_BEfunc::getRecord($this->currentTable, $uid, 't3ver_wsid', '', $useDeleteClause);
567
			$whereClause .= t3lib_BEfunc::getWorkspaceWhereClause($foreign_table, $currentRecord['t3ver_wsid']);
568
		}
569

  
550 570
			// get the correct sorting field
551 571
		if ($conf['foreign_sortby']) {											// specific manual sortby for data handled by this field
552 572
			if ($conf['symmetric_sortby'] && $conf['symmetric_field']) {
......
804 824
	 *
805 825
	 * @param	string		Table name
806 826
	 * @param	integer		Record UID
807
	 * @return	void
827
	 * @return	array Information concerning modifications delivered by t3lib_refindex::updateRefIndexTable()
808 828
	 */
809 829
	function updateRefIndex($table,$id)	{
810
		$refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
811
		$result = $refIndexObj->updateRefIndexTable($table,$id);
830
		if ($this->updateReferenceIndex === TRUE) {
831
			/** @var $refIndexObj t3lib_refindex */
832
			$refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
833
			return $refIndexObj->updateRefIndexTable($table,$id);
834
		}
812 835
	}
813 836

  
814 837
	/**
t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie)
2 2
/***************************************************************
3 3
*  Copyright notice
4 4
*
5
*  (c) 2006-2010 Oliver Hader <oh@inpublica.de>
5
*  (c) 2006-2010 Oliver Hader <oliver@typo3.org>
6 6
*  All rights reserved
7 7
*
8 8
*  This script is part of the TYPO3 project. The TYPO3 project is
......
29 29
 *
30 30
 * $Id: class.t3lib_tceforms_inline.php 9258 2010-11-03 17:35:43Z steffenk $
31 31
 *
32
 * @author	Oliver Hader <oh@inpublica.de>
32
 * @author	Oliver Hader <oliver@typo3.org>
33 33
 */
34 34
/**
35 35
 * [CLASS/FUNCTION INDEX of SCRIPT]
......
205 205
			}
206 206
				// If the parent is a page, use the uid(!) of the (new?) page as pid for the child records:
207 207
			if ($table == 'pages') {
208
				$this->inlineFirstPid = $row['uid'];
208
				$liveVersionId = t3lib_BEfunc::getLiveVersionIdOfRecord('pages', $row['uid']);
209
				$this->inlineFirstPid = (is_null($liveVersionId) ? $row['uid'] : $liveVersionId);
209 210
				// If pid is negative, fetch the previous record and take its pid:
210 211
			} elseif ($row['pid'] < 0) {
211 212
				$prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
......
1701 1702
	 * @return	array		A record row from the database post-processed by t3lib_transferData
1702 1703
	 */
1703 1704
	function getRecord($pid, $table, $uid, $cmd='') {
1705
			// Fetch workspace version of a record (if any):
1706
		if ($cmd !== 'new' && $GLOBALS['BE_USER']->workspace !== 0) {
1707
			$workspaceVersion = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $uid, 'uid');
1708
			if ($workspaceVersion !== FALSE) {
1709
				$uid = $workspaceVersion['uid'];
1710
			}
1711
		}
1712

  
1704 1713
		$trData = t3lib_div::makeInstance('t3lib_transferData');
1705 1714
		$trData->addRawData = TRUE;
1706 1715
		$trData->lockRecords=1;
typo3/sysext/version/ws/index.php (Arbeitskopie)
236 236
					}
237 237
				}
238 238

  
239
		#		debug($cmdArray);
240

  
239
				/** @var $tce t3lib_TCEmain */
241 240
				$tce = t3lib_div::makeInstance('t3lib_TCEmain');
242 241
				$tce->stripslashes_values = 0;
243 242
				$tce->start(array(), $cmdArray);
244 243
				$tce->process_cmdmap();
244
				$tce->printLogErrorMessages('');
245 245
			}
246 246
		}
247 247
	}
typo3/sysext/version/class.tx_version_tcemain.php (Arbeitskopie)
48 48
	 ****************************/
49 49

  
50 50
	/**
51
	 * hook that is called before any cmd of the commandmap is 
52
	 * executed
53
	 * @param	$tcemainObj	reference to the main tcemain object
54
	 * @return	void
51
	 * hook that is called before any cmd of the commandmap is executed
52
	 *
53
	 * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
54
	 * @return void
55 55
	 */
56
	public function processCmdmap_beforeStart(&$tcemainObj) {
56
	public function processCmdmap_beforeStart(t3lib_TCEmain $tcemainObj) {
57 57
			// Reset notification array
58 58
		$this->notificationEmailInfo = array();
59
			// Resolve dependencies of version/workspaces actions:
60
		$tcemainObj->cmdmap = $this->getCommandMap($tcemainObj, $tcemainObj->cmdmap)->process()->get();
59 61
	}
60 62

  
61 63

  
......
94 96
				break;
95 97

  
96 98
				case 'swap':
97
					$swapMode = $tcemainObj->BE_USER->getTSConfigVal('options.workspaces.swapMode');
98
					$elementList = array();
99
					if ($swapMode == 'any' || ($swapMode == 'page' && $table == 'pages')) {
100
							// check if we are allowed to do synchronios publish. 
101
							// We must have a single element in the cmdmap to be allowed
102
						if (count($tcemainObj->cmdmap) == 1 && count($tcemainObj->cmdmap[$table]) == 1) {
103
							$elementList = $this->findPageElementsForVersionSwap($table, $id, $value['swapWith']);
104
						}
105
					}
106
					if (count($elementList) == 0) {
107
						$elementList[$table][] = array($id, $value['swapWith']);
108
					}
109
					foreach ($elementList as $tbl => $idList) {
110
						foreach ($idList as $idKey => $idSet) {
111
							$this->version_swap($tbl, $idSet[0], $idSet[1], $value['swapIntoWS'], $tcemainObj);
112
						}
113
					}
99
					$this->version_swap($table, $id, $value['swapWith'], $value['swapIntoWS'], $tcemainObj);
114 100
				break;
115 101

  
116 102
				case 'clearWSID':
......
122 108
				break;
123 109

  
124 110
				case 'setStage':
125
					$elementList = array();
126
					$idList = $elementList[$table] = t3lib_div::trimExplode(',', $id, 1);
127
					$setStageMode = $tcemainObj->BE_USER->getTSConfigVal('options.workspaces.changeStageMode');
128
					if ($setStageMode == 'any' || $setStageMode == 'page') {
129
						if (count($idList) == 1) {
130
							$rec = t3lib_BEfunc::getRecord($table, $idList[0], 't3ver_wsid');
131
							$workspaceId = $rec['t3ver_wsid'];
132
						} else {
133
							$workspaceId = $tcemainObj->BE_USER->workspace;
134
						}
135
						if ($table !== 'pages') {
136
							if ($setStageMode == 'any') {
137
									// (1) Find page to change stage and (2) 
138
									// find other elements from the same ws to change stage
139
								$pageIdList = array();
140
								$this->findPageIdsForVersionStateChange($table, $idList, $workspaceId, $pageIdList, $elementList);
141
								$this->findPageElementsForVersionStageChange($pageIdList, $workspaceId, $elementList);
142
							}
143
						} else {
144
							// Find all elements from the same ws to change stage
145
							$this->findRealPageIds($idList);
146
							$this->findPageElementsForVersionStageChange($idList, $workspaceId, $elementList);
147
						}
111
					$elementIds = t3lib_div::trimExplode(',', $id, TRUE);
112
					foreach ($elementIds as $elementId) {
113
						$this->version_setStage($table, $elementId, $value['stageId'],
114
							(isset($value['comment']) && $value['comment'] ? $value['comment'] : $this->generalComment),
115
							TRUE,
116
							$tcemainObj
117
						);
148 118
					}
149

  
150
					foreach ($elementList as $tbl => $elementIdList) {
151
						foreach ($elementIdList as $elementId) {
152
							$this->version_setStage($tbl, $elementId, $value['stageId'], ($value['comment'] ? $value['comment'] : $this->generalComment), TRUE, $tcemainObj);
153
						}
154
					}
155 119
				break;
156 120
			}
157 121
		}
......
463 427
				if ($emailMessage && $emailSubject) {
464 428
					t3lib_div::deprecationLog('This TYPO3 installation uses Workspaces staging notification by setting the TSconfig options "TCEMAIN.notificationEmail_subject" / "TCEMAIN.notificationEmail_body". Please use the more flexible marker-based options tx_version.workspaces.stageNotificationEmail.message / tx_version.workspaces.stageNotificationEmail.subject');
465 429

  
466
					$emailSubject = sprintf($subject, $elementName);
430
					$emailSubject = sprintf($emailSubject, $elementName);
467 431
					$emailMessage = sprintf($emailMessage,
468 432
						$markers['###SITE_NAME###'],
469 433
						$markers['###SITE_URL###'],
......
521 485
							if (!isset($languageObjects[$recipientLanguage])) {
522 486
									// a LANG object in this language hasn't been 
523 487
									// instantiated yet, so this is done here
488
								/** @var $languageObject language */
524 489
								$languageObject = t3lib_div::makeInstance('language');
525 490
								$languageObject->init($recipientLanguage);
526 491
								$languageObjects[$recipientLanguage] = $languageObject;
......
662 627
				}
663 628
			}
664 629

  
630
				// Remove the possible inline child tables from the tables to be versioniozed automatically:
631
			$verTablesArray = array_diff($verTablesArray, $this->getPossibleInlineChildTablesOfParentTable('pages'));
632

  
665 633
				// Begin to copy pages if we're allowed to:
666 634
			if ($tcemainObj->BE_USER->workspaceVersioningTypeAccess($versionizeTree)) {
667 635

  
......
866 834
												} else {
867 835
													// Otherwise update the movePlaceholder:
868 836
													$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($movePlhID), $movePlh);
869
													$tcemainObj->updateRefIndex($table, $movePlhID);
837
													$tcemainObj->addRemapStackRefIndex($table, $movePlhID);
870 838
												}
871 839
											}
872 840

  
......
880 848
											$tcemainObj->newlog2(($swapIntoWS ? 'Swapping' : 'Publishing') . ' successful for table "' . $table . '" uid ' . $id . '=>' . $swapWith, $table, $id, $swapVersion['pid']);
881 849

  
882 850
												// Update reference index of the live record:
883
											$tcemainObj->updateRefIndex($table, $id);
851
											$tcemainObj->addRemapStackRefIndex($table, $id);
884 852

  
885 853
												// Set log entry for live record:
886 854
											$propArr = $tcemainObj->getRecordPropertiesFromRow($table, $swapVersion);
......
893 861
											$tcemainObj->setHistory($table, $id, $theLogId);
894 862

  
895 863
												// Update reference index of the offline record:
896
											$tcemainObj->updateRefIndex($table, $swapWith);
864
											$tcemainObj->addRemapStackRefIndex($table, $swapWith);
897 865
												// Set log entry for offline record:
898 866
											$propArr = $tcemainObj->getRecordPropertiesFromRow($table, $curVersion);
899 867
											if ($propArr['_ORIG_pid'] == -1) {
......
970 938

  
971 939
			// Process pointer fields on normalized database:
972 940
		if ($inlineType == 'field') {
973
				// Read relations that point to the current record (e.g. live record):
941
			// Read relations that point to the current record (e.g. live record):
942
			/** @var $dbAnalysisCur t3lib_loadDBGroup */
974 943
			$dbAnalysisCur = t3lib_div::makeInstance('t3lib_loadDBGroup');
944
			$dbAnalysisCur->setUpdateReferenceIndex(FALSE);
975 945
			$dbAnalysisCur->start('', $conf['foreign_table'], '', $curVersion['uid'], $table, $conf);
976
				// Read relations that point to the record to be swapped with e.g. draft record):
946
			// Read relations that point to the record to be swapped with e.g. draft record):
947
			/** @var $dbAnalysisSwap t3lib_loadDBGroup */
977 948
			$dbAnalysisSwap = t3lib_div::makeInstance('t3lib_loadDBGroup');
949
			$dbAnalysisSwap->setUpdateReferenceIndex(FALSE);
978 950
			$dbAnalysisSwap->start('', $conf['foreign_table'], '', $swapVersion['uid'], $table, $conf);
979 951
				// Update relations for both (workspace/versioning) sites:
980 952
			$dbAnalysisCur->writeForeignField($conf, $curVersion['uid'], $swapVersion['uid']);
981 953
			$dbAnalysisSwap->writeForeignField($conf, $swapVersion['uid'], $curVersion['uid']);
982 954

  
955
			$items = array_merge($dbAnalysisCur->itemArray, $dbAnalysisSwap->itemArray);
956
			foreach ($items as $item) {
957
				$tcemainObj->addRemapStackRefIndex($item['table'], $item['id']);
958
			}
... This diff was truncated because it exceeds the maximum size that can be displayed.