From e9fedb570a3e5968c1afd518298715f8f8646d40 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 25 Dec 2011 16:59:13 +0000 Subject: [PATCH] PHP is shit. MySQL is also shit. --- ext/tag_list/main.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index fd2a1971..8284daa9 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -113,6 +113,15 @@ class TagList implements Extension { return $config->get_int('tags_min'); } } + + private function get_starts_with() { + if(isset($_GET['starts_with'])) { + return $_GET['starts_with']; + } + else { + return ""; + } + } // }}} // maps {{{ private function build_navigation() { @@ -129,7 +138,7 @@ class TagList implements Extension { global $database; $tags_min = $this->get_tags_min(); - $starts_with = @$_GET['starts_with'] || "a"; + $starts_with = $this->get_starts_with(); $cache_key = "data/tag_cloud-"+md5($tags_min + $starts_with)+".html"; if(file_exists($cache_key)) {return file_get_contents($cache_key);} @@ -139,9 +148,9 @@ class TagList implements Extension { FLOOR(LOG(2.7, LOG(2.7, count - :tags_min + 1)+1)*1.5*100)/100 AS scaled FROM tags WHERE count >= :tags_min - AND tag ILIKE :starts_with + AND tag LIKE :starts_with ORDER BY tag - ", array("tags_min"=>$tags_min, "starts_with"=>$starts_with+"%")); + ", array("tags_min"=>$tags_min, "starts_with"=>$starts_with)); $html = ""; foreach($tag_data as $row) { @@ -162,7 +171,7 @@ class TagList implements Extension { global $database; $tags_min = $this->get_tags_min(); - $starts_with = @$_GET['starts_with'] || "a"; + $starts_with = $this->get_starts_with(); $cache_key = "data/tag_alpha-"+md5($tags_min + $starts_with)+".html"; if(file_exists($cache_key)) {return file_get_contents($cache_key);} @@ -170,9 +179,9 @@ class TagList implements Extension { SELECT tag, count FROM tags WHERE count >= :tags_min - AND tag ILIKE :starts_with + AND tag LIKE :starts_with ORDER BY tag - ", array("tags_min"=>$tags_min, "starts_with"=>$starts_with+"%")); + ", array("tags_min"=>$tags_min, "starts_with"=>$starts_with)); $html = ""; $lastLetter = "";