~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to frontends/php/include/classes/ctextbox.inc.php

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2007-07-02 09:06:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070702090651-8l6fl3fjw9rh6l2u
Tags: 1:1.4.1-2
Add patch from SVN in order to fix Incorrect processing of character '%'
in user parameters and remote commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        class CTextBox extends CTag
23
23
        {
24
24
/* private */
25
 
                var $caption;
 
25
                //var $caption;
26
26
/* public */
27
27
                function CTextBox($name='textbox',$value="",$size=20,$readonly="no")
28
28
                {
 
29
                        $this->caption = null;
29
30
                        parent::CTag('input','no');
 
31
                        $this->tag_body_start = '';
30
32
                        $this->options['class'] = 'biginput';
31
 
                        $this->options['name'] = $name;
32
 
                        $this->options['size'] = $size;
33
 
                        $this->options['value'] = $value;
 
33
                        $this->AddOption('name', $name);
 
34
                        $this->AddOption('size', $size);
 
35
                        $this->AddOption('value',$value);
34
36
                        $this->SetReadonly($readonly);
35
37
                }
36
38
                function SetReadonly($value='yes')
61
63
                }
62
64
        }
63
65
 
 
66
        class CNumericBox extends CTextBox
 
67
        {
 
68
                function CNumericBox($name='number',$value='0',$size=20,$readonly="no",$allowempty=false)
 
69
                {
 
70
                        parent::CTextBox($name,$value,$size,$readonly);
 
71
                        $this->AddOption('MaxLength', $size);
 
72
                        $this->AddOption('Style', 'text-align: right;');
 
73
                        $this->AddAction('OnKeyPress',
 
74
                                ' var c = (window.event) ? event.keyCode : event.which;'.
 
75
                                ' if(event.ctrlKey || c <= 31 || (c >= 48 && c <= 57)) return true; else return false; ');
 
76
                        $this->AddAction('OnChange',
 
77
                                        ($allowempty ? ' if(this.value.length==0 || this.value==null) this.value = \'\'; else ' : '').
 
78
                                        ' if(isNaN(parseInt(this.value))) this.value = 0; '.
 
79
                                        ' else this.value = parseInt(this.value);'
 
80
                                );
 
81
                }
 
82
        }
 
83
 
 
84
        class CIpBox
 
85
        {
 
86
                //var $ip_parts = array();
 
87
                
 
88
                function CIPBox($name='ip',$value)
 
89
                {
 
90
                        $this->ip_parts = array();
 
91
 
 
92
                        if(!is_array($value)) $value = explode('.', $value);
 
93
                        if(!isset($value[0])) $value[0] = 0;
 
94
                        if(!isset($value[1])) $value[1] = 0;
 
95
                        if(!isset($value[2])) $value[2] = 0;
 
96
                        if(!isset($value[3])) $value[3] = 0;
 
97
                        
 
98
                        for($i = 0; $i < 4; $i++)
 
99
                        {
 
100
                                $this->ip_parts[$i] = new CNumericBox($name.'['.$i.']', $value[$i], 3);
 
101
                                if($i != 3)
 
102
                                {
 
103
                                        $this->ip_parts[$i]->tag_end = '';
 
104
                                        $this->ip_parts[$i]->AddAction('OnKeyDown',
 
105
                                                ' this.maxlength = this.getAttribute("maxlength"); '.
 
106
                                                ' this.oldlength = this.value.length; ');
 
107
                                        $this->ip_parts[$i]->AddAction('OnKeyUp',
 
108
                                                ' if(this.oldlength != this.value.length && this.value.length == this.maxlength) {'.
 
109
                                                ' var el = this.form.elements["'.$name.'['.($i+1).']'.'"];'.
 
110
                                                ' if(el) { el.focus(); el.select(); }}');
 
111
                                }
 
112
                                $this->ip_parts[$i] = unpack_object($this->ip_parts[$i]);
 
113
                        }
 
114
                }
 
115
 
 
116
                function ToString($destroy=true)
 
117
                {
 
118
                        $res = implode('.',$this->ip_parts);
 
119
                        
 
120
                        if($destroy)
 
121
                        {
 
122
### TODO Problem under PHP 5.0  "Fatal error: Cannot re-assign $this in ..."
 
123
#                               $this = null;
 
124
                        }
 
125
 
 
126
                        return $res;
 
127
                }
 
128
 
 
129
                function Show($destroy=true)
 
130
                {
 
131
                        echo $this->ToString($destroy);
 
132
                }
 
133
        }
 
134
 
64
135
?>