Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 class Sort_Table
00027 {
00028
00029 function __construct()
00030 {
00031 $this->nb = 0;
00032 $this->array = array();
00033 }
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 function add($p_header, $p_url, $p_sql_asc, $p_sql_desc, $p_get_asc, $p_get_desc)
00046 {
00047 $array = array(
00048 'head' => $p_header,
00049 'url' => $p_url,
00050 'sql_asc' => $p_sql_asc,
00051 'sql_desc' => $p_sql_desc,
00052 'parm_asc' => $p_get_asc,
00053 'parm_desc' => $p_get_desc,
00054 'car_asc' => '<span>▲</span>',
00055 'car_desc' => '<span>▼</span>'
00056 );
00057 $ind = $this->nb;
00058 $this->array[$ind] = $array;
00059 $this->nb++;
00060 }
00061
00062
00063
00064
00065
00066
00067 function get_header($p_ind)
00068 {
00069 if ($p_ind < 0 || $p_ind > $this->nb)
00070 return 'ERREUR TRI';
00071 $file = str_replace('extension.php', '', $_SERVER['SCRIPT_FILENAME']);
00072
00073 $base = $this->array[$p_ind]['url'];
00074 $str = '';
00075 $str .= '<A style="display:inline" HREF="' . $base . '&ord=' . $this->array[$p_ind]['parm_asc'] . '">' .
00076 $this->array[$p_ind]['car_asc'] .
00077 '</A>' .
00078 $this->array[$p_ind]['head'] .
00079 '<A style="display:inline" HREF="' . $base . '&ord=' . $this->array[$p_ind]['parm_desc'] . '">' .
00080 $this->array[$p_ind]['car_desc'] .
00081 '</A>';
00082 return $str;
00083 }
00084
00085 function get_sql_order($p_get)
00086 {
00087 for ($i = 0; $i < $this->nb; $i++)
00088 {
00089 if ($p_get == $this->array[$i]['parm_asc'])
00090 {
00091 $this->array[$i]['car_asc'] = '<span style="color:red">▲</span>';
00092 return $this->array[$i]['sql_asc'];
00093 }
00094 if ($p_get == $this->array[$i]['parm_desc'])
00095 {
00096 $this->array[$i]['car_desc'] = '<span style="color:red">▼</span>';
00097 return $this->array[$i]['sql_desc'];
00098 }
00099 }
00100 }
00101
00102 }
00103
00104 ?>