forked from gsoules/AvantSearch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAvantSearchPlugin.php
105 lines (86 loc) · 2.43 KB
/
AvantSearchPlugin.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
<?php
class AvantSearchPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $item;
protected $_hooks = array(
'admin_head',
'before_save_item',
'config',
'config_form',
'define_routes',
'initialize',
'install',
'items_browse_sql',
'public_footer',
'public_head'
);
protected $_filters = array(
'items_browse_default_sort',
'items_browse_params',
'search_element_texts'
);
public function filterItemsBrowseDefaultSort($params)
{
if (is_admin_theme())
return $params;
$params[0] = ItemMetadata::getTitleElementId();
$params[1] = 'a';
return $params;
}
public function filterItemsBrowseParams($params)
{
return AvantSearch::filterAdvancedSearchParams($params);
}
public function filterSearchElementTexts($elementTexts)
{
return AvantSearch::filterSearchElementTexts($this->item, $elementTexts);
}
public function hookAdminHead($args)
{
queue_css_file('avantsearch-admin');
}
public function hookBeforeSaveItem($args)
{
$this->item = $args['record'];
}
public function hookConfig()
{
SearchConfig::saveConfiguration();
}
public function hookConfigForm()
{
require dirname(__FILE__) . '/config_form.php';
}
public function hookDefineRoutes($args)
{
$args['router']->addConfig(new Zend_Config_Ini(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'routes.ini', 'routes'));
}
public function hookInitialize()
{
// Register the dispatch filter controller plugin.
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new AvantSearch_Controller_Plugin_DispatchFilter);
}
public function hookInstall()
{
SearchConfig::setDefaultOptionValues();
}
public function hookItemsBrowseSql($args)
{
// This method is called whenever any kind of query is being generated.
AvantSearch::buildSearchQuery($args);
}
public function hookPublicFooter($args)
{
echo get_view()->partial('avantsearch-script.php');
}
public function hookPublicHead($args)
{
queue_css_file('avantsearch');
if (AvantSearch::useElasticsearch())
{
queue_js_file('js.cookie');
}
AvantSearch::emitSearchResultsTableCss();
}
}