Code

Prepared for RequestHandler
[gosa.git] / include / class_GOsaGuiElement.inc
1 <?php
3 /*! \brief   GOsaGuiElement base class
4     \author  Cajus Pollmeier <pollmeier@gonicus.de>
5     \version 1.00
6     \date    2007/11/12
8     This abstract base class defines a GOsaGuiElement.
9  */
10 abstract class GOsaGuiElement implements GOsaGuiElementInteraction {
12   protected $errorMessage= "";
13   protected $id;
16   public function __construct() {
17     /* Generate an unique id */
18     $this->id= "G".uniqid()."_";
19   }
22   public function render() {
23     #TODO: Add "tooltip" for errorMessage
24     if ($this->errorMessage) {
25       return "<div class='GOsaGuiElementError'>\n".$this->__render()."</div>\n";
26     } else {
27       return $this->__render();
28     }
29   }
32   public function process() {
33     /* Return original processing results */
34     return $this->__process();
35   }
38   protected function createVariable($name) {
39     return ($this->id."_$name");
40   }
43   protected function __call($method, $parameters) {
45     #FIXME: hack should be done by RequestHandler, but it is not ready yet
46     if (preg_match('/^getRequestVariable_/', $method)){
47       $name= preg_replace('/^[^_]+_/', '', $method); 
49       if (isset($_REQUEST[$this->id.$name])){
50         return strip_tags(rtrim($_REQUEST[$this->id.$name], "\0"));
51       } else {
52         return "";
53       }
54     }
56     throw new Exception(sprintf(_("Unknown method '%s' called for '%s'."), $method, get_class()));
57   }
60   abstract protected function __render();
62   abstract protected function __process();
63 }
65 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
66 ?>