This repository was archived by the owner on Dec 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathplugin.php
More file actions
83 lines (73 loc) · 2.92 KB
/
Copy pathplugin.php
File metadata and controls
83 lines (73 loc) · 2.92 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
<?php
/**
* @version $Id$
* @copyright William Mayo 2011
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @package SubjectBrowse
*/
//Define Constants
define('SUBJECT_BROWSE_PAGE_PATH', 'items/subject-browse/');
// Add plugin hooks.
add_plugin_hook('install', 'subject_browse_install');
add_plugin_hook('uninstall', 'subject_browse_uninstall');
add_plugin_hook('define_routes', 'subject_browse_define_routes');
add_plugin_hook('config', 'subject_browse_config');
add_plugin_hook('config_form', 'subject_browse_config_form');
// Add filters.
add_filter('public_navigation_items', 'subject_browse_public_navigation_items');
if (get_option('subject_browse_item_links')){
add_filter(array('Display', 'Item', 'Dublin Core', 'Subject'), 'subject_browse_item_links');
}
function subject_browse_install()
{
// Get the 'id' key values for the Dublin Core element set and Subject element. Currently only Subject is used.
$db = get_db();
$select = "SELECT id
FROM ". $db->ElementSets . "
WHERE name='Dublin Core';";
$result = $db->fetchAll($select);
set_option('subject_browse_DC_id', $result[0]['id'] );
$select = "SELECT id FROM " . $db->Elements . "
WHERE name='Subject' AND element_set_id='" . get_option('subject_browse_DC_id') . "';";
$result = $db->fetchAll($select);
set_option('subject_browse_DC_Subject_id', $result[0]['id']);
set_option('subject_browse_alphabetical_skiplinks', 1);
set_option('subject_browse_headers', 1);
set_option('subject_browse_item_links', 1);
}
function subject_browse_uninstall()
{
delete_option('subject_browse_DC_id');
delete_option('subject_browse_DC_Subject_id');
delete_option('subject_browse_DC_Subject_id');
delete_option('subject_browse_alphabetical_helpers');
delete_option('subject_browse_headers');
delete_option('subject_browse_item_links');
}
function subject_browse_define_routes($router)
{
$router->addRoute(
'subject_browse_subjectbrowse',
new Zend_Controller_Router_Route(
SUBJECT_BROWSE_PAGE_PATH,
array('module' => 'subject-browse')
)
);
}
function subject_browse_config(){
set_option('subject_browse_alphabetical_skiplinks', $_POST['alphabetical_skiplinks']);
set_option('subject_browse_headers', $_POST['headers']);
set_option('subject_browse_item_links', $_POST['item_links']);
}
function subject_browse_config_form(){
include 'config_form.php';
}
function subject_browse_public_navigation_items($nav)
{
$nav['Browse by Subject'] = uri(SUBJECT_BROWSE_PAGE_PATH);
return $nav;
}
function subject_browse_item_links($subject){
$subject = '<a href="' . uri('items/browse?search=&advanced[0][element_id]=' . get_option('subject_browse_DC_Subject_id') . '&advanced[0][type]=contains&advanced[0][terms]=' . urlencode(html_entity_decode($subject)) . '&submit_search=Search') . '">' . $subject . '</a>';
return $subject;
}