Code

Added prototype support
[gosa.git] / gosa-core / include / class_pathNavigator.inc
1 <?php
3 class pathNavigator
4 {
6   static function registerPlugin($class, $title= "")
7   {
8     $str = "";
10     // Display headline of management plugins
11     if($class instanceOf management && isset($class->plHeadline)){
12       $str= _($class->plHeadline);
13     }
15     // Shown title of sub dialogs (They have no plHeadline set.)
16     if($class instanceOf plugin && !isset($class->plHeadline)){
17       if(!empty($class->pathTitle)){
18         $str = _($class->pathTitle);
19       }
20     }
21   
22     // In case of tabs add the 'dn' of the entry 
23     if($class instanceOf tabs){
25       // Convert dn to cn
26       if(isset($class->dn)){
27         if(!session::is_set("pathNavigator::registerPlugin:{$class->dn}")){
28           global $config;
29           $ldap = $config->get_ldap_link();
31           if(!empty($class->dn)){
32             $namingAttr = preg_replace("/^([^=]*)=.*$/","\\1",$class->dn);
34             $ldap->cat($class->dn, array($namingAttr));
35             if($ldap->count()){
36               $attrs = $ldap->fetch();
37               $str = $attrs[$namingAttr][0];
38             }
39             session::set("pathNavigator::registerPlugin:{$class->dn}", $str);
40           }
41         }
42         $str = session::get("pathNavigator::registerPlugin:{$class->dn}");
43         if(empty($title)){
44           $title = $class->dn;
45         }
46       }
47     }
49     // Simple string given 
50     if(is_string($class)){
51       $str = $class;
52     }
53     
54     if(!empty($str)){
55       $cur = session::get('pathNavigator::position');
56       $entry = array('TITLE' => $title, 'NAME' => $str);
57       $cur[] = $entry;
58       session::set('pathNavigator::position', $cur);
59     }
60   }
62   static function getCurrentPath()
63   {
64     $list = session::get('pathNavigator::position');
65     $path = "";
66     $sTitle = "";
67     foreach($list as $entry){
68         $title = (!empty($entry['TITLE']))? 'title="'.htmlentities(LDAP::fix($entry['TITLE']),ENT_COMPAT,'UTF-8').'"': '';
69         $path.= "\n<li {$title} class='left path-element'>{$entry['NAME']}</li>";
70         $sTitle .= " - ".$entry['NAME'];
71     }
73     if(empty($path)){
74       $path = "<li class='left path-element'>"._("Welcome to GOsa")."</li>";
75     }
77     $smarty = get_smarty();
78     $smarty->assign('title', 'GOsa '.$sTitle);
79     return($path);
80   }
82   static function clear()
83   {
84     session::set('pathNavigator::position', array());
85     session::set('pathNavigator::title','');
86   }
87 }
89 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
90 ?>