public function get_active_product_categories_ul_in_public()
 {
     $product_categories_table = $this->get_element();
     $product_categories = $product_categories_table->get_active_product_categories();
     $product_categories_ul = new HTMLTags_UL();
     foreach ($product_categories as $product_category) {
         $product_category_renderer = $product_category->get_renderer();
         $product_categories_ul->append_tag_to_content($product_category_renderer->get_product_category_li_in_public());
     }
     return $product_categories_ul;
 }
 protected function render_top_links_ul()
 {
     $page_options_div = new HTMLTags_Div();
     $page_options_div->set_attribute_str('id', 'page-options');
     $other_pages_ul = new HTMLTags_UL();
     foreach ($this->get_top_links_as() as $a) {
         $li = new HTMLTags_LI();
         $li->append_tag_to_content($a);
         $other_pages_ul->append_tag_to_content($li);
     }
     $page_options_div->append_tag_to_content($other_pages_ul);
     echo $page_options_div->get_as_string();
 }
 public function get_short_address_ul()
 {
     $address = $this->get_element();
     $address_ul = new HTMLTags_UL($address_text);
     if ($address->has_post_office_box()) {
         $p_o_li = new HTMLTags_LI($address->get_post_office_box());
         $address_ul->append_tag_to_content($p_o_li);
     }
     if ($address->has_extended_address()) {
         $extended_address_li = new HTMLTags_LI($address->get_extended_address());
         $address_ul->append_tag_to_content($extended_address_li);
     }
     $address_ul->append_tag_to_content(new HTMLTags_LI($address->get_street_address()));
     $address_ul->append_tag_to_content(new HTMLTags_LI($address->get_locality()));
     $address_ul->append_tag_to_content(new HTMLTags_LI($address->get_region()));
     $address_ul->append_tag_to_content(new HTMLTags_LI($address->get_postal_code()));
     $address_ul->append_tag_to_content(new HTMLTags_LI($address->get_country_name()));
     return $address_ul;
 }
    /**
     * The purpose of this div is to tell the customer which
     * the stage of the checkout process they have reached.
     *
     * A short explanation of the stage is also given.
     */
    public function get_checkout_status_div()
    {
        // accounts >> shipping-details >> payment-options
        $checkout_status = $this->get_checkout_status();
        #echo $checkout_status; exit;
        $checkout_status_div = new HTMLTags_Div();
        $checkout_status_div->set_attribute_str('id', 'checkout_status_div');
        $checkout_status_ul = new HTMLTags_UL();
        switch ($checkout_status) {
            case 'accounts':
                $status_step_one_li = new HTMLTags_LI();
                $status_step_one_li->append_tag_to_content(new HTMLTags_Em('Log In'));
                $checkout_status_ul->append_tag_to_content($status_step_one_li);
                $status_step_two_li = new HTMLTags_LI();
                $status_step_two_li->append_str_to_content('Shipping Details');
                $checkout_status_ul->append_tag_to_content($status_step_two_li);
                $status_step_three_li = new HTMLTags_LI();
                $status_step_three_li->append_str_to_content('Go to Secure Server');
                $checkout_status_ul->append_tag_to_content($status_step_three_li);
                $p_text = <<<TXT
Please complete this form and create an account with us.
Alternatively, log in with your existing email address and password.
TXT;
                break;
            case 'shipping-details':
                $status_step_one_li = new HTMLTags_LI();
                $status_step_one_li->append_str_to_content('Log In');
                $checkout_status_ul->append_tag_to_content($status_step_one_li);
                $status_step_two_li = new HTMLTags_LI();
                $status_step_two_li->append_tag_to_content(new HTMLTags_Em('Shipping Details'));
                $checkout_status_ul->append_tag_to_content($status_step_two_li);
                $status_step_three_li = new HTMLTags_LI();
                $status_step_three_li->append_str_to_content('Go to Secure Server');
                $checkout_status_ul->append_tag_to_content($status_step_three_li);
                $p_text = <<<TXT
Please enter or confirm your shipping address, this must be the same as your billing address. 
TXT;
                break;
            case 'payment-options':
                $status_step_one_li = new HTMLTags_LI();
                $status_step_one_li->append_str_to_content('Log In');
                $checkout_status_ul->append_tag_to_content($status_step_one_li);
                $status_step_two_li = new HTMLTags_LI();
                $status_step_two_li->append_str_to_content('Shipping Details');
                $checkout_status_ul->append_tag_to_content($status_step_two_li);
                $status_step_three_li = new HTMLTags_LI();
                $status_step_three_li->append_tag_to_content(new HTMLTags_Em('Go to Secure Server'));
                $checkout_status_ul->append_tag_to_content($status_step_three_li);
                $p_text = <<<TXT
Check your shipping details and shopping basket.
TXT;
                $p2_text = <<<TXT
When you're happy, click the button below to be 
transfered to a secure server where you 
can enter your credit card details to complete the payment.
TXT;
                break;
        }
        $checkout_status_div->append_tag_to_content($checkout_status_ul);
        $checkout_status_div->append_tag_to_content(new HTMLTags_P($p_text));
        if (isset($p2_text)) {
            $checkout_status_div->append_tag_to_content(new HTMLTags_P($p2_text));
        }
        return $checkout_status_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 Customer');
 $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 Customer');
 $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);
 ####################################################################
 #
 # Display some of the data in the table.
    public function get_widget_content()
    {
        $mysql_user_factory = Database_MySQLUserFactory::get_instance();
        $mysql_user = $mysql_user_factory->get_for_this_project();
        $database = $mysql_user->get_database();
        $people_table = $database->get_table('hpi_mailing_list_people');
        $widget_div = new HTMLTags_Div();
        $rows_html_ul = new HTMLTags_UL();
        $rows_html_ul->set_attribute_str('class', 'people');
        $query = <<<SQL
SELECT *
FROM hpi_mailing_list_people
WHERE status = 'new' OR status = 'accepted'
ORDER BY `added` DESC
LIMIT 0, 5
SQL;
        try {
            $rows = $people_table->get_rows_for_select($query);
        } catch (Exception $e) {
        }
        if (count($rows) > 0) {
            $explanation_p = new HTMLTags_P();
            $explanation_txt = <<<TXT
The last five people to join the list:
TXT;
            $explanation_p->append($explanation_txt);
            $widget_div->append($explanation_p);
            foreach ($rows as $row) {
                $li = new HTMLTags_LI();
                $li->append_str_to_content($row->get_name() . '&nbsp;(' . $row->get_email() . ')');
                $rows_html_ul->append_tag_to_content($li);
            }
        } else {
            $no_people_p = new HTMLTags_P();
            $no_people_txt = <<<TXT
There are no people in the Mailing List.
TXT;
            $no_people_p->append($no_people_txt);
            $widget_div->append($no_people_p);
        }
        $widget_div->append_tag_to_content($rows_html_ul);
        $widget_div->append(self::get_mailing_list_links_ul());
        return $widget_div;
    }
    $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 refresh page.
 */
