Code

Updated navigator
[gosa.git] / gosa-core / include / class_pathNavigator.inc
1 <?php
3 class pathNavigator
4 {
6   static function registerPlugin($class)
7   {
8     
9     $str = $title = "";
11     // Display headline of management plugins
12     if($class instanceOf management && isset($class->plHeadline)){
13       $str= _($class->plHeadline);
14     }
16     // Shown title of sub dialogs (They have no plHeadline set.)
17     if($class instanceOf plugin && !isset($class->plHeadline)){
18       if(empty($class->pathTitle)){
19         $str = "Missing: ".get_class($class);
20       }else{
21         $str = _($class->pathTitle);
22       }
23     }
24   
25     // In case of tabs add the 'dn' of the entry 
26     if($class instanceOf tabs){
28       // Convert dn to cn
29       if(isset($class->dn)){
30         if(!session::is_set("pathNavigator::registerPlugin:{$class->dn}")){
31           global $config;
32           $ldap = $config->get_ldap_link();
33           $ldap->cat($class->dn, array('cn'));
34           if($ldap->count()){
35             $attrs = $ldap->fetch();
36             $str = $attrs['cn'][0];
37           }
38           session::set("pathNavigator::registerPlugin:{$class->dn}", $str);
39         }
40         $str = session::get("pathNavigator::registerPlugin:{$class->dn}");
41         $title = $class->dn;
42       }
43     }
45     // Simple string given 
46     if(is_string($class)){
47       $str = $class;
48     }
49     
50     if(!empty($str)){
51       $cur = session::get('pathNavigator::position');
53       if(!empty($title)) $title = " title='{$title}' ";
55       if(empty($cur)){
56         $cur.= "\n<li {$title} class='left path-element'>{$str}</li>";
57       }else{
58         $cur.= "\n<li {$title} class='left path-element'>{$str}</li>";
59       }
60       session::set('pathNavigator::position', $cur);
61     }
62   }
64   static function getCurrentPath()
65   {
66     $path = session::get('pathNavigator::position');
67     if(empty($path)){
68       $path = "<li class='left path-element'>"._("Welcome to GOsa")."</li>";
69     }
70     return($path);
71   }
73   static function clear()
74   {
75     session::set('pathNavigator::position','');
76   }
77 }
79 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
80 ?>