From 945a8817dc959ffb90ab96120a3886a7960a7077 Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 12 Nov 2007 17:55:17 +0000 Subject: [PATCH] Prepared for RequestHandler git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7782 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_GOsaGuiElement.inc | 43 +++++++++++++++- include/class_ObjectListViewport.inc | 73 +++++++++++++++------------- 2 files changed, 79 insertions(+), 37 deletions(-) diff --git a/include/class_GOsaGuiElement.inc b/include/class_GOsaGuiElement.inc index d8284f2c6..6959bc4f3 100644 --- a/include/class_GOsaGuiElement.inc +++ b/include/class_GOsaGuiElement.inc @@ -1,12 +1,26 @@ + \version 1.00 + \date 2007/11/12 + + This abstract base class defines a GOsaGuiElement. */ abstract class GOsaGuiElement implements GOsaGuiElementInteraction { - protected $errorMessage= "asdf"; + protected $errorMessage= ""; + protected $id; + + + public function __construct() { + /* Generate an unique id */ + $this->id= "G".uniqid()."_"; + } + public function render() { + #TODO: Add "tooltip" for errorMessage if ($this->errorMessage) { return "
\n".$this->__render()."
\n"; } else { @@ -14,10 +28,35 @@ abstract class GOsaGuiElement implements GOsaGuiElementInteraction { } } + public function process() { + /* Return original processing results */ return $this->__process(); } + + protected function createVariable($name) { + return ($this->id."_$name"); + } + + + protected function __call($method, $parameters) { + + #FIXME: hack should be done by RequestHandler, but it is not ready yet + if (preg_match('/^getRequestVariable_/', $method)){ + $name= preg_replace('/^[^_]+_/', '', $method); + + if (isset($_REQUEST[$this->id.$name])){ + return strip_tags(rtrim($_REQUEST[$this->id.$name], "\0")); + } else { + return ""; + } + } + + throw new Exception(sprintf(_("Unknown method '%s' called for '%s'."), $method, get_class())); + } + + abstract protected function __render(); abstract protected function __process(); diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index 91a0d3e40..eb454a53f 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -38,7 +38,7 @@ class ObjectListViewport extends GOsaGuiElement { protected $displayHeaderFlag= TRUE; protected $displayFooterFlag= TRUE; - protected $numberOfCols= 0; + private $numberOfCols= 0; /*! \brief Container for objects @@ -52,10 +52,6 @@ class ObjectListViewport extends GOsaGuiElement { */ protected $multiselect; - /*! \brief ID used to identify objects of same list */ - protected $id = ""; - - /*! \brief ObjectListViewport constructor The ObjectListViewport class renders/handles the ObjectList defined by $config. @@ -64,6 +60,9 @@ class ObjectListViewport extends GOsaGuiElement { */ public function __construct($config, $multiselect= TRUE, $displayHeader= TRUE, $displayFooter= FALSE){ + /* Initialize from parents method */ + parent::__construct(); + /* Transfer initialization values */ $this->displayFooterFlag= $displayFooter; $this->displayHeaderFlag= $displayHeader; @@ -78,20 +77,6 @@ class ObjectListViewport extends GOsaGuiElement { /* Load and instanciate classes, extract filter, icons, view hooks, etc. */ $this->objects= new ObjectList($config); - - /* generate an unique id */ - $this->id= uniqid(); - } - - - /*! \brief Handles _POST / _GET events - - Processes the list of registered plugins to do their eventHandler and adapt - internal objectlist according to this. - */ - public function eventHandler(){ - /* Reloads the list if things have changed interally */ - $this->objects->reload(); } @@ -103,6 +88,9 @@ class ObjectListViewport extends GOsaGuiElement { */ protected function __process(){ + /* FIXME: Dummy Action*/ + $this->objects->reload(); + /* TODO: process input */ return FALSE; } @@ -152,7 +140,7 @@ class ObjectListViewport extends GOsaGuiElement { #} - /* TODO: replace this -> not our task */ + /* FIXME: replace this -> not our task */ private function getEntryIcon($entry,$alt = ""){ return("".$alt.""); } @@ -186,13 +174,15 @@ class ObjectListViewport extends GOsaGuiElement { foreach ($matches as $match){ $filterName= preg_replace('/,.+$/', '', $match[1]); $filterParameter= preg_replace('/^[^,]+,/', '', $match[1]); - $buffer= preg_replace('/\{_filter\('.normalizePreg($match[1]).'\)\}/', $this->applyEntryFilter($filterName, $filterParameter), $buffer); + $buffer= preg_replace('/\{_filter\('.normalizePreg($match[1]).'\)\}/', + $this->applyEntryFilter($filterName, $filterParameter), + $buffer); } #TODO: Make $buffer a proper HTML table output $tmp = split("\|",trim($buffer,"|")); - /* define entry template */ + /* Define entry template */ $tpl = "
{content} @@ -254,20 +244,31 @@ class ObjectListViewport extends GOsaGuiElement { $entries .= $this->renderEntry($value); } - $smarty = get_smarty(); - $smarty->assign("OLV_Entries",array("Doesn't work" => "Does not work."));//$objects); - $smarty->assign("OLV_List_Id",$this->id); - - /* Footer variables */ - $smarty->assign("OLV_Footer_Enabled",$this->displayFooterFlag); - $smarty->assign("OLV_Footer_Message",$this->footer); - $smarty->assign("OLV_Num_Cols",$this->numberOfCols); - - /* Assign Headline values */ - $smarty->assign("OLV_Header_Enabled",$this->displayHeaderFlag); - $smarty->assign("OLV_Header",$this->headline); + return "README ;-)\n"; + + #Fabian: _POST/_GET Variablen bitte mit $this->createVariable('name'); + # erstellen. + # Damit kann das von der übergreifenden Funktion extrahiert werden + # und wir haben keinen doppelten Code dafür. + # + # Wurde z.B. eine Variable via $this->createVariable('cn') erzeugt und via + # smarty eingebunden, dann kann Sie nach einem _POST oder _GET via + # $this->getRequestVariable_cn() wieder abgefragt werden. + + #$smarty = get_smarty(); + #$smarty->assign("OLV_Entries",array("Doesn't work" => "Does not work."));//$objects); + #$smarty->assign("OLV_List_Id",$this->id); + + #/* Footer variables */ + #$smarty->assign("OLV_Footer_Enabled",$this->displayFooterFlag); + #$smarty->assign("OLV_Footer_Message",$this->footer); + #$smarty->assign("OLV_Num_Cols",$this->numberOfCols); + + #/* Assign Headline values */ + #$smarty->assign("OLV_Header_Enabled",$this->displayHeaderFlag); + #$smarty->assign("OLV_Header",$this->headline); - return($smarty->fetch("ObjectListViewport.tpl")); + #return($smarty->fetch("ObjectListViewport.tpl")); } @@ -304,10 +305,12 @@ class ObjectListViewport extends GOsaGuiElement { $alignment.= "top-"; $style.= "vertical-align: top;"; } + if(preg_match("/B/i", $al)){ $alignment.= "bottom-"; $style.= "vertical-align: bottom;"; } + if(preg_match("/R/i", $al)){ $alignment.= "right"; $style.= "text-align: right;"; -- 2.30.2