aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ODDDocument.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-22 17:01:17 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-22 17:01:17 +0000
commit965cbe52f22809f19ca150feb585b0218aa89f85 (patch)
treefc1b59b44c5ecbaedf27cc8c71e7abc80a15305e /engine/classes/ODDDocument.php
parent56b3e3dcd833a8a9124581b536c69806962b9640 (diff)
downloadelgg-965cbe52f22809f19ca150feb585b0218aa89f85.tar.gz
elgg-965cbe52f22809f19ca150feb585b0218aa89f85.tar.bz2
Converted line endings to unix.
git-svn-id: http://code.elgg.org/elgg/trunk@6957 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ODDDocument.php')
-rw-r--r--engine/classes/ODDDocument.php258
1 files changed, 129 insertions, 129 deletions
diff --git a/engine/classes/ODDDocument.php b/engine/classes/ODDDocument.php
index 0c8731a75..834b5b8fe 100644
--- a/engine/classes/ODDDocument.php
+++ b/engine/classes/ODDDocument.php
@@ -1,129 +1,129 @@
-<?php
-/**
- * @class ODDDocument ODD Document container.
- * This class is used during import and export to construct.
- * @author Curverider Ltd
- */
-class ODDDocument implements Iterator {
- /**
- * ODD Version
- *
- * @var string
- */
- private $ODDSupportedVersion = "1.0";
-
- /**
- * Elements of the document.
- */
- private $elements;
-
- /**
- * Optional wrapper factory.
- */
- private $wrapperfactory;
-
- public function __construct(array $elements = NULL) {
- if ($elements) {
- if (is_array($elements)) {
- $this->elements = $elements;
- } else {
- $this->addElement($elements);
- }
- } else {
- $this->elements = array();
- }
- }
-
- /**
- * Return the version of ODD being used.
- *
- * @return string
- */
- public function getVersion() {
- return $this->ODDSupportedVersion;
- }
-
- public function getNumElements() {
- return count($this->elements);
- }
-
- public function addElement(ODD $element) {
- if (!is_array($this->elements)) {
- $this->elements = array();
- $this->elements[] = $element;
- }
- }
-
- public function addElements(array $elements) {
- foreach ($elements as $element) {
- $this->addElement($element);
- }
- }
-
- public function getElements() {
- return $this->elements;
- }
-
- /**
- * Set an optional wrapper factory to optionally embed the ODD document in another format.
- */
- public function setWrapperFactory(ODDWrapperFactory $factory) {
- $this->wrapperfactory = $factory;
- }
-
- /**
- * Magic function to generate valid ODD XML for this item.
- */
- public function __toString() {
- $xml = "";
-
- if ($this->wrapperfactory) {
- // A wrapper has been provided
- $wrapper = $this->wrapperfactory->getElementWrapper($this); // Get the wrapper for this element
-
- $xml = $wrapper->wrap($this); // Wrap this element (and subelements)
- } else {
- // Output begin tag
- $generated = date("r");
- $xml .= "<odd version=\"{$this->ODDSupportedVersion}\" generated=\"$generated\">\n";
-
- // Get XML for elements
- foreach ($this->elements as $element) {
- $xml .= "$element";
- }
-
- // Output end tag
- $xml .= "</odd>\n";
- }
-
- return $xml;
- }
-
- // ITERATOR INTERFACE //////////////////////////////////////////////////////////////
- /*
- * This lets an entity's attributes be displayed using foreach as a normal array.
- * Example: http://www.sitepoint.com/print/php5-standard-library
- */
-
- private $valid = FALSE;
-
- function rewind() {
- $this->valid = (FALSE !== reset($this->elements));
- }
-
- function current() {
- return current($this->elements);
- }
-
- function key() {
- return key($this->elements);
- }
-
- function next() {
- $this->valid = (FALSE !== next($this->elements));
- }
-
- function valid() {
- return $this->valid;
- }
-}
+<?php
+/**
+ * @class ODDDocument ODD Document container.
+ * This class is used during import and export to construct.
+ * @author Curverider Ltd
+ */
+class ODDDocument implements Iterator {
+ /**
+ * ODD Version
+ *
+ * @var string
+ */
+ private $ODDSupportedVersion = "1.0";
+
+ /**
+ * Elements of the document.
+ */
+ private $elements;
+
+ /**
+ * Optional wrapper factory.
+ */
+ private $wrapperfactory;
+
+ public function __construct(array $elements = NULL) {
+ if ($elements) {
+ if (is_array($elements)) {
+ $this->elements = $elements;
+ } else {
+ $this->addElement($elements);
+ }
+ } else {
+ $this->elements = array();
+ }
+ }
+
+ /**
+ * Return the version of ODD being used.
+ *
+ * @return string
+ */
+ public function getVersion() {
+ return $this->ODDSupportedVersion;
+ }
+
+ public function getNumElements() {
+ return count($this->elements);
+ }
+
+ public function addElement(ODD $element) {
+ if (!is_array($this->elements)) {
+ $this->elements = array();
+ $this->elements[] = $element;
+ }
+ }
+
+ public function addElements(array $elements) {
+ foreach ($elements as $element) {
+ $this->addElement($element);
+ }
+ }
+
+ public function getElements() {
+ return $this->elements;
+ }
+
+ /**
+ * Set an optional wrapper factory to optionally embed the ODD document in another format.
+ */
+ public function setWrapperFactory(ODDWrapperFactory $factory) {
+ $this->wrapperfactory = $factory;
+ }
+
+ /**
+ * Magic function to generate valid ODD XML for this item.
+ */
+ public function __toString() {
+ $xml = "";
+
+ if ($this->wrapperfactory) {
+ // A wrapper has been provided
+ $wrapper = $this->wrapperfactory->getElementWrapper($this); // Get the wrapper for this element
+
+ $xml = $wrapper->wrap($this); // Wrap this element (and subelements)
+ } else {
+ // Output begin tag
+ $generated = date("r");
+ $xml .= "<odd version=\"{$this->ODDSupportedVersion}\" generated=\"$generated\">\n";
+
+ // Get XML for elements
+ foreach ($this->elements as $element) {
+ $xml .= "$element";
+ }
+
+ // Output end tag
+ $xml .= "</odd>\n";
+ }
+
+ return $xml;
+ }
+
+ // ITERATOR INTERFACE //////////////////////////////////////////////////////////////
+ /*
+ * This lets an entity's attributes be displayed using foreach as a normal array.
+ * Example: http://www.sitepoint.com/print/php5-standard-library
+ */
+
+ private $valid = FALSE;
+
+ function rewind() {
+ $this->valid = (FALSE !== reset($this->elements));
+ }
+
+ function current() {
+ return current($this->elements);
+ }
+
+ function key() {
+ return key($this->elements);
+ }
+
+ function next() {
+ $this->valid = (FALSE !== next($this->elements));
+ }
+
+ function valid() {
+ return $this->valid;
+ }
+}