From 4c273bcca53e335d449ee677e36bf90e1fd1d253 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sat, 30 Jan 2010 18:21:20 +0000 Subject: Configuration data is now loaded from the include/config.ini file For now the $config and $db variables are initialized from within the theme class. This class supercedes the entire script as it is so far. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2.1@483 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- index.php | 31 +++++++++++++++++-------------- themes/default/footer.php | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/index.php b/index.php index f9b7177..01fe58b 100644 --- a/index.php +++ b/index.php @@ -7,18 +7,10 @@ define('BAYONET_ROOT', basename(dirname('.'))); define('BAYONET_INCLUDE', BAYONET_ROOT . '/include'); define('BAYONET_CONFIG', BAYONET_ROOT . '/include/config.ini'); -require BAYONET_INCLUDE . '/config.php'; require BAYONET_INCLUDE . '/debug.php'; require BAYONET_INCLUDE . '/sql.class.php'; require BAYONET_INCLUDE . '/functions.php'; -$db = new Bayonet_SQL(); -$db->Connect( - $config['sql']['hostname'], - $config['sql']['username'], - $config['sql']['password'] - ); -$db->Select_db($config['sql']['database']); class Bayonet_Theme { @@ -38,7 +30,7 @@ class Bayonet_Theme { if(!isset($_GET['theme'])) { - self::$name = Bayonet_Config::$ini['Theme']['name']; + self::$name = Bayonet_Config::$ini['site']['theme']; } else { @@ -62,7 +54,7 @@ class Bayonet_Theme self::$header = self::$root_path . '/header.php'; self::$footer = self::$root_path . '/footer.php'; - decho(get_class_vars(Bayonet_Theme)); + //decho(get_class_vars(Bayonet_Theme)); //do not re-enable this self::load(); } @@ -80,8 +72,19 @@ class Bayonet_Theme static function load() { - global $db; - + global $db, $config; + + // Globally referenced configuration and database variables + $config = Bayonet_Config::$ini; + $db = new Bayonet_SQL(); + + $db->Connect( + $config['sql']['hostname'], + $config['sql']['username'], + $config['sql']['password'] + ); + $db->Select_db($config['sql']['database']); + decho("Loading theme: '" . self::$name . "'"); require self::$index; } @@ -104,7 +107,7 @@ class Bayonet_Config } class Bayonet -{ +{ static function init() { decho('Initializing Bayonet'); @@ -113,8 +116,8 @@ class Bayonet } } - Bayonet::init(); + ?> \ No newline at end of file diff --git a/themes/default/footer.php b/themes/default/footer.php index cbbd2bd..e971b9f 100644 --- a/themes/default/footer.php +++ b/themes/default/footer.php @@ -34,7 +34,7 @@ $debug_output = sprintf("Page generated in %.3f seconds | Memory: real(%.3fmb) p Administrative Control Panel

-
+



-- cgit