$refresh_page_li = new HTMLTags_LI();
$refresh_page_a = new HTMLTags_A('Check for new transactions');
$refresh_page_a->set_href($current_page_url);
$refresh_page_li->append_tag_to_content($refresh_page_a);
$other_pages_ul->append_tag_to_content($refresh_page_li);
$page_options_div->append_tag_to_content($other_pages_ul);
$content_div->append_tag_to_content($page_options_div);
####################################################################
#
# Display some of the data in the table.
#
####################################################################
$actions_method_args[] = $current_page_url;
$selection_div = $table_renderer->get_admin_database_selection_html_table(ORDER_BY, DIRECTION, OFFSET, LIMIT, $current_page_url, 'added order_id txn_id payment_status payment_amount payment_shipping receiver_email payer_email', 'Transactions');
//        $selection_div
//            = $table_renderer
//		->get_admin_transactions_selection_html_table(
//			DIRECTION,
//			ORDER_BY,
//			LIMIT,
$label_email->set_attribute_str('for', 'email');
$li_email->append_tag_to_content($label_email);
//	<input class="email" name="email" type="text" id="name" value="
$input_email = new HTMLTags_Input();
$input_email->set_attribute_str('id', 'email');
$input_email->set_attribute_str('name', 'email');
$input_email->set_attribute_str('type', 'text');
//    if ($_SESSION['email']) {
//        echo $_SESSION['email'];
//    }
$input_email->set_attribute_str('value', isset($_SESSION['email']) ? $_SESSION['email'] : '');
//" size="17" />
#$input_email->set_attribute_str('size', 17);
//        <br>
$li_email->append_tag_to_content($input_email);
$ul_inputs->append_tag_to_content($li_email);
if (isset($_GET['email_incorrect'])) {
    $li_force_email = new HTMLTags_LI();
    //<label for="force_email">Force email:</label>
    $label_force_email = new HTMLTags_Label('Force email: ');
    $label_force_email->set_attribute_str('for', 'force_email');
    $li_force_email->append_tag_to_content($label_force_email);
    //<input
    //    id="force_email"
    //    name="force_email"
    //    type="checkbox"
    ///>
    $input_force_email = new HTMLTags_Input();
    $input_force_email->set_attribute_str('id', 'force_email');
    $input_force_email->set_attribute_str('name', 'force_email');
    $input_force_email->set_attribute_str('type', 'checkbox');
$database = $mysql_user->get_database();
$customer_regions_table = $database->get_table('hpi_shop_customer_regions');
$customer_regions = $customer_regions_table->get_all_rows('sort_order', 'ASC');
$customer_regions_div = new HTMLTags_Div();
$customer_regions_div->set_attribute_str('id', 'tabs');
$customer_regions_ul = new HTMLTags_UL();
foreach ($customer_regions as $customer_region) {
    $customer_region_li = new HTMLTags_LI();
    $customer_region_link_span = new HTMLTags_Span($customer_region->get_name());
    if ($customer_region->get_id() == $_SESSION['customer_region_id']) {
        $double_span = new HTMLTags_Span();
        $double_span->set_attribute_str('class', 'current');
        $double_span->append_tag_to_content($customer_region_link_span);
        $customer_region_li->append_tag_to_content($double_span);
    } else {
        //$customer_region_link_file = '/';
        //$customer_region_link_location = new HTMLTags_URL();
        //$customer_region_link_location->set_file($customer_region_link_file);
        //$customer_region_link_location->set_get_variable('page', $page_manager->get_page());
        $customer_region_link_location = $page_manager->get_script_uri();
        $customer_region_link_location->set_get_variable('customer_region_session', $customer_region->get_id());
        $customer_region_link_anchor = new HTMLTags_A();
        $customer_region_link_anchor->set_href($customer_region_link_location);
        $customer_region_link_anchor->set_attribute_str('title', 'Change your location to&nbsp;' . $customer_region->get_name());
        $customer_region_link_anchor->append_tag_to_content($customer_region_link_span);
        $customer_region_li->append_tag_to_content($customer_region_link_anchor);
    }
    $customer_regions_ul->append_tag_to_content($customer_region_li);
}
$customer_regions_div->append_tag_to_content($customer_regions_ul);
echo $customer_regions_div->get_as_string();
 public function get_share_links_ul_in_public()
 {
     $share_links_ul = new HTMLTags_UL();
     $share_product_link = new HTMLTags_A('Spread the word!');
     $share_product_location = $this->get_product_page_url();
     $share_product_location->set_get_variable('share_product', '1');
     $share_product_link->set_href($share_product_location);
     $share_product_li = new HTMLTags_LI();
     $share_product_li->append_tag_to_content($share_product_link);
     $share_links_ul->append_tag_to_content($share_product_li);
     return $share_links_ul;
 }
 /**
  * This takes a space separated list of tags and returns
  * a UL containing the products that have been tagged that way.
  *
  * For example, products that should be displayed on the front page
  * might get tagged 'front_page'.
  */
 public function get_products_for_product_tags_ul_in_public($product_tags_space_separated_str)
 {
     $products_table = $this->get_element();
     $database = $products_table->get_database();
     $product_tags_table = $database->get_table('hpi_shop_product_tags');
     $already_displayed_products = array();
     $products_ul = new HTMLTags_UL();
     $products_ul->set_attribute_str('id', 'products');
     $product_tags_strs = $products_table->explode_tags($product_tags_space_separated_str);
     #print_r($product_tags_strs); exit;
     foreach ($product_tags_strs as $product_tag_str) {
         $conditions['tag'] = $product_tag_str;
         $product_tags = array();
         $product_tags = $product_tags_table->get_rows_where($conditions);
         #print_r($product_tags); exit;
         if (count($product_tags) > 0) {
             $products = $product_tags[0]->get_product_rows();
             #print_r($products); exit;
             foreach ($products as $product) {
                 if ($product->is_active()) {
                     $already_displayed = FALSE;
                     foreach ($already_displayed_products as $already_displayed_product) {
                         if ($product->get_id() == $already_displayed_product->get_id() || $product->get_style_id() == $already_displayed_product->get_style_id()) {
                             $already_displayed = TRUE;
                         }
                     }
                     if ($already_displayed == FALSE) {
                         $product_renderer = $product->get_renderer();
                         $product_description_li = $product_renderer->get_product_description_li();
                         $product_description_li->set_attribute_str('id', 'product');
                         $products_ul->append_tag_to_content($product_description_li);
                         $already_displayed_products[] = $product;
                     }
                 } else {
                     #echo "Inactive\n";
                 }
             }
             #exit;
         }
     }
     return $products_ul;
 }
 public static function get_latest_frames_div()
 {
     /*
      * This is a bad idea really, cos you shouldnt just show everyone's
      * frames regardless of who owns them, just for now
      */
     $div = new HTMLTags_Div();
     $div->set_attribute_str('class', 'frame_thumbnail_list');
     $heading = new HTMLTags_Heading(3, 'Latest Frames');
     $div->append_tag_to_content($heading);
     $ul = new HTMLTags_UL();
     $frames = Oedipus_FrameHelper::get_latest_option_frames(4);
     foreach ($frames as $frame) {
         $li = new HTMLTags_LI();
         $a = Oedipus_FrameImageHelper::get_frame_png_thumbnail_img_a($frame);
         $li->append_tag_to_content($a);
         $ul->append_tag_to_content($li);
     }
     $div->append_tag_to_content($ul);
     return $div;
 }
 public function get_shopping_basket_checkout_links_ul()
 {
     $shopping_baskets_table = $this->get_element();
     $product_links_ul = new HTMLTags_UL();
     $product_links_ul->set_attribute_str('id', 'shopping-basket-ul');
     $all_products_link = new HTMLTags_A('Continue Shopping');
     $all_products_location = new HTMLTags_URL();
     $all_products_location->set_file('/hpi/shop/products.html');
     $all_products_link->set_href($all_products_location);
     $all_products_li = new HTMLTags_LI();
     $all_products_li->set_attribute_str('class', 'all-products');
     $all_products_li->append_tag_to_content($all_products_link);
     $product_links_ul->append_tag_to_content($all_products_li);
     if ($shopping_baskets_table->check_for_current_session_in_shopping_baskets()) {
         $checkout_link = new HTMLTags_A();
         $checkout_link->append_tag_to_content(new HTMLTags_Span('Checkout'));
         $checkout_location = new HTMLTags_URL();
         $checkout_location->set_file('/hpi/shop/checkout.html');
         $checkout_link->set_href($checkout_location);
         $checkout_li = new HTMLTags_LI();
         $checkout_li->set_attribute_str('class', 'checkout');
         $checkout_li->append_tag_to_content($checkout_link);
         $product_links_ul->append_tag_to_content($checkout_li);
     }
     return $product_links_ul;
 }
 /**
  * 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 Brand');
 $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 Photographs');
 #
 #$delete_all_href = new HTMLTags_URL();
 #
 #$delete_all_href->set_file('/admin/index.php');
 #
 #$delete_all_href->set_get_variable('module', 'shop');
 #$delete_all_href->set_get_variable('page', 'product_brands');
 #$delete_all_href->set_get_variable('delete_all');
 #
 public static function render_body_form_add_email()
 {
     $form_email_adding = new HTMLTags_Form();
     /*
      * Form altered by RFI 2007-07-13
      */
     #$form_action = new HTMLTags_URL();
     #
     #$form_action->set_file('/');
     #
     #$form_action->set_get_variable('section', 'plug-ins');
     #$form_action->set_get_variable('module', 'mailing-list');
     #$form_action->set_get_variable('page', 'sign-up');
     #$form_action->set_get_variable('type', 'redirect-script');
     #$form_action->set_get_variable('add_person');
     #$form_action->set_get_variable('return_to', urlencode('/?section=project-specific&page=sign-up'));
     $form_action = MailingList_SignUpURLFactory::get_email_adding_redirect_script();
     #echo 'action="' . $form_action->get_as_string() . "\"\n";
     $form_email_adding->set_action($form_action);
     $form_email_adding->set_attribute_str('method', 'POST');
     //    method="POST"
     //>
     $ul_inputs = new HTMLTags_UL();
     $li_name = new HTMLTags_LI();
     //        <label for="name">Name:</label>
     $label_name = new HTMLTags_Label('Name: ');
     $label_name->set_attribute_str('for', 'name');
     $li_name->append_tag_to_content($label_name);
     //	<input class="name" name="name" type="text" id="name" value="
     $input_name = new HTMLTags_Input();
     $input_name->set_attribute_str('id', 'name');
     $input_name->set_attribute_str('name', 'name');
     $input_name->set_attribute_str('type', 'text');
     //    if ($_SESSION['name']) {
     //        echo $_SESSION['name'];
     //    }
     $input_name->set_attribute_str('value', isset($_SESSION['name']) ? $_SESSION['name'] : '');
     //" size="17" />
     #$input_name->set_attribute_str('size', 17);
     //        <br />
     $li_name->append_tag_to_content($input_name);
     $ul_inputs->add_li($li_name);
     //
     $li_email = new HTMLTags_LI();
     //	<label for="name">Email:</label>
     $label_email = new HTMLTags_Label('Email: ');
     $label_email->set_attribute_str('for', 'email');
     $li_email->append_tag_to_content($label_email);
     //	<input class="email" name="email" type="text" id="name" value="
     $input_email = new HTMLTags_Input();
     $input_email->set_attribute_str('id', 'email');
     $input_email->set_attribute_str('name', 'email');
     $input_email->set_attribute_str('type', 'text');
     //    if ($_SESSION['email']) {
     //        echo $_SESSION['email'];
     //    }
     $input_email->set_attribute_str('value', isset($_SESSION['email']) ? $_SESSION['email'] : '');
     //" size="17" />
     #$input_email->set_attribute_str('size', 17);
     //        <br>
     $li_email->append_tag_to_content($input_email);
     $ul_inputs->append_tag_to_content($li_email);
     if (isset($_GET['email_incorrect'])) {
         $li_force_email = new HTMLTags_LI();
         //<label for="force_email">Force email:</label>
         $label_force_email = new HTMLTags_Label('Force email: ');
         $label_force_email->set_attribute_str('for', 'force_email');
         $li_force_email->append_tag_to_content($label_force_email);
         //<input
         //    id="force_email"
         //    name="force_email"
         //    type="checkbox"
         ///>
         $input_force_email = new HTMLTags_Input();
         $input_force_email->set_attribute_str('id', 'force_email');
         $input_force_email->set_attribute_str('name', 'force_email');
         $input_force_email->set_attribute_str('type', 'checkbox');
         $li_force_email->append_tag_to_content($input_force_email);
         //<br>
         $ul_inputs->append_tag_to_content($li_force_email);
     }
     $form_email_adding->append_tag_to_content($ul_inputs);
     $li_submit = new HTMLTags_LI();
     #    <input class="submit" type="submit" name="Submit" value="Submit">
     $input_submit = new HTMLTags_Input();
     $input_submit->set_attribute_str('id', 'submit');
     $input_submit->set_attribute_str('name', 'submit');
     $input_submit->set_attribute_str('class', 'submit');
     $input_submit->set_attribute_str('type', 'submit');
     $input_submit->set_attribute_str('value', 'Submit');
     $li_submit->append_tag_to_content($input_submit);
     $ul_inputs->append_tag_to_content($li_submit);
     //</form>
     echo $form_email_adding->get_as_string();
 }
 public function get_customer_region_selection_div()
 {
     $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();
     #$customer_regions_table = $database->get_table('hpi_shop_customer_regions');
     $customer_regions_table = $this->get_element();
     $customer_regions = $customer_regions_table->get_all_rows('sort_order', 'ASC');
     $customer_regions_div = new HTMLTags_Div();
     $customer_regions_div->set_attribute_str('id', 'tabs');
     $customer_regions_ul = new HTMLTags_UL();
     foreach ($customer_regions as $customer_region) {
         $customer_region_li = new HTMLTags_LI();
         $customer_region_link_span = new HTMLTags_Span($customer_region->get_name());
         if ($customer_region->get_id() == $_SESSION['customer_region_id']) {
             $double_span = new HTMLTags_Span();
             $double_span->set_attribute_str('class', 'current');
             $double_span->append_tag_to_content($customer_region_link_span);
             $customer_region_li->append_tag_to_content($double_span);
         } else {
             //$customer_region_link_file = '/';
             //$customer_region_link_location = new HTMLTags_URL();
             //$customer_region_link_location->set_file($customer_region_link_file);
             //$customer_region_link_location->set_get_variable('page', $page_manager->get_page());
             $redirect_script_location = PublicHTML_PublicURLFactory::get_url('plug-ins', 'shop', 'customer-region', 'redirect-script');
             $redirect_script_location->set_get_variable('customer_region_session', $customer_region->get_id());
             $desired_location = $page_manager->get_script_uri();
             if (isset($_GET['product_id'])) {
                 $desired_location->set_get_variable('product_id', $_GET['product_id']);
             }
             if (isset($_GET['product_category_id'])) {
                 $desired_location->set_get_variable('product_category_id', $_GET['product_category_id']);
             }
             $redirect_script_location->set_get_variable('desired_location', urlencode($desired_location->get_as_string()));
             $customer_region_link_anchor = new HTMLTags_A();
             $customer_region_link_anchor->set_href($redirect_script_location);
             $customer_region_link_anchor->set_attribute_str('title', 'Change your location to&nbsp;' . $customer_region->get_name());
             $customer_region_link_anchor->append_tag_to_content($customer_region_link_span);
             $customer_region_li->append_tag_to_content($customer_region_link_anchor);
         }
         $customer_regions_ul->append_tag_to_content($customer_region_li);
     }
     $customer_regions_div->append_tag_to_content($customer_regions_ul);
     #echo $customer_regions_div->get_as_string();
     return $customer_regions_div;
 }
    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();
    }
 /**
  * Allows the customer to search for products by reducing the search
  * criteria using select drop-downs.
  *
  * Used in:
  * 	- The secondary navigation div.
  *
  * Changes:
  * 	- RFI 2007-12-13
  * 		Instead of going to separate pages for product categories and tags,
  * 		the customer is taken to the products page where the selection criteria
  * 		for products is constrained appropriately.
  */
 public function get_public_tag_selection_div()
 {
     $product_tag = $this->get_element();
     $tag = $product_tag->get_tag();
     $div = new HTMLTags_Div();
     $div->set_attribute_str('id', $tag);
     $div->set_attribute_str('class', 'tag-selection');
     $heading = new HTMLTags_Heading(3, ucfirst($tag));
     $tag_link_href = new HTMLTags_URL();
     $tag_link_file = '/?section=plug-ins&module=shop&page=products&type=html&tag=' . $tag;
     $tag_link_href->set_file($tag_link_file);
     $tag_link = new HTMLTags_A();
     $tag_link->set_href($tag_link_href);
     $tag_link->append_tag_to_content($heading);
     $div->append_tag_to_content($tag_link);
     /*
      * Brand Select Form
      */
     $brand_form = new MashShop_TagSelectionForm();
     $brand_form->set_attribute_str('id', 'brand');
     #$brand_form->add_hidden_input('section', 'plug-ins');
     #$brand_form->add_hidden_input('module', 'shop');
     #$brand_form->add_hidden_input('page', 'product-brand');
     #$brand_form->add_hidden_input('type', 'html');
     $brand_form = self::add_hidden_inputs_for_results_page_get_vars_to_tag_selection_form($brand_form);
     $brand_form->add_hidden_input('tag', $tag);
     $brand_action = new HTMLTags_URL();
     $brand_action->set_file('/');
     $brand_form->set_action($brand_action);
     $brand_form->set_attribute_str('name', 'brand');
     $brand_form->set_attribute_str('method', 'GET');
     $form_ul = new HTMLTags_UL();
     $brand_li = new HTMLTags_LI();
     $brand_label = new HTMLTags_Label('Brands:');
     $brand_label->set_attribute_str('for', 'product_brand_id');
     $brand_li->append_tag_to_content($brand_label);
     $brand_select_box = $this->get_brand_select();
     $brand_li->append_tag_to_content($brand_select_box);
     $form_ul->append_tag_to_content($brand_li);
     $submit_button = new HTMLTags_Input();
     $submit_button->set_attribute_str('type', 'submit');
     $submit_button->set_attribute_str('value', 'Go');
     $submit_button->set_attribute_str('class', 'submit');
     $submit_li = new HTMLTags_LI();
     $submit_li->append_tag_to_content($submit_button);
     $form_ul->append_tag_to_content($submit_li);
     $brand_form->append_tag_to_content($form_ul);
     $div->append_tag_to_content($brand_form);
     $clear_div = new HTMLTags_Div();
     $clear_div->set_attribute_str('style', 'clear:both;');
     $div->append_tag_to_content($clear_div);
     /*
      * category Select Form
      */
     $category_form = new MashShop_TagSelectionForm();
     $category_form->set_attribute_str('id', 'category');
     #$category_form->add_hidden_input('section', 'plug-ins');
     #$category_form->add_hidden_input('module', 'shop');
     #$category_form->add_hidden_input('page', 'product-category');
     #$category_form->add_hidden_input('type', 'html');
     $category_form = self::add_hidden_inputs_for_results_page_get_vars_to_tag_selection_form($category_form);
     $category_form->add_hidden_input('tag', $tag);
     $category_action = new HTMLTags_URL();
     $category_action->set_file('/');
     $category_form->set_action($category_action);
     $category_form->set_attribute_str('name', 'category');
     $category_form->set_attribute_str('method', 'GET');
     $form_ul = new HTMLTags_UL();
     $category_li = new HTMLTags_LI();
     $category_label = new HTMLTags_Label('Products:');
     $category_label->set_attribute_str('for', 'product_category_id');
     $category_li->append_tag_to_content($category_label);
     $category_select_box = $this->get_category_select();
     $category_li->append_tag_to_content($category_select_box);
     $form_ul->append_tag_to_content($category_li);
     $submit_button = new HTMLTags_Input();
     $submit_button->set_attribute_str('type', 'submit');
     $submit_button->set_attribute_str('value', 'Go');
     $submit_button->set_attribute_str('class', 'submit');
     $submit_li = new HTMLTags_LI();
     $submit_li->append_tag_to_content($submit_button);
     $form_ul->append_tag_to_content($submit_li);
     $category_form->append_tag_to_content($form_ul);
     $div->append_tag_to_content($category_form);
     $div->append_tag_to_content($clear_div);
     return $div;
 }
