aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-14 22:33:44 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-14 22:33:44 +0000
commit6b090d639e9623ef47ff8b06f390ef23361a4261 (patch)
tree1d9be8b70672cc8e7e7e716d6673b38ba5c1889b /engine
parent1434676e0f5a213b6feda28b660faa92c5aad919 (diff)
downloadelgg-6b090d639e9623ef47ff8b06f390ef23361a4261.tar.gz
elgg-6b090d639e9623ef47ff8b06f390ef23361a4261.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Import functions now deal in ODD! git-svn-id: https://code.elgg.org/elgg/trunk@446 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/export.php47
1 files changed, 42 insertions, 5 deletions
diff --git a/engine/lib/export.php b/engine/lib/export.php
index e997a1c5a..cbb7465ee 100644
--- a/engine/lib/export.php
+++ b/engine/lib/export.php
@@ -94,16 +94,16 @@
$this->setAttribute('generated', date("r"));
}
- protected function setAttribute($key, $value) { $this->attributes[$key] = $value; }
- protected function getAttribute($key)
+ public function setAttribute($key, $value) { $this->attributes[$key] = $value; }
+ public function getAttribute($key)
{
if (isset($this->attributes[$key]))
return $this->attributes[$key];
return NULL;
}
- protected function setBody($value) { $this->body = $value; }
- protected function getBody() { return $this->body; }
+ public function setBody($value) { $this->body = $value; }
+ public function getBody() { return $this->body; }
/**
* Return the version of ODD being used.
@@ -222,6 +222,39 @@
protected function getTagName() { return "relationship"; }
}
+ /**
+ * Attempt to construct an ODD object out of a XmlElement or sub-elements.
+ *
+ * @param XmlElement $element The element(s)
+ * @return mixed An ODD object if the element can be handled, or false.
+ */
+ function ODD_factory(XmlElement $element)
+ {
+ $name = $element->name;
+ $odd = false;
+
+ switch ($name)
+ {
+ case 'header' : $odd = new ODDHeader(); break;
+ case 'entity' : $odd = new ODDEntity("","",""); break;
+ case 'metadata' : $odd = new ODDMetaData("","","",""); break;
+ case 'relationship' : $odd = new ODDRelationship("","",""); break;
+ }
+
+ // Now populate values
+ if ($odd)
+ {
+ // Attributes
+ foreach ($element->attributes as $k => $v)
+ $odd->setAttribute($k,$v);
+
+ // Body
+ $odd->setBody($element->content);
+ }
+
+ return $odd;
+ }
+
/** Relationship verb mapping */
$ODD_RELATIONSHIP_VERBS = array();
@@ -338,9 +371,13 @@
function __process_element($element)
{
global $IMPORTED_DATA, $IMPORTED_OBJECT_COUNTER;
+
+ // See if we can convert the element into an ODD element
+ $odd = ODD_factory($element);
// See if anyone handles this element, return true if it is.
- $handled = trigger_plugin_hook("import", "all", array("name" => $element->name, "element" => $element), $to_be_serialised);
+ if ($odd)
+ $handled = trigger_plugin_hook("import", "all", array("element" => $odd), $to_be_serialised);
// If not, then see if any of its sub elements are handled
if (!$handled)