public function get_admin_photograph_html_table() { $photograph_row = $this->get_element(); /** * The table. */ $rows_html_table = new HTMLTags_Table(); /** * The caption. */ $caption = new HTMLTags_Caption('Photograph: ' . $photograph_row->get_name()); $rows_html_table->append_tag_to_content($caption); /** * The Heading Row. */ $heading_tr = new HTMLTags_TR(); $heading_tr->append_tag_to_content(new HTMLTags_TH('Name')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Added')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Image')); $rows_html_table->append_tag_to_content($heading_tr); /** * Display the contents of the table. */ $data_tr = $this->get_admin_photographs_html_table_tr_without_actions(); $rows_html_table->append_tag_to_content($data_tr); return $rows_html_table; }
public function get_admin_pages_html_table() { $pages_table = $this->get_element(); $admin_pages_html_table = new HTMLTags_Table(); $admin_pages_html_table->set_attribute_str('id', 'admin_pages_table'); /* * The head */ $thead = new HTMLTags_THead(); $header_tr = new HTMLTags_TR(); $header_tr->append_tag_to_content(new HTMLTags_TH('Name')); $header_tr->append_tag_to_content(new HTMLTags_TH('Author')); $header_tr->append_tag_to_content(new HTMLTags_TH('Title')); $actions_th = new HTMLTags_TH('Actions'); $actions_th->set_attribute_str('colspan', 2); $header_tr->append_tag_to_content($actions_th); $thead->append_tag_to_content($header_tr); $admin_pages_html_table->append_tag_to_content($thead); /* * The body. */ $tbody = new HTMLTags_TBody(); $pages = $pages_table->get_pages_viewable_by_currently_logged_in_user(); foreach ($pages as $page) { $page_renderer = $page->get_renderer(); $tbody->append_tag_to_content($page_renderer->get_admin_page_html_table_tr()); } $admin_pages_html_table->append_tag_to_content($tbody); return $admin_pages_html_table; }
public function get_admin_product_brand_html_table() { $product_brand_row = $this->get_element(); /** * The table. */ $rows_html_table = new HTMLTags_Table(); /** * The caption. */ $caption = new HTMLTags_Caption('Product Brand: ' . $product_brand_row->get_name()); $rows_html_table->append_tag_to_content($caption); /** * The Heading Row. */ $heading_tr = new HTMLTags_TR(); $heading_tr->append_tag_to_content(new HTMLTags_TH('Name')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Owner')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Description')); $heading_tr->append_tag_to_content(new HTMLTags_TH('URL')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Image')); $rows_html_table->append_tag_to_content($heading_tr); /** * Display the contents of the table. */ $data_tr = $this->get_admin_product_brands_html_table_tr_without_actions(); $rows_html_table->append_tag_to_content($data_tr); return $rows_html_table; }
private function get_drama_table() { $table = new HTMLTags_Table(); $table->append($this->get_heading_tr()); $i = 1; foreach ($this->get_dramas() as $drama) { $drama_tr = $this->get_drama_tr($drama); if ($i & 1) { $drama_tr->set_attribute_str('class', 'odd'); } $i++; $table->append($drama_tr); } return $table; }
public function __construct() { parent::__construct(); $this->set_attribute_str('id', 'reorder_rows'); $this->column_titles = array(); $this->row_data = array(); }
public function __construct(Oedipus_Frame $frame) { parent::__construct(); $this->set_attribute_str('class', 'oedipus'); $this->frame = $frame; $this->characters = $frame->get_characters(); }
public function __construct(Oedipus_Table $table, $edit_mode = TRUE) { parent::__construct(); $this->set_attribute_str('class', 'oedipus'); $this->edit_mode = $edit_mode; $this->table = $table; $this->actors = $table->get_actors(); }
/** * A table to display the people in public, with pages */ public function get_public_short_people_div($page) { $people_table = $this->get_element(); $short_people_div = new HTMLTags_Div(); # ------------------------------------------------------------------ /** * The table. */ $rows_html_table = new HTMLTags_Table(); $rows_html_table->set_attribute_str('class', 'table_short'); $conditions['status'] = 'accepted'; $rows = $people_table->get_rows_where($conditions, ORDER_BY, DIRECTION, OFFSET, LIMIT); #$rows = $people_table->get_all_rows(ORDER_BY, DIRECTION, OFFSET, LIMIT); foreach ($rows as $row) { $row_renderer = $row->get_renderer(); #$data_tr = $row_renderer->get_admin_database_tr(); $data_tr = $row_renderer->get_public_people_tr(); $rows_html_table->append_tag_to_content($data_tr); } # ------------------------------------------------------------------ $short_people_div->append_tag_to_content($rows_html_table); return $short_people_div; }
# Display some of the data in the table. # #################################################################### # ------------------------------------------------------------------ $suppliers = $suppliers_table->get_all_rows(); // print_r($suppliers); foreach ($suppliers as $supplier) { // $supplier_heading = new HTMLTags_Heading(2); // $supplier_heading->append_str_to_content($supplier->get_name()); // $conditions = array(); // $conditions['supplier_id'] = $supplier->get_id(); // $supplier_shipping_prices = $supplier_shipping_prices_table->get_rows_where($conditions); /** * The table. */ $supplier_table = new HTMLTags_Table(); // $supplier_table->set_attribute_str('class', ''); /** * The caption. */ $supplier_address = $supplier->get_address(); $caption_text = ''; $caption_text .= $supplier->get_name(); $caption_text .= ' ('; $caption_text .= $supplier_address->get_country_name(); $caption_text .= ')'; $caption = new HTMLTags_Caption($caption_text); $supplier_table->append_tag_to_content($caption); $customer_regions = $customer_regions_table->get_all_rows(); $heading_tr = new HTMLTags_TR(); $heading_tr->append_tag_to_content(new HTMLTags_TH());
* 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); $row_count = $product_brands_table->count_all_rows(); #echo "\$row_count: $row_count\n"; $previous_next_ul = new Database_PreviousNextUL($previous_next_url, OFFSET, LIMIT, $row_count); $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. */ $caption = new HTMLTags_Caption('The Product Brands in the Shop'); $rows_html_table->append_tag_to_content($caption); /** * The Heading Row. */ $sort_href = clone $current_page_url; $sort_href->set_get_variable('limit', LIMIT); $heading_row = new Database_SortableHeadingTR($sort_href, DIRECTION); $field_names = explode(' ', 'name url'); $product_brand_header = new HTMLTags_TH('Image'); $heading_row->append_tag_to_content($product_brand_header);
public function get_all_data_html_table() { $all_data_html_table = new HTMLTags_Table(); $row = $this->get_element(); $table = $row->get_table(); $fields = $table->get_fields(); $heading_row = new HTMLTags_TR(); foreach ($fields as $field) { $heading_row->append_tag_to_content(new HTMLTags_TH($field->get_name())); } $all_data_html_table->append_tag_to_content($heading_row); $data_row = new HTMLTags_TR(); foreach ($fields as $field) { #$field_td = new HTMLTags_TD($row->get($field->get_name())); $field_td = $this->get_data_html_table_td($field); $data_row->append_tag_to_content($field_td); } $all_data_html_table->append_tag_to_content($data_row); return $all_data_html_table; }
public function get_admin_people_html_table() { $person_row = $this->get_element(); /** * The table. */ $rows_html_table = new HTMLTags_Table(); /** * The caption. */ $caption = new HTMLTags_Caption('Person to be deleted'); $rows_html_table->append_tag_to_content($caption); /** * The Heading Row. */ $heading_tr = new HTMLTags_TR(); $heading_tr->append_tag_to_content(new HTMLTags_TH('Added')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Name')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Email')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Status')); $rows_html_table->append_tag_to_content($heading_tr); /** * Display the contents of the table. */ $data_tr = $this->get_admin_people_html_table_tr_without_actions(); $rows_html_table->append_tag_to_content($data_tr); return $rows_html_table; return $person_table; }
public function get_paged_public_all_comments_div($current_page_url) { $product = $this->get_element(); // $comments = $product->get_comments(); $database = $product->get_database(); $comments_table = $database->get_table('hpi_shop_comments'); $all_comments_div = new HTMLTags_Div(); #################################################################### # # Display some of the data in the comments table. # #################################################################### if ($product->count_comments() >= 11) { /* * 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 = new HTMLTags_URL(); // $limit_action->set_file('/'); $limit_form = new Database_LimitForm($current_page_url, LIMIT, '10 20 50'); // $limit_form->add_hidden_input('page', $page); $limit_form->add_hidden_input('order_by', ORDER_BY); $limit_form->add_hidden_input('direction', DIRECTION); $limit_form->add_hidden_input('offset', OFFSET); $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('product_id', $product->get_id()); // $previous_next_url->set_get_variable('order_by', ORDER_BY); // $previous_next_url->set_get_variable('direction', DIRECTION); #print_r($previous_next_url); $row_count = $product->count_comments(); #echo "\$row_count: $row_count\n"; $previous_next_ul = new Database_PreviousNextUL($previous_next_url, OFFSET, LIMIT, $row_count); $limit_previous_next_div->append_tag_to_content($previous_next_ul); $all_comments_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. */ #$caption = new HTMLTags_Caption( # 'All Comments' #); #$rows_html_table->append_tag_to_content($caption); # /** * The Heading Row. */ #$sort_href = new HTMLTags_URL(); #$sort_href->set_file('/index.php'); # #$sort_href->set_get_variable('page', $page); # #$sort_href->set_get_variable('limit', LIMIT); # #$heading_row = new Database_SortableHeadingTR($sort_href, DIRECTION); #$fields = $comments_table->get_fields(); # #foreach ($fields as $field) { # $heading_row->append_sortable_field_name($field->get_name()); #} # #$field_names = explode(' ', 'name comment added'); # #foreach ($field_names as $field_name) { # $heading_row->append_sortable_field_name($field_name); #} #$buy_th = new HTMLTags_TH('Buy This'); # #$heading_row->append_tag_to_content($buy_th); #$rows_html_table->append_tag_to_content($heading_row); # ------------------------------------------------------------------ /** * Display the contents of the table. */ #$order_by = isset($_GET['order_by']) ? $_GET['order_by'] : 'id'; #$direction = isset($_GET['direction']) ? $_GET['direction'] : 'ASC'; #$table_renderer->render_all_data_table($order_by, $direction); $conditions['status'] = 'accepted'; $conditions['product_id'] = $product->get_id(); $comments = $comments_table->get_rows_where($conditions, ORDER_BY, DIRECTION, OFFSET, LIMIT); foreach ($comments as $comment) { $row_renderer = $comment->get_renderer(); #$data_tr = $row_renderer->get_admin_database_tr(); $data_tr = $row_renderer->get_public_comments_hreview_tr(); $rows_html_table->append_tag_to_content($data_tr); } # ------------------------------------------------------------------ $all_comments_div->append_tag_to_content($rows_html_table); if ($product->count_comments() >= 11) { $all_comments_div->append_tag_to_content($limit_previous_next_div); } return $all_comments_div; }
public function get_all_orders_table($current_page_url) { $supplier = $this->get_element(); $database = $supplier->get_database(); $orders_table = $database->get_table('hpi_shop_orders'); $all_orders_table = new HTMLTags_Table(); $all_orders_table->set_attribute_str('id', 'shopping-basket-table'); $caption = new HTMLTags_Caption('Your Orders'); $all_orders_table->append_tag_to_content($caption); $thead = new HTMLTags_THead(); $thead_tr = new HTMLTags_TR(); $added_th = new HTMLTags_TH('Date of Purchase'); $id_th = new HTMLTags_TH('Order No.'); $product_th = new HTMLTags_TH('Product'); $customer_th = new HTMLTags_TH('Customer'); $quantity_th = new HTMLTags_TH('Amount'); $status_th = new HTMLTags_TH('Status'); $set_status_th = new HTMLTags_TH('Set Status'); $thead_tr->append_tag_to_content($added_th); $thead_tr->append_tag_to_content($id_th); $thead_tr->append_tag_to_content($product_th); $thead_tr->append_tag_to_content($customer_th); $thead_tr->append_tag_to_content($quantity_th); $thead_tr->append_tag_to_content($status_th); $thead_tr->append_tag_to_content($set_status_th); $thead->append_tag_to_content($thead_tr); $all_orders_table->append_tag_to_content($thead); // $tfoot = new HTMLTags_TFoot(); // $tfoot_tr = new HTMLTags_TR(); // $sub_total_th= new HTMLTags_TH('Sub-Total'); // $blank_td= new HTMLTags_TD(''); // $sub_total_td = new HTMLTags_TD($sub_total_price->get_as_string()); // // $tfoot_tr->append_tag_to_content($sub_total_th); // $tfoot_tr->append_tag_to_content($blank_td); // $tfoot_tr->append_tag_to_content($blank_td); // $tfoot_tr->append_tag_to_content($sub_total_td); // $tfoot_tr->append_tag_to_content($blank_td); // // $tfoot->append_tag_to_content($tfoot_tr); // $all_orders_table->append_tag_to_content($tfoot); $tbody = new HTMLTags_TBody(); try { $orders = $orders_table->get_orders_for_supplier($supplier, $order_by = 'added'); } catch (Exception $e) { /* * Shouldn't something happen here? */ } #print_r($orders); foreach ($orders as $order) { $order_renderer = $order->get_renderer(); $order_tr = $order_renderer->get_public_order_supplier_tr($current_page_url); $tbody->append_tag_to_content($order_tr); } $all_orders_table->append_tag_to_content($tbody); return $all_orders_table; }
require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TR.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TD.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_A.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/' . 'HTMLTags_URL.inc.php'; require_once PROJECT_ROOT . '/haddock/database/classes/' . 'Database_MySQLUserFactory.inc.php'; /* * Start the displayed content. */ $content_div = new HTMLTags_Div(); $content_div->set_attribute_str('id', 'content'); $mysql_user_factory = Database_MySQLUserFactory::get_instance(); $mysql_user = $mysql_user_factory->get_for_this_project(); $database = $mysql_user->get_database(); $server_logs_table = $database->get_table('hc_logging_server_logs'); $entrances = $server_logs_table->get_entrances(); $entrances_table = new HTMLTags_Table(); foreach ($entrances as $entrance) { $tr = new HTMLTags_TR(); $td = new HTMLTags_TD(); $tr->append_tag_to_content(new HTMLTags_TD($entrance['domain'])); #$entrance_a = new HTMLTags_A($entrance['domain']); # #$entrance_a->set_href(new HTMLTags_URL($entrance['domain'])); # #$entrance_a->set_attribute_str('target', '_blank'); # #$td->append_tag_to_content($entrance_a); # #$tr->append_tag_to_content($td); $tr->append_tag_to_content(new HTMLTags_TD($entrance['count'])); $entrances_table->append_tag_to_content($tr);
#require_once PROJECT_ROOT # . '/haddock/html-tags/classes/standard/' # . 'HTMLTags_TH.inc.php'; # #require_once PROJECT_ROOT # . '/haddock/html-tags/classes/standard/' # . 'HTMLTags_TD.inc.php'; /* * Make the content div. */ $content_div = new HTMLTags_Div(); $content_div->set_attribute_str('id', 'content'); /* * Make the disk usage table. */ $d_u_table = new HTMLTags_Table(); /* * Make the heading row. */ $heading_row = new HTMLTags_TR(); $heading_row->append_tag_to_content(new HTMLTags_TH('Item')); $heading_row->append_tag_to_content(new HTMLTags_TH('Disk Usage (MB)')); $d_u_table->append_tag_to_content($heading_row); /* * The disk usage of the project directory. */ $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance(); $project_directory = $project_directory_finder->get_project_directory_for_this_project(); $p_d_row = new HTMLTags_TR(); $p_d_row->append_tag_to_content(new HTMLTags_TD('Project Directory')); $p_d_d_u = $project_directory->get_disk_usage();
*/ /* * Define the necessary classes. */ require_once PROJECT_ROOT . '/project-specific/classes/' . 'ServerAdminScripts_LocalControlCentre.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_Div.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_Heading.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_Table.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TR.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TH.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TD.inc.php'; $control_centre = new ServerAdminScripts_LocalControlCentre(); $content_div = new HTMLTags_Div(); $content_div->set_attribute_str('id', 'content'); $content_div->append_tag_to_content(new HTMLTags_Heading(2, 'Current Tasks')); $tasks_table = new HTMLTags_Table(); $tasks_tr = new HTMLTags_TR(); $tasks_tr->append_tag_to_content(new HTMLTags_TH('Task Event ID')); $tasks_tr->append_tag_to_content(new HTMLTags_TH('Host')); $tasks_tr->append_tag_to_content(new HTMLTags_TH('System')); $tasks_tr->append_tag_to_content(new HTMLTags_TH('Task')); $tasks_tr->append_tag_to_content(new HTMLTags_TH('Start')); $tasks_table->append_tag_to_content($tasks_tr); $current_task_events = $control_centre->get_current_task_events(); foreach ($current_task_events as $current_task_event) { $tasks_tr = new HTMLTags_TR(); $tasks_tr->append_tag_to_content(new HTMLTags_TD($current_task_event->get('ps_task_events.id'))); $tasks_tr->append_tag_to_content(new HTMLTags_TD($current_task_event->get('ps_hosts.name'))); $tasks_tr->append_tag_to_content(new HTMLTags_TD($current_task_event->get('ps_systems.name'))); $tasks_tr->append_tag_to_content(new HTMLTags_TD($current_task_event->get('ps_tasks.name'))); $tasks_tr->append_tag_to_content(new HTMLTags_TD($current_task_event->get('ps_task_events.start')));
public function __construct(HTMLTags_URL $url, Database_Table $table, $order_by, $direction, $offset, $limit, $limit_str, $rows_html_table_caption, $lpnd_class, $data_table_class, $fields, $actions) { parent::__construct(); $table_renderer = $table->get_renderer(); /* * ---------------------------------------- * Check the inputs. * ---------------------------------------- */ /* * ---------------------------------------- * Create the content. * ---------------------------------------- */ $limit_previous_next_div = new HTMLTags_Div(); $limit_previous_next_div->set_attribute_str('class', $lpnd_class); /* * To allow the user to set the number of extras to show at a time. */ $limit_action = clone $url; $limit_action->delete_all_get_variables(); $limit_form = new Database_LimitForm($limit_action, $limit, $limit_str); $get_vars = $url->get_get_variables(); foreach (array_keys($get_vars) as $key) { $limit_form->add_hidden_input($key, $get_vars[$key]); } $limit_form->add_hidden_input('order_by', $order_by); $limit_form->add_hidden_input('direction', $direction); $limit_form->add_hidden_input('offset', $offset); $limit_previous_next_div->append_tag_to_content($limit_form); $previous_next_url = clone $url; $previous_next_url->set_get_variable('order_by', $order_by); $previous_next_url->set_get_variable('direction', $direction); $row_count = $table->count_all_rows(); $previous_next_ul = new Database_PreviousNextUL($previous_next_url, $offset, $limit, $row_count); $limit_previous_next_div->append_tag_to_content($previous_next_ul); $this->append_tag_to_content($limit_previous_next_div); # ------------------------------------------------------------------ /* * The table. */ $rows_html_table = new HTMLTags_Table(); $rows_html_table->set_attribute_str('class', $data_table_class); /* * The caption. */ $caption = new HTMLTags_Caption($rows_html_table_caption); $rows_html_table->append_tag_to_content($caption); /* * The Heading Row. */ $sort_href = clone $url; $sort_href->set_get_variable('limit', $limit); $heading_row = new Database_SortableHeadingTR($sort_href, $direction); //if (isset($fields_str)) { // $fields = array(); // // foreach (explode(' ', $fields_str) as $field_name) { // $fields[] = $table->get_field($field_name); // } //} else { // $fields = $table->get_fields(); //} foreach ($fields as $field) { if ($field['sortable']) { $heading_row->append_sortable_field_name($field['name']); } else { $heading_row->append_nonsortable_field_name($field['name']); } } foreach ($actions as $action) { $heading_row->append_tag_to_content($action['th']); } $rows_html_table->append_tag_to_content($heading_row); # ------------------------------------------------------------------ /* * Display the contents of the table. */ $rows = $table->get_all_rows($order_by, $direction, $offset, $limit); foreach ($rows as $row) { $row_renderer = $row->get_renderer(); $data_tr = new HTMLTags_TR(); foreach ($fields as $field) { $field_td = self::get_html_table_cell_for_field($field, $row_renderer); $data_tr->append_tag_to_content($field_td); } //foreach ( // $row_renderer->get_action_tds( // $actions_str, // $url // ) // as // $action_td //) { // $data_tr->append_tag_to_content($action_td); //} foreach ($actions as $action) { $action_td = self::get_html_table_cell_for_field($action, $row_renderer); $data_tr->append_tag_to_content($action_td); } $rows_html_table->append_tag_to_content($data_tr); } # ------------------------------------------------------------------ $this->append_tag_to_content($rows_html_table); $this->append_tag_to_content($limit_previous_next_div); }
public function get_checkout_shopping_basket_for_current_session_table() { $shopping_baskets_table = $this->get_element(); $database = $shopping_baskets_table->get_database(); $customer_regions_table = $database->get_table('hpi_shop_customer_regions'); $customer_region = $customer_regions_table->get_row_by_id($_SESSION['customer_region_id']); $currency = $customer_region->get_currency(); $shopping_baskets_table = $this->get_element(); $checkout_shopping_basket_table = new HTMLTags_Table(); $checkout_shopping_basket_table->set_attribute_str('id', 'shopping-basket-table'); $caption = new HTMLTags_Caption('Your Shopping Basket'); $checkout_shopping_basket_table->append_tag_to_content($caption); // THEAD $thead = new HTMLTags_THead(); $thead_tr = new HTMLTags_TR(); $name_th = new HTMLTags_TH('Name'); $price_th = new HTMLTags_TH('Unit Price'); $quantity_th = new HTMLTags_TH('Amount'); $sub_total_th = new HTMLTags_TH('Sub-Total'); $thead_tr->append_tag_to_content($name_th); $thead_tr->append_tag_to_content($price_th); $thead_tr->append_tag_to_content($quantity_th); $thead_tr->append_tag_to_content($sub_total_th); $thead->append_tag_to_content($thead_tr); $checkout_shopping_basket_table->append_tag_to_content($thead); // TFOOT $tfoot = new HTMLTags_TFoot(); $blank_td = new HTMLTags_TD(''); // TFOOT - sub-total-tr $tfoot_sub_total_tr = new HTMLTags_TR(); $sub_total_price = new Shop_SumOfMoney($shopping_baskets_table->get_sub_total_for_current_session($customer_region), $currency); $sub_total_th = new HTMLTags_TH('Sub-Total'); $sub_total_td = new HTMLTags_TD($sub_total_price->get_as_string()); $tfoot_sub_total_tr->append_tag_to_content($blank_td); $tfoot_sub_total_tr->append_tag_to_content($blank_td); $tfoot_sub_total_tr->append_tag_to_content($sub_total_th); $tfoot_sub_total_tr->append_tag_to_content($sub_total_td); $tfoot->append_tag_to_content($tfoot_sub_total_tr); // TFOOT - shipping-tr $shipping_price = new Shop_SumOfMoney($shopping_baskets_table->get_shipping_total_for_current_session($customer_region->get_id()), $currency); $tfoot_shipping_tr = new HTMLTags_TR(); $shipping_th = new HTMLTags_TH('Shipping'); $shipping_td = new HTMLTags_TD($shipping_price->get_as_string()); $tfoot_shipping_tr->append_tag_to_content($blank_td); $tfoot_shipping_tr->append_tag_to_content($blank_td); $tfoot_shipping_tr->append_tag_to_content($shipping_th); $tfoot_shipping_tr->append_tag_to_content($shipping_td); $tfoot->append_tag_to_content($tfoot_shipping_tr); // TFOOT - total-tr $total_price = new Shop_SumOfMoney($shopping_baskets_table->get_total_for_current_session($customer_region->get_id()), $currency); $tfoot_total_tr = new HTMLTags_TR(); $total_th = new HTMLTags_TH('Total'); $total_td = new HTMLTags_TD($total_price->get_as_string()); $tfoot_total_tr->append_tag_to_content($blank_td); $tfoot_total_tr->append_tag_to_content($blank_td); $tfoot_total_tr->append_tag_to_content($total_th); $tfoot_total_tr->append_tag_to_content($total_td); $tfoot->append_tag_to_content($tfoot_total_tr); $checkout_shopping_basket_table->append_tag_to_content($tfoot); // TBODY $tbody = new HTMLTags_TBody(); try { $shopping_baskets = $shopping_baskets_table->get_shopping_baskets_for_current_session(); } catch (Exception $e) { } if (count($shopping_baskets) > 0) { foreach ($shopping_baskets as $shopping_basket) { $shopping_basket_renderer = $shopping_basket->get_renderer(); $shopping_basket_tr = $shopping_basket_renderer->get_checkout_shopping_basket_tr(); $tbody->append_tag_to_content($shopping_basket_tr); } } $checkout_shopping_basket_table->append_tag_to_content($tbody); return $checkout_shopping_basket_table; }
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(' '); $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 ' . $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 "' . $product_category->get_name() . '"'; } 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(); }
public function get_checkout_order_for_current_session_table() { $orders_table = $this->get_element(); $database = $orders_table->get_database(); $customer_regions_table = $database->get_table('hpi_shop_customer_regions'); $orders_table = $this->get_element(); $checkout_order_table = new HTMLTags_Table(); $caption = new HTMLTags_Caption('Your Shopping Basket'); $checkout_order_table->append_tag_to_content($caption); // THEAD $thead = new HTMLTags_THead(); $thead_tr = new HTMLTags_TR(); $name_th = new HTMLTags_TH('Name'); $price_th = new HTMLTags_TH('Unit Price'); $quantity_th = new HTMLTags_TH('Amount'); $sub_total_th = new HTMLTags_TH('Sub-Total'); $thead_tr->append_tag_to_content($name_th); $thead_tr->append_tag_to_content($price_th); $thead_tr->append_tag_to_content($quantity_th); $thead_tr->append_tag_to_content($sub_total_th); $thead->append_tag_to_content($thead_tr); $checkout_order_table->append_tag_to_content($thead); // TFOOT $tfoot = new HTMLTags_TFoot(); $blank_td = new HTMLTags_TD(''); // TFOOT - sub-total-tr $tfoot_sub_total_tr = new HTMLTags_TR(); $sub_total_th = new HTMLTags_TH('Sub-Total'); $sub_total_td = new HTMLTags_TD($orders_table->get_sub_total_for_current_session()); $tfoot_sub_total_tr->append_tag_to_content($blank_td); $tfoot_sub_total_tr->append_tag_to_content($blank_td); $tfoot_sub_total_tr->append_tag_to_content($sub_total_th); $tfoot_sub_total_tr->append_tag_to_content($sub_total_td); $tfoot->append_tag_to_content($tfoot_sub_total_tr); // TFOOT - shipping-tr $tfoot_shipping_tr = new HTMLTags_TR(); $shipping_th = new HTMLTags_TH('Shipping'); $shipping_td = new HTMLTags_TD($orders_table->get_shipping_total_for_current_session()); $tfoot_shipping_tr->append_tag_to_content($blank_td); $tfoot_shipping_tr->append_tag_to_content($blank_td); $tfoot_shipping_tr->append_tag_to_content($shipping_th); $tfoot_shipping_tr->append_tag_to_content($shipping_td); $tfoot->append_tag_to_content($tfoot_shipping_tr); // TFOOT - total-tr $tfoot_total_tr = new HTMLTags_TR(); $total_th = new HTMLTags_TH('Total'); $total_td = new HTMLTags_TD($orders_table->get_total_for_current_session($shipping_location)); $tfoot_total_tr->append_tag_to_content($blank_td); $tfoot_total_tr->append_tag_to_content($blank_td); $tfoot_total_tr->append_tag_to_content($total_th); $tfoot_total_tr->append_tag_to_content($total_td); $tfoot->append_tag_to_content($tfoot_total_tr); $checkout_order_table->append_tag_to_content($tfoot); // TBODY $tbody = new HTMLTags_TBody(); try { $orders = $orders_table->get_orders_for_current_session(); } catch (Exception $e) { } if (count($orders) > 0) { foreach ($orders as $order) { $order_renderer = $order->get_renderer(); $order_tr = $order_renderer->get_checkout_order_tr(); $tbody->append_tag_to_content($order_tr); } } $checkout_order_table->append_tag_to_content($tbody); return $checkout_order_table; }
require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TR.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TH.inc.php'; require_once PROJECT_ROOT . '/haddock/html-tags/classes/standard/' . 'HTMLTags_TD.inc.php'; require_once PROJECT_ROOT . '/haddock/haddock-project-organisation/classes/' . 'HaddockProjectOrganisation_ProjectDirectoryFinder.inc.php'; /* * ----------------------------------------------------------------------------- */ $content_div = new HTMLTags_Div(); $content_div->set_attribute_str('id', 'content'); /* * Find all the tests. */ $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance(); $project_directory = $project_directory_finder->get_project_directory_for_this_project(); $unit_tests_php_class_files = $project_directory->get_all_unit_tests_php_class_files(); $unit_tests_html_table = new HTMLTags_Table(); $heading_tr = new HTMLTags_TR(); $heading_tr->append_tag_to_content(new HTMLTags_TH('Name')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Passes')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Tests')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Result')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Time (s)')); $unit_tests_html_table->append_tag_to_content($heading_tr); $total_passes = 0; $total_tests = 0; $everything_passes = TRUE; $total_time_all_tests = 0; foreach ($unit_tests_php_class_files as $u_t_p_c_f) { $u_t_tr = new HTMLTags_TR(); $u_t_tr->append_tag_to_content(new HTMLTags_TD($u_t_p_c_f->get_php_class_name())); $count_passed_tests = $u_t_p_c_f->count_passed_tests();
*/ if (isset($_GET['query'])) { $query = stripcslashes($_GET['query']); if (strlen($query) == 0) { $p = new HTMLTags_P('Try typing a SELECT statement.'); $content_div->append_tag_to_content($p); } elseif (preg_match('/^(?:\\s*\\()*\\s*(?:(?:EXPLAIN\\s*)?SELECT|SHOW)\\s/i', $query)) { $muf = Database_MySQLUserFactory::get_instance(); $mu = $muf->get_for_this_project(); $dbh = $mu->get_database_handle(); $result = mysql_query($query, $dbh); /* * The table. */ if ($result && mysql_num_rows($result) > 0) { $results_table = new HTMLTags_Table(); $first = TRUE; while ($row = mysql_fetch_assoc($result)) { $fields = array_keys($row); if ($first) { $first = FALSE; $fields_header_tr = new HTMLTags_TR(); foreach ($fields as $field) { $fields_header_tr->append_tag_to_content(new HTMLTags_TH($field)); } $results_table->append_tag_to_content($fields_header_tr); } $fields_data_tr = new HTMLTags_TR(); foreach ($fields as $field) { $fields_data_tr->append_tag_to_content(new HTMLTags_TD(htmlentities($row[$field]))); }
/** * Renders the HTML table that contains the data and the * links to other pages to do stuff to individual items. */ protected function render_data_table() { /* * 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. * ---------------------------------------- */ $caption_str = $this->get_data_table_caption_content(); $rows_html_table->append_tag_to_content(new HTMLTags_Caption($caption_str)); /* * ---------------------------------------- * The heading row of the HTML table that displays the products. * ---------------------------------------- */ $thead = new HTMLTags_THead(); $sort_href = $this->get_current_base_url(); $sort_href->set_get_variable('limit', $this->get_current_limit()); $sort_href->set_get_variable('offset', $this->get_current_offset()); $heading_row = new Database_SortableHeadingTR($sort_href, $this->get_current_direction()); $fields = $this->get_data_table_fields(); #print_r($fields); foreach ($fields as $field) { if (isset($field['sortable']) && strtolower($field['sortable']) == 'no') { $heading_row->append_nonsortable_field_name($field['col_name'], isset($field['title']) ? $field['title'] : NULL); } else { $heading_row->append_sortable_field_name($field['col_name'], isset($field['title']) ? $field['title'] : NULL); } } foreach ($this->get_data_table_action_ths() as $action_th) { $heading_row->append_tag_to_content($action_th); } $thead->append_tag_to_content($heading_row); $rows_html_table->append_tag_to_content($thead); /* * ---------------------------------------- * Fetch the rows from the database table. * ---------------------------------------- */ $tbody = new HTMLTags_TBody(); $rows = $this->get_matching_rows(); /* * Display some of the contents of the table. */ foreach ($rows as $row) { $data_tr = $this->get_data_html_table_tr($row); $tbody->append_tag_to_content($data_tr); } $rows_html_table->append_tag_to_content($tbody); echo $rows_html_table->get_as_string(); }
public function get_admin_comments_html_table() { $comment_row = $this->get_element(); /** * The table. */ $rows_html_table = new HTMLTags_Table(); /** * The caption. */ $caption = new HTMLTags_Caption('Comment to be deleted'); $rows_html_table->append_tag_to_content($caption); /** * The Heading Row. */ $heading_tr = new HTMLTags_TR(); $heading_tr->append_tag_to_content(new HTMLTags_TH('Added')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Modified')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Product Id')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Status')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Front Page')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Name')); $heading_tr->append_tag_to_content(new HTMLTags_TH('Comment')); $rows_html_table->append_tag_to_content($heading_tr); /** * Display the contents of the table. */ $data_tr = $this->get_admin_comments_html_table_tr_without_actions(); $rows_html_table->append_tag_to_content($data_tr); return $rows_html_table; return $comment_table; }