]> source.dussan.org Git - nextcloud-server.git/commitdiff
Working subnavigation
authorJakob Sack <kde@jakobsack.de>
Sun, 17 Apr 2011 17:38:04 +0000 (19:38 +0200)
committerJakob Sack <kde@jakobsack.de>
Sun, 17 Apr 2011 17:38:04 +0000 (19:38 +0200)
admin/appinfo/app.php
admin/users.php
files/appinfo/app.php
help/appinfo/app.php
lib/app.php
lib/template.php
log/appinfo/app.php
templates/layout.admin.php

index 2426adc9f8acaddcdb67c0c29d584804329b43e3..40d8b9188ec499cf1fa9d7ca44453083db66cce5 100644 (file)
@@ -7,4 +7,7 @@ OC_APP::addAdminPage( array( "id" => "core_users", "order" => 3, "href" => OC_HE
 OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
 OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 5, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
 
+// Add subentries for App installer
+OC_APP::addNavigationSubEntry( "core_apps", array( "id" => "core_apps_installed", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Installed apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
+
 ?>
index 9529ea7497741344a0554544bf7a251cd27fb220..a5b08e0ce5c12114f678e639b27bff9e2e811362 100644 (file)
@@ -30,6 +30,7 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin'
 
 // We have some javascript foo!
 OC_UTIL::addScript( "admin", "users" );
+OC_APP::setActiveNavigationEntry( "core_users" );
 
 $users = array();
 $groups = array();
index eff45cbe6e3ade3530970a3bd1a586db67626a1a..1d83674852ddd6196d076db5dfd20b6c3f87acbc 100644 (file)
@@ -3,6 +3,6 @@
 OC_APP::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
 
 OC_APP::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_HELPER::linkTo( "files", "index.php" ), "icon" => OC_HELPER::imagePath( "files", "navicon.png" ), "name" => "Files" ));
-OC_APP::addSettingsPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files" ));
+OC_APP::addSettingsPage( array( "id" => "files_administration", "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files" ));
 
 ?>
index 12ae59b94c204fa718929814bc0c4f24827db1cc..952c57f9bc8cb1148142cbc2843887987a52c321 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 OC_APP::register( array( "order" => 1, "id" => "help", "name" => "Help" ));
-OC_APP::addSettingsPage( array( "order" => 2, "href" => OC_HELPER::linkTo( "help", "index.php" ), "name" => "Help", "icon" => OC_HELPER::imagePath( "settings", "information.png" )));
+OC_APP::addSettingsPage( array( "id" => "help", "order" => 2, "href" => OC_HELPER::linkTo( "help", "index.php" ), "name" => "Help", "icon" => OC_HELPER::imagePath( "settings", "information.png" )));
 
 ?>
index 19e6df77f84d9ab581de7da7b426b497209cdc42..7ce9e919f9a47855e2f79e74471ecbf8b86ac42e 100644 (file)
@@ -148,7 +148,7 @@ class OC_APP{
         *     the navigation. Lower values come first.
         */
        public static function addNavigationSubEntry( $parent, $data ){
-               if( !array_key_exists( self::$subnavigation[$parent] )){
+               if( !array_key_exists( $parent, self::$subnavigation )){
                        self::$subnavigation[$parent] = array();
                }
                self::$subnavigation[$parent][] = $data;
@@ -239,57 +239,80 @@ class OC_APP{
         *     contains the subentries if the key "active" is true
         */
        public static function getNavigation(){
-               // TODO: write function
-               return OC_APP::$navigation;
+               $navigation = self::proceedNavigation( self::$navigation );
+               $navigation = self::addSubNavigation( $navigation );
+               return $navigation;
        }
 
        /**
-        * @brief Returns the admin pages
+        * @brief Returns the Settings Navigation
         * @returns associative array
         *
-        * This function returns an array containing all admin pages added. The
+        * This function returns an array containing all settings pages added. The
         * entries are sorted by the key "order" ascending.
         */
-       public static function getAdminPages(){
-               // TODO: write function
-               return OC_APP::$adminpages;
+       public static function getSettingsNavigation(){
+               $navigation = self::proceedNavigation( self::$settingspages );
+               $navigation = self::addSubNavigation( $navigation );
+
+               return $navigation;
        }
 
        /**
-        * @brief Returns the admin pages
-        * @param $app optional, name of the app we want the settings for
+        * @brief Returns the admin navigation
         * @returns associative array
         *
-        * This function returns an array with the settings pages. If $app is not
-        * set, it will return the main settings pages for all apps (where
-        * "id" == "app"). Otherwise it will list all settings pages of the app.
-        * The entries are sorted by the key "order" ascending.
+        * This function returns an array containing all admin pages added. The
+        * entries are sorted by the key "order" ascending.
         */
-       public static function getSettingsPages( $app = null ){
-               $return = array();
+       public static function getAdminNavigation(){
+               $navigation = self::proceedNavigation( self::$adminpages );
+               $navigation = self::addSubNavigation( $navigation );
 
-               if( is_null( $app )){
-                       foreach( OC_APP::$settingspages as $i ){
-                               if(!isset($i["id"])){
-                                       $i["id"]='';
-                               }
-                               if(!isset($i["app"])){
-                                       $i["app"]='';
-                               }
-                               if( $i["id"] == $i["app"] ){
-                                       $return[] = $i;
+               return $navigation;
+       }
+
+       /// Private foo
+       private static function addSubNavigation( $list ){
+               $found = false;
+               foreach( self::$subnavigation as $parent => $selection ){
+                       foreach( $selection as $subentry ){
+                               if( $subentry["id"] == self::$activeapp ){
+                                       foreach( $list as &$naventry ){
+                                               if( $naventry["id"] == $parent ){
+                                                       $naventry["active"] = true;
+                                                       $naventry["subnavigation"] = $selection;
+                                               }
+                                               else{
+                                                       $naventry["active"] = false;
+                                               }
+                                       }
+                                       $found = true;
                                }
                        }
                }
-               else{
-                       foreach( OC_APP::$settingspages as $i ){
-                               if( $i["app"] == $app ){
-                                       $return[] = $i;
+
+               return $list;
+       }
+
+       /// This is private as well. It simply works, so don't ask for more details
+       private static function proceedNavigation( $list ){
+               foreach( $list as &$naventry ){
+                       $naventry["subnavigation"] = array();
+                       if( $naventry["id"] == self::$activeapp ){
+                               $naventry["active"] = true;
+                               if( array_key_exists( $naventry["id"], self::$subnavigation )){
+                                       $naventry["subnavigation"] = self::$subnavigation[$naventry["id"]];
                                }
                        }
+                       else{
+                               $naventry["active"] = false;
+                       }
                }
 
-               return $return;
+               usort( $list, create_function( '$a, $b', 'if( $a["order"] == $b["order"] ){return 0;}elseif( $a["order"] < $b["order"] ){return -1;}else{return 1;}' ));
+
+               return $list;
        }
 
        /**
index 0e1c268efaa4c1010d5aeed212beaf84f074b828..dd1943ae7f57cc695821f519f334b4c03d8c8de4 100644 (file)
@@ -198,16 +198,10 @@ class OC_TEMPLATE{
                        {
                                $page = new OC_TEMPLATE( "core", "layout.admin" );
                                // Add menu data
-                               $navigation = array();
                                if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){
-                                       foreach( OC_APP::getAdminPages() as $i ){
-                                               $navigation[] = $i;
-                                       }
+                                       $page->assign( "settingsnavigation", OC_APP::getSettingsNavigation());
                                }
-                               foreach( OC_APP::getSettingsPages() as $i ){
-                                       $navigation[] = $i;
-                               }
-                               $page->assign( "navigation", $navigation );
+                               $page->assign( "adminnavigation", OC_APP::getAdminNavigation());
                        }
                        else
                        {
index fd53d1ec225c1033751960fd933f335262f51683..60769a990ff641661e71dcd9509a84a94a5ea5e1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 OC_APP::register( array( "order" => 1, "id" => "log", "name" => "Log" ));
-OC_APP::addSettingsPage( array( "order" => 2, "href" => OC_HELPER::linkTo( "log", "index.php" ), "name" => "Log", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
+OC_APP::addSettingsPage( array( "id" => "log", "order" => 2, "href" => OC_HELPER::linkTo( "log", "index.php" ), "name" => "Log", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
 
 ?>
index 6b1e73fd3a4fe5c5ae999210e250b2bde751e560..f7392c5de1d687ca2e1a99b5bd83d015cdd16d31 100644 (file)
                        <div id="plugins">
                                <ul>
                                        <li><a style="background-image:url(<?php echo image_path('settings', 'information.png'); ?>)" href="<?php echo link_to('settings', 'index.php'); ?>" title="">Information</a></li>
-                                       <?php foreach($_['navigation'] as $entry):?>
+                                       <?php foreach($_['settingsnavigation'] as $entry):?>
                                                <li><a style="background-image:url(<?php echo $entry['icon']; ?>)" href="<?php echo $entry['href']; ?>" title=""><?php echo $entry['name'] ?></a></li>
                                        <?php endforeach; ?>
+                                       <?php foreach($_['adminnavigation'] as $entry):?>
+                                               <li><a style="background-image:url(<?php echo $entry['icon']; ?>)" href="<?php echo $entry['href']; ?>" title=""><?php echo $entry['name'] ?><?php if( $entry["active"] ) echo "I AM ACTIVE!!!"; ?></a></li>
+                                               <?php if( sizeof( $entry["subnavigation"] )): ?>
+                                                       <?php foreach($entry["subnavigation"] as $subentry):?>
+                                                               <li><a style="background-color:#FF8800;" href="<?php echo $subentry['href']; ?>" title=""><?php echo $subentry['name'] ?></a></li>
+                                                       <?php endforeach; ?>
+                                               <?php endif; ?>
+                                       <?php endforeach; ?>
                                </ul>
                        </div>