Changing bootstrap->render

This commit is contained in:
rootcoma 2013-12-04 19:09:23 -08:00
parent 04af7dd2de
commit 29a16973cb
8 changed files with 54 additions and 15 deletions

View File

@ -1,3 +1,6 @@
<?php
require_once('includes/autoload.php');
$container->render('about.php', 'About', 'about.php');
$container->setTitle('About');
$container->setCurrentPage('about.php');
$container->render('about.php');

View File

@ -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 . ' &middot; ';
}
if(!empty($currentPage)) {
$viewVars['currentPage'] = $currentPage;
$viewVars['title'] = $this->title;
if($this->title != '') {
$viewVars['title'] .= ' &middot; ';
}
$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;
}

View File

@ -1,3 +1,6 @@
<?php
require_once('includes/autoload.php');
$container->render('home.php', 'Home', 'index.php');
$container->setTitle('Home');
$container->setCurrentPage('index.php');
$container->render('home.php');

View File

@ -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);

View File

@ -1,3 +1,7 @@
<?php
require_once('includes/autoload.php');
$container->render('reports.php', 'Reports', 'reports.php');
$container->setTitle('Reports');
$container->setCurrentPage('reports.php');
$container->render('reports.php');

View File

@ -1,3 +1,7 @@
<?php
require_once('includes/autoload.php');
$container->render('stats.php', 'Stats', 'stats.php');
$container->setTitle('Stats');
$container->setCurrentPage('stats.php');
$container->render('stats.php');

View File

@ -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');

View File

@ -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);