FEATURE: add widget for social buttons
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Widgets\SocialButtons\Presenters;
|
||||||
|
|
||||||
|
use App\Models\Widgets\Widget;
|
||||||
|
use App\Models\Widgets\WidgetType;
|
||||||
|
use App\Models\Settings as SettingsModel;
|
||||||
|
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
||||||
|
use App\CMS\Widgets\SocialButtons\Presenters\Route;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Blog\Article\Entities\Article as ArticleModel;
|
||||||
|
use Modules\Blog\Article\Handlers\Article;
|
||||||
|
|
||||||
|
class SocialButtons 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)
|
||||||
|
{
|
||||||
|
return view('visitor.widgets.shareButtons.all', compact('widget'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display form for creating new instance of widget
|
||||||
|
*
|
||||||
|
* @param WidgetType $type
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function renderAddForm(WidgetType $type)
|
||||||
|
{
|
||||||
|
return view('admin.widgets.socialButtons.new', [
|
||||||
|
'type' => $type,
|
||||||
|
'widget' => new Widget(),
|
||||||
|
'settings' => new \stdClass()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display form for editing already existing widget
|
||||||
|
*
|
||||||
|
* @param Widget $widget
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function renderEditForm(Widget $widget)
|
||||||
|
{
|
||||||
|
$settings = $widget->settings;
|
||||||
|
return view('admin.widgets.socialButtons.edit', ['widget' => $widget, 'settings' => $settings]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Widgets\SocialButtons;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Widgets\PublicWidget;
|
||||||
|
use App\CMS\Widgets\Exceptions\MissingParameterException;
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Widgets\Widget;
|
||||||
|
|
||||||
|
class SocialButtons implements PublicWidget
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name getter
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getName()
|
||||||
|
{
|
||||||
|
return 'widgets/socialButtons.widgetName';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for description
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDescription()
|
||||||
|
{
|
||||||
|
return 'widgets/socialButtons.widgetDescription';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for presenter/renderer of this widget
|
||||||
|
*
|
||||||
|
* @return WidgetRenderer
|
||||||
|
*/
|
||||||
|
public static function getPresenter()
|
||||||
|
{
|
||||||
|
return Presenters\SocialButtons::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws MissingParameterException
|
||||||
|
*/
|
||||||
|
public static function save(Request $data)
|
||||||
|
{
|
||||||
|
//if (!isset($data->code) || empty($data->code)) {
|
||||||
|
// throw new MissingParameterException('code');
|
||||||
|
//}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
@extends('admin.layoutWithNavigation')
|
||||||
|
|
||||||
|
@section('pageHeading', @trans('widgets/socialButtons.edit', ['name' => $widget->name]))
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="col-lg-8">
|
||||||
|
@include('admin.widgets.socialButtons.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])])
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<h3>@lang('widgets/socialButtons.preview')</h3>
|
||||||
|
|
||||||
|
@widgetPreview($widget)
|
||||||
|
</div>
|
||||||
|
@stop
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<form action="{{$action}}" method="POST">
|
||||||
|
@include('admin.widgets.snippets.commonForm')
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
@lang('widgets/socialButtons.save')
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
@extends('admin.layoutWithNavigation')
|
||||||
|
|
||||||
|
@section('pageHeading', @trans('widgets/socialButtons.new'))
|
||||||
|
@section('pageDescription', @trans($type->description))
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
@include('admin.widgets.socialButtons.form', ['action' => route('widgets.postNew', ['type' => $type])])
|
||||||
|
@stop
|
||||||
|
|
||||||
Reference in New Issue
Block a user