#!/usr/bin/perl -w
# group1TitledPictureAndPayPal.pl
use strict;
use lib "/pathToYourWebspace/cgi-bin/gnu";
use CGI;
use CGI::Carp qw( fatalsToBrowser);
use subjectGroup1::SideIndex;
use Comments;
use MostRecentSideIndex;
use PageFormatterTemplate;
use PathInfo;
# techie stuff: clean up environment for taint mode before calling mail
BEGIN {
$ENV{PATH} = "/bin:/usr/bin";
delete @ENV{ qw( IFS CDPATH ENV BASH_ENV) };
} # end BEGIN
# end techie stuff
# we'll be checking the environment for post parameters etc
my $cgiObj = new CGI();
# do this bit of printing to allow for early error messages
print "Content-type: text/html; charset=iso-8859-1\n\n";
# To use this template
# 1. modify the header content
# 2. modify the contentAry
# 3. modify $sideIndexObj
# pathInfo determines the side index to use and whether we issue a payPal thank you page
# when we return from there following a successful sale
# Note that tests for informationType of any given type need only be conducted if
# the page features on one of the informationType indexes or has a payPal button
# Note that $infoString is used to carry info (if any) specific to a given type e.g.
# in the case of PayPal where I may be selling different pictures on the same page then
# $infoString will contain a picture identifier
my $pathInfoObj = PathInfo->new($cgiObj);
if ($pathInfoObj->pathInfo()) {
if ( ( $pathInfoObj->printablePage() ) ||
($pathInfoObj->mostRecentSideIndex() ) ||
($pathInfoObj->workInProgressSideIndex() ) ||
($pathInfoObj->payPalSale() ) ) {
# OK
} else {
# someone is fooling around
# send message but keep going - ignore it
Mailer::sendErrorEmail("unrecognised pathInfo string","subjectGroup1","group1TitledPictureAndPayPal");
} # end if
} # end if
# determine the side index to use
my $sideIndexObj = subjectGroup1::SideIndex->new();
if ($pathInfoObj->mostRecentSideIndex()) {
$sideIndexObj = MostRecentSideIndex->new();
} # end if
if ($pathInfoObj->workInProgressSideIndex()) {
$sideIndexObj = WorkInProgressSideIndex->new();
} # end if
# header content
my $metaKeywords = "I,hope,you,get,use,from,this,website,generation,program,by,julius,guzy,available,under,gnu,free,software,licence";
my $metaDescription = "I hope you get use from this website generation program by julius guzy available under,gnu free software licence";
my $pageTitle = "Example of how to encode a titled painting";
my $indexGroup = "subjectGroup1";
my $pageFileName = "group1TitledPictureAndPayPal.pl";
# the order of the elements determines the order in which the elements are written in the html
my @contentAry = (
{
contentType => "paragraphSequence",
paraSequence => [
"The source code for this page may be seen <a href='http://yourWebsiteDotCom/gnuCodeInHtml/group1TitledPictureAndPayPal.html'>here</a>.",
],
}, # end anon hash
{
contentType => "titledPainting",
pictureGroup =>"subjectGroup1",
pictureWidth =>500,
pictureHeight =>353,
pictureUrl =>"bellaDreamingForSale.jpg",
pictureAlt =>"Print from Bella's Dream: Bella dreaming, flamingos, seals, gibbon,parrots, anaconda, snaes and anteater and baby anteater",
pictureTitle =>"Print from Bella's Dream: Bella dreaming",
pictureMedium =>"watercolour and body colour",
}, # end anon hash
{
contentType => "payPalPainting",
pictureGroup =>"subjectGroup1",
pictureWidth =>276,
pictureHeight =>200,
pictureUrl =>"bellaDreamingMountBought.jpg",
pictureAlt =>"Print from Bella's Dream: Bella dreaming, flamingos, seals, gibbon,parrots, anaconda, snaes and anteater and baby anteater",
pictureTitle =>"The print on top quality glossy heavy photo paper showing relationship
of printed area of 29 x 20.4cm to the A4 (29.7 x 21cm) sheet",
}, # end anon hash
{
contentType => "payPalButtonMyText",
testButton =>"true",
slogan =>"I like it. I want it!",
price =>"20.00",
basketEncodedItem =>"the payPal encryption string goes here",
}, # end anon hash
); # end contentAry
# check for comments data having been sent to us
# new will get these and validate them
my $commentsObj = Comments->new($cgiObj);
# pass the PageFormatter all the information used to create the page other than the content itself
my $pageObj = PageFormatterTemplate->new($cgiObj,$indexGroup,$sideIndexObj,$commentsObj,$pageFileName,$pageTitle,$metaKeywords,$metaDescription);
# if we are returning from a PayPal sale then we generate a special thank you page
# Note that we only need this if statement if we have a PayPal button we can return from
if ($pathInfoObj->payPalSale() ) {
$pageObj->payPalThankYouContent($pathInfoObj->payPalTheObjectSold());
} else {
# create the standard page
$pageObj->standardContent(\@contentAry);
} # end if