-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathPlugin.php
123 lines (117 loc) · 4.4 KB
/
Plugin.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
<?php namespace Mohsin\Txt;
use Event;
use Backend;
use System\Classes\PluginBase;
/**
* Txt Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'mohsin.txt::lang.plugin.name',
'description' => 'mohsin.txt::lang.plugin.description',
'author' => 'Saifur Rahman Mohsin',
'icon' => 'icon-map-marker',
'homepage' => 'https://github.com/SaifurRahmanMohsin/txt-plugin',
];
}
/**
* boot method, called right before the request route.
*
* @return void
*/
public function boot()
{
Event::listen('system.settings.extendItems', function ($settingsManager) {
if (\Mohsin\Txt\Models\Setting::get('use_robots')) {
$settingsManager->addSettingItems('Mohsin.txt', [
'robots' => [
'label' => 'mohsin.txt::lang.robots.label',
'description' => 'mohsin.txt::lang.robots.description',
'category' => 'mohsin.txt::lang.plugin.name',
'icon' => 'icon-android',
'order' => 601,
'permissions' => ['mohsin.txt.access_robots'],
'url' => Backend::url('mohsin/txt/robots')
],
'agents' => [
'label' => 'mohsin.txt::lang.agent.plural',
'description' => 'mohsin.txt::lang.agent.description',
'category' => 'mohsin.txt::lang.plugin.name',
'icon' => 'icon-search',
'order' => 602,
'permissions' => ['mohsin.txt.access_agents'],
'url' => Backend::url('mohsin/txt/agents')
]
]);
}
if (\Mohsin\Txt\Models\Setting::get('use_humans')) {
$settingsManager->addSettingItems('Mohsin.txt', [
'humans' => [
'label' => 'mohsin.txt::lang.humans.label',
'description' => 'mohsin.txt::lang.humans.description',
'category' => 'mohsin.txt::lang.plugin.name',
'icon' => 'icon-users',
'order' => 603,
'permissions' => ['mohsin.txt.access_humans'],
'url' => Backend::url('mohsin/txt/humans')
]
]);
}
});
}
/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return [
'mohsin.txt.access_settings' => [
'tab' => 'mohsin.txt::lang.plugin.name',
'label' => 'mohsin.txt::lang.permissions.access_settings'
],
'mohsin.txt.access_humans' => [
'tab' => 'mohsin.txt::lang.plugin.name',
'label' => 'mohsin.txt::lang.permissions.access_humans'
],
'mohsin.txt.access_robots' => [
'tab' => 'mohsin.txt::lang.plugin.name',
'label' => 'mohsin.txt::lang.permissions.access_robots'
],
'mohsin.txt.access_agents' => [
'tab' => 'mohsin.txt::lang.plugin.name',
'label' => 'mohsin.txt::lang.permissions.access_agents'
]
];
}
/**
* Registers any settings used by this plugin.
*
* @return array
*/
public function registerSettings()
{
return [
'settings' => [
'label' => 'mohsin.txt::lang.settings.label',
'description' => 'mohsin.txt::lang.settings.description',
'category' => 'mohsin.txt::lang.plugin.name',
'icon' => 'icon-cog',
'url' => Backend::url('mohsin/txt/settings'),
'class' => 'Mohsin\Txt\Models\Setting',
'order' => 600,
'permissions' => ['mohsin.txt.access_settings'],
'keywords' => 'txt robots humans'
]
];
}
}