-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFilePaginatorPlugin.php
More file actions
83 lines (72 loc) · 2.24 KB
/
FilePaginatorPlugin.php
File metadata and controls
83 lines (72 loc) · 2.24 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
/**
* File Paginator
* @copyright Copyright 2018 Ken Albers
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
*/
/**
* File Paginator Plugin
* @package File Paginator
*/
class FilePaginatorPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array(
'public_head',
'public_footer',
'config',
'config_form',
);
protected $_filters = array(
'files_for_item',
'file_markup',
'file_markup_options'
);
public function hookInitialize()
{
get_view()->addHelperPath(dirname(__FILE__) . '/views/helpers', 'FilePaginator_View_Helper_FileShowPagination');
}
public function hookPublicHead($args)
{
queue_js_file('jquery.simplePagination');
queue_js_file('filePagination');
queue_css_file('simplePagination');
queue_css_file('filePaginator');
}
public function hookPublicFooter($args)
{
$view = $args['view'];
echo $view->partial('common/file-show-pagination.php');
}
public function hookConfigForm($args) {
$view = $args['view'];
include('config_form.php');
}
public function hookConfig($args){
$post = $args['post'];
set_option('file_paginator_theme',$post['theme']);
set_option('file_paginator_links',$post['links']);
set_option('file_paginator_metadata',$post['metadata']);
}
public function filterFilesForItem($html) {
$theme = get_option('file_paginator_theme');
return '<div id="file-pagination" data-theme="' . $theme . '"></div>'.$html;
}
public function filterFileMarkupOptions($options) {
if (get_option('file_paginator_links') == 1) {
$options['linkAttributes']['target'] = '_blank';
}
return $options;
}
public function filterFileMarkup($html,$args) {
$file = $args['file'];
$options = $args['options'];
if (empty($options['filesForItem'])) {
return $html;
}
return '<div class="single-file">'
. $html
. (get_option('file_paginator_metadata') == '1' ? all_element_texts($file, array('show_element_set_headings' => false)) : '')
. '</div>';
}
}
?>