<?php

class TreeNode extends View {



	protected $package = 'core-tree';
	protected $idRequired = true;



	public function __construct($id) {
		parent::__construct($id);
		$this->data['expanded'] = &$_SESSION[$this->id]['expanded'];
		$this->addListener(new ToggleListener(
			new Action("/view/{$this->package}/TreeCtrl/toggle", "'{$this->id}'")
		));
		$this->icon = 'var/img/blank.png';
	}



	public function toggle() {
		$this->expanded ? $this->colapse() : $this->expand();
	}



	public function expand() {
		$this->expanded = true;
		$response = ResponseContext::getInstance();
		$response->Tree->expandNode($this->getId());
	}



	public function colapse() {
		$this->expanded = FALSE;
		$response = ResponseContext::getInstance();
		$response->Tree->colapseNode($this->getId());
	}



	public function isExpanded() {
		return $this->expanded;
	}



} // class TreeNode

?>