<?php

/**
 * A div that is displayed if the customer is trying to go to the checkout with no shopping basket.
 *
 * @copyright Clear Line Web Design, 2007-08-21
 */
$no_shopping_basket_div = new HTMLTags_Div();
$p_text = <<<TXT
I'm sorry, you have no shopping basket yet. Why are you trying to Checkout?
TXT;
$product_links_ul = new HTMLTags_UL();
$product_links_ul->set_attribute_str('id', 'shopping-basket-ul');
$all_products_link = new HTMLTags_A('See All Products');
$all_products_location = new HTMLTags_URL();
$all_products_location->set_file('/hpi/shop/products.html');
$all_products_link->set_href($all_products_location);
$all_products_li = new HTMLTags_LI();
$all_products_li->set_attribute_str('class', 'all-products');
$all_products_li->append_tag_to_content($all_products_link);
$product_links_ul->append_tag_to_content($all_products_li);
$no_shopping_basket_div->append_tag_to_content(new HTMLTags_P($p_text));
$no_shopping_basket_div->append_tag_to_content($product_links_ul);
echo $no_shopping_basket_div->get_as_string();
 /**
  * Renders a UL that contains links to other pages
  * to do with this one.
  * e.g. the 'delete_everything' version of this page.
  */
 protected function render_other_pages_ul()
 {
     $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($this->get_add_something_link_text());
     $add_row_href = $this->get_add_something_page_url();
     $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($this->get_delete_everything_link_text());
     $delete_all_href = $this->get_current_base_url();
     $delete_all_href->set_get_variable('content', 'delete_everything');
     $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);
     echo $page_options_div->get_as_string();
 }
