Author
|
zPlus <-->
2016-11-28 23:48:00
|
Committer
|
zPlus <-->
2016-11-28 23:48:00
|
Commit
|
ab6d789
(patch)
|
Tree
|
d33e427
|
Parent(s)
|
|
new file: search.php
new file: template/search.twig
commits diff:
f219d0d..ab6d789
2 files changed,
59 insertions,
0 deletions
—
download
Diffstat
Diff options
+39/-0
A search.php
index
0000000..90a37da
|
old size: 0B
-
new size: 587B
|
new file mode: -rw-r--r--
|
|
1
|
+ |
<?php
|
|
2
|
+ |
|
|
3
|
+ |
/* This script is used to search content and display results */
|
|
4
|
+ |
|
|
5
|
+ |
require_once 'session.php';
|
|
6
|
+ |
require_once 'database.php';
|
|
7
|
+ |
require_once 'date.php';
|
|
8
|
+ |
require_once 'twig.php';
|
|
9
|
+ |
|
|
10
|
+ |
$db = new Database();
|
|
11
|
+ |
$db->connect();
|
|
12
|
+ |
|
|
13
|
+ |
// Must have a query ?q=
|
|
14
|
+ |
if (!isset ($_GET['q']))
|
|
15
|
+ |
{
|
|
16
|
+ |
header ('Location: ./');
|
|
17
|
+ |
exit ();
|
|
18
|
+ |
}
|
|
19
|
+ |
|
|
20
|
+ |
$query = trim ($_GET['q']);
|
|
21
|
+ |
|
|
22
|
+ |
// Query must not be an empty string
|
|
23
|
+ |
if (strlen ($query) == 0)
|
|
24
|
+ |
{
|
|
25
|
+ |
header ('Location: ./');
|
|
26
|
+ |
exit ();
|
|
27
|
+ |
}
|
|
28
|
+ |
|
|
29
|
+ |
|
|
30
|
+ |
|
|
31
|
+ |
echo $twig->render (
|
|
32
|
+ |
'search.twig',
|
|
33
|
+ |
array ('search_results' => []));
|
|
34
|
+ |
|
|
35
|
+ |
|
|
36
|
+ |
|
|
37
|
+ |
|
|
38
|
+ |
|
|
39
|
+ |
|
|
39
|
< |
\ No newline at end of file
|
+20/-0
A template/search.twig
index
0000000..1d9dfcd
|
old size: 0B
-
new size: 371B
|
new file mode: -rw-r--r--
|
|
1
|
+ |
{% include 'header.twig' %}
|
|
2
|
+ |
|
|
3
|
+ |
<div class="results">
|
|
4
|
+ |
|
|
5
|
+ |
{% for result in search_results %}
|
|
6
|
+ |
|
|
7
|
+ |
<div class="result">
|
|
8
|
+ |
{{ result }}
|
|
9
|
+ |
</div>
|
|
10
|
+ |
|
|
11
|
+ |
{% endfor %}
|
|
12
|
+ |
|
|
13
|
+ |
<div class="more">
|
|
14
|
+ |
<a href="?page={{ page + 1 }}" class="button button_default1">
|
|
15
|
+ |
More
|
|
16
|
+ |
</a>
|
|
17
|
+ |
</div>
|
|
18
|
+ |
</div>
|
|
19
|
+ |
|
|
20
|
+ |
{% include 'footer.twig' %}
|