diff options
author | deva <deva> | 2010-03-01 08:27:57 +0000 |
---|---|---|
committer | deva <deva> | 2010-03-01 08:27:57 +0000 |
commit | 9e701aea428bb62f892ad9fa2fdafb93b5465d3a (patch) | |
tree | c722efe871a8e61b7d98cc1805f794936bc1e96a | |
parent | 9d6e3ab0be248bde75ed5b70dbab5f24d2bfeac5 (diff) |
Moved vars out from config.php and into the config module.
-rw-r--r-- | htdocs/index.php | 12 | ||||
-rw-r--r-- | utils/modules/config.php | 62 |
2 files changed, 50 insertions, 24 deletions
diff --git a/htdocs/index.php b/htdocs/index.php index 25f5ad1..37aebc3 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -39,7 +39,7 @@ if($config->value('splash') == "true") { <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml" /> <link rel="author" title="Bent Bisballe Nyeng" href="http://www.aasimon.org"/> <link href="/favicon.ico" rel="shortcut icon"/> - <link rel="stylesheet" type="text/css" href="<?php echo $CSS; ?>" media="screen"/> + <link rel="stylesheet" type="text/css" href="<?php echo $config->value('css'); ?>" media="screen"/> </head> <body> <div class="splash"> @@ -69,8 +69,8 @@ if($config->value('splash') == "true") { <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml" /> <link rel="author" title="Bent Bisballe Nyeng" href="http://www.aasimon.org"/> <link href="/favicon.ico" rel="shortcut icon"/> - <link rel="stylesheet" type="text/css" href="<?php echo $CSS; ?>" media="screen"/> - <link rel="stylesheet" type="text/css" href="handheld.css" media="handheld"/> + <link rel="stylesheet" type="text/css" href="<?php echo $config->value('css'); ?>" media="screen"/> +<!-- <link rel="stylesheet" type="text/css" href="handheld.css" media="handheld"/> --> <link rel="stylesheet" type="text/css" href="admin.css" media="screen"/> <script type="text/javascript"> // <!-- @@ -90,8 +90,8 @@ if($config->value('splash') == "true") { </head> <body><?php - include_once($UTIL_DIR."/preload.php"); -preload("design/mors/style.css"); +include_once($UTIL_DIR."/preload.php"); +preload($config->value('css')); if($page == "admin") { include($UTIL_DIR."/admin.php"); @@ -118,7 +118,7 @@ if(sizeof($menu)) { <div class="content"> <?php if($page && $page != "admin") $_p = $pages->getPage($page); -else $_p = $pages->getPage($config->value('default')); +else $_p = $pages->getPage($config->value('defaultpage')); if($_p) $_p->show(); ?> </div> diff --git a/utils/modules/config.php b/utils/modules/config.php index 4c7ac07..13cdda1 100644 --- a/utils/modules/config.php +++ b/utils/modules/config.php @@ -12,6 +12,8 @@ class Config { // Admin config public $admin_title = "Site Config"; public $admin_submodules = array("Title" => "title", + "CSS" => "css", + "Default page" => "defaultpage", "Menu" => "menu", "Splash" => "splash"); @@ -33,6 +35,24 @@ class Config { } } + public function admin_css($action, $vars) + { + switch($action) { + case "update": + $this->setValue("css", $vars["css"]); + echo "The stylesheet has now been changed to \"". $this->value("css") . "\""; + $this->write(); + break; + + default: + $form = new Form("update"); + $form->addWidget(new LineEdit("CSS file:", "css", $this->value("css", "CSS not yet set"))); + $form->addWidget(new Button("Update")); + $form->render(); + break; + } + } + public function admin_splash($action, $vars) { switch($action) { @@ -55,6 +75,24 @@ class Config { } } + public function admin_defaultpage($action, $vars) + { + switch($action) { + case "update": + $this->setValue("defaultpage", $vars["defaultpage"]); + echo "Default page has now been set to ".$this->value("defaultpage")."."; + $this->write(); + break; + + default: + $form = new Form("update"); + $form->addWidget(new LineEdit("Default page:", "defaultpage", $this->value("defaultpage", ""))); + $form->addWidget(new Button("Update")); + $form->render(); + break; + } + } + public function admin_menu($action, $vars) { switch($action) { @@ -89,6 +127,12 @@ class Config { case "title": $this->admin_title($action, $vars); break; + case "css": + $this->admin_css($action, $vars); + break; + case "defaultpage": + $this->admin_defaultpage($action, $vars); + break; case "menu": $this->admin_menu($action, $vars); break; @@ -130,24 +174,6 @@ class Config { public function value($name, $default = "") { if(isset($this->configs[$name])) return $this->configs[$name]; - - ////////// - ////////// TEMPORARY VAR EXPANSION - Remove when the real values are done. - ////////// - global $TITLE, $PRELOAD, $DEFAULT_PAGE, $MENU; - switch($name) { - case 'title': - return $TITLE; - case 'preload': - return $PRELOAD; - case 'default': - return $DEFAULT_PAGE; - case 'menu': - return $MENU; - default: - return $default; - } - return $default; } |