$checkout_li->append_tag_to_content($checkout_link);
$product_links_ul->append_tag_to_content($checkout_li);
$shopping_desc_div->append_tag_to_content($product_links_ul);
$navigation_div->append_tag_to_content($shopping_desc_div);
###########################################
# Navigation Links
###########################################
###########################################
# Links UL
###########################################
$pages_ul = new HTMLTags_UL();
$pages_ul->set_attribute_str('id', 'navigation-ul');
foreach ($pages as $page) {
    $page_li = new HTMLTags_LI();
    if ($page['name'] == $page_manager->get_page() || $page['name'] == $_GET['page']) {
        $page_link_span = new HTMLTags_Span('&nbsp;' . $page['text']);
        $page_li->append_tag_to_content($page_link_span);
    } else {
        $page_link_file = '/' . $page['name'] . '.html';
        $page_link_location = new HTMLTags_URL();
        $page_link_location->set_file($page_link_file);
        $page_link_anchor = new HTMLTags_A();
        $page_link_anchor->set_href($page_link_location);
        $page_link_anchor->set_attribute_str('title', $page['title']);
        $page_link_anchor->append_str_to_content($page['text']);
        $page_li->append_tag_to_content($page_link_anchor);
    }
    $pages_ul->append_tag_to_content($page_li);
}
$navigation_div->append_tag_to_content($pages_ul);
echo $navigation_div;
<?php

