0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-18 02:03:18 +00:00

Working subnavigation

This commit is contained in:
Jakob Sack 2011-04-17 19:38:04 +02:00
parent 1ffb09b38a
commit 47223ae2d9
8 changed files with 79 additions and 50 deletions
admin
files/appinfo
help/appinfo
lib
log/appinfo
templates

View 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" )));
?>

View 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();

View 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" ));
?>

View 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" )));
?>

View 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 settings pages added. The
* entries are sorted by the key "order" ascending.
*/
public static function getSettingsNavigation(){
$navigation = self::proceedNavigation( self::$settingspages );
$navigation = self::addSubNavigation( $navigation );
return $navigation;
}
/**
* @brief Returns the admin navigation
* @returns associative array
*
* This function returns an array containing all admin 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 getAdminNavigation(){
$navigation = self::proceedNavigation( self::$adminpages );
$navigation = self::addSubNavigation( $navigation );
return $navigation;
}
/**
* @brief Returns the admin pages
* @param $app optional, name of the app we want the settings for
* @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.
*/
public static function getSettingsPages( $app = null ){
$return = array();
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;
}
}
}
else{
foreach( OC_APP::$settingspages as $i ){
if( $i["app"] == $app ){
$return[] = $i;
/// 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;
}
}
}
return $return;
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;
}
}
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;
}
/**

View 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
{

View 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" )));
?>

View file

@ -26,9 +26,17 @@
<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>