This repository was archived by the owner on Dec 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPlacidPlugin.php
executable file
·78 lines (71 loc) · 2.07 KB
/
PlacidPlugin.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
<?php
namespace Craft;
class PlacidPlugin extends BasePlugin
{
function getName()
{
return Craft::t('Placid');
}
function getVersion()
{
return '1.6.3';
}
function getDeveloper()
{
return 'Alec Ritson';
}
function getDeveloperUrl()
{
return 'http://alecritson.co.uk';
}
public function hasCpSection()
{
return true;
}
public function registerCpRoutes()
{
return array(
'placid' => array('action' => 'placid/placidIndex'),
'placid/requests/(?P<requestId>\d+)' => array('action' => 'placid/editRequest'),
'placid/requests/new' => array('action' => 'placid/editRequest'),
'placid/auth' => array('action' => 'placid/authIndex'),
'placid/auth/(?P<tokenId>\d+)' => array('action' => 'placid/editAuth'),
'placid/auth/new' => array('action' => 'placid/editAuth'),
'placid/oauth' => array('action' => 'placid/oauthIndex'),
);
}
/**
* Defines the settings.
*
* @access protected
* @return array
*/
protected function defineSettings()
{
return array(
'cache' => array(AttributeType::Bool, 'default' => true),
'widgetTemplatesPath' => array(AttributeType::String, 'default' => '_widgets/placid')
);
}
public function getSettingsHtml()
{
return craft()->templates->render('placid/settings', array(
'settings' => $this->getSettings()
));
}
/**
* Remove all tokens related to this plugin when uninstalled
*/
public function onBeforeUninstall()
{
if(isset(craft()->oauth))
{
craft()->oauth->deleteTokensByPlugin('placid');
}
}
public function onAfterInstall()
{
$exampleRequest = array('name'=> 'Dribbble shots', 'url' => 'http://api.dribbble.com/shots/everyone', 'handle' => 'dribbbleShots', 'oauth' => '', 'params' => '');
craft()->db->createCommand()->insert('placid_requests', $exampleRequest);
}
}