FEATURE: move contactform into own repository
This commit is contained in:
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
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user