From b5cd8aa32cf2e9c83ec457fbb0a235cdec8e37cd Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 9 Nov 2014 20:28:50 +0100 Subject: move init-code into bootstrap-file --- index.php | 6 +----- lib/PhpTemplate.php | 9 ++++++++- lib/bootstrap.php | 10 ++++++++++ party.php | 7 +------ room.php | 6 +----- 5 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 lib/bootstrap.php diff --git a/index.php b/index.php index 96bb197..4faff27 100644 --- a/index.php +++ b/index.php @@ -1,13 +1,9 @@ render(array( 'page' => 'rooms', - 'baseurl' => baseurl(), 'title' => 'Overview', 'rooms' => $GLOBALS['CONFIG']['ROOMS'], diff --git a/lib/PhpTemplate.php b/lib/PhpTemplate.php index 8dd6f72..4fc4dfe 100644 --- a/lib/PhpTemplate.php +++ b/lib/PhpTemplate.php @@ -12,14 +12,21 @@ if(!function_exists('h')) class PhpTemplate { + private $data = array(); + public function __construct($file) { $this -> file = $file; } + public function set($___data = array()) + { + $this->data = array_merge($this->data, $___data); + } + public function render($___data = array()) { - extract((array)$___data); + extract(array_merge($this->data, $___data)); unset($___data); ob_start(); diff --git a/lib/bootstrap.php b/lib/bootstrap.php new file mode 100644 index 0000000..297144b --- /dev/null +++ b/lib/bootstrap.php @@ -0,0 +1,10 @@ +set(array( + 'baseurl' => baseurl(), +)); diff --git a/party.php b/party.php index 3307f35..a095df3 100644 --- a/party.php +++ b/party.php @@ -1,16 +1,11 @@ render(array( 'page' => 'party', - 'baseurl' => baseurl(), 'title' => $GLOBALS['CONFIG']['ROOMS'][$room], 'rooms' => $GLOBALS['CONFIG']['ROOMS'], diff --git a/room.php b/room.php index 9844246..43bddcc 100644 --- a/room.php +++ b/room.php @@ -1,8 +1,6 @@ render(array( 'page' => 'room', - 'baseurl' => baseurl(), 'title' => $GLOBALS['CONFIG']['ROOMS'][$room].' – '.$GLOBALS['CONFIG']['FORMATS'][$format], 'rooms' => $GLOBALS['CONFIG']['ROOMS'], -- cgit v1.2.3