Changing bootstrap->render
This commit is contained in:
parent
04af7dd2de
commit
29a16973cb
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue