]> git.imager.perl.org - bse.git/commitdiff
move product module into bse module dir
authorAdrian Oldham <adriann@visualthought.com.au>
Sat, 30 Aug 2014 01:54:42 +0000 (11:54 +1000)
committerAdrian Oldham <adriann@visualthought.com.au>
Mon, 1 Sep 2014 09:33:01 +0000 (19:33 +1000)
14 files changed:
MANIFEST
site/cgi-bin/modules/BSE/API.pm
site/cgi-bin/modules/BSE/Cart.pm
site/cgi-bin/modules/BSE/Edit/Product.pm
site/cgi-bin/modules/BSE/Generate/Article.pm
site/cgi-bin/modules/BSE/Generate/Product.pm [new file with mode: 0644]
site/cgi-bin/modules/BSE/Generate/Seminar.pm
site/cgi-bin/modules/BSE/Permissions.pm
site/cgi-bin/modules/BSE/UI/AdminShop.pm
site/cgi-bin/modules/Generate/Catalog.pm
site/cgi-bin/modules/Generate/Product.pm [deleted file]
site/data/db/sql_statements.data
site/docs/.gitignore
site/docs/makedocs

index 47cdfd27a630e17ba92ffd287c038b38f0ab28ad..27270479f610af15ed237d7d6447e18993b9bd3e 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -345,7 +345,7 @@ site/cgi-bin/modules/DevHelp/Validate.pm
 site/cgi-bin/modules/Generate.pm
 site/cgi-bin/modules/BSE/Generate/Article.pm
 site/cgi-bin/modules/Generate/Catalog.pm
-site/cgi-bin/modules/Generate/Product.pm
+site/cgi-bin/modules/BSE/Generate/Product.pm
 site/cgi-bin/modules/Generate/Subscription.pm
 site/cgi-bin/modules/OtherParent.pm
 site/cgi-bin/modules/OtherParents.pm
