-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfestival-page.php
executable file
·307 lines (252 loc) · 14.3 KB
/
festival-page.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
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?php
session_start();
// Enable error reporting
error_reporting(E_ALL);
// Display errors
ini_set('display_errors', 1);
// Your PHP code here
require_once('includes/connect.php');
include('includes/header.php');
include('comment.php');
include('includes/navigation.php');
// Check if HTTPS is used, otherwise default to HTTP
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
// Get the server name (e.g., www.example.com)
$serverName = $_SERVER['SERVER_NAME'];
// Get the port number
$port = $_SERVER['SERVER_PORT'];
// If the port is not standard, include it in the URL
if (($protocol === "https://" && $port != 443) || ($protocol === "http://" && $port != 80)) {
$serverName .= ":" . $port;
}
// Get the web root path (if your application is in a subdirectory e.g., /myapp)
$webRoot = dirname($_SERVER['PHP_SELF']);
// Construct the base URL
$baseUrl = $protocol . $serverName . $webRoot;
// Get the web root path (if your application is in a subdirectory e.g., /myapp)
$webRoot = dirname($_SERVER['PHP_SELF']);
// Construct the base URL
$baseUrl = $protocol . $serverName . $webRoot;
// get number of per page results from settings table
$rppsql = "SELECT * FROM settings WHERE name='resultsperpage'";
$rppresult = $db->prepare($rppsql);
$rppresult->execute();
$rpp = $rppresult->fetch(PDO::FETCH_ASSOC);
$perpage = $rpp['value'];
if(isset($_GET['page']) & !empty($_GET['page'])){
$curpage = $_GET['page'];
}else{
$curpage = 1;
}
// get the number of total tensum from tensum table
$sqlPage = "SELECT * FROM events";
$resultPage = $db->prepare($sqlPage);
$resultPage->execute();
$totalres = $resultPage->rowCount();
// create startpage, nextpage, endpage variables with values
$endpage = ceil($totalres/$perpage);
$startpage = 1;
$nextpage = $curpage + 1;
$previouspage = $curpage - 1;
$start = ($curpage * $perpage) - $perpage;
?>
<!-- Page Content -->
<div style="width: 97%!important;" class="container">
<div class="row">
<div class="col-lg-8"style="padding-bottom: 200px; padding-top: 50px;">
<div>
<form action="festival-page.php" style="margin-top: 1px;" class="input-group custom-search-form">
<input style="border-color: rgb(199, 228, 254); background-color: rgb(228, 242, 255);margin-bottom: 10px;"name="search" type="text" class="form-control" placeholder="<?php echo htmlspecialchars(translate('search_for'), ENT_QUOTES, 'UTF-8'); ?>">
<span class="input-group-btn">
<button style="border-radius: 0px 5px 5px 0px; padding-top: 10px; background-color: rgb(245, 246, 246);" class="btn btn-default" type="submit">
<?php echo htmlspecialchars(translate('search_btn'), ENT_QUOTES, 'UTF-8'); ?>
<i class="fa fa-search"></i>
</button>
</span>
<div style="margin-left: 20px;" class="col-12 p-1">
<input name="festival" value="festival" type="checkbox" class="form-check-input" id="exampleCheck1" checked>
<label class="form-check-label" for="exampleCheck1"><?php echo htmlspecialchars(translate('festival'), ENT_QUOTES, 'UTF-8'); ?> </label>
</div>
</form>
<?php
// Search form
// Check if search data exists
if (isset($_GET['search']) && !empty($_GET['search'])) {
$searchTerm = $_GET['search'];
$limit = 10; // Number of results per page
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$start = ($page > 1) ? ($page * $limit) - $limit : 0;
// Prepare the full-text search query
$sql = "SELECT *, MATCH(event_tbname, event_enname) AGAINST(:searchTerm IN NATURAL LANGUAGE MODE) AS score FROM events WHERE MATCH(event_tbname, event_enname)
AGAINST(:searchTerm IN NATURAL LANGUAGE MODE) ORDER BY score DESC LIMIT :start, :limit";
$stmt = $db->prepare($sql);
$stmt->bindValue(':searchTerm', $searchTerm);
$stmt->bindValue(':start', $start, PDO::PARAM_INT);
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Calculate total pages
$totalSql = "SELECT COUNT(*) FROM events WHERE MATCH(event_tbname, event_enname) AGAINST(:searchTerm IN NATURAL LANGUAGE MODE)";
$totalStmt = $db->prepare($totalSql);
$totalStmt->bindValue(':searchTerm', $searchTerm);
$totalStmt->execute();
$totalResults = $totalStmt->fetchColumn();
$totalPages = ceil($totalResults / $limit);
// Display results
if (empty($totalResults)) {
?>
<div class="col-12">
<p style="color: #999;border-bottom: 1px solid #ececec;margin: 0px 0px 13px; padding: 0px 0px 10px 0px; text-align: justify; font-family: 'Monlam', Arial, sans-serif; font-size: 12px!important;">
འདི་འདྲ་ཞིག་ <span style="color:red;" ><?php echo $_GET['search'] ?></span> རྙེད་ཀྱི་མི་འདུག
</p>
</div>
<?php
}else{
?>
<p style="color: #999;border-bottom: 1px solid #ececec;margin: 0px 0px 13px; padding: 0px 0px 10px 0px; text-align: justify; font-family: 'Monlam', Arial, sans-serif; font-size: 12px !important; ">
འཚོལ་ཞིབ་ཀྱི་རྙེད་དོན་གྲངས་ <span style="color:rgb(4, 162, 125);" ><?php echo $totalResults ?></span> འདུག
</p>
<?php
}
foreach ($results as $row) {
if($_SESSION['lang'] === 'en'){
$titel = $row['event_enname'];
$web_content = $row['en_description'];
}else if($_SESSION['lang'] === 'bo'){
$titel = $row['event_tbname'];
$web_content = $row['tb_description'];
}else{
$titel = $row['event_enname'];
$web_content = $row['en_description'];
}
?>
<div style="padding-top: 20px;" class="card-body">
<a href="event.php?url=<?php echo $row['slug']; ?>"><h4 style="color: #1e5fa6;margin: 1px;font-size: 20px;line-height: 35px;" class="card-title"><?php echo $titel ?></h4></a>
<div style="border-bottom: 1px solid #ececec;min-height: 110px;">
<img style="width: 150px;object-fit: cover;flo;float: left;height: 90px;object-position: top;margin-right: 6px;position: relative;top: 0px;" class="img-fluid rounded" src="<?php echo $baseUrl ?>/<?php echo $row['pic']; ?>" alt="" onerror="this.onerror=null; this.src='vendor/img/noimage.jpg';">
<p style="position: relative; line-height: 30px; margin: 0px 0px 14px; padding: 0px 0px 10px 0px; text-align: justify; font-family: 'Monlam', Arial, sans-serif; font-size: 14px !important; background-color: #ffffff; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; max-height: 90px; -webkit-line-clamp: 3;">
<?php echo htmlspecialchars($web_content) ?>
</p>
</div>
</div>
<?php
}
// Pagination
for ($i = 1; $i <= $totalPages; $i++) {
echo '<a href="?search=' . urlencode($searchTerm) . '&page=' . $i . '">' . $i . '</a> ';
}
}else {
if($_SESSION['lang'] === 'en'){
$titel = "event_enname";
$web_content = "en_description";
}else if($_SESSION['lang'] === 'bo'){
$titel = "event_tbname";
$web_content = "tb_description";
}else{
$titel = "event_enname";
$web_content = "en_description";
}
$limit2 = 10; // Number of results per page
$page2 = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$start2 = ($page2 > 1) ? ($page2 * $limit2) - $limit2 : 0;
// Prepare the full-text search query
$sql2 = "SELECT * FROM events ORDER BY $titel DESC LIMIT :start, :limit";
$stmt2 = $db->prepare($sql2);
$stmt2->bindValue(':start', $start2, PDO::PARAM_INT);
$stmt2->bindValue(':limit', $limit2, PDO::PARAM_INT);
$stmt2->execute();
$results2 = $stmt2->fetchAll(PDO::FETCH_ASSOC);
// Calculate total pages
$totalSql2 = "SELECT COUNT(*) FROM events ";
$totalStmt2 = $db->prepare($totalSql2);
$totalStmt2->execute();
$totalResults2 = $totalStmt2->fetchColumn();
$totalPages2 = ceil($totalResults2 / $limit2);
// Display results
foreach ($results2 as $row) {
if($_SESSION['lang'] === 'en'){
$titel = $row['event_enname'];
$web_content = $row['en_description'];
}else if($_SESSION['lang'] === 'bo'){
$titel = $row['event_tbname'];
$web_content = $row['tb_description'];
}else{
$titel = $row['event_enname'];
$web_content = $row['en_description'];
}
?>
<div style="padding-top: 20px;" class="card-body">
<a href="event.php?url=<?php echo $row['slug']; ?>"><h4 style="color: #1e5fa6;margin: 1px;font-size: 20px;line-height: 35px;" class="card-title"><?php echo $titel ?></h4></a>
<div style="border-bottom: 1px solid #ececec;min-height: 110px;">
<img style="width: 150px;object-fit: cover;flo;float: left;height: 90px;object-position: top;margin-right: 6px;position: relative;" class="img-fluid rounded" src="<?php echo $row['pic']; ?>" alt="" onerror="this.onerror=null; this.src='vendor/img/noimage.jpg';">
<p style="position: relative; line-height: 30px; margin: 0px 0px 14px; padding: 0px 0px 10px 0px; text-align: justify; font-family: 'Monlam', Arial, sans-serif; font-size: 14px !important; background-color: #ffffff; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; max-height: 90px; -webkit-line-clamp: 3;">
<?php echo htmlspecialchars($web_content) ?>
</p>
</div>
</div>
<?php
}
}
?>
<div style="margin: 10px;">
<!-- Pagination -->
<ul class="pagination justify-content-center mb-4">
<?php if($curpage != $startpage){ ?>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $startpage; ?>">« <?php echo htmlspecialchars(translate('first'), ENT_QUOTES, 'UTF-8'); ?></a>
</li>
<?php } ?>
<?php if($curpage >= 2){ ?>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $previouspage; ?>"><?php echo $previouspage; ?></a>
</li>
<?php } ?>
<?php if($curpage != $endpage ){ ?>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $nextpage; ?>"><?php echo $nextpage; ?></a>
</li>
<?php } ?>
<?php if($curpage != $endpage){ ?>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $endpage; ?>">» <?php echo htmlspecialchars(translate('last'), ENT_QUOTES, 'UTF-8'); ?></a>
</li>
<?php } ?>
</ul>
</div>
</div>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
<?php echo htmlspecialchars(translate('calendar'), ENT_QUOTES, 'UTF-8'); ?>
</button>
<div class="collapse" id="collapseExample">
<div class="card card-body"style="border: none; padding: 0px; margin-top: 20px;">
<!-- ལོ་ཐོ།་འགོ་ འགོ་འཛུགས། -->
<h4><?php echo htmlspecialchars(translate('calendar'), ENT_QUOTES, 'UTF-8'); ?></h4>
<link rel="stylesheet" href="vendor/calendar/calendar.css"> <!-- Link to your CSS file -->
<div style="padding-bottom: 200px;" id="calendar-container">
<div id="calendar-header" class="col-12">
<button type="button" class="btn" id="prev-month">སྔོན་མ།</button>
<span id="month-year"></span>
<button type="button" class="btn" id="next-month">རྗེས་མ།</button>
</div>
<div id="calendar-days"></div>
<div id="calendar">
<div id="event" class="event">
</div>
</div>
</div>
<div id="calendar"></div>
<div>
</div>
<!-- ལོ་ཐོ།་འགོ་ མཇུག། -->
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="vendor/calendar/calendar.js"></script> <!-- Link to your JavaScript file -->
<?php include('includes/sidebar.php'); ?>
</div>
<!-- /.row -->
</div>
</div>
<!-- /.container -->
<?php include('includes/footer.php'); ?>