get the tag initials from the database itself

This commit is contained in:
Shish 2011-12-25 22:34:20 +00:00
parent 8887ffe101
commit 082730f29a

View File

@ -132,13 +132,29 @@ class TagList implements Extension {
} }
private function build_az() { private function build_az() {
$alpha = "abcdefghijklmnopqrstuvwxyz"; global $database;
$tags_min = $this->get_tags_min();
$cache_key = "data/tag_inits-" . md5("tc" . $tags_min) . ".html";
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
$tag_data = $database->get_col("
SELECT DISTINCT
substr(tag, 1, 1)
FROM tags
WHERE count >= :tags_min
ORDER BY tag
", array("tags_min"=>$tags_min));
$html = ""; $html = "";
for($n=0; $n<strlen($alpha); $n++) { foreach($tag_data as $a) {
$a = $alpha[$n];
$html .= " <a href='".modify_current_url(array("starts_with"=>$a))."'>$a</a>"; $html .= " <a href='".modify_current_url(array("starts_with"=>$a))."'>$a</a>";
} }
$html .= "<p><hr>"; $html .= "<p><hr>";
if(SPEED_HAX) {file_put_contents($cache_key, $html);}
return $html; return $html;
} }
// }}} // }}}