34 if( is_array($this->
config) ){
43 if( is_string($this->
config)){
47 if( !is_array($this->
config) ){
66 if( !is_array($this->
config) ){
67 throw new exception(
"Fehler beim Laden der Einstellungen. Datenbank möglicherweise fehlerhaft.");
82 if(is_array($this->
config) ){
86 $this->
config[
"br"] = $val;
89 }
else if ( (
$name ==
"true") OR (
$name ==
"false") ){
90 $value_clean = htmlspecialchars($val , ENT_QUOTES ,
"UTF-8",
true);
91 if( (strlen($value_clean) > 256) ){
95 $this->
config[
"true"] = $value_clean;
97 $this->
config[
"false"] = $value_clean;
101 }
else if (
$name ==
"dropdown"){
102 if( $val ==
"true" ){
103 $this->
config[
"dropdown"] =
true;
105 $this->
config[
"dropdown"] =
false;
107 }
else if (
$name ==
"max"){
108 if( is_numeric($val ) ){
109 $this->
config[
"max"] = intval($val);
111 $this->
config[
"max"] = -1;
114 }
else if(
$name ==
"font-family" ){
115 $this->
config[
"font-family"] = $val;
116 }
else if(
$name ==
"font-size" ){
117 $this->
config[
"font-size"] = $val;
118 }
else if(
$name ==
"font-bold"){
120 $this->
config[
"font-bold"] =
true;
122 $this->
config[
"font-bold"] =
false;
124 }
else if(
$name ==
"numberQuestion"){
126 $this->
config[
"numberQuestion"] =
true;
128 $this->
config[
"numberQuestion"] =
false;
130 }
else if(
$name ==
"chartType"){
131 $allowed = array(
"pieChart",
"barChart",
"barChart2",
"radarChart",
"doughnutChart");
132 if( in_array($val,$allowed) ){
133 $this->
config[
"chartType"] = $val;
135 }
else if(
$name ==
"showCharts" ){
137 $this->
config[
"showCharts"] =
true;
139 $this->
config[
"showCharts"] =
false;
141 }
else if(
$name ==
"width" ){
142 if( is_numeric($val) AND (floatval($val) >= 0) ){
143 $this->
config[
"width"] = floatval($val);
145 $this->
config[
"width"] = -1;
147 }
else if(
$name ==
"margin-left" ){
148 if( is_numeric($val) AND (floatval($val) >= 0) ){
149 $this->
config[
"margin-left"] = floatval($val);
151 $this->
config[
"margin-left"] = 0;
153 }
else if(
$name ==
"margin-right" ){
154 if( is_numeric($val) AND (floatval($val) >= 0) ){
155 $this->
config[
"margin-right"] = floatval($val);
157 $this->
config[
"margin-right"] = 0;
159 }
else if(
$name ==
"float" ){
160 if( in_array($val,array(
"left",
"right")) ){
161 $this->
config[
"float"] = $val;
163 $this->
config[
"float"] =
"left";
183 if( is_array($this->
config) ){
186 if( isset($this->
config[
"br"]) ){
187 return $this->
config[
"br"];
192 }
else if(
$name ==
"true"){
193 if( isset($this->
config[
"true"]) ){
194 return $this->
config[
"true"];
199 }
else if(
$name ==
"false"){
200 if( isset($this->
config[
"false"]) ){
201 return $this->
config[
"false"];
205 }
else if(
$name ==
"dropdown"){
206 if( isset($this->
config[
"dropdown"]) ){
207 return $this->
config[
"dropdown"];
212 }
else if(
$name ==
"max"){
213 if( isset($this->
config[
"max"] )) {
214 return $this->
config[
"max"];
218 }
else if(
$name ==
"font-family" ){
219 if( isset( $this->
config[
"font-family"] )) {
220 return $this->
config[
"font-family"];
224 }
else if(
$name ==
"font-size" ){
225 if( isset( $this->
config[
"font-size"] )) {
226 return $this->
config[
"font-size"];
230 }
else if(
$name ==
"font-bold"){
231 if( isset( $this->
config[
"font-bold"] )) {
232 return $this->
config[
"font-bold"];
236 }
else if(
$name ==
"numberQuestion"){
237 if( isset( $this->
config[
"numberQuestion"] )) {
238 return $this->
config[
"numberQuestion"];
242 }
else if(
$name ==
"chartType"){
243 if( isset( $this->
config[
"chartType"] ) ){
244 return $this->
config[
"chartType"];
248 }
else if(
$name ==
"showCharts"){
249 if( isset( $this->
config[
"showCharts"] ) ){
250 return $this->
config[
"showCharts"];
255 }
else if(
$name ==
"width"){
256 if( isset( $this->
config[
"width"] ) ){
257 return $this->
config[
"width"];
262 }
else if(
$name ==
"margin-left"){
263 if( isset( $this->
config[
"margin-left"] ) ){
264 return $this->
config[
"margin-left"];
269 }
else if(
$name ==
"margin-right"){
270 if( isset( $this->
config[
"margin-right"] ) ){
271 return $this->
config[
"margin-right"];
276 }
else if(
$name ==
"float"){
277 if( isset( $this->
config[
"float"] ) ){
278 return $this->
config[
"float"];
294 if(
$name ==
"count"){
295 if( is_numeric($val) ){
296 $this->data[
"count"] = $val;
307 if(
$name ==
"count" ){
308 if(isset($this->data[
"count"])){
309 return $this->data[
"count"];
322 if ( !(isset($this->typ)) OR !(isset($this->
name)) OR !(isset($this->index)) OR !(isset($this->
pollID)) ){
325 if( ($this->typ ==
"") OR ($this->
name ==
"") ){
336 if($this->is_required ==
false){
340 $name =
"mit der ID {$this->ID}";
341 if( (isset($this->dispName) ) AND ( $this->dispName !=
"") ){
343 }
else if ( (isset($this->
name) ) AND ( $this->
name !=
"") ){
347 if( !isset($_POST[ $this->
name ]) ){
348 return "Das Feld <b>$name</b> ist ein Plichtfeld. Bitte dieses angeben.";
350 if( $_POST[ $this->name ] ==
"" ){
351 return "Das Feld <b>$name</b> ist ein Plichtfeld. Bitte dieses angeben.";
365 $name =
"mit der ID {$this->ID}";
366 if( (isset($this->dispName) ) AND ( $this->dispName !=
"") ){
368 }
else if ( (isset($this->
name) ) AND ( $this->
name !=
"") ){
377 if( $this->
get_data(
"count") >= $max ){
378 return "Das Feld <b>$name</b> ist leider nicht mehr verfügbar! Bitte wähle ein Anderes.";
394 $err_reason =
"anzeigeName enthält mehr als 256 Zeichen";
412 $name = htmlspecialchars(
$name , ENT_QUOTES ,
"UTF-8",
true);
415 if( (strlen(
$name) <= 25) ){
417 if( preg_match_all(
"/[^0-9^a-z^A-Z^_]/",
$name, $m) !== 0){
418 $err_reason =
"Datenbankname enthält ungültige Zeichen, gültige Zeichen sind a-z, A-Z oder 0-9";
421 $err_reason =
"Der Datenbankname ist zu lang (max 25 Zeichen)";
423 if( (strlen(
$name) == 0) ){
424 if( isset($this->ID) ){
425 $name = strval($this->ID);
427 $err_reason =
"Bitte einen Datenbanknamen angeben!";
444 $font_family= $this->
get_config(
"font-family");
446 if( $font_family !=
""){ $font_family =
"font-family:".$font_family; }
447 if( $font_size !=
""){ $font_size =
"font-size:".$font_size; }
449 if( (isset($_SESSION[
"last_widget_edit"])) AND ($_SESSION[
"last_widget_edit"] == $this->ID) ){
450 echo
"<script type='text/javascript'>
451 $(document).ready(function(){
452 window.scrollBy(0,-150);
455 $lasted =
" widget_last_edit";
456 unset( $_SESSION[
"last_widget_edit"] );
459 echo
"<div class='widget_container$lasted' style='position:relative;$font_family;$font_size;z-index:100;background-color:rgba(255,255,255,0.5)' id='widget_container_{$this->ID}'>";
460 echo
"<div class='widget_edit_toolbar'>";
461 echo
"<a href='action.widget.php?pollID={$this->pollID}&widgetID={$this->ID}' title='Bearbeiten' ><img src='".APP_ROOT.
"/icons/22/preferences-system.png' alt='edit'/></a>";
462 echo
"<a href='action.widget.php?pollID={$this->pollID}&widgetID={$this->ID}&action=duplicate_widget' title='Kopieren'><img src='".APP_ROOT.
"/icons/22/edit-copy.png' alt='remove'/></a>";
463 echo
"<a href='action.widget.php?pollID={$this->pollID}&widgetID={$this->ID}&action=rmwid' style='margin-left:0px' title='Löschen' ><img src='".APP_ROOT.
"/icons/22/edit-delete.png' alt='remove'/></a>";
464 echo
"<span style='margin-left:7px'> </span>";
465 echo
"<a href='action.widget.php?pollID={$this->pollID}&widgetID={$this->ID}&action=mvup' title='weiter nach Oben schieben'><img src='".APP_ROOT.
"/icons/22/go-up.png' alt='mv up'/></a>";
466 echo
"<a href='action.widget.php?pollID={$this->pollID}&widgetID={$this->ID}&action=mvdwn' title='weiter nach Unten schieben'><img src='".APP_ROOT.
"/icons/22/go-down.png' alt='mv down'/></a>";
469 echo
"<a href='edit.php?pollID={$this->pollID}&widgetID={$this->ID}' class='widget_edit_link' id='widget{$this->ID}'> </a>";
478 echo
"<label for='widget_name'>Datenbankname </label>
479 <input type='text' name='widget_name' id='widget_name' size='40' value='{$this->name}' placeholder='Spaltenname in der Datenbank'/>
480 <span style='font-size:80%;color:#370500'>(nur A-Z a-z 0-9 / 25 Zeichen)</span>";
489 if(isset($_POST[
"widget_name"])){
497 return "Name nicht angegeben!";
506 echo
"<label for='widget_dispname'>Titel / sichtbarer Name </label>
507 <input type='text' name='widget_dispname' id='widget_dispname' value='{$this->dispName}' placeholder='Fragestellung' size='40'/>
508 <span style='font-size:80%;color:#370500'>(256 Zeichen)</span>";
517 if(isset($_POST[
"widget_dispname"])){
525 return "Anzeige Name nicht angegeben!";
534 if($this->is_required){
535 $presel =
"checked='checked'";
537 echo
"<input type='checkbox' name='widget_is_required' id='widget_is_required' value='true' $presel/>
538 <label for='widget_is_required'>Pflichtfeld</label>";
547 if( (isset($_POST[
"widget_is_required"])) AND ($_POST[
"widget_is_required"] ===
"true") ){
548 $this->is_required =
true;
550 $this->is_required =
false;
564 echo
"Diagrammtyp: <select name='widget_chartType'>";
565 echo
"<option value='' >Standard</option>";
566 for(
$i=0 ;
$i<
sizeof($allowed) ; ++
$i){
568 if( $allowed[
$i] == $conf ){
569 $selected =
"selected='selected'";
571 echo
"<option value='{$allowed[$i]}' $selected >{$allowed_names[$i]}</option>";
583 if( (isset($_POST[
"widget_chartType"])) AND ($_POST[
"widget_chartType"] !=
"") ){
584 if (in_array($_POST[
"widget_chartType"],$allowed)){
585 return $this->
set_config(
"chartType",$_POST[
"widget_chartType"]);
587 return "Ungültiger diagrammtyp";
601 $r =
$db->update_widget_field($this ,
"config" , $this->
config);
612 return $db->update_widget_field($this ,
"dispName" , $this->dispName);
621 return $db->update_widget_field($this ,
"is_required" , $this->is_required);
630 $db->update_widget_name($this,$new_name);