set_default
git-svn-id: file:///home/shish/svn/shimmie2/trunk@292 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
		
							parent
							
								
									dc23b3bdb4
								
							
						
					
					
						commit
						b4e93df363
					
				| @ -66,6 +66,11 @@ class Config { | |||||||
| 		$this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N'); | 		$this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N'); | ||||||
| 		$this->save($name); | 		$this->save($name); | ||||||
| 	} | 	} | ||||||
|  | 	public function set_default($name, $value) { | ||||||
|  | 		if(is_null($this->get($name))) { | ||||||
|  | 			$this->values[$name] = $value; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	public function get_int($name, $default=null) { | 	public function get_int($name, $default=null) { | ||||||
| 		// deprecated -- ints should be stored as ints now
 | 		// deprecated -- ints should be stored as ints now
 | ||||||
|  | |||||||
| @ -1,6 +1,4 @@ | |||||||
| <?php | <?php | ||||||
| define("TAG_LIST_LENGTH", 15); |  | ||||||
| define("TAGS_MIN", 3); |  | ||||||
| 
 | 
 | ||||||
| class TagList extends Extension { | class TagList extends Extension { | ||||||
| 	var $theme = null; | 	var $theme = null; | ||||||
| @ -9,6 +7,12 @@ class TagList extends Extension { | |||||||
| 	public function receive_event($event) { | 	public function receive_event($event) { | ||||||
| 		if($this->theme == null) $this->theme = get_theme_object("tag_list", "TagListTheme"); | 		if($this->theme == null) $this->theme = get_theme_object("tag_list", "TagListTheme"); | ||||||
| 		 | 		 | ||||||
|  | 		if(is_a($event, 'InitExtEvent')) { | ||||||
|  | 			global $config; | ||||||
|  | 			$config->set_default("tag_list_length", 15); | ||||||
|  | 			$config->set_default("tags_min", 3); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		if(is_a($event, 'PageRequestEvent') && ($event->page == "tags")) { | 		if(is_a($event, 'PageRequestEvent') && ($event->page == "tags")) { | ||||||
| 			global $page; | 			global $page; | ||||||
| 
 | 
 | ||||||
| @ -33,7 +37,7 @@ class TagList extends Extension { | |||||||
| 		if(is_a($event, 'PageRequestEvent') && ($event->page == "index")) { | 		if(is_a($event, 'PageRequestEvent') && ($event->page == "index")) { | ||||||
| 			global $config; | 			global $config; | ||||||
| 			global $page; | 			global $page; | ||||||
| 			if($config->get_int('tag_list_length', TAG_LIST_LENGTH) > 0) { | 			if($config->get_int('tag_list_length') > 0) { | ||||||
| 				if(isset($_GET['search'])) { | 				if(isset($_GET['search'])) { | ||||||
| 					$this->add_refine_block($page, tag_explode($_GET['search'])); | 					$this->add_refine_block($page, tag_explode($_GET['search'])); | ||||||
| 				} | 				} | ||||||
| @ -45,7 +49,7 @@ class TagList extends Extension { | |||||||
| 
 | 
 | ||||||
| 		if(is_a($event, 'DisplayingImageEvent')) { | 		if(is_a($event, 'DisplayingImageEvent')) { | ||||||
| 			global $config; | 			global $config; | ||||||
| 			if($config->get_int('tag_list_length', TAG_LIST_LENGTH) > 0) { | 			if($config->get_int('tag_list_length') > 0) { | ||||||
| 				$this->add_related_block($event->page, $event->image); | 				$this->add_related_block($event->page, $event->image); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @ -82,7 +86,7 @@ class TagList extends Extension { | |||||||
| 		global $database; | 		global $database; | ||||||
| 		global $config; | 		global $config; | ||||||
| 
 | 
 | ||||||
| 		$tags_min = $config->get_int('tags_min', TAGS_MIN); | 		$tags_min = $config->get_int('tags_min'); | ||||||
| 		$result = $database->Execute( | 		$result = $database->Execute( | ||||||
| 				"SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", | 				"SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", | ||||||
| 				array($tags_min)); | 				array($tags_min)); | ||||||
| @ -106,7 +110,7 @@ class TagList extends Extension { | |||||||
| 		global $database; | 		global $database; | ||||||
| 		global $config; | 		global $config; | ||||||
| 
 | 
 | ||||||
| 		$tags_min = $config->get_int('tags_min', TAGS_MIN); | 		$tags_min = $config->get_int('tags_min'); | ||||||
| 		$result = $database->Execute( | 		$result = $database->Execute( | ||||||
| 				"SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", | 				"SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", | ||||||
| 				array($tags_min)); | 				array($tags_min)); | ||||||
| @ -133,7 +137,7 @@ class TagList extends Extension { | |||||||
| 		global $database; | 		global $database; | ||||||
| 		global $config; | 		global $config; | ||||||
| 
 | 
 | ||||||
| 		$tags_min = $config->get_int('tags_min', TAGS_MIN); | 		$tags_min = $config->get_int('tags_min'); | ||||||
| 		$result = $database->Execute( | 		$result = $database->Execute( | ||||||
| 				"SELECT tag,count FROM tags WHERE count > ? ORDER BY count DESC, tag ASC", | 				"SELECT tag,count FROM tags WHERE count > ? ORDER BY count DESC, tag ASC", | ||||||
| 				array($tags_min) | 				array($tags_min) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user