noalyss Version-9
sort_table.class.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 private $nb;
29 private $array;
30
31 function __construct()
32 {
33 $this->nb = 0;
34 $this->array = array();
35 }
36
37 /**
38 *@brief add row of a header in the internal array ($this->array)
39 * , it uses the $_GET['ord'] parameter,
40 * @param string $p_header label of the header
41 * @param string $p_url base url
42 * @param string $p_sql_asc sql if ascending
43 * @param string $p_sql_desc sql if descending
44 * @param string $p_get_asc the value in $_GET if ascending is choosen
45 * @param string $p_get_desc the value in $_GET if descending is choosen
46 */
47 function add($p_header, $p_url, $p_sql_asc, $p_sql_desc, $p_get_asc, $p_get_desc)
48 {
49 $array = array(
50 'head' => $p_header,
51 'url' => $p_url,
52 'sql_asc' => $p_sql_asc,
53 'sql_desc' => $p_sql_desc,
54 'parm_asc' => $p_get_asc,
55 'parm_desc' => $p_get_desc,
56 'car_asc' => '<span style="font-size:70%">&#9650</span>',
57 'car_desc' => '<span style="font-size:70%">&#9660</span>'
58 );
60 $this->array[$ind] = $array;
61 $this->nb++;
62 }
63/**
64 * Returns the header (the value into th tags) with the symbol ascending and
65 * descending
66 * @param int $p_ind the element (from 0 to nb)
67 * @return string
68 */
69 function get_header($p_ind)
70 {
71 if ($p_ind < 0 || $p_ind > $this->nb)
72 return 'ERREUR TRI';
73 $file = str_replace('extension.php', '', $_SERVER['PHP_SELF']);
74
75 $base = $this->array[$p_ind]['url'];
76 $str = $this->array[$p_ind]['head'] .'';
77 $str .= '<A style="display:inline;text-decoration:none" HREF="' . $base . '&ord=' . $this->array[$p_ind]['parm_asc'] . '">' .
78 $this->array[$p_ind]['car_asc'] .
79 '</A>' .
80
81 '<A style="display:inline;text-decoration:none" HREF="' . $base . '&ord=' . $this->array[$p_ind]['parm_desc'] . '">' .
82 $this->array[$p_ind]['car_desc'] .
83 '</A>';
84 return $str;
85 }
86
87 function get_sql_order($p_get)
88 {
89 for ($i = 0; $i < $this->nb; $i++)
90 {
91 if ($p_get == $this->array[$i]['parm_asc'])
92 {
93 $this->array[$i]['car_asc'] = '<span style="color:red;font-size:70%">&#9650</span>';
94 return $this->array[$i]['sql_asc'];
95 }
96 if ($p_get == $this->array[$i]['parm_desc'])
97 {
98 $this->array[$i]['car_desc'] = '<span style="color:red;font-size:70%">&#9660</span>';
99 return $this->array[$i]['sql_desc'];
100 }
101 }
102 }
103
104}
105
106?>
nb($p_number)
format the number for the CSV export
Definition: ac_common.php:107
$base
Definition: action.inc.php:56
for($i=0;$i<=6;$i++) $ind
Definition: calendar.php:34
Description of class_syn_sort_table.
get_sql_order($p_get)
get_header($p_ind)
Returns the header (the value into th tags) with the symbol ascending and descending.
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,
$str
Definition: fiche.inc.php:91
$p_url