noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_sort_table.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 // Copyright Author Dany De Bontridder danydb@aevalys.eu
20 
21 /**
22  * Description of class_syn_sort_table
23  *
24  * @author dany
25  */
27 {
28 
29  function __construct()
30  {
31  $this->nb = 0;
32  $this->array = array();
33  }
34 
35  /**
36  *@brief add row of a header in the internal array ($this->array)
37  * , it uses the $_GET['ord'] parameter,
38  * @param type $p_header label of the header
39  * @param type $p_url base url
40  * @param type $p_sql_asc sql if ascending
41  * @param type $p_sql_desc sql if descending
42  * @param type $p_get_asc the value in $_GET if ascending is choosen
43  * @param type $p_get_desc the value in $_GET if descending is choosen
44  */
45  function add($p_header, $p_url, $p_sql_asc, $p_sql_desc, $p_get_asc, $p_get_desc)
46  {
47  $array = array(
48  'head' => $p_header,
49  'url' => $p_url,
50  'sql_asc' => $p_sql_asc,
51  'sql_desc' => $p_sql_desc,
52  'parm_asc' => $p_get_asc,
53  'parm_desc' => $p_get_desc,
54  'car_asc' => '<span>&#9650</span>',
55  'car_desc' => '<span>&#9660</span>'
56  );
57  $ind = $this->nb;
58  $this->array[$ind] = $array;
59  $this->nb++;
60  }
61 /**
62  * Returns the header (the value into th tags) with the symbol ascending and
63  * descending
64  * @param $p_ind the element (from 0 to nb)
65  * @return string
66  */
67  function get_header($p_ind)
68  {
69  if ($p_ind < 0 || $p_ind > $this->nb)
70  return 'ERREUR TRI';
71  $file = str_replace('extension.php', '', $_SERVER['SCRIPT_FILENAME']);
72 
73  $base = $this->array[$p_ind]['url'];
74  $str = '';
75  $str .= '<A style="display:inline" HREF="' . $base . '&ord=' . $this->array[$p_ind]['parm_asc'] . '">' .
76  $this->array[$p_ind]['car_asc'] .
77  '</A>' .
78  $this->array[$p_ind]['head'] .
79  '<A style="display:inline" HREF="' . $base . '&ord=' . $this->array[$p_ind]['parm_desc'] . '">' .
80  $this->array[$p_ind]['car_desc'] .
81  '</A>';
82  return $str;
83  }
84 
85  function get_sql_order($p_get)
86  {
87  for ($i = 0; $i < $this->nb; $i++)
88  {
89  if ($p_get == $this->array[$i]['parm_asc'])
90  {
91  $this->array[$i]['car_asc'] = '<span style="color:red">&#9650</span>';
92  return $this->array[$i]['sql_asc'];
93  }
94  if ($p_get == $this->array[$i]['parm_desc'])
95  {
96  $this->array[$i]['car_desc'] = '<span style="color:red">&#9660</span>';
97  return $this->array[$i]['sql_desc'];
98  }
99  }
100  }
101 
102 }
103 
104 ?>
$base
Definition: action.inc.php:55
$str
Definition: fiche.inc.php:97
nb($p_number)
format the number for the CSV export
Definition: ac_common.php:107
$p_url
get_header($p_ind)
Returns the header (the value into th tags) with the symbol ascending and descending.
get_sql_order($p_get)
Description of class_syn_sort_table.
for($i=0;$i<=6;$i++) $ind
Definition: calendar.php:29
add($p_header, $p_url, $p_sql_asc, $p_sql_desc, $p_get_asc, $p_get_desc)
add row of a header in the internal array ($this->array) , it uses the $_GET['ord'] parameter...