Code

Added futur base selector class
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jan 2010 17:09:45 +0000 (17:09 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jan 2010 17:09:45 +0000 (17:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15390 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/html/themes/default/style.css
gosa-core/include/class_baseSelector.inc [new file with mode: 0644]

index 6e594f18d1f7f87a4b5c79a4c36ae5604bf4e7d0..42fe28620d0847f762715366bb1f120ce6a8c493 100644 (file)
@@ -2016,6 +2016,7 @@ ul.treeList, ul.treeList ul { list-style-type: none; background: url(../../image
 ul.treeList ul { margin-left: 10px; }
 ul.treeList a:hover { background-color: #DDD }
 a.treeList { font-weight: bold }
+a.treeListSelected { font-weight: bold; color: red; }
 ul.treeList li { margin: 0; padding: 0 12px; line-height: 20px; background: url(../../images/lists/node.png) no-repeat; font-weight: bold; }
 li.treeListSelected a {color: red}
 ul.treeList li.last { background: #fff url(../../images/lists/lastnode.png) no-repeat; }
diff --git a/gosa-core/include/class_baseSelector.inc b/gosa-core/include/class_baseSelector.inc
new file mode 100644 (file)
index 0000000..18f363e
--- /dev/null
@@ -0,0 +1,139 @@
+<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2010 GONICUS GmbH
+ *
+ * ID: $$Id: class_listing.inc 15296 2010-01-26 08:27:39Z cajus $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class baseSelector {
+
+  private $base;
+  protected $tree;
+  protected $pathMapping;
+
+  // It would be better to get a dn -> [name, description, type] array
+  // to avoid these tasks be done several times. Skipping for the moment.
+  #'dc' => 'plugins/departments/images/domain.png',
+  #'dc' => 'plugins/departments/images/dc.png',
+  #'l' => 'plugins/departments/images/locality.png',
+  #'c' => 'plugins/departments/images/country.png',
+  #'o' => 'plugins/departments/images/organization.png',
+  #'ou' => 'plugins/departments/images/folder.png',
+
+  function __construct($bases, $base= "")
+  {
+    $this->setBases($bases);
+    $this->setBase($base);
+  }
+
+
+  function setBase($base)
+  {
+    if (isset($this->pathMapping[$base])) {
+      $this->base= $base;
+    } else {
+      die("Invalid base selected");
+    }
+  }
+
+
+  function setBases($bases)
+  {
+    global $config;
+
+    $this->pathMapping= array();
+    $selected= $this->base == $config->current['BASE']?"Selected":"";
+    $this->tree= "<a class='treeList$selected' href='#'>"._("Root")."</a><ul class='treeList'>\n";
+    $first= true;
+    $last_indent= 2;
+
+    foreach ($bases as $base => $dummy) {
+
+      // Build path style display
+      $elements= explode(',', substr($base, 0, strlen($base) - strlen($config->current['BASE'])));
+      $elements= array_reverse($elements, true);
+
+      $this->pathMapping[$base]= $base == $config->current['BASE']? '/' : ldap::fix(preg_replace('/(^|,)[a-z0-9]+=/i', '/', implode(',', $elements)));
+
+      // Skip root for tree
+      if ($base == $config->current['BASE']) {
+        continue;
+      }
+
+      $indent= count($elements);
+      if (!$first && ($indent == $last_indent)) {
+        $this->tree.= "</li>\n";
+      }
+      if ($indent > $last_indent) {
+        $this->tree.= "<ul>\n";
+      }
+      if ($indent < $last_indent) {
+        for ($i= 0; $i < ($last_indent-$indent); $i++) {
+          $this->tree.= "</li></ul>\n";
+        }
+        $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>";
+
+      $last_indent= $indent;
+      $first= false;
+    }
+
+    // Close tree
+    for ($i= 0; $i<$last_indent; $i++) {
+      $this->tree.= "</li></ul>\n";
+    }
+
+echo $this->tree;
+
+    // Save bases to session for autocompletion
+    session::global_set('pathMapping', $this->pathMapping);
+  }
+
+
+  function render()
+  {
+    $result= "";
+    return $result;
+  }
+
+
+  function update()
+  {
+    echo "update";
+  }
+
+
+  function getBase()
+  {
+    return $this->base;
+  }
+
+
+  function getAction()
+  {
+    // Do not do anything if this is not our PID, or there's even no PID available...
+    #if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid) {
+    #  return;
+    #}
+  }
+
+}
+
+?>