-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrender.php
More file actions
97 lines (76 loc) · 3.07 KB
/
render.php
File metadata and controls
97 lines (76 loc) · 3.07 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
<?php
use airmoi\FileMaker\FileMakerException;
require_once('utilities.php');
require_once ('DatabaseSearch.php');
require_once ('credentials_controller.php');
session_set_cookie_params(0,'/','.ubc.ca',isset($_SERVER["HTTPS"]), true);
session_start();
define("DATABASE", $_GET['Database'] ?? null);
checkDatabaseField(DATABASE);
try {
$databaseSearch = DatabaseSearch::fromDatabaseName(DATABASE);
} catch (FileMakerException $e) {
$_SESSION['error'] = 'Unsupported database given';
header('Location: error.php');
exit;
}
# get the fields for the search and result layout
$layoutFields = $databaseSearch->getSearchLayout()->listFields();
$recFields = $databaseSearch->getResultLayout()->listFields();
$maxResponses = 100;
# remove any empty get fields
$usefulGETFields = array_filter($_GET);
# since we are diffing by keys, we need to set dummy values
$unUsedGETFields = ['type' => '', 'Sort' => '', 'Page' => '', 'SortOrder' => '', 'Database' => ''];
$usefulGETFields = array_diff_key($usefulGETFields, $unUsedGETFields);
try {
$result = $databaseSearch->queryForResults($maxResponses, $usefulGETFields, $_GET['type'] ?? 'and',
$_GET['Sort'] ?? null, $_GET['Page'] ?? 1, $_GET['SortOrder'] ?? null);
} catch (FileMakerException $e) {
$_SESSION['error'] = $e->getMessage();
header('Location: error.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
require_once('partials/conditionalCSS.php');
require_once('partials/widgets.php');
HeaderWidget('Search Table');
?>
<link rel="stylesheet" href="css/render.css">
</head>
<body class="container-fluid no-padding">
<!-- navbar -->
<?php Navbar(); ?>
<!-- Page title below navbar -->
<?php TitleBanner(databaseName: DATABASE); ?>
<!-- main body with table and its widgets -->
<div class="container-fluid">
<?php TableControllerWidget($maxResponses, $result); ?>
<!-- Modify Search Button -->
<div class="form-group">
<form method=post action=<?php echo "search.php"."?Database=".htmlspecialchars(DATABASE);?>>
<?php
# will add the search params as hidden inputs to use in future sort or page calls
foreach ($_GET as $key=>$value) {
if (in_array($key, $layoutFields) || (in_array(str_replace('_', ' ', $key), $layoutFields))) {
echo "<input type=hidden value=".htmlspecialchars($value)." name=".htmlspecialchars($key).">";
}
}
?>
<button type="submit" value = "Submit" class="btn btn-custom">Modify Search</button>
</form>
</div>
<?php
# data table
$databaseSearch->echoDataTable($result);
TableControllerWidget($maxResponses, $result);
?>
</div>
<!-- footer -->
<?php FooterWidget(imgSrc: 'images/beatyLogo.png'); ?>
</body>
</html>