-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPageBannerPlugin.php
106 lines (75 loc) · 2.29 KB
/
PageBannerPlugin.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
<?php
/**
* Page Banner plugin
*
* @copyright Ruud de Jong for the Meertens Institute / University of Twente
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
*/
define('PB_PLUGIN_DIR', dirname(__FILE__));
define('PB_PAGE_PATH', 'pb/');
class PageBannerPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array(
'admin_plugin_uninstall_message',
'define_acl',
'config_form',
'config',
'public_content_top'
);
protected $_filters = array();
/**
* @var array Options and their default values.
*/
protected $_options = array(
'pb_page_url' => '/search',
'pb_show_public' => true,
'pb_banner_text' => 'Help mee deze pagina te verbeteren. Geef uw mening over deze pagina met 10 vragen.',
'pb_banner_button_text' => 'Help mee',
'pb_banner_button_url' => ''
);
public function hookAdminPluginUninstallMessage()
{
echo '<p><strong>Warning</strong>: Uninstalling the Page Banner plugin
will remove the Page Banner.</p>';
}
/**
* Define the acces to controllers and actions
*/
public function hookDefineAcl($args)
{
$acl = $args['acl'];
$indexResource = new Zend_Acl_Resource('PageBanner_Index');
$acl->add($indexResource);
$acl->allow(null, 'PageBanner_Index');
}
/**
* Display the plugin config form.
*/
public function hookConfigForm()
{
require 'config_form.php';
}
/**
* Set the options from the config form input.
*/
public function hookConfig($args)
{
$post = $args['post'];
set_option('pb_page_url', $post['pb_page_url']);
set_option('pb_show_public', (int)(boolean)$post['pb_show_public']);
set_option('pb_banner_text', $post['pb_banner_text']);
set_option('pb_banner_button_text', $post['pb_banner_button_text']);
set_option('pb_banner_button_url', $post['pb_banner_button_url']);
}
/**
* Display the banner if on search page and banner is activated
*/
public function hookPublicContentTop($args){
if (current_url() == get_option('pb_page_url') && (boolean)get_option('pb_show_public')){
if(!isset($_COOKIE['pb_clicked']) || $_COOKIE['pb_clicked'] == false){
include('views/public/index/index.php');
}
}
}
}
?>