Umfragen
matrixOption.class.php
Go to the documentation of this file.
1 <?php
3 
5  public $typ = "matrixOption";
6  public $direct_result = false;
7 
8 
9  public function set_value($val){
10  $val = htmlspecialchars($val , ENT_QUOTES , "UTF-8",true);
11 
12  $err_reason = "";
13  if( (strlen($val) > 256) ){
14  $err_reason = "Wert der Option mit der ID {$this->ID} enthält mehr als 256 Zeichen.";
15  }
16  if( (strlen($val) == 0) ){
17  $err_reason = "Bitte Wert für die Wert Option mit der ID {$this->ID} angeben.";
18  }
19 
20  if($err_reason == ""){
21  $this->value = $val;
22  return true;
23  }else{
24  return $err_reason;
25  }
26 
27  }
28 
29  public function set_default_values($db){
30  $this->set_dispName("Option {$this->index}");
31  }
32 
33 
34 
35  public function display_option_edit(){
36  $edited ="";
37  if( (isset($_SESSION["last_option_edit"])) AND ( $_SESSION["last_option_edit"] == $this->ID ) ){
38  $edited = "option_last_edit";
39  unset($_SESSION["last_option_edit"] );
40  }
41 
42  echo "<tr class='$edited'>";
43  echo "<td>{$this->ID}</td>";
44  echo "<td style='text-align:center'>
45  <input type='text' value='{$this->value}' name='option_ID{$this->ID}_value' placeholder='Antwort' style='width:90%'/>
46  </td>";
47  echo "<td style='text-align:center'>
48  <input type='text' value='{$this->dispName}' name='option_ID{$this->ID}_name' placeholder='optionale Beschreibung' style='width:90%'/>
49  </td>";
50 
51  echo "
52  <td>
53  <input type='submit' name='add_option_ID{$this->ID}' title='Option 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;' />
54  <input type='submit' name='rm_option_ID{$this->ID}' title='Option Löschen' tabindex='-1' value='' 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;' />
55  <input type='submit' name='mvup_option_ID{$this->ID}' title='Option 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;' />
56  <input type='submit' name='mvdwn_option_ID{$this->ID}' title='Option 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' />
57  </td>";
58  echo "</tr>";
59  }
60 
61  public function handle_option_edit(){
62  if( (isset($_POST["option_ID{$this->ID}_name"])) AND ($_POST["option_ID{$this->ID}_name"] != "") ){
63  $dispName = htmlspecialchars($_POST["option_ID{$this->ID}_name"] , ENT_QUOTES , "UTF-8",true);
64  if(strlen($dispName) < 256){
65  $this->dispName = $dispName;
66  }else{
67  return "Name der Option mit ID {$this->ID} enthält mehr als 256 Zeichen!";
68  }
69  }else{
70  $this->dispName = "";
71  }
72  // dispName gültig, sonst return vorher schon.
73  if( isset($_POST["option_ID{$this->ID}_value"]) ){
74  if( ($_POST["option_ID{$this->ID}_value"] != "") ){
75  return $this->set_value( $_POST["option_ID{$this->ID}_value"] );
76  }else{
77  return "Keinen Wert angegeben.";//$this->set_value( $this->dispName);
78  }
79  }else{
80  return "Keinen Wert angegeben."; //return $this->set_value( $this->dispName);
81  }
82  return true;
83  }
84 
85  public function handle_inpt(){
86  return true;
87  }
88  public function display_edit(){
89 
90  }
91  public function display(){
92 
93  }
94 
95 
96 }
97 // ! no ending newLine
98 ?>