# apf_main.pm
#
# Version 4.091210 - 10th December 2009
#
# This version created by Labbs (http://www.labbs.com) from an original
# script by MrRat (http://www.mrrat.com), with collaborative help from
# users of the APF Forum (http://www.absolutefreebies.com/phpBB2/)
#
# You can support this script by making a donation at
# http://s1.amazon.com/exec/varzea/pay/T3M26803DZOCMK
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
use strict vars;
sub build_products__main {
my $xml_result = shift;
if ($FORM{Operation} eq "ItemSearch") {
if ($Internal_variables{browse_header} and !$MY_variables{error_msg}) { $MY_variables{products_html} .= "
"; }
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
if ($AWS_variables{TotalResults} eq 1) {
${${$level_1}{Item}}[0] =~ /([^<]+)<\/ASIN>/;
$FORM{ItemId} = "$1"; $FORM{Operation} = "ItemLookup"; $FORM{ResponseGroup} = $Internal_variables{ResponseGroup_Item};
delete $MY_variables{header}; delete $MY_variables{SearchIndex}; delete $FORM{BrowseNode}; delete $FORM{Keywords};
$debug .= "wait 1 second then get single product
\n";
sleep 1;
goto START_PROCESSING_LABEL; # yes i know goto is lame, bite me
} elsif ($FORM{SearchIndex} eq "Blended") {
parse_blended($level_1);
} else {
if ($FORM{Keywords}) { ($MY_variables{subject} = $FORM{Keywords}) =~ s/\+/ /g; $MY_variables{store} = $language_text{button_text4}; $MY_variables{header} = qq[$MY_variables{store}: $MY_variables{subject}]; }
assign_variables("products",$level_1);
}
if ($Internal_variables{browse_header}) {
$MY_variables{header} = $Internal_variables{browse_header};
}
} elsif ($FORM{Operation} eq "ItemLookup") {
if ($FORM{ItemId} =~ /,/) {
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
assign_variables("products",$level_1);
$MY_variables{store} = $language_text{header_text2}; $MY_variables{subject} = $language_text{header_text3};
} elsif ($FORM{myOperation} eq "CustomerReviews") {
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
assign_variables("customer_reviews",$level_1);
$MY_variables{store} = $lookup_store{$catalog_to_mode{$AWS_variables{ProductGroup}}}; $MY_variables{subject} = $AWS_variables{Title};
$MY_variables{header} = qq[$MY_variables{store} : $MY_variables{subject}];
} elsif ($FORM{myOperation} eq "Image") {
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
assign_variables("larger_image",$level_1);
$MY_variables{store} = $lookup_store{$catalog_to_mode{$AWS_variables{ProductGroup}}}; $MY_variables{subject} = $AWS_variables{Title};
$MY_variables{header} = qq[$MY_variables{store} : $MY_variables{subject}];
} else {
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
assign_variables("item",$level_1);
$MY_variables{store} = $lookup_store{$catalog_to_mode{$AWS_variables{ProductGroup}}}; $MY_variables{subject} = $AWS_variables{Title};
}
$MY_variables{header} = $AWS_variables{Title};
} elsif ($FORM{Operation} eq "SimilarityLookup") {
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
assign_variables("products",$level_1);
$MY_variables{store} = $language_text{my_similar_products_text1}; $MY_variables{subject} = $language_text{button_text4}; $MY_variables{header} = qq[$MY_variables{store} $MY_variables{subject}];
} elsif ($MY_variables{SearchIndex}) {
$MY_variables{subject} = $language_text{header_text5};
if (!$FORM{BrowseNode}) {
$Internal_variables{nav_menu_type} = "modes";
if (!$current_base_nodes{$MY_variables{SearchIndex}}) {
$Internal_variables{node_listing} = \%{$MY_variables{SearchIndex}};
} else {
$FORM{BrowseNode} = $current_base_nodes{$MY_variables{SearchIndex}};
$Internal_variables{node_listing} = get_node_children($FORM{BrowseNode});
}
# $MY_variables{BrowseNodeName_display} = $language_text{header_text4};
} else {
$Internal_variables{nav_menu_type} = "children";
$Internal_variables{node_listing} = get_node_children($FORM{BrowseNode});
}
# $Internal_variables{browse_header} = qq[$Internal_variables{bestsellers_header}$MY_variables{store} > $MY_variables{BrowseNodeName_display}];
$MY_variables{products_html} = load_browse_table($Internal_variables{node_listing}, "SearchIndex=$MY_variables{SearchIndex}&BrowseNode=");
$FORM{Operation} = "ItemSearch";
$debug .= "wait 1 second then get products
\n";
sleep 1;
goto START_PROCESSING_LABEL; # yes i know goto is lame, bite me
} elsif ($FORM{Operation} eq "ListLookup") {
$MY_variables{store} = $FORM{ListType};
$xml_result =~ s/([^<]+<\/ListItemId>)(.*?)- /$1$2
- $1/sg;
my $level_1 = parse_xml_into_hashes_of_arrays($xml_result);
if ($AWS_variables{TotalResults} eq 1) {
${${$level_1}{Item}}[0] =~ /([^<]+)<\/ASIN>/;
$FORM{ItemId} = "$1"; $FORM{Operation} = "ItemLookup"; $FORM{ResponseGroup} = $Internal_variables{ResponseGroup_Item} . ",ListItems";
delete $MY_variables{header}; delete $MY_variables{SearchIndex}; delete $FORM{BrowseNode}; delete $FORM{Keywords};
$debug .= "wait 1 second then get single product
\n";
sleep 1;
goto START_PROCESSING_LABEL; # yes i know goto is lame, bite me
} else {
$xml_result =~ s/(\d+)<\/TotalPages>/$AWS_variables{TotalPages} = $1/e;
my $level_2 = process_hashes_of_arrays(\%$level_1);
my $level_3 = process_hashes_of_arrays(\%$level_2);
assign_variables("products",$level_3);
}
} else {
(my $this_function = (caller(0))[3]) =~ s/[^:]+:://; my $test_mod;
foreach my $item (@mod_files) {
my $hash_name = qq[subs__$item]; my $sub_name = $this_function . "__" . $item;
if ($mod_use{$item} eq "Yes" and ${$hash_name}{$this_function} eq "Yes") { $test_mod .= &{$sub_name}; }
}
if ($test_mod ne "found") {
# default action - display the modes
$Internal_variables{nav_menu_type} = "none";
$MY_variables{subject} = $language_text{header_text1}; $MY_variables{store} = $language_text{header_text4};
foreach my $key (keys %store_to_browse) {
if (!$current_base_nodes{$store_to_browse{$key}} and !%{$store_to_browse{$key}}) { delete $store_to_browse{$key}; }
}
$MY_variables{products_html} = load_browse_table(\%store_to_browse, "SearchIndex=");
}
}
}
sub build_the_page__main {
my $html_length;
# Price Disclaimer
$MY_variables{price_disclaimer} = $language_text{disclaimer_price};
# Site Disclaimer
$MY_variables{site_disclaimer} = $language_text{disclaimer_site};
#$debug .= qq[Price Disclaimer: $MY_variables{price_disclaimer}
\n];
#$debug .= qq[Site Disclaimer: $MY_variables{site_disclaimer}
\n];
if ($FORM{Operation} eq "ListManiaSearch") { $MY_variables{header} = "$AWS_variables{ListName}"; }
if (!$MY_variables{header}) { $MY_variables{header} = qq[$MY_variables{store} : $MY_variables{subject}]; }
if ($MY_variables{error_msg} and !$Internal_variables{browse_header}) {
$MY_variables{products_html} .= qq[$MY_variables{error_msg}
];
(my $temp_options = $Internal_variables{url_options}) =~ s/^&//;
$MY_variables{header} = qq[$language_text{header_text1}];
}
build_search_box();
$Internal_variables{html} .= set_html("page");
my $apf_footer = qq[