-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathExtension.php
138 lines (126 loc) · 4.89 KB
/
Extension.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
<?php
namespace Igniter\Frontend;
use Illuminate\Support\Facades\Validator;
class Extension extends \System\Classes\BaseExtension
{
public function boot()
{
$this->addCaptchaValidationRule();
}
public function register()
{
$this->registerReCaptcha();
}
public function registerComponents()
{
return [
\Igniter\Frontend\Components\Banners::class => [
'code' => 'banners',
'name' => 'lang:igniter.frontend::default.banners.component_title',
'description' => 'lang:igniter.frontend::default.banners.component_desc',
],
\Igniter\Frontend\Components\Contact::class => [
'code' => 'contact',
'name' => 'lang:igniter.frontend::default.contact.component_title',
'description' => 'lang:igniter.frontend::default.contact.component_desc',
],
\Igniter\Frontend\Components\Slider::class => [
'code' => 'slider',
'name' => 'lang:igniter.frontend::default.slider.component_title',
'description' => 'lang:igniter.frontend::default.slider.component_desc',
],
\Igniter\Frontend\Components\Newsletter::class => [
'code' => 'newsletter',
'name' => 'lang:igniter.frontend::default.newsletter.component_title',
'description' => 'lang:igniter.frontend::default.newsletter.component_desc',
],
\Igniter\Frontend\Components\FeaturedItems::class => [
'code' => 'featuredItems',
'name' => 'lang:igniter.frontend::default.featured.component_title',
'description' => 'lang:igniter.frontend::default.featured.component_desc',
],
\Igniter\Frontend\Components\Captcha::class => [
'code' => 'captcha',
'name' => 'lang:igniter.frontend::default.captcha.component_title',
'description' => 'lang:igniter.frontend::default.captcha.component_desc',
],
];
}
public function registerNavigation()
{
return [
'design' => [
'child' => [
'sliders' => [
'priority' => 30,
'class' => 'sliders',
'href' => admin_url('igniter/frontend/sliders'),
'title' => lang('igniter.frontend::default.text_side_menu'),
'permission' => ['Igniter.FrontEnd.ManageBanners', 'Igniter.FrontEnd.ManageSlideshow'],
],
],
],
];
}
public function registerPermissions()
{
return [
'Igniter.FrontEnd.ManageSettings' => [
'description' => 'Configure google recaptcha and mailchimp settings',
'group' => 'module',
],
'Igniter.FrontEnd.ManageBanners' => [
'description' => 'Create, modify and delete front-end banners',
'group' => 'module',
],
'Igniter.FrontEnd.ManageSlideshow' => [
'group' => 'module',
'description' => 'Create, modify and delete front-end sliders',
],
];
}
public function registerSettings()
{
return [
'captchasettings' => [
'label' => 'reCaptcha Settings',
'description' => 'Manage google reCAPTCHA settings.',
'icon' => 'fa fa-gear',
'model' => \Igniter\Frontend\Models\CaptchaSettings::class,
'permissions' => ['Igniter.FrontEnd.ManageSettings'],
],
'mailchimpsettings' => [
'label' => 'Mailchimp Settings',
'description' => 'Manage Mailchimp API settings.',
'icon' => 'fa fa-gear',
'model' => \Igniter\Frontend\Models\MailchimpSettings::class,
'permissions' => ['Igniter.FrontEnd.ManageSettings'],
],
];
}
public function registerMailTemplates()
{
return [
'igniter.frontend::mail.contact' => 'Contact form email to admin',
];
}
protected function registerReCaptcha()
{
$this->app->singleton('recaptcha', function ($app) {
$settings = Models\CaptchaSettings::instance();
return new Classes\ReCaptcha(
$settings->get('api_secret_key'),
$settings->get('version')
);
});
}
/**
* Extends Validator to include a recaptcha type
*/
protected function addCaptchaValidationRule()
{
Validator::extendImplicit('recaptcha', function ($attribute, $value, $parameters, $validator) {
return app('recaptcha')->verifyResponse($value);
}, lang('igniter.frontend::default.captcha.error_recaptcha'));
}
}