Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
get the tag initials from the database itself
  • Loading branch information
shish committed Dec 25, 2011
1 parent 8887ffe commit 082730f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ext/tag_list/main.php
Expand Up @@ -132,13 +132,29 @@ private function get_starts_with() {
}

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 = "";
for($n=0; $n<strlen($alpha); $n++) {
$a = $alpha[$n];
foreach($tag_data as $a) {
$html .= " <a href='".modify_current_url(array("starts_with"=>$a))."'>$a</a>";
}
$html .= "<p><hr>";

if(SPEED_HAX) {file_put_contents($cache_key, $html);}

return $html;
}
// }}}
Expand Down

0 comments on commit 082730f

Please sign in to comment.