From 8887ffe10121319fd8b4ad2d995fcaefb96d4d8b Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 25 Dec 2011 18:23:00 +0000 Subject: [PATCH] make paging optional --- ext/tag_list/main.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 50913674..b3a13f4b 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -19,6 +19,7 @@ class TagList implements Extension { $config->set_default_int("tags_min", 3); $config->set_default_string("info_link", 'http://en.wikipedia.org/wiki/$tag'); $config->set_default_string("tag_list_image_type", 'related'); + $config->set_default_bool("tag_list_pages", false); } if(($event instanceof PageRequestEvent) && $event->page_matches("tags")) { @@ -94,6 +95,7 @@ class TagList implements Extension { "Show related" => "related" ), "
Image tag list: "); $sb->add_bool_option("tag_list_numbers", "
Show tag counts: "); + $sb->add_bool_option("tag_list_pages", "
Paged tag lists: "); $event->panel->add_block($sb); } } @@ -115,13 +117,30 @@ class TagList implements Extension { } private function get_starts_with() { + global $config; if(isset($_GET['starts_with'])) { return $_GET['starts_with'] . "%"; } else { - return "%"; + if($config->get_bool("tag_list_pages")) { + return "a%"; + } + else { + return "%"; + } } } + + private function build_az() { + $alpha = "abcdefghijklmnopqrstuvwxyz"; + $html = ""; + for($n=0; $n$a))."'>$a"; + } + $html .= "


"; + return $html; + } // }}} // maps {{{ private function build_navigation() { @@ -130,12 +149,12 @@ class TagList implements Extension { $h_alphabetic = "Alphabetic"; $h_popularity = "Popularity"; $h_cats = "Categories"; - $h_all = "Show All"; + $h_all = "Show All"; return "$h_index
 
$h_map
$h_alphabetic
$h_popularity
$h_cats
 
$h_all"; } private function build_tag_map() { - global $database; + global $config, $database; $tags_min = $this->get_tags_min(); $starts_with = $this->get_starts_with(); @@ -153,6 +172,7 @@ class TagList implements Extension { ", array("tags_min"=>$tags_min, "starts_with"=>$starts_with)); $html = ""; + if($config->get_bool("tag_list_pages")) $html .= $this->build_az(); foreach($tag_data as $row) { $h_tag = html_escape($row['tag']); $size = sprintf("%.2f", (float)$row['scaled']); @@ -168,7 +188,7 @@ class TagList implements Extension { } private function build_tag_alphabetic() { - global $database; + global $config, $database; $tags_min = $this->get_tags_min(); $starts_with = $this->get_starts_with(); @@ -184,6 +204,7 @@ class TagList implements Extension { ", array("tags_min"=>$tags_min, "starts_with"=>$starts_with)); $html = ""; + if($config->get_bool("tag_list_pages")) $html .= $this->build_az(); $lastLetter = ""; foreach($tag_data as $row) { $h_tag = html_escape($row['tag']);