--- /dev/null
+<?php
+
+/**
+ * Homerton May Ball Ticketing System.
+ *
+ * Copyright 2011 Richard Whitehouse for Homerton May Ball 2011
+ **/
+
+class Page {
+
+ public function logic($template){
+
+ }
+
+}
+
+class Template {
+
+ public function display(){
+
+ }
+
+}
+
+class Ticketing {
+
+ private static $instance;
+
+ public static function Get(){
+ if(!isset(Ticketing::$instance)){
+ Ticketing::$instance = new Ticketing();
+ }
+
+ return Ticketing::$instance;
+ }
+
+ private $config;
+
+ public function config(){
+ if(!isset($this->config)){
+ $this->config = Config::Load();
+ }
+ return $config;
+ }
+
+ private $type;
+
+ public function type(){
+ if(!isset($this->type)){
+ $type = isset($_GET['page']) ? $_GET['page'] : null;
+ if(isset($type) && file_exists('pages/' . $type . '.php') && file_exists('templates/' . $type . '.php')){
+ $this->type = $type;
+ } elseif(file_exists('pages/index.php') && file_exists('templates/index.php')) {
+ $this->type = 'index';
+ } else {
+ throw new Exception('Invalid type');
+ }
+ }
+ return $this->type;
+ }
+
+ private $page;
+
+ public function page(){
+ if(!isset($this->page)){
+ require_once('pages/' . $this->type() . '.php');
+ $class = 'Page_' . $this->type();
+ $this->page = new $class();
+ if(!isset($this->page) || !($this->page instanceof Page)){
+ throw new Exception('Invalid Page Object - ' . $this->type());
+ }
+ }
+ return $this->page;
+ }
+
+ private $template;
+
+ public function template(){
+ if(!isset($this->template)){
+ require_once('templates/' . $this->type() . '.php');
+ $class = 'Template_' . $this->type();
+ $this->template = new $class();
+ if(!isset($this->template) || !($this->template instanceof Template)){
+ throw new Exception('Invalid Template Object - ' . $this->type());
+ }
+ }
+ return $this->template;
+ }
+
+ public function run(){
+ try {
+
+ $this->page()->logic($this->template());
+ $this->template()->display();
+
+ } catch(Exception $e){
+ header('Content-type: text/plain'); print_r($e); exit;
+ }
+ }
+
+}
+
+Ticketing::Get()->run();
+