noalyss Version-9
iselect.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!
23 * \file
24 * \brief Html Input , create a tag <SELECT> ... </SELECT>
25 * if readonly == true then display the label corresponding to the selected value
26 * You can use also $this->rowsize to specify the number of lines to display
27 *
28 * @see Database::make_array
29 */
30
31/*!
32 * \class ISelect
33 * \brief Html Input , create a tag <SELECT> ... </SELECT>
34 * if readonly == true then display the label corresponding to the selected value
35 * You can use also $this->rowsize to specify the number of lines to display
36 *
37 * @see Database::make_array
38 */
39class ISelect extends HtmlInput
40{
41 /**
42 * Constructor , $p_value is supposed to be an array
43 * @param string $p_name name of the element
44 * @param array $p_value
45 * @param DOMID $p_id
46 */
47 function __construct($p_name="", $p_value="", $p_id="")
48 {
49 parent::__construct($p_name, $p_value, $p_id);
50 if ( $p_value =="" )
51 {
52 $this->value=[];
53 } else {
54 $this->value=$p_value;
55 }
56 }
57 /*!\brief show the html input of the widget*/
58 public function input($p_name=null,$p_value=null)
59 {
60 $this->name=($p_name==null)?$this->name:$p_name;
61 $this->value=($p_value==null)?$this->value:$p_value;
62 if ( $this->readOnly==true) return $this->display();
63 $style=(isset($this->style))?$this->style:"";
64 $this->id=($this->id=="")?$this->name:$this->id;
65
66 $disabled=($this->disabled==true)?"disabled":"";
67 $rowsize = (isset ($this->rowsize)) ? ' size = "'.$this->rowsize.'"':"";
68
69 $r="";
70
71 $a="<SELECT id=\"$this->id\" NAME=\"$this->name\" $style $this->javascript $disabled $rowsize>";
72 if (empty($this->value)) return '';
73 for ( $i=0;$i<sizeof($this->value);$i++)
74 {
75 $checked=($this->selected==$this->value[$i]['value'])?"SELECTED":"";
76 $a.='<OPTION VALUE="'.$this->value[$i]['value'].'" '.$checked.'>';
77 $a.=strip_tags($this->value[$i]['label']);
78 }
79 $a.="</SELECT>";
80 if ( $this->table == 1 ) $a='<td>'.$a.'</td>';
81
82 return $r.$a;
83 }
84 /*!\brief print in html the readonly value of the widget*/
85 public function display()
86 {
87 $r="";
88 if ($this->value == null) {
89 $this->value=array();
90 }
91 for ( $i=0;$i<sizeof($this->value);$i++)
92 {
93 if ($this->selected==$this->value[$i]['value'] )
94 {
95 $r=htmlentities($this->value[$i]['label'],ENT_QUOTES|ENT_HTML5,'UTF-8',true);
96
97 }
98 }
99 // $r='<span class="input_text_ro">'.$r.'</span>';
100 if ( $this->table == 1 ) $r='<td>'.$r.'</td>';
101 return $r;
102 }
103 /*!\brief print in html the readonly value of the widget*/
104 public function get_value()
105 {
106 $r="";
107 for ( $i=0;$i<sizeof($this->value);$i++)
108 {
109 if ($this->selected==$this->value[$i]['value'] )
110 {
111 $r=$this->value[$i]['label'];
112
113 }
114 }
115 return $r;
116 }
117 /**
118 * @brief set the value of an ISelect with the array , this array
119 * is bidimensional , the first dimension is the code to store and the second
120 * is the label to display.
121 * Example
122 * @code
123 * array(array('M'=>'Mister'),array('Ms'=>'Miss'));
124 * // will be turned into
125 * array( array("value"=>'M,"label"=>"Mister")...)
126 * @endcode
127 * @param array $p_array
128 */
129 public function transform($p_array) {
130 if (! is_array($p_array) || count($p_array)==0) return ;
131 $a_ret=array();
132 foreach ($p_array as $key=>$value) {
133 $a_ret['value']=$key;
134 $a_ret['label']=$value;
135 $this->value[]=$a_ret;
136 }
137 }
138 function set_value($p_string) {
139 $this->selected=$p_string;
140 }
141 static public function test_me()
142 {
143 }
144}
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$select selected
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
$opd_description style
$from_poste name
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
input($p_name=null, $p_value=null)
show the html input of the widget
get_value()
print in html the readonly value of the widget
set_value($p_string)
Set the value of input (IText, INum,...)
display()
print in html the readonly value of the widget
transform($p_array)
set the value of an ISelect with the array , this array is bidimensional , the first dimension is the...
__construct($p_name="", $p_value="", $p_id="")
Constructor , $p_value is supposed to be an array.
static test_me()
$all table
$icard readOnly
$action rowsize
$all disabled