<%args> $page_no=>1

<% $page_title %>\ % if (defined $subpage){ , <% $subpage_title %> % } <& SELF:.photo_list, page_no => $page_no, rows => $display_rows, height=> $height &>

<& PARENT:.left_column &>
<%shared> use HTML::Table; my $dbh = DBI->connect('DBI:mysql:barondb:localhost', 'web', 'www-data'); (my $page_path = $m->dhandler_arg) =~ s/\.html$//; my ($page,$subpage) = split '/', $page_path; my ($page_title,$page_meta,$page_description,$display_rows); # # Grab page title, meta tag, description, and number of rows to display on page. # But do this only if $page corresponds to content. # ($page_title,$page_meta,$page_description,$display_rows) = $dbh->selectrow_array("select title,meta,description,display_rows from title_codes where code=?",undef,$page) if ( $dbh->selectrow_array("select file from photo_index where page=?",undef,$page) ); # $page_title won't be defined if there weren't any photos... undef $page unless defined $page_title; # avoid errors for bogus page titles my ($subpage_ref,$subpage_title,$subpage_meta,$subpage_description,$exclude_page_desc); my %rank_file = (); my $height = 415; if (defined $page){ my $rank_file_ref = $dbh->selectall_arrayref("select file,rank from photo_index where page=?",undef,$page); %rank_file = map {$_->[0] => $_->[1]} @$rank_file_ref; } # end if defined $page my %color_key = map @$_, @{$dbh->selectall_arrayref("select * from color_codes")}; $dbh->disconnect(); <%method .title> Baron Belts: <% $page_title %>\ <%method .photo_list> <%args> $rows $page_no $height <& SELF:.pager, page_no => $page_no, page_nos => $page_nos &> <% $page_description %>

<% $table %>

<%init> my @photos = sort { $rank_file{$b} <=> $rank_file{$a} } grep {$rank_file{$_} >= 0} keys %rank_file; $_ = $m->scomp('SELF:.prod_view',file=>$_,height=>$height) for @photos; my $allthumbs = []; push @{$allthumbs}, [ shift @photos ] while @photos; # $allthumbs is a ref to an array of array refs my $page_nos = 1; if ($rows > 0) { $page_nos= int( @$allthumbs / $rows ); $page_nos +=1 if $page_nos < @$allthumbs / $rows; } my @thumbs = splice @$allthumbs, $rows*($page_no-1), $rows; my $table = HTML::Table->new(-data => \@thumbs); $table->setClass('show-prod'); <%method .pager> <%args> $page_no $page_nos ( % for ( 1 .. $page_nos) { % if ( $_ == $page_no) { <% $page_no %> % } else { <% $_ %> % } <% $_ != $page_nos ? "·" : "" %> % } ) <%init> return unless $page_nos > 1; <%method .prod_view> <%args> $file $height
%# pics are 650px but need to leave room for IE6 scrollbar; also need to add %# extra pixel to height to remove scrollbar in Safari2 <% $pic_alt | h %>
<% $pic_desc %>
% if ($sizes =~ /,/){ %# set up multiple size ordering here % my @header = qw/Item Color Price/; % $color = $color_key{$color}; # replace color code with color name for display % $price = sprintf '$%.2f', $price/100; # prices stored in cents
<% join "", @header %>
<% join "", ($item_no,$color,$price) %>
% my @size_list = split /,/, $sizes; % for my $i (0..$#size_list){ " value="<% $size_list[$i] | h %>" /> % }
SizeQuantity
<% $size_list[$i] %> " size=3 />
% } else { # i.e. there is only one possible size % my @header = qw/Item Color Size Price Qty/; % $color = $color_key{$color}; # replace color code with color name for display % $price = sprintf '$%.2f', $price/100; # prices stored in cents
<% join "", @header %>
<% join "", ($item_no,$color,$sizes,$price) %>
% }
<%init> my ($display_rank,$pic_page,$pic_subpage,$pic_desc,$pic_alt) = $dbh->selectrow_array("select rank,page,subpage,description,alt from photo_index where file=?",undef,$file); my ($item_no,$color,$size_code,$options,$price) = $dbh->selectrow_array("select item_no,color,sizing,options,unit_price from prod_info where photo=? order by item_no",undef,$file); # SHORT CIRCUIT: not actually presenting options at this time. # $options should be 'NA', default in DB. my $option_choice = $options; # translate sizing code: my $sizes = $dbh->selectrow_array('select sizes from sizing_codes where code=?',undef,$size_code); # Javascript in IE abhors hyphens: my $jfile = $file; $jfile =~ s/-//g; <%method .description> <%method .stylesheet> <%method .top_nav_bar>