-
Notifications
You must be signed in to change notification settings - Fork 54
/
add.php
executable file
·93 lines (82 loc) · 2.86 KB
/
add.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
<?
$id = $_GET["module"];
$table = isset($_GET["table"]) ? $_GET["table"] : "";
$module = $admin->getModule($id);
// Try to make sense of a plural title into singular
if (isset($_GET["title"])) {
$title = $_GET["title"];
if (substr($title,-3,3) == "ies") {
$title = substr($title,0,-3)."y";
} else {
$title = rtrim($title,"s");
}
if (strtolower($_GET["title"]) == "news") {
$title = $_GET["title"];
}
} else {
$title = "";
}
// Find out if we have more than one view. If so, give them an option of which one to return to.
$available_views = $admin->getModuleViews("title",$module["id"]);
$title = htmlspecialchars(urldecode($title));
?>
<div class="container">
<form method="post" action="<?=DEVELOPER_ROOT?>modules/forms/create/<?=$module["id"]?>/" class="module">
<section>
<div class="left last">
<fieldset>
<label class="required">Item Title <small>(for example, "Question" as in "Adding Question")</small></label>
<input type="text" class="required" name="title" value="<?=$title?>" />
</fieldset>
<fieldset>
<label class="required">Data Table</label>
<select name="table" id="form_table" class="required">
<option></option>
<? BigTree::getTableSelectOptions($table); ?>
</select>
</fieldset>
<fieldset>
<input type="checkbox" name="tagging" />
<label class="for_checkbox">Enable Tagging</label>
</fieldset>
</div>
<div class="right last">
<? if (count($available_views) > 1) { ?>
<fieldset>
<label>Return View <small>(after the form is submitted, it will return to this view)</small></label>
<select name="return_view">
<? foreach ($available_views as $view) { ?>
<option value="<?=$view["id"]?>"<? if (isset($_GET["view"]) && $_GET["view"] == $view["id"]) { ?> selected="selected"<? } ?>><?=$view["title"]?></option>
<? } ?>
</select>
</fieldset>
<? } ?>
<fieldset>
<label>Return URL <small>(an optional return URL to override the default return view)</small></label>
<input type="text" name="return_url" />
</fieldset>
<fieldset>
<label>Preprocessing Function <small>(passes in post data, returns keyed array of adds/edits)</small></label>
<input type="text" name="preprocess" />
</fieldset>
<fieldset>
<label>Function Callback <small>(passes in ID and parsed post data, and publish state)</small></label>
<input type="text" name="callback" />
</fieldset>
</div>
</section>
<section class="sub" id="field_area">
<?
if ($table) {
include BigTree::path("admin/ajax/developer/load-form.php");
} else {
echo "<p>Please choose a table to populate this area.</p>";
}
?>
</section>
<footer>
<input type="submit" class="button blue" value="Create" />
</footer>
</form>
</div>
<? include BigTree::path("admin/modules/developer/modules/forms/_js.php") ?>