diff options
| author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-10-28 19:17:36 +0000 | 
|---|---|---|
| committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-10-28 19:17:36 +0000 | 
| commit | 7ddd9521b3f3a397da3b0a6b56238d31414eb4be (patch) | |
| tree | 6eb6a9a51db5fa0f5d3cc2ec6de29b9e258b12a1 /engine/classes/ODDDocument.php | |
| parent | bd3484417d170e62bc94e9db81d4ad37e8ddee6a (diff) | |
| download | elgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.gz elgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.bz2 | |
Standardized code in all of core, not including language files, tests, or core mods.
git-svn-id: http://code.elgg.org/elgg/trunk@7124 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ODDDocument.php')
| -rw-r--r-- | engine/classes/ODDDocument.php | 76 | 
1 files changed, 75 insertions, 1 deletions
| diff --git a/engine/classes/ODDDocument.php b/engine/classes/ODDDocument.php index d5619ce46..4d185aba5 100644 --- a/engine/classes/ODDDocument.php +++ b/engine/classes/ODDDocument.php @@ -1,7 +1,9 @@  <?php  /** - * @class ODDDocument ODD Document container.   * This class is used during import and export to construct. + * + * @package    Elgg.Core + * @subpackage ODD   */  class ODDDocument implements Iterator {  	/** @@ -21,6 +23,13 @@ class ODDDocument implements Iterator {  	 */  	private $wrapperfactory; +	/** +	 * Create a new ODD Document. +	 * +	 * @param array $elements Elements to add +	 * +	 * @return void +	 */  	public function __construct(array $elements = NULL) {  		if ($elements) {  			if (is_array($elements)) { @@ -42,10 +51,22 @@ class ODDDocument implements Iterator {  		return $this->ODDSupportedVersion;  	} +	/** +	 * Returns the number of elements +	 * +	 * @return int +	 */  	public function getNumElements() {  		return count($this->elements);  	} +	/** +	 * Add an element +	 * +	 * @param ODD $element An ODD element +	 * +	 * @return void +	 */  	public function addElement(ODD $element) {  		if (!is_array($this->elements)) {  			$this->elements = array(); @@ -53,18 +74,34 @@ class ODDDocument implements Iterator {  		}  	} +	/** +	 * Add multiple elements at once +	 * +	 * @param array $elements Array of ODD elements +	 * +	 * @return void +	 */  	public function addElements(array $elements) {  		foreach ($elements as $element) {  			$this->addElement($element);  		}  	} +	/** +	 * Return all elements +	 * +	 * @return array +	 */  	public function getElements() {  		return $this->elements;  	}  	/**  	 * Set an optional wrapper factory to optionally embed the ODD document in another format. +	 * +	 * @param ODDWrapperFactory $factory The factory +	 * +	 * @return void  	 */  	public function setWrapperFactory(ODDWrapperFactory $factory) {  		$this->wrapperfactory = $factory; @@ -72,6 +109,8 @@ class ODDDocument implements Iterator {  	/**  	 * Magic function to generate valid ODD XML for this item. +	 * +	 * @return string  	 */  	public function __toString() {  		$xml = ""; @@ -106,22 +145,57 @@ class ODDDocument implements Iterator {  	private $valid = FALSE; +	/** +	 * Iterator interface +	 * +	 * @see Iterator::rewind() +	 * +	 * @return void +	 */  	function rewind() {  		$this->valid = (FALSE !== reset($this->elements));  	} +	/** +	 * Iterator interface +	 * +	 * @see Iterator::current() +	 * +	 * @return void +	 */  	function current() {  		return current($this->elements);  	} +	/** +	 * Iterator interface +	 * +	 * @see Iterator::key() +	 * +	 * @return void +	 */  	function key() {  		return key($this->elements);  	} +	/** +	 * Iterator interface +	 * +	 * @see Iterator::next() +	 * +	 * @return void +	 */  	function next() {  		$this->valid = (FALSE !== next($this->elements));  	} +	/** +	 * Iterator interface +	 * +	 * @see Iterator::valid() +	 * +	 * @return void +	 */  	function valid() {  		return $this->valid;  	} | 
