diff options
Diffstat (limited to 'lib/app.php')
-rw-r--r-- | lib/app.php | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/lib/app.php b/lib/app.php index 475015f6779..b6c2512e79a 100644 --- a/lib/app.php +++ b/lib/app.php @@ -158,7 +158,10 @@ class OC_APP{ * the navigation. Lower values come first. */ public static function addNavigationEntry( $data ){ - // TODO: write function + $data['active']=false; + if(!isset($data['icon'])){ + $data['icon']=''; + } OC_APP::$navigation[] = $data; return true; } @@ -184,6 +187,10 @@ class OC_APP{ * the navigation. Lower values come first. */ public static function addNavigationSubEntry( $parent, $data ){ + $data['active']=false; + if(!isset($data['icon'])){ + $data['icon']=''; + } if( !array_key_exists( $parent, self::$subnavigation )){ self::$subnavigation[$parent] = array(); } @@ -310,33 +317,34 @@ class OC_APP{ /// Private foo private static function addSubNavigation( $list ){ - $found = false; - foreach( self::$subnavigation as $parent => $selection ){ - foreach( $selection as $subentry ){ - if( $subentry['id'] == self::$activeapp ){ + if(isset(self::$subnavigation[self::$activeapp])){ + $subNav=self::$subnavigation[self::$activeapp]; + foreach( $list as &$naventry ){ + if( $naventry['id'] == self::$activeapp ){ + $naventry['active'] = true; + $naventry['subnavigation'] = $subNav; + } + } + }else{ + foreach(self::$subnavigation as $parent=>$entries){ + $activeParent=false; + foreach($entries as &$subNav){ + $subNav['active']=$subNav['id'] == self::$activeapp; + if($subNav['active']){ + $activeParent=true; + } + } + if($activeParent){ foreach( $list as &$naventry ){ if( $naventry['id'] == $parent ){ $naventry['active'] = true; - $naventry['subnavigation'] = $selection; - } - else{ - $naventry['active'] = false; + $naventry['subnavigation'] = $entries; } - } unset( $naventry ); - $found = true; + } } } } - // Mark subentry as active - foreach( $list as &$naventry ){ - if( $naventry['active'] ){ - foreach( $naventry['subnavigation'] as &$subnaventry ){ - $subnaventry['active'] = $subnaventry['id'] == self::$activeapp? true : false; - } unset( $subnaventry ); - } - } unset( $naventry ); - return $list; } |