forked from commando/commando
-
Notifications
You must be signed in to change notification settings - Fork 1
/
recipes.php
97 lines (88 loc) · 3.83 KB
/
recipes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/*
# Copyright 2012 NodeSocket, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
($_SERVER['SCRIPT_NAME'] !== "/controller.php") ? require_once(__DIR__ . "/classes/Requires.php") : Links::$pretty = true;
//Get recipes
$recipes = array();
$result = MySQLQueries::get_recipes();
while($row = MySQLConnection::fetch_object($result)) {
$recipes[$row->id] = $row;
}
//Get number of versions for all recipes
$result = MySQLQueries::get_number_of_recipe_versions();
while($row = MySQLConnection::fetch_object($result)) {
$recipes[$row->id]->number_of_versions = $row->count;
}
$recipes = Functions::format_dates($recipes);
Header::set_title("Commando.io - Recipes");
Header::render();
Navigation::render("recipes");
?>
<div class="container">
<h1 class="header">Recipes</h1>
<div class="row">
<div class="span12 well">
<a href="<?php echo Links::render("add-recipe") ?>" class="btn btn-primary btn-large"><i class="icon-plus-sign icon-white"></i> Add Recipe</a>
</div>
</div>
<div class="row">
<div class="span12 well">
<div class="alert alert-info fade in" <?php if(count($recipes) > 0): ?>style="display: none;"<?php endif; ?>>
<a class="close" data-dismiss="alert">×</a>
<h4>Did You Know?</h4>
Recipes are containers of commands that are fully versioned. Recipes can be written in pure <i><strong>shell</strong></i>, <i><strong>bash</strong></i>, <i><strong>perl</strong></i>, <i><strong>python</strong></i>, or <i><strong>node.js</strong></i>.
</div>
<div id="no-recipes" class="alert alert-grey no-bottom-margin" <?php if(count($recipes) > 0): ?>style="display: none;"<?php endif; ?>>
No recipes added. <a href="<?php echo Links::render("add-recipe") ?>">Add</a> a recipe now.
</div>
<?php if(count($recipes) > 0): ?>
<div id="table-container">
<div class="control-group">
<div class="controls">
<a id="delete-recipes" class="btn disabled"><i class="icon-remove"></i> Delete Selected</a>
</div>
</div>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th><input type="checkbox" id="recipe-delete-all-check" /></th>
<th>Name</th>
<th>Interpreter</th>
<th>Number Of Versions</th>
<th>Added</th>
<th>Modified</th>
</tr>
</thead>
<tbody>
<?php foreach($recipes as $recipe): ?>
<tr id="<?php echo $recipe->id ?>" class="recipe">
<td><input type="checkbox" class="recipe-delete-check" value="<?php echo $recipe->id ?>" /></td>
<td><a href="<?php echo Links::render("view-recipe", array($recipe->id)) ?>"><?php echo $recipe->name ?></a></td>
<td><?php echo ucfirst($recipe->interpreter) ?></td>
<td><span class="badge"><?php echo $recipe->number_of_versions ?></span></td>
<td><?php echo $recipe->added ?></td>
<td><?php echo $recipe->modified ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<?php
Footer::render(array("bootbox", "recipes"));
?>