forked from jan-vince/smallcontactform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
172 lines (139 loc) · 6.39 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
namespace JanVince\SmallContactForm;
use \Illuminate\Support\Facades\Event;
use System\Classes\PluginBase;
use System\Classes\PluginManager;
use Config;
use Backend;
use JanVince\SmallContactForm\Models\Settings;
class Plugin extends PluginBase {
/**
* @var array Plugin dependencies
*/
public $require = [];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails() {
return [
'name' => 'janvince.smallcontactform::lang.plugin.name',
'description' => 'janvince.smallcontactform::lang.plugin.description',
'author' => 'Jan Vince',
'icon' => 'icon-inbox'
];
}
public function boot() {
}
public function registerSettings() {
return [
'settings' => [
'label' => 'janvince.smallcontactform::lang.plugin.name',
'description' => 'janvince.smallcontactform::lang.plugin.description',
'category' => 'Small plugins',
'icon' => 'icon-inbox',
'class' => 'JanVince\SmallContactForm\Models\Settings',
'keywords' => 'small contact form message recaptcha antispam',
'order' => 990,
'permissions' => ['janvince.smallcontactform.access_settings'],
]
];
}
public function registerNavigation(){
return [
'smallcontactform' => [
'label' => 'janvince.smallcontactform::lang.navigation.main_label',
'url' => Backend::url('janvince/smallcontactform/messages'),
'icon' => 'icon-inbox',
'permissions' => ['janvince.smallcontactform.access_messages'],
'order' => 990,
'sideMenu' => [
'messages' => [
'label' => 'janvince.smallcontactform::lang.navigation.messages',
'icon' => 'icon-envelope-o',
'url' => Backend::url('janvince/smallcontactform/messages'),
'permissions' => ['janvince.smallcontactform.access_messages']
],
],
],
];
}
public function registerPermissions(){
return [
'janvince.smallcontactform.access_messages' => [
'label' => 'janvince.smallcontactform::lang.permissions.access_messages',
'tab' => 'janvince.smallcontactform::lang.plugin.name',
],
'janvince.smallcontactform.delete_messages' => [
'label' => 'janvince.smallcontactform::lang.permissions.delete_messages',
'tab' => 'janvince.smallcontactform::lang.plugin.name',
],
'janvince.smallcontactform.access_settings' => [
'label' => 'janvince.smallcontactform::lang.permissions.access_settings',
'tab' => 'janvince.smallcontactform::lang.plugin.name',
],
];
}
public function registerComponents()
{
return [
'JanVince\SmallContactForm\Components\SmallContactForm' => 'contactForm',
];
}
public function registerPageSnippets()
{
return [
'JanVince\SmallContactForm\Components\SmallContactForm' => 'contactForm',
];
}
public function registerMailTemplates()
{
return Settings::getTranslatedTemplates();
}
public function registerMarkupTags()
{
return [
'filters' => [
],
'functions' => [
'trans' => function($value) { return e(trans($value)); },
'html_entity_decode' => function($value) { return html_entity_decode($value); },
'settingsGet' => function($value, $default = NULL) { return Settings::get($value, $default); }
]
];
}
/**
* Custom list types
*/
public function registerListColumnTypes()
{
return [
'strong' => function($value) { return '<strong>'. $value . '</strong>'; },
'text_preview' => function($value) { $content = mb_substr(strip_tags($value), 0, 150); if(mb_strlen($content) > 150) { return ($content . '...'); } else { return $content; } },
'array_preview' => function($value) { $content = mb_substr(strip_tags( implode(' --- ', $value) ), 0, 150); if(mb_strlen($content) > 150) { return ($content . '...'); } else { return $content; } },
'switch_icon_star' => function($value) { return '<div class="text-center"><span class="'. ($value==1 ? 'oc-icon-circle text-success' : 'text-muted oc-icon-circle text-draft') .'">' . ($value==1 ? e(trans('janvince.smallcontactform::lang.models.message.columns.new')) : e(trans('janvince.smallcontactform::lang.models.message.columns.read')) ) . '</span></div>'; },
'switch_extended_input' => function($value) { if($value){return '<input type="checkbox" checked>';} else { return '<input type="checkbox">';} },
'switch_extended' => function($value) { if($value){return '<span class="list-badge badge-success"><span class="icon-check"></span></span>';} else { return '<span class="list-badge badge-danger"><span class="icon-minus"></span></span>';} },
'attached_images_count' => function($value){ return (count($value) ? count($value) : NULL); },
'image_preview' => function($value) {
$width = Settings::get('records_list_preview_width') ? Settings::get('records_list_preview_width') : 50;
$height = Settings::get('records_list_preview_height') ? Settings::get('records_list_preview_height') : 50;
if($value){ return "<img src='".$value->getThumb($width, $height)."' style='width: auto; height: auto; max-width: ".$width."px; max-height: ".$height."px'>"; }
},
];
}
public function registerReportWidgets()
{
return [
'JanVince\SmallContactForm\ReportWidgets\Messages' => [
'label' => 'janvince.smallcontactform::lang.reportwidget.partials.messages.label',
'context' => 'dashboard'
],
'JanVince\SmallContactForm\ReportWidgets\NewMessage' => [
'label' => 'janvince.smallcontactform::lang.reportwidget.partials.new_message.label',
'context' => 'dashboard'
],
];
}
}