From 3084446c2e6cecc85dd9d1b442cf1fbb0a04d3fc Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 16 Jul 2007 14:09:12 +0000 Subject: [PATCH] goodbye, global config defaults~ git-svn-id: file:///home/shish/svn/shimmie2/trunk@294 7f39781d-f577-437e-ae19-be835c7a54ca --- core/config.class.php | 19 +------------------ core/image.class.php | 8 ++++---- core/util.inc.php | 2 +- ext/load_ext_data/main.php | 2 +- ext/upgrade/main.php | 2 +- index.php | 1 + install.php | 28 +++++++++++++++++++++++----- themes/default/layout.class.php | 7 +++---- 8 files changed, 35 insertions(+), 34 deletions(-) diff --git a/core/config.class.php b/core/config.class.php index 74567251..5d4a7bee 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -1,16 +1,6 @@ 'Shimmie', # setup - 'version' => 'Shimmie2-2.0.3', // internal - 'base_href' => './index.php?q=', # setup - 'data_href' => './', # setup - 'image_ilink' => '$base/image/$id.$ext', # view - 'image_slink' => '', # view - 'image_tlink' => '$base/thumb/$id.jpg', # view - 'image_tip' => '$tags // $size // $filesize' # view - ); public function Config() { global $database; @@ -74,20 +64,13 @@ class Config { } public function get_bool($name, $default=null) { // deprecated -- bools should be stored as Y/N now - return ( - $this->get($name, $default) == 'Y' || - $this->get($name, $default) == '1' || - $this->get($name, $default) === true - ); + return ($this->get($name, $default) == 'Y' || $this->get($name, $default) == '1'); } private function get($name, $default=null) { if(isset($this->values[$name])) { return $this->values[$name]; } - else if(isset($this->defaults[$name])) { - return $this->defaults[$name]; - } else { return $default; } diff --git a/core/image.class.php b/core/image.class.php index 5bdeba86..37b8068c 100644 --- a/core/image.class.php +++ b/core/image.class.php @@ -92,22 +92,22 @@ class Image { public function get_image_link() { global $config; - return $this->parse_link_template($config->get_string('image_ilink')); + return $this->parse_link_template($config->get_string('image_ilink', '$base/image/$id.$ext')); } public function get_short_link() { global $config; - return $this->parse_link_template($config->get_string('image_slink')); + return $this->parse_link_template($config->get_string('image_slink', '')); } public function get_thumb_link() { global $config; - return $this->parse_link_template($config->get_string('image_tlink')); + return $this->parse_link_template($config->get_string('image_tlink', '$base/thumb/$id.jpg')); } public function get_tooltip() { global $config; - return $this->parse_link_template($config->get_string('image_tip')); + return $this->parse_link_template($config->get_string('image_tip', '$tags // $size // $filesize')); } public function get_image_filename() { diff --git a/core/util.inc.php b/core/util.inc.php index 16a78ee2..93f9474d 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -92,7 +92,7 @@ function tag_explode($tags) { function make_link($page, $query=null) { global $config; - $base = $config->get_string('base_href'); + $base = $config->get_string('base_href', './index.php?q='); if(is_null($query)) { return "$base/$page"; diff --git a/ext/load_ext_data/main.php b/ext/load_ext_data/main.php index 3d3184d9..63ec5373 100644 --- a/ext/load_ext_data/main.php +++ b/ext/load_ext_data/main.php @@ -4,7 +4,7 @@ class LoadExtData extends Extension { if(is_a($event, 'PageRequestEvent')) { global $page, $config; - $data_href = $config->get_string("data_href"); + $data_href = $config->get_string("data_href", './'); foreach(glob("ext/*/style.css") as $css_file) { $page->add_header(""); diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 6c21f810..0257fee3 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -20,7 +20,7 @@ class Upgrade extends Extension { $config->set_int("db_version", 2); } - if($config->get_int("db_version") == 2) { + if($config->get_int("db_version") <= 2) { $database->Execute("CREATE TABLE layout ( title varchar(64) primary key not null, section varchar(32) not null default \"left\", diff --git a/index.php b/index.php index 2c501b54..cd04aa1c 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,6 @@ Execute("DROP TABLE IF EXISTS tags"); $db->Execute("CREATE TABLE tags ( - image_id int(11) NOT NULL default '0', - tag varchar(255) NOT NULL default '', - UNIQUE KEY image_id (image_id,tag), - KEY tags_tag (tag), + id int not null auto_increment primary key, + tag varchar(64) not null unique, + count int not null default 0, + KEY tags_count(count) + )"); + + $db->Execute("DROP TABLE IF EXISTS image_tags"); + $db->Execute("CREATE TABLE image_tags ( + image_id int NOT NULL default 0, + tag_id int NOT NULL default 0, + UNIQUE KEY image_id_tag_id (image_id,tag_id), + KEY tags_tag_id (tag_id), KEY tags_image_id (image_id) )"); @@ -502,7 +510,17 @@ function create_tables_mysql($db) { UNIQUE (name) )"); - $db->Execute("INSERT INTO config(name, value) VALUES(?, ?)", Array('db_version', '2.0.0.9')); + $db->Execute("DROP TABLE IF EXISTS layout"); + $database->Execute("CREATE TABLE layout ( + title varchar(64) primary key not null, + section varchar(32) not null default \"left\", + position int not null default 50, + visible enum('Y', 'N') default 'Y' not null + )"); + + $db->Execute("INSERT INTO config(name, value) VALUES(?, ?)", Array('title', 'Shimmie')); + $db->Execute("INSERT INTO config(name, value) VALUES(?, ?)", Array('db_version', 5)); + $db->Execute("INSERT INTO config(name, value) VALUES(?, ?)", Array('front_page', 'index')); return $db->CommitTrans(); } diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index 523c7cb7..5ffc79d3 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -3,11 +3,10 @@ class Layout { function display_page($page) { global $config; - $theme_name = $config->get_string('theme'); - $base_href = $config->get_string('base_href'); - $data_href = $config->get_string('data_href'); + $theme_name = $config->get_string('theme', 'default'); + $data_href = $config->get_string('data_href', './'); $contact_link = $config->get_string('contact_link'); - $version = $config->get_string('version'); + $version = "Shimmie-".VERSION; $header_html = ""; foreach($page->headers as $line) {