2016-11-11 20:36:27 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// An interface to bootstrap navbars and grids.
|
|
|
|
|
2016-11-22 09:20:07 +00:00
|
|
|
$fixed_navbar = false;
|
|
|
|
|
2016-11-11 20:36:27 +00:00
|
|
|
////////////// NAVBAR ////////////////
|
|
|
|
|
|
|
|
// call this to start the navbar.
|
2016-11-15 05:58:12 +00:00
|
|
|
// $brand: the text or image to show at left of navbar
|
|
|
|
// If text, put it in <a class="navbar-brand" ...
|
2016-11-11 20:36:27 +00:00
|
|
|
//
|
2016-11-22 09:20:07 +00:00
|
|
|
function navbar_start($brand, $fixed, $inverse) {
|
|
|
|
global $fixed_navbar;
|
|
|
|
$class = "navbar";
|
|
|
|
if ($inverse) {
|
|
|
|
$class .= " navbar-inverse";
|
2016-11-11 20:36:27 +00:00
|
|
|
} else {
|
2016-11-22 09:20:07 +00:00
|
|
|
$class .= " navbar-default";
|
|
|
|
}
|
|
|
|
if ($fixed) {
|
|
|
|
$class .= " navbar-fixed-top";
|
|
|
|
$fixed_navbar = true;
|
2016-11-11 20:36:27 +00:00
|
|
|
}
|
2016-11-22 09:20:07 +00:00
|
|
|
echo "<nav class=\"$class\">\n";
|
2016-11-11 20:36:27 +00:00
|
|
|
echo '
|
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="navbar-header">
|
|
|
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
|
|
|
|
<span class="icon-bar"></span>
|
|
|
|
<span class="icon-bar"></span>
|
|
|
|
<span class="icon-bar"></span>
|
|
|
|
</button>
|
2016-11-15 05:58:12 +00:00
|
|
|
'.$brand.'
|
2016-11-11 20:36:27 +00:00
|
|
|
</div>
|
|
|
|
<div class="collapse navbar-collapse" id="myNavbar">
|
|
|
|
<ul class="nav navbar-nav">
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
// call this to end it
|
|
|
|
//
|
|
|
|
function navbar_end($fixed) {
|
|
|
|
echo '
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
// put the login/logout stuff at the right side of navbar
|
|
|
|
//
|
|
|
|
function navbar_right($user) {
|
|
|
|
global $is_login_page;
|
|
|
|
echo '
|
|
|
|
</ul>
|
|
|
|
<ul class="nav navbar-nav navbar-right">
|
|
|
|
';
|
|
|
|
if (!$is_login_page) {
|
|
|
|
if ($user) {
|
|
|
|
echo '
|
2016-11-25 02:01:41 +00:00
|
|
|
<li><a href=home.php>'.$user->name.'</a></li>
|
2016-11-11 20:36:27 +00:00
|
|
|
';
|
2016-11-25 02:01:41 +00:00
|
|
|
$url_tokens = url_tokens($user->authenticator);
|
2016-11-11 20:36:27 +00:00
|
|
|
echo '
|
|
|
|
<li><a href="logout.php?'.$url_tokens.'">Log out</a></li>
|
|
|
|
';
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<li><a href="create_account_form.php">Sign Up</a></li>
|
|
|
|
<li><a href="login_form.php">Login</a></li>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add a dropdown menu
|
|
|
|
//
|
|
|
|
function navbar_menu($name, $items) {
|
|
|
|
echo '
|
|
|
|
<li class="dropdown">
|
|
|
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">'.$name.'
|
|
|
|
<span class="caret"></span></a>
|
|
|
|
<ul class="dropdown-menu">
|
|
|
|
';
|
|
|
|
foreach ($items as $item) {
|
2016-11-25 02:01:41 +00:00
|
|
|
if (is_array($item)) {
|
|
|
|
echo '<li><a href="'.$item[1].'">'.$item[0].'</a></li>
|
|
|
|
';
|
|
|
|
} else {
|
|
|
|
echo '<li class="dropdown-header">'.$item.'</li>
|
|
|
|
';
|
|
|
|
}
|
2016-11-11 20:36:27 +00:00
|
|
|
}
|
|
|
|
echo '
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
// add a single item (not menu)
|
|
|
|
//
|
|
|
|
function navbar_item($name, $url) {
|
|
|
|
echo '<li><a href="'.$url.'">'.$name.'</a></li>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
// A generic navbar.
|
|
|
|
// Call this from project_banner().
|
|
|
|
// If you want to customized it, copy it to your project.inc
|
|
|
|
// and give it a new name
|
|
|
|
//
|
2016-11-22 09:20:07 +00:00
|
|
|
function sample_navbar(
|
|
|
|
$url_prefix,
|
|
|
|
// prefix for links; needed for pages not in top dir
|
|
|
|
$user,
|
|
|
|
// logged-in user, if any
|
|
|
|
$fixed=false,
|
|
|
|
// if true, navbar is fixed at top of page.
|
|
|
|
// NOTE: if you do this, you must set a global var $fixed_navbar
|
|
|
|
// to true at compile time
|
|
|
|
// (it needs to be set when page_head() is called).
|
|
|
|
$inverse=false
|
|
|
|
// white on black?
|
|
|
|
) {
|
2016-11-15 05:58:12 +00:00
|
|
|
$master_url = parse_config(get_config(), "<master_url>");
|
|
|
|
$brand = "<a class=\"navbar-brand\" href=$master_url>".PROJECT."</a>";
|
2016-11-22 09:20:07 +00:00
|
|
|
navbar_start($brand, $fixed, $inverse);
|
2016-11-11 20:36:27 +00:00
|
|
|
|
2016-11-25 02:01:41 +00:00
|
|
|
$x = array(
|
|
|
|
array(tra("About %1", PROJECT), $url_prefix."about.php"),
|
|
|
|
array(tra("Help"), $url_prefix."help.php"),
|
|
|
|
|
|
|
|
);
|
2016-11-11 20:36:27 +00:00
|
|
|
if ($user) {
|
2016-11-25 02:01:41 +00:00
|
|
|
array_unshift($x, array(tra("Account"), $url_prefix."home.php"));
|
2016-11-11 20:36:27 +00:00
|
|
|
}
|
2016-11-25 02:01:41 +00:00
|
|
|
navbar_menu(tra("Project"), $x);
|
|
|
|
|
2016-11-11 20:36:27 +00:00
|
|
|
if (defined('NO_COMPUTING')) {
|
|
|
|
// this is for projects that don't do computing, e.g. BOSSA-based
|
|
|
|
//
|
2016-11-12 04:10:12 +00:00
|
|
|
navbar_menu(tra("Participate"), array(
|
2016-11-22 09:20:07 +00:00
|
|
|
array(tra("Do work"), $url_prefix."bossa_apps.php"),
|
2016-11-11 20:36:27 +00:00
|
|
|
));
|
|
|
|
} else {
|
2016-11-25 02:01:41 +00:00
|
|
|
navbar_menu(tra("Computing"), array(
|
2016-11-22 09:20:07 +00:00
|
|
|
array(tra("Server status"), $url_prefix."server_status.php"),
|
|
|
|
array(tra("Statistics"), $url_prefix."stats.php"),
|
2016-11-25 02:01:41 +00:00
|
|
|
array(tra("Applications"), $url_prefix."apps.php"),
|
|
|
|
'Leader boards:',
|
|
|
|
array(tra("Participants"), $url_prefix."top_users.php"),
|
|
|
|
array(tra("Computers"), $url_prefix."top_hosts.php"),
|
|
|
|
array(tra("Teams"), $url_prefix."top_teams.php"),
|
|
|
|
array(tra("GPU models"), $url_prefix."gpu_list.php"),
|
|
|
|
array(tra("CPU models"), $url_prefix."cpu_list.php"),
|
2016-11-11 20:36:27 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
navbar_menu(tra("Community"), array(
|
2016-11-22 09:20:07 +00:00
|
|
|
array(tra("Message boards"), $url_prefix."forum_index.php"),
|
|
|
|
//array(tra("Questions and Answers"), $url_prefix."forum_help_desk.php"),
|
|
|
|
array(tra("Teams"), $url_prefix."team.php", tra("create or join a team")),
|
|
|
|
array(tra("Profiles"), $url_prefix."profile_menu.php"),
|
|
|
|
array(tra("User search"), $url_prefix."user_search.php"),
|
|
|
|
array(tra("User of the day"), $url_prefix."uotd.php"),
|
|
|
|
array(tra("Certificate"), $url_prefix."cert1.php", "", "_blank"),
|
2016-11-11 20:36:27 +00:00
|
|
|
));
|
|
|
|
navbar_menu(tra("Site"), array(
|
2016-11-22 09:20:07 +00:00
|
|
|
array(tra("Site search"), $url_prefix."site_search.php"),
|
|
|
|
array(tra("Languages"), $url_prefix."language_select.php")
|
2016-11-11 20:36:27 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
// add your own menu here if you want
|
|
|
|
|
|
|
|
navbar_right($user);
|
|
|
|
navbar_end(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// output a panel.
|
|
|
|
// $content_func is a function that generates the panel contents
|
|
|
|
//
|
|
|
|
function panel($title, $content_func) {
|
|
|
|
echo '
|
|
|
|
<div class="panel panel-primary">
|
|
|
|
';
|
|
|
|
if ($title) {
|
|
|
|
echo '
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h1 class="panel-title">'.$title.'</h1>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
echo '
|
|
|
|
<div class="panel-body">
|
|
|
|
';
|
|
|
|
$content_func();
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
// grid layout with a full-width row followed by two equal columns
|
|
|
|
// $top_func, $left_func, and $right_func
|
|
|
|
// are functions that generate the top, left, and right content
|
2016-11-14 22:47:40 +00:00
|
|
|
// $left_width is the width of left column in 1/12 units.
|
2016-11-11 20:36:27 +00:00
|
|
|
//
|
2016-11-14 22:47:40 +00:00
|
|
|
function grid($top_func, $left_func, $right_func, $left_width=6) {
|
2016-11-11 20:36:27 +00:00
|
|
|
echo '
|
|
|
|
<div class="container">
|
|
|
|
';
|
|
|
|
if ($top_func) {
|
|
|
|
echo '
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12">
|
|
|
|
';
|
|
|
|
$top_func();
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
2016-11-14 22:47:40 +00:00
|
|
|
$right_width = 12-$left_width;
|
2016-11-11 20:36:27 +00:00
|
|
|
echo '
|
|
|
|
<div class="row">
|
2016-11-14 22:47:40 +00:00
|
|
|
<div class="col-sm-'.$left_width.'">
|
2016-11-11 20:36:27 +00:00
|
|
|
';
|
|
|
|
$left_func();
|
|
|
|
echo '
|
|
|
|
</div>
|
2016-11-14 22:47:40 +00:00
|
|
|
<div class="col-sm-'.$right_width.'">
|
2016-11-11 20:36:27 +00:00
|
|
|
';
|
|
|
|
$right_func();
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|