[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. a77e2edb1547bbef567cb218de34e65eb2e325d0
Stefan Hornburg
racke at rt.icdevgroup.org
Thu May 28 06:45:37 UTC 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange wellwell catalog".
The branch, master has been updated
via a77e2edb1547bbef567cb218de34e65eb2e325d0 (commit)
via fceffac82bbdb82674b70a909fbfbd132e4a3261 (commit)
from 53238359b93f8efe8fdafd75051f016d55fb49a8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a77e2edb1547bbef567cb218de34e65eb2e325d0
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Wed May 27 19:12:36 2009 +0200
fix duplicate declaration of @parts
commit fceffac82bbdb82674b70a909fbfbd132e4a3261
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Wed May 27 19:05:39 2009 +0200
produce nice URLs for category searches instead of scan links
sort products by name
-----------------------------------------------------------------------
Summary of changes and diff:
code/lookup_hook.sub | 19 ++++++++++++++-----
code/paging.sub | 23 ++++++++++++++++++++++-
code/product_list.tag | 8 ++++++++
3 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/code/lookup_hook.sub b/code/lookup_hook.sub
index c1e3a0c..ad88197 100644
--- a/code/lookup_hook.sub
+++ b/code/lookup_hook.sub
@@ -16,22 +16,31 @@ sub {
}
# check if it matches category URI
- my $set;
+ my (@parts, $set, $page, $lookup);
+
+ @parts = grep {/\S/} split(/\//, $name);
+ if ($parts[$#parts] =~ /^(\d+)$/) {
+ $page = pop(@parts);
+ $lookup = join('/', @parts);
+ push(@parts, $page);
+ }
+ else {
+ $lookup = $name;
+ }
$Tag->perl({tables => 'categories'});
$set = $Db{categories}->query(q{select code from categories where uri = '%s'},
- $name);
+ $lookup);
if (@$set == 1) {
$CGI->{category} = $set->[0]->[0];
+ $CGI->{category_page} = $page;
return(1, 'overview');
}
# finally assume that link contains SKU at the end
- my (@parts, $sku);
-
- @parts = grep {/\S/} split(/\//, $name);
+ my $sku;
if (@parts > 1) {
$sku = pop(@parts);
diff --git a/code/paging.sub b/code/paging.sub
index 1905d18..040575a 100644
--- a/code/paging.sub
+++ b/code/paging.sub
@@ -10,6 +10,20 @@ sub {
my ($pages, $first, $curpage, $url, @links, @more, $base_url, $prefix, $suffix, $session, $form_arg, $nav, $ml, $matches);
+ # turn form parameter into a hash
+ my %form;
+
+ if ($opt->{form}) {
+ my (@params, $key, $val);
+
+ @params = split /\n+/, $opt->{form};
+
+ for (@params) {
+ ($key, $val) = split /=/, $_, 2;
+ $form{$key} = $val;
+ }
+ }
+
$ml = $q->{mv_matchlimit};
$matches = $q->{matches};
$pages = $matches / $ml;
@@ -29,8 +43,10 @@ sub {
$form_arg = qq{mv_more_ip=1\nmv_nextpage=$search_page};
$form_arg .= "\npf=$q->{prefix}" if $q->{prefix};
$form_arg .= "\n$opt->{form}" if $opt->{form};
+
$base_url = $Session->{last_url};
$base_url =~ s%^/%%;
+ $base_url =~ s%(/\d+)?(\.html)?$%%;
for (my $i = 1; $i <= $pages; $i++) {
$start = ($i - 1) * $ml;
@@ -45,7 +61,12 @@ sub {
$end = matches;
}
$nav = join(':', $session, $start, $start + ($ml-1), $ml);
- $url = $Tag->area({href => "scan/MM=$nav", form => $form_arg});
+ if ($form{category}) {
+ $url = $Tag->area({href => "$base_url/$i"});
+ }
+ else {
+ $url = $Tag->area({href => "scan/MM=$nav", form => $form_arg});
+ }
$links[$i] = $url;
}
diff --git a/code/product_list.tag b/code/product_list.tag
index a937767..f324615 100644
--- a/code/product_list.tag
+++ b/code/product_list.tag
@@ -66,6 +66,8 @@ sub {
my $ml = $opt->{ml} || $opt->{mv_matchlimit} || 0;
my $more = $opt->{more} || 1;
my $form = $opt->{form};
+ my $jump;
+
if ($category){
$category = " AND pc.category='$category' ";
}
@@ -75,12 +77,18 @@ sub {
SELECT p.sku,p.manufacturer,p.name,p.description,p.price
FROM products p LEFT OUTER JOIN product_categories pc
ON p.sku=pc.sku WHERE p.inactive IS NOT TRUE $category
+ ORDER by p.name
};
+ if ($CGI->{category_page} > 1) {
+ $jump = ($CGI->{category_page} - 1) * $ml + 1;
+ }
+
return $Tag->query({
prefix => $prefix,
more_routine => 'paging',
form => $form,
+ fm => $jump,
ml => $ml,
more => $more,
sql => $sql,
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list