public function __construct($item_reviewed, $review, $reviewer, $date_reviewed)
 {
     parent::__construct();
     $this->set_attribute_str('class', 'hreview');
     $item_div = new HTMLTags_Div();
     $item_div->set_attribute_str('class', 'item');
     $item_div->append_str_to_content($item_reviewed);
     $this->append_tag_to_content($item_div);
     $description_div = new HTMLTags_Div();
     $description_div->set_attribute_str('class', 'description');
     $description_p = new HTMLTags_P($review);
     $description_div->append_tag_to_content($description_p);
     $this->append_tag_to_content($description_div);
     $reviewer_vcard_span = new HTMLTags_Span();
     $reviewer_vcard_span->set_attribute_str('class', 'reviewer vcard');
     $reviewer_fn_span = new HTMLTags_Span();
     $reviewer_fn_span->set_attribute_str('class', 'fn');
     $reviewer_fn_span->append_str_to_content($reviewer);
     $reviewer_vcard_span->append_tag_to_content($reviewer_fn_span);
     $random_br_tag = new HTMLTags_BR();
     $reviewer_vcard_span->append_tag_to_content($random_br_tag);
     $date_reviewed_abbr = new HTMLTags_Abbr();
     $date_reviewed_abbr->set_attribute_str('class', 'dtreviewed');
     $datetime_iso8601 = Formatting_DateTime::datetime_to_ISO8601($date_reviewed);
     $date_reviewed_abbr->set_attribute_str('title', $datetime_iso8601);
     $datetime_human_readable = Formatting_DateTime::datetime_to_human_readable($date_reviewed);
     $date_reviewed_abbr->append_str_to_content($datetime_human_readable);
     $reviewer_vcard_span->append_tag_to_content($date_reviewed_abbr);
     $this->append_tag_to_content($reviewer_vcard_span);
     return $this;
 }
 private function get_home_page_welcome_text_div()
 {
     $welcome_div = new HTMLTags_Div();
     $welcome_div->set_attribute_str('class', 'welcome');
     $db_page = DBPages_SPoE::get_filtered_page_section('home', 'welcome');
     $welcome_div->append_str_to_content($db_page);
     return $welcome_div;
 }
 private function get_drama_page_frame_instructions_div()
 {
     $instructions_div = new HTMLTags_Div();
     $instructions_div->set_attribute_str('class', 'instructions');
     $instructions_div->set_attribute_str('id', 'drama-page-frame');
     $db_page = DBPages_SPoE::get_filtered_page_section('drama', 'frame-instructions');
     $instructions_div->append_str_to_content($db_page);
     return $instructions_div;
 }
 public function render_body_div_navigation()
 {
     $navigation_div = new HTMLTags_Div();
     $navigation_div->set_attribute_str('id', 'navigation');
     ob_start();
     require PROJECT_ROOT . '/plug-ins/admin/www-includes/html/' . 'body.div.nav-or-error-msg.inc.php';
     $str = ob_get_clean();
     $navigation_div->append_str_to_content($str);
     echo $navigation_div->get_as_string();
 }
 public function render_body_div_navigation()
 {
     $navigation_div = new HTMLTags_Div();
     $navigation_div->set_attribute_str('id', 'navigation');
     #$pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     #$pd = $pdf->get_project_directory_for_this_project();
     #
     #$anxf = $pd->get_admin_navigation_xml_file();
     #
     #$site_map_ul = new Admin_SiteMapUL($anxf);
     #
     #$navigation_div->append_tag_to_content($site_map_ul);
     ob_start();
     require PROJECT_ROOT . '/haddock/admin/www-includes/html/' . 'body.div.nav-or-error-msg.inc.php';
     $str = ob_get_clean();
     $navigation_div->append_str_to_content($str);
     echo $navigation_div->get_as_string();
 }
$redirect_script_url->set_get_variable('type', 'redirect-script');
$cancel_href = clone $current_page_url;
/*
 * Create the HTML tags objects.
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
/*
 * The title of the page.
 */
