FEATURE: move contactform into own repository
This commit is contained in:
Executable
Executable
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => '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,
|
||||
];
|
||||
Executable
+152
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Handlers;
|
||||
|
||||
use App\CMS\Contracts\Content\AdvancedContentModifier;
|
||||
use App\CMS\Contracts\Content\ContentTitles;
|
||||
use App\CMS\Enumerations\ModulesHandlerToId;
|
||||
use App\CMS\Handlers\AdminHandler;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\User;
|
||||
|
||||
class ContactForm extends AdminHandler implements ContentTitles, AdvancedContentModifier
|
||||
{
|
||||
public static function getHistoryHandler()
|
||||
{
|
||||
return ContactFormHistory::class;
|
||||
}
|
||||
|
||||
public static function getModuleId()
|
||||
{
|
||||
$handler = config('contactform.handler');
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
||||
|
||||
return $moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for section names in creating/editing content resource
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getExtendedFormSections()
|
||||
{
|
||||
$sections = parent::getExtendedFormSections();
|
||||
$sections['content'] = trans('contactform::admin/content.content');
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for views used in extended part of form for creating new content
|
||||
*
|
||||
* This method should return pairs <section, view-name>. 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Handlers;
|
||||
|
||||
use App\CMS\Handlers\History;
|
||||
|
||||
class ContactFormHistory extends History
|
||||
{
|
||||
/**
|
||||
* Translate column name for history view
|
||||
*
|
||||
* @param $column
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function parseColumnName($column)
|
||||
{
|
||||
// try to translate as contact form field
|
||||
$translationString = 'contactform::admin/history.column' . ucfirst($column);
|
||||
$translation = trans($translationString);
|
||||
|
||||
// when translation is not available, try to fallback into core fields
|
||||
if ($translation == $translationString) {
|
||||
return parent::parseColumnName($column);
|
||||
}
|
||||
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Http\Controllers\Visitor;
|
||||
|
||||
use App\CMS\Helpers\Template;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Content\Content;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Modules\ContactForm\Http\Requests\SendNewEmailRequest;
|
||||
|
||||
class CreateNewMessage extends Controller
|
||||
{
|
||||
/**
|
||||
* Method for sending emails via contact form
|
||||
*
|
||||
* @param SendNewEmailRequest $request
|
||||
* @param $formId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function postMessage(SendNewEmailRequest $request, $formId)
|
||||
{
|
||||
// load form settings
|
||||
$form = Content::where('moduleHandler', config('contactform.handler'))
|
||||
->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');
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php namespace Modules\ContactForm\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SendNewEmailRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'message' => 'required',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
Route::group([
|
||||
'middleware' => ['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');
|
||||
});
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Pipeline\SavePipeline;
|
||||
|
||||
use App\CMS\Contracts\Content\SavePipeline\Process;
|
||||
use App\Models\Content\Content;
|
||||
use Modules\ContactForm\Handlers\ContactForm;
|
||||
|
||||
class SaveContactInformation implements Process
|
||||
{
|
||||
/**
|
||||
* Process and modify given page
|
||||
*
|
||||
* @param Content $page
|
||||
* @param array $input
|
||||
*
|
||||
* @return void>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php namespace Modules\ContactForm\Providers;
|
||||
|
||||
use App\CMS\Modules\ServiceProviders\ServiceProvider;
|
||||
use Modules\ContactForm\Handlers\ContactForm;
|
||||
use Modules\ContactForm\Pipeline\SavePipeline\SaveContactInformation;
|
||||
use Modules\ContactForm\Widgets\Address\Address;
|
||||
use Modules\ContactForm\Widgets\Form\Form;
|
||||
|
||||
class ContactFormServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
$this->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__;
|
||||
}
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
"contactForm" => "Kontaktní formulář",
|
||||
"emails" => "E-mailové šablony",
|
||||
"new" => "Nový",
|
||||
"overview" => "Všechny formuláře",
|
||||
"sentMessages" => "Zprávy",
|
||||
"templatePath" => "Kontaktní formulář",
|
||||
];
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
return [
|
||||
"address" => "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",
|
||||
];
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
return [
|
||||
"columnAddress" => "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",
|
||||
];
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
return [
|
||||
"address" => [
|
||||
"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ář",
|
||||
];
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
"allForms" => "Všechny formuláře",
|
||||
"description" => "Jednoduchý kontaktní formulář",
|
||||
"editForm" => "Upravuji formulář",
|
||||
"name" => "Kontaktní formulář",
|
||||
"newForm" => "Vytvořit nový kontaktní formulář",
|
||||
];
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'contactForm' => 'Contact form',
|
||||
'new' => 'New',
|
||||
'overview' => 'All contact forms',
|
||||
'sentMessages' => 'Messages',
|
||||
'templatePath' => 'Contact form',
|
||||
'emails' => 'E-mail templates',
|
||||
];
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
return [
|
||||
'content' => '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'
|
||||
];
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
return [
|
||||
'columnPhone' => 'Phone',
|
||||
'columnAddress' => 'Address',
|
||||
'columnEmail' => 'E-mail',
|
||||
'columnContactEmail' => 'Contact E-mail',
|
||||
'columnSubject' => 'Subject',
|
||||
'columnCompanyName' => 'Company name',
|
||||
'columnGpsLat' => 'GPS Latitude',
|
||||
'columnGpsLng' => 'Gps Longitude',
|
||||
];
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
return [
|
||||
'address' => [
|
||||
'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'
|
||||
];
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
'name' => 'Contact form',
|
||||
'description' => 'Simple contact form',
|
||||
'allForms' => 'All contact forms',
|
||||
'newForm' => 'Create new contact form',
|
||||
'editForm' => 'Editing contact form'
|
||||
];
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
"contactForm" => "Kontaktný formulár",
|
||||
"new" => "Nový",
|
||||
"overview" => "Všetky formuláre",
|
||||
"sentMessages" => "Správy",
|
||||
"templatePath" => "Kontaktný formulár",
|
||||
];
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
return [
|
||||
"address" => "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",
|
||||
];
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
return [
|
||||
"columnAddress" => "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",
|
||||
];
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
"description" => "Jednoduchý kontaktný formulár",
|
||||
"name" => "Kontaktný formulár",
|
||||
];
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<input type="text" name="title" required class="form-control slug-source"
|
||||
placeholder="@lang('admin/contents.field_title')"
|
||||
value="{{old('title', $page->title)}}" />
|
||||
|
||||
@include('admin.snippets.hasError', ['field' => 'title'])
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
||||
<input type="text" name="url" required class="form-control slug-target"
|
||||
placeholder="@lang('admin/contents.field_url')"
|
||||
value="{{old('url', $page->url)}}" />
|
||||
|
||||
@include('admin.snippets.hasError', ['field' => 'url'])
|
||||
</div>
|
||||
<div class="col-lg-2 text-center">
|
||||
<div>
|
||||
<label class="label-control">
|
||||
<input class="checkbox" value="1" id="lockUrl"
|
||||
@if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked
|
||||
@endif name="lockUrl" type="checkbox">
|
||||
<span>@lang('admin/contents.lockUrl')</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<select class="form-control" name="status">
|
||||
@foreach($contentStatuses as $status => $translation)
|
||||
<option value="{{$status}}" @if(old('status', $page->status) == $status) selected @endif>
|
||||
{{$translation}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
@include('admin.snippets.hasError', ['field' => 'status'])
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<select class="form-control" name="parentPage">
|
||||
<option value="">@lang('admin/contents.noParentPage')</option>
|
||||
|
||||
@foreach($rootPages as $rootPage)
|
||||
<option value="{{$rootPage->id}}"
|
||||
@if(old('parent_page', $page->parent_id) == $rootPage->id) selected @endif>
|
||||
{{$rootPage->title}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
@include('admin.snippets.hasError', ['field' => 'parentPage'])
|
||||
</div>
|
||||
|
||||
@if($module->support_categories && count($categories))
|
||||
<div class="col-lg-12">
|
||||
<select class="form-control" name="categoryId">
|
||||
<option value="">@lang('admin/contents.noCategory')</option>
|
||||
@foreach($categories as $category)
|
||||
<option value="{{$category->id}}"
|
||||
@if($category->id == old('categoryId', $page->categoryId)) selected @endif>
|
||||
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<h2>@lang('contactform::admin/content.contactInformation')</h2>
|
||||
|
||||
<div class="row">
|
||||
<div class="column col-lg-6">
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.email')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="email" name="email" value="{{$page->moduleSettings['email'] or ''}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.phone')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="tel" name="phone" value="{{$page->moduleSettings['phone'] or ''}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.compName')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="companyName"
|
||||
value="{{$page->moduleSettings['companyName'] or ''}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.address')
|
||||
</label>
|
||||
|
||||
<textarea rows="3" class="form-control" name="address">{{$page->moduleSettings['address'] or ''}}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="column col-lg-6">
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.contactEmail')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="email" name="contactEmail"
|
||||
value="{{$page->moduleSettings['contactEmail'] or \Auth::user()->email}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.subject')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="subject"
|
||||
value="{{$page->moduleSettings['subject'] or trans('contactform::admin/content.defaultSubject')}}" />
|
||||
|
||||
<div class="row">
|
||||
<div class="column col-lg-6">
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.gpsLat')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" value="{{$page->moduleSettings['gpsLat'] or ''}}"
|
||||
name="gpsLat" />
|
||||
</div>
|
||||
<div class="column col-lg-6">
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.gpsLng')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" value="{{$page->moduleSettings['gpsLng'] or ''}}"
|
||||
name="gpsLng" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
|
||||
{{old('pageContent', $page->content)}}
|
||||
</textarea>
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
@extends('admin.layoutWithNavigation')
|
||||
|
||||
@section('pageHeading', @trans('contactform::admin/widgets.address.edit'))
|
||||
@section('pageDescription', $widget->description)
|
||||
|
||||
@section('content')
|
||||
|
||||
@if(!count($forms))
|
||||
<div class="alert alert-warning">@lang('contactform::admin/widgets.noContactForms')</div>
|
||||
@else
|
||||
<div class="col-md-10">
|
||||
@include('contactform::admin.widgets.address.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])])
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
@widgetPreview($widget)
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<form action="{{$action}}" method="POST">
|
||||
@include('admin.widgets.snippets.commonForm')
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/widgets.selectContactForm')
|
||||
</label>
|
||||
|
||||
<select class="form-control" name="contactFormId">
|
||||
@foreach($forms as $form)
|
||||
<option @if(old('contactFormId', isset($widget->settings->contactFormId) ? $widget->settings->contactFormId : '') == $form->id) selected @endif value="{{$form->id}}">{{$form->title}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@lang('widgets/htmlCode.save')
|
||||
</button>
|
||||
</form>
|
||||
+14
@@ -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))
|
||||
<div class="alert alert-warning">@lang('contactform::admin/widgets.noContactForms')</div>
|
||||
@else
|
||||
@include('contactform::admin.widgets.address.form', ['action' => route('widgets.postNew', ['type' => $type])])
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
@extends('admin.layoutWithNavigation')
|
||||
|
||||
@section('pageHeading', @trans('contactform::admin/widgets.address.edit'))
|
||||
@section('pageDescription', $widget->description)
|
||||
|
||||
@section('content')
|
||||
|
||||
@if(!count($forms))
|
||||
<div class="alert alert-warning">@lang('contactform::admin/widgets.noContactForms')</div>
|
||||
@else
|
||||
<div class="col-md-8">
|
||||
@include('contactform::admin.widgets.form.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])])
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
@widgetPreview($widget)
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<form action="{{$action}}" method="POST">
|
||||
@include('admin.widgets.snippets.commonForm')
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/widgets.selectContactForm')
|
||||
</label>
|
||||
|
||||
<select class="form-control" name="contactFormId">
|
||||
@foreach($forms as $form)
|
||||
<option @if(old('contactFormId', isset($widget->settings->contactFormId) ? $widget->settings->contactFormId : '') == $form->id) selected @endif value="{{$form->id}}">{{$form->title}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@lang('widgets/htmlCode.save')
|
||||
</button>
|
||||
</form>
|
||||
+14
@@ -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))
|
||||
<div class="alert alert-warning">@lang('contactform::admin/widgets.noContactForms')</div>
|
||||
@else
|
||||
@include('contactform::admin.widgets.form.form', ['action' => route('widgets.postNew', ['type' => $type])])
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Widgets\Address;
|
||||
|
||||
use App\CMS\Contracts\Widgets\PublicWidget;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Widgets\Widget;
|
||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||
|
||||
class Address implements PublicWidget
|
||||
{
|
||||
/**
|
||||
* Name getter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'contactform::admin/widgets.address.name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription()
|
||||
{
|
||||
return 'contactform::admin/widgets.address.description';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for presenter/renderer of this widget
|
||||
*
|
||||
* @return WidgetRenderer
|
||||
*/
|
||||
public static function getPresenter()
|
||||
{
|
||||
return Presenter::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Widget $widget
|
||||
* @param \stdClass $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function save(Request $data)
|
||||
{
|
||||
return ['contactFormId' => $data->contactFormId];
|
||||
}
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Widgets\Address;
|
||||
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Widgets\Widget;
|
||||
use App\Models\Widgets\WidgetType;
|
||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||
|
||||
class Presenter implements WidgetRenderer
|
||||
{
|
||||
/**
|
||||
* Method used for displaying widget.
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function render(Widget $widget)
|
||||
{
|
||||
$form = Content::find($widget->settings->contactFormId);
|
||||
|
||||
if (!$form)
|
||||
return null;
|
||||
|
||||
$formData = $form->moduleSettings;
|
||||
|
||||
$code = '<div class="address-widget ' . e($widget->container_class) . '"';
|
||||
if ($widget->container_id) {
|
||||
$code .= ' id="' . e($widget->container_id).'"';
|
||||
}
|
||||
$code .= '>';
|
||||
$code .= "<p class='name'>".e($formData['companyName']).'</p>';
|
||||
$code .= nl2br($formData['address']);
|
||||
$code .= "</div>";
|
||||
|
||||
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
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Widgets\Form;
|
||||
|
||||
use App\CMS\Contracts\Widgets\PublicWidget;
|
||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Widgets\Widget;
|
||||
|
||||
class Form implements PublicWidget
|
||||
{
|
||||
/**
|
||||
* Name getter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'contactform::admin/widgets.form.name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription()
|
||||
{
|
||||
return 'contactform::admin/widgets.form.description';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for presenter/renderer of this widget
|
||||
*
|
||||
* @return WidgetRenderer
|
||||
*/
|
||||
public static function getPresenter()
|
||||
{
|
||||
return Presenter::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Widget $widget
|
||||
* @param \stdClass $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function save(Request $data)
|
||||
{
|
||||
return ['contactFormId' => $data->contactFormId];
|
||||
}
|
||||
}
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Widgets\Form;
|
||||
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Widgets\Widget;
|
||||
use App\Models\Widgets\WidgetType;
|
||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||
|
||||
class Presenter implements WidgetRenderer
|
||||
{
|
||||
public static $template = null;
|
||||
|
||||
/**
|
||||
* Method used for displaying widget.
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public static function render(Widget $widget)
|
||||
{
|
||||
if (!self::$template) {
|
||||
throw new \ErrorException('Cannot render contact form without template! Please, set Presenter::$template variable before rendering.');
|
||||
}
|
||||
|
||||
$form = Content::find($widget->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
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Namespaces And Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When a module starting, this file will executed automatically. This helps
|
||||
| to register some namespaces like translator or view. Also this file
|
||||
| will load the routes file for each module. You may also modify
|
||||
| this file as you want.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__ . '/Http/routes.php';
|
||||
Reference in New Issue
Block a user