index 1f156933daacfb1f2b88649db36809ba9709b50c..0f177000d8d95faf8455474ca4bc592fb7268237 100644 (file)
@@ -82,7 +82,7 @@ my %product_defaults =
   (
    template => 'shopitem.tmpl',
    parentid => 4,
-   generator => 'Generate::Product',
+   generator => 'BSE::Generate::Product',
    wholesalePrice => 0,
    gst => 0,
    leadTime => 0,
index b780c9cc0a9dba5ef49a5fd7e6aa0ecd59fbe421..fc2ef21bfac6e0adc04ec6a3bd262b51634a78c8 100644 (file)
@@ -727,7 +727,7 @@ sub _product {
     $product = Products->getByPkey($id)
       or die "No product $id\n";
     # FIXME
-    if ($product->generator ne "Generate::Product") {
+    if ($product->generator ne "BSE::Generate::Product") {
       require BSE::TB::Seminars;
       $product = BSE::TB::Seminars->getByPkey($id)
        or die "Not a product, not a seminar $id\n";
index b7cde4e192423f4958c620a3afb00417b70a2110..1ffeccb482e404ab10c28d9f93556a7180e18d29 100644 (file)
@@ -33,7 +33,7 @@ my %money_fields =
    gst => "GST",
   );
 
-sub generator { 'Generate::Product' }
+sub generator { 'BSE::Generate::Product' }
 
 sub base_template_dirs {
   return ( "products" );
index e7da607c88fb7071a05b414ee0df07b4e687a0f6..acb3df444657e5876694d7042f0511d3bd4e5049 100644 (file)
@@ -1232,7 +1232,7 @@ See the summary tag.
 =item generator
 
 The class used to generate the article.  Should be one of
-BSE::Generate::Article, Generate::Catalog or Generate::Product.
+BSE::Generate::Article, Generate::Catalog or BSE::Generate::Product.
 
 =item level
 
diff --git a/site/cgi-bin/modules/BSE/Generate/Product.pm b/site/cgi-bin/modules/BSE/Generate/Product.pm
new file mode 100644 (file)
index 0000000..38ce005
--- /dev/null
@@ -0,0 +1,201 @@
+package BSE::Generate::Product;
+use strict;
+use BSE::Generate::Article;
+use Products;
+use BSE::TB::Images;
+use base qw(BSE::Generate::Article);
+use Constants qw(:shop $CGI_URI $ADMIN_URI);
+use Carp qw(confess);
+use BSE::Util::HTML;
+use BSE::Util::Tags qw(tag_article);
+
+our $VERSION = "1.001";
+
+sub edit_link {
+  my ($self, $id) = @_;
+  return "/cgi-bin/admin/add.pl?id=$id";
+}
+
+sub generate {
+  my ($self, $article, $articles) = @_;
+
+  my $product = Products->getByPkey($article->{id});
+  return $self->SUPER::generate($product, $articles);
+}
+
+sub _default_admin {
+  my ($self, $product, $embedded) = @_;
+
+       my $html = <<HTML;
+<table>
+<tr>
+<td><form action="$CGI_URI/admin/add.pl">
+<input type=hidden name="edit" value=1>
+<input type=hidden name=id value=$product->{id}>
+<input type=submit value="Edit Product"></form></td>
+<td><form action="$ADMIN_URI">
+<input type=submit value="Admin menu">
+</form></td>
+<td><form action="$CGI_URI/admin/admin.pl" target="_blank">
+<input type=submit value="Display">
+<input type=hidden name=admin value=0>
+<input type=hidden name=id value="$product->{id}"></form></td>
+</tr>
+</table>
+HTML
+}
+
+sub baseActs {
+  my ($self, $articles, $acts, $product, $embedded) = @_;
+
+  unless ($product->isa('Product')) {
+    $product = Products->getByPkey($product->{id});
+  }
+
+  my @stepcats = $product->step_parents();
+  my $stepcat_index;
+  my @options = $product->option_descs($self->{cfg});
+  my $option_index;
+
+  return
+    (
+     $self->SUPER::baseActs($articles, $acts, $product, $embedded),
+     product=> [ \&tag_article, $product, $self->{cfg} ],
+     admin => [ tag_admin => $self, $product, 'product', $embedded ],
+     iterate_options_reset => sub { $option_index = -1 },
+     iterate_options => sub { ++$option_index < @options },
+     option => 
+     sub {
+       if ($_[0] eq 'popup') {
+        my $option = $options[$option_index];
+        my @args =
+          (
+           -name      => $option->{id},
+           -id        => $option->{id},
+           -values    => $option->{values},
+           -override  => 1,
+          );
+        push(@args, -labels=>$option->{labels}) if $option->{labels};
+        push(@args, -default=>$option->{default}) if $option->{default};
+        return BSE::Util::HTML::popup_menu(@args);
+       }
+       else {
+        return escape_html($options[$option_index]{$_[0]})
+       }
+     },
+     ifOptions => sub { @options },
+     iterate_stepcats_reset => sub { $stepcat_index = -1 },
+     iterate_stepcats => sub { ++$stepcat_index < @stepcats },
+     stepcat => sub { tag_article($stepcats[$stepcat_index], $self->{cfg}, $_[0]) },
+     ifStepCats => sub { @stepcats },
+    );
+}
+
+sub visible {
+  my ($self, $article) = @_;
+  return $article->{listed};
+}
+
+sub get_real_article {
+  my ($self, $article) = @_;
+
+  return Products->getByPkey($article->{id});
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+  BSE::Generate::Product - generates product detail pages for BSE
+
+=head1 DESCRIPTION
+
+Like the NAME says.
+
+=head1 TAGS
+
+=over 4
+
+=item product I<field>
+
+Access to product fields of the product being rendered.  This is the
+same as the C<article> I<field> tag for normal articles, but also give
+you access to the product fields.
+
+=item admin
+
+Produces product specific administration links in admin mode.
+
+=item iterator ... options
+
+Iterates over the options available for the product, setting the option tag.
+
+=item option popup
+
+The popup list of values for the current option.
+
+=item option field
+
+Retrieves the given field from the option.  Most commonly you just
+want the desc field.
+
+  <:if Options:>
+  <!-- you might want to start a table here -->
+  <:iterator begin options:>
+  <:option desc:>: <:option popup:>
+  <:iterator end options:>
+  <!-- and end a table here -->
+  <:or Options:><:eif Options:>
+
+=item iterator ... stepcats
+
+Iterates over any step parents of the product, setting the I<stepcat>
+for each element.
+
+=item stepcat I<field>
+
+Access to fields of the step catalogs of the parent.
+
+=item ifStepCats
+
+Conditional tag, true if the product has any step catalogs.
+
+=back
+
+=head2 Product specific fields
+
+=over 4
+
+=item summary
+
+An in-between length description of the article for use on the catalog
+page.
+
+=item leadTime
+
+The number of days it takes to receive the product after it has been
+ordered.
+
+=item retailPrice
+
+The cost to the customer of the product.  You need to use the C<money>
+tag to format this field for display.
+
+=item wholesalePrice
+
+Your cost.  You need to use the C<money> tag to format this field for
+display.
+
+=item gst
+
+The GST (in Australia) payable on the product.
+
+=item options
+
+The raw version of the options that can be set for this product.
+
+=back
+
+=cut
index 34fb7111460c75828d186e9a2d5e58c6557de2f3..2c571b830f790b7405c08c665f46a22aeb0f72e5 100644 (file)
@@ -1,6 +1,6 @@
 package BSE::Generate::Seminar;
 use strict;
-use base 'Generate::Product';
+use base 'BSE::Generate::Product';
 use BSE::TB::Seminars;
 use BSE::Util::HTML;
 use BSE::Util::Tags qw(tag_article);
index 04fa8bb2c591cbce9779885ef4145c4abfe57d5d..b01e554d459962ac264f130915fb2f5f54b9d118 100644 (file)
@@ -416,7 +416,7 @@ sub check_edit_delete_article {
 sub check_edit_add_child {
   my ($self, $user, $article, $action, $rmsg) = @_;
 
-  if ($article->{generator} eq 'Generate::Product') {
+  if ($article->{generator} eq 'BSE::Generate::Product') {
     $$rmsg = "Products cannot have children";
     return;
   }
index 00ba85fe495f9eb50be52ddd57182fbf5747e3e3..0258c8a54fb19fecff63dc6148c30a59b7f80762 100644 (file)
@@ -91,7 +91,7 @@ sub embedded_catalog {
       (my $file = $gen . ".pm") =~ s!::!/!g;
       require $file;
     }
-    @list = grep UNIVERSAL::isa($_->{generator}, 'Generate::Product'), $catalog->allkids;
+    @list = grep UNIVERSAL::isa($_->{generator}, 'BSE::Generate::Product'), $catalog->allkids;
     @list = map { $products->getByPkey($_->{id}) } @list;
   }
   else {
index f7b1a55cfe4ea4ee898600becb0e4de523a267a0..15ae4bd3ec6a409662ddbf27cf00a8d0e1580720 100644 (file)
@@ -136,7 +136,7 @@ sub baseActs {
     (my $file = $gen . ".pm") =~ s!::!/!g;
     require $file;
   }
-  my @allprods = grep UNIVERSAL::isa($_->{generator}, 'Generate::Product'), 
+  my @allprods = grep UNIVERSAL::isa($_->{generator}, 'BSE::Generate::Product'), 
     @allkids;
   for (@allprods) {
     unless ($_->isa('Product')) {
diff --git a/site/cgi-bin/modules/Generate/Product.pm b/site/cgi-bin/modules/Generate/Product.pm
deleted file mode 100644 (file)
index fea38ba..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-package Generate::Product;
-use strict;
-use BSE::Generate::Article;
-use Products;
-use BSE::TB::Images;
-use base qw(BSE::Generate::Article);
-use Constants qw(:shop $CGI_URI $ADMIN_URI);
-use Carp qw(confess);
-use BSE::Util::HTML;
-use BSE::Util::Tags qw(tag_article);
-
-our $VERSION = "1.001";
-
-sub edit_link {
-  my ($self, $id) = @_;
-  return "/cgi-bin/admin/add.pl?id=$id";
-}
-
-sub generate {
-  my ($self, $article, $articles) = @_;
-
-  my $product = Products->getByPkey($article->{id});
-  return $self->SUPER::generate($product, $articles);
-}
-
-sub _default_admin {
-  my ($self, $product, $embedded) = @_;
-
-       my $html = <<HTML;
-<table>
-<tr>
-<td><form action="$CGI_URI/admin/add.pl">
-<input type=hidden name="edit" value=1>
-<input type=hidden name=id value=$product->{id}>
-<input type=submit value="Edit Product"></form></td>
-<td><form action="$ADMIN_URI">
-<input type=submit value="Admin menu">
-</form></td>
-<td><form action="$CGI_URI/admin/admin.pl" target="_blank">
-<input type=submit value="Display">
-<input type=hidden name=admin value=0>
-<input type=hidden name=id value="$product->{id}"></form></td>
-</tr>
-</table>
-HTML
-}
-
-sub baseActs {
-  my ($self, $articles, $acts, $product, $embedded) = @_;
-
-  unless ($product->isa('Product')) {
-    $product = Products->getByPkey($product->{id});
-  }
-
-  my @stepcats = $product->step_parents();
-  my $stepcat_index;
-  my @options = $product->option_descs($self->{cfg});
-  my $option_index;
-
-  return
-    (
-     $self->SUPER::baseActs($articles, $acts, $product, $embedded),
-     product=> [ \&tag_article, $product, $self->{cfg} ],
-     admin => [ tag_admin => $self, $product, 'product', $embedded ],
-     iterate_options_reset => sub { $option_index = -1 },
-     iterate_options => sub { ++$option_index < @options },
-     option => 
-     sub {
-       if ($_[0] eq 'popup') {
-        my $option = $options[$option_index];
-        my @args =
-          (
-           -name      => $option->{id},
-           -id        => $option->{id},
-           -values    => $option->{values},
-           -override  => 1,
-          );
-        push(@args, -labels=>$option->{labels}) if $option->{labels};
-        push(@args, -default=>$option->{default}) if $option->{default};
-        return BSE::Util::HTML::popup_menu(@args);
-       }
-       else {
-        return escape_html($options[$option_index]{$_[0]})
-       }
-     },
-     ifOptions => sub { @options },
-     iterate_stepcats_reset => sub { $stepcat_index = -1 },
-     iterate_stepcats => sub { ++$stepcat_index < @stepcats },
-     stepcat => sub { tag_article($stepcats[$stepcat_index], $self->{cfg}, $_[0]) },
-     ifStepCats => sub { @stepcats },
-    );
-}
-
-sub visible {
-  my ($self, $article) = @_;
-  return $article->{listed};
-}
-
-sub get_real_article {
-  my ($self, $article) = @_;
-
-  return Products->getByPkey($article->{id});
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-  Generate::Product - generates product detail pages for BSE
-
-=head1 DESCRIPTION
-
-Like the NAME says.
-
-=head1 TAGS
-
-=over 4
-
-=item product I<field>
-
-Access to product fields of the product being rendered.  This is the
-same as the C<article> I<field> tag for normal articles, but also give
-you access to the product fields.
-
-=item admin
-
-Produces product specific administration links in admin mode.
-
-=item iterator ... options
-
-Iterates over the options available for the product, setting the option tag.
-
-=item option popup
-
-The popup list of values for the current option.
-
-=item option field
-
-Retrieves the given field from the option.  Most commonly you just
-want the desc field.
-
-  <:if Options:>
-  <!-- you might want to start a table here -->
-  <:iterator begin options:>
-  <:option desc:>: <:option popup:>
-  <:iterator end options:>
-  <!-- and end a table here -->
-  <:or Options:><:eif Options:>
-
-=item iterator ... stepcats
-
-Iterates over any step parents of the product, setting the I<stepcat>
-for each element.
-
-=item stepcat I<field>
-
-Access to fields of the step catalogs of the parent.
-
-=item ifStepCats
-
-Conditional tag, true if the product has any step catalogs.
-
-=back
-
-=head2 Product specific fields
-
-=over 4
-
-=item summary
-
-An in-between length description of the article for use on the catalog
-page.
-
-=item leadTime
-
-The number of days it takes to receive the product after it has been
-ordered.
-
-=item retailPrice
-
-The cost to the customer of the product.  You need to use the C<money>
-tag to format this field for display.
-
-=item wholesalePrice
-
-Your cost.  You need to use the C<money> tag to format this field for
-display.
-
-=item gst
-
-The GST (in Australia) payable on the product.
-
-=item options
-
-The raw version of the options that can be set for this product.
-
-=back
-
-=cut
index d6befef3a4b85718242e00f9a87ba4aa0b545846..9a80e357272ed4c91b1c68383749cf91f64e42a7 100644 (file)
@@ -525,13 +525,13 @@ where owner_type = 'BA'
      from article
      where parentid = ? 
        and listed != 0
-       and generator = 'Generate::Product'
+       and generator = 'BSE::Generate::Product'
   union
    select op.childId
      from other_parents op, article a
       where op.parentId = ?
         and op.childId = a.id
-        and a.generator = 'Generate::Product'
+        and a.generator = 'BSE::Generate::Product'
    )
 SQL
 
@@ -546,14 +546,14 @@ where t.id = m.tag_id
      from article
      where parentid = ? 
        and listed <> 0
-       and generator = 'Generate::Product'
+       and generator = 'BSE::Generate::Product'
   union
    select op.childId
      from other_parents op, article a
       where op.parentId = ?
         and op.childId = a.id
        and a.listed <> 0
-        and a.generator = 'Generate::Product')
+        and a.generator = 'BSE::Generate::Product')
 SQL
 
 name: TagMembers.allkids
index 0d565e27732b179739c589c67c0d9e127b9e6a62..c5a419cf81af008697724e6f74ddabdb22d92de8 100644 (file)
@@ -6,7 +6,7 @@
 /Generate.html
 /BSE::Generate::Article.html
 /Generate::Catalog.html
-/Generate::Product.html
+/BSE::Generate::Product.html
 /Squirrel::Template.html
 /Squirrel::Template::Expr.html
 /Squirrel::Template::Expr::WrapArray.html
index e97bf22f5a6f99217c0499617e900d36c5f16f44..15eef595f15d94b6b3d0a0706041a53c4366fd3b 100644 (file)
@@ -15,9 +15,9 @@ my @targets =
    'bugs.html',
    'templates.html',
    'Generate.html',
-   'Generate::Product.html',
    'Generate::Catalog.html',
    'BSE::Generate::Article.html',
+   'BSE::Generate::Product.html',
    'Squirrel::Template.html',
    'Squirrel::Template::Expr.html',
    'Squirrel::Template::Expr::WrapArray.html',