nb = 0;
$this->array = array();
}
/**
*@brief add row of a header in the internal array ($this->array)
* , it uses the $_GET['ord'] parameter,
* @param type $p_header label of the header
* @param type $p_url base url
* @param type $p_sql_asc sql if ascending
* @param type $p_sql_desc sql if descending
* @param type $p_get_asc the value in $_GET if ascending is choosen
* @param type $p_get_desc the value in $_GET if descending is choosen
*/
function add($p_header, $p_url, $p_sql_asc, $p_sql_desc, $p_get_asc, $p_get_desc)
{
$array = array(
'head' => $p_header,
'url' => $p_url,
'sql_asc' => $p_sql_asc,
'sql_desc' => $p_sql_desc,
'parm_asc' => $p_get_asc,
'parm_desc' => $p_get_desc,
'car_asc' => '▲',
'car_desc' => '▼'
);
$ind = $this->nb;
$this->array[$ind] = $array;
$this->nb++;
}
/**
* Returns the header (the value into th tags) with the symbol ascending and
* descending
* @param $p_ind the element (from 0 to nb)
* @return string
*/
function get_header($p_ind)
{
if ($p_ind < 0 || $p_ind > $this->nb)
return 'ERREUR TRI';
$file = str_replace('extension.php', '', $_SERVER['SCRIPT_FILENAME']);
$base = $this->array[$p_ind]['url'];
$str = '';
$str .= '' .
$this->array[$p_ind]['car_asc'] .
'' .
$this->array[$p_ind]['head'] .
'' .
$this->array[$p_ind]['car_desc'] .
'';
return $str;
}
function get_sql_order($p_get)
{
for ($i = 0; $i < $this->nb; $i++)
{
if ($p_get == $this->array[$i]['parm_asc'])
{
$this->array[$i]['car_asc'] = '▲';
return $this->array[$i]['sql_asc'];
}
if ($p_get == $this->array[$i]['parm_desc'])
{
$this->array[$i]['car_desc'] = '▼';
return $this->array[$i]['sql_desc'];
}
}
}
}
?>