-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
287 lines (237 loc) · 8.21 KB
/
Copy pathindex.php
File metadata and controls
287 lines (237 loc) · 8.21 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?php
require_once 'assets/config/config.php';
require_once "vendor/autoload.php";
/*
* The Photo Tech Guru
* Created by John R. Pepp
* Date Created: July, 12, 2021
* Last Revision: April 20, 2023
* Version: 5.01 ßeta
*
*/
use PhotoTech\{
ErrorHandler,
Database,
Links,
ImageContentManager
};
$errorHandler = new ErrorHandler();
// Register the exception handler method
set_exception_handler([$errorHandler, 'handleException']);
$database = new Database();
$pdo = $database->createPDO();
$args = [];
// New Instance of CMS Class
$gallery = new ImageContentManager($pdo, $args);
if ($database->check_login_token()) {
header('location: dashboard.php');
exit();
}
$displayFormat = ["gallery-container w-2 h-2", 'gallery-container w-2 h-2', 'gallery-container w-2 h-2', 'gallery-container h-2', 'gallery-container h-2', 'gallery-container w-2 h-2"', 'gallery-container h-2', 'gallery-container h-2', 'gallery-container w-2 h-2', 'gallery-container h-2', 'gallery-container h-2', 'gallery-container w-2 h-2'];
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_GET['category'])) {
$category = $_GET['category'];
} else {
error_log('Category is not set in the GET data');
$category = 'wildlife';
}
$total_count = $gallery->countAllPage($category);
} else {
try {
$category = 'wildlife';
$total_count = $gallery->countAllPage($category);
} catch (Exception $e) {
error_log('Error while counting all pages: ' . $e->getMessage());
}
}
/*
* Using pagination in order to have a nice looking
* website page.
*/
// Grab the current page the user is on
if (isset($_GET['page']) && !empty($_GET['page'])) {
$current_page = urldecode($_GET['page']);
} else {
$current_page = 1;
}
$per_page = 1; // Total number of records to be displayed:
// Grab Total Pages
$total_pages = $gallery->total_pages($total_count, $per_page);
/* Grab the offset (page) location from using the offset method */
/* $per_page * ($current_page - 1) */
$offset = $gallery->offset($per_page, $current_page);
// Figure out the Links that you want the display to look like
$links = new Links($current_page, $per_page, $total_count, $category);
// Finally grab the records that are actually going to be displayed on the page
$records = $gallery->page($per_page, $offset, 'gallery', $category);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=yes, initial-scale=1.0">
<title>Home Page</title>
<link rel="stylesheet" media="all" href="assets/css/stylesheet.css">
<style>
#myButton {
outline: none;
color: #fff;
border: none;
background-color: #f12929;
box-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5);
width: 6.25em;
font-family: "Rubik", sans-serif;
font-size: 1.2em;
text-transform: capitalize;
text-decoration: none;
cursor: pointer;
padding: 0.313em;
margin: 0.625em;
transition: background-color 0.5s;
float: right;
text-align: center;
}
#myButton:hover {
background-color: #009578;
}
.pagination {
display: inline-block;
padding-left: 0;
margin: 20px 0;
border-radius: 4px;
}
.pagination > li {
display: inline;
}
.pagination > li > a,
.pagination > li > span {
position: relative;
float: left;
font-size: 1.0em;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
}
.pagination > li:first-child > a,
.pagination > li:first-child > span {
margin-left: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.pagination > li:last-child > a,
.pagination > li:last-child > span {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.pagination > li > a:hover,
.pagination > li > a:focus {
color: #23527c;
background-color: #eee;
border-color: #ddd;
}
.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover,
.pagination > .active > span:hover,
.pagination > .active > a:focus,
.pagination > .active > span:focus {
z-index: 2;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
}
.pagination > li > span {
display: inline-block;
padding: 6px 12px;
color: #999;
background-color: #fff;
border: 1px solid #ddd;
box-sizing: border-box;
height: 2.313em;
}
.pagination > li > span::before {
content: '...';
display: inline-block;
vertical-align: middle;
}
</style>
</head>
<body class="site">
<header class="nav">
<input type="checkbox" class="nav-btn" id="nav-btn">
<label for="nav-btn">
<span></span>
<span></span>
<span></span>
</label>
<nav class="nav-links" id="nav-links">
<?php $database->regular_navigation(); ?>
</nav>
<div class="name-website">
<h1 class="webtitle">The Photo Tech Guru</h1>
</div>
</header>
<main class="main_container">
<section class="home_article">
<?php
foreach ($records as $record) {
echo '<article class="home_info" itemscope itemtype="http://schema.org/BlogPosting">';
echo '<meta itemprop="author" content="' . $record['author'] . '">';
echo '<meta itemprop="datePublished" content="' . $record['date_added'] . '">';
echo '<meta itemprop="dateModified" content="' . $record['date_updated'] . '">';
echo '<h2 itemprop="headline" class="home_heading">' . $record['heading'] . '</h2>';
echo '<img itemprop="image" class="home_image" src="' . $record['image_path'] . '" title="' . $record['heading'] . '" alt="' . $record['heading'] . '">';
echo '<div itemprop="articleBody" class="home_paragraph">' . nl2br($record['content']) . '</div>';
echo '</article>';
}
?>
</section>
<aside class="home_sidebar">
<form id="myForm" action="index.php" method="GET">
<label for="category">Category:</label>
<select id="category" class="select-css" name="category" tabindex="1">
<option selected value="<?= $category ?>"><?= ucfirst($category) ?></option>
<option value="general">General</option>
<option value="landscape">Landscape</option>
<option value="lego">LEGO</option>
<option value="halloween">Halloween</option>
<option value="wildlife">Wildlife</option>
</select>
<button style="display: none" type="submit" class="submit-btn" name="enter" tabindex="2">Submit</button>
</form>
<?php echo $links->display_links(); ?>
</aside>
</main>
<aside class="sidebar">
</aside>
<footer class="colophon">
<p>© <?php echo date("Y") ?> The Photo Tech Guru</p>
</footer>
<script>
const selectElement = document.getElementById("category");
selectElement.addEventListener("change", (event) => {
// Code to handle the change event
event.target.form.submit();
});
</script>
<script src="assets/js/lightbox.js"></script>
<script>
function toggleNavMenu() {
let navLinks = document.getElementById('nav-links');
if (navLinks.style.height === '0px' || navLinks.style.height === '') {
navLinks.style.height = 'calc(100vh - 3.125em)';
navLinks.style.overflowY = 'auto';
} else {
navLinks.style.height = '0px';
navLinks.style.overflowY = 'hidden';
}
}
</script>
</body>
</html>