-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFeedbackPlugin.php
executable file
·138 lines (121 loc) · 3.33 KB
/
FeedbackPlugin.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* @package omeka-feedback-plugin
* @copyright King's College London Department of Digital Humanities
* @license https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*/
/**
* Feedback plugin.
*/
class FeedbackPlugin extends Omeka_Plugin_AbstractPlugin
{
/**
* @var array Hooks for the plugin.
*/
protected $_hooks = array('install', 'uninstall', 'upgrade', 'initialize',
'define_acl', 'define_routes', 'config_form', 'config');
/**
* @var array Filters for the plugin.
*/
protected $_filters = array(
'admin_navigation_main',
);
/**
* @var array Options and their default values.
*/
protected $_options = array();
/**
* Install the plugin.
* @throws Exception
*/
public function hookInstall()
{
$this->_db->query(<<<SQL
CREATE TABLE IF NOT EXISTS {$this->_db->prefix}feedback_items (
id int(10) unsigned NOT NULL auto_increment,
email varchar(255) NOT NULL,
url text collate utf8_unicode_ci NOT NULL,
title mediumtext collate utf8_unicode_ci NOT NULL,
feedback mediumtext collate utf8_unicode_ci NOT NULL,
created timestamp NOT NULL DEFAULT NOW(),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SQL
);
$this->_installOptions();
}
/**
* Uninstall the plugin.
*/
public function hookUninstall()
{
$this->_db->query(
"DROP TABLE IF EXISTS {$this->_db->prefix}feedback_items");
$this->_uninstallOptions();
}
/**
* Upgrade the plugin.
*
* @param array $args contains: 'old_version' and 'new_version'
*/
public function hookUpgrade($args)
{
}
/**
* Add the translations.
*/
public function hookInitialize()
{
}
public function hookDefineRoutes($args)
{
$args['router']->addConfig(new Zend_Config_Ini(
dirname(__FILE__) . "/routes.ini")
);
}
/**
* Display the plugin config form.
*/
public function hookConfigForm()
{
require dirname(__FILE__) . '/config_form.php';
}
/**
* Define the ACL.
*
* @param Omeka_Acl
*/
public function hookDefineAcl($args)
{
$acl = $args['acl'];
$mappingResource = new Zend_Acl_Resource('Feedback_FeedbackItem');
$acl->add($mappingResource);
}
/**
* Set the options from the config form input.
*/
public function hookConfig()
{
set_option('feedback_notification_sender', $_POST['feedback_notification_sender']);
set_option('feedback_recipient_emails', $_POST['feedback_recipient_emails']);
}
public function hookPublicHead($args)
{
queue_css_file('feedback', $media = "all", $conditional = false, $dir = 'css');
queue_js_file("feedback", $dir = "js");
}
/**
* Add a link to the administrative navigation bar.
*
* @param array $nav The array of label/URI pairs.
* @return array
*/
public function filterAdminNavigationMain($nav)
{
$nav[] = array(
'label' => __('Feedback'),
'uri' => url('feedback')
);
return $nav;
}
}