noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_sort_table.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 
00021 /**
00022  * Description of class_syn_sort_table
00023  *
00024  * @author dany
00025  */
00026 class Sort_Table
00027 {
00028 
00029     function __construct()
00030     {
00031         $this->nb = 0;
00032         $this->array = array();
00033     }
00034 
00035     /**
00036      *@brief add row of a header in the internal array ($this->array)
00037      * , it uses the $_GET['ord'] parameter,
00038      * @param type $p_header label of the header
00039      * @param type $p_url base url
00040      * @param type $p_sql_asc sql if ascending
00041      * @param type $p_sql_desc sql if descending
00042      * @param type $p_get_asc the value in $_GET if ascending is choosen
00043      * @param type $p_get_desc the value in $_GET if descending is choosen
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>&#9650</span>',
00055             'car_desc' => '<span>&#9660</span>'
00056         );
00057         $ind = $this->nb;
00058         $this->array[$ind] = $array;
00059         $this->nb++;
00060     }
00061 /**
00062  * Returns the header (the value into th tags) with the symbol ascending and
00063  * descending
00064  * @param  $p_ind the element (from 0 to nb)
00065  * @return string
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">&#9650</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">&#9660</span>';
00097                 return $this->array[$i]['sql_desc'];
00098             }
00099         }
00100     }
00101 
00102 }
00103 
00104 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations