-- alias used to generate links
linkAlias varchar(255) not null default '',
+
+ category varchar(40) not null default '',
PRIMARY KEY (id),
@ISA = qw/Squirrel::Row BSE::TB::SiteCommon BSE::TB::TagOwner/;
use Carp 'confess';
-our $VERSION = "1.005";
+our $VERSION = "1.006";
sub columns {
return qw/id parentid displayOrder title titleImage body
customInt1 customInt2 customInt3 customInt4
lastModifiedBy created createdBy author pageTitle
force_dynamic cached_dynamic inherit_siteuser_rights
- metaDescription metaKeywords summary menu titleAlias linkAlias/;
+ metaDescription metaKeywords summary menu titleAlias linkAlias
+ category/;
}
sub table {
@ISA = qw(Squirrel::Table BSE::TB::TagOwners);
use Article;
-our $VERSION = "1.002";
+our $VERSION = "1.003";
sub rowClass {
return 'Article';
);
}
+sub categories {
+ my $cfg = BSE::Cfg->single;
+
+ my @cat_ids = split /,/, $cfg->entry("article categories", "ids", "");
+ grep $_ eq "", @cat_ids
+ or unshift @cat_ids, "";
+
+ my @cats;
+ for my $id (@cat_ids) {
+ my $section = length $id ? "article category $id" : "article category empty";
+ my $def_name = length $id ? ucfirst $id : "(None)";
+ my $name = $cfg->entry($section, "name",
+ $cfg->entry("article categories", $id, $def_name));
+ push @cats, +{ id => $id, name => $name };
+ }
+
+ return @cats;
+}
+
1;
use Carp 'confess';
@ISA = qw(BSE::DB);
-our $VERSION = "1.004";
+our $VERSION = "1.005";
use vars qw($VERSION $MAX_CONNECTION_AGE);
# don't ever load the entire articles table
#Articles => 'select * from article',
replaceArticle =>
- 'replace article values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
+ 'replace article values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
addArticle =>
- 'insert article values (null, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
+ 'insert article values (null, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
deleteArticle => 'delete from article where id = ?',
getArticleByPkey => 'select * from article where id = ?',
use BSE::Template;
use BSE::Util::ContentType qw(content_type);
use DevHelp::Date qw(dh_parse_date dh_parse_sql_date);
+use List::Util qw(first);
use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
-our $VERSION = "1.009";
+our $VERSION = "1.010";
=head1 NAME
@templates;
}
+sub categories {
+ my ($self, $articles) = @_;
+
+ return $articles->categories;
+}
+
sub edit_parent {
my ($article) = @_;
return make_arrows($req->cfg, $down_url, $up_url, $refresh_url, $img_prefix);
}
+sub tag_category {
+ my ($self, $articles, $article) = @_;
+
+ my @cats = $self->categories($articles);
+
+ my %labels = map { $_->{id}, $_->{name} } @cats;
+
+ return popup_menu(-name => 'category',
+ -values => [ map $_->{id}, @cats ],
+ -labels => \%labels,
+ -default => $article->{category});
+}
+
sub tag_edit_link {
my ($cfg, $article, $args, $acts, $funcname, $templater) = @_;
my ($which, $name) = split / /, $args, 2;
$it->make_iterator([ iter_file_stores => $self],
'file_store', 'file_stores'),
ifGroupRequired => [ \&tag_ifGroupRequired, $article, \$current_group ],
+ category => [ tag_category => $self, $articles, $article ],
$ito->make
(
single => "tag",
$errors->{linkAlias} = "Link alias must contain only alphanumerics and contain at least one letter";
}
}
+
+ if (defined $data->{category}) {
+ unless (first { $_->{id} eq $data->{category} } $self->categories($articles)) {
+ $errors->{category} = "msg:bse/admin/edit/category/unknown";
+ }
+ }
}
sub validate {
# end adrian
$self->fill_new_data($req, \%data, $articles);
- for my $col (qw(titleImage imagePos template keyword menu titleAlias linkAlias body author summary)) {
+ for my $col (qw(titleImage imagePos template keyword menu titleAlias linkAlias body author summary category)) {
defined $data{$col}
or $data{$col} = $self->default_value($req, \%data, $col);
}
linkAlias => '',
author => '',
summary => '',
+ category => '',
);
sub default_value {
id: bse/admin/edit/tags/nochange
description: name field error if no change is saved
+id: bse/admin/edit/category
+description: Category field errors
+
+id: bse/admin/edit/category/unknown
+description: if an unknown article category is received
+
id: bse/admin/shop/
description: Shop Administration
id: bse/admin/edit/tags/nochange
message: No changes to save
+id: bse/admin/edit/category/unknown
+message: Unknown article category
+
id: bse/admin/message/noid
message: Missing id parameter
Replacement is performed case-insenitively. Regexp metacharacters
+=head2 [article categories]
+
+=over
+
+=item *
+
+ids - a comma separated list of category ids. There are (currently)
+no restrictions on the contents of these ids, but alphanumerics are
+recommended to simplify templates.
+
+=item *
+
+I<id> - a description for a particular category id. Overridden by the
+C<name> key in C<< [article category I<id>] >>. Default: ucfirst of
+the id.
+
+=back
+
+=head2 [article category I<id>]
+
+=over
+
+=item *
+
+name - name of the article category.
+
+=back
+
+Other keys may be used as desired, eg. to make it simpler to configure
+article behaviour based on the category.
+
=head1 AUTHOR
Tony Cook <tony@develop-help.com>
</div>
+<div>
+<h2><a name="keywords"></a>Category</h2>
+
+ <p>This indicates the type of use that an article is intended for.
+ The possible values and the results will depend on your local
+ configuration.</p>
+
+</div>
+
<div>
<h2><a name="listed"></a>List article</h2>
</div>
-</body></html>
\ No newline at end of file
+</body></html>
<:or:><:ifArticle force_dynamic :>Yes<:or Article:>No<:eif Article:><:eif:></td>
<td class="help"><:help edit keywords:> <:error_img keyword:></td>
</tr>
+ <tr>
+ <th>Category:</th>
+ <td>
+ <:if FieldPerm category:><:category:><:or FieldPerm:><: article category :><:eif FieldPerm:></td>
+ <td class="help"><:help edit category:> <:error_img category:></td>
+ </tr>
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
# the invisible subsection for what's hot
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
id=>3,
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
id=>4,
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
id=>5,
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
id=>6,
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
id=>7,
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
{
id=>8,
summary => '',
menu => 0,
titleAlias => '',
+ category => '',
},
);
Column menu;smallint(5);NO;0;
Column titleAlias;varchar(60);NO;;
Column linkAlias;varchar(255);NO;;
+Column category;varchar(40);NO;;
Index PRIMARY;1;[id]
Index article_alias;0;[linkAlias]
Index article_date_index;0;[release;expire;id]
my @cols = Article->columns;
-my $base = 113;
+my $base = 119;
my $count = $base + (@cols - 13) * 4;
}
}
+ { # try to set a bad value for category
+ my %req_data =
+ (
+ save => 1,
+ id => $art->{id},
+ category => "A" . rand(),
+ lastModified => $art->{lastModified},
+ );
+ my $data = do_req($add_url, \%req_data, "save bad category");
+ SKIP:
+ {
+ $data or skip("Not json from setting bad category", 4);
+ ok(!$data->{success}, "shouldn't be successful");
+ ok(!$data->{article}, "should be no article object");
+ is($data->{error_code}, "FIELD", "should be a field error");
+ ok($data->{errors} && $data->{errors}{category},
+ "should be an error message for category");
+ }
+ }
+
my $tag_name1 = "YHUIOP";
my $tag_name2 = "zyx: alpha";
{ # save tags