ActionsView

<?php include_once "autoload.php";
class ActionsView extends ExploreView
{

	public function getTitleComponent()
	{
		return new TitleComponent("Actions");
	}
	
	public function getLeftButtonComponent()
	{
		return new LabelComponent("Left Button");
	}
	public function getRightButtonComponent()
	{
		return new LabelComponent("Right Button");
	}
	
	public function getToolbarComponent()
	{
		return new LabelComponent("Toolbar");
	}
}

?>

ExploreView

<?php include_once "autoload.php";
abstract class ExploreView extends ToolbarView
{
	public function compose()
	{
		$ret = false;
		
		do
		{
			if (!parent::compose())
			{
				ERROUT(get_class($this).":compose - Error composing parent");
				break;
			}
		
			$layout = new VerticalLayout();
			foreach ($this->action->get("resourceCollection") as $resource)
			{
				$resourceComponent = new ResourceComponent($resource);
				if (!$layout->add($resourceComponent))
				{
					ERROUT(get_class($this)."compose - Error adding resourceComponent to layout");
					continue;
				}
			}
	
			if (!$this->document->add($layout))
			{
				ERROUT(get_class($this)."compose - Error adding layout to document");
				break;
			}
			
			$ret = true;
		} while (false);
		
		return $ret;
	}


}

?>

ToolbarView

<?php include_once "autoload.php";
abstract class ToolbarView extends TitlebarView
{
	public abstract function getToolbarComponent();
	
	public function compose()
	{
		$ret = false;
		
		do
		{
			if (!parent::compose())
			{
				ERROUT(get_class($this).":compose - Error composing parent");
				break;
			}
		
			$toolbar = $this->getToolbarComponent();
			
			if (!$this->document->add($toolbar))
			{
				ERROUT(get_class($this).":compose - Error adding toolbar to document");
				break;
			}
			
			$ret = true;
		} while (false);
		
		return $ret;
	}
}

?>

TitlebarView

<?php include_once "autoload.php";
abstract class TitlebarView extends ContainerComponent
{
	protected $document;
	protected $titlebar;
	protected $action;
	
	public function __construct(&$action)
	{
		$this->action = $action;
			
	}
	
	public function getLeftButtonComponent()
	{
		return new BackButtonComponent("back", "Back");
	}

	public function getRightButtonComponent()
	{
		return new ButtonComponent("done", "Done");
	}
	
	public abstract function getTitleComponent();
	
	public function compose()
	{
		$ret = false;
		
		do
		{
			$this->document = new HtmlDocument($this->action);
			if (!$this->add($this->document))
			{
				ERROUT(get_class($this).":compose - error adding document to view");
				break;
			}
			
			$this->titlebar = new Titlebar($this->getTitleComponent(), $this->getLeftButtonComponent(), $this->getRightButtonComponent());
			if (!$this->document->add($this->titlebar))
			{
				ERROUT(get_class($this).":compose - error adding titlebar to document");
				break;
			}

			$ret = true;

		} while (false);
	
		return $ret;
	}
}

?>

ContainerComponent

<?php require_once "autoload.php";

abstract class ContainerComponent extends Component
{
	protected $componentCollection;

	public function add(&$component)
	{
		$this->componentCollection[] = $component;
		return true;
	}

	public function render()
	{
		parent::render();
		foreach ($this->componentCollection as $component)
		{
			$component->render();
		}
		return true;
	}
}

?>

Component

<?php require_once "autoload.php";

abstract class Component extends Bean
{
	public function render()
	{
/*
		?><a href="Source.php?class=<?=get_class($this)?>" style="color: #888; text-decoration: none; font-family: courier new; font-size: 12pt;" target="_blank">≡</a><?
*/
		return true;
	}

}
?>

Bean

<?php include_once "autoload.php";

abstract class Bean
{
	public function set($field, &$value) { $this->$field = $value; }
	public function &get($field) { return $this->$field; }

	public function __construct()
	{
	}

	public function map_to_vars(&$map)
	{
		foreach (array_keys(get_object_vars($this)) as $key)
		{
			$this->$key = $map[$key];
		}
	}
}
?>