From 29a16973cb923becfe5ca7b00227b7b480cfcac4 Mon Sep 17 00:00:00 2001 From: rootcoma Date: Wed, 4 Dec 2013 19:09:23 -0800 Subject: [PATCH] Changing bootstrap->render --- php/about.php | 5 ++++- php/includes/bootstrap.php | 32 ++++++++++++++++++++++++-------- php/index.php | 5 ++++- php/profile.php | 5 ++++- php/reports.php | 6 +++++- php/stats.php | 6 +++++- php/top.php | 5 ++++- php/user.php | 5 ++++- 8 files changed, 54 insertions(+), 15 deletions(-) diff --git a/php/about.php b/php/about.php index afa373c..460e577 100644 --- a/php/about.php +++ b/php/about.php @@ -1,3 +1,6 @@ render('about.php', 'About', 'about.php'); +$container->setTitle('About'); +$container->setCurrentPage('about.php'); + +$container->render('about.php'); diff --git a/php/includes/bootstrap.php b/php/includes/bootstrap.php index edcd94e..4cd2a77 100644 --- a/php/includes/bootstrap.php +++ b/php/includes/bootstrap.php @@ -5,28 +5,44 @@ class Bootstrap public $config; public $login; + public $title = ''; + public $currentPage = ''; + public function __construct($config) { $this->config = $config; $this->storage = new Storage($this->config['dbLocation']); $this->login = new Login($this->storage); } - public function render($page, $title='', $currentPage='', $values=array()) { + public function render($page, $values=array()) { $viewVars = array(); - $viewVars['title'] = ''; - $viewVars['currentPage'] = ''; - if(!empty($title)) { - $viewVars['title'] = $title . ' · '; - } - if(!empty($currentPage)) { - $viewVars['currentPage'] = $currentPage; + $viewVars['title'] = $this->title; + if($this->title != '') { + $viewVars['title'] .= ' · '; } + $viewVars['currentPage'] = $this->currentPage; $container = $this; include($this->config['viewLocation'] . 'header.php'); include($this->config['viewLocation'] . $page); include($this->config['viewLocation'] . 'footer.php'); } + public function setTitle($title) { + $this->title = $title; + } + + public function setCurrentPage($currentPage) { + $this->currentPage = $currentPage; + } + + public function getTitle() { + return $this->title; + } + + public function getCurrentPage() { + return $this->currentPage; + } + public function getLogin() { return $this->login; } diff --git a/php/index.php b/php/index.php index 7069dce..b71f2f8 100644 --- a/php/index.php +++ b/php/index.php @@ -1,3 +1,6 @@ render('home.php', 'Home', 'index.php'); +$container->setTitle('Home'); +$container->setCurrentPage('index.php'); + +$container->render('home.php'); diff --git a/php/profile.php b/php/profile.php index 8275ba4..a44f256 100644 --- a/php/profile.php +++ b/php/profile.php @@ -117,4 +117,7 @@ $values['usernameCanonical'] = $usernameCanonical; $values['errors'] = $errors; $values['lastSeen'] = $lastSeen; -$container->render('profile.php', $username, '', $values); +$container->setTitle($username); +$container->setCurrentPage('profile.php'); + +$container->render('profile.php', $values); diff --git a/php/reports.php b/php/reports.php index c5cbd82..f4e92b3 100644 --- a/php/reports.php +++ b/php/reports.php @@ -1,3 +1,7 @@ render('reports.php', 'Reports', 'reports.php'); + +$container->setTitle('Reports'); +$container->setCurrentPage('reports.php'); + +$container->render('reports.php'); diff --git a/php/stats.php b/php/stats.php index 0e56f9f..1d0ba09 100644 --- a/php/stats.php +++ b/php/stats.php @@ -1,3 +1,7 @@ render('stats.php', 'Stats', 'stats.php'); + +$container->setTitle('Stats'); +$container->setCurrentPage('stats.php'); + +$container->render('stats.php'); diff --git a/php/top.php b/php/top.php index d537a8e..3af50f0 100644 --- a/php/top.php +++ b/php/top.php @@ -11,4 +11,7 @@ if(array_key_exists('t', $_GET)) { } } -$container->render('top.php', 'Top Scores for ' . $timeDesc, 'top.php'); +$container->setTitle('Top Scores for ' . $timeDesc); +$container->setCurrentPage('top.php'); + +$container->render('top.php'); diff --git a/php/user.php b/php/user.php index 3037973..22d0036 100644 --- a/php/user.php +++ b/php/user.php @@ -53,4 +53,7 @@ $values['usersCount'] = $usersCount; $values['users'] = $users; $values['errors'] = $errors; -$container->render('user.php', 'Players', 'user.php', $values); +$container->setTitle('Players'); +$container->setCurrentPage('user.php'); + +$container->render('user.php', $values);