noalyss Version-9
Public Member Functions | Private Attributes
Inplace_Switch Class Reference

A switch let you switch between 2 values : 0 and 1, it is used to replace the check. More...

+ Collaboration diagram for Inplace_Switch:

Public Member Functions

 __construct ($p_name, $p_value)
 
 add_json_param ($p_attribute, $p_value)
 Add json parameter to the current one, if there attribute already exists it will be overwritten. More...
 
 get_callback ()
 
 get_iconoff ()
 
 get_iconon ()
 
 get_jscript ()
 
 get_json ()
 
 get_name ()
 
 get_value ()
 
 input ()
 
 set_callback ($callback)
 
 set_iconoff ($iconoff)
 
 set_iconon ($iconon)
 
 set_jscript ($jscript)
 
 set_json ($json)
 
 set_name ($name)
 
 set_value ($value)
 

Private Attributes

 $callback
 callback More...
 
 $iconoff
 The icon off. More...
 
 $iconon
 The icon on. More...
 
 $jscript
 Supplemental javascript command, execute after the ajax script. More...
 
 $json
 Json object. More...
 
 $name
 name of the widget, javascript id must be unique More...
 
 $value
 value More...
 

Detailed Description

A switch let you switch between 2 values : 0 and 1, it is used to replace the check.

Definition at line 33 of file inplace_switch.class.php.

Constructor & Destructor Documentation

◆ __construct()

Inplace_Switch::__construct (   $p_name,
  $p_value 
)

Definition at line 51 of file inplace_switch.class.php.

