Skip to content

Commit e036d4c

Browse files
authored
Migration to WinterCMS (#2)
* update references to Winter * update Winter imports * update references to Winter * update references to Winter
1 parent ed1180c commit e036d4c

File tree

16 files changed

+191
-177
lines changed

16 files changed

+191
-177
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ about: Create a bug report for Magic Forms
88
Use issues to report errors / bugs only.
99
1010
Do you have questions?
11-
* Read the docs: https://skydiver.github.io/october-plugin-forms/docs/introduction/
12-
* Start a discussion: https://github.com/skydiver/october-plugin-forms/discussions
11+
* Read the docs: https://github.com/skydiver/wn-magic-forms/
12+
* Start a discussion: https://github.com/skydiver/wn-magic-forms/discussions
1313
14-
-->
14+
-->

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
4-
url: https://github.com/skydiver/october-plugin-forms/discussions
5-
about: Ask questions and discuss with other community members
4+
url: https://github.com/skydiver/wn-magic-forms/discussions
5+
about: Ask questions and discuss with other community members

Plugin.php

Lines changed: 101 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,116 @@
11
<?php
22

3-
namespace Martin\Forms;
3+
namespace Martin\Forms;
44

5-
use Backend, Lang, Validator;
6-
use System\Classes\PluginBase;
7-
use System\Classes\SettingsManager;
8-
use Martin\Forms\Classes\BackendHelpers;
9-
use Martin\Forms\Classes\GDPR;
10-
use Martin\Forms\Classes\ReCaptchaValidator;
11-
use Martin\Forms\Classes\UnreadRecords;
12-
use Martin\Forms\Models\Settings;
5+
use Backend\Facades\Backend;
6+
use Martin\Forms\Classes\GDPR;
7+
use System\Classes\PluginBase;
8+
use Martin\Forms\Models\Settings;
9+
use System\Classes\SettingsManager;
10+
use Illuminate\Support\Facades\Lang;
11+
use Martin\Forms\Classes\UnreadRecords;
12+
use Martin\Forms\Classes\BackendHelpers;
13+
use Winter\Storm\Support\Facades\Validator;
1314

14-
class Plugin extends PluginBase {
15-
16-
public function pluginDetails() {
17-
return [
18-
'name' => 'martin.forms::lang.plugin.name',
19-
'description' => 'martin.forms::lang.plugin.description',
20-
'author' => 'Martin M.',
21-
'icon' => 'icon-bolt',
22-
'homepage' => 'https://github.com/skydiver/'
23-
];
24-
}
15+
class Plugin extends PluginBase
16+
{
17+
public function pluginDetails()
18+
{
19+
return [
20+
'name' => 'martin.forms::lang.plugin.name',
21+
'description' => 'martin.forms::lang.plugin.description',
22+
'author' => 'Martin M.',
23+
'icon' => 'icon-bolt',
24+
'homepage' => 'https://github.com/skydiver/'
25+
];
26+
}
2527

26-
public function registerNavigation() {
27-
if(Settings::get('global_hide_button', false)) { return; }
28-
return [
29-
'forms' => [
30-
'label' => 'martin.forms::lang.menu.label',
31-
'icon' => 'icon-bolt',
32-
'iconSvg' => 'plugins/martin/forms/assets/imgs/icon.svg',
33-
'url' => BackendHelpers::getBackendURL(['martin.forms.access_records' => 'martin/forms/records', 'martin.forms.access_exports' => 'martin/forms/exports'], 'martin.forms.access_records'),
34-
'permissions' => ['martin.forms.*'],
35-
'sideMenu' => [
36-
'records' => [
37-
'label' => 'martin.forms::lang.menu.records.label',
38-
'icon' => 'icon-database',
39-
'url' => Backend::url('martin/forms/records'),
40-
'permissions' => ['martin.forms.access_records'],
41-
'counter' => UnreadRecords::getTotal(),
42-
'counterLabel' => 'Un-Read Messages'
43-
],
44-
'exports' => [
45-
'label' => 'martin.forms::lang.menu.exports.label',
46-
'icon' => 'icon-download',
47-
'url' => Backend::url('martin/forms/exports'),
48-
'permissions' => ['martin.forms.access_exports']
49-
],
50-
]
51-
]
52-
];
28+
public function registerNavigation()
29+
{
30+
if (Settings::get('global_hide_button', false)) {
31+
return;
5332
}
5433

55-
public function registerSettings() {
56-
return [
57-
'config' => [
58-
'label' => 'martin.forms::lang.menu.label',
59-
'description' => 'martin.forms::lang.menu.settings',
60-
'category' => SettingsManager::CATEGORY_CMS,
61-
'icon' => 'icon-bolt',
62-
'class' => 'Martin\Forms\Models\Settings',
63-
'permissions' => ['martin.forms.access_settings'],
64-
'order' => 500
34+
return [
35+
'forms' => [
36+
'label' => 'martin.forms::lang.menu.label',
37+
'icon' => 'icon-bolt',
38+
'iconSvg' => 'plugins/martin/forms/assets/imgs/icon.svg',
39+
'url' => BackendHelpers::getBackendURL(['martin.forms.access_records' => 'martin/forms/records', 'martin.forms.access_exports' => 'martin/forms/exports'], 'martin.forms.access_records'),
40+
'permissions' => ['martin.forms.*'],
41+
'sideMenu' => [
42+
'records' => [
43+
'label' => 'martin.forms::lang.menu.records.label',
44+
'icon' => 'icon-database',
45+
'url' => Backend::url('martin/forms/records'),
46+
'permissions' => ['martin.forms.access_records'],
47+
'counter' => UnreadRecords::getTotal(),
48+
'counterLabel' => 'Un-Read Messages'
49+
],
50+
'exports' => [
51+
'label' => 'martin.forms::lang.menu.exports.label',
52+
'icon' => 'icon-download',
53+
'url' => Backend::url('martin/forms/exports'),
54+
'permissions' => ['martin.forms.access_exports']
55+
],
6556
]
66-
];
67-
}
68-
69-
public function registerPermissions() {
70-
return [
71-
'martin.forms.access_settings' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_settings'],
72-
'martin.forms.access_records' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_records'],
73-
'martin.forms.access_exports' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_exports'],
74-
'martin.forms.gdpr_cleanup' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.gdpr_cleanup'],
75-
];
76-
}
57+
]
58+
];
59+
}
7760

78-
public function registerComponents() {
79-
return [
80-
'Martin\Forms\Components\GenericForm' => 'genericForm',
81-
'Martin\Forms\Components\FilePondForm' => 'filepondForm',
82-
'Martin\Forms\Components\EmptyForm' => 'emptyForm',
83-
];
84-
}
61+
public function registerSettings()
62+
{
63+
return [
64+
'config' => [
65+
'label' => 'martin.forms::lang.menu.label',
66+
'description' => 'martin.forms::lang.menu.settings',
67+
'category' => SettingsManager::CATEGORY_CMS,
68+
'icon' => 'icon-bolt',
69+
'class' => 'Martin\Forms\Models\Settings',
70+
'permissions' => ['martin.forms.access_settings'],
71+
'order' => 500
72+
]
73+
];
74+
}
8575

86-
public function registerMailTemplates() {
87-
return [
88-
'martin.forms::mail.notification' => Lang::get('martin.forms::lang.mails.form_notification.description'),
89-
'martin.forms::mail.autoresponse' => Lang::get('martin.forms::lang.mails.form_autoresponse.description'),
90-
];
91-
}
76+
public function registerPermissions()
77+
{
78+
return [
79+
'martin.forms.access_settings' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_settings'],
80+
'martin.forms.access_records' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_records'],
81+
'martin.forms.access_exports' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.access_exports'],
82+
'martin.forms.gdpr_cleanup' => ['tab' => 'martin.forms::lang.permissions.tab', 'label' => 'martin.forms::lang.permissions.gdpr_cleanup'],
83+
];
84+
}
9285

93-
public function register() {
94-
$this->app->resolving('validator', function($validator) {
95-
Validator::extend('recaptcha', 'Martin\Forms\Classes\ReCaptchaValidator@validateReCaptcha');
96-
});
97-
}
86+
public function registerComponents()
87+
{
88+
return [
89+
'Martin\Forms\Components\GenericForm' => 'genericForm',
90+
'Martin\Forms\Components\FilePondForm' => 'filepondForm',
91+
'Martin\Forms\Components\EmptyForm' => 'emptyForm',
92+
];
93+
}
9894

99-
public function registerSchedule($schedule) {
100-
$schedule->call(function () {
101-
$records = GDPR::cleanRecords();
102-
})->daily();
103-
}
95+
public function registerMailTemplates()
96+
{
97+
return [
98+
'martin.forms::mail.notification' => Lang::get('martin.forms::lang.mails.form_notification.description'),
99+
'martin.forms::mail.autoresponse' => Lang::get('martin.forms::lang.mails.form_autoresponse.description'),
100+
];
101+
}
104102

103+
public function register()
104+
{
105+
$this->app->resolving('validator', function () {
106+
Validator::extend('recaptcha', 'Martin\Forms\Classes\ReCaptchaValidator@validateReCaptcha');
107+
});
105108
}
106109

107-
?>
110+
public function registerSchedule($schedule)
111+
{
112+
$schedule->call(function () {
113+
GDPR::cleanRecords();
114+
})->daily();
115+
}
116+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Magic Forms for OctoberCMS
1+
# Magic Forms for WinterCMS
22
Create easy (and almost magic) AJAX forms.
33

44

@@ -33,4 +33,4 @@ So, the objective was to find a way to just put the HTML elements on the page, s
3333

3434
## Documentation
3535
Checkout our docs at:
36-
> https://skydiver.github.io/october-plugin-forms/
36+
> https://github.com/skydiver/wn-magic-forms/

classes/FilePond/FilePondController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Martin\Forms\Classes\FilePond;
44

5-
use Validator;
65
use Illuminate\Http\Request;
76
use Martin\Forms\Models\Settings;
87
use Illuminate\Support\Facades\Response;
9-
use October\Rain\Filesystem\Definitions;
8+
use Winter\Storm\Filesystem\Definitions;
9+
use Winter\Storm\Support\Facades\Validator;
1010
use Illuminate\Routing\Controller as BaseController;
1111

1212
class FilePondController extends BaseController

classes/MagicForm.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
namespace Martin\Forms\Classes;
44

5-
use App;
6-
use Lang;
7-
use Config;
8-
use Request;
9-
use Session;
10-
use Redirect;
11-
use Validator;
12-
use AjaxException;
135
use Cms\Classes\ComponentBase;
146
use Martin\Forms\Models\Record;
157
use Martin\Forms\Models\Settings;
8+
use Illuminate\Support\Facades\App;
9+
use Illuminate\Support\Facades\Lang;
1610
use Illuminate\Support\Facades\Event;
11+
use Winter\Storm\Validation\Validator;
12+
use Illuminate\Support\Facades\Request;
13+
use Illuminate\Support\Facades\Session;
14+
use Illuminate\Support\Facades\Redirect;
1715
use Martin\Forms\Classes\BackendHelpers;
16+
use Winter\Storm\Support\Facades\Config;
17+
use Winter\Storm\Exception\AjaxException;
1818
use Martin\Forms\Classes\FilePond\FilePond;
1919
use Martin\Forms\Classes\Mails\AutoResponse;
2020
use Martin\Forms\Classes\Mails\Notification;
21-
use October\Rain\Exception\ValidationException;
21+
use Winter\Storm\Exception\ValidationException;
2222

2323
abstract class MagicForm extends ComponentBase
2424
{

classes/Mails/Notification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Martin\Forms\Classes\Mails;
44

5-
use Mail;
65
use Martin\Forms\Models\Record;
76
use System\Models\MailTemplate;
8-
use October\Rain\Database\Collection;
7+
use Winter\Storm\Database\Collection;
8+
use Winter\Storm\Support\Facades\Mail;
99
use Martin\Forms\Classes\BackendHelpers as BH;
1010

1111
class Notification

components/emptyform/default.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h3>Here goes your custom form</h3>
2-
<p>Override HTML by creating a new partial called <strong>default.htm</strong> (more info <a href="https://octobercms.com/docs/cms/components#overriding-partials" target="_blank">here</a>)</p>
2+
<p>Override HTML by creating a new partial called <strong>default.htm</strong> (more info <a href="https://wintercms.com/docs/cms/components#overriding-partials" target="_blank">here</a>)</p>
33
<p>You can copy/paste this basic template:</p>
44
<pre>
55
&lt;form data-request="&lbrace;&lbrace; __SELF__ }}::onFormSubmit"&gt;
@@ -9,4 +9,4 @@ <h3>Here goes your custom form</h3>
99
&lbrace;% partial '@recaptcha' %}
1010
&lt;!-- SUBMIT BUTTON --&gt;
1111
&lt;/form&gt;
12-
</pre>
12+
</pre>

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "martin/wn-magic-forms-plugin",
3+
"type": "winter-plugin",
4+
"description": "Create easy (and almost magic) AJAX forms",
5+
"keywords": ["winter", "cms", "plugin", "forms", "magic forms"],
6+
"homepage": "https://github.com/skydiver/wn-magic-forms/",
7+
"license": "MIT"
8+
}

controllers/Records.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Martin\Forms\Controllers;
44

5-
use App;
6-
use Lang;
7-
use BackendMenu;
85
use Backend\Facades\Backend;
96
use Martin\Forms\Classes\GDPR;
107
use Backend\Classes\Controller;
118
use Martin\Forms\Models\Record;
9+
use Backend\Facades\BackendMenu;
10+
use Illuminate\Support\Facades\App;
11+
use Illuminate\Support\Facades\Lang;
1212
use Martin\Forms\Classes\UnreadRecords;
13-
use October\Rain\Support\Facades\Flash;
13+
use Winter\Storm\Support\Facades\Flash;
1414
use Illuminate\Support\Facades\Redirect;
1515

1616
class Records extends Controller
@@ -32,10 +32,12 @@ public function __construct()
3232
public function view($id)
3333
{
3434
$record = Record::find($id);
35+
3536
if (!$record) {
3637
Flash::error(e(trans('martin.forms::lang.controllers.records.error')));
3738
return Redirect::to(Backend::url('martin/forms/records'));
3839
}
40+
3941
$record->unread = false;
4042
$record->save();
4143
$this->addCss('/plugins/martin/forms/assets/css/records.css');

0 commit comments

Comments
 (0)