Code

Updated base selector tree
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jan 2010 17:46:03 +0000 (17:46 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jan 2010 17:46:03 +0000 (17:46 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15393 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_baseSelector.inc

index baea70e5fcc27eaec6b724b3adc670990a8d7d55..9ca0a429542758b63d761508c383eb411812e8f0 100644 (file)
@@ -39,6 +39,7 @@ class baseSelector {
   {
     $this->setBases($bases);
     $this->setBase($base);
+    $this->update();
   }
 
 
@@ -69,12 +70,32 @@ class baseSelector {
       $elements= array_reverse($elements, true);
 
       $this->pathMapping[$base]= $base == $config->current['BASE']? '/' : ldap::fix(preg_replace('/(^|,)[a-z0-9]+=/i', '/', implode(',', $elements)));
+    }
+
+    // Save bases to session for autocompletion
+    session::global_set('pathMapping', $this->pathMapping);
+  }
+
+
+  function update()
+  {
+    global $config;
+
+    $selected= $this->base == $config->current['BASE']?"Selected":"";
+    $this->tree= "<div class='treeList'><a class='treeList$selected' href='#'>"._("Root")."</a><ul class='treeList'>\n";
+    $first= true;
+    $last_indent= 2;
+
+    foreach ($this->pathMapping as $base => $dummy) {
 
       // Skip root for tree
       if ($base == $config->current['BASE']) {
         continue;
       }
 
+      // Build path style display
+      $elements= explode(',', substr($base, 0, strlen($base) - strlen($config->current['BASE'])));
+
       $indent= count($elements);
       if (!$first && ($indent == $last_indent)) {
         $this->tree.= "</li>\n";
@@ -89,7 +110,7 @@ class baseSelector {
         $this->tree.= "</li>\n";
       }
       $selected= $this->base == $base?" class='treeListSelected'":"";
-      $this->tree.= "<li$selected><a href='#'>".ldap::fix(preg_replace('/^[a-z0-9]+=([^,]+),.*$/i', '$1', $base))."</a>";
+      $this->tree.= "<li><a$selected href='#'>".ldap::fix(preg_replace('/^[a-z0-9]+=([^,]+),.*$/i', '$1', $base))."</a>";
 
       $last_indent= $indent;
       $first= false;
@@ -102,12 +123,8 @@ class baseSelector {
     $this->tree.= "</div>\n";
 
 echo $this->tree;
-
-    // Save bases to session for autocompletion
-    session::global_set('pathMapping', $this->pathMapping);
   }
 
-
   function render()
   {
     $result= "";
@@ -115,12 +132,6 @@ echo $this->tree;
   }
 
 
-  function update()
-  {
-    echo "update";
-  }
-
-
   function getBase()
   {
     return $this->base;