diff options
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | lib/PhpTemplate.php | 9 | ||||
-rw-r--r-- | lib/bootstrap.php | 10 | ||||
-rw-r--r-- | party.php | 7 | ||||
-rw-r--r-- | room.php | 6 |
5 files changed, 21 insertions, 17 deletions
@@ -1,13 +1,9 @@ <?php -require_once('lib/PhpTemplate.php'); -require_once('lib/helper.php'); -require_once('lib/config.php'); +require_once('lib/bootstrap.php'); -$tpl = new PhpTemplate('template/page.phtml'); echo $tpl->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 @@ +<?php + +require_once('lib/PhpTemplate.php'); +require_once('lib/helper.php'); +require_once('lib/config.php'); + +$tpl = new PhpTemplate('template/page.phtml'); +$tpl->set(array( + 'baseurl' => baseurl(), +)); @@ -1,16 +1,11 @@ <?php -require_once('lib/PhpTemplate.php'); -require_once('lib/helper.php'); -require_once('lib/config.php'); +require_once('lib/bootstrap.php'); $room = $_GET['room']; - -$tpl = new PhpTemplate('template/page.phtml'); echo $tpl->render(array( 'page' => 'party', - 'baseurl' => baseurl(), 'title' => $GLOBALS['CONFIG']['ROOMS'][$room], 'rooms' => $GLOBALS['CONFIG']['ROOMS'], @@ -1,8 +1,6 @@ <?php -require_once('lib/PhpTemplate.php'); -require_once('lib/helper.php'); -require_once('lib/config.php'); +require_once('lib/bootstrap.php'); $room = $_GET['room']; $language = $_GET['language']; @@ -36,11 +34,9 @@ switch($format) { break; } -$tpl = new PhpTemplate('template/page.phtml'); echo $tpl->render(array( 'page' => 'room', - 'baseurl' => baseurl(), 'title' => $GLOBALS['CONFIG']['ROOMS'][$room].' – '.$GLOBALS['CONFIG']['FORMATS'][$format], 'rooms' => $GLOBALS['CONFIG']['ROOMS'], |