forked from luwes/craft-polls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPollsPlugin.php
executable file
·105 lines (80 loc) · 2.61 KB
/
PollsPlugin.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
<?php
namespace Craft;
/**
* Polls plugin class
*/
class PollsPlugin extends BasePlugin
{
public function getName()
{
return 'Polls';
}
public function getVersion()
{
return '1.1.0';
}
public function getDeveloper()
{
return 'Wesley Luyten';
}
public function getDeveloperUrl()
{
return 'https://wesleyluyten.com';
}
public function hasCpSection()
{
return true;
}
public function init()
{
}
public function getSettingsHtml()
{
return craft()->templates->render('polls/settings', array(
'settings' => $this->getSettings()
));
}
protected function defineSettings()
{
return array(
'requireLogin' => array(AttributeType::Bool, 'default' => false),
);
}
public function registerCpRoutes()
{
return array(
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/answers'
=> array('action' => 'polls/answers/answersIndex'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/options/(?P<optionId>\d+)/(?P<localeId>\w+)'
=> array('action' => 'polls/options/editOption'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/options/new/(?P<localeId>\w+)'
=> array('action' => 'polls/options/editOption'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/options/(?P<optionId>\d+)'
=> array('action' => 'polls/options/editOption'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/options/new'
=> array('action' => 'polls/options/editOption'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/options'
=> array('action' => 'polls/options/optionsIndex'),
'polls/(?P<pollHandle>{handle})/questions/new/(?P<localeId>\w+)'
=> array('action' => 'polls/questions/editQuestion'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)/(?P<localeId>\w+)'
=> array('action' => 'polls/questions/editQuestion'),
'polls/(?P<pollHandle>{handle})/questions/new'
=> array('action' => 'polls/questions/editQuestion'),
'polls/(?P<pollHandle>{handle})/questions/(?P<questionId>\d+)'
=> array('action' => 'polls/questions/editQuestion'),
'polls/(?P<pollId>\d+)/questiontypes/(?P<questionTypeId>\d+)'
=> array('action' => 'polls/editQuestionType'),
'polls/(?P<pollId>\d+)/optiontypes/(?P<optionTypeId>\d+)'
=> array('action' => 'polls/editOptionType'),
'polls/questions'
=> array('action' => 'polls/questions/questionsIndex'),
'polls/new'
=> array('action' => 'polls/editPoll'),
'polls/(?P<pollHandle>{handle})'
=> array('action' => 'polls/editPoll'),
'polls'
=> array('action' => 'polls/pollsIndex'),
);
}
}