From 6b0509a1dbe11d4ca5ad0badae7c1884593eeef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 22 Aug 2017 20:17:39 +0200 Subject: [PATCH] FEATURE: move contactform into own repository --- Config/.gitkeep | 0 Config/config.php | 12 ++ Handlers/ContactForm.php | 152 ++++++++++++++++++ Handlers/ContactFormHistory.php | 28 ++++ Http/Controllers/Visitor/CreateNewMessage.php | 60 +++++++ Http/Requests/SendNewEmailRequest.php | 21 +++ Http/routes.php | 12 ++ .../SavePipeline/SaveContactInformation.php | 39 +++++ Providers/ContactFormServiceProvider.php | 50 ++++++ Resources/lang/cs/admin/adminMenu.php | 9 ++ Resources/lang/cs/admin/content.php | 15 ++ Resources/lang/cs/admin/history.php | 11 ++ Resources/lang/cs/admin/widgets.php | 16 ++ Resources/lang/cs/module.php | 8 + Resources/lang/en/admin/adminMenu.php | 9 ++ Resources/lang/en/admin/content.php | 15 ++ Resources/lang/en/admin/history.php | 12 ++ Resources/lang/en/admin/widgets.php | 16 ++ Resources/lang/en/module.php | 8 + Resources/lang/sk/admin/adminMenu.php | 8 + Resources/lang/sk/admin/content.php | 15 ++ Resources/lang/sk/admin/history.php | 11 ++ Resources/lang/sk/module.php | 5 + .../views/admin/form/basicInfo.blade.php | 136 ++++++++++++++++ Resources/views/admin/form/content.blade.php | 3 + .../admin/widgets/address/edit.blade.php | 19 +++ .../admin/widgets/address/form.blade.php | 19 +++ .../views/admin/widgets/address/new.blade.php | 14 ++ .../views/admin/widgets/form/edit.blade.php | 19 +++ .../views/admin/widgets/form/form.blade.php | 17 ++ .../views/admin/widgets/form/new.blade.php | 14 ++ Widgets/Address/Address.php | 51 ++++++ Widgets/Address/Presenter.php | 76 +++++++++ Widgets/Form/Form.php | 51 ++++++ Widgets/Form/Presenter.php | 73 +++++++++ start.php | 15 ++ 36 files changed, 1039 insertions(+) create mode 100755 Config/.gitkeep create mode 100755 Config/config.php create mode 100755 Handlers/ContactForm.php create mode 100755 Handlers/ContactFormHistory.php create mode 100755 Http/Controllers/Visitor/CreateNewMessage.php create mode 100755 Http/Requests/SendNewEmailRequest.php create mode 100755 Http/routes.php create mode 100755 Pipeline/SavePipeline/SaveContactInformation.php create mode 100644 Providers/ContactFormServiceProvider.php create mode 100755 Resources/lang/cs/admin/adminMenu.php create mode 100755 Resources/lang/cs/admin/content.php create mode 100755 Resources/lang/cs/admin/history.php create mode 100755 Resources/lang/cs/admin/widgets.php create mode 100755 Resources/lang/cs/module.php create mode 100755 Resources/lang/en/admin/adminMenu.php create mode 100755 Resources/lang/en/admin/content.php create mode 100755 Resources/lang/en/admin/history.php create mode 100755 Resources/lang/en/admin/widgets.php create mode 100755 Resources/lang/en/module.php create mode 100755 Resources/lang/sk/admin/adminMenu.php create mode 100755 Resources/lang/sk/admin/content.php create mode 100755 Resources/lang/sk/admin/history.php create mode 100755 Resources/lang/sk/module.php create mode 100755 Resources/views/admin/form/basicInfo.blade.php create mode 100755 Resources/views/admin/form/content.blade.php create mode 100755 Resources/views/admin/widgets/address/edit.blade.php create mode 100755 Resources/views/admin/widgets/address/form.blade.php create mode 100755 Resources/views/admin/widgets/address/new.blade.php create mode 100755 Resources/views/admin/widgets/form/edit.blade.php create mode 100755 Resources/views/admin/widgets/form/form.blade.php create mode 100755 Resources/views/admin/widgets/form/new.blade.php create mode 100755 Widgets/Address/Address.php create mode 100755 Widgets/Address/Presenter.php create mode 100755 Widgets/Form/Form.php create mode 100755 Widgets/Form/Presenter.php create mode 100755 start.php diff --git a/Config/.gitkeep b/Config/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/Config/config.php b/Config/config.php new file mode 100755 index 0000000..c4bbdcd --- /dev/null +++ b/Config/config.php @@ -0,0 +1,12 @@ + 'ContactForm', + 'translatedName' => 'contactform::module.name', + 'translatedDescription' => 'contactform::module.description', + 'alias' => 'contactform', + 'handler' => '\\Modules\\ContactForm\\Handlers\\ContactForm', + 'providers' => [\Modules\ContactForm\Providers\ContactFormServiceProvider::class], + 'files' => ['start.php'], + 'order' => 0, +]; \ No newline at end of file diff --git a/Handlers/ContactForm.php b/Handlers/ContactForm.php new file mode 100755 index 0000000..3755038 --- /dev/null +++ b/Handlers/ContactForm.php @@ -0,0 +1,152 @@ +. View is returned only as name in plain text + * + * @return array of views/templates/html codes divided into section + */ + public static function getExtendedFormInputsCreate() + { + return [ + 'basicInfo' => 'contactform::admin.form.basicInfo', + 'content' => 'contactform::admin.form.content', + 'meta' => 'admin.content.formParts.metaInformation', + 'appearance' => 'admin.content.formParts.appearance', + 'publication' => 'admin.content.formParts.publicationSetup', + 'files' => 'admin.content.formParts.files', + ]; + } + + public static function getExtendedFormInputsEdit() + { + return self::getExtendedFormInputsCreate(); + } + + /** + * Register admin menu (or multiple ones) + * + * This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before + * starting any middleware.. + * + * @param User $user model of logged user + */ + public static function registerAdminMenu(User $user) + { + // register links in admin menu + $menu = \Menu::instance('mainMenu'); + + $submenu = $menu->whereTitle(trans('admin/mainMenu.contentPages')); + $submenu->dropdown(trans('contactform::admin/adminMenu.contactForm'), function ($submenu) use ($user) { + $submenu->route('content.new', trans('contactform::admin/adminMenu.new'), ['moduleId' => self::getModuleId()], 10, ['icon' => 'fa fa-plus']); + $submenu->route('content.overview', trans('contactform::admin/adminMenu.overview'), ['moduleId' => self::getModuleId()], 20, ['icon' => 'fa fa-list']); + // $submenu->route('emails.sent', trans('contactform::admin/adminMenu.sentMessages'), [], 30, ['icon' => 'fa fa-send']); + }, 25, ['icon' => 'fa fa-envelope-o']); + } + + /** + * Does given module manage content? Or is it just module with widgets/something internal/something absolutely else? + * + * @return bool + */ + public static function managesContent() + { + return true; + } + + /** + * Get translated title for pages overview of given type. + * + * This value is used for rendering list of all content pages of given type in administration. + * + * @return string + */ + public static function getOverviewTitle() + { + return trans('contactform::module.allForms'); + } + + /** + * Title displayed above for for creating new content page + * + * @return string + */ + public static function getCreateNewTitle() + { + return trans('contactform::module.newForm'); + } + + /** + * Title for form displayed for editin content page + * + * @param Content $content + * + * @return mixed + */ + public static function getEditTitle(Content $content) + { + return trans('contactform::module.editForm'); + } + + /** + * Does this module support categories? + * + * @return boolean + */ + public static function supportCategories() + { + return true; + } + + /** + * Method called right after content page is marked as deleted + * + * This method is supposed to clean after "deleted" page. + * + * @param Content $content + * + * @return mixed + */ + public static function delete(Content $content) + { + } +} \ No newline at end of file diff --git a/Handlers/ContactFormHistory.php b/Handlers/ContactFormHistory.php new file mode 100755 index 0000000..3a1def5 --- /dev/null +++ b/Handlers/ContactFormHistory.php @@ -0,0 +1,28 @@ +findOrFail($formId); + + // select template + $template = isset($form->moduleSettings['emailTemplate']) ? $form->moduleSettings['emailTemplate'] : 'contactform::emails.default'; + + // send email + $status = Mail::send(Template::name($template), ['data' => $request], function (Message $message) use ($request, $form) { + $message->from($request->email, $request->name); + + // get message subject + $subject = isset($form->moduleSettings['subject']) ? $form->moduleSettings['subject'] : trans('contactform::admin/contents.defaultSubject'); + + $message->to($form->moduleSettings['email']) + ->subject($subject); + }); + + // inform user about success or failure + return $this->sendResponse($status, $request, $form); + } + + private function sendResponse($status, SendNewEmailRequest $request, $form) + { + // send response for ajax + if ($request->ajax()) { + return response()->json([ + 'status' => $status ? 'success' : 'failed', + 'redirectUrl' => $form->url + ]); + } else { + // redirect user to previous form + $response = redirect()->back(); + + return $status ? $response->with('success', 'sent') : $response->with('error', 'cannotSend'); + } + } +} diff --git a/Http/Requests/SendNewEmailRequest.php b/Http/Requests/SendNewEmailRequest.php new file mode 100755 index 0000000..7e0dab6 --- /dev/null +++ b/Http/Requests/SendNewEmailRequest.php @@ -0,0 +1,21 @@ + 'required', + 'email' => 'required|email', + 'message' => 'required', + 'g-recaptcha-response' => 'required|recaptcha', + ]; + } +} diff --git a/Http/routes.php b/Http/routes.php new file mode 100755 index 0000000..2ff17cf --- /dev/null +++ b/Http/routes.php @@ -0,0 +1,12 @@ + ['web'], + 'namespace' => '\Modules\ContactForm\Http\Controllers\Visitor', + 'prefix' => LaravelLocalization::setLocale() . '/contactform' + ], function () { + + // method for sending new message + + Route::post('/message/{formId}', 'CreateNewMessage@postMessage') + ->name('email.send'); +}); \ No newline at end of file diff --git a/Pipeline/SavePipeline/SaveContactInformation.php b/Pipeline/SavePipeline/SaveContactInformation.php new file mode 100755 index 0000000..a4f7441 --- /dev/null +++ b/Pipeline/SavePipeline/SaveContactInformation.php @@ -0,0 +1,39 @@ + + */ + function handle(Content & $page, array & $input) + { + if (trim($page->moduleHandler, '\\') != ContactForm::class) { + return; + } + + $settings = [ + 'phone' => $input['phone'], + 'email' => $input['email'], + 'contactEmail' => $input['contactEmail'], + 'subject' => $input['subject'], + 'companyName' => $input['companyName'], + 'address' => $input['address'], + 'gpsLat' => $input['gpsLat'], + 'gpsLng' => $input['gpsLng'], + ]; + + // save settings + $page->moduleSettings = $settings; + $page->save(); + } +} \ No newline at end of file diff --git a/Providers/ContactFormServiceProvider.php b/Providers/ContactFormServiceProvider.php new file mode 100644 index 0000000..10f6590 --- /dev/null +++ b/Providers/ContactFormServiceProvider.php @@ -0,0 +1,50 @@ +registerWidgets(); + + app('saveContentPipeline')->add(SaveContactInformation::class); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + } + + private function registerWidgets() + { + $registrator = $this->app->make('registerWidget'); + + $registrator->register(Address::class, null, ContactForm::getModuleId()); + $registrator->register(Form::class, null, ContactForm::getModuleId()); + } + + protected function setModuleAlias() + { + $this->alias = 'contactform'; + } + + protected function setModulePath() + { + $this->path = __DIR__; + } +} diff --git a/Resources/lang/cs/admin/adminMenu.php b/Resources/lang/cs/admin/adminMenu.php new file mode 100755 index 0000000..72e7b03 --- /dev/null +++ b/Resources/lang/cs/admin/adminMenu.php @@ -0,0 +1,9 @@ + "Kontaktní formulář", +"emails" => "E-mailové šablony", +"new" => "Nový", +"overview" => "Všechny formuláře", +"sentMessages" => "Zprávy", +"templatePath" => "Kontaktní formulář", +]; diff --git a/Resources/lang/cs/admin/content.php b/Resources/lang/cs/admin/content.php new file mode 100755 index 0000000..85db12f --- /dev/null +++ b/Resources/lang/cs/admin/content.php @@ -0,0 +1,15 @@ + "Adresa", +"compName" => "Jméno zobrazené nad adresou", +"contactEmail" => "E-mail, kam budou doručovány zprávy z tohoto formuláře", +"contactInformation" => "Kontaktní informace", +"content" => "Obsah kontaktního formuláře", +"defaultSubject" => "Nová zpráva z kontaktního formuláře", +"email" => "E-mail", +"emailList" => "Odesílat zprávy na tyto adresy", +"gpsLat" => "GPS šířka", +"gpsLng" => "GPS délka", +"phone" => "Kontaktní telefon", +"subject" => "Předmět zprávy", +]; diff --git a/Resources/lang/cs/admin/history.php b/Resources/lang/cs/admin/history.php new file mode 100755 index 0000000..2c6525b --- /dev/null +++ b/Resources/lang/cs/admin/history.php @@ -0,0 +1,11 @@ + "Adresa", +"columnCompanyName" => "Jméno společnosti", +"columnContactEmail" => "Kontaktní e-mail", +"columnEmail" => "E-mail", +"columnGpsLat" => "GPS šířka", +"columnGpsLng" => "GPS délka", +"columnPhone" => "Telefon", +"columnSubject" => "Předmět", +]; diff --git a/Resources/lang/cs/admin/widgets.php b/Resources/lang/cs/admin/widgets.php new file mode 100755 index 0000000..9c2f1d0 --- /dev/null +++ b/Resources/lang/cs/admin/widgets.php @@ -0,0 +1,16 @@ + [ + "description" => "Malý widget určený pro zobrazení adresy, která byla uložena u vybraného kontaktního formuláře.", + "edit" => "Upravuji blok s adresou", + "name" => "Blok s adresou", + "new" => "Nový blok s adresou", + ], + "form" => [ + "description" => "Widget pro zobrazení kontaktního formuláře kdekoliv na webu - v obsahu stránky, menu, patičce, ...", + "name" => "Kontaktní formulář", + "new" => "Nový widget s kontaktním formulářem", + ], + "noContactForms" => "Vypadá to, že v systému nebyl vytvořen žádný kontaktní formulář. Z toho důvodu není možné vytvořit ani tento widget. Vytvořte nejprve nějaký kontaktní formulář a pak opakujte tento pokus.", + "selectContactForm" => "Vybrat kontaktní formulář", +]; diff --git a/Resources/lang/cs/module.php b/Resources/lang/cs/module.php new file mode 100755 index 0000000..c76b942 --- /dev/null +++ b/Resources/lang/cs/module.php @@ -0,0 +1,8 @@ + "Všechny formuláře", +"description" => "Jednoduchý kontaktní formulář", +"editForm" => "Upravuji formulář", +"name" => "Kontaktní formulář", +"newForm" => "Vytvořit nový kontaktní formulář", +]; diff --git a/Resources/lang/en/admin/adminMenu.php b/Resources/lang/en/admin/adminMenu.php new file mode 100755 index 0000000..3e869c0 --- /dev/null +++ b/Resources/lang/en/admin/adminMenu.php @@ -0,0 +1,9 @@ + 'Contact form', + 'new' => 'New', + 'overview' => 'All contact forms', + 'sentMessages' => 'Messages', + 'templatePath' => 'Contact form', + 'emails' => 'E-mail templates', +]; \ No newline at end of file diff --git a/Resources/lang/en/admin/content.php b/Resources/lang/en/admin/content.php new file mode 100755 index 0000000..134b9b3 --- /dev/null +++ b/Resources/lang/en/admin/content.php @@ -0,0 +1,15 @@ + 'Contact form content', + 'address' => 'Address', + 'emailList' => 'Send emails to these addresses', + 'gpsLat' => 'GPS latitude', + 'gpsLng' => 'GPS longitude', + 'compName' => 'Name displayed above address', + 'phone' => 'Contact phone', + 'email' => 'E-mail', + 'contactEmail' => 'E-mail, where messages from this form will be delivered', + 'contactInformation' => 'Contact information', + 'subject' => 'Subject', + 'defaultSubject' => 'New message from contact form' +]; \ No newline at end of file diff --git a/Resources/lang/en/admin/history.php b/Resources/lang/en/admin/history.php new file mode 100755 index 0000000..dab9086 --- /dev/null +++ b/Resources/lang/en/admin/history.php @@ -0,0 +1,12 @@ + 'Phone', + 'columnAddress' => 'Address', + 'columnEmail' => 'E-mail', + 'columnContactEmail' => 'Contact E-mail', + 'columnSubject' => 'Subject', + 'columnCompanyName' => 'Company name', + 'columnGpsLat' => 'GPS Latitude', + 'columnGpsLng' => 'Gps Longitude', +]; + diff --git a/Resources/lang/en/admin/widgets.php b/Resources/lang/en/admin/widgets.php new file mode 100755 index 0000000..3d387a0 --- /dev/null +++ b/Resources/lang/en/admin/widgets.php @@ -0,0 +1,16 @@ + [ + 'name' => 'Address block', + 'description' => 'Small widget for displaying address saved in selected contact form.', + 'new' => 'New address block', + 'edit' => 'Editing address block' + ], + 'form' => [ + 'name' => 'Contact form', + 'description' => 'Display small contact form anywhere on website.', + 'new' => 'New contact form widget' + ], + 'noContactForms' => 'You have not created any contact form. Try to create one before creating this widget.', + 'selectContactForm' => 'Select contact form' +]; \ No newline at end of file diff --git a/Resources/lang/en/module.php b/Resources/lang/en/module.php new file mode 100755 index 0000000..3e9d374 --- /dev/null +++ b/Resources/lang/en/module.php @@ -0,0 +1,8 @@ + 'Contact form', + 'description' => 'Simple contact form', + 'allForms' => 'All contact forms', + 'newForm' => 'Create new contact form', + 'editForm' => 'Editing contact form' +]; \ No newline at end of file diff --git a/Resources/lang/sk/admin/adminMenu.php b/Resources/lang/sk/admin/adminMenu.php new file mode 100755 index 0000000..d4dcea9 --- /dev/null +++ b/Resources/lang/sk/admin/adminMenu.php @@ -0,0 +1,8 @@ + "Kontaktný formulár", + "new" => "Nový", + "overview" => "Všetky formuláre", + "sentMessages" => "Správy", + "templatePath" => "Kontaktný formulár", +]; \ No newline at end of file diff --git a/Resources/lang/sk/admin/content.php b/Resources/lang/sk/admin/content.php new file mode 100755 index 0000000..c283c25 --- /dev/null +++ b/Resources/lang/sk/admin/content.php @@ -0,0 +1,15 @@ + "Adresa", + "compName" => "Názov zobrazený nad adresou", + "contactEmail" => "E-mail, kam budú doručované správy z tohoto formulára", + "contactInformation" => "Kontaktné informácie", + "content" => "Obsah kontaktného formulára", + "defaultSubject" => "Nová správa z kontaktného formulára", + "email" => "E-mail", + "emailList" => "Odosielať správy na tieto adresy", + "gpsLat" => "GPS šírka", + "gpsLng" => "GPS dĺžka", + "phone" => "Kontaktný telefón", + "subject" => "Predmet správy", +]; diff --git a/Resources/lang/sk/admin/history.php b/Resources/lang/sk/admin/history.php new file mode 100755 index 0000000..c0664df --- /dev/null +++ b/Resources/lang/sk/admin/history.php @@ -0,0 +1,11 @@ + "Adresa", + "columnCompanyName" => "Názov spoločnosti", + "columnContactEmail" => "Kontaktný e-mail", + "columnEmail" => "E-mail", + "columnGpsLat" => "GPS šírka", + "columnGpsLng" => "GPS dĺžka", + "columnPhone" => "Telefón", + "columnSubject" => "Predmet", +]; diff --git a/Resources/lang/sk/module.php b/Resources/lang/sk/module.php new file mode 100755 index 0000000..ad64271 --- /dev/null +++ b/Resources/lang/sk/module.php @@ -0,0 +1,5 @@ + "Jednoduchý kontaktný formulár", + "name" => "Kontaktný formulár", +]; diff --git a/Resources/views/admin/form/basicInfo.blade.php b/Resources/views/admin/form/basicInfo.blade.php new file mode 100755 index 0000000..184df29 --- /dev/null +++ b/Resources/views/admin/form/basicInfo.blade.php @@ -0,0 +1,136 @@ +
+
+ + + @include('admin.snippets.hasError', ['field' => 'title']) +
+
+ + + + @include('admin.snippets.hasError', ['field' => 'url']) +
+
+
+ +
+
+
+ +
+
+ + + @include('admin.snippets.hasError', ['field' => 'status']) +
+
+ + + @include('admin.snippets.hasError', ['field' => 'parentPage']) +
+ + @if($module->support_categories && count($categories)) +
+ +
+ @endif +
+ +

@lang('contactform::admin/content.contactInformation')

+ +
+
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+ + + +
+
+ + + +
+
+
+
diff --git a/Resources/views/admin/form/content.blade.php b/Resources/views/admin/form/content.blade.php new file mode 100755 index 0000000..5d680a1 --- /dev/null +++ b/Resources/views/admin/form/content.blade.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Resources/views/admin/widgets/address/edit.blade.php b/Resources/views/admin/widgets/address/edit.blade.php new file mode 100755 index 0000000..00692dd --- /dev/null +++ b/Resources/views/admin/widgets/address/edit.blade.php @@ -0,0 +1,19 @@ +@extends('admin.layoutWithNavigation') + +@section('pageHeading', @trans('contactform::admin/widgets.address.edit')) +@section('pageDescription', $widget->description) + +@section('content') + + @if(!count($forms)) +
@lang('contactform::admin/widgets.noContactForms')
+ @else +
+ @include('contactform::admin.widgets.address.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])]) +
+
+ @widgetPreview($widget) +
+ @endif +@endsection + diff --git a/Resources/views/admin/widgets/address/form.blade.php b/Resources/views/admin/widgets/address/form.blade.php new file mode 100755 index 0000000..e6cda72 --- /dev/null +++ b/Resources/views/admin/widgets/address/form.blade.php @@ -0,0 +1,19 @@ +
+ @include('admin.widgets.snippets.commonForm') + + + + + + + + +
\ No newline at end of file diff --git a/Resources/views/admin/widgets/address/new.blade.php b/Resources/views/admin/widgets/address/new.blade.php new file mode 100755 index 0000000..3a5eef5 --- /dev/null +++ b/Resources/views/admin/widgets/address/new.blade.php @@ -0,0 +1,14 @@ +@extends('admin.layoutWithNavigation') + +@section('pageHeading', @trans('contactform::admin/widgets.address.new')) +@section('pageDescription', @trans($type->description)) + +@section('content') + + @if(!count($forms)) +
@lang('contactform::admin/widgets.noContactForms')
+ @else + @include('contactform::admin.widgets.address.form', ['action' => route('widgets.postNew', ['type' => $type])]) + @endif +@endsection + diff --git a/Resources/views/admin/widgets/form/edit.blade.php b/Resources/views/admin/widgets/form/edit.blade.php new file mode 100755 index 0000000..b3b0b98 --- /dev/null +++ b/Resources/views/admin/widgets/form/edit.blade.php @@ -0,0 +1,19 @@ +@extends('admin.layoutWithNavigation') + +@section('pageHeading', @trans('contactform::admin/widgets.address.edit')) +@section('pageDescription', $widget->description) + +@section('content') + + @if(!count($forms)) +
@lang('contactform::admin/widgets.noContactForms')
+ @else +
+ @include('contactform::admin.widgets.form.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])]) +
+
+ @widgetPreview($widget) +
+ @endif +@endsection + diff --git a/Resources/views/admin/widgets/form/form.blade.php b/Resources/views/admin/widgets/form/form.blade.php new file mode 100755 index 0000000..19dfcd3 --- /dev/null +++ b/Resources/views/admin/widgets/form/form.blade.php @@ -0,0 +1,17 @@ +
+ @include('admin.widgets.snippets.commonForm') + + + + + + +
\ No newline at end of file diff --git a/Resources/views/admin/widgets/form/new.blade.php b/Resources/views/admin/widgets/form/new.blade.php new file mode 100755 index 0000000..fc3ff7c --- /dev/null +++ b/Resources/views/admin/widgets/form/new.blade.php @@ -0,0 +1,14 @@ +@extends('admin.layoutWithNavigation') + +@section('pageHeading', @trans('contactform::admin/widgets.form.new')) +@section('pageDescription', @trans($type->description)) + +@section('content') + + @if(!count($forms)) +
@lang('contactform::admin/widgets.noContactForms')
+ @else + @include('contactform::admin.widgets.form.form', ['action' => route('widgets.postNew', ['type' => $type])]) + @endif +@endsection + diff --git a/Widgets/Address/Address.php b/Widgets/Address/Address.php new file mode 100755 index 0000000..75d6f63 --- /dev/null +++ b/Widgets/Address/Address.php @@ -0,0 +1,51 @@ + $data->contactFormId]; + } +} \ No newline at end of file diff --git a/Widgets/Address/Presenter.php b/Widgets/Address/Presenter.php new file mode 100755 index 0000000..d828752 --- /dev/null +++ b/Widgets/Address/Presenter.php @@ -0,0 +1,76 @@ +settings->contactFormId); + + if (!$form) + return null; + + $formData = $form->moduleSettings; + + $code = '
container_id) { + $code .= ' id="' . e($widget->container_id).'"'; + } + $code .= '>'; + $code .= "

