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:
shish
2007-07-05 21:30:37 +00:00
parent 9d6becdb6c
commit b6809c3b0a
11 changed files with 75 additions and 34 deletions

View File

@@ -12,7 +12,7 @@ class AddAliasEvent extends Event {
class AliasEditor extends Extension {
var $theme;
// event handler {{{
public function receive_event($event) {
if(is_null($this->theme)) $this->theme = get_theme_object("alias_editor", "AliasEditorTheme");
@@ -65,7 +65,6 @@ class AliasEditor extends Extension {
}
}
}
// }}}
}
add_event_listener(new AliasEditor());
?>

View File

@@ -45,6 +45,7 @@ class ET extends Extension {
$info['stat_comments'] = $database->db->GetOne("SELECT COUNT(*) FROM comments");
$info['stat_users'] = $database->db->GetOne("SELECT COUNT(*) FROM users");
$info['stat_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM tags");
$info['stat_image_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM image_tags");
$els = array();
foreach($_event_listeners as $el) {

View File

@@ -30,6 +30,7 @@ Images: {$info['stat_images']}
Comments: {$info['stat_comments']}
Users: {$info['stat_users']}
Tags: {$info['stat_tags']}
Applications: {$info['stat_image_tags']}
EOD;
$html = <<<EOD
<form action='http://shimmie.shishnet.org/register.php' method='POST'>

View File

@@ -89,7 +89,7 @@ class TagList extends Extension {
$tags_min = $config->get_int('tags_min');
$result = $database->Execute(
"SELECT tag,COUNT(image_id) AS count FROM tags GROUP BY tag HAVING count > ? ORDER BY tag",
"SELECT tag,count FROM tags WHERE count > ? ORDER BY tag",
array($tags_min));
$html = "";
@@ -113,7 +113,7 @@ class TagList extends Extension {
$tags_min = $config->get_int('tags_min');
$result = $database->Execute(
"SELECT tag,COUNT(image_id) AS count FROM tags GROUP BY tag HAVING count > ? ORDER BY tag",
"SELECT tag,count FROM tags WHERE count > ? ORDER BY tag",
array($tags_min));
$html = "";
@@ -140,7 +140,7 @@ class TagList extends Extension {
$tags_min = $config->get_int('tags_min');
$result = $database->Execute(
"SELECT tag,COUNT(image_id) AS count FROM tags GROUP BY tag HAVING count > ? ORDER BY count DESC, tag ASC",
"SELECT tag,count FROM tags WHERE count > ? ORDER BY count DESC, tag ASC",
array($tags_min)
);
@@ -168,19 +168,23 @@ class TagList extends Extension {
global $config;
$query = "
SELECT COUNT(t3.image_id) as count, t3.tag
SELECT COUNT(it3.image_id) as count, t3.tag
FROM
image_tags AS it1,
image_tags AS it2,
image_tags AS it3,
tags AS t1,
tags AS t2,
tags AS t3
tags AS t3
WHERE
t1.image_id=?
AND t1.tag=t2.tag
AND t2.image_id=t3.image_id
it1.image_id=?
AND it1.tag_id=it2.tag_id
AND it2.image_id=it3.image_id
AND t1.tag != 'tagme'
AND t3.tag != 'tagme'
GROUP by t3.tag
ORDER by count DESC
AND t1.id = it1.tag_id
AND t3.id = it3.tag_id
GROUP BY it3.tag_id
ORDER BY count DESC
LIMIT ?
";
$args = array($image->id, $config->get_int('tag_list_length'));
@@ -196,9 +200,8 @@ class TagList extends Extension {
global $config;
$query = "
SELECT tag, COUNT(image_id) AS count
SELECT tag, count
FROM tags
GROUP BY tag
ORDER BY count DESC
LIMIT ?
";
@@ -219,13 +222,17 @@ class TagList extends Extension {
$s_tag_list = join(',', $s_tags);
$query = "
SELECT t2.tag, COUNT(t2.image_id) AS count
SELECT t2.tag, COUNT(it2.image_id) AS count
FROM
image_tags AS it1,
image_tags AS it2,
tags AS t1,
tags AS t2
WHERE
t1.tag IN($s_tag_list)
AND t1.image_id=t2.image_id
AND it1.image_id=it2.image_id
AND it1.tag_id = t1.id
AND it2.tag_id = t2.id
GROUP BY t2.tag
ORDER BY count
DESC LIMIT ?
@@ -233,6 +240,7 @@ class TagList extends Extension {
$args = array($config->get_int('tag_list_length'));
$tags = $database->db->GetAll($query, $args);
print $database->db->ErrorMsg();
if(count($tags) > 0) {
$this->theme->display_refine_block($page, $tags, $search);
}