site/cgi-bin/modules/BSE/DB.pm
site/cgi-bin/modules/BSE/DB/Mysql.pm
site/cgi-bin/modules/BSE/DummyArticle.pm
+site/cgi-bin/modules/BSE/DummyProduct.pm
site/cgi-bin/modules/BSE/Dynamic/Article.pm
site/cgi-bin/modules/BSE/Dynamic/Catalog.pm
site/cgi-bin/modules/BSE/Dynamic/Product.pm
site/templates/admin/include/auditentry.tmpl
site/templates/admin/include/audithead.tmpl
site/templates/admin/include/edit_common.tmpl
+site/templates/admin/include/edit_metadata.tmpl
site/templates/admin/include/message.tmpl
site/templates/admin/include/oauditlog.tmpl
site/templates/admin/include/order_list_filter.tmpl
--- /dev/null
+package BSE::DummyProduct;
+use strict;
+use BSE::DummyArticle;
+our @ISA = qw(BSE::DummyArticle);
+use BSE::TB::Products;
+
+our $VERSION = "1.000";
+
+{
+ my %fields;
+ @fields{BSE::TB::Product->columns} = ();
+ delete @fields{BSE::TB::Article->columns};
+ for my $name (keys %fields) {
+ eval "sub $name { \$_[0]{$name} }";
+ }
+}
+
+
+sub prices {}
+
+1;
use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
use constant ARTICLE_CUSTOM_FIELDS_CFG => "article custom fields";
-our $VERSION = "1.053";
+our $VERSION = "1.054";
=head1 NAME
# only return the fields that are defined
$request->set_variable(custom => $custom);
$request->set_variable(errors => $errors || {});
+ my $article_type = $cfg->entry('level names', $article->{level}, 'Article');
+ $request->set_variable(article_type => $article_type);
return
(
article => sub { tag_article($article, $cfg, $_[0]) },
old => [ \&tag_old, $article, $cgi ],
default => [ \&tag_default, $self, $request, $article ],
- articleType => [ \&tag_art_type, $article->{level}, $cfg ],
+ articleType => escape_html($article_type),
parentType => [ \&tag_art_type, $article->{level}-1, $cfg ],
ifNew => [ \&tag_if_new, $article ],
list => [ \&tag_list, $self, $article, $articles, $cgi, $request ],
return;
}
+ return $self->_make_dummy_article(\%article);
+}
+
+sub _make_dummy_article {
+ my ($self, $article) = @_;
+
require BSE::DummyArticle;
- return bless \%article, "BSE::DummyArticle";
+ return bless $article, "BSE::DummyArticle";
}
sub add_form {
use BSE::Util::Tags qw(tag_hash tag_article);
use constant PRODUCT_CUSTOM_FIELDS_CFG => "product custom fields";
-our $VERSION = "1.015";
+our $VERSION = "1.016";
=head1 NAME
sub generator { 'BSE::Generate::Product' }
+sub _make_dummy_article {
+ my ($self, $article) = @_;
+
+ require BSE::DummyProduct;
+ return bless $article, "BSE::DummyProduct";
+}
+
sub base_template_dirs {
return ( "products" );
}
my @tiers;
my $price_tier;
my %prices;
+ $req->set_variable(product => $article);
return
(
product => [ \&tag_article, $article, $cfg ],
use BSE::Util::HTML;
use Carp qw(cluck confess);
-our $VERSION = "1.031";
+our $VERSION = "1.032";
=head1 NAME
($value) = $cgi->param($name);
require DevHelp::Date;
my $msg;
- my ($year, $month, $day) = DevHelp::Date::dh_parse_date($value, \$msg);
- $value = sprintf("%04d-%02d-%02d", $year, $month, $day);
+ if (my ($year, $month, $day) = DevHelp::Date::dh_parse_date($value, \$msg)) {
+ $value = sprintf("%04d-%02d-%02d", $year, $month, $day);
+ }
}
elsif ($field->{type} && $field->{type} eq "time" && !$opts{api}) {
($value) = $cgi->param($name);
+
<:wrap admin/base.tmpl title=>[cond [ifNew] [cat "New " [articleType]] [cat "Edit " [articleType] ": " [article title]]], js => "admin_edit.js":>
<h1><:ifNew:>New<:or:>Edit<:eif:> <:articleType:></h1>
<:if Message:>
</tr>
<:or Article:><:eif Article:>
</table>
-<:.set metas = [ article.metafields ] -:>
-<: .if metas.size -:>
-<fieldset>
- <legend>Article Metadata</legend>
-<input type="hidden" name="_save_meta" value="1">
-<: .for m in metas -:>
-<:#= bse.dumper(m) |raw :>
-<: .set name = "meta_" _ m.name -:>
-<: .set mdata = article.meta_by_name(m.name) -:>
-<: .if m.type eq 'image' -:>
-<: .set def = article.meta_by_name(m.display_name) -:>
-<: .set def = def ? def.value_text : "" -:>
-<: .else -:>
-<: .set def = mdata ? mdata.value_text : "" -:>
-<: .end if -:>
-<: .if m.ro -:>
-<: .call "inlinefieldro", name: name, field: m.field,
- options: { default: def } -:>
-<: .else -:>
-<: .call "inlinefield", name: name, field: m.field,
- options: { delete: 1, default: def } -:>
-<: .end if :>
-<: .end for -:>
-</fieldset>
-<: .end if -:>
+<:.call "admin/include/edit_metadata.tmpl", tr: 0 :>
<p><: ifNew :>
<input type="submit" name="save" value="Add New <: articleType:>" />
+<:.set article_type = "Product" -:>
<:wrap admin/base.tmpl title => [cond [ifNew] "Add Product" "Edit Product"], menuitem=>"edit", showtitle=>"1", js => "admin_edit.js" :>
<:ifMessage:>
<p><b><:message:></b></p>
<:or:><:eif:>
+<:.set oldf = @{name, def: cgi.param(name).defined ? cgi.param(name) : def} -:>
<:include admin/product_menu.tmpl:>
<:ifNew:><:or:><:if Or [iadminuser_count] [iadmingroup_count]:>
<form action="/cgi-bin/admin/adminusers.pl">
<tr>
<th><:cfg "product fields" retailPrice "Retail price":>:</th>
<td>$
- <:ifFieldPerm retailPrice:><input type="text" name="retailPrice" value="<:old retailPrice money default retailPrice:>" size="7" />
+ <:ifFieldPerm retailPrice:><input type="text" name="retailPrice" value="<:= oldf("retailPrice", bse.number("money", product.retailPrice)) :>" size="7" />
(0.00)<:or:><:money product retailPrice:><:eif:> </td>
<td class="help"><:help product retail:> <:error_img retailPrice:></td>
</tr>
</tr>
<tr><td colspan="3">*These fields cannot be modified once this product has been
included in an order.</td></tr>
+<:.call "admin/include/edit_metadata.tmpl", tr: 1:>
<:if UserCan edit_save:article:>
<tr>
<td colspan="3" class="buttons"><:ifNew:><input type="submit" name="save" value="Add Product" /><:or:><input type="submit" name="save" value="Update Product" /><:eif:>
</td></tr><:or UserCan:><:eif UserCan:>
</table>
</form>
+
--- /dev/null
+<:.set metas = [ article.metafields ] -:>
+<: .if metas.size -:>
+<:.if tr:>
+<tr><td colspan="3">
+<:.end if :>
+<fieldset>
+ <legend><:= article_type |html :> Metadata</legend>
+<input type="hidden" name="_save_meta" value="1">
+<: .for m in metas -:>
+<:#= bse.dumper(m) |raw :>
+<: .set name = "meta_" _ m.name -:>
+<: .set mdata = article.meta_by_name(m.name) -:>
+<: .if m.type eq 'image' -:>
+<: .set def = article.meta_by_name(m.display_name) -:>
+<: .set def = def ? def.value_text : "" -:>
+<: .else -:>
+<: .set def = mdata ? mdata.value_text : "" -:>
+<: .end if -:>
+<: .if m.ro -:>
+<: .call "inlinefieldro", name: name, field: m.field,
+ options: { default: def } -:>
+<: .else -:>
+<: .call "inlinefield", name: name, field: m.field,
+ options: { delete: 1, default: def } -:>
+<: .end if :>
+<: .end for -:>
+</fieldset>
+<:.if tr:>
+</td></tr>
+<:.end if :>
+<: .end if -:>
+