/**
 * A div that is displayed if the customer is already logged into a shop.
 *
 * @copyright Clear Line Web Design, 2007-08-21
 */
$checkout_process_div = new HTMLTags_Div();
$checkout_process_div->set_attribute_str('id', 'checkout_process_div');
$checkout_process_ul = new HTMLTags_UL();
$process_step_one_li = new HTMLTags_LI();
$process_step_one_li->append_tag_to_content(new HTMLTags_Em('Step 1'));
$checkout_process_ul->append_tag_to_content($process_step_one_li);
$process_step_two_li = new HTMLTags_LI();
$process_step_two_li->append_str_to_content('Step 2');
$checkout_process_ul->append_tag_to_content($process_step_two_li);
$process_step_three_li = new HTMLTags_LI();
$process_step_three_li->append_str_to_content('Step 3');
$checkout_process_ul->append_tag_to_content($process_step_three_li);
$checkout_process_div->append_tag_to_content($checkout_process_ul);
// Already logged in
// You are logged in as Mr. X.
$p_text = <<<TXT
Step 1 on the Checkout process
TXT;
$checkout_process_div->append_tag_to_content(new HTMLTags_P($p_text));
echo $checkout_process_div->get_as_string();
<?php

/**
 * Account management options for the My Account Page
 *
 * @copyright Clear Line Web Design, 2007-08-21
 */
/*
 * Create the singleton objects.
 */
$page_manager = PublicHTML_PageManager::get_instance();
$account_management_div = new HTMLTags_Div();
$account_management_div->set_attribute_str('id', 'account_management_div');
//$account_management_div->append_tag_to_content(new HTMLTags_P($p_text));
$account_management_div->append_tag_to_content(new HTMLTags_Heading(3, 'Account Management'));
$options_ul = new HTMLTags_UL();
/*
 * Link to change your password
 */
$password_reset_li = new HTMLTags_LI();
$password_reset_li->append_str_to_content($page_manager->get_inc_file_as_string('body.a.password-reset'));
$options_ul->append_tag_to_content($password_reset_li);
/*
 * Link to change your customer_region
 */
$customer_region_li = new HTMLTags_LI();
$customer_region_li->append_str_to_content($page_manager->get_inc_file_as_string('body.a.shipping-details-link'));
$options_ul->append_tag_to_content($customer_region_li);
$account_management_div->append_tag_to_content($options_ul);
echo $account_management_div->get_as_string();