summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-02-04 19:26:36 +0100
committerYorhel <git@yorhel.nl>2011-02-04 19:26:36 +0100
commit80d22665f3f4a99f60c4b808bb5dc97a1f8f6830 (patch)
treed28444b0d592bced999e3e424e1b71ab248796c7 /lib
parent9b8d7c719a722007839ec501b42070c2291f9e04 (diff)
Added category field to tags (content/ero/technical)
Not very useful at the moment, but will be used to improve several other things.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Tags.pm4
-rw-r--r--lib/VNDB/Handler/Tags.pm11
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm
index b7792eb8..51ab4b93 100644
--- a/lib/VNDB/DB/Tags.pm
+++ b/lib/VNDB/DB/Tags.pm
@@ -39,7 +39,7 @@ sub dbTagGet {
't.meta = ?' => $o{meta}?1:0 ) : (),
);
my @select = (
- qw|t.id t.meta t.name t.description t.state t.c_vns|,
+ qw|t.id t.meta t.name t.description t.state t.cat t.c_vns|,
q|extract('epoch' from t.added) as added|,
$o{what} =~ /addedby/ ? ('t.addedby', 'u.username') : (),
);
@@ -122,7 +122,7 @@ sub dbTagEdit {
$self->dbExec('UPDATE tags !H WHERE id = ?', {
$o{upddate} ? ('added = NOW()' => 1) : (),
- map { +"$_ = ?" => $o{$_} } qw|name meta description state|
+ map { +"$_ = ?" => $o{$_} } qw|name meta description state cat|
}, $id);
$self->dbExec('DELETE FROM tags_aliases WHERE tag = ?', $id);
$self->dbExec('INSERT INTO tags_aliases (tag, alias) VALUES (?, ?)', $id, $_) for (@{$o{aliases}});
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index 43137506..50c91455 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -94,6 +94,11 @@ sub tagpage {
lit bb2html $t->{description};
end;
}
+ p class => 'center';
+ b mt('_tagp_cat');
+ br;
+ txt mt("_tagcat_$t->{cat}");
+ end;
if(@{$t->{aliases}}) {
p class => 'center';
b mt('_tagp_aliases');
@@ -198,6 +203,7 @@ sub tagedit {
$frm = $self->formValidate(
{ post => 'name', required => 1, maxlength => 250, regex => [ qr/^[^,]+$/, 'A comma is not allowed in tag names' ] },
{ post => 'state', required => 0, default => 0, enum => [ 0..2 ] },
+ { post => 'cat', required => 1, enum => $self->{tag_categories} },
{ post => 'meta', required => 0, default => 0 },
{ post => 'alias', required => 0, maxlength => 1024, default => '', regex => [ qr/^[^,]+$/s, 'No comma allowed in aliases' ] },
{ post => 'description', required => 0, maxlength => 10240, default => '' },
@@ -225,6 +231,7 @@ sub tagedit {
my %opts = (
name => $frm->{name},
state => $frm->{state},
+ cat => $frm->{cat},
description => $frm->{description},
meta => $frm->{meta}?1:0,
aliases => \@aliases,
@@ -242,7 +249,7 @@ sub tagedit {
}
if($tag) {
- $frm->{$_} ||= $t->{$_} for (qw|name meta description state|);
+ $frm->{$_} ||= $t->{$_} for (qw|name meta description state cat|);
$frm->{alias} ||= join "\n", @{$t->{aliases}};
$frm->{parents} ||= join ', ', map $_->{name}, @{$t->{parents}};
}
@@ -274,6 +281,8 @@ sub tagedit {
$tag ?
[ static => content => mt '_tagedit_frm_meta_warn' ] : (),
) : (),
+ [ select => short => 'cat', name => mt('_tagedit_frm_cat'), options => [
+ map [$_, mt "_tagcat_$_"], @{$self->{tag_categories}} ] ],
[ textarea => short => 'alias', name => mt('_tagedit_frm_alias'), cols => 30, rows => 4 ],
[ textarea => short => 'description', name => mt '_tagedit_frm_desc' ],
[ static => content => mt '_tagedit_frm_desc_msg' ],