1 package Memories::SystemTag;
3 use base qw(Memories::DBI Maypole::Model::CDBI::Plain);
4 __PACKAGE__->columns(Essential => qw/id name/);
5 __PACKAGE__->table("system_tag");
7 Memories::Photo->set_sql(sorted_by_system_tag => q/
8 SELECT photo.id as id, title, uploader, uploaded, x, y
9 FROM photo, system_tag, system_tagging
10 WHERE system_tagging.photo = photo.id
11 AND system_tagging.tag = system_tag.id
13 ORDER BY photo.uploaded DESC
19 my $page = $r->params->{page} || 1;
20 my $pager = Class::DBI::Pager::_pager("Memories::Photo",
21 Memories->config->{photos_per_page}, $page);
22 $r->{template_args}{pager} = $pager;
25 $tag = $self->search(name => $r->{args}->[0])->first;
27 $tag = $r->objects->[0]; # Should hardly happen
29 $r->{template_args}{tag} = $tag;
30 $r->{template_args}{tags} = [$tag]; # For selector
31 $r->{template_args}{photos} =
32 [$pager->search_sorted_by_system_tag($tag->id)];
36 package Memories::SystemTagging;
37 use base qw(Memories::DBI);
38 use Class::DBI::Pager;
39 __PACKAGE__->table("system_tagging");
40 __PACKAGE__->columns(TEMP => qw/count/);
41 __PACKAGE__->columns(Essential => qw/id tag photo/);
42 __PACKAGE__->set_sql(summary => qq/
43 SELECT id, system_tag, count(*) AS count
49 __PACKAGE__->set_sql(all => qq/
50 SELECT id, tag, count(*) AS count
55 Memories::SystemTagging->has_a("photo" => "Memories::Photo");
56 Memories::SystemTagging->has_a("tag" => "Memories::SystemTag");
58 Memories::Photo->has_many(system_tags => ["Memories::SystemTagging" => "system_tag"]);
59 Memories::Photo->has_many(system_taggings => "Memories::SystemTagging");
60 Memories::SystemTag->has_many(photos => ["Memories::SystemTagging" => "photo"] );
61 Memories::SystemTag->has_many(system_taggings => "Memories::SystemTagging");