<?php
// $Header: /cvsroot/phptsmadmin/phpTSMadmin/lib/menu.php,v 1.2 2009/04/19 04:03:05 wurley Exp $

/**
 * @package leenooksApp
 * @author Deon George
 *
 * Abstract class which represents the Menu view ; the draw() method
 * must be implemented by subclasses
 *
 * @see Menu_HTML
 */
abstract class Menu {
	# Datastore server represented by this tree
	protected $index = null;

	protected function __construct($index) {
		$this->index = $index;
	}

	static public function getInstance($index) {
		$menu = get_cached_item($index,'menu');
		if (! $menu) {
			$menu = $_SESSION[APPCONFIG]->getValue('appearance','menu');
			eval('$menu = new '.$menu.'($index);');
			set_cached_item($index,'menu','null',$menu);
		}
		return $menu;
	}

	/**
	 * Get the server Object for this tree
	 *
	 * @return object Server Object for this tree
	 */
	protected function getServer() {
		return $_SESSION[APPCONFIG]->getServer($this->index);
	}

	public function getDatastore() {
		return isset($_SESSION[APPCONFIG]->datastore->object[$this->index]) ? $_SESSION[APPCONFIG]->datastore->object[$this->index] : null;
	}

	/**
	 * Displays the Menu
	 */
	abstract public function draw();
}
?>
