-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
100 lines (70 loc) · 2.59 KB
/
index.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
98
99
100
<?php
require_once("config.php");
require_once(SPYC);
global $logger;
if(isset($_POST['submit'])){
SubmitHandler::process($_POST);
}
$result = false;
if(isset($_GET['ShoppingList'])){
//then this is a shopping list edit
$item = ShoppingListItem::findById($_GET['ShoppingList']);
if($item){
$form = Form::editForm(
"index.php", FORMS_PATH.DS.'formInput.yaml', "ShoppingList", $item);
}
}elseif(isset($_GET['TodoList'])){
$item = TodoList::findById($_GET['TodoList']);
if($item){
$form = Form::editForm(
"index.php", FORMS_PATH.DS.'todoInputs.yaml', "TodoList", $item);
}
}
$now=time();
$now = array(
'date'=>strftime("%m/%d/%g",$now),
'time'=>strftime("%H:%M",$now)
);
$header = "<html><head>";
$header.= "<script src=\"http://code.jquery.com/jquery-latest.js\"></script>";
$header.= "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheets/main.css\">";
$header.= "</head>";
$header.= "<body>";
$formInput = FORMS_PATH.DS."formInput.yaml";
$form = !isset($form) ? new Form("index.php", $formInput, "ShoppingList") : $form;
$intro ="<section id=\"intro\">";
$intro .="<button id=\"toggle\" class=\"ShoppingList\" type=\"button\" >switch to TODOs</button>";
$intro .="<div id=\"mutableForm\">";
$intro .=$form->toString();
$intro .="</div>";
$toggler = "<script href=\"js/toggler.js\" type=\"text/javascript\"></script>";
$confirm = "<script href=\"js/confirm.js\" type=\"text/javascript\"></script>";
$script = $toggler.$confirm;
$intro .=$script;
$intro .="<a href=\"printme.php\">printable</a>";
$intro .="</section>";// id=\"intro\">";
//----------------------intro done
$logger->log(0,"index.php::buildPage()", "presenting form defined in {$formInput}");
$content = "<div id=\"content\">";
$content.="<div id=\"content_left\">";
$shoppingList = Lists::parseGroceryList(Lists::getList("ShoppingList"));
$list = "<div id=\"grocery_list\">";
$list .="<h3>Shopping</h3>";
$list .= ListView::RenderList($shoppingList);
$list .="</div>";
$content.=$list."</div>";
//$content.="<div id=\"content_right\">";
//$todoList = Lists::parseTodoList(Lists::getList("TodoList"));
//krumo($todoList);
//$list= "<div id=\"todo_list\">";
//$list.="<h3>TODOs</h3>";
//
//$list.= ListView::RenderTodoList($todoList);
//$list.="</div>";
//$content.=$list."</div>";
$content.= "</div>";// id=\"content\">";
//NEXT STEPS...
// instantiate ListItem from POST array, write it out to file, after checking first to know whether it already exists
// check length of file for too much length.
$closure= "<body/></html>";
echo $header.$intro.$content.$closure;