Umfragen
widget.class.php
Go to the documentation of this file.
1 <?php
2 /*
3  * widget.class.php
4  *
5  * Copyright 2012 Johannes <jojo@jojo-42>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301, USA.
21  *
22  *
23  */
24 
25 require_once("Exceptions.class.php");
26 
27 
28 interface iWidget{
29 
30  /*public $pollID;
31  public $name;
32  public $value;
33  public $config;
34  public $is_required = false;
35  public $dispName;
36  public $index;
37  public $ID;
38  public $is_child = false;
39  public $parent = -1; */
40 
41  /*
42  * should be inherited from widget base class
43  * */
47  public function serialize_config();
48 
52  public function unserialize_config();
53 
57  public function set_config($name,$val);
58 
62  public function get_config($name);
63 
67  public function check_vital_vars();
68 
72  public function check_required();
73 
77  public function check_max();
78 
82  public function set_dispName($dispName);
83 
87  public function set_name($name);
88 
92  public function display_edit_begin();
93 
97  public function display_name_edit();
98 
102  public function handle_name_edit();
103 
107  public function display_dispName_edit();
108 
112  public function handle_dispName_edit();
113 
117  public function display_required_edit();
118 
122  public function handle_required_edit();
123 
127  public function display_chartType_edit_generic($allowed,$allowed_names);
128 
132  public function handle_chartType_edit_generic($allowed);
133 
137  public function save_config($db);
138 
142  public function save_dispName($db);
143 
147  public function save_required($db);
148 
152  public function save_name($db,$new_name);
153 
154  /*
155  * has to be implemented for each
156  * */
157 
161  public function display_edit();
162 
166  public function set_default_values($db);
167 
168 }
169 
170 interface input_widget{
175  public function handle_inpt();
176 }
177 interface output_widget{
181  public function display();
182 
183 }
184 
196  public function count($db);
197 }
198 
204  public function chart_format_data();
205 
209  public function chart_display_chart();
210 
214  public function chart_display_legend();
215 
219  public function chart_display();
220 
224  public function chart_make();
225 }
226 
227 
228 require("widgetBaseClass.class.php");
229 require("container.class.php");
230 
231 require("text.class.php");
232 require("longtext.class.php");
233 
234 require("radioButton.class.php");
235 require("radioButtonList.class.php");
236 
237 require("checkBox.class.php");
238 require("checkBoxList.class.php");
239 
240 require("checkBoxSingle.class.php");
241 
242 require("matrixOption.class.php");
243 require("matrixQuestion.class.php");
244 require("matrix.class.php");
245 
246 require("label.class.php");
247 require("labelTiny.class.php");
248 require("line.class.php");
249 require("textExt.class.php");
250 
251 require("scheduleOption.class.php");
252 require("scheduleName.class.php");
253 require("scheduleDate.class.php");
254 require("schedule.class.php");
255 
256 
257 
263 function widgetFactory($type){
264  // input widgets
265  if( $type == "text" ){
266  $widget = new text();
267  }else if ($type == "radioButtonList"){
268  $widget = new radioButtonList();
269  }else if ($type == "checkBoxSingle"){
270  $widget = new checkBoxSingle();
271  }else if ($type == "checkBoxList"){
272  $widget = new checkBoxList();
273  }else if ($type == "matrix"){
274  $widget = new matrix();
275  }else if ($type == "schedule"){
276  $widget = new schedule();
277  }else if ($type == "longtext"){
278  $widget = new longtext();
279  }else if( $type == "textExt" ){
280  $widget = new textExt();
281  //output widgets
282  }else if ($type == "label"){
283  $widget = new label();
284  }else if ($type == "line"){
285  $widget = new line();
286  // sub widgets
287  }else if($type == "radioButton"){
288  $widget = new radioButton();
289  }else if($type == "checkBox"){
290  $widget = new checkBox();
291  }else if($type == "matrixQuestion"){
292  $widget = new matrixQuestion();
293  }else if($type == "matrixOption"){
294  $widget = new matrixOption();
295  }else if($type == "scheduleDate"){
296  $widget = new scheduleDate();
297  }else if($type == "scheduleOption"){
298  $widget = new scheduleOption();
299  }else if($type == "scheduleName"){
300  $widget = new scheduleName();
301  }else if( $type == "labelTiny" ){
302  $widget = new labelTiny();
303  // widget base class
304  }else{
305  $widget = new widget();
306  }
307  return $widget;
308 }
309 
310 
311 ?>