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

« back to all changes in this revision

Viewing changes to frontends/php/include/classes/ccombobox.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:
19
19
**/
20
20
?>
21
21
<?php
 
22
        require_once("include/classes/ctag.inc.php");
 
23
 
22
24
        class CComboItem extends CTag
23
25
        {
24
26
/* public */
59
61
        class CComboBox extends CTag
60
62
        {
61
63
/* private */
62
 
                var $value;
 
64
                //var $value;
63
65
 
64
66
/* public */
65
67
                function CComboBox($name='combobox',$value=NULL,$action=NULL)
80
82
                {
81
83
                        $this->value = $value;
82
84
                }
83
 
                function AddItem($value, $caption, $selected=NULL, $enabled='yes')
 
85
                function AddItem($value, $caption='', $selected=NULL, $enabled='yes')
84
86
                {
85
87
//                      if($enabled=='no') return;      /* disable item method 1 */
86
88
 
98
100
        class CListBox extends CComboBox
99
101
        {
100
102
/* public */
101
 
                function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL)
 
103
                function CListBox($name='listbox',$value=NULL,$size=5,$action=NULL)
102
104
                {
103
105
                        parent::CComboBox($name,NULL,$action);
104
106
                        $this->options['multiple'] = 'multiple';
111
113
                }
112
114
        }
113
115
 
 
116
        function        inseret_javascript_for_editable_combobox()
 
117
        {
 
118
                if(defined('EDITABLE_COMBOBOX_SCRIPT_INSERTTED')) return;
 
119
 
 
120
                define('EDITABLE_COMBOBOX_SCRIPT_INSERTTED', 1);
 
121
?>
 
122
<script language="JavaScript" type="text/javascript">
 
123
<!--
 
124
                function CEditableComboBoxInit(obj)
 
125
                {
 
126
                        var opt = obj.options;
 
127
 
 
128
                        if(obj.value) obj.oldValue = obj.value;
 
129
 
 
130
                        for (var i = 0; i < opt.length; i++)
 
131
                                if (-1 == opt.item(i).value)
 
132
                                        return;
 
133
 
 
134
                        opt = document.createElement("option");
 
135
                        opt.value = -1;
 
136
                        opt.text = "(other ...)";
 
137
 
 
138
                        if(!obj.options.add)
 
139
                                obj.insertBefore(opt, obj.options.item(0));
 
140
                        else
 
141
                                obj.options.add(opt, 0);
 
142
 
 
143
                        return;
 
144
                }
 
145
 
 
146
                function CEditableComboBoxOnChange(obj,size)
 
147
                {
 
148
                        if(-1 != obj.value)
 
149
                        {
 
150
                                obj.oldValue = obj.value;
 
151
                        }
 
152
                        else
 
153
                        {
 
154
                                var new_obj = document.createElement("input");
 
155
                                new_obj.type = "text";
 
156
                                new_obj.name = obj.name;
 
157
                                if(size && size > 0)
 
158
                                {
 
159
                                        new_obj.size = size;
 
160
                                }
 
161
                                new_obj.className = obj.className;
 
162
                                if(obj.oldValue) new_obj.value = obj.oldValue;
 
163
                                obj.parentNode.replaceChild(new_obj, obj);
 
164
                                new_obj.focus();
 
165
                                new_obj.select();
 
166
                        }
 
167
                }
 
168
-->
 
169
</script>
 
170
<?php
 
171
        }
 
172
 
 
173
        class CEditableComboBox extends CComboBox
 
174
        {
 
175
                function CEditableComboBox($name='editablecombobox',$value=NULL,$size=0,$action=NULL)
 
176
                {
 
177
                        inseret_javascript_for_editable_combobox();
 
178
 
 
179
                        parent::CComboBox($name,$value,$action);
 
180
                        parent::AddAction('onfocus','CEditableComboBoxInit(this);');
 
181
                        parent::AddAction('onchange','CEditableComboBoxOnChange(this,'.$size.');');
 
182
                }
 
183
 
 
184
                function AddItem($value, $caption='', $selected=NULL, $enabled='yes')
 
185
                {
 
186
                        if(is_null($selected))
 
187
                        {
 
188
                                if($value == $this->value || (is_array($this->value) && in_array($value, $this->value)))
 
189
                                        $this->value_exist = 1;
 
190
                        }
 
191
 
 
192
                        parent::AddItem($value,$caption,$selected,$enabled);
 
193
                }
 
194
 
 
195
                function ToString($destroy=true)
 
196
                {
 
197
                        if(!isset($this->value_exist) && !empty($this->value))
 
198
                        {
 
199
                                $this->AddItem($this->value, $this->value, 'yes');
 
200
                        }
 
201
                        return parent::ToString($destroy);
 
202
                }
 
203
        }
114
204
?>