forked from ColdTrick/search_advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.php
70 lines (55 loc) · 2.57 KB
/
start.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
<?php
require_once(dirname(__FILE__) . "/lib/functions.php");
require_once(dirname(__FILE__) . "/lib/hooks.php");
function search_advanced_init(){
// page handler for search actions and results
elgg_register_page_handler('search_advanced', 'search_advanced_page_handler');
elgg_register_page_handler('search', 'search_advanced_search_page_handler');
// search hooks
search_advanced_unregister_default_search_hooks();
search_advanced_register_search_hooks();
// views
elgg_extend_view("css/elgg", "search_advanced/css/site");
elgg_extend_view("js/elgg", "search_advanced/js/site");
// search widget
elgg_register_widget_type("search", elgg_echo("search"), elgg_echo("search"), "profile,dashboard,index,groups", true);
if (elgg_is_active_plugin("categories")) {
// make universal categories searchable
add_translation(get_current_language(), array("tag_names:universal_categories" => elgg_echo("categories")));
elgg_register_tag_metadata_name("universal_categories");
}
}
function search_advanced_page_handler($page){
switch($page[0]){
case "autocomplete":
include_once(dirname(__FILE__) . "/procedures/autocomplete.php");
return true;
}
}
function search_advanced_search_page_handler($page){
// if there is no q set, we're being called from a legacy installation
// it expects a search by tags.
// actually it doesn't, but maybe it should.
// maintain backward compatibility
if(!get_input('q', get_input('tag', NULL)) && isset($page[0])) {
set_input('q', $page[0]);
//set_input('search_type', 'tags');
}
// as there is no tags search any more, replace it with ALL search
if (get_input("search_type") == "tags") {
set_input("search_type", "all");
}
$base_dir = elgg_get_plugins_path() . 'search_advanced/pages/search';
include_once("$base_dir/index.php");
return true;
}
elgg_register_event_handler('init','system','search_advanced_init');
// hooks and events to clear cache
// register hooks
elgg_register_plugin_hook_handler("action", "admin/plugins/activate", "search_advanced_clear_keywords_cache");
elgg_register_plugin_hook_handler("action", "admin/plugins/deactivate", "search_advanced_clear_keywords_cache");
elgg_register_plugin_hook_handler("action", "admin/plugins/activate_all", "search_advanced_clear_keywords_cache");
elgg_register_plugin_hook_handler("action", "admin/plugins/deactivate_all", "search_advanced_clear_keywords_cache");
elgg_register_plugin_hook_handler("action", "plugins/settings/save", "search_advanced_clear_keywords_cache");
// register events
elgg_register_event_handler("upgrade", "system", "search_advanced_clear_keywords_cache");