Code

Updated to read from sample config
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 3 Nov 2007 13:40:18 +0000 (13:40 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 3 Nov 2007 13:40:18 +0000 (13:40 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7723 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa.conf
include/class_ConfigManager.inc
include/class_ObjectListViewport.inc
test

index c03ca2a98709e599da96226d4516fd3459136e1a..02f25da4cd6ffab6cb8f993132fd36cac131b4c6 100644 (file)
--- a/gosa.conf
+++ b/gosa.conf
@@ -117,3 +117,8 @@ queue-script = "/usr/local/bin/queue-script.sh"
 [plugin/environment]
 kiosk-path = "/var/spool/kiosk"
 ppd-path = "/var/spool/ppds"
+
+[plugin/sample]
+headline= "|{16px}|{90%}Name|{64px:R}Actions|"
+footer= "Statistics with no information currently"
+entryFormat= "|{_icon}|{cn} ({_filter(uppercase,{cn})})|{_actions}|"
index 67061c71a6c7d2d5757cf32d79fa3f5f88c61e43..8c40ea19f2a5bcd03ebff34fc768590cd3ae4f53 100644 (file)
@@ -20,7 +20,9 @@ class ConfigManagerException extends Exception {
 class ConfigManager {
 
        /* Config container */
-       protected $config= NULL;
+       private $config;
+       private $current;
+       private $section;
 
        public function __construct(){}
 
@@ -48,36 +50,56 @@ class ConfigManager {
                        throw new ConfigManagerException($ret);
                }
 
-               echo "Test config and load additional configuration data from LDAP\n";
+               #echo "Test config and load additional configuration data from LDAP\n";
                #$this->test_config();
                #$this->load_servers();        -> Section servers/...;
                #$this->load_plugin_configs(); -> Section pugins/name/value;
 
-               print_r($this->config);
+               #print_r($this->config);
        }
 
 
        public function save($file){
+               throw new ConfigManagerException(_("Save not supported yet!"));
        }
 
 
-       public function set_section($section_name){
+       public function setSection($name){
+               if (isset($this->config[$name])){
+                       $this->section= $name;
+                       $this->current= &$this->config[$name];
+                       return TRUE;
+               } else {
+                       $this->section= "";
+                       $this->current= NULL;
+                       return FALSE;
+               }
        }
 
 
-       public function &get_section(){
+       public function getSection(){
+               return $this->section;
        }
 
 
-       public function &get_sections(){
+       public function getSections(){
        }
 
 
-       public function &get_value($section){
+       public function getValue($name){
+               if (!$this->current){
+                       throw new ConfigManagerException(_("Can't get value without current section set!"));
+               }
+               
+               if (isset($this->current[$name])){
+                       return $this->current[$name];
+               } else {
+                       return NULL;
+               }
        }
 
 
-       public function set_value($section, $value){
+       public function setValue($section, $value){
        }
 
 }
index 330dbfc6c6cc416a7e8285531476e60809a5fd1c..414d45ba464145676c0349b1e455fbdbf0665f25 100644 (file)
@@ -25,12 +25,12 @@ class ObjectListViewportException extends Exception {
  */
 class ObjectListViewport {
 
-  # DUMMY values ---->
-  private $headline= "|{16px}|{90%}Name|{64px:R}Actions|";
-  private $footer= "Statistics with no information currently";
-  private $entryFormat= "|{_icon}|{cn} ({_filter(uppercase,{cn})})|{_actions}|";
+  /* Dummy here ----> */
+  private $headline;
+  private $footer;
+  private $entryFormat;
   private $attributes= array('cn', '_icon', '_actions', 'dn');
-  # <--- DUMMY values.
+  /* <---- Dummy here */
 
   /*!
     \brief Container for objects
@@ -48,6 +48,13 @@ class ObjectListViewport {
    */
        public function __construct($config){
 
+    /* Dummy here */
+    $cr= Registry::getInstance("ConfigManager");
+    $cr->setSection("plugin/sample");
+    $this->headline= $cr->getValue("headline");
+    $this->footer= $cr->getValue("footer");
+    $this->entryFormat= $cr->getValue("entryFormat");
+
     /* Load and instanciate classes, extract filter, icons, view hooks, etc. */
     $this->objects= new ObjectList($config);
   }
diff --git a/test b/test
index 3b4469d151af9d75162637e7bd1f22f254991fe9..6101c399f63801216f2d2861c1731c1431a88be5 100755 (executable)
--- a/test
+++ b/test
@@ -10,8 +10,8 @@ require_once("include/autoload.inc");
 try {
 
        /* Get new test instance of the Configuration */
-       #$cr= Registry::getInstance("ConfigManager");
-       #$cr->load("gosa.conf");
+       $cr= Registry::getInstance("ConfigManager");
+       $cr->load("gosa.conf");
 
        /* Get a new test instance of ObjectListViewports */
        $vp= new ObjectListViewport(array("dummy", "dummy"));