Project

General

Profile

Feature #24041 » 0016374_4-5.patch

Administrator Admin, 2010-11-13 19:11

View differences:

t3lib/core_autoload.php (Arbeitskopie)
't3lib_tceforms_suggest' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest.php',
't3lib_tceforms_suggest_defaultreceiver' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php',
't3lib_utility_client' => PATH_t3lib . 'utility/class.t3lib_utility_client.php',
't3lib_utility_dependency' => PATH_t3lib . 'utility/class.t3lib_utility_dependency.php',
't3lib_utility_dependency_callback' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_callback.php',
't3lib_utility_dependency_element' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_element.php',
't3lib_utility_dependency_factory' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_factory.php',
't3lib_utility_dependency_reference' => PATH_t3lib . 'utility/dependency/class.t3lib_utility_dependency_reference.php',
't3lib_utility_http' => PATH_t3lib . 'utility/class.t3lib_utility_http.php',
't3lib_utility_mail' => PATH_t3lib . 'utility/class.t3lib_utility_mail.php',
't3lib_utility_phpoptions' => PATH_t3lib . 'utility/class.t3lib_utility_phpoptions.php',
t3lib/class.t3lib_tcemain.php (Arbeitskopie)
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.
var $remapStack = array(); // array used for remapping uids and values at the end of process_datamap
var $remapStackRecords = array(); // array used for remapping uids and values at the end of process_datamap (e.g. $remapStackRecords[<table>][<uid>] = <index in $remapStack>)
protected $remapStackChildIds = array(); // array used for checking whether new children need to be remapped
protected $remapStackActions = array(); // array used for executing addition actions after remapping happened (sett processRemapStack())
protected $remapStackRefIndex = array(); // array used for executing post-processing on the reference index
var $updateRefIndexStack = array(); // array used for additional calls to $this->updateRefIndex
var $callFromImpExp = false; // tells, that this TCEmain was called from tx_impext - this variable is set by tx_impexp
var $newIndexMap = array(); // Array for new flexform index mapping
......
}
$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!
if ($phShadowId) {
$this->placeholderShadowing($table,$phShadowId);
// Processes fields of the placeholder record:
$this->triggerRemapAction(
$table,
$id,
array($this, 'placeholderShadowing'),
array($table, $phShadowId)
);
// Hold auto-versionized ids of placeholders:
$this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
}
......
// check, if there is a NEW... id in the value, that should be substituded later
if (strpos($value, 'NEW') !== false) {
$this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
$this->addNewValuesToRemapStackChildIds($valueArray);
$this->remapStack[] = array(
'func' => 'checkValue_group_select_processDBdata',
'args' => array($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field),
......
// We need to decide whether we use the stack or can save the relation directly.
if(strpos($value, 'NEW') !== false || !t3lib_div::testInt($id)) {
$this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
$this->addNewValuesToRemapStackChildIds($valueArray);
$this->remapStack[] = array(
'func' => 'checkValue_inline_processDBdata',
'args' => array($valueArray, $tcaFieldConf, $id, $status, $table, $field),
......
// Finally, before exit, check if there are ID references to remap.
// This might be the case if versioning or copying has taken place!
$this->remapListedDBRecords();
$this->processRemapStack();
foreach ($hookObjectsArr as $hookObj) {
if (method_exists($hookObj, 'processCmdmap_afterFinish')) {
......
if ($theNewSQLID) {
$this->copyRecord_fixRTEmagicImages($table, t3lib_BEfunc::wsMapId($table, $theNewSQLID));
$this->copyMappingArray[$table][$origUid] = $theNewSQLID;
// Keep automatically versionized record information:
if (isset($copyTCE->autoVersionIdMap[$table][$theNewSQLID])) {
$this->autoVersionIdMap[$table][$theNewSQLID] = $copyTCE->autoVersionIdMap[$table][$theNewSQLID];
}
}
// Copy back the cached TSconfig
......
} else {
if (!t3lib_div::testInt($realDestPid)) {
$newId = $this->copyRecord($v['table'], $v['id'], -$v['id']);
} elseif ($realDestPid == -1) {
$newId = $this->versionizeRecord($v['table'], $v['id'], 'Auto-created for WS #'.$this->BE_USER->workspace);
} elseif ($realDestPid == -1 && t3lib_BEfunc::isTableWorkspaceEnabled($v['table'])) {
$workspaceVersion = t3lib_BEfunc::getWorkspaceVersionOfRecord(
$this->BE_USER->workspace, $v['table'], $v['id'], 'uid'
);
// If workspace version does not exist, create a new one:
if ($workspaceVersion === FALSE) {
$newId = $this->versionizeRecord($v['table'], $v['id'], 'Auto-created for WS #' . $this->BE_USER->workspace);
// If workspace version already exists, use it:
} else {
$newId = $workspaceVersion['uid'];
}
} else {
$newId = $this->copyRecord_raw($v['table'], $v['id'], $realDestPid);
}
......
// Execute the copy:
$newId = $this->copyRecord($table, $uid, -$uid, 1, $overrideValues, implode(',', $excludeFields), $language);
$autoVersionNewId = $this->getAutoVersionId($table, $newId);
if (is_null($autoVersionNewId) === FALSE) {
$this->triggerRemapAction(
$table,
$newId,
array($this, 'placeholderShadowing'),
array($table, $autoVersionNewId),
TRUE
);
}
} else {
// Create new record:
......
if (t3lib_div::testInt($type) && isset($elementsOriginal[$type])) {
$item = $elementsOriginal[$type];
$item['id'] = $this->localize($item['table'], $item['id'], $language);
$item['id'] = $this->overlayAutoVersionId($item['table'], $item['id']);
$dbAnalysisCurrent->itemArray[] = $item;
} elseif (t3lib_div::inList('localize,synchronize', $type)) {
foreach ($elementsOriginal as $originalId => $item) {
$item['id'] = $this->localize($item['table'], $item['id'], $language);
$item['id'] = $this->overlayAutoVersionId($item['table'], $item['id']);
$dbAnalysisCurrent->itemArray[] = $item;
}
}
......
$this->remapListedDBRecords_procDBRefs($conf, $value, $theUidToUpdate, $table);
} elseif ($inlineType !== false) {
/** @var $dbAnalysis t3lib_loadDBGroup */
$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
$dbAnalysis->start($value, $conf['foreign_table'], '', 0, $table, $conf);
// Update child records if using pointer fields ('foreign_field'):
if ($inlineType == 'field') {
$dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
}
// If the current field is set on a page record, update the pid of related child records:
if ($table == 'pages') {
$thePidToUpdate = $theUidToUpdate;
......
$thePidToUpdate = $this->copyMappingArray_merged['pages'][$thePidToUpdate];
}
// Update child records if using pointer fields ('foreign_field'):
if ($inlineType == 'field') {
$dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
}
// Update child records if change to pid is required:
// // Update child records if change to pid is required (only if the current record is not on a workspace):
if ($thePidToUpdate) {
$updateValues = array('pid' => $thePidToUpdate);
foreach ($dbAnalysis->itemArray as $v) {
if ($v['id'] && $v['table']) {
if ($v['id'] && $v['table'] && is_null(t3lib_BEfunc::getLiveVersionIdOfRecord($v['table'], $v['id']))) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($v['table'], 'uid='.intval($v['id']), $updateValues);
}
}
......
* @return void
*/
function processRemapStack() {
// Processes the remap stack:
if(is_array($this->remapStack)) {
foreach($this->remapStack as $remapAction) {
// If no position index for the arguments was set, skip this remap action:
......
}
}
}
// Processes the remap stack actions:
if ($this->remapStackActions) {
foreach ($this->remapStackActions as $action) {
if (isset($action['callback']) && isset($action['arguments'])) {
call_user_func_array(
$action['callback'],
$action['arguments']
);
}
}
}
// Processes the reference index updates of the remap stack:
foreach ($this->remapStackRefIndex as $table => $idArray) {
foreach ($idArray as $id) {
$this->updateRefIndex($table, $id);
unset($this->remapStackRefIndex[$table][$id]);
}
}
// Reset:
$this->remapStack = array();
$this->remapStackRecords = array();
$this->remapStackActions = array();
$this->remapStackRefIndex = array();
}
/**
* Triggers a remap action for a specific record.
*
* Some records are post-processed by the processRemapStack() method (e.g. IRRE children).
* This method determines wether an action/modification is executed directly to a record
* or is postponed to happen after remapping data.
*
* @param string $table Name of the table
* @param string $id Id of the record (can also be a "NEW..." string)
* @param array $callback The method to be called
* @param array $arguments The arguments to be submitted to the callback method
* @param boolean $forceRemapStackActions Whether to force to use the stack
* @return void
*
* @see processRemapStack
*/
protected function triggerRemapAction($table, $id, array $callback, array $arguments, $forceRemapStackActions = FALSE) {
// Check whether the affected record is marked to be remapped:
if (!$forceRemapStackActions && !isset($this->remapStackRecords[$table][$id]) && !isset($this->remapStackChildIds[$id])) {
call_user_func_array($callback, $arguments);
} else {
$this->remapStackActions[] = array(
'affects' => array(
'table' => $table,
'id' => $id,
),
'callback' => $callback,
'arguments' => $arguments,
);
}
}
/**
* Adds a table-id-pair to the reference index remapping stack.
*
* @param string $table
* @param integer $id
* @return void
*/
public function addRemapStackRefIndex($table, $id) {
$this->remapStackRefIndex[$table][$id] = $id;
}
/**
* If a parent record was versionized on a workspace in $this->process_datamap,
* it might be possible, that child records (e.g. on using IRRE) were affected.
* This function finds these relations and updates their uids in the $incomingFieldArray.
......
}
return $result;
}
/**
* Gets the automatically versionized id of a record.
*
* @param string $table Name of the table
* @param integer $id Uid of the record
* @return integer
*/
protected function getAutoVersionId($table, $id) {
$result = NULL;
if (isset($this->autoVersionIdMap[$table][$id])) {
$result = $this->autoVersionIdMap[$table][$id];
}
return $result;
}
/**
* Overlays the automatically versionized id of a record.
*
* @param string $table Name of the table
* @param integer $id Uid of the record
* @return integer
*/
protected function overlayAutoVersionId($table, $id) {
$autoVersionId = $this->getAutoVersionId($table, $id);
if (is_null($autoVersionId) === FALSE) {
$id = $autoVersionId;
}
return $id;
}
/**
* Adds new values to the remapStackChildIds array.
*
* @param array $idValues uid values
* @return void
*/
protected function addNewValuesToRemapStackChildIds(array $idValues) {
foreach ($idValues as $idValue) {
if (strpos($idValue, 'NEW') === 0) {
$this->remapStackChildIds[$idValue] = TRUE;
}
}
}
}
t3lib/utility/class.t3lib_utility_dependency.php (Revision 40160)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Oliver Hader <oliver@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Object to handle and determine dependent references of elements.
*/
class t3lib_utility_Dependency {
/**
* @var t3lib_utility_Dependency_Factory
*/
protected $factory;
/**
* @var array
*/
protected $elements = array();
/**
* @var array
*/
protected $eventCallbacks = array();
/**
* @var boolean
*/
protected $outerMostParentsRequireReferences = FALSE;
/**
* @var array
*/
protected $outerMostParents;
/**
* Sets a callback for a particular event.
*
* @param string $eventName
* @param t3lib_utility_Dependency_Callback $callback
* @return t3lib_utility_Dependency
*/
public function setEventCallback($eventName, t3lib_utility_Dependency_Callback $callback) {
$this->eventCallbacks[$eventName] = $callback;
return $this;
}
/**
* Executes a registered callback (if any) for a particular event.
*
* @param string $eventName
* @param object $caller
* @param array $callerArguments
* @return mixed
*/
public function executeEventCallback($eventName, $caller, array $callerArguments = array()) {
if (isset($this->eventCallbacks[$eventName])) {
/** @var $callback t3lib_utility_Dependency_Callback */
$callback = $this->eventCallbacks[$eventName];
return $callback->execute($callerArguments, $caller, $eventName);
}
}
/**
* Sets the condition that outermost parents required at least one child or parent reference.
*
* @param boolean $outerMostParentsRequireReferences
* @return t3lib_utility_Dependency
*/
public function setOuterMostParentsRequireReferences($outerMostParentsRequireReferences) {
$this->outerMostParentsRequireReferences = (bool)$outerMostParentsRequireReferences;
return $this;
}
/**
* Adds an element to be checked for dependent references.
*
* @param string $table
* @param integer $id
* @param array $data
* @return t3lib_utility_Dependency_Element
*/
public function addElement($table, $id, array $data = array()) {
$element = $this->getFactory()->getElement($table, $id, $data, $this);
$elementName = $element->__toString();
$this->elements[$elementName] = $element;
return $element;
}
/**
* Gets the outermost parents that define complete dependent structure each.
*
* @return array
*/
public function getOuterMostParents() {
if (!isset($this->outerMostParents)) {
$this->outerMostParents = array();
/** @var $element t3lib_utility_Dependency_Element */
foreach ($this->elements as $element) {
$this->processOuterMostParent($element);
}
}
return $this->outerMostParents;
}
/**
* Processes and registers the outermost parents accordant to the registered elements.
*
* @param t3lib_utility_Dependency_Element $element
* @return void
*/
protected function processOuterMostParent(t3lib_utility_Dependency_Element $element) {
if ($this->outerMostParentsRequireReferences === FALSE || $element->hasReferences()) {
$outerMostParent = $element->getOuterMostParent();
if ($outerMostParent !== FALSE) {
$outerMostParentName = $outerMostParent->__toString();
if (!isset($this->outerMostParents[$outerMostParentName])) {
$this->outerMostParents[$outerMostParentName] = $outerMostParent;
}
}
}
}
/**
* Gets all nested elements (including the parent) of a particular outermost parent element.
*
* @throws RuntimeException
* @param t3lib_utility_Dependency_Element $outerMostParent
* @return array
*/
public function getNestedElements(t3lib_utility_Dependency_Element $outerMostParent) {
$outerMostParentName = $outerMostParent->__toString();
if (!isset($this->outerMostParents[$outerMostParentName])) {
throw new RuntimeException(
'Element "' . $outerMostParentName . '" was detected as outermost parent.',
1289318609
);
}
$nestedStructure = array_merge(
array($outerMostParentName => $outerMostParent),
$outerMostParent->getNestedChildren()
);
return $nestedStructure;
}
/**
* Gets the registered elements.
*
* @return array
*/
public function getElements() {
return $this->elements;
}
/**
* Gets an instance of the factory to keep track of element or reference entities.
*
* @return t3lib_utility_Dependency_Factory
*/
public function getFactory() {
if (!isset($this->factory)) {
$this->factory = t3lib_div::makeInstance('t3lib_utility_Dependency_Factory');
}
return $this->factory;
}
}
t3lib/utility/dependency/class.t3lib_utility_dependency_factory.php (Revision 40160)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Oliver Hader <oliver@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Object to create and keep track of element or reference entities.
*/
class t3lib_utility_Dependency_Factory {
/**
* @var array
*/
protected $elements = array();
/**
* @var array
*/
protected $references = array();
/**
* Gets and registers a new element.
*
* @param string $table
* @param integer $id
* @param array $data (optional)
* @param t3lib_utility_Dependency $dependency
* @return t3lib_utility_Dependency_Element
*/
public function getElement($table, $id, array $data = array(), t3lib_utility_Dependency $dependency) {
$elementName = $table . ':' . $id;
if (!isset($this->elements[$elementName])) {
$this->elements[$elementName] = t3lib_div::makeInstance(
't3lib_utility_Dependency_Element',
$table, $id, $data, $dependency
);
}
return $this->elements[$elementName];
}
/**
* Gets and registers a new reference.
*
* @param t3lib_utility_Dependency_Element $element
* @param string $field
* @return t3lib_utility_Dependency_Reference
*/
public function getReference(t3lib_utility_Dependency_Element $element, $field) {
$referenceName = $element->__toString() . '.' . $field;
if (!isset($this->references[$referenceName][$field])) {
$this->references[$referenceName][$field] = t3lib_div::makeInstance(
't3lib_utility_Dependency_Reference',
$element, $field
);
}
return $this->references[$referenceName][$field];
}
/**
* Gets and registers a new reference.
*
* @param string $table
* @param integer $id
* @param string $field
* @param array $data (optional
* @param t3lib_utility_Dependency $dependency
* @return t3lib_utility_Dependency_Reference
* @see getElement
* @see getReference
*/
public function getReferencedElement($table, $id, $field, array $data = array(), t3lib_utility_Dependency $dependency) {
return $this->getReference(
$this->getElement($table, $id, $data, $dependency),
$field
);
}
}
t3lib/utility/dependency/class.t3lib_utility_dependency_element.php (Revision 40160)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Oliver Hader <oliver@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Object to hold information on a dependent database element in abstract.
*/
class t3lib_utility_Dependency_Element {
const REFERENCES_ChildOf = 'childOf';
const REFERENCES_ParentOf = 'parentOf';
const EVENT_Construct = 't3lib_utility_Dependency_Element::construct';
const EVENT_CreateChildReference = 't3lib_utility_Dependency_Element::createChildReference';
const EVENT_CreateParentReference = 't3lib_utility_Dependency_Element::createParentReference';
const RESPONSE_Skip = 't3lib_utility_Dependency_Element->skip';
/**
* @var string
*/
protected $table;
/**
* @var integer
*/
protected $id;
/**
* @var array
*/
protected $data;
/**
* @var t3lib_utility_Dependency
*/
protected $dependency;
/**
* @var array
*/
protected $children;
/**
* @var array
*/
protected $parents;
/**
* @var boolean
*/
protected $traversingParents = FALSE;
/**
* @var t3lib_utility_Dependency_Element
*/
protected $outerMostParent;
/**
* @var array
*/
protected $nestedChildren;
/**
* Creates this object.
*
* @param string $table
* @param integer $id
* @param array $data (optional)
* @param t3lib_utility_Dependency $dependency
*/
public function __construct($table, $id, array $data = array(), t3lib_utility_Dependency $dependency) {
$this->table = $table;
$this->id = intval($id);
$this->data = $data;
$this->dependency = $dependency;
$this->dependency->executeEventCallback(self::EVENT_Construct, $this);
}
/**
* Gets the table.
*
* @return string
*/
public function getTable() {
return $this->table;
}
/**
* Gets the id.
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Gets the data.
*
* @return array
*/
public function getData() {
return $this->data;
}
/**
* Gets a value for a particular key from the data.
*
* @param string $key
* @return mixed
*/
public function getDataValue($key) {
$result = NULL;
if ($this->hasDataValue($key)) {
$result = $this->data[$key];
}
return $result;
}
/**
* Sets a value for a particular key in the data.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function setDataValue($key, $value) {
$this->data[$key] = $value;
}
/**
* Determines whether a particular key holds data.
*
* @param string $key
* @return
*/
public function hasDataValue($key) {
return (isset($this->data[$key]));
}
/**
* Converts this object for string representation.
*
* @return string
*/
public function __toString() {
return self::getIdentifier($this->table, $this->id);
}
/**
* Gets the parent dependency object.
*
* @return t3lib_utility_Dependency
*/
public function getDependency() {
return $this->dependency;
}
/**
* Gets all child references.
*
* @return array
*/
public function getChildren() {
if (!isset($this->children)) {
$this->children = array();
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'*',
'sys_refindex',
'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->table, 'sys_refindex') .
' AND recuid=' . $this->id
);
if (is_array($rows)) {
foreach ($rows as $row) {
$reference = $this->getDependency()->getFactory()->getReferencedElement(
$row['ref_table'], $row['ref_uid'], $row['field'], array(), $this->getDependency()
);
$callbackResponse = $this->dependency->executeEventCallback(
self::EVENT_CreateChildReference,
$this, array('reference' => $reference)
);
if ($callbackResponse !== self::RESPONSE_Skip) {
$this->children[] = $reference;
}
}
}
}
return $this->children;
}
/**
* Gets all parent references.
*
* @return array
*/
public function getParents() {
if (!isset($this->parents)) {
$this->parents = array();
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'*',
'sys_refindex',
'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->table, 'sys_refindex') .
' AND deleted=0 AND ref_uid=' . $this->id
);
if (is_array($rows)) {
foreach ($rows as $row) {
$reference = $this->getDependency()->getFactory()->getReferencedElement(
$row['tablename'], $row['recuid'], $row['field'], array(), $this->getDependency()
);
$callbackResponse = $this->dependency->executeEventCallback(
self::EVENT_CreateParentReference,
$this, array('reference' => $reference)
);
if ($callbackResponse !== self::RESPONSE_Skip) {
$this->parents[] = $reference;
}
}
}
}
return $this->parents;
}
/**
* Determines whether there are child or parent references.
*
* @return boolean
*/
public function hasReferences() {
return (count($this->getChildren()) > 0 || count($this->getParents()) > 0);
}
/**
* Gets the outermost parent element.
*
* @return t3lib_utility_Dependency_Element
*/
public function getOuterMostParent() {
if (!isset($this->outerMostParent)) {
$parents = $this->getParents();
if (count($parents) === 0) {
$this->outerMostParent = $this;
} else {
$this->outerMostParent = FALSE;
/** @var $parent t3lib_utility_Dependency_Reference */
foreach ($parents as $parent) {
$outerMostParent = $parent->getElement()->getOuterMostParent();
if ($outerMostParent instanceof t3lib_utility_Dependency_Element) {
$this->outerMostParent = $outerMostParent;
break;
} elseif ($outerMostParent === FALSE) {
break;
}
}
}
}
return $this->outerMostParent;
}
/**
* Gets nested children accumulated.
*
* @return array
*/
public function getNestedChildren() {
if (!isset($this->nestedChildren)) {
$this->nestedChildren = array();
$children = $this->getChildren();
/** @var $child t3lib_utility_Dependency_Reference */
foreach ($children as $child) {
$this->nestedChildren = array_merge(
$this->nestedChildren,
array($child->getElement()->__toString() => $child->getElement()),
$child->getElement()->getNestedChildren()
);
}
}
return $this->nestedChildren;
}
/**
* Converts the object for string representation.
*
* @param string $table
* @param integer $id
* @return string
*/
public static function getIdentifier($table, $id) {
return $table . ':' . $id;
}
}
t3lib/utility/dependency/class.t3lib_utility_dependency_callback.php (Revision 40160)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Oliver Hader <oliver@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Object to hold information on a callback to a defined object and method.
*/
class t3lib_utility_Dependency_Callback {
/**
* @var object
*/
protected $object;
/**
* @var string
*/
protected $method;
/**
* @var array
*/
protected $targetArguments;
/**
* Creates the objects.
*
* @param object $object
* @param string $method
* @param array $targetArguments (optional)
*/
public function __construct($object, $method, array $targetArguments = array()) {
$this->object = $object;
$this->method = $method;
$this->targetArguments = $targetArguments;
$this->targetArguments['target'] = $object;
}
/**
* Executes the callback.
*
* @param array $callerArguments
* @param object $caller
* @param string $eventName
* @return mixed
*/
public function execute(array $callerArguments = array(), $caller, $eventName) {
return call_user_func_array(
array($this->object, $this->method),
array($callerArguments, $this->targetArguments, $caller, $eventName)
);
}
}
t3lib/utility/dependency/class.t3lib_utility_dependency_reference.php (Revision 40160)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Oliver Hader <oliver@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Object to hold reference information of a database field and one accordant element.
*/
class t3lib_utility_Dependency_Reference {
/**
* @var t3lib_utility_Dependency_Element
*/
protected $element;
/**
* @var string
*/
protected $field;
/**
* Creates this object.
*
* @param t3lib_utility_Dependency_Element $element
* @param string $field
*/
public function __construct(t3lib_utility_Dependency_Element $element, $field) {
$this->element = $element;
$this->field = $field;
}
/**
* Gets the elements.
*
* @return t3lib_utility_Dependency_Element
*/
public function getElement() {
return $this->element;
}
/**
* Gets the field.
*
* @return string
*/
public function getField() {
return $this->field;
}
/**
* Converts this object for string representation.
*
* @return string
*/
public function __toString() {
return $this->element . '.' . $this->field;
}
}
t3lib/class.t3lib_befunc.php (Arbeitskopie)
* @return array If found, the record, otherwise nothing.
*/
public static function getLiveVersionOfRecord($table, $uid, $fields = '*') {
global $TCA;
$liveVersionId = self::getLiveVersionIdOfRecord($table, $uid);
// Check that table supports versioning:
if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS']) {
$rec = self::getRecord($table, $uid, 'pid,t3ver_oid');
if (is_null($liveVersionId) === FALSE) {
return self::getRecord($table, $liveVersionId, $fields);
}
}
if ($rec['pid']==-1) {
return self::getRecord($table, $rec['t3ver_oid'], $fields);
/**
* Gets the id of the live version of a record.
*
* @param string $table Name of the table
* @param integer $uid Uid of the offline/draft record
* @return integer The id of the live version of the record (or NULL if nothing was found)
*/
public static function getLiveVersionIdOfRecord($table, $uid) {
$liveVersionId = NULL;
if (self::isTableWorkspaceEnabled($table)) {
$currentRecord = self::getRecord($table, $uid, 'pid,t3ver_oid');
if (is_array($currentRecord) && $currentRecord['pid'] == -1) {
$liveVersionId = $currentRecord['t3ver_oid'];
}
}
return $liveVersionId;
}
/**
......
}
/**
* Get additional where clause to select records of a specific workspace (includes live as well).
*
* @param $table
* @param $workspaceId
* @return string
*/
public static function getWorkspaceWhereClause($table, $workspaceId = NULL) {
$whereClause = '';
if (is_null($workspaceId)) {
$workspaceId = $GLOBALS['BE_USER']->workspace;
}
if (self::isTableWorkspaceEnabled($table)) {
$workspaceId = intval($workspaceId);
$pidOperator = ($workspaceId === 0 ? '!=' : '=');
$whereClause = ' AND ' . $table . '.t3ver_wsid=' . $workspaceId . ' AND ' . $table . '.pid' . $pidOperator . '-1';
}
return $whereClause;
}
/**
* Count number of versions on a page
*
* @param integer Workspace ID
......
return $script;
}
/**
* Determines whether a table is enabled for workspaces.
*
* @param $table Name of the table to be checked
* @return boolean
*/
public static function isTableWorkspaceEnabled($table) {
return (isset($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']);
}
/**
* Gets the TCA configuration of a field.
*
* @param string $table Name of the table
* @param string $field Name of the field
* @return array
*/
public static function getTcaFieldConfiguration($table, $field) {
$configuration = array();
t3lib_div::loadTCA($table);
if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config'])) {
$configuration = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
}
return $configuration;
}
}
?>
t3lib/class.t3lib_loaddbgroup.php (Arbeitskopie)
var $MM_insert_fields = array(); // array of fields and value pairs used for insert in MM table
var $MM_table_where = ''; // extra MM table where
/**
* @var boolean
*/
protected $updateReferenceIndex = TRUE;
/**
* Initialization of the class.
......
}
/**
* Sets whether the reference index shall be updated.
*
* @param boolean $updateReferenceIndex Whether the reference index shall be updated
* @return void
*/
public function setUpdateReferenceIndex($updateReferenceIndex) {
$this->updateReferenceIndex = (bool)$updateReferenceIndex;
}
/**
* Explodes the item list and stores the parts in the internal arrays itemArray and tableArray from MM records.
*
* @param string Item list
......
$whereClause .= ' AND '.$foreign_table_field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->currentTable, $foreign_table);
}
// Select children in the same workspace:
if (t3lib_BEfunc::isTableWorkspaceEnabled($this->currentTable) && t3lib_BEfunc::isTableWorkspaceEnabled($foreign_table)) {
$currentRecord = t3lib_BEfunc::getRecord($this->currentTable, $uid, 't3ver_wsid', '', $useDeleteClause);
$whereClause .= t3lib_BEfunc::getWorkspaceWhereClause($foreign_table, $currentRecord['t3ver_wsid']);
}
// get the correct sorting field
if ($conf['foreign_sortby']) { // specific manual sortby for data handled by this field
if ($conf['symmetric_sortby'] && $conf['symmetric_field']) {
......
*
* @param string Table name
* @param integer Record UID
* @return void
* @return array Information concerning modifications delivered by t3lib_refindex::updateRefIndexTable()
*/
function updateRefIndex($table,$id) {
$refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
$result = $refIndexObj->updateRefIndexTable($table,$id);
if ($this->updateReferenceIndex === TRUE) {
/** @var $refIndexObj t3lib_refindex */
$refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
return $refIndexObj->updateRefIndexTable($table,$id);
}
}
/**
t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie)
/***************************************************************
* Copyright notice
*
* (c) 2006-2010 Oliver Hader <oh@inpublica.de>
* (c) 2006-2010 Oliver Hader <oliver@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......
*
* $Id: class.t3lib_tceforms_inline.php 9258 2010-11-03 17:35:43Z steffenk $
*
* @author Oliver Hader <oh@inpublica.de>
* @author Oliver Hader <oliver@typo3.org>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
......
}
// If the parent is a page, use the uid(!) of the (new?) page as pid for the child records:
if ($table == 'pages') {
$this->inlineFirstPid = $row['uid'];
$liveVersionId = t3lib_BEfunc::getLiveVersionIdOfRecord('pages', $row['uid']);
$this->inlineFirstPid = (is_null($liveVersionId) ? $row['uid'] : $liveVersionId);
// If pid is negative, fetch the previous record and take its pid:
} elseif ($row['pid'] < 0) {
$prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
......
* @return array A record row from the database post-processed by t3lib_transferData
*/
function getRecord($pid, $table, $uid, $cmd='') {
// Fetch workspace version of a record (if any):
if ($cmd !== 'new' && $GLOBALS['BE_USER']->workspace !== 0) {
$workspaceVersion = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $uid, 'uid');
if ($workspaceVersion !== FALSE) {
$uid = $workspaceVersion['uid'];
}
}
$trData = t3lib_div::makeInstance('t3lib_transferData');
$trData->addRawData = TRUE;
$trData->lockRecords=1;
typo3/sysext/version/ws/index.php (Arbeitskopie)
}
}
# debug($cmdArray);
/** @var $tce t3lib_TCEmain */
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->start(array(), $cmdArray);
$tce->process_cmdmap();
$tce->printLogErrorMessages('');
}
}
}
typo3/sysext/version/class.tx_version_tcemain.php (Arbeitskopie)
****************************/
/**
* hook that is called before any cmd of the commandmap is
* executed
* @param $tcemainObj reference to the main tcemain object
* @return void
* hook that is called before any cmd of the commandmap is executed
*
* @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
* @return void
*/
public function processCmdmap_beforeStart(&$tcemainObj) {
public function processCmdmap_beforeStart(t3lib_TCEmain $tcemainObj) {
// Reset notification array
$this->notificationEmailInfo = array();
// Resolve dependencies of version/workspaces actions:
$tcemainObj->cmdmap = $this->getCommandMap($tcemainObj, $tcemainObj->cmdmap)->process()->get();
}
......
break;
case 'swap':
$swapMode = $tcemainObj->BE_USER->getTSConfigVal('options.workspaces.swapMode');
$elementList = array();
if ($swapMode == 'any' || ($swapMode == 'page' && $table == 'pages')) {
// check if we are allowed to do synchronios publish.
// We must have a single element in the cmdmap to be allowed
if (count($tcemainObj->cmdmap) == 1 && count($tcemainObj->cmdmap[$table]) == 1) {
$elementList = $this->findPageElementsForVersionSwap($table, $id, $value['swapWith']);
}
}
if (count($elementList) == 0) {
$elementList[$table][] = array($id, $value['swapWith']);
}
foreach ($elementList as $tbl => $idList) {
foreach ($idList as $idKey => $idSet) {
$this->version_swap($tbl, $idSet[0], $idSet[1], $value['swapIntoWS'], $tcemainObj);
}
}
$this->version_swap($table, $id, $value['swapWith'], $value['swapIntoWS'], $tcemainObj);
break;
case 'clearWSID':
......
break;
case 'setStage':
$elementList = array();
$idList = $elementList[$table] = t3lib_div::trimExplode(',', $id, 1);
$setStageMode = $tcemainObj->BE_USER->getTSConfigVal('options.workspaces.changeStageMode');
if ($setStageMode == 'any' || $setStageMode == 'page') {
if (count($idList) == 1) {
$rec = t3lib_BEfunc::getRecord($table, $idList[0], 't3ver_wsid');
$workspaceId = $rec['t3ver_wsid'];
} else {
$workspaceId = $tcemainObj->BE_USER->workspace;
}
if ($table !== 'pages') {
if ($setStageMode == 'any') {
// (1) Find page to change stage and (2)
// find other elements from the same ws to change stage
$pageIdList = array();
$this->findPageIdsForVersionStateChange($table, $idList, $workspaceId, $pageIdList, $elementList);
$this->findPageElementsForVersionStageChange($pageIdList, $workspaceId, $elementList);
}
} else {
// Find all elements from the same ws to change stage
$this->findRealPageIds($idList);
$this->findPageElementsForVersionStageChange($idList, $workspaceId, $elementList);
}
$elementIds = t3lib_div::trimExplode(',', $id, TRUE);
foreach ($elementIds as $elementId) {
$this->version_setStage($table, $elementId, $value['stageId'],
(isset($value['comment']) && $value['comment'] ? $value['comment'] : $this->generalComment),
TRUE,
$tcemainObj
);
}
foreach ($elementList as $tbl => $elementIdList) {
foreach ($elementIdList as $elementId) {
$this->version_setStage($tbl, $elementId, $value['stageId'], ($value['comment'] ? $value['comment'] : $this->generalComment), TRUE, $tcemainObj);
}
}
break;
}
}
......
if ($emailMessage && $emailSubject) {
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');
$emailSubject = sprintf($subject, $elementName);
$emailSubject = sprintf($emailSubject, $elementName);
$emailMessage = sprintf($emailMessage,
$markers['###SITE_NAME###'],
$markers['###SITE_URL###'],
......
if (!isset($languageObjects[$recipientLanguage])) {
// a LANG object in this language hasn't been
// instantiated yet, so this is done here
/** @var $languageObject language */
$languageObject = t3lib_div::makeInstance('language');
$languageObject->init($recipientLanguage);
$languageObjects[$recipientLanguage] = $languageObject;
......
}
}
// Remove the possible inline child tables from the tables to be versioniozed automatically:
$verTablesArray = array_diff($verTablesArray, $this->getPossibleInlineChildTablesOfParentTable('pages'));
// Begin to copy pages if we're allowed to:
if ($tcemainObj->BE_USER->workspaceVersioningTypeAccess($versionizeTree)) {
......
} else {
// Otherwise update the movePlaceholder:
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($movePlhID), $movePlh);
$tcemainObj->updateRefIndex($table, $movePlhID);
$tcemainObj->addRemapStackRefIndex($table, $movePlhID);
}
}
......
$tcemainObj->newlog2(($swapIntoWS ? 'Swapping' : 'Publishing') . ' successful for table "' . $table . '" uid ' . $id . '=>' . $swapWith, $table, $id, $swapVersion['pid']);
// Update reference index of the live record:
$tcemainObj->updateRefIndex($table, $id);
$tcemainObj->addRemapStackRefIndex($table, $id);
// Set log entry for live record:
$propArr = $tcemainObj->getRecordPropertiesFromRow($table, $swapVersion);
......
$tcemainObj->setHistory($table, $id, $theLogId);
// Update reference index of the offline record:
$tcemainObj->updateRefIndex($table, $swapWith);
$tcemainObj->addRemapStackRefIndex($table, $swapWith);
// Set log entry for offline record:
$propArr = $tcemainObj->getRecordPropertiesFromRow($table, $curVersion);
if ($propArr['_ORIG_pid'] == -1) {
......
// Process pointer fields on normalized database:
if ($inlineType == 'field') {
// Read relations that point to the current record (e.g. live record):
// Read relations that point to the current record (e.g. live record):
/** @var $dbAnalysisCur t3lib_loadDBGroup */
$dbAnalysisCur = t3lib_div::makeInstance('t3lib_loadDBGroup');
$dbAnalysisCur->setUpdateReferenceIndex(FALSE);
$dbAnalysisCur->start('', $conf['foreign_table'], '', $curVersion['uid'], $table, $conf);
// Read relations that point to the record to be swapped with e.g. draft record):
// Read relations that point to the record to be swapped with e.g. draft record):
/** @var $dbAnalysisSwap t3lib_loadDBGroup */
$dbAnalysisSwap = t3lib_div::makeInstance('t3lib_loadDBGroup');
$dbAnalysisSwap->setUpdateReferenceIndex(FALSE);
$dbAnalysisSwap->start('', $conf['foreign_table'], '', $swapVersion['uid'], $table, $conf);
// Update relations for both (workspace/versioning) sites:
$dbAnalysisCur->writeForeignField($conf, $curVersion['uid'], $swapVersion['uid']);
$dbAnalysisSwap->writeForeignField($conf, $swapVersion['uid'], $curVersion['uid']);
$items = array_merge($dbAnalysisCur->itemArray, $dbAnalysisSwap->itemArray);
foreach ($items as $item) {
$tcemainObj->addRemapStackRefIndex($item['table'], $item['id']);
}
... This diff was truncated because it exceeds the maximum size that can be displayed.
(1-1/2)