$content_div->append_tag_to_content(new HTMLTags_Heading(2, 'Your Account'));
if ($log_in_manager->is_logged_in()) {
    /*
     * My account paragraph
     */
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.p.my-account'));
    /*
     * All Orders for SUPPLIER Div
     */
    $customer = $log_in_manager->get_user();
    if ($customer->is_supplier()) {
        if (isset($_GET['set_status_order_id'])) {
            /**
             * Row editing.
             */
            $mysql_user_factory = Database_MySQLUserFactory::get_instance();
            $mysql_user = $mysql_user_factory->get_for_this_project();
            $database = $mysql_user->get_database();
            $orders_table = $database->get_table('hpi_shop_orders');
            $order_row = $orders_table->get_row_by_id($_GET['set_status_order_id']);
            $order_row_renderer = $order_row->get_renderer();
<?php

/**
 * The page that lists all the products in the shop plug-in.
 * 
 * @copyright Clear Line Web Design, 2007-07-26
 */
$page_manager = PublicHTML_PageManager::get_instance();
$mysql_user_factory = Database_MySQLUserFactory::get_instance();
$mysql_user = $mysql_user_factory->get_for_this_project();
$database = $mysql_user->get_database();
$products_table = $database->get_table('hpi_shop_products');
$products_table_renderer = $products_table->get_renderer();
$shopping_baskets_table = $database->get_table('hpi_shop_shopping_baskets');
$comments_table = $database->get_table('hpi_shop_comments');
// CONTENT DIV
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
// MAIN PAGE HEADER
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.content-header'));
// CUSTOMER REGION NOTIFICATION
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.customer-region-notification'));
// SHOP WELCOME BLURB
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.welcome-blurb'));
// ALL PRODUCTS DIV
$all_products_ul = $products_table_renderer->get_all_products_ul_in_public();
$content_div->append_tag_to_content($all_products_ul);
echo $content_div->get_as_string();
 *
 * @copyright Clear Line Web Design, 2007-08-21
 */
/*
 * Create singleton objects.
 */
$log_in_manager = Shop_LogInManager::get_instance();
$page_manager = PublicHTML_PageManager::get_instance();
/*
 * Create the HTML tags objects.
 */
$log_in_to_account_div = new HTMLTags_Div();
$log_in_to_account_div->set_attribute_str('id', 'log_in_to_account_div');
if ($log_in_manager->is_logged_in()) {
    // Change Account
    $log_in_to_account_div->append_str_to_content($page_manager->get_inc_file_as_string('body.p.log-out'));
    //$log_in_to_account_div->append_str_to_content(
    //	$page_manager->get_inc_file_as_string('body.a.log-out')
    //);
} else {
    /*
     * Tell the customer about any log in errors.
     */
    if (isset($_GET['error_message'])) {
        $log_in_to_account_div->append_tag_to_content(new HTMLTags_LastActionBoxDiv($message = stripslashes(urldecode($_GET['error_message'])), $no_script_href = '', $status = 'error'));
    }
    /*
     * Log into the customer's account.
     */
    $form_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'log-in', 'html');
    $redirect_script_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'log-in', 'redirect-script');
$main_page_header_title = 'Checkout';
$main_page_header_class = 'checkout';
$main_page_header_h = new HTMLTags_Heading(2);
$main_page_header_h->set_attribute_str('class', $main_page_header_class);
$main_page_header_h->set_attribute_str('id', $main_page_header_id);
$main_page_header_h->append_tag_to_content(new HTMLTags_Span($main_page_header_title));
$content_div->append_tag_to_content($main_page_header_h);
// Get Checkout Status
//
$checkout_manager = Shop_CheckoutManager::get_instance();
$checkout_status = $checkout_manager->get_checkout_status();
#print_r($checkout_status);
#echo "About to show the nested div\n";
if ($checkout_status != 'no-shopping-basket') {
    // Put up the Checkout status div
    $checkout_status_div = $checkout_manager->get_checkout_status_div();
    $content_div->append_tag_to_content($checkout_status_div);
    // If checkout_status == 'accounts'
    if ($checkout_status == 'accounts') {
        $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.accounts'));
    } elseif ($checkout_status == 'shipping-details') {
        $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.shipping-details'));
    } elseif ($checkout_status == 'payment-options') {
        $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.payment-options'));
    } elseif ($checkout_status == 'checkout-error') {
        $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.checkout-error'));
    }
} elseif ($checkout_status == 'no-shopping-basket') {
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.no-shopping-basket'));
}
echo $content_div->get_as_string();
 * @copyright Clear Line Web Design, 2006-09-27
 */
/*
 * Create singleton objects.
 */
$log_in_manager = Shop_LogInManager::get_instance();
$page_manager = PublicHTML_PageManager::get_instance();
/*
 * CONTENT DIV
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
/*
 * Show The Header
 */
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.h2.main-page-header'));
/*
 * Already Logged in?
 */
if ($log_in_manager->is_logged_in()) {
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.already-logged-in'));
}
/*
 * Going through the Checkout process?
 */
if (isset($_GET['return_to'])) {
    if ($_GET['return_to'] == 'payment-options') {
        $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.checkout-process'));
    }
}
/*
<?php

/**
 * the navigation div on the navigation page.
 *
 * @copyright Clear Line Web Design, 2007-08-19
 */
$navigation_div = new HTMLTags_Div();
$navigation_div->set_attribute_str('id', 'navigation');
ob_start();
require PROJECT_ROOT . '/haddock/admin/www-includes/html/' . 'body.div.nav-or-error-msg.inc.php';
$str = ob_get_clean();
$navigation_div->append_str_to_content($str);
echo $navigation_div->get_as_string();
<?php

/**
 * Content of the mailing list adding page.
 *
 * @copyright Clear Line Web Design, 2007-07-13
 */
/*
 * Create the singleton variables.
 */
$page_manager = PublicHTML_PageManager::get_instance();
/*
 * Create the HTML tags objects.
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.email-adding'));
echo $content_div->get_as_string();
예제 #13
0
<?php

/**
 * Prints the header for a DB page.
 *
 * @copyright Clear Line Web Desgin, 2007-08-29
 */
/*
 * Create the singleton objects.
 */
$gvm = Caching_GlobalVarManager::get_instance();
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'header');
$page_row = $gvm->get('page-row');
$content_div->append_str_to_content($page_row->get_title());
echo $content_div->get_as_string();
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
$logo_span = new HTMLTags_Span();
$logo_span->set_attribute_str('class', 'logo');
$content_div->append_tag_to_content($logo_span);
// HEADER
$main_page_header_id = 'home';
$main_page_header_title = 'Home';
$main_page_header_h = new HTMLTags_Heading(2);
$main_page_header_h->set_attribute_str('class', 'logo');
$main_page_header_h->set_attribute_str('id', $main_page_header_id);
$main_page_header_h->append_str_to_content($main_page_header_title);
$content_div->append_tag_to_content($main_page_header_h);
// IF LOGGED IN MESSAGE
if ($logged_in) {
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.p.logged-in-salutation'));
}
// WELCOME MESSAGE
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.p.welcome-message'));
// CONNECTED FILMS SHOP IMAGE
//
$home_img = new HTMLTags_IMG();
$home_img_location = new HTMLTags_URL();
$home_img_location->set_file('/images/clapperboard.png');
$home_img->set_src($home_img_location);
$home_img->set_attribute_str('class', 'home-page-img');
$content_div->append_tag_to_content($home_img);
// CUSTOMER REGION NOTIFICATION
//
$customer_regions_table = $database->get_table('hpi_shop_customer_regions');
$customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']);
 * @copyright Clear Line Web Design, 2006-09-27
 */
/*
 * Create singleton objects.
 */
$log_in_manager = Shop_LogInManager::get_instance();
$page_manager = PublicHTML_PageManager::get_instance();
/*
 * CONTENT DIV
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
/*
 * Show The Header
 */
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.h2.main-page-header'));
/*
 * Already Logged in?
 */
if ($log_in_manager->is_logged_in()) {
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.already-logged-in'));
}
/* Going through the Checkout process?
 *
 */
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.checkout-process'));
/*
 * Blurb at bottom
 */
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.p.have-a-nice-day'));
echo $content_div->get_as_string();
예제 #16
0
<?php

/**
 * The header div for the shop plug-in.
 * 
 * @copyright Clear Line Web Design, 2006-09-27
 */
$page_manager = PublicHTML_PageManager::get_instance();
$header_div = new HTMLTags_Div();
$header_div->set_attribute_str('id', 'header');
/*
 * A span for the logo (CSS hack).
 */
$logo_span = new HTMLTags_Span();
$header_div->append_tag_to_content($logo_span);
/*
 * A heading that looks at the config file for this project.
 */
$header_div_header_h = new HTMLTags_Heading(1);
$header_div_header_h->set_attribute_str('class', 'header');
$header_div_header_h->set_attribute_str('id', 'shop_title');
$pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
$project_directory = $pdf->get_project_directory_for_this_project();
$config_file = $project_directory->get_config_file();
$header_div_header_h->append_str_to_content($config_file->get_project_title());
$header_div->append_tag_to_content($header_div_header_h);
/*
 * The various regions where this shop sells products.
 */
$header_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.customer-regions'));
echo $header_div->get_as_string();
<?php

/**
 * Content of the "db-page" page.
 *
 * @copyright Clear Line Web Design, 2007-08-27
 */
/*
 * Create the singleton objects.
 */
$gvm = Caching_GlobalVarManager::get_instance();
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
$page_row = $gvm->get('page-row');
/*
 * Edit button if an admin user is logged in.
 */
$content_div->append_str_to_content($page_row->get_html_content());
echo $content_div->get_as_string();
 * @copyright Clear Line Web Design, 2007-09-24
 */
/*
 * Create the singleton objects.
 */
$log_in_manager = Shop_LogInManager::get_instance();
$page_manager = PublicHTML_PageManager::get_instance();
/*
 * Create the HTML tags objects.
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
/*
 * Append the heading.
 */
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.h2.reset-password'));
/*
 * Decide on the locations of the various scripts
 * and pages.
 */
$form_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'password-reset-confirmation', 'html');
$redirect_script_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'password-reset-confirmation', 'redirect-script');
$desired_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'log-in', 'html');
$cancel_page_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'home', 'html');
/*
 * Append the form.
 */
