-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathAdminImagesPlugin.php
118 lines (107 loc) · 2.91 KB
/
AdminImagesPlugin.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
<?php
/**
* AdminImages plugin
*
* @package AdminImages
* @copyright Copyright 2014-2021 UCSC Library Digital Initiatives
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
*/
/**
* AdminImages plugin class
*
* @package AdminImages
*/
class AdminImagesPlugin extends Omeka_plugin_AbstractPlugin
{
/**
* @var array Hooks for the plugin.
*/
protected $_hooks = array(
'install',
'uninstall',
'initialize',
'define_acl',
'admin_head',
);
/**
* @var array Filters for the plugin.
*/
protected $_filters = array('admin_navigation_main');
public function hookInstall($args)
{
try{
$sql = "
CREATE TABLE IF NOT EXISTS `{$this->_db->AdminImage}` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` text,
`alt` text,
`href` text,
`file_id` int,
`creator_id` int,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
$this->_db->query($sql);
}
catch(Exception $e) {
throw $e;
}
}
/**
* When the plugin uninstalls, delete the database tables
*which store the logs
*
* @return void
*/
public function hookUninstall()
{
try {
$db = get_db();
$sql = "DROP TABLE IF EXISTS `$db->AdminImage` ";
$db->query($sql);
}
catch(Exception $e) {
throw $e;
}
}
public function hookInitialize()
{
// Add translation.
add_translation_source(dirname(__FILE__) . '/languages');
add_shortcode('admin_image', 'admin_image_tag_shortcode');
require_once(dirname(__FILE__) . "/helpers/AdminImageFunctions.php");
get_view()->addHelperPath(dirname(__FILE__) . '/views/helpers/', 'AdminImages_View_Helper_');
}
/**
* Define the plugin's access control list.
*
* @param array $args This array contains a reference to
* the zend ACL under its 'acl' key.
* @return void
*/
public function hookDefineAcl($args)
{
$args['acl']->addResource('AdminImages_Index');
}
/**
* Add the AdminImages link to the admin main navigation.
*
* @param array $nav Array of links for admin nav section
* @return array $nav Updated array of links for admin nav section
*/
public function hookAdminHead()
{
queue_css_file('admin-images');
queue_js_file('admin-images');
}
public function filterAdminNavigationMain($nav)
{
$nav[] = array(
'label' => __('Admin Images'),
'uri' => url('admin-images'),
'resource' => 'AdminImages_Index',
'privilege' => 'index'
);
return $nav;
}
}