aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ODD.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes/ODD.php')
-rw-r--r--engine/classes/ODD.php46
1 files changed, 42 insertions, 4 deletions
diff --git a/engine/classes/ODD.php b/engine/classes/ODD.php
index 1d553c7c4..fa5b616fc 100644
--- a/engine/classes/ODD.php
+++ b/engine/classes/ODD.php
@@ -1,8 +1,9 @@
<?php
/**
* Open Data Definition (ODD) superclass.
- * @package Elgg
- * @subpackage Core
+ *
+ * @package Elgg.Core
+ * @subpackage ODD
*/
abstract class ODD {
/**
@@ -22,14 +23,34 @@ abstract class ODD {
$this->body = "";
}
+ /**
+ * Returns an array of attributes
+ *
+ * @return array
+ */
public function getAttributes() {
return $this->attributes;
}
+ /**
+ * Sets an attribute
+ *
+ * @param string $key Name
+ * @param mixed $value Value
+ *
+ * @return void
+ */
public function setAttribute($key, $value) {
$this->attributes[$key] = $value;
}
+ /**
+ * Returns an attribute
+ *
+ * @param string $key Name
+ *
+ * @return mixed
+ */
public function getAttribute($key) {
if (isset($this->attributes[$key])) {
return $this->attributes[$key];
@@ -38,10 +59,22 @@ abstract class ODD {
return NULL;
}
+ /**
+ * Sets the body of the ODD.
+ *
+ * @param mixed $value Value
+ *
+ * @return void
+ */
public function setBody($value) {
$this->body = $value;
}
+ /**
+ * Gets the body of the ODD.
+ *
+ * @return mixed
+ */
public function getBody() {
return $this->body;
}
@@ -50,6 +83,8 @@ abstract class ODD {
* Set the published time.
*
* @param int $time Unix timestamp
+ *
+ * @return void
*/
public function setPublished($time) {
$this->attributes['published'] = date("r", $time);
@@ -66,25 +101,28 @@ abstract class ODD {
/**
* For serialisation, implement to return a string name of the tag eg "header" or "metadata".
+ *
* @return string
*/
abstract protected function getTagName();
/**
* Magic function to generate valid ODD XML for this item.
+ *
+ * @return string
*/
public function __toString() {
// Construct attributes
$attr = "";
foreach ($this->attributes as $k => $v) {
- $attr .= ($v!="") ? "$k=\"$v\" " : "";
+ $attr .= ($v != "") ? "$k=\"$v\" " : "";
}
$body = $this->getBody();
$tag = $this->getTagName();
$end = "/>";
- if ($body!="") {
+ if ($body != "") {
$end = "><![CDATA[$body]]></{$tag}>";
}