Umfragen
labelTiny.class.php
Go to the documentation of this file.
1 <?php
2 require_once(INCLUDE_DIR."/htmlpurifier-4.4.0/HTMLPurifier.standalone.php");
3 
4 
5 class labelTiny extends widget implements iWidget, output_widget{
6 
7  public $typ = "labelTiny";
8  public $direct_result = true;
9 
10  function set_value($value){
11  if($value != ""){
12  $config = HTMLPurifier_Config::createDefault();
13  // allowed HTML tags
14  $config->set('HTML.Allowed', 'abbr, acronym, b, caption,em, i, strike, strong,span,
15  a[href|target], img[src|alt|height|width],
16  *[style],*[title]' );
17  // allow CSS properties
18  $config->set('CSS.AllowedProperties',array(
19  'text-decoration','text-align','font-family','font-size',
20  'padding-left','padding-right','padding-top','padding-bottom','padding',
21  'margin-left','margin-right','margin-top','margin-bottom','margin',
22  'border-left','border-right','border-top','border-bottom','border','border-collapse','border-color','border-style',
23  'color','background-color','border','border-radius','box-shadow'
24  ));
25  // finally clean and save
26  $purifier = new HTMLPurifier($config);
27  $clean_html = $purifier->purify($value);
28 
29  if( (strlen($clean_html) > 256) ){
30  return "Text enthält mehr als 256 Zeichen";
31  }
32  $this->value = $clean_html;
33  return true;
34  }else{
35  return "Text darf nicht leer sein";
36  }
37  return false;
38  }
39 
40 
41  public function save_label($db){
42  return $db->update_widget_field($this,"value",$this->value);
43  }
44 
45  function display(){
46  $width= $this->get_config("width");
47  $margin_left= $this->get_config("margin-left");
48  $margin_right= $this->get_config("margin-right");
49 
50  if( $width != -1){ $width = "width:{$width}em"; }else{ $width=""; }
51  if( $margin_left != 0){ $margin_left = "margin-left:{$margin_left}em"; }else{ $margin_left=""; }
52  if( $margin_right != 0){ $margin_right = "margin-right:{$margin_right}em"; }else{ $margin_right=""; }
53 
54  echo "<div class='labelTiny_widget' style='margin:0px;pading:0px;position:relative;$width;$margin_left;$margin_right'>{$this->value}</div>";
55  }
56 
57  function handle_inpt(){
58  return true;
59  }
60 
61  function display_edit(){
62  return true;
63  }
64 
66  $this->set_dispName("Bitte Fragestellung eingeben");
67  $this->set_value("Bitte Fragestellung eingeben");
68  }
69 
70 }
71 // ! no ending newLine
72 ?>