forked from featherbb/featherbb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearch.php
More file actions
90 lines (72 loc) · 2.71 KB
/
Copy pathSearch.php
File metadata and controls
90 lines (72 loc) · 2.71 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
<?php
/**
* Copyright (C) 2015-2016 FeatherBB
* based on code by (C) 2008-2015 FluxBB
* and Rickard Andersson (C) 2002-2008 PunBB
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*/
namespace FeatherBB\Controller;
use FeatherBB\Core\Error;
use FeatherBB\Core\Url;
use FeatherBB\Core\Utils;
class Search
{
public function __construct()
{
$this->model = new \FeatherBB\Model\Search();
translate('userlist');
translate('search');
translate('topic');
translate('forum');
}
public function display($req, $res, $args)
{
Container::get('hooks')->fire('controller.search.display');
if (User::get()->g_search == '0') {
throw new Error(__('No search permission'), 403);
}
// Figure out what to do :-)
if (Input::query('action') || (Input::query('search_id'))) {
$search = $this->model->get_search_results();
// We have results to display
if (!is_object($search) && isset($search['is_result'])) {
View::setPageInfo(array(
'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Search results')),
'active_page' => 'search',
'search' => $search,
'footer' => $search,
));
$display = $this->model->display_search_results($search);
View::setPageInfo(array(
'display' => $display,
)
);
View::addTemplate('search/header.php', 1);
if ($search['show_as'] == 'posts') {
View::addTemplate('search/posts.php', 5);
}
else {
View::addTemplate('search/topics.php', 5);
}
View::addTemplate('search/footer.php', 10)->display();
} else {
return Router::redirect(Router::pathFor('search'), __('No hits'));
}
}
// Display the form
else {
View::setPageInfo(array(
'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Search')),
'active_page' => 'search',
'focus_element' => array('search', 'keywords'),
'is_indexed' => true,
'forums' => $this->model->get_list_forums(),
))->addTemplate('search/form.php')->display();
}
}
public function quicksearches($req, $res, $args)
{
Container::get('hooks')->fire('controller.search.quicksearches');
return Router::redirect(Router::pathFor('search').'?action=show_'.$args['show']);
}
}