52 {
53 $this->name=$p_name;
54 $this->value=$p_value;
55 $this->iconon=Icon_Action::iconon(uniqid(), "");
56 $this->iconoff=Icon_Action::iconoff(uniqid(), "");
57 $this->json=json_encode(['name'=>$p_name,"value"=>$p_value], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
58 $this->callback="ajax.php";
59 $this->jscript="";
60 }
$from_poste name
static iconoff($p_id, $p_javascript, $p_style="")
Display a icon OFF.
static iconon($p_id, $p_javascript, $p_style="")
Display a icon ON.

References Icon_Action\iconoff(), Icon_Action\iconon(), name, and value.

+ Here is the call graph for this function:

Member Function Documentation

◆ add_json_param()

Inplace_Switch::add_json_param (   $p_attribute,
  $p_value 
)

Add json parameter to the current one, if there attribute already exists it will be overwritten.

Definition at line 164 of file inplace_switch.class.php.

164 {
165 $x=json_decode($this->json,TRUE);
166 $x[$p_attribute]=$p_value;
167 $this->json=json_encode($x, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
168 }

◆ get_callback()

Inplace_Switch::get_callback ( )

Definition at line 106 of file inplace_switch.class.php.

107 {
108 return $this->callback;
109 }

References $callback.

◆ get_iconoff()

Inplace_Switch::get_iconoff ( )

Definition at line 126 of file inplace_switch.class.php.

127 {
128 return $this->iconoff;
129 }

References $iconoff.

◆ get_iconon()

Inplace_Switch::get_iconon ( )

Definition at line 121 of file inplace_switch.class.php.

122 {
123 return $this->iconon;
124 }

References $iconon.

◆ get_jscript()

Inplace_Switch::get_jscript ( )

Definition at line 91 of file inplace_switch.class.php.

92 {
93 return $this->jscript;
94 }
$jscript
Supplemental javascript command, execute after the ajax script.

References $jscript.

◆ get_json()

Inplace_Switch::get_json ( )

Definition at line 101 of file inplace_switch.class.php.

102 {
103 return $this->json;
104 }

References $json.

◆ get_name()

Inplace_Switch::get_name ( )

Definition at line 131 of file inplace_switch.class.php.

132 {
133 return $this->name;
134 }
$name
name of the widget, javascript id must be unique

References $name.

◆ get_value()

Inplace_Switch::get_value ( )

Definition at line 136 of file inplace_switch.class.php.

137 {
138 return $this->value;
139 }

References $value.

◆ input()

Inplace_Switch::input ( )

Definition at line 62 of file inplace_switch.class.php.

63 {
64 if ($this->value==1)
65 {
66 $icon=$this->iconon;
67 $color="green";
68 }
69 elseif ($this->value==0)
70 {
71 $icon=$this->iconoff;
72 $color="red";
73 }
74 else
75 {
76 throw new Exception(_("Invalide value"));
77 }
78
79 $r=sprintf('<span style="text-decoration: none;color:%s" class="inplace_edit icon" id="%s">', $color,$this->name);
80 $r.=$icon;
81 $r.= '</span>';
82 $r.=<<<EOF
83 <script>
84{$this->name}.onclick=function() {new Ajax.Updater({$this->name},'{$this->callback}',{method:"get",parameters:{$this->json},evalScripts:true} );
85 {$this->jscript}
86 }
87</script>
88EOF;
89 return $r;
90 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
if( $delta< 0) elseif( $delta==0)

References $color, $iconoff, $iconon, $r, elseif, name, and value.

◆ set_callback()

Inplace_Switch::set_callback (   $callback)

Definition at line 116 of file inplace_switch.class.php.

117 {
118 $this->callback=$callback;
119 }

References $callback.

◆ set_iconoff()

Inplace_Switch::set_iconoff (   $iconoff)

Definition at line 146 of file inplace_switch.class.php.

147 {
148 $this->iconoff=$iconoff;
149 }

References $iconoff.

◆ set_iconon()

Inplace_Switch::set_iconon (   $iconon)

Definition at line 141 of file inplace_switch.class.php.

142 {
143 $this->iconon=$iconon;
144 }

References $iconon.

◆ set_jscript()

Inplace_Switch::set_jscript (   $jscript)

Definition at line 96 of file inplace_switch.class.php.

97 {
98 $this->jscript=$jscript;
99 }

References $jscript.

◆ set_json()

Inplace_Switch::set_json (   $json)

Definition at line 111 of file inplace_switch.class.php.

112 {
113 $this->json=$json;
114 }

References $json.

◆ set_name()

Inplace_Switch::set_name (   $name)

Definition at line 151 of file inplace_switch.class.php.

152 {
153 $this->name=$name;
154 }

References $name, and name.

◆ set_value()

Inplace_Switch::set_value (   $value)

Definition at line 156 of file inplace_switch.class.php.

157 {
158 $this->value=$value;
159 }

References $value, and value.

Field Documentation

◆ $callback

Inplace_Switch::$callback
private

callback

Definition at line 47 of file inplace_switch.class.php.

Referenced by get_callback(), and set_callback().

◆ $iconoff

Inplace_Switch::$iconoff
private

The icon off.

Definition at line 39 of file inplace_switch.class.php.

Referenced by get_iconoff(), input(), and set_iconoff().

◆ $iconon

Inplace_Switch::$iconon
private

The icon on.

Definition at line 37 of file inplace_switch.class.php.

Referenced by get_iconon(), input(), and set_iconon().

◆ $jscript

Inplace_Switch::$jscript
private

Supplemental javascript command, execute after the ajax script.

Definition at line 49 of file inplace_switch.class.php.

Referenced by get_jscript(), and set_jscript().

◆ $json

Inplace_Switch::$json
private

Json object.

Definition at line 45 of file inplace_switch.class.php.

Referenced by get_json(), and set_json().

◆ $name

Inplace_Switch::$name
private

name of the widget, javascript id must be unique

Definition at line 41 of file inplace_switch.class.php.

Referenced by get_name(), and set_name().

◆ $value

Inplace_Switch::$value
private

value

Definition at line 43 of file inplace_switch.class.php.

Referenced by get_value(), and set_value().


The documentation for this class was generated from the following file: