noalyss Version-9
input_checkbox.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * * Copyright (C) 2019 Dany De Bontridder <dany@alchimerys.be>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Aut
20 *
21 */
22
23// Copyright Author Dany De Bontridder danydb@noalyss.eu
24
25/**
26 * @file
27 * @brief modern checkbox, using a javascript to change the icon when clicked and a hidden field, there is always a
28 * value , either 1 or 0 EXPERIMENTAL
29 */
30/**
31 * @class
32 * @brief modern checkbox, using a javascript to change the icon when clicked and a hidden field, there is always a
33 * value , either 1 or 0 , EXPERIMENTAL
34 */
35
37{
38
39 var $icon;
41 var $value;
42 /**
43 * Construct an input_checkbox object
44 *
45 * @param string $name of the hidden
46 * @param bool $value Value is 1 or 0
47 * @param string $p_id id of the hidden
48 */
49 function __construct($name='', $value='', $p_id="")
50 {
51 $this->value_container=$name;
52 $this->value=$value;
53
54 $this->id_hidden=$p_id;
55 $this->id_icon=uniqid($p_id);
56 $this->javascript="";
57 $this->classrange="";
58 }
59
60 function input($p_name=NULL, $p_value=0)
61 {
62 $r="";
63 if ($p_name!=NULL)
64 $this->value_container=$p_name;
65 if ($p_value!==0)
66 $this->value=$p_value;
67
68
69 if ( trim($this->value_container) ==="" || trim($this->value) === "") {
70 throw new Exception(_("Valeur invalide"),1);
71 }
72 if ($this->readOnly == TRUE) {
73 return $this->display();
74 }
75 $r.= HtmlInput::hidden($this->value_container, $this->value,$this->id_hidden);
76
77 $this->javascript=sprintf('toggle_checkbox_onoff(\'%s\',\'%s\');%s;',
78 $this->id_icon,
79 $this->id_hidden,
80 $this->javascript);
81
82 if ($this->value=='1') {
83 $r.=Icon_Action::checked($this->id_icon,$this->javascript,$this->classrange);
84 } else {
85 $r.=Icon_Action::unchecked($this->id_icon,$this->javascript,$this->classrange);
86 }
87 return $r;
88 }
89 function display()
90 {
91 if ($this->value=='1') {
92 return Icon_Action::checked($this->id_icon, "");
93 } else {
94 return Icon_Action::unchecked($this->id_icon, "");
95 }
96 }
97
98 /**
99 * click several checkbox when you shift click on that name
100 */
101 function click_range()
102 {
103
104 }
105
106}
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$ret javascript
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
static hidden($p_name, $p_value, $p_id="")
static checked($p_id, $p_javascript="", $p_classrange="")
static unchecked($p_id, $p_javascript="", $p_classrange="")
__construct($name='', $value='', $p_id="")
Construct an input_checkbox object.
click_range()
click several checkbox when you shift click on that name
input($p_name=NULL, $p_value=0)
$icard readOnly