-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFacetsPlugin.php
125 lines (108 loc) · 2.9 KB
/
FacetsPlugin.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* @copyright Jean-Baptiste HEREN, 2018
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @package FacetsPlugin
*/
if (!defined('FACETS_PLUGIN_DIR')) {
define('FACETS_PLUGIN_DIR', dirname(__FILE__));
}
require_once FACETS_PLUGIN_DIR . '/helpers/FacetsFunctions.php';
class FacetsPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array(
'install',
'uninstall',
'initialize',
'define_routes',
'public_head',
'items_browse_sql',
'public_items_browse'
);
/**
* Installs the plugin.
*/
public function hookInstall()
{
}
/**
* Uninstalls the plugin.
*/
public function hookUninstall()
{
}
/**
* Initialize this plugin.
*/
public function hookInitialize()
{
get_view()->addHelperPath(dirname(__FILE__) . '/views/helpers', 'Facets_View_Helper_');
}
public function hookPublicHead($args)
{
queue_css_file('facets');
}
public function hookDefineRoutes($args)
{
if (is_admin_theme()) {
return;
}
//Itemtypes browse
$router = $args['router'];
$router->addRoute(
'facets',
new Zend_Controller_Router_Route(
"facets",
array(
'module' => 'facets',
'controller' => 'facets',
'action' => 'browse'
)
)
);
}
/**
* Deal with search terms (advanced search).
*
* Allows to get refinements when a base Dublin Core is used.
*
* @internal This hook is used twice, first to prepare select for the
* current page, second to get the total count.
*
* @internal This should be used, because the filter is not enough for
* requests with a refinable element that should contains something.
*
* @internal MySql 5.5 has a limit: group by is done before order by, and it
* is complex to skirt.
*
* @see DublinCoreExtendedPlugin::filterItemsBrowseParams()
*
* @param Omeka_Db_Select $select
* @param array $params
*/
public function hookItemsBrowseSql($args)
{
$db = $this->_db;
$select = $args['select'];
$params = $args['params'];
}
public function hookPublicItemsBrowse($args)
{
$view = $args['view'];
$items = $args['items'];
// $params = $args['params'];
$itemsArray = array();
$allItems = get_db()->getTable('Item')->findAll();
// $allItems = $this->_helper->db->findBy($params);
foreach($allItems as $item){
$itemsArray[] = $item->id;
}
// echo get_view()->partial('facets/browse.php',array(
// 'itemsArray' => $itemsArray,
// 'items' => $items
// ));
echo get_view()->partial('facets/browse.php',array(
'itemsArray' => $itemsArray
));
}
}