tags(image_id,tag) split into image_tags(image_id,tag_id) and tags(id,tag,count)
git-svn-id: file:///home/shish/svn/shimmie2/trunk@227 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class AutoComplete extends Extension {
|
||||
// event handling {{{
|
||||
public function receive_event($event) {
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page == "index" || $event->page == "view")) {
|
||||
global $page;
|
||||
@ -14,14 +13,12 @@ class AutoComplete extends Extension {
|
||||
$page->set_data($this->get_completions($event->get_arg(0)));
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
// do things {{{
|
||||
|
||||
private function get_completions($start) {
|
||||
global $database;
|
||||
$tags = $database->db->GetCol("SELECT tag,count(image_id) AS count FROM tags WHERE tag LIKE ? GROUP BY tag ORDER BY count DESC", array($start.'%'));
|
||||
$tags = $database->db->GetCol("SELECT tag,count FROM tags WHERE tag LIKE ? ORDER BY count DESC", array($start.'%'));
|
||||
return implode("\n", $tags);
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
add_event_listener(new AutoComplete());
|
||||
?>
|
||||
|
Reference in New Issue
Block a user