blob: 8fe6a51269dd67041e6534a153c9b0e17dd2177b (
plain)
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
|
<?php
#===============================================================================
# DEFINE: Administration
#===============================================================================
define('ADMINISTRATION', TRUE);
define('AUTHENTICATION', TRUE);
#===============================================================================
# INCLUDE: Initialization
#===============================================================================
require '../../core/application.php';
#===============================================================================
# IF: Handle search request
#===============================================================================
if($search = HTTP::GET('q')) {
if($postIDs = Post\Item::getSearchResultIDs($search, [NULL, NULL, NULL], $Database)) {
foreach($postIDs as $postID) {
try {
$Post = Post\Factory::build($postID);
$User = User\Factory::build($Post->attr('user'));
$posts[] = generatePostItemTemplate($Post, $User);
}
catch(Post\Exception $Exception){}
catch(User\Exception $Exception){}
}
}
}
#===============================================================================
# Build document
#===============================================================================
$SearchTemplate = Template\Factory::build('post/search');
$SearchTemplate->set('QUERY', $search);
$SearchTemplate->set('POSTS', $posts ?? []);
$MainTemplate = Template\Factory::build('main');
$MainTemplate->set('NAME', $Language->text('title_post_search'));
$MainTemplate->set('HTML', $SearchTemplate);
echo $MainTemplate;
|