diff --git a/core/config.class.php b/core/config.class.php index 913965d4..17c6c192 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -66,6 +66,11 @@ class Config { $this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N'); $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) { // deprecated -- ints should be stored as ints now diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index b4f17c4a..5cf35d44 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -1,6 +1,4 @@ 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")) { global $page; @@ -33,7 +37,7 @@ class TagList extends Extension { if(is_a($event, 'PageRequestEvent') && ($event->page == "index")) { global $config; 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'])) { $this->add_refine_block($page, tag_explode($_GET['search'])); } @@ -45,7 +49,7 @@ class TagList extends Extension { if(is_a($event, 'DisplayingImageEvent')) { 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); } } @@ -82,7 +86,7 @@ class TagList extends Extension { global $database; global $config; - $tags_min = $config->get_int('tags_min', TAGS_MIN); + $tags_min = $config->get_int('tags_min'); $result = $database->Execute( "SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", array($tags_min)); @@ -106,7 +110,7 @@ class TagList extends Extension { global $database; global $config; - $tags_min = $config->get_int('tags_min', TAGS_MIN); + $tags_min = $config->get_int('tags_min'); $result = $database->Execute( "SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", array($tags_min)); @@ -133,7 +137,7 @@ class TagList extends Extension { global $database; global $config; - $tags_min = $config->get_int('tags_min', TAGS_MIN); + $tags_min = $config->get_int('tags_min'); $result = $database->Execute( "SELECT tag,count FROM tags WHERE count > ? ORDER BY count DESC, tag ASC", array($tags_min)