__construct($parent_page); } function __construct($parent_page='') { if ($parent_page === '') { $parent_page = $_SERVER['QUERY_STRING']; $p1 = strpos($parent_page, 'page='); $p2 = strpos($parent_page, '&'); if ($p2 === false) { $parent_page = substr($parent_page, $p1+5); } else { $parent_page = substr($parent_page, $p1+5, $p2-$p1-5); } } $this->parent_page = $parent_page; } function __destruct() { } function add_subpage($title, $slug, $view) { $this->pages[] = array('title' => $title, 'slug' => $slug, 'view' => $view); } function add_subpages($pages) { foreach ($pages as $page) { $this->pages[] = array('title' => $page[0], 'slug' => $page[1], 'view' => $page[2]); } } function page_from_slug($slug) { if (!isset($slug)) { return $this->pages[0]; } foreach ($this->pages as $page) { if ($page['slug'] === $slug) { return $page; } } die('non-existent slug'); } function display_menu() { echo "\n\n"; } function display_view() { $this->current_page['view'](); } function display() { $this->display_menu(); $this->display_view(); } } /* ?>