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;
|
|
|
|
|
Remote job submission: add support for per-job templates in submit requests
This supports the TACC use case,
in the jobs in a batch can use different Docker images
and different input and output file signatures,
none of which are known in advance.
Python API binding:
- A JOB_DESC object can optionally contain wu_template and result_template
elements, which are the templates (the actual XML) to use for that job.
Add these to the XML request message if present.
- Added the same capability to the PHP binding, but not C++.
- Added and debugged test cases for both languages.
Also, submit_batch() can take either a batch name (in which case
the batch is created) or a batch ID
(in which the batch was created prior to remotely staging files).
RPC handler:
- in submit_batch(), check for jobs with templates specified
and store them in files.
For input templates (which are deleted after creating jobs)
we put them in /tmp,
and use a map so that if two templates are the same we use 1 file.
For output templates (which have to last until all jobs are done)
we put them in templates/tmp, with content-based filenames
to economize.
- When creating jobs, or generating SQL strings for multiple jobs,
use these names as --wu_template_filename
and --result_template_filename args to create_work
(either cmdline args or stdin args)
- Delete WU templates when done
create_work.cpp:
handle per-job --wu_template and --result_template args in stdin job lines
(the names of per-job WU and result templates).
Maintain a map mapping WU template name to contents,
to avoid repeatedly reading them.
For jobs that don't specify templates, use the ones specified
at the batch level, or the defaults.
2017-01-21 08:24:11 +00:00
|
|
|
if (defined('REMOTE_JOB_SUBMISSION') && REMOTE_JOB_SUBMISSION) {
|
|
|
|
require_once("../inc/submit_db.inc");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
//
|
2016-12-07 03:18:34 +00:00
|
|
|
function navbar_end() {
|
2016-11-11 20:36:27 +00:00
|
|
|
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) {
|
2017-02-01 19:54:10 +00:00
|
|
|
echo sprintf('
|
2017-07-13 08:17:21 +00:00
|
|
|
<li><a href=%s%s>%s</a></li>
|
|
|
|
', url_base(), USER_HOME, $user->name
|
2017-02-01 19:54:10 +00:00
|
|
|
);
|
2016-11-25 02:01:41 +00:00
|
|
|
$url_tokens = url_tokens($user->authenticator);
|
2017-02-01 19:54:10 +00:00
|
|
|
echo sprintf('<li><a href="%slogout.php?%s">Log out</a></li>',
|
2017-02-12 09:03:16 +00:00
|
|
|
url_base(), $url_tokens
|
2017-02-01 19:54:10 +00:00
|
|
|
);
|
2016-11-11 20:36:27 +00:00
|
|
|
} else {
|
2017-02-01 19:54:10 +00:00
|
|
|
echo sprintf('
|
|
|
|
<li><a href="%screate_account_form.php">Sign Up</a></li>
|
|
|
|
<li><a href="%slogin_form.php">Login</a></li>
|
2017-02-12 09:03:16 +00:00
|
|
|
', url_base(), url_base()
|
2017-02-01 19:54:10 +00:00
|
|
|
);
|
2016-11-11 20:36:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-26 04:41:09 +00:00
|
|
|
global $master_url;
|
|
|
|
|
2016-11-15 05:58:12 +00:00
|
|
|
$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-29 08:34:26 +00:00
|
|
|
$x = array();
|
2016-11-11 20:36:27 +00:00
|
|
|
if ($user) {
|
2017-07-13 08:17:21 +00:00
|
|
|
$x[] = array(tra("Account"), $url_prefix.USER_HOME);
|
2016-11-29 08:34:26 +00:00
|
|
|
$x[] = array(tra("Join"), $url_prefix."join.php");
|
2017-06-06 22:31:59 +00:00
|
|
|
$x[] = array(tra("Preferences"), $url_prefix."prefs.php?subset=project");
|
2016-11-11 20:36:27 +00:00
|
|
|
}
|
2016-11-29 08:34:26 +00:00
|
|
|
$x[] = array(tra("About %1", PROJECT), $url_prefix."about.php");
|
|
|
|
$x[] = array(tra("Help"), $url_prefix."help.php");
|
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
|
|
|
|
//
|
2017-03-15 07:59:05 +00:00
|
|
|
if (defined('BOSSA')) {
|
|
|
|
navbar_menu(tra("Participate"), array(
|
|
|
|
array(tra("Do work"), $url_prefix."bossa_apps.php"),
|
|
|
|
));
|
|
|
|
}
|
2016-11-11 20:36:27 +00:00
|
|
|
} else {
|
2016-12-06 21:55:18 +00:00
|
|
|
$x = array(
|
2017-06-06 22:31:59 +00:00
|
|
|
array(tra("Preferences"), $url_prefix."prefs.php?subset=global"),
|
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"),
|
2016-12-06 21:55:18 +00:00
|
|
|
);
|
|
|
|
if (defined('REMOTE_JOB_SUBMISSION') && REMOTE_JOB_SUBMISSION) {
|
2016-12-08 02:17:57 +00:00
|
|
|
if ($user && BoincUserSubmit::lookup_userid($user->id)) {
|
2016-12-06 21:55:18 +00:00
|
|
|
$x[] = array("Job submission", $url_prefix."submit.php");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$x = array_merge($x,
|
|
|
|
array(
|
|
|
|
'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"),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
navbar_menu(tra("Computing"), $x);
|
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"),
|
2017-06-06 22:31:59 +00:00
|
|
|
array(tra("Preferences"), $url_prefix."edit_forum_preferences_form.php"),
|
2016-11-22 09:20:07 +00:00
|
|
|
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);
|
2016-12-07 03:18:34 +00:00
|
|
|
navbar_end();
|
2016-11-11 20:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// output a panel.
|
|
|
|
// $content_func is a function that generates the panel contents
|
|
|
|
//
|
2017-07-01 20:43:43 +00:00
|
|
|
function panel($title, $content_func, $class="panel-primary") {
|
|
|
|
echo sprintf('<div class="panel %s">
|
|
|
|
', $class
|
|
|
|
);
|
2016-11-11 20:36:27 +00:00
|
|
|
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 '
|
2017-03-01 20:38:46 +00:00
|
|
|
<div class="container-fluid">
|
2016-11-11 20:36:27 +00:00
|
|
|
';
|
|
|
|
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>
|
|
|
|
';
|
|
|
|
}
|
2016-12-16 20:05:30 +00:00
|
|
|
|
2017-02-12 08:46:15 +00:00
|
|
|
function form_start($action, $method='get') {
|
|
|
|
echo sprintf(
|
|
|
|
'<div class="container">
|
|
|
|
<form class="form-horizontal" method="%s" action="%s">'
|
|
|
|
,
|
|
|
|
$method, $action
|
|
|
|
);
|
2016-12-16 20:05:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function form_input_hidden($name, $value) {
|
|
|
|
echo '<input type="hidden" name="'.$name.'" value="'.$value.'">
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
function form_end() {
|
|
|
|
echo '</form>
|
2017-01-24 05:37:30 +00:00
|
|
|
</div>
|
2016-12-16 20:05:30 +00:00
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2017-06-20 07:38:11 +00:00
|
|
|
define('FORM_LEFT_CLASS', 'col-sm-5');
|
|
|
|
define('FORM_LEFT_OFFSET', 'col-sm-offset-5');
|
|
|
|
define('FORM_RIGHT_CLASS', 'col-sm-7');
|
|
|
|
|
2016-12-16 20:05:30 +00:00
|
|
|
function form_input_text($label, $name, $value='', $type='text', $attrs='') {
|
2017-06-20 07:38:11 +00:00
|
|
|
echo sprintf('
|
2016-12-16 20:05:30 +00:00
|
|
|
<div class="form-group">
|
2017-06-20 07:38:11 +00:00
|
|
|
<label class="control-label %s">%s</label>
|
|
|
|
<div class="%s">
|
|
|
|
<input %s type="%s" class="form-control" name="%s" value="%s">
|
2016-12-16 20:05:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-06-20 07:38:11 +00:00
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS,
|
|
|
|
$attrs, $type, $name, $value
|
|
|
|
);
|
2016-12-16 20:05:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-01 05:51:17 +00:00
|
|
|
// display name/value with same formatting as form
|
|
|
|
//
|
|
|
|
function form_attr($name, $value) {
|
|
|
|
echo sprintf('
|
|
|
|
<div class="form-group">
|
2017-06-20 07:38:11 +00:00
|
|
|
<div class="%s text-right">%s</div>
|
|
|
|
<div class="%s">%s</div>
|
2017-02-01 05:51:17 +00:00
|
|
|
</div>
|
2017-06-20 07:38:11 +00:00
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $name, FORM_RIGHT_CLASS, $value
|
2017-02-01 05:51:17 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-12-22 06:12:57 +00:00
|
|
|
function form_input_textarea($label, $name, $value='') {
|
2017-06-20 07:38:11 +00:00
|
|
|
echo sprintf('
|
2016-12-22 06:12:57 +00:00
|
|
|
<div class="form-group">
|
2017-06-20 07:38:11 +00:00
|
|
|
<label class="control-label %s" for="%s">%s</label>
|
|
|
|
<div class="%s">
|
|
|
|
<textarea rows="6" class="form-control" id="%s" name="%s">%s</textarea>
|
2016-12-22 06:12:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-06-20 07:38:11 +00:00
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $name, $label, FORM_RIGHT_CLASS, $name, $name, $value
|
|
|
|
);
|
2016-12-22 06:12:57 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 08:46:15 +00:00
|
|
|
// $items is either a string of <option> elements, or an array
|
|
|
|
//
|
2016-12-16 20:05:30 +00:00
|
|
|
function form_select($label, $name, $items) {
|
2017-06-20 07:38:11 +00:00
|
|
|
echo sprintf('
|
2016-12-16 20:05:30 +00:00
|
|
|
<div class="form-group">
|
2017-06-20 07:38:11 +00:00
|
|
|
<label class="control-label %s" for="%s">%s</label>
|
|
|
|
<div class="%s">
|
|
|
|
<select class="form-control" id="%s" name="%s">
|
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $name, $label, FORM_RIGHT_CLASS, $name, $name
|
|
|
|
);
|
2017-02-12 08:46:15 +00:00
|
|
|
if (is_array($items)) {
|
|
|
|
foreach ($items as $i) {
|
|
|
|
echo '<option value="'.$i[0].'">'.$i[1].'</option>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo $items;
|
2016-12-16 20:05:30 +00:00
|
|
|
}
|
|
|
|
echo "</select></div></div>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// same, for multiple select.
|
|
|
|
// flags, if non-null, says which ones are selected
|
|
|
|
//
|
|
|
|
function form_select_multiple($label, $name, $items, $flags) {
|
2017-06-20 07:38:11 +00:00
|
|
|
echo sprintf('
|
2016-12-16 20:05:30 +00:00
|
|
|
<div class="form-group">
|
2017-06-20 07:38:11 +00:00
|
|
|
<label class="control-label %s" for="%s">%s</label>
|
|
|
|
<div class="%s">
|
|
|
|
<select multiple class="form-control" id="%s" name="%s[]">
|
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $name, $label, FORM_RIGHT_CLASS, $name, $name
|
|
|
|
);
|
2016-12-16 20:05:30 +00:00
|
|
|
$n = 0;
|
|
|
|
foreach ($items as $i) {
|
|
|
|
$s = ($flags && $flags[$n])?'selected':'';
|
|
|
|
echo '<option '.$s.' value="'.$i[0].'">'.$i[1].'</option>
|
|
|
|
';
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
echo "</select></div></div>\n";
|
|
|
|
}
|
|
|
|
|
2017-06-20 07:38:11 +00:00
|
|
|
// $items is list of (name, label)
|
|
|
|
//
|
|
|
|
function form_checkboxes($label, $items) {
|
|
|
|
echo sprintf('
|
2016-12-16 20:05:30 +00:00
|
|
|
<div class="form-group">
|
2017-06-20 07:38:11 +00:00
|
|
|
<label class="control-label %s">%s</label>
|
|
|
|
<div class="%s">
|
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS
|
|
|
|
);
|
|
|
|
foreach ($items as $i) {
|
|
|
|
echo sprintf('<input type="checkbox" name="%s"> %s <br>
|
|
|
|
',
|
|
|
|
$i[0], $i[1]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
echo '</div>
|
2016-12-16 20:05:30 +00:00
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
2017-01-24 05:37:30 +00:00
|
|
|
|
2017-06-20 07:38:11 +00:00
|
|
|
// $items is list of (value, label)
|
|
|
|
//
|
2017-06-22 08:07:25 +00:00
|
|
|
function form_radio_buttons($label, $name, $items, $selected) {
|
2017-06-20 07:38:11 +00:00
|
|
|
echo sprintf('
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="control-label %s">%s</label>
|
|
|
|
<div class="%s">
|
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS
|
|
|
|
);
|
|
|
|
foreach ($items as $i) {
|
2017-06-22 08:07:25 +00:00
|
|
|
$checked = ($selected == $i[0])?"checked":"";
|
|
|
|
echo sprintf('<input type="radio" name="%s" value="%s" %s> %s <br>
|
2017-06-20 07:38:11 +00:00
|
|
|
',
|
2017-06-22 08:07:25 +00:00
|
|
|
$name, $i[0], $checked, $i[1]
|
2017-06-20 07:38:11 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
echo '</div>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
function form_general($label, $item) {
|
|
|
|
echo '
|
|
|
|
<div class="form-group">
|
|
|
|
';
|
|
|
|
if (strlen($label)) {
|
|
|
|
echo sprintf(
|
|
|
|
' <label class="control-label %s">%s</label>
|
|
|
|
<div class="%s">%s</div>
|
|
|
|
',
|
|
|
|
FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS, $item
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
echo sprintf(
|
|
|
|
' <div class="%s %s">%s</div>
|
|
|
|
',
|
|
|
|
FORM_LEFT_OFFSET, FORM_RIGHT_CLASS, $item
|
|
|
|
);
|
|
|
|
}
|
|
|
|
echo '</div>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
function form_submit($text) {
|
|
|
|
form_general(
|
|
|
|
"",
|
|
|
|
sprintf('<button type="submit" class="btn btn-success">%s</button>',
|
|
|
|
$text
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-01-24 05:37:30 +00:00
|
|
|
function form_checkbox($label, $name, $checked=false) {
|
|
|
|
echo sprintf('
|
|
|
|
<div class="form-group">
|
|
|
|
<input type="checkbox" name="%s" %s> <span class="lead">%s</span>
|
|
|
|
</div>
|
|
|
|
', $name, $checked?"checked":"", $label
|
|
|
|
);
|
|
|
|
}
|