-
Notifications
You must be signed in to change notification settings - Fork 2
/
extension.driver.php
106 lines (93 loc) · 2.62 KB
/
extension.driver.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
require_once(EXTENSIONS . '/anti_spam_question/lib/class.anti_spam_question.php');
class extension_anti_spam_question extends Extension {
/**
* Append custom navigation items to backend navigation
*/
public function fetchNavigation()
{
return array(
array(
'location' => __('System'),
'name' => anti_spam_question::EXT_NAME,
'link' => '/questions/'
)
);
}
/**
* Subscribe to delegates
*/
public function getSubscribedDelegates()
{
return array(
array(
'page' => '/blueprints/events/',
'delegate' => 'AppendEventFilterDocumentation',
'callback' => 'appendEventFilterDocumentation'
),
array(
'page' => '/blueprints/events/new/',
'delegate' => 'AppendEventFilter',
'callback' => 'appendEventFilter'
),
array(
'page' => '/blueprints/events/edit/',
'delegate' => 'AppendEventFilter',
'callback' => 'appendEventFilter'
),
array(
'page' => '/frontend/',
'delegate' => 'EventPreSaveFilter',
'callback' => 'eventPreSaveFilter'
)
);
}
/**
* install the extension
*/
public function install()
{
return anti_spam_question::createTable();
}
/**
* uninstall the extension
*/
public function uninstall()
{
return anti_spam_question::deleteTable();
}
/**
* Append filter to symphony's event pages
*/
public function appendEventFilter($context)
{
$context['options'][] = array(
anti_spam_question::EXT_DS_ROOT,
@in_array(
anti_spam_question::EXT_DS_ROOT, $context['selected']
),
anti_spam_question::EXT_NAME
);
}
/**
* Append filter documentation to symphony's event pages
*/
public function appendEventFilterDocumentation($context)
{
if (in_array('anti-spam-question', $context['selected'])) {
$context['documentation'][] = new XMLElement('h3', __('Anti Spam Question Filter'));
$context['documentation'][] = new XMLElement('p', __('To use the Anti Spam Question Filter, attach the Anti Spam Question Datasource on the pages that you use this event and add the following to your form:'));
$code = Widget::Label('<xsl:value-of select="//anti-spam-question/entry" />');
$code->appendChild(Widget::Input('anti-spam-question[answer]', NULL, 'text' ));
$code->appendChild(Widget::Input('anti-spam-question[id]', '{//anti-spam-question/entry/@id}', 'hidden' ));
$context['documentation'][] = contentAjaxEventDocumentation::processDocumentationCode($code);
}
}
/**
* perform event filter
*/
public function eventPreSaveFilter($context)
{
anti_spam_question::eventFilter($context);
}
}