".e($formData['companyName']).'

'; + $code .= nl2br($formData['address']); + $code .= "
"; + + return $code; + } + + /** + * Display form for creating new instance of widget + * + * @param WidgetType $type + * + * @return mixed + */ + public static function renderAddForm(WidgetType $type) + { + $contactForms = Content::where('moduleHandler', config('contactform.handler')) + ->get(); + + return view('contactform::admin.widgets.address.new', [ + 'type' => $type, + 'widget' => new Widget(), + 'forms' => $contactForms + ]); + } + + /** + * Display form for editing already existing widget + * + * @param Widget $widget + * + * @return mixed + */ + public static function renderEditForm(Widget $widget) + { + $contactForms = Content::where('moduleHandler', config('contactform.handler')) + ->get(); + return view('contactform::admin.widgets.address.edit', [ + 'widget' => $widget, + 'forms' => $contactForms + ]); + } +} \ No newline at end of file diff --git a/Widgets/Form/Form.php b/Widgets/Form/Form.php new file mode 100755 index 0000000..cb30e07 --- /dev/null +++ b/Widgets/Form/Form.php @@ -0,0 +1,51 @@ + $data->contactFormId]; + } +} \ No newline at end of file diff --git a/Widgets/Form/Presenter.php b/Widgets/Form/Presenter.php new file mode 100755 index 0000000..b4859ed --- /dev/null +++ b/Widgets/Form/Presenter.php @@ -0,0 +1,73 @@ +settings->contactFormId); + + if (!$form) { + return null; + } + + return view(self::$template, ['widget' => $widget, 'form' => $form]); + } + + /** + * Display form for creating new instance of widget + * + * @param WidgetType $type + * + * @return mixed + */ + public static function renderAddForm(WidgetType $type) + { + $contactForms = Content::where('moduleHandler', config('contactform.handler')) + ->get(); + + return view('contactform::admin.widgets.form.new', [ + 'type' => $type, + 'widget' => new Widget(), + 'forms' => $contactForms + ]); + } + + /** + * Display form for editing already existing widget + * + * @param Widget $widget + * + * @return mixed + */ + public static function renderEditForm(Widget $widget) + { + $contactForms = Content::where('moduleHandler', config('contactform.handler')) + ->get(); + return view('contactform::admin.widgets.address.edit', [ + 'widget' => $widget, + 'forms' => $contactForms + ]); + } +} \ No newline at end of file diff --git a/start.php b/start.php new file mode 100755 index 0000000..7be329c --- /dev/null +++ b/start.php @@ -0,0 +1,15 @@ +