-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
487 lines (407 loc) · 20.8 KB
/
plugin.php
File metadata and controls
487 lines (407 loc) · 20.8 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<?php
/**********************************************************************************************************
* File: plugin.php
* Project: Access Keys
* Programmed by: Cory Bohon (AccessibleFuture.org, BrailleSC.org) at USC Upstate (http://uscupstate.edu)
*
* This software is released under an MIT license.
* For more information about this license type, visit:
* http://www.opensource.org/licenses/mit-license.php
*
*
* Copyright (c) 2009-2013 AccessibleFuture.org, BrailleSC.org, and Cory Bohon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
**********************************************************************************************************
*/
// add plugin hooks
add_plugin_hook('public_footer', 'access_keys_print_footer');
//add_plugin_hook('public_items_show', 'access_keys_browsing_items');
add_plugin_hook('config', 'access_keys_configuration');
add_plugin_hook('config_form', 'access_keys_configuration_form');
add_plugin_hook('uninstall', 'access_keys_uninstall');
// save plugin configuration page
function access_keys_configuration()
{
// save the access keys as a plugin option
set_option('access_keys_page', trim($_POST['access_keys_page']));
set_option('access_keys_skip', trim($_POST['access_keys_skip']));
set_option('access_keys_home', trim($_POST['access_keys_home']));
set_option('access_keys_items', trim($_POST['access_keys_items']));
set_option('access_keys_collections', trim($_POST['access_keys_collections']));
set_option('access_keys_previous', trim($_POST['access_keys_previous']));
set_option('access_keys_next', trim($_POST['access_keys_next']));
set_option('access_keys_search', trim($_POST['access_keys_search']));
// save the custom access keys as a plugin option -- A URL and key for each of the 10 keys
set_option('access_keys_ck1_key', trim($_POST['access_keys_ck1_key']));
set_option('access_keys_ck1_url', trim($_POST['access_keys_ck1_url']));
set_option('access_keys_ck2_key', trim($_POST['access_keys_ck2_key']));
set_option('access_keys_ck2_url', trim($_POST['access_keys_ck2_url']));
set_option('access_keys_ck3_key', trim($_POST['access_keys_ck3_key']));
set_option('access_keys_ck3_url', trim($_POST['access_keys_ck3_url']));
set_option('access_keys_ck4_key', trim($_POST['access_keys_ck4_key']));
set_option('access_keys_ck4_url', trim($_POST['access_keys_ck4_url']));
set_option('access_keys_ck5_key', trim($_POST['access_keys_ck5_key']));
set_option('access_keys_ck5_url', trim($_POST['access_keys_ck5_url']));
set_option('access_keys_ck6_key', trim($_POST['access_keys_ck6_key']));
set_option('access_keys_ck6_url', trim($_POST['access_keys_ck6_url']));
set_option('access_keys_ck7_key', trim($_POST['access_keys_ck7_key']));
set_option('access_keys_ck7_url', trim($_POST['access_keys_ck7_url']));
set_option('access_keys_ck8_key', trim($_POST['access_keys_ck8_key']));
set_option('access_keys_ck8_url', trim($_POST['access_keys_ck8_url']));
set_option('access_keys_ck9_key', trim($_POST['access_keys_ck9_key']));
set_option('access_keys_ck9_url', trim($_POST['access_keys_ck9_url']));
set_option('access_keys_ck10_key', trim($_POST['access_keys_ck10_key']));
set_option('access_keys_ck10_url', trim($_POST['access_keys_ck10_url']));
}
//Uninstall function
function access_keys_uninstall()
{
delete_option('access_keys_page');
delete_option('access_keys_skip');
delete_option('access_keys_home');
delete_option('access_keys_items');
delete_option('access_keys_collections');
delete_option('access_keys_previous');
delete_option('access_keys_next');
delete_option('access_keys_search');
delete_option('access_keys_ck1_key');
delete_option('access_keys_ck1_url');
delete_option('access_keys_ck2_key');
delete_option('access_keys_ck2_url');
delete_option('access_keys_ck3_key');
delete_option('access_keys_ck3_url');
delete_option('access_keys_ck4_key');
delete_option('access_keys_ck4_url');
delete_option('access_keys_ck5_key');
delete_option('access_keys_ck5_url');
delete_option('access_keys_ck6_key');
delete_option('access_keys_ck6_url');
delete_option('access_keys_ck7_key');
delete_option('access_keys_ck7_url');
delete_option('access_keys_ck8_key');
delete_option('access_keys_ck8_url');
delete_option('access_keys_ck9_key');
delete_option('access_keys_ck9_url');
delete_option('access_keys_ck10_key');
delete_option('access_keys_ck10_url');
}
// show plugin configuration page
function access_keys_configuration_form()
{
// create a form inputs to collect the user's custom accesskeys
echo '<div id="access_keys_config_form">';
echo 'Create access keys for the functions below by specifying a one character key for each item you wish to use. Items that have no entries will be ignored when presenting keys to the user.';
echo '<h3><strong>Configure Built-in Omeka Functions</strong></h3>';
?>
<div class="field">
<label for="access_keys_page">Access Keys Description Page: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_page', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_page'), null); ?>
</div>
</div>
<div class="field">
<label for="access_keys_skip">Skip to Content: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_skip', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_skip'), null); ?>
</div>
</div>
<div class="field">
<label for="access_keys_home">Go to Home Page: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_home', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_home'), null); ?>
</div>
</div>
<div class="field">
<label for="access_keys_items">Browse Items: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_items', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_items'), null); ?>
</div>
</div>
<div class="field">
<label for="access_keys_collections">Browse Collections: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_collections', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_collections'), null); ?>
</div>
</div>
<div class="field">
<label for="access_keys_search">Advanced Search: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_search', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_search'), null); ?>
</div>
</div>
<?php //custom access keys configuration ?>
<br /><br />
<h3><strong>Configure Custom Access Keys</strong></h3>
<div class="field">
<label for="access_keys_ck1_key">Custom Access Key 1: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck1_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck1_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck1_url', 'size'=>'50'), get_option('access_keys_ck1_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck2_key">Custom Access Key 2: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck2_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck2_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck2_url', 'size'=>'50'), get_option('access_keys_ck2_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck3_key">Custom Access Key 3: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck3_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck3_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck3_url', 'size'=>'50'), get_option('access_keys_ck3_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck4_key">Custom Access Key 4: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck4_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck4_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck4_url', 'size'=>'50'), get_option('access_keys_ck4_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck1_key">Custom Access Key 5: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck5_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck5_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck5_url', 'size'=>'50'), get_option('access_keys_ck5_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck6_key">Custom Access Key 6: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck6_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck6_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck6_url', 'size'=>'50'), get_option('access_keys_ck6_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck7_key">Custom Access Key 7: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck7_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck7_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck7_url', 'size'=>'50'), get_option('access_keys_ck7_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck8_key">Custom Access Key 8: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck8_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck8_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck8_url', 'size'=>'50'), get_option('access_keys_ck8_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck9_key">Custom Access Key 9: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck9_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck9_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck9_url', 'size'=>'50'), get_option('access_keys_ck9_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<div class="field">
<label for="access_keys_ck10_key">Custom Access Key 10: </label>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck10_key', 'maxlength'=>'1', 'size'=>'2'), get_option('access_keys_ck10_key'), null); ?>
<p class="explanation">
Enter the 1-character access key here.
</p>
</div>
<div class="inputs">
<?php echo get_view()->formText(array('name'=>'access_keys_ck10_url', 'size'=>'50'), get_option('access_keys_ck10_url'), null); ?>
<p class="explanation">
Enter the URL for the access key above.
</p>
</div>
</div>
<?php
}
// function that will print the next/previous item access
function access_keys_browsing_items()
{
//prints out the ahref tags with the appropriate access keys -- only usable when browsing items
if(get_option('access_keys_previous') != "")
{
?>
<a href="<?php echo link_to_previous_item_show(); ?>" accesskey="<?php echo get_option('access_keys_previous'); ?>" title="Press the <?php echo get_option('access_keys_previous'); ?> access key to go to the previous item in the collection."></a>
<?php
}
if(get_option('access_keys_next') != "")
{
?>
<a href="<?php echo link_to_next_item_show(); ?>" accesskey="<?php echo get_option('access_keys_next'); ?>" title="Press the <?php echo get_option('access_keys_next'); ?> access key to go to the previous item in the collection."></a>
<?php
}
}
function access_keys_print_footer()
{
//prints out the the ahref tags with the appropriate accesskeys that are usable on any page in Omeka
if(get_option('access_keys_skip') != "")
{
echo '<a href="#content" "accesskey="' . get_option('access_keys_skip') . '" title="Press the ' . get_option('access_keys_skip') . ' access key to skip to the content of the page"></a>';
}
if(get_option('access_keys_home') != "")
{
echo '<a href="' . html_escape(WEB_ROOT) . '"' . 'accesskey="' . get_option('access_keys_home') . '" title="Press the ' . get_option('access_keys_home') . ' access key to go to the home page of this archive."></a>';
}
if(get_option('access_keys_items') != "")
{
echo '<a href="' . html_escape(WEB_ROOT) . '/items" accesskey="' . get_option('access_keys_items') . '" title="Press the ' . get_option('access_keys_items') . ' access key to browse the collection by items."></a>';
}
if(get_option('access_keys_collections') != "")
{
echo '<a href="' . html_escape(WEB_ROOT) . '/collections" accesskey="' . get_option('access_keys_collections') . '" title="Press the ' . get_option('access_keys_collections') . ' access key to browse the archive by collections."></a>';
}
if(get_option('access_keys_search') != "")
{
echo '<a href="' . html_escape(WEB_ROOT) . '/items/advanced-search" accesskey="' . get_option('access_keys_search') . '" title="Press the ' . get_option('access_keys_search') . ' access key to go to the search page."></a>';
}
//prints out the ahref tags for the custom access keys. These are accessible from any page in Omeka.
if(get_option('access_keys_ck1_key') != "" && get_option('access_keys_ck1_url') != "")
{
echo '<a href="' . get_option('access_keys_ck1_url') . '" accesskey="' . get_option('access_keys_ck1_key') . '" title="Press the ' . get_option('access_keys_ck1_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck1_url') . '"></a>';
}
if(get_option('access_keys_ck2_key') != "" && get_option('access_keys_ck2_url') != "")
{
echo '<a href="' . get_option('access_keys_ck2_url') . '" accesskey="' . get_option('access_keys_ck2_key') . '" title="Press the ' . get_option('access_keys_ck2_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck2_url') . '"></a>';
}
if(get_option('access_keys_ck3_key') != "" && get_option('access_keys_ck3_url') != "")
{
echo '<a href="' . get_option('access_keys_ck3_url') . '" accesskey="' . get_option('access_keys_ck3_key') . '" title="Press the ' . get_option('access_keys_ck3_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck3_url') . '"></a>';
}
if(get_option('access_keys_ck4_key') != "" && get_option('access_keys_ck4_url') != "")
{
echo '<a href="' . get_option('access_keys_ck4_url') . '" accesskey="' . get_option('access_keys_ck4_key') . '" title="Press the ' . get_option('access_keys_ck4_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck4_url') . '"></a>';
}
if(get_option('access_keys_ck5_key') != "" && get_option('access_keys_ck5_url') != "")
{
echo '<a href="' . get_option('access_keys_ck5_url') . '" accesskey="' . get_option('access_keys_ck5_key') . '" title="Press the ' . get_option('access_keys_ck5_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck5_url') . '"></a>';
}
if(get_option('access_keys_ck6_key') != "" && get_option('access_keys_ck6_url') != "")
{
echo '<a href="' . get_option('access_keys_ck6_url') . '" accesskey="' . get_option('access_keys_ck6_key') . '" title="Press the ' . get_option('access_keys_ck6_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck6_url') . '"></a>';
}
if(get_option('access_keys_ck7_key') != "" && get_option('access_keys_ck7_url') != "")
{
echo '<a href="' . get_option('access_keys_ck7_url') . '" accesskey="' . get_option('access_keys_ck7_key') . '" title="Press the ' . get_option('access_keys_ck7_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck7_url') . '"></a>';
}
if(get_option('access_keys_ck8_key') != "" && get_option('access_keys_ck8_url') != "")
{
echo '<a href="' . get_option('access_keys_ck8_url') . '" accesskey="' . get_option('access_keys_ck8_key') . '" title="Press the ' . get_option('access_keys_ck8_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck8_url') . '"></a>';
}
if(get_option('access_keys_ck9_key') != "" && get_option('access_keys_ck9_url') != "")
{
echo '<a href="' . get_option('access_keys_ck9_url') . '" accesskey="' . get_option('access_keys_ck9_key') . '" title="Press the ' . get_option('access_keys_ck9_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck9_url') . '"></a>';
}
if(get_option('access_keys_ck10_key') != "" && get_option('access_keys_ck10_url') != "")
{
echo '<a href="' . get_option('access_keys_ck10_url') . '" accesskey="' . get_option('access_keys_ck10_key') . '" title="Press the ' . get_option('access_keys_ck10_key') . ' access key to go to the following URL: ' . get_option('access_keys_ck10_url') . '"></a>';
}
//Custom Functions
//custom link to function to add an additional tag for access keys
function link_to_custom($additionaltag='', $record, $action=null, $text='View', $props = array(), $queryParams=array())
{
// If we're linking directly to a record, use the URI for that record.
if($record instanceof Omeka_Record) {
$url = record_uri($record, $action);
}
else {
// Otherwise $record is the name of the controller to link to.
$urlOptions = array();
//Use Zend Framework's built-in 'default' route
$route = 'default';
$urlOptions['controller'] = (string) $record;
if($action) $urlOptions['action'] = (string) $action;
$url = uri($urlOptions, $route, $queryParams);
}
$attr = !empty($props) ? ' ' . _tag_attributes($props) : '';
return '<a href="'. html_escape($url) . '"' . $additionaltag . $attr . '>' . $text . '</a>';
}
}
?>