aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-11 18:14:16 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-11 18:14:16 +0000
commit538a796fceaecd20c145b0912143a9066000e860 (patch)
tree4aa384ceca938ac43034bd708549513271126f48 /engine/lib
parent498986d5e7d269b60d307fba3e79148023d73fb5 (diff)
downloadelgg-538a796fceaecd20c145b0912143a9066000e860.tar.gz
elgg-538a796fceaecd20c145b0912143a9066000e860.tar.bz2
Added getNumElements()
git-svn-id: https://code.elgg.org/elgg/trunk@1406 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/opendd.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/engine/lib/opendd.php b/engine/lib/opendd.php
index 2acb21811..5093cdee1 100644
--- a/engine/lib/opendd.php
+++ b/engine/lib/opendd.php
@@ -40,7 +40,12 @@
public function __construct(array $elements = NULL)
{
if ($elements)
- $this->elements = $elements;
+ {
+ if (is_array($elements))
+ $this->elements = $elements;
+ else
+ $this->addElement($elements);
+ }
else
$this->elements = array();
}
@@ -52,7 +57,9 @@
*/
public function getVersion() { return $this->ODDSupportedVersion; }
- public function addElement(ODD $element) { $this->elements[] = $element; }
+ 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)
@@ -180,6 +187,13 @@
}
/**
+ * Return the published time as a unix timestamp.
+ *
+ * @return int or false on failure.
+ */
+ public function getPublishedAsTime() { return strtotime($this->attributes['published']); }
+
+ /**
* For serialisation, implement to return a string name of the tag eg "header" or "metadata".
* @return string
*/