$reset_password_form_div = new HTMLTags_Div();
#$login_form_div->set_attribute_str('class', 'cmx-form');
if (isset($_GET['error_message'])) {
    $reset_password_form_div->append_tag_to_content(new HTMLTags_LastActionBoxDiv($message = stripslashes(urldecode($_GET['error_message'])), $no_script_href = '', $status = 'error'));
<?php

/**
 * Navigation page for the admin back-end.
 *
 * @copyright Clear Line Web Design, 2007-08-19
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
ob_start();
require PROJECT_ROOT . '/haddock/admin/www-includes/html/' . 'body.div.nav-or-error-msg.inc.php';
$str = ob_get_clean();
$content_div->append_str_to_content($str);
echo $content_div->get_as_string();
$customers_table = $database->get_table('hpi_shop_customers');
$customers_table_renderer = $customers_table->get_renderer();
$shopping_baskets_table = $database->get_table('hpi_shop_shopping_baskets');
$shopping_baskets_table_renderer = $shopping_baskets_table->get_renderer();
/*
 * Create the HTML tags objects.
 */
$payments_div = new HTMLTags_Div();
$payments_div->set_attribute_str('id', 'payments_div');
///*
// * Display Protx form
// * when clicked convert the shopping baskets into orders
// * and send the person to Protx
// */
$protx_form = $page_manager->get_inc_file_as_string('body.div.protx-form');
$payments_div->append_str_to_content($protx_form);
//$payment_buttons_div = $payments_option_buttons_factory->get_html_div();
//$payments_div->append_tag_to_content($payment_buttons_div);
/* 
 * Display Customer Shipping Details
 * with edit button to reset the session 
 * and send you back to stage 2
 */
$user = $log_in_manager->get_user();
$user_renderer = $user->get_renderer();
$desired_location = $current_page_url;
$payments_div->append_tag_to_content($user_renderer->get_customer_details_display_div($redirect_script_url, $desired_location));
/*
 * Display Shopping Basket
 * with edit button to go to shopping-basket.html
 */
/*
 *  CONNECTED FILMS SHOP IMAGE
 */
//$home_img = new HTMLTags_IMG();
//$home_img_location = new HTMLTags_URL();
//$home_img_location->set_file('/images/home_page_image.jpg');
//$home_img->set_src($home_img_location);
//$home_img->set_attribute_str('class', 'home-page-img');
//$welcome_div->append_tag_to_content($home_img);
/*
 * Customer Region Notification
 *
 * We should make inclusion of this div conditional and move the region code
 * to a separate plug-in as many shops do not divide their customers into regions.
 */
$welcome_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.customer-region-notification'));
/*
 *  LIST OF PRODUCT CATEGORIES
 */
//$welcome_div->append_str_to_content(
//    $page_manager->get_inc_file_as_string('body.div.lines-of-stock')
//);
/*
 *  ALL PRODUCTS LINK
 */
$welcome_div->append_str_to_content($page_manager->get_inc_file_as_string('body.p.all-products-link'));
$content_div->append_tag_to_content($welcome_div);
// FRONT PAGE PRODUCT DISPLAY
//
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.front-page-products'));
echo $content_div->get_as_string();
    public function render_body_div_content()
    {
        /*
         * Get the database objects.
         */
        $mysql_user_factory = Database_MySQLUserFactory::get_instance();
        $mysql_user = $mysql_user_factory->get_for_this_project();
        $database = $mysql_user->get_database();
        $products_table = $database->get_table('hpi_shop_products');
        $table_renderer = $products_table->get_renderer();
        $page_manager = PublicHTML_PageManager::get_instance();
        $gvm = Caching_GlobalVarManager::get_instance();
        /*
         * Assemble the HTML
         */
        $content_div = new HTMLTags_Div();
        $content_div->set_attribute_str('id', 'content');
        /*
         * Cloned repeatedly throughout.
         */
        #$current_page_url = $gvm->get('current_page_admin_url');
        #$redirect_script_url = $gvm->get('redirect_script_admin_url');
        $current_page_url = new HTMLTags_URL();
        $current_page_url->set_file('/haddock/public-html/public-html/index.php');
        $current_page_url->set_get_variable('oo-page');
        $current_page_url->set_get_variable('page-class', 'Shop_AdminProductsPage');
        $redirect_script_url = Admin_AdminIncluderURLFactory::get_url('plug-ins', 'shop', 'products', 'redirect-script');
        $cancel_href = $current_page_url;
        ########################################################################
        #
        # Forms for changing the contents of the database.
        #
        ########################################################################
        if (isset($_GET['delete_all'])) {
            /**
             * Confirm deleting all the rows in the table.
             */
            $action_div = new HTMLTags_Div();
            $action_div->set_attribute_str('id', 'action-div');
            $question_delete_all_p = new HTMLTags_P('Are you sure that you want to delete all of the products?');
            $action_div->append_tag_to_content($question_delete_all_p);
            $confirm_delete_all_p = new HTMLTags_P();
            $delete_all_href = clone $redirect_script_url;
            $delete_all_href->set_get_variable('delete_all');
            $delete_all_a = new HTMLTags_A('DELETE ALL');
            $delete_all_a->set_attribute_str('class', 'cool_button');
            $delete_all_a->set_attribute_str('id', 'inline');
            $delete_all_a->set_href($delete_all_href);
            $confirm_delete_all_p->append_tag_to_content($delete_all_a);
            $confirm_delete_all_p->append_str_to_content('&nbsp;');
            $cancel_a = new HTMLTags_A('Cancel');
            $cancel_a->set_attribute_str('class', 'cool_button');
            $cancel_a->set_attribute_str('id', 'inline');
            $cancel_a->set_href($cancel_href);
            $confirm_delete_all_p->append_tag_to_content($cancel_a);
            $action_div->append_tag_to_content($confirm_delete_all_p);
            $content_div->append_tag_to_content($action_div);
        } elseif (isset($_GET['delete_id'])) {
            /**
             * Confirm deleting a row.
             */
            $row = $products_table->get_row_by_id($_GET['delete_id']);
            $question_p = new HTMLTags_P();
            $question_p->set_attribute_str('class', 'question');
            $question_p->append_str_to_content('Are you sure that you want to delete this row?');
            $content_div->append_tag_to_content($question_p);
            /**
             * Show the user the data in the row.
             */
            $row_renderer = $row->get_renderer();
            $content_div->append_tag_to_content($row_renderer->get_all_data_html_table());
            # ------------------------------------------------------------------
            $answer_p = new HTMLTags_P();
            $answer_p->set_attribute_str('class', 'answer');
            $delete_link = new HTMLTags_A('DELETE');
            $delete_href = clone $redirect_script_url;
            $delete_href->set_get_variable('delete_id', $row->get_id());
            $delete_link->set_href($delete_href);
            $delete_link->set_attribute_str('class', 'cool_button');
            $delete_link->set_attribute_str('id', 'inline');
            $answer_p->append_tag_to_content($delete_link);
            $cancel_link = new HTMLTags_A('Cancel');
            $cancel_link->set_href($cancel_href);
            $cancel_link->set_attribute_str('class', 'cool_button');
            $cancel_link->set_attribute_str('id', 'inline');
            $answer_p->append_tag_to_content($cancel_link);
            $content_div->append_tag_to_content($answer_p);
        } elseif (isset($_GET['edit_id'])) {
            /*
             * Edit the values of this product.
             */
            $row_editing_url = clone $redirect_script_url;
            $row_editing_url->set_get_variable('edit_id', $_GET['edit_id']);
            $product_row = $products_table->get_row_by_id($_GET['edit_id']);
            $row_editing_url->set_get_variable('plu_code', $product_row->get_plu_code());
            $product_row_renderer = $product_row->get_renderer();
            $row_editing_form = $product_row_renderer->get_product_editing_form($row_editing_url, $cancel_href);
            $content_div->append_tag_to_content($row_editing_form);
            $explanation_div = new HTMLTags_Div();
            $explanation_text = <<<TXT
Some other links to edit forms:
TXT;
            $explanation_div->append_tag_to_content(new HTMLTags_P($explanation_text));
            $explanation_links_ul = new HTMLTags_UL();
            #$explanation_link_li_1 = new HTMLTags_LI();
            #$explanation_link_a = new HTMLTags_A('Add a new photograph...');
            #
            #$explanation_link_href = clone $current_page_url;
            #
            #$explanation_link_href->set_get_variable('admin-page', 'photographs');
            #$explanation_link_href->set_get_variable('add_row', '1');
            #$explanation_link_a->set_href($explanation_link_href);
            #
            #$explanation_link_li_1->append_tag_to_content($explanation_link_a);
            #$explanation_links_ul->append_tag_to_content($explanation_link_li_1);
            $explanation_link_li_2 = new HTMLTags_LI();
            $explanation_link_a = new HTMLTags_A('Edit all the tags for this product...');
            $explanation_link_href = clone $current_page_url;
            $explanation_link_href->set_get_variable('edit_tags', '1');
            $explanation_link_href->set_get_variable('product_id', $_GET['edit_id']);
            $explanation_link_a->set_href($explanation_link_href);
            $explanation_link_li_2->append_tag_to_content($explanation_link_a);
            $explanation_links_ul->append_tag_to_content($explanation_link_li_2);
            $explanation_div->append_tag_to_content($explanation_links_ul);
            $content_div->append_tag_to_content($explanation_div);
        } elseif (isset($_GET['add_row'])) {
            /**
             * Row Adding.
             */
            $row_adding_url = clone $redirect_script_url;
            $row_adding_url->set_get_variable('add_row');
            $row_adding_form = $table_renderer->get_product_adding_form($row_adding_url, $cancel_href);
            $content_div->append_tag_to_content($row_adding_form);
            $explanation_div = new HTMLTags_Div();
            $explanation_text = <<<TXT
Some other links to forms:
TXT;
            $explanation_div->append_tag_to_content(new HTMLTags_P($explanation_text));
            $explanation_links_ul = new HTMLTags_UL();
            $explanation_link_li_1 = new HTMLTags_LI();
            $explanation_link_a = new HTMLTags_A('Add a new photograph...');
            $explanation_link_href = clone $current_page_url;
            $explanation_link_href->set_get_variable('admin-page', 'photographs');
            $explanation_link_href->set_get_variable('add_row', '1');
            $explanation_link_a->set_href($explanation_link_href);
            $explanation_link_li_1->append_tag_to_content($explanation_link_a);
            $explanation_links_ul->append_tag_to_content($explanation_link_li_1);
            $explanation_div->append_tag_to_content($explanation_links_ul);
            $content_div->append_tag_to_content($explanation_div);
        } elseif (isset($_GET['edit_tags']) && isset($_GET['product_id'])) {
            /**
             * Row editing.
             */
            $product_row = $products_table->get_row_by_id($_GET['product_id']);
            $product_row_renderer = $product_row->get_renderer();
            $row_editing_form = $product_row_renderer->get_product_tag_editing_form($redirect_script_url, $cancel_href);
            $content_div->append_tag_to_content($row_editing_form);
        } elseif (isset($_GET['set_principal_tags']) && isset($_GET['product_id'])) {
            /**
             * Row editing.
             */
            $product_row = $products_table->get_row_by_id($_GET['product_id']);
            $product_row_renderer = $product_row->get_renderer();
            $row_editing_form = $product_row_renderer->get_product_principal_tag_editing_form($redirect_script_url, $cancel_href);
            $content_div->append_tag_to_content($row_editing_form);
        } elseif (isset($_GET['set_price']) && isset($_GET['product_id'])) {
            /**
             * Set Prices
             */
            $set_price_url = clone $redirect_script_url;
            $set_price_url->set_get_variable('set_price');
            $set_price_url->set_get_variable('product_id', $_GET['product_id']);
            $product_currency_prices_table = $database->get_table('hpi_shop_product_currency_prices');
            $product_currency_prices_table_renderer = $product_currency_prices_table->get_renderer();
            $price_setting_form = $product_currency_prices_table_renderer->get_product_currency_price_editing_form($_GET['product_id'], $set_price_url, $cancel_href);
            $content_div->append_tag_to_content($price_setting_form);
        } elseif (isset($_GET['set_stock_level']) && isset($_GET['product_id'])) {
            /**
             * Set Stock Level
             */
            $product_row = $products_table->get_row_by_id($_GET['product_id']);
            $product_row_renderer = $product_row->get_renderer();
            $row_editing_form = $product_row_renderer->get_stock_level_editing_form($redirect_script_url, $cancel_href);
            $content_div->append_tag_to_content($row_editing_form);
        } elseif (isset($_GET['stock_level']) && isset($_GET['product_id'])) {
            /*
             * Shows the current stock levels for a single product.
             */
            ob_start();
            $return_to_p = self::get_back_to_products_link_p();
            echo $return_to_p;
            $id = $_GET['product_id'];
            $dbh = $database->get_database_handle();
            /*
             * Get product names, sizes, colours and quantities for this product.
             */
            $query = <<<SQL
SELECT 
\thpi_shop_products.name,
\thpi_trackit_stock_management_stock_levels.size,
\thpi_trackit_stock_management_stock_levels.colour,
\thpi_trackit_stock_management_stock_levels.quantity
FROM
\thpi_shop_products
\t\tINNER JOIN hpi_trackit_stock_management_products
\t\t\tON hpi_shop_products.id = hpi_trackit_stock_management_products.shop_product_id
\t\tINNER JOIN hpi_trackit_stock_management_stock_levels
\t\t\tON
\t\t\t\thpi_trackit_stock_management_products.product_id
\t\t\t\t=
\t\t\t\thpi_trackit_stock_management_stock_levels.product_id
WHERE
\thpi_shop_products.id = {$id}
SQL;
            $result = mysql_query($query, $dbh);
            if (mysql_num_rows($result)) {
                $first = TRUE;
                while ($row = mysql_fetch_assoc($result)) {
                    if ($first) {
                        ?>
<table>
	<caption>Stock Levels for <?php 
                        echo $row['name'];
                        ?>
</caption>
	<tr>
		<th>Size</th>
		<th>Colour</th>
		<th>Quantity</th>
	</tr>	
<?php 
                        $first = FALSE;
                    }
                    ?>
	<tr>
		<td><?php 
                    echo $row['size'];
                    ?>
</td>
		<td><?php 
                    echo $row['colour'];
                    ?>
</td>
		<td><?php 
                    echo (int) $row['quantity'];
                    ?>
</td>
	</tr>
<?php 
                }
                echo "</table>\n";
            } else {
                ?>
<p class="error">
	No product found!
</p>
<?php 
            }
            echo $return_to_p;
            $content_div->append_str_to_content(ob_get_clean());
        } elseif (isset($_GET['set_main_photograph']) && isset($_GET['product_id'])) {
            $product = $products_table->get_row_by_id($_GET['product_id']);
            $instruction_p = new HTMLTags_P('Set main photograph for ' . $product->get_name());
            $content_div->append_tag_to_content($instruction_p);
            $photographs_table = $database->get_table('hpi_shop_photographs');
            $photograhps_ul = new HTMLTags_UL();
            $photograhps_ul->set_attribute_str('id', 'photographs');
            $photographs = $photographs_table->get_all_rows();
            $set_main_photograph_url = clone $redirect_script_url;
            $set_main_photograph_url->set_get_variable('product_id', $product->get_id());
            $set_main_photograph_url->set_get_variable('set_main_photograph');
            foreach ($photographs as $photograph) {
                $li = new HTMLTags_LI();
                $pr = $photograph->get_renderer();
                $set_main_photograph_to_this_photograph_url = clone $set_main_photograph_url;
                $set_main_photograph_to_this_photograph_url->set_get_variable('photograph_id', $photograph->get_id());
                $tnia = $pr->get_thumbnail_image_a();
                $tnia->set_href($set_main_photograph_to_this_photograph_url);
                $li->append_tag_to_content($tnia);
                $photograhps_ul->add_li($li);
            }
            $content_div->append_tag_to_content($photograhps_ul);
        } elseif (isset($_GET['set_design_photograph']) && isset($_GET['product_id'])) {
            $product = $products_table->get_row_by_id($_GET['product_id']);
            $instruction_p = new HTMLTags_P('Set design photograph for ' . $product->get_name());
            $content_div->append_tag_to_content($instruction_p);
            $photographs_table = $database->get_table('hpi_shop_photographs');
            $photograhps_ul = new HTMLTags_UL();
            $photograhps_ul->set_attribute_str('id', 'photographs');
            $photographs = $photographs_table->get_all_rows();
            $set_design_photograph_url = clone $redirect_script_url;
            $set_design_photograph_url->set_get_variable('product_id', $product->get_id());
            $set_design_photograph_url->set_get_variable('set_design_photograph');
            foreach ($photographs as $photograph) {
                $li = new HTMLTags_LI();
                $pr = $photograph->get_renderer();
                $set_design_photograph_to_this_photograph_url = clone $set_design_photograph_url;
                $set_design_photograph_to_this_photograph_url->set_get_variable('photograph_id', $photograph->get_id());
                $tnia = $pr->get_thumbnail_image_a();
                $tnia->set_href($set_design_photograph_to_this_photograph_url);
                $li->append_tag_to_content($tnia);
                $photograhps_ul->add_li($li);
            }
            $content_div->append_tag_to_content($photograhps_ul);
        } elseif (isset($_GET['add_extra_photograph']) && isset($_GET['product_id'])) {
            $product = $products_table->get_row_by_id($_GET['product_id']);
            $instruction_p = new HTMLTags_P('Add extra photograph for ' . $product->get_name());
            $content_div->append_tag_to_content($instruction_p);
            $photographs_table = $database->get_table('hpi_shop_photographs');
            $photograhps_ul = new HTMLTags_UL();
            $photograhps_ul->set_attribute_str('id', 'photographs');
            $photographs = $photographs_table->get_all_rows();
            $url = clone $redirect_script_url;
            $url->set_get_variable('product_id', $product->get_id());
            $url->set_get_variable('add_extra_photograph');
            foreach ($photographs as $photograph) {
                $li = new HTMLTags_LI();
                $pr = $photograph->get_renderer();
                $this_photograph_url = clone $url;
                $this_photograph_url->set_get_variable('photograph_id', $photograph->get_id());
                $tnia = $pr->get_thumbnail_image_a();
                $tnia->set_href($this_photograph_url);
                $li->append_tag_to_content($tnia);
                $photograhps_ul->add_li($li);
            }
            $content_div->append_tag_to_content($photograhps_ul);
        } else {
            /**
             * LAST ACTION BOX DIV
             *
             */
            if (isset($_GET['last_deleted_id']) || isset($_GET['last_edited_id']) || isset($_GET['last_added_id']) || isset($_GET['deleted_all'])) {
                if (isset($_GET['last_deleted_id'])) {
                    $message = 'Deleted product id: ' . $_GET['last_deleted_id'];
                } elseif (isset($_GET['last_edited_id'])) {
                    $product = $products_table->get_row_by_id($_GET['last_edited_id']);
                    $message = 'Edited ' . $product->get_name();
                } elseif (isset($_GET['last_added_id'])) {
                    $product = $products_table->get_row_by_id($_GET['last_added_id']);
                    $message = 'Added ' . $product->get_name();
                } elseif (isset($_GET['deleted_all'])) {
                    if ($_GET['deleted_all'] == 'successful') {
                        $message = 'Succesfully deleted 
					all of your products! 
					(Not really - feature disabled)';
                    } else {
                        $message = 'Failed to delete all of your products.';
                    }
                }
                $last_error_box_div = new HTMLTags_LastActionBoxDiv($message, $current_page_url->get_as_string(), 'message');
                $content_div->append_tag_to_content($last_error_box_div);
            }
            /**
             * Links to other pages in the admin section.
             */
            //        $page_options_div = new HTMLTags_Div();
            //        $page_options_div->set_attribute_str('id', 'page-options');
            //        $other_pages_ul = new HTMLTags_UL();
            /**
             * Link to the add row form.
             */
            #$add_row_li = new HTMLTags_LI();
            #
            #$add_row_a = new HTMLTags_A('Add New Product');
            #
            #$add_row_href = clone $current_page_url;
            #$add_row_href->set_get_variable('add_row');
            #
            #$add_row_a->set_href($add_row_href);
            #
            #$add_row_li->append_tag_to_content($add_row_a);
            #
            #$other_pages_ul->append_tag_to_content($add_row_li);
            /**
             * Link to the delete all confirmation page.
             */
            //        $delete_all_li = new HTMLTags_LI();
            //        $delete_all_a = new HTMLTags_A('Delete All Products');
            //        $delete_all_href = clone $current_page_url;
            //        $delete_all_href->set_get_variable('delete_all');
            //        $delete_all_a->set_href($delete_all_href);
            //        $delete_all_li->append_tag_to_content($delete_all_a);
            //        $other_pages_ul->append_tag_to_content($delete_all_li);
            //        $page_options_div->append_tag_to_content($other_pages_ul);
            //        $content_div->append_tag_to_content($page_options_div);
            //
            /*
             * ----------------------------------------
             * See if the variables for constraining the selection of products
             * have been set in GET.
             * ----------------------------------------
             */
            $product_category_id = NULL;
            if (isset($_GET['product_category_id']) && is_numeric($_GET['product_category_id'])) {
                $product_category_id = $_GET['product_category_id'];
            }
            //        $just_with_photos = FALSE;
            $just_with_photos = TRUE;
            if (isset($_GET['just_with_photos']) && strtolower($_GET['just_with_photos']) == 'yes') {
                $just_with_photos = TRUE;
            } elseif (isset($_GET['just_with_photos']) && strtolower($_GET['just_with_photos']) == 'no') {
                $just_with_photos = FALSE;
            }
            // Hide hidden products
            //
            //        $just_displayed_products = FALSE;
            $just_displayed_products = TRUE;
            if (isset($_GET['just_displayed_products']) && strtolower($_GET['just_displayed_products']) == 'yes') {
                $just_displayed_products = TRUE;
            } elseif (isset($_GET['just_displayed_products']) && strtolower($_GET['just_displayed_products']) == 'no') {
                $just_displayed_products = FALSE;
            }
            if (isset($_GET['plu_code'])) {
                // If PLU Code is set, unset everyhting else
                $just_with_photos = FALSE;
                $just_displayed_products = FALSE;
            }
            $content_div->append_tag_to_content($this->get_enter_plu_code_form());
            /*
             * -------------------------------------------------------------------------
             * The product selecting form.
             * -------------------------------------------------------------------------
             */
            $product_category_selecting_form = new HTMLTags_Form();
            $product_category_selecting_form->set_attribute_str('name', 'product_category_selecting');
            $product_category_selecting_form->set_attribute_str('method', 'GET');
            $product_category_selecting_form->set_attribute_str('class', 'table-select-form');
            $product_category_selecting_form->set_action(new HTMLTags_URL('/'));
            $inputs_ol = new HTMLTags_OL();
            /*
             * Select whether you want all products or just those with status==display
             */
            $li = new HTMLTags_LI();
            $label = new HTMLTags_Label('Just Display Products');
            $label->set_attribute_str('for', 'just_displayed_products');
            $li->append_tag_to_content($label);
            $select = new HTMLTags_Select();
            $select->set_attribute_str('name', 'just_displayed_products');
            $yes_option = new HTMLTags_Option('Yes');
            $yes_option->set_attribute_str('value', 'yes');
            $no_option = new HTMLTags_Option('No');
            $no_option->set_attribute_str('value', 'no');
            if (isset($_GET['just_displayed_products'])) {
                if ($_GET['just_displayed_products'] == 'no') {
                    $no_option->set_attribute_str('selected', 'TRUE');
                }
            } else {
                $yes_option->set_attribute_str('selected', 'TRUE');
            }
            $select->add_option($yes_option);
            $select->add_option($no_option);
            /*
             * The default is 'no'. /changed it to yes SAUL
             *
             * i.e. Get all the products, regardless of whether they have photos or not.
             */
            if (isset($_GET['just_displayed_products'])) {
                $select->set_value($_GET['just_displayed_products']);
            } else {
                $select->set_value('yes');
            }
            $li->append_tag_to_content($select);
            $inputs_ol->add_li($li);
            /*
             * Select whether you want all products or just those with photos.
             */
            $li = new HTMLTags_LI();
            $label = new HTMLTags_Label('Just with Photos');
            $label->set_attribute_str('for', 'just_with_photos');
            $li->append_tag_to_content($label);
            $select = new HTMLTags_Select();
            $select->set_attribute_str('name', 'just_with_photos');
            $yes_option = new HTMLTags_Option('Yes');
            $yes_option->set_attribute_str('value', 'yes');
            $no_option = new HTMLTags_Option('No');
            $no_option->set_attribute_str('value', 'no');
            if (isset($_GET['just_with_photos'])) {
                if ($_GET['just_with_photos'] == 'no') {
                    $no_option->set_attribute_str('selected', 'TRUE');
                }
            } else {
                $yes_option->set_attribute_str('selected', 'TRUE');
            }
            $select->add_option($yes_option);
            $select->add_option($no_option);
            /*
             * The default is 'no'. /changed it to yes SAUL
             *
             * i.e. Get all the products, regardless of whether they have photos or not.
             */
            if (isset($_GET['just_with_photos'])) {
                $select->set_value($_GET['just_with_photos']);
            } else {
                $select->set_value('yes');
            }
            $li->append_tag_to_content($select);
            $inputs_ol->add_li($li);
            /*
             * Select the product_category_id.
             */
            $product_category_li = new HTMLTags_LI();
            $product_category_label = new HTMLTags_Label('Product Category');
            $product_category_label->set_attribute_str('for', 'product_category_id');
            $product_category_li->append_tag_to_content($product_category_label);
            if (isset($_GET['product_category_id'])) {
                $product_category_form_select = $table_renderer->get_product_category_form_select($_GET['product_category_id']);
            } else {
                $product_category_form_select = $table_renderer->get_product_category_form_select();
            }
            $all_product_categories_option = new HTMLTags_Option('all');
            $all_product_categories_option->set_attribute_str('value', 'all');
            if ($_GET['product_category_id'] == 'all' || !isset($_GET['product_category_id'])) {
                $all_product_categories_option->set_attribute_str('selected');
            }
            $product_category_form_select->add_option($all_product_categories_option);
            $product_category_li->append_tag_to_content($product_category_form_select);
            $inputs_ol->add_li($product_category_li);
            /*
             * The hidden inputs.
             */
            $product_category_selecting_action = clone $current_page_url;
            $product_category_selecting_action_get_vars = $product_category_selecting_action->get_get_variables();
            foreach (array_keys($product_category_selecting_action_get_vars) as $key) {
                $form_hidden_input = new HTMLTags_Input();
                $form_hidden_input->set_attribute_str('type', 'hidden');
                $form_hidden_input->set_attribute_str('name', $key);
                $form_hidden_input->set_attribute_str('value', $product_category_selecting_action_get_vars[$key]);
                $product_category_selecting_form->append_tag_to_content($form_hidden_input);
            }
            /*
             * The submit button.
             */
            $go_button_li = new HTMLTags_LI();
            $go_button = new HTMLTags_Input();
            $go_button->set_attribute_str('type', 'submit');
            $go_button->set_attribute_str('value', 'Go');
            $go_button->set_attribute_str('class', 'submit');
            $go_button_li->append_tag_to_content($go_button);
            $inputs_ol->add_li($go_button_li);
            $product_category_selecting_form->append_tag_to_content($inputs_ol);
            $content_div->append_tag_to_content($product_category_selecting_form);
            ####################################################################
            #
            # Display some of the data in the table.
            #
            ####################################################################
            /*
             * Build the the 'from' and 'where' clauses for the select statements below.
             *
             * One counts the rows matching the selection criteria and the other fetches
             * the data from the database.
             */
            $from_and_where_clauses = <<<SQL
FROM
\thpi_shop_products
\t
SQL;
            if ($just_with_photos) {
                $from_and_where_clauses .= <<<SQL
\t\tINNER JOIN hpi_shop_product_photograph_links
\t\t\tON hpi_shop_products.id = hpi_shop_product_photograph_links.product_id
\t\tINNER JOIN hpi_shop_photographs
\t\t\tON hpi_shop_product_photograph_links.photograph_id = hpi_shop_photographs.id
\t\t\t
SQL;
            }
            if (isset($_GET['plu_code'])) {
                // If PLU_CODE is set, then nothing else should be
                // (different form)
                $plu_code = $_GET['plu_code'];
                $from_and_where_clauses .= <<<SQL

WHERE
\thpi_shop_products.plu_code = {$plu_code}

SQL;
            }
            if (isset($product_category_id) || $just_with_photos || $just_displayed_products) {
                $from_and_where_clauses .= <<<SQL

WHERE

SQL;
            }
            if (isset($product_category_id)) {
                $from_and_where_clauses .= <<<SQL
\t
\thpi_shop_products.product_category_id = {$product_category_id}
\t
SQL;
            }
            if (isset($product_category_id) && ($just_with_photos || $just_displayed_products)) {
                $from_and_where_clauses .= <<<SQL

\tAND

SQL;
            }
            if ($just_displayed_products) {
                $from_and_where_clauses .= <<<SQL

\thpi_shop_products.status = 'display'
\t
SQL;
            }
            if ($just_with_photos && ($just_displayed_products || isset($product_category_id))) {
                $from_and_where_clauses .= <<<SQL

\tAND

SQL;
            }
            if ($just_with_photos) {
                $from_and_where_clauses .= <<<SQL

\thpi_shop_product_photograph_links.type = 'main'
\t
SQL;
            }
            $from_and_where_clauses .= <<<SQL

\tGROUP BY hpi_shop_products.style_id
\t
SQL;
            /*
             * DIV for limits and previous and nexts.
             */
            $limit_previous_next_div = new HTMLTags_Div();
            $limit_previous_next_div->set_attribute_str('class', 'table_pages_div');
            /*
             * To allow the user to set the number of extras to show at a time.
             */
            $limit_action = clone $current_page_url;
            #		echo 'LIMIT: ' . LIMIT . "\n";
            #		exit;
            $limit_form = new Database_LimitForm($limit_action, LIMIT, '10 20 50');
            //                $limit_form->add_hidden_input('module', 'shop');
            //                $limit_form->add_hidden_input('page', 'products');
            $limit_form->add_hidden_input('section', 'haddock');
            $limit_form->add_hidden_input('module', 'admin');
            $limit_form->add_hidden_input('page', 'admin-includer');
            $limit_form->add_hidden_input('type', 'html');
            $limit_form->add_hidden_input('admin-section', 'plug-ins');
            $limit_form->add_hidden_input('admin-module', 'shop');
            $limit_form->add_hidden_input('admin-page', 'products');
            $limit_form->add_hidden_input('order_by', ORDER_BY);
            $limit_form->add_hidden_input('direction', DIRECTION);
            $limit_form->add_hidden_input('offset', OFFSET);
            /*
             * Extra get vars if we've restricted the selection.
             */
            if (isset($product_category_id)) {
                $limit_form->add_hidden_input('product_category_id', $product_category_id);
            }
            if ($just_displayed_products) {
                $limit_form->add_hidden_input('just_displayed_products', 'yes');
            } else {
                $limit_form->add_hidden_input('just_displayed_products', 'no');
            }
            if ($just_with_photos) {
                $limit_form->add_hidden_input('just_with_photos', 'yes');
            } else {
                $limit_form->add_hidden_input('just_with_photos', 'no');
            }
            $limit_previous_next_div->append_tag_to_content($limit_form);
            /*
             * Go the previous or next list of extras.
             */
            $previous_next_url = clone $current_page_url;
            $previous_next_url->set_get_variable('order_by', ORDER_BY);
            $previous_next_url->set_get_variable('direction', DIRECTION);
            #print_r($previous_next_url);
            /*
             * Count the rows in the table that match our selection criteria.
             */
            #$row_count = $products_table->count_all_rows();
            $query = <<<SQL
SELECT
\tCOUNT(hpi_shop_products.id)
{$from_and_where_clauses}

SQL;
            if (DEBUG) {
                echo DEBUG_DELIM_OPEN;
                echo 'Line: ' . __LINE__ . "\n";
                echo 'File: ' . __FILE__ . "\n";
                echo 'Class: ' . __CLASS__ . "\n";
                echo 'Method: ' . __METHOD__ . "\n";
                echo 'get_class($this): ' . get_class($this) . "\n";
                echo "\n";
                echo '$query: ' . "\n";
                print_r($query);
                echo DEBUG_DELIM_CLOSE;
            }
            $dbh = DB::m();
            $result = mysql_query($query, $dbh);
            $row_count = 0;
            //        if (
            //                $result
            //                &&
            //                ($row = mysql_fetch_array($result))
            //        ) {
            //                $row_count = $row[0];
            //        }
            //        mysql_num_rows was better since we added the GROUP BY bit
            if ($result) {
                $row_count = mysql_num_rows($result);
            }
            //        echo "\$query: $query\n";
            //        echo "\$row_count: $row_count\n";
            $previous_next_ul = new Database_PreviousNextUL($previous_next_url, OFFSET, LIMIT, $row_count);
            /*
             * Extra get vars if we've restricted the selection.
             */
            if (isset($product_category_id)) {
                $previous_next_url->set_get_variable('product_category_id', $product_category_id);
            }
            if ($just_displayed_products) {
                $previous_next_url->set_get_variable('just_displayed_products', 'yes');
            } else {
                $previous_next_url->set_get_variable('just_displayed_products', 'no');
            }
            if ($just_with_photos) {
                $previous_next_url->set_get_variable('just_with_photos', 'yes');
            } else {
                $previous_next_url->set_get_variable('just_with_photos', 'no');
            }
            $limit_previous_next_div->append_tag_to_content($previous_next_ul);
            $content_div->append_tag_to_content($limit_previous_next_div);
            # ------------------------------------------------------------------
            /*
             * The table.
             */
            $rows_html_table = new HTMLTags_Table();
            $rows_html_table->set_attribute_str('class', 'table_pages');
            /*
             * ----------------------------------------
             * The caption for the HTML table displaying the products.
             * ----------------------------------------
             */
            #if (isset($_GET['product_category_id'])) {
            #	if ($_GET['product_category_id'] == 'all') {
            #		$caption = new HTMLTags_Caption(
            #			'All Products'
            #		);
            #
            #		#$caption->append_str_to_content(' (' . $products_table->count_products() . ')');
            #	} else {
            #		$product_categories_table = $database->get_table('hpi_shop_product_categories');
            #		$product_category = $product_categories_table->get_row_by_id($_GET['product_category_id']);
            #		$caption = new HTMLTags_Caption(
            #			'Products in Category&nbsp;' . $product_category->get_name()
            #		);
            #
            #		#$caption->append_str_to_content(' (' . $product_category->count_products() . ')');
            #	}
            #} else {
            #	$caption = new HTMLTags_Caption(
            #		'All Products'
            #	);
            #
            #	#$caption->append_str_to_content(' (' . $products_table->count_products() . ')');
            #	$caption->append_str_to_content(" ($row_count)");
            #}
            #
            #$rows_html_table->append_tag_to_content($caption);
            $caption_str = '';
            if (isset($product_category_id)) {
                $product_categories_table = $database->get_table('hpi_shop_product_categories');
                $product_category = $product_categories_table->get_row_by_id($product_category_id);
                $caption_str .= 'Products in Category&nbsp;&quot;' . $product_category->get_name() . '&quot;';
            } else {
                $caption_str .= 'All Products';
            }
            if (isset($_GET['plu_code'])) {
                $caption_str .= ' with PLU code ' . $_GET['plu_code'];
            }
            if ($just_with_photos) {
                $caption_str .= ' with photos';
            }
            if ($just_displayed_products) {
                $caption_str .= ' on display';
            }
            $caption_str .= " ({$row_count})";
            $rows_html_table->append_tag_to_content(new HTMLTags_Caption($caption_str));
            /*
             * ----------------------------------------
             * The heading row of the HTML table that displays the products.
             * ----------------------------------------
             */
            $sort_href = clone $current_page_url;
            $sort_href->set_get_variable('limit', LIMIT);
            $sort_href->set_get_variable('offset', OFFSET);
            /*
             * Extra get vars if we've restricted the selection.
             */
            if (isset($product_category_id)) {
                $sort_href->set_get_variable('product_category_id', $product_category_id);
            }
            if ($just_displayed_products) {
                $sort_href->set_get_variable('just_displayed_products', 'yes');
            }
            if ($just_with_photos) {
                $sort_href->set_get_variable('just_with_photos', 'yes');
            }
            $heading_row = new Database_SortableHeadingTR($sort_href, DIRECTION);
            $plu_code_header = new HTMLTags_TH('PLU Code');
            $heading_row->append_tag_to_content($plu_code_header);
            $style_id_header = new HTMLTags_TH('Style ID');
            $heading_row->append_tag_to_content($style_id_header);
            $field_names = explode(' ', 'added name');
            foreach ($field_names as $field_name) {
                $heading_row->append_sortable_field_name($field_name);
            }
            $photograph_header = new HTMLTags_TH('Photograph');
            $heading_row->append_tag_to_content($photograph_header);
            $brand_header = new HTMLTags_TH('Brand');
            $heading_row->append_tag_to_content($brand_header);
            $product_category_id_header = new HTMLTags_TH('Product Category');
            $heading_row->append_tag_to_content($product_category_id_header);
            $price_header = new HTMLTags_TH('Price');
            $heading_row->append_tag_to_content($price_header);
            #$supplier_header = new HTMLTags_TH('Supplier');
            #$heading_row->append_tag_to_content($supplier_header);
            //        $comments_header = new HTMLTags_TH('Comments');
            //        $heading_row->append_tag_to_content($comments_header);
            $heading_row->append_tag_to_content(new HTMLTags_TH('Tags'));
            //                $heading_row->append_sortable_field_name('use_stock_level');
            //                $heading_row->append_sortable_field_name('stock_level');
            //                $heading_row->append_sortable_field_name('stock_buffer_level');
            #$heading_row->append_tag_to_content(new HTMLTags_TH('Stock (Buffer)'));
            #	$heading_row->append_sortable_field_name('sort_order');
            //                $heading_row->append_tag_to_content(new HTMLTags_TH('Principal Tags'));
            //                $heading_row->append_tag_to_content(new HTMLTags_TH('Tags'));
            //                $heading_row->append_tag_to_content(new HTMLTags_TH('Price'));
            $heading_row->append_sortable_field_name('status');
            $heading_row->append_tag_to_content(new HTMLTags_TH('Stock Level'));
            $heading_row->append_tag_to_content(new HTMLTags_TH('Edit'));
            //        foreach (
            //                $table_renderer->get_admin_database_action_ths()
            //                as
            //                $action_th
            //        ) {
            //                $heading_row->append_tag_to_content($action_th);
            //        }
            $rows_html_table->append_tag_to_content($heading_row);
            # ------------------------------------------------------------------
            #if (isset($_GET['product_category_id'])) {
            #	if ($_GET['product_category_id'] == 'all') {
            #		$rows = $products_table->get_all_rows(ORDER_BY, DIRECTION, OFFSET, LIMIT);
            #	} else {
            #		$conditions = array();
            #		$conditions['product_category_id'] = $_GET['product_category_id'];
            #		$rows = $products_table->get_rows_where($conditions, ORDER_BY, DIRECTION, OFFSET, LIMIT);
            #	}
            /*
             * ----------------------------------------
             * Fetch the products from the database table.
             * ----------------------------------------
             */
            $query = <<<SQL
SELECT
\thpi_shop_products.*
{$from_and_where_clauses}

SQL;
            /*
             * Can we do something about these defined constants.
             *
             * They're making me feel ill.
             */
            $order_by = ORDER_BY;
            $direction = DIRECTION;
            $offset = OFFSET;
            $limit = LIMIT;
            $query .= <<<SQL
ORDER BY
\t{$order_by} {$direction}
LIMIT
\t{$offset}, {$limit}
\t
SQL;
            #echo $query; exit;
            if (DEBUG) {
                echo DEBUG_DELIM_OPEN;
                echo 'Line: ' . __LINE__ . "\n";
                echo 'File: ' . __FILE__ . "\n";
                echo 'Class: ' . __CLASS__ . "\n";
                echo 'Method: ' . __METHOD__ . "\n";
                echo 'get_class($this): ' . get_class($this) . "\n";
                echo "\n";
                echo "\$query: \n{$query}\n";
                echo DEBUG_DELIM_CLOSE;
            }
            //                echo "data \$query: \n$query\n";
            $rows = $products_table->get_rows_for_select($query);
            /*
             * Display some of the contents of the table.
             */
            foreach ($rows as $row) {
                $row_renderer = $row->get_renderer();
                #$data_tr = $row_renderer->get_admin_database_tr();
                $data_tr = $row_renderer->get_admin_products_html_table_tr($current_page_url, $redirect_script_url);
                $rows_html_table->append_tag_to_content($data_tr);
            }
            # ------------------------------------------------------------------
            $content_div->append_tag_to_content($rows_html_table);
            $content_div->append_tag_to_content($limit_previous_next_div);
        }
        echo $content_div->get_as_string();
    }
        //                        $status_detail,
        //                        $vendor_tx_code,
        //                        $vps_tx_id,
        //                        $tx_auth_no,
        //                        $amount,
        //                        $avscv2,
        //                        $address_result,
        //                        $postcode_result,
        //                        $cv2_result,
        //                        $gift_aid,
        //                        $threedee_secure_status,
        //                        $cavv
        //                )
        $last_added_id = $transactions_table->add_transaction($session_id, $strStatus, $strStatusDetail, $strVendorTxCode, $strVPSTxId, $strTxAuthNo, $strAmount, $strAVSCV2, $strAddressResult, $strPostCodeResult, $strCV2Result, $strGiftAid, $str3DSecureStatus, $strCAVV);
    }
}
$content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.payment-confirmed'));
if ($log_in_manager->is_logged_in()) {
    /*
     * All Orders Div
     */
    $customer = $log_in_manager->get_user();
    $customer_renderer = $customer->get_renderer();
    $content_div->append_tag_to_content($customer_renderer->get_all_orders_div());
} else {
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.not-logged-in'));
}
/*
 * Print everything.
 */
