-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
141 lines (115 loc) · 3.9 KB
/
index.php
File metadata and controls
141 lines (115 loc) · 3.9 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'class/database.php';
require_once 'class/log.php';
require_once 'class/util.php';
require_once 'class/ui/textInput.php';
require_once 'class/ui/textArea.php';
require_once 'class/ui/dropdown.php';
$exportParam = Util::ifx($_GET, 'export');
$tableNameParam = Util::ifx($_GET, 'table');
$actionParam = Util::ifx($_GET, 'action');
$resultParam = Util::ifx($_GET, 'result');
$idParam = Util::ifx($_GET, 'id');
$db = new Database();
$logDao = new LogChanges($db);
?>
<!doctype html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A basic CMS for use with BDI mobile applications.">
<meta name="author" content="Grant McNally">
<title>BDI ² CMS</title>
<link rel="canonical" href="">
<!-- Bootstrap core CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0"
crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"
integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8"
crossorigin="anonymous"></script>
<style>
tbody tr:hover {
background-color: lightgray;
cursor: pointer;
}
input, select {
width: 100%;
height: 40px;
}
textarea {
width: 100%;
height: 80px;
}
.container {
margin-top: 10px;
margin-bottom: 10px;
}
.row.form {
margin: 10px;
}
.alert-success, .alert-warning {
padding: 20px;
margin-top: 12px;
margin-bottom: 12px;
}
.CodeMirror, .CodeMirror-scroll {
min-height: 100px !important;
}
</style>
</head>
<body class="">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">BDI ² CMS</a>
<button class="btn btn-primary" type="button" onclick="window.location='index.php?export=<?php echo Export::Home; ?>'">Export</button>
</div>
</nav>
<?php
if ($resultParam):
?>
<div class="container">
<div class="row justify-content-center">
<div class="col-6 alert alert-success text-center" role="alert">
Successfully <?php echo $resultParam; ?>
</div>
</div>
</div>
<?php
endif;
?>
<?php
if ($tableNameParam && in_array($actionParam, array(Action::Add, Action::Edit))) {
require_once 'page/addRow.php';
} else if ($tableNameParam && $actionParam == Action::Delete) {
require_once 'page/deleteRow.php';
} else if ($tableNameParam) {
require_once 'page/rows.php';
} else if ($exportParam && in_array($exportParam, array(Export::Home, Export::AllData, Export::AllChanges))) {
require_once 'page/export.php';
} else {
require_once 'page/tables.php';
}
?>
</body>
</html>
<?php
abstract class Action
{
const Add = 'add';
const Edit = 'edit';
const Delete = 'delete';
const Saved = 'saved';
}
abstract class Export
{
const Home = 'home';
const AllData = 'allData';
const AllChanges = 'allChanges';
}
?>