noalyss Version-9
icheckbox.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/*!\file
23 * \brief Html Input
24 */
25
26/*!
27 * \class ICheckBox
28 * \brief Html Input
29 */
30class ICheckBox extends HtmlInput
31{
32 var $range;
33
34 function __construct($p_name="", $p_value="", $p_id="")
35 {
36 parent::__construct($p_name, $p_value, $p_id);
37 $this->range="";
38 }
39
40 function get_range($p_name) {
41 return $this->range;
42 }
43 function set_range($p_name) {
44 $this->range=' class="'.$p_name.'" ';
45 }
46 /*!\brief show the html input of the widget*/
47 public function input($p_name=null,$p_value=null,$id="")
48 {
49 $this->name=($p_name==null)?$this->name:$p_name;
50 $this->value=($p_value==null)?$this->value:$p_value;
51 if ( $this->readOnly==true) return $this->display();
52 $this->id=($this->id=="")?$this->name:$this->id;
53
54 $check=( $this->selected==true )?"checked":"unchecked";
55 $r='<input type="CHECKBOX" id="'.$this->id.'" name="'.$this->name.'"'.' value="'.$this->value.'"';
56 $r.=" $check";
58 $r.=$this->get_node_attribute();
59 $r.=' '.$this->disabled." ".$this->javascript.'>';
60
61 $r=$r." $this->label";
62
63 return $r;
64
65
66 }
67 /*!\brief print in html the readonly value of the widget*/
68 public function display()
69 {
70 $check=( $this->selected==true )?"checked":"unchecked";
71 $r='<input type="CHECKBOX" id="'.$this->name.'" name="'.$this->name.'"';
72 $r.=" $check";
73 $r.=' disabled>';
74
75 return $r;
76
77 }
78 /**
79 *set selected to true (checked) if the value equal the parameter
80 * @param $p_value value to compare
81 */
82 public function set_check($p_value)
83 {
84 if ($this->value==$p_value)$this->selected=true;
85 }
86 static function toggle_checkbox($p_name,$p_form) {
87 $a=new ICheckBox($p_name);
88 $a->javascript='onclick="toggle_checkbox(\''.$p_form.'\')"';
89 return $a->input();
90 }
91 /**
92 * Before calling this function , you must set a range with the function set_range. It will add the event on
93 * click (checkbox_set_range)
94 *
95 * @param string $p_name
96 * @returns javascript to execute string
97 */
98 static function javascript_set_range($p_name) {
99 $js=sprintf("(function () {activate_checkbox_range('%s');})();",$p_name);
100 return create_script($js);
101 }
102}
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$select selected
$ret javascript
$from_poste name
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
get_node_attribute()
Insert attribute inside a INPUT TYPE, these attribute can be retrieved in javascript with element....
Html Input.
display()
print in html the readonly value of the widget
__construct($p_name="", $p_value="", $p_id="")
set_check($p_value)
set selected to true (checked) if the value equal the parameter
get_range($p_name)
set_range($p_name)
static toggle_checkbox($p_name, $p_form)
input($p_name=null, $p_value=null, $id="")
show the html input of the widget
$icard readOnly
$check