'data_table'));
$this->table_name = $table_name;
$this->additional_parameters = array ();
$this->param_prefix = $table_name.'_';
$this->page_nr = isset ($_SESSION[$this->param_prefix.'page_nr']) ? intval($_SESSION[$this->param_prefix.'page_nr']) : 1;
$this->page_nr = isset ($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr;
$this->column = isset ($_SESSION[$this->param_prefix.'column']) ? intval($_SESSION[$this->param_prefix.'column']) : $default_column;
$this->column = isset ($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column;
//$this->direction = isset ($_SESSION[$this->param_prefix.'direction']) ? $_SESSION[$this->param_prefix.'direction'] : $default_order_direction;
if (isset($_SESSION[$this->param_prefix.'direction'])) {
$my_session_direction = $_SESSION[$this->param_prefix.'direction'];
if(!in_array($my_session_direction, array('ASC','DESC'))){
$this->direction = 'ASC';
} else {
if ($my_session_direction=='ASC') {
$this->direction = 'ASC';
} elseif ($my_session_direction=='DESC') {
$this->direction = 'DESC';
}
}
}
if (isset($_GET[$this->param_prefix.'direction'])) {
$my_get_direction = $_GET[$this->param_prefix.'direction'];
if(!in_array($my_get_direction, array('ASC','DESC'))){
$this->direction = 'ASC';
} else {
if ($my_get_direction=='ASC') {
$this->direction = 'ASC';
} elseif ($my_get_direction=='DESC') {
$this->direction = 'DESC';
}
}
}
//allow to change paginate in multiples tabs
unset($_SESSION[$this->param_prefix.'per_page']);
$this->per_page = isset ($_SESSION[$this->param_prefix.'per_page']) ? intval($_SESSION[$this->param_prefix.'per_page']) : $default_items_per_page;
$this->per_page = isset ($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page;
$_SESSION[$this->param_prefix.'per_page'] = $this->per_page;
$_SESSION[$this->param_prefix.'direction'] = $this->direction ;
$_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr;
$_SESSION[$this->param_prefix.'column'] = $this->column;
$this->pager = null;
$this->default_items_per_page = $default_items_per_page;
$this->total_number_of_items = -1;
$this->get_total_number_function = $get_total_number_function;
$this->get_data_function = $get_data_function;
$this->column_filters = array ();
$this->form_actions = array ();
$this->checkbox_name = null;
$this->td_attributes = array ();
$this->th_attributes = array ();
$this->other_tables = array();
}
/**
* Get the Pager object to split the showed data in several pages
*/
public function get_pager () {
if (is_null($this->pager))
{
$total_number_of_items = $this->get_total_number_of_items();
$params['mode'] = 'Sliding';
$params['perPage'] = $this->per_page;
$params['totalItems'] = $total_number_of_items;
$params['urlVar'] = $this->param_prefix.'page_nr';
$params['currentPage'] = $this->page_nr;
$params['prevImg'] = '';
$params['nextImg'] = '
';
$params['firstPageText'] = '
';
$params['lastPageText'] = '
';
$params['firstPagePre'] = '';
$params['lastPagePre'] = '';
$params['firstPagePost'] = '';
$params['lastPagePost'] = '';
$params['spacesBeforeSeparator'] = '';
$params['spacesAfterSeparator'] = '';
$query_vars = array_keys($_GET);
$query_vars_needed = array ($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page');
if (count($this->additional_parameters) > 0)
{
$query_vars_needed = array_merge($query_vars_needed, array_keys($this->additional_parameters));
}
$query_vars_exclude = array_diff($query_vars, $query_vars_needed);
$params['excludeVars'] = $query_vars_exclude;
$this->pager = & Pager :: factory($params);
}
return $this->pager;
}
/**
* Displays the table, complete with navigation buttons to browse through
* the data-pages.
*/
public function display () {
global $charset;
$empty_table = false;
$html = '';
if ($this->get_total_number_of_items() == 0)
{
$cols = $this->getColCount();
$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols);
if (api_is_xml_http_request()===true) {
$message_empty=api_utf8_encode(get_lang('TheListIsEmpty'));
} else {
$message_empty=get_lang('TheListIsEmpty');
}
$this->setCellContents(1, 0,$message_empty);
$empty_table = true;
}
$html='';
if (!$empty_table)
{
$form = $this->get_page_select_form();
$nav = $this->get_navigation_html();
$html = '
'; $html .= $form; $html .= ' | '; $html .= ''; $html .= $this->get_table_title(); $html .= ' | '; $html .= ''; $html .= $nav; $html .= ' | '; $html .= '