echo $content_div->get_as_string();
        if (isset($_GET['tag'])) {
            $products_for_product_category_ul = $products_table_renderer->get_products_for_product_category_and_tag_ul_in_public($product_category_id, $_GET['tag']);
        } else {
            $products_for_product_category_ul = $products_table_renderer->get_products_for_product_category_ul_in_public($product_category_id);
        }
        $content_div->append_tag_to_content($products_for_product_category_ul);
    } else {
        $customer_regions_table = $database->get_table('hpi_shop_customer_regions');
        $customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']);
        $this_product_category_inactive_text = 'There are no&nbsp;';
        $this_product_category_inactive_text .= $product_category->get_name();
        $this_product_category_inactive_text .= '&nbsp;available in&nbsp;';
        $this_product_category_inactive_text .= $customer_region->get_name_with_the();
        $this_product_category_inactive_text .= '.';
        $this_product_category_inactive_p = new HTMLTags_P($this_product_category_inactive_text);
        $content_div->append_tag_to_content($this_product_category_inactive_p);
        $all_products_available_text = 'See all products available in&nbsp;';
        $all_products_available_text .= $customer_region->get_name_with_the();
        $all_products_link = new HTMLTags_A($all_products_available_text);
        $all_products_location = clone $current_page_url;
        $all_products_location->set_get_variable('page', 'products');
        $all_products_location->set_get_variable('customer_region_session', $customer_region->get_id());
        $all_products_link->set_href($all_products_location);
        $all_products_available_p = new HTMLTags_P();
        $all_products_available_p->append_tag_to_content($all_products_link);
        $content_div->append_tag_to_content($all_products_available_p);
    }
} elseif (!isset($_GET['product_category_id'])) {
    $content_div->append_str_to_content($page_manager->get_inc_file_as_string('body.div.product_category_id-missing'));
}
echo $content_div->get_as_string();
 public function get_order_description_div()
 {
     $order = $this->get_element();
     $customer = $order->get_customer();
     #$product = $order->get_product();
     $address = $customer->get_address();
     $description_div = new HTMLTags_Div();
     $description_div->set_attribute_str('class', 'details');
     $html = '<h3>Order #' . $order->get_id() . ':</h3><dl><dt>Customer:</dt><dd>' . $customer->get_first_name() . '&nbsp;' . $customer->get_last_name() . '</dd><dt>Address:</dt><dd>' . $address->get_street_address() . ',<br />' . $address->get_locality() . ',<br />' . $address->get_postal_code() . ',<br />' . $address->get_country_name() . '</dd><dt>Order received:</dt><dd>' . date('F j, Y, g:i a', strtotime($order->get_added())) . '</dd>' . '<dt>Transaction ref:</dt><dd>' . $order->get_txn_id() . '</dd></dl>';
     $description_div->append_str_to_content($html);
     return $description_div;
 }
    public function get_full_product_div_in_public()
    {
        $full_product_div = new HTMLTags_Div();
        $product = $this->get_element();
        $design_photograph = $product->get_design_photograph();
        $design_photograph_renderer = $design_photograph->get_renderer();
        $database = $product->get_database();
        $shopping_baskets_table = $database->get_table('hpi_shop_shopping_baskets');
        $hlisting_div = new HTMLTags_Div();
        $hlisting_div->set_attribute_str('id', 'single-product');
        $hlisting_div->set_attribute_str('class', 'hlisting offer-sale full-item');
        $hlisting_summary_div = new HTMLTags_Div();
        $hlisting_summary_div->set_attribute_str('class', 'summary');
        $hlisting_summary_div->append_str_to_content($product->get_name());
        $hlisting_div->append_tag_to_content($hlisting_summary_div);
        $hlisting_description_div = new HTMLTags_Div();
        $hlisting_description_div->set_attribute_str('class', 'description');
        $hlisting_images_div = new HTMLTags_Div();
        $hlisting_images_div->set_attribute_str('class', 'images');
        if (isset($_GET['thumbnail_photograph_id'])) {
            $photographs_table = $database->get_table('hpi_shop_photographs');
            $main_photograph = $photographs_table->get_row_by_id($_GET['thumbnail_photograph_id']);
        } else {
            $main_photograph = $product->get_main_photograph();
        }
        $main_photograph_renderer = $main_photograph->get_renderer();
        $main_img = $main_photograph_renderer->get_full_size_img();
        $hlisting_images_div->append_tag_to_content($main_img);
        $thumbnail_div = $this->get_extras_thumbnail_div($main_photograph);
        $hlisting_images_div->append_tag_to_content($thumbnail_div);
        $design_img = $design_photograph_renderer->get_full_size_img();
        $hlisting_images_div->append_tag_to_content($design_img);
        $hlisting_description_div->append_tag_to_content($hlisting_images_div);
        //                $hlisting_description_p = new HTMLTags_P($product->get_description());
        //                $hlisting_description_div->append_tag_to_content($hlisting_description_p);
        $hlisting_description_div->append_str_to_content($product->get_description());
        $hlisting_div->append_tag_to_content($hlisting_description_div);
        $product_details_ul = $this->get_product_details_ul();
        $product_details_div = new HTMLTags_Div();
        $product_details_div->set_attribute_str('class', 'details');
        $product_details_div->append_tag_to_content($product_details_ul);
        // CHECK TO SEE IF PRODUCT IS IN SHOPPING BASKET
        $shopping_basket_already_exists = $shopping_baskets_table->check_for_product_in_current_session($product->get_id(), session_id());
        if ($shopping_basket_already_exists) {
            $conditions['product_id'] = $product->get_id();
            $conditions['session_id'] = "'" . session_id() . "'";
            $conditions['deleted'] = 'no';
            $conditions['moved_to_orders'] = 'no';
            $shopping_basket_row = $shopping_baskets_table->get_rows_where($conditions);
            //print_r($shopping_basket_row);
            $previous_quantity = $shopping_basket_row[0]->get_quantity();
            $previous_purchase_p = new HTMLTags_P();
            $previous_purchase_p->set_attribute_str('class', 'previous-purchase');
            $previous_purchase_text = <<<TXT
You already have&nbsp;
TXT;
            $previous_purchase_text .= $shopping_basket_row[0]->get_quantity();
            $previous_purchase_text .= <<<TXT
&nbsp;of these in your Shopping Basket.
TXT;
            $previous_purchase_p->append_str_to_content($previous_purchase_text);
            $product_details_div->append_tag_to_content($previous_purchase_p);
        } else {
        }
        if ($product->is_active() && !$product->is_out_of_stock()) {
            //Link to ADD TO BASKET
            $add_to_basket_link = $this->get_add_to_shopping_basket_link();
            $add_to_basket_link_p = new HTMLTags_P();
            $add_to_basket_link_p->set_attribute_str('class', 'options');
            $add_to_basket_link_p->append_tag_to_content($add_to_basket_link);
            $product_details_div->append_tag_to_content($add_to_basket_link_p);
        } else {
            if ($product->is_out_of_stock()) {
                $other_products_link = new HTMLTags_A();
                $other_products_link->append_str_to_content('See other products');
                $other_products_location = new HTMLTags_URL();
                $other_products_location->set_file('/');
                $other_products_location->set_get_variable('section', 'plug-ins');
                $other_products_location->set_get_variable('module', 'shop');
                $other_products_location->set_get_variable('page', 'products');
                $other_products_location->set_get_variable('type', 'html');
                $other_products_link->set_href($other_products_location);
                $other_products_available_p = new HTMLTags_P();
                $other_products_available_p->append_tag_to_content($other_products_link);
                $product_details_div->append_tag_to_content($other_products_available_p);
            } else {
                $customer_regions_table = $database->get_table('hpi_shop_customer_regions');
                $customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']);
                $product_not_available_p = new HTMLTags_P();
                $product_not_available_p->append_str_to_content('This product is not available in&nbsp;');
                $product_not_available_p->append_str_to_content($customer_region->get_name_with_the());
                $product_not_available_p->append_str_to_content('.');
                $product_details_div->append_tag_to_content($product_not_available_p);
                $product_category = $product->get_product_category();
                if ($product_category->is_active()) {
                    $other_products_in_category_link = new HTMLTags_A();
                    $other_products_in_category_link->append_str_to_content('See other&nbsp;' . $product_category->get_name() . '&nbsp;available in&nbsp;' . $customer_region->get_name_with_the());
                    $other_products_in_category_location = new HTMLTags_URL();
                    $other_products_in_category_location->set_file('/');
                    $other_products_in_category_location->set_get_variable('section', 'plug-ins');
                    $other_products_in_category_location->set_get_variable('module', 'shop');
                    $other_products_in_category_location->set_get_variable('page', 'product-category');
                    $other_products_in_category_location->set_get_variable('type', 'html');
                    $other_products_in_category_location->set_get_variable('product_category_id', $product_category->get_id());
                    $other_products_in_category_link->set_href($other_products_in_category_location);
                    $other_products_available_p = new HTMLTags_P();
                    $other_products_available_p->append_tag_to_content($other_products_in_category_link);
                    $product_details_div->append_tag_to_content($other_products_available_p);
                } else {
                    $all_products_in_region_link = new HTMLTags_A();
                    $all_products_in_region_link->append_str_to_content('See other products available in&nbsp;' . $customer_region->get_name_with_the());
                    $all_products_in_region_location = new HTMLTags_URL();
                    $all_products_in_region_location->set_file('/');
                    $all_products_in_region_location->set_get_variable('section', 'plug-ins');
                    $all_products_in_region_location->set_get_variable('module', 'shop');
                    $all_products_in_region_location->set_get_variable('page', 'products');
                    $all_products_in_region_location->set_get_variable('type', 'html');
                    $all_products_in_region_location->set_get_variable('page', 'products');
                    $all_products_in_region_location->set_get_variable('customer_region_session', $customer_region->get_id());
                    $all_products_in_region_link->set_href($all_products_in_region_location);
                    $other_products_available_p = new HTMLTags_P();
                    $other_products_available_p->append_tag_to_content($all_products_in_region_link);
                    $product_details_div->append_tag_to_content($other_products_available_p);
                }
            }
        }
        $hlisting_div->append_tag_to_content($product_details_div);
        $full_product_div->append_tag_to_content($hlisting_div);
        return $full_product_div;
    }