diff --git a/core/trunk/core/tests/class/DataObject.php b/core/trunk/core/tests/class/DataObject.php index a931b20efed668d599660bafa0c41425b8cca06c..72f782f4e51d78edf4234bb7b359a71fd14d50c1 100644 --- a/core/trunk/core/tests/class/DataObject.php +++ b/core/trunk/core/tests/class/DataObject.php @@ -8,11 +8,13 @@ class DataObject private $schemaPath; private $parentObject; private $storage; + private $changes = array(); public function DataObject($name, $schemaPath) { $this->name = $name; $this->schemaPath = $schemaPath; + $this->changes[] = new DataObjectChange(DataObjectChange::CREATE); } public function setParentObject($parentObject) @@ -40,6 +42,7 @@ class DataObject } } elseif(is_scalar($value) || !$value) { //echo "<br/>Adding scalar $name = $value"; + $this->changes[] = new DataObjectChange(DataObjectChange::UPDATE, $name, (string)$this->storage[$name], $value); $this->storage[$name]->setValue($value); } } @@ -96,6 +99,14 @@ class DataObject return $return; } + public function getChanges() + { + return $this->changes; + } + + //************************************************************************* + // XML + //************************************************************************* public function asXmlDocument() { $Document = new DOMDocument(); diff --git a/core/trunk/core/tests/class/DataObjectArray.php b/core/trunk/core/tests/class/DataObjectArray.php index 66307f08ef8876601dcd3d6a9401e3be2be56513..ed04dfd07f198a38274867fb1a820c7399fdeb8b 100644 --- a/core/trunk/core/tests/class/DataObjectArray.php +++ b/core/trunk/core/tests/class/DataObjectArray.php @@ -7,6 +7,7 @@ class DataObjectArray private $schemaPath; private $arraySchemaPath; private $parentObject; + private $changes; public function DataObjectArray($name, $schemaPath, $arraySchemaPath) { @@ -15,6 +16,7 @@ class DataObjectArray $this->arraySchemaPath = $arraySchemaPath; $this->setFlags(ArrayObject::ARRAY_AS_PROPS); $this->setFlags(ArrayObject::STD_PROP_LIST); + $this->changes[] = new DataObjectChange(DataObjectChange::CREATE); } public function setParentObject($parentObject) @@ -22,10 +24,22 @@ class DataObjectArray $this->parentObject = $parentObject; } - public function append($childObject) + public function append($childObject, $silent=false) { $this->offsetSet(null, $childObject); $childObject->setParentObject($this->parentObject); + if(!$silent) { + $this->changes[] = new DataObjectChange(DataObjectChange::CREATE, $childObject->name, null, serialize($childObject)); + } + } + + public function remove($offset) + { + $objectBefore = $this->offsetGet($offset); + $this->offsetUnset($offset); + if(!$silent) { + $this->changes[] = new DataObjectChange(DataObjectChange::DELETE, $objectBefore->name, serialize($objectBefore)); + } } public function __get($name) { @@ -57,5 +71,9 @@ class DataObjectArray } return $return; } - + + public function getChanges() + { + return $this->changes; + } } \ No newline at end of file diff --git a/core/trunk/core/tests/class/DataObjectChange.php b/core/trunk/core/tests/class/DataObjectChange.php new file mode 100644 index 0000000000000000000000000000000000000000..5a0e518d4097a3c8bd78028d20873b437590b9e5 --- /dev/null +++ b/core/trunk/core/tests/class/DataObjectChange.php @@ -0,0 +1,33 @@ +<?php + + + +class DataObjectChange +{ + const NONE = 0; + const CREATE = 1; + const READ = 2; + const UPDATE = 3; + const DELETE = 4; + + private $timestamp; + private $type; + private $name; + private $ValueBefore; + private $valueAfter; + + public function DataObjectChange($type, $name=false, $valueBefore=false, $valueAfter=false) + { + $this->type = $type; + $this->timestamp = date('d-m-y h:i:s') ; + $this->name = $name; + $this->valueBefore = $valueBefore; + $this->valueAfter = $valueAfter; + } + + public function __get($name) + { + return $this->$name; + } + +} diff --git a/core/trunk/core/tests/class/DataObjectController.php b/core/trunk/core/tests/class/DataObjectController.php index e8fd8a7949bf652b8c8113d2ed704af45f683deb..921f6419b3a6a58c59f240508e8765998bbb8a54 100644 --- a/core/trunk/core/tests/class/DataObjectController.php +++ b/core/trunk/core/tests/class/DataObjectController.php @@ -16,6 +16,8 @@ class dataObjectController extends DOMDocument require_once 'core/tests/class/DataObject.php'; require_once 'core/tests/class/DataObjectProperty.php'; + require_once 'core/tests/class/DataObjectChange.php'; + require_once 'core/tests/class/DataAccessService_Database.php'; $this->dataAccessService_Database = new dataAccessService_Database(); @@ -121,7 +123,7 @@ class dataObjectController extends DOMDocument for($i=0; $i<count($objectDatas); $i++) { $objectData = $objectDatas[$i]; $itemDataObject = $this->instanciateDataObject($schemaPath); - $dataObject->append($itemDataObject); + $dataObject->append($itemDataObject, $silent=true); //echo "<br/> Result has " . count($objectData) . " properties for object #$i of array"; $this->loadProperties($itemDataObject, $objectData); $this->loadChildren($itemDataObject); @@ -152,7 +154,8 @@ class dataObjectController extends DOMDocument break; } } - + + //************************************************************************* // PUBLIC DAS FUNCTIONS //************************************************************************* @@ -212,7 +215,8 @@ class dataObjectController extends DOMDocument else return $objectSchema->name; } - public function getContentLabels($objectName) { + public function getContentLabels($objectName) + { $objectSchema = $this->schema->getObjectSchema($objectName); $childElements = $objectSchema->getChildElements(); for($i=0; $i<$childElements->length;$i++) { diff --git a/core/trunk/core/tests/class/DataObjectProperty.php b/core/trunk/core/tests/class/DataObjectProperty.php index ed8145ffe55d0b1d7741e380ff3d0b24d103e5e6..4e5677e3d05b071cc91fbae6b357631908c1cc11 100644 --- a/core/trunk/core/tests/class/DataObjectProperty.php +++ b/core/trunk/core/tests/class/DataObjectProperty.php @@ -34,10 +34,9 @@ class DataObjectProperty } } - public function setValue($value) - { - $this->storage = $value; + { + $this->storage = $value; } public function __toString() diff --git a/core/trunk/core/tests/class/DataObjectValidator.php b/core/trunk/core/tests/class/DataObjectValidator.php index 75d5c8061c44a238cf611d5a4fce003d59932e4d..156488ae264754ba98ab35c93bc0ee545517c908 100644 --- a/core/trunk/core/tests/class/DataObjectValidator.php +++ b/core/trunk/core/tests/class/DataObjectValidator.php @@ -32,7 +32,7 @@ class DataObjectValidatorError function DataObjectValidatorError($libXMLError) { $this->level = $libXMLError->level; - $this->code = $libXMLError->code; + $this->code = 'XML-' . $libXMLError->code; $this->message = $libXMLError->message; }