/
luggage_isudigitalrepo.module
199 lines (152 loc) · 5.42 KB
/
luggage_isudigitalrepo.module
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* @file
* Code for the luggage_isudigitalrepo feature.
*/
include_once 'luggage_isudigitalrepo.features.inc';
/**
* Implements hook_theme().
*/
function luggage_isudigitalrepo_theme($existing, $type, $theme, $path) {
$themes = array();
$themes['luggage_isudigitalrepo_bepress_widget'] = array(
'variables' => array(
'map_context' => '',
'site_title' => '',
'site_link' => ''
),
'template' => 'luggage-isudigitalrepo-bepress-widget',
'path' => drupal_get_path('module', 'luggage_isudigitalrepo') . '/templates',
);
$themes['views_view_fields__digital_repository'] = array(
'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL),
'template' => 'views-view-fields--digital-repository',
'base hook' => 'views_view_fields',
'path' => drupal_get_path('module', 'luggage_isudigitalrepo') . '/templates',
);
$themes['views_view_list__digital_repository__page'] = array(
'variables' => array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL),
'template' => 'views-view-list--digital-repository--page',
'base hook' => 'views_view_list',
'path' => drupal_get_path('module', 'luggage_isudigitalrepo') . '/templates',
);
return $themes;
}
/**
* Preprocess function for the luggage_isudigitalrepo_bepress_widget theme template
*/
function template_preprocess_luggage_isudigitalrepo_bepress_widget(&$variables) {
if (!empty($variables['map_context'])) {
$variables['map_context'] = drupal_json_encode($variables['map_context']);
}
if (!empty($variables['site_title'])) {
$variables['site_title'] = drupal_json_encode($variables['site_title']);
}
if (!empty($variables['site_link'])) {
$variables['site_link'] = drupal_json_encode($variables['site_link']);
}
}
/*
* Implements hook_block_info().
*/
function luggage_isudigitalrepo_block_info() {
$blocks = array();
$blocks['bepress_widget'] = array(
'info' => t('ISU Digital Repository Publication Map'),
);
return $blocks;
}
/*
* Implements hook_block_configure().
*/
function luggage_isudigitalrepo_block_configure($delta = '') {
$form = array();
switch ($delta) {
case 'bepress_widget':
$form['map_context'] = array(
'#type' => 'textfield',
'#title' => t('Map Context'),
'#default_value' => variable_get('luggage_isudigitalrepo_bepress_widget_map_context', ''),
'#maxlength' => 255,
'#description' => t('mapContext property value for the widget'),
'#required' => TRUE,
'#weight' => -18,
);
$form['site_title'] = array(
'#type' => 'textfield',
'#title' => t('Site Title'),
'#default_value' => variable_get('luggage_isudigitalrepo_bepress_widget_site_title', ''),
'#maxlength' => 255,
'#description' => t('site_title property value for the widget'),
'#required' => TRUE,
'#weight' => -18,
);
$form['site_link'] = array(
'#type' => 'textfield',
'#title' => t('Site Link'),
'#default_value' => variable_get('luggage_isudigitalrepo_bepress_widget_site_link', ''),
'#maxlength' => 255,
'#description' => t('site_link property value for the widget'),
'#required' => TRUE,
'#weight' => -18,
);
break;
}
return $form;
}
/*
* Implements hook_block_save().
*/
function luggage_isudigitalrepo_block_save($delta = '', $edit = array()) {
switch ($delta) {
case 'bepress_widget':
variable_set('luggage_isudigitalrepo_bepress_widget_map_context', $edit['map_context']);
variable_set('luggage_isudigitalrepo_bepress_widget_site_title', $edit['site_title']);
variable_set('luggage_isudigitalrepo_bepress_widget_site_link', $edit['site_link']);
break;
}
}
/*
* Implements hook_block_view().
*/
function luggage_isudigitalrepo_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'bepress_widget':
$map_context = variable_get('luggage_isudigitalrepo_bepress_widget_map_context', '');
$site_title = variable_get('luggage_isudigitalrepo_bepress_widget_site_title', '');
if (empty($site_title)) {
$site_title = variable_get('site_name', '');
}
$site_link = variable_get('luggage_isudigitalrepo_bepress_widget_site_link', '');
if (!empty($map_context) && !empty($site_title) && !empty($site_link)) {
$block['subject'] = t('Recent Publications');
$block['content'] = theme('luggage_isudigitalrepo_bepress_widget', array('map_context' => $map_context, 'site_title' => $site_title, 'site_link' => $site_link));
}
break;
}
return $block;
}
/**
* Implements hook_feed_plugins().
*/
function luggage_isudigitalrepo_feeds_plugins() {
$info = array();
$info['FeedsISUDigitalRepositoryParser'] = array(
'name' => 'ISU Digital Repository parser',
'description' => 'Parse Dublin Core (oai_dc) metadata and document URLs from the ISU Digital Repository.',
'handler' => array(
'parent' => 'FeedsOAIParser',
'class' => 'FeedsISUDigitalRepositoryParser',
'file' => 'FeedsISUDigitalRepositoryParser.inc',
'path' => drupal_get_path('module', 'luggage_isudigitalrepo') . '/plugins',
),
);
return $info;
}
/**
* Implements hook_views_pre_render().
*/
function luggage_isudigitalrepo_preprocess_html(&$variables) {
drupal_add_css(drupal_get_path('module', 'luggage_isudigitalrepo') . '/css/luggage_isudigitalrepo.css');
}