goodbye, global config defaults~
git-svn-id: file:///home/shish/svn/shimmie2/trunk@294 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
		
							parent
							
								
									da30c88776
								
							
						
					
					
						commit
						3084446c2e
					
				| @ -1,16 +1,6 @@ | |||||||
| <?php | <?php | ||||||
| class Config { | class Config { | ||||||
| 	var $values = array(); | 	var $values = array(); | ||||||
| 	var $defaults = array( |  | ||||||
| 			'title' => '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() { | 	public function Config() { | ||||||
| 		global $database; | 		global $database; | ||||||
| @ -74,20 +64,13 @@ class Config { | |||||||
| 	} | 	} | ||||||
| 	public function get_bool($name, $default=null) { | 	public function get_bool($name, $default=null) { | ||||||
| 		// deprecated -- bools should be stored as Y/N now
 | 		// deprecated -- bools should be stored as Y/N now
 | ||||||
| 		return ( | 		return ($this->get($name, $default) == 'Y' || $this->get($name, $default) == '1'); | ||||||
| 			$this->get($name, $default) == 'Y' || |  | ||||||
| 			$this->get($name, $default) == '1' || |  | ||||||
| 			$this->get($name, $default) === true |  | ||||||
| 			); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private function get($name, $default=null) { | 	private function get($name, $default=null) { | ||||||
| 		if(isset($this->values[$name])) { | 		if(isset($this->values[$name])) { | ||||||
| 			return $this->values[$name]; | 			return $this->values[$name]; | ||||||
| 		} | 		} | ||||||
| 		else if(isset($this->defaults[$name])) { |  | ||||||
| 			return $this->defaults[$name]; |  | ||||||
| 		} |  | ||||||
| 		else { | 		else { | ||||||
| 			return $default; | 			return $default; | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -92,22 +92,22 @@ class Image { | |||||||
| 
 | 
 | ||||||
| 	public function get_image_link() { | 	public function get_image_link() { | ||||||
| 		global $config; | 		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() { | 	public function get_short_link() { | ||||||
| 		global $config; | 		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() { | 	public function get_thumb_link() { | ||||||
| 		global $config; | 		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() { | 	public function get_tooltip() { | ||||||
| 		global $config; | 		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() { | 	public function get_image_filename() { | ||||||
|  | |||||||
| @ -92,7 +92,7 @@ function tag_explode($tags) { | |||||||
| 
 | 
 | ||||||
| function make_link($page, $query=null) { | function make_link($page, $query=null) { | ||||||
| 	global $config; | 	global $config; | ||||||
| 	$base = $config->get_string('base_href'); | 	$base = $config->get_string('base_href', './index.php?q='); | ||||||
| 
 | 
 | ||||||
| 	if(is_null($query)) { | 	if(is_null($query)) { | ||||||
| 		return "$base/$page"; | 		return "$base/$page"; | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ class LoadExtData extends Extension { | |||||||
| 		if(is_a($event, 'PageRequestEvent')) { | 		if(is_a($event, 'PageRequestEvent')) { | ||||||
| 			global $page, $config; | 			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) { | 			foreach(glob("ext/*/style.css") as $css_file) { | ||||||
| 				$page->add_header("<link rel='stylesheet' href='$data_href/$css_file' type='text/css'>"); | 				$page->add_header("<link rel='stylesheet' href='$data_href/$css_file' type='text/css'>"); | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ class Upgrade extends Extension { | |||||||
| 			$config->set_int("db_version", 2); | 			$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 (
 | 			$database->Execute("CREATE TABLE layout (
 | ||||||
| 				title varchar(64) primary key not null, | 				title varchar(64) primary key not null, | ||||||
| 				section varchar(32) not null default \"left\",
 | 				section varchar(32) not null default \"left\",
 | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| <?php | <?php | ||||||
| define("DEBUG", true); | define("DEBUG", true); | ||||||
|  | define("VERSION", '2.0.3-svn'); | ||||||
| 
 | 
 | ||||||
| if(DEBUG) { | if(DEBUG) { | ||||||
| 	error_reporting(E_ALL); | 	error_reporting(E_ALL); | ||||||
|  | |||||||
							
								
								
									
										28
									
								
								install.php
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								install.php
									
									
									
									
									
								
							| @ -482,10 +482,18 @@ function create_tables_mysql($db) { | |||||||
| 
 | 
 | ||||||
| 	$db->Execute("DROP TABLE IF EXISTS tags"); | 	$db->Execute("DROP TABLE IF EXISTS tags"); | ||||||
| 	$db->Execute("CREATE TABLE tags (
 | 	$db->Execute("CREATE TABLE tags (
 | ||||||
| 		image_id int(11) NOT NULL default '0', | 		id int not null auto_increment primary key, | ||||||
| 		tag varchar(255) NOT NULL default '', | 		tag varchar(64) not null unique, | ||||||
| 		UNIQUE KEY image_id (image_id,tag), | 		count int not null default 0, | ||||||
| 		KEY tags_tag (tag), | 		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) | 		KEY tags_image_id (image_id) | ||||||
| 	)");
 | 	)");
 | ||||||
| 
 | 
 | ||||||
| @ -502,7 +510,17 @@ function create_tables_mysql($db) { | |||||||
| 		UNIQUE (name) | 		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(); | 	return $db->CommitTrans(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,11 +3,10 @@ | |||||||
| class Layout { | class Layout { | ||||||
| 	function display_page($page) { | 	function display_page($page) { | ||||||
| 		global $config; | 		global $config; | ||||||
| 		$theme_name = $config->get_string('theme'); | 		$theme_name = $config->get_string('theme', 'default'); | ||||||
| 		$base_href = $config->get_string('base_href'); | 		$data_href = $config->get_string('data_href', './'); | ||||||
| 		$data_href = $config->get_string('data_href'); |  | ||||||
| 		$contact_link = $config->get_string('contact_link'); | 		$contact_link = $config->get_string('contact_link'); | ||||||
| 		$version = $config->get_string('version'); | 		$version = "Shimmie-".VERSION; | ||||||
| 
 | 
 | ||||||
| 		$header_html = ""; | 		$header_html = ""; | ||||||
| 		foreach($page->headers as $line) { | 		foreach($page->headers as $line) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user