Source for file TableDisplay.php
Documentation is available at TableDisplay.php
/* -------------------------------------------------------------------------- */
/* Module : TableDisplay */
/* Date Vsn Author Description */
/* -------------------------------------------------------------------------- */
/* 21/11/08 1.0 Sonja Lindo Initial Version */
/* 24/02/09 2.0 Sonja Lindo Converted to to the Zend Framework */
/* -------------------------------------------------------------------------- */
* Used to display data in a table. The row colours may alternate.
// Ordinary member variables
private $formatted_table =
null;
private $header_array =
Array();
private $row_array =
Array();
private $cell_array =
Array();
private $table_class =
'standard'; // may be overwritten
private $row_class; // colour set in displayRows
private $cell_class =
'admin_standard'; // may be overwritten
private $bg_colour_1=
'booking_col_1';
private $bg_colour_2=
'booking_col_2';
////////////////////////////////////////////////////////// tabledisplay
* Column headers and individual table rows are formatted for display
* @return mixed String containing all HTML for a table of data
public function tabledisplay($in_table_array, $in_edit_allowed, $in_delete_allowed)
$this->formatted_table =
null;
$this->header_array =
Array();
$this->row_array =
Array();
$this->cell_array =
Array();
$errorNoRecords =
'There is nothing to display on the ' .
$this->view->pageTitle .
' screen';
if (count($in_table_array) ==
0)
// SORT THE RETRIEVED DATA
$obj_Table_Display->sortData($_SESSION['Session']->getClientId(), $result);
foreach ($in_table_array['colHeaders'] as $colHeader)
foreach ($in_table_array['data'] as $currentRow)
$this->cell_array =
array();
foreach ($currentRow as $name =>
$value)
// Php auto converts types. '===' forces typed comparison
// $name may be an integer or a string so beware
if ($name ===
'edit_ids')
// Field is a href/link - build the url
if ( $value['action'] ==
'edit' ||
$value['action'] ==
'insert' ||
$value['action'] ==
'delete' )
( 'controller'=>
$this->view->controllerName,
'action'=>
$value['action'],
'table'=>
$value['table'],
( 'controller'=>
$this->view->controllerName,
'action'=>
$value['action'],
'params'=>
$value['params']
if (isset
($value['heading']))
$urlDetails['heading'] =
$value['heading'];
$this->view->url ($urlDetails) .
'">' .
$value['display'] .
'</a>');
array ( 'controller'=>
$this->view->controllerName,
'table' =>
$this->view->table,
'ids' =>
$currentRow['edit_ids'])) .
array ( 'controller' =>
$this->view->controllerName,
'table' =>
$this->view->table,
'ids' =>
$currentRow['edit_ids'])) .
// FORMAT THE WHOLE TABLE
return $this->formatted_table;
////////////////////////////////////////////////////////// addToOutput
* Input string is added to the formatted table HTML
$this->formatted_table .=
$in_string;
////////////////////////////////////////////////////////////////// sortData
* Sorts data according to the chosen 'order by' value.
public function sortData($in_client_id, $in_result)
$this->obj_Sort_Data =
newObject('Sort_Data');
$this->obj_Sort_Data->setup ($in_client_id, $in_result);
$this->result_sorted =
$this->obj_Sort_Data->select('$_POST[order_by]', $_POST[order_dir]);
/////////////////////////////////////////////////////////////////// constructTable
* Sets up the final table ready to be displayed.
public function constructTable($in_table_class, $in_cell_class, $in_alternate_flag)
// Overwrite default table/cell classes?
if ($in_table_class !=
'')
$this->table_class =
$in_table_class;
if ($this->cell_class !=
'')
$this->cell_class =
$in_cell_class;
// DISPLAY THE TABLE HERE
$this->addToOutput( "\n\n<table class=\"" .
$this->table_class .
"\">\n");
* Formats the column headers for the table
//////////////////////////////////////////////////////////// displayHeader
foreach ($this->header_array as $header_cell)
$this->addToOutput( "\n\t\t<td class=\"admin_standard\">" .
$header_cell .
"</td>" );
//////////////////////////////////////////////////////////// displayRows
$this->row_class =
$this->bg_colour_1;
foreach ($this->row_array as $curr_cell_array)
if ($in_alternate_flag ==
true)
// 2 row colors are required, each row alternating the display.
if ($this->row_class ==
$this->bg_colour_2)
$this->row_class =
$this->bg_colour_1;
$this->row_class =
$this->bg_colour_2;
$this->addToOutput( "\n\t<tr class=\"" .
$this->row_class .
"\">\n" );
// Display all cells for this row
foreach ($curr_cell_array as $cell)
// Does this cell need a styling class?
$class_as_array=
explode('=', $cell_as_array[0]);
$this->cell_class =
$class_as_array[1];
$this->addToOutput( "\n\t\t<td class=\"" .
$this->cell_class .
"\">" .
$cell .
"</td>" );
///////////////////////////////////////////////////////// addToHeader
* Input column is added to the header
$this->header_array[] =
$in_col_header;
///////////////////////////////////////////////////////// addToOrderHeader
* Input column is added to the header and is a valid 'order by' column
$in_order_by =
'booking_id';
if ($_POST['order_dir'] ==
'asc')
//$this->addToHeader('<A class=in-line-link href=javascript:document.forms['form'].order_by.value='$in_order_by';document.forms['form'].order_dir.value='$order_dir';trigger_submit('$_POST[submit_trigger]')>$in_order_text</A>');
////////////////////////////////////////////////////////// addToRow
* Input cell is added to the current row
public function addToRow($in_cell_value)
$this->cell_array[] =
$in_cell_value;
////////////////////////////////////////////////////////// endCurrRow
$this->row_array[] =
$this->cell_array;
$this->cell_array =
Array();
Documentation generated on Fri, 27 Mar 2009 13:48:45 +0000 by phpDocumentor 1.4.1