forked from commando/commando
-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit-recipe.php
93 lines (84 loc) · 4.17 KB
/
edit-recipe.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
<?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;
Functions::check_required_parameters(array($_GET['param1']));
//Get recipe
$result = MySQLQueries::get_recipe($_GET['param1']);
$recipe = MySQLConnection::fetch_object($result);
$recipe = Functions::format_dates($recipe);
$interpreters = array("shell", "bash", "perl", "python", "node.js");
Header::set_title("Commando.io - Edit Recipe");
Header::render(array("chosen", "codemirror"));
Navigation::render("recipes");
?>
<div class="container">
<div>
<h1 class="header" style="float: left;"><?php echo $recipe->name ?></h1>
<div style="float: right;">
<a href="<?php echo Links::render("view-recipe", array($recipe->id)) ?>" class="btn btn-large"><?php echo substr($recipe->version, 0, 10) ?> (HEAD)</a>
</div>
</div>
<div class="row">
<div class="span12 well">
<form id="form-edit-recipe" class="well form-horizontal" method="post" action="/actions/edit_recipe.php">
<input type="hidden" name="id" value="<?php echo $recipe->id ?>" />
<fieldset>
<div class="control-group">
<label class="control-label" for="recipe-name">Name</label>
<div class="controls">
<input type="text" class="input-large" id="recipe-name" name="name" placeholder="RECIPE NAME" maxlength="30" value="<?php echo $recipe->name ?>" />
<p class="help-block">The recipe name. Must be unique.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="recipe-interpreter">Interpreter</label>
<div class="controls">
<select name="interpreter" id="recipe-interpreter" class="span2" data-placeholder="">
<?php foreach($interpreters as $interpreter): ?>
<option value="<?php echo $interpreter ?>" <?php if($interpreter === $recipe->interpreter): ?>selected="selected"<?php endif; ?>><?php echo ucfirst($interpreter) ?></option>
<?php endforeach; ?>
</select>
<p class="help-block">The interpreter to execute the recipe with. If you wish to write scripts with control structures and functions select an interpreter other than shell.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="recipe-notes">Notes</label>
<div class="controls">
<textarea id="recipe-notes" name="notes"><?php echo $recipe->notes ?></textarea>
<p class="help-block" style="clear: both;">Optional notes and comments you wish to attach to the recipe. <a href="http://daringfireball.net/projects/markdown/">Markdown</a> is supported.</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="recipe-editor">Recipe</label>
<div class="controls">
<textarea id="recipe-editor" name="content"><?php echo $recipe->content ?></textarea>
<p class="help-block" style="clear: both;"></p>
</div>
</div>
<div class="control-group">
<div class="controls">
<a class="btn btn-primary" id="edit-recipe-submit" onclick="validate_edit_recipe();"><i class="icon-ok-sign icon-white"></i> Update Recipe</a>
<a class="btn" href="<?php echo Links::render("view-recipe", array($recipe->id)) ?>">Cancel</a>
</div>
</div>
</fieldset>
</form>
</div>
</div>
<?php
Footer::render(array("chosen", "codemirror", "autosize", "edit-recipe"));
?>