From 538a796fceaecd20c145b0912143a9066000e860 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 11 Jul 2008 18:14:16 +0000 Subject: Added getNumElements() git-svn-id: https://code.elgg.org/elgg/trunk@1406 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/opendd.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'engine/lib/opendd.php') 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) @@ -179,6 +186,13 @@ $this->attributes['published'] = date("r", $time); } + /** + * 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 -- cgit v1.2.3