noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_iselect.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 
20 // Copyright Author Dany De Bontridder danydb@aevalys.eu
21 
22 /*!\file
23  * \brief Html Input , create a tag <SELECT> ... </SELECT>
24  * if readonly == true then display the label corresponding to the selected value
25  * You can use also $this->rowsize to specify the number of lines to display
26  *
27  * @see Database::make_array
28  */
29 require_once NOALYSS_INCLUDE.'/lib/class_html_input.php';
30 class ISelect extends HtmlInput
31 {
32  /*!\brief show the html input of the widget*/
33  public function input($p_name=null,$p_value=null)
34  {
35  $this->name=($p_name==null)?$this->name:$p_name;
36  $this->value=($p_value==null)?$this->value:$p_value;
37  if ( $this->readOnly==true) return $this->display();
38  $style=(isset($this->style))?$this->style:"";
39  $this->id=($this->id=="")?$this->name:$this->id;
40 
41  $disabled=($this->disabled==true)?"disabled":"";
42  $rowsize = (isset ($this->rowsize)) ? ' size = "'.$this->rowsize.'"':"";
43 
44  $r="";
45 
46  $a="<SELECT id=\"$this->id\" NAME=\"$this->name\" $style $this->javascript $disabled $rowsize>";
47  if (empty($this->value)) return '';
48  for ( $i=0;$i<sizeof($this->value);$i++)
49  {
50  $checked=($this->selected==$this->value[$i]['value'])?"SELECTED":"";
51  $a.='<OPTION VALUE="'.$this->value[$i]['value'].'" '.$checked.'>';
52  $a.=$this->value[$i]['label'];
53  }
54  $a.="</SELECT>";
55  if ( $this->table == 1 ) $a='<td>'.$a.'</td>';
56 
57  return $r.$a;
58  }
59  /*!\brief print in html the readonly value of the widget*/
60  public function display()
61  {
62  $r="";
63  for ( $i=0;$i<sizeof($this->value);$i++)
64  {
65  if ($this->selected==$this->value[$i]['value'] )
66  {
67  $r=h($this->value[$i]['label']);
68 
69  }
70  }
71  if ( $this->table == 1 ) $a='<td>'.$r.'</td>';
72  return $r;
73  }
74  /**
75  * @brief set the value of an ISelect with the array , this array
76  * is bidimensional , the first dimension is the code to store and the second
77  * is the label to display.
78  * Example
79  * @code
80  * array(array('M'=>'Mister'),array('Ms'=>'Miss'));
81  * // will be turned into
82  * array( array("value"=>'M,"label"=>"Mister")...)
83  * @endcode
84  * @param type $p_array
85  * @return type
86  */
87  public function transform($p_array) {
88  if (count($p_array)==0) return array();
89  $a_ret=array();
90  foreach ($p_array as $key=>$value) {
91  $a_ret['value']=$key;
92  $a_ret['label']=$value;
93  $this->value[]=$a_ret;
94  }
95  }
96  static public function test_me()
97  {
98  }
99 }
$opd_description style
transform($p_array)
set the value of an ISelect with the array , this array is bidimensional , the first dimension is the...
$all disabled
if(!defined('ALLOWED'))
for($e=0;$e< count($array);$e++) $desc readOnly
static test_me()
display()
print in html the readonly value of the widget
$from_poste name
h($p_string)
to protect again bad characters which can lead to a cross scripting attack the string to be diplayed ...
Definition: ac_common.php:38
input($p_name=null, $p_value=null)
show the html input of the widget
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
$select_type table
$me_code selected