Umfragen
matrixQuestion.class.php
Go to the documentation of this file.
1 <?php
3 
4 class matrixQuestion extends widget implements input_widget, output_widget{
5  public $typ = "matrixQuestion";
6  public $direct_result = true;
7 
8  public function set_default_values($db){
9  $this->set_dispName("Frage {$this->index}");
10  }
11 
12  public function get_data($name){
13  if( substr($name,0,5) == "count" ){
14  $n = explode("_",$name);
15  if( (sizeof($n) == 2) AND (is_numeric($n[1])) ){
16  if( isset($this->data[$name]) ){
17  return $this->data[$name];
18  }else{
19  return 0;
20  }
21  }else{
22  return "falsche synthax bei data[count]";
23  }
24 
25  }else{
26  return parent::get_data($name);
27  }
28  }
29 
30  public function set_data($name,$value){
31  if( substr($name,0,5) == "count" ){
32  $n = explode("_",$name);
33  if( (sizeof($n) == 2) AND (is_numeric($n[1])) ){
34  if( is_numeric($value) ){
35  $this->data[$name] = intval($value);
36  }
37  }else{
38  return "falsche synthax bei data[count]";
39  }
40 
41  }else{
43  }
44 
45  }
46 
47 
48  public function display_option_edit($polltype){
49  $edited ="";
50  if( (isset($_SESSION["last_option_edit"])) AND ( $_SESSION["last_option_edit"] == $this->ID ) ){
51  $edited = "option_last_edit";
52  unset($_SESSION["last_option_edit"] );
53  }
54 
55  echo "<tr class='$edited'>";
56  echo "<td>{$this->ID}</td>";
57  echo "<td style='text-align:center'>
58  <input type='text' value='{$this->dispName}' name='question_ID{$this->ID}_name' placeholder='Fragestellung' style='width:90%'/>
59  </td>";
60  if( $polltype == POLLTYPE_ADVANCED ){
61  echo "<td style='text-align:center'>
62  <input type='text' value='{$this->name}' name='question_ID{$this->ID}_name2' style='width:90%'/>
63  </td>";
64  }
65  $sel = "";
66  if( $this->is_required === true){
67  $sel = "checked='checked'";
68  }
69  echo "<td style='text-align:center;'>
70  <input type='checkbox' name='question_ID{$this->ID}_required' value='true' $sel>
71  </td>";
72 
73  echo "
74  <td>
75  <input type='submit' name='addq_option_ID{$this->ID}' title='Frage Einfügen' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT."/icons/22/list-add.png );background-repeat:no-repeat;width:26px;height:26px;' />
76  <input type='submit' name='rmq_option_ID{$this->ID}' title='Frage Löschen' value='' tabindex='-1' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT."/icons/22/edit-delete.png );background-repeat:no-repeat;width:26px;height:26px;' />
77  <input type='submit' name='mvupq_option_ID{$this->ID}' title='Frage nach Oben schieben' tabindex='-1' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT."/icons/22/go-up.png );background-repeat:no-repeat;width:26px;height:26px;' />
78  <input type='submit' name='mvdwnq_option_ID{$this->ID}' title='Frage nach Unten schieben' tabindex='-1' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT."/icons/22/go-down.png );background-repeat:no-repeat;width:26px;height:26px' />
79  </td>";
80  echo "</tr>";
81  }
82 
83 
84  public function handle_option_edit(){
85  // required
86  if( (isset($_POST["question_ID{$this->ID}_required"])) AND ($_POST["question_ID{$this->ID}_required"] == "true") ){
87  $this->is_required = true;
88  }else{
89  $this->is_required = false;
90  }
91 
92  // disp name
93  if( (isset($_POST["question_ID{$this->ID}_name"])) AND ($_POST["question_ID{$this->ID}_name"] != "") ){
94  $dispName = htmlspecialchars($_POST["question_ID{$this->ID}_name"] , ENT_QUOTES , "UTF-8",true);
95  if(strlen($dispName) < 256){
96  $this->dispName = $dispName;
97  }else{
98  return "Name der Option mit ID {$this->ID} enthält mehr als 256 Zeichen!";
99  }
100  }else{
101  return "Name der Option mit ID {$this->ID} nicht angegeben!";
102  }
103 
104  // name
105  if( (isset($_POST["question_ID{$this->ID}_name2"])) AND ($_POST["question_ID{$this->ID}_name2"] != "") ){
106  $r = $this->set_name( $_POST["question_ID{$this->ID}_name2"] );
107  if($r !== true){
108  return $r;
109  }else{
110  return true;
111  }
112  }else{
113  $r = $this->set_name( $this->ID );
114  }
115 
116  return true;
117  }
118 
119 
120  public function handle_inpt(){
121  return true;
122  }
123 
124  public function display(){
125 
126  }
127 
128 
129 
130 }
131 // ! no ending newLine
132 ?>