Merge branch 'dev' into binarity.cz
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PublishTemplateResources extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'template:publish';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Publish assets and views for currently set template';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->call('vendor:publish', ['--tag' => 'module-views', '--force' => true]);
|
||||
$this->call('vendor:publish', ['--tag' => 'public-assets', '--force' => true]);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Commands\AddLanguage;
|
||||
use App\Console\Commands\PublishTemplateResources;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -22,7 +22,8 @@ class Kernel extends ConsoleKernel
|
||||
Commands\TranslateAll::class,
|
||||
Commands\InitDatabaseSchema::class,
|
||||
Commands\SetTemplate::class,
|
||||
AddLanguage::class
|
||||
Commands\AddLanguage::class,
|
||||
PublishTemplateResources::class
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
+45
-17
@@ -9,6 +9,46 @@ class WidgetAreas
|
||||
* @var array list of inicialized widget areas
|
||||
*/
|
||||
protected static $widgetAreas = [];
|
||||
protected static $initialized = false;
|
||||
|
||||
protected static function saveRenderedWidgetArea($widgets)
|
||||
{
|
||||
foreach ($widgets as $widget) {
|
||||
if (!isset(self::$widgetAreas[$widget->widget_area_code]))
|
||||
self::$widgetAreas[$widget->widget_area_code] = '';
|
||||
|
||||
$handler = $widget->widget_type_handler;
|
||||
$widget->settings = json_decode($widget->settings);
|
||||
$presenter = call_user_func([$handler, 'getPresenter']);
|
||||
|
||||
self::$widgetAreas[$widget->widget_area_code] .= call_user_func([$presenter, 'render'], $widget);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function loadWidgetArea($uniqueCode)
|
||||
{
|
||||
$widgetArea = new WidgetArea();
|
||||
$widgets = $widgetArea->getWidgets($uniqueCode)
|
||||
->get();
|
||||
|
||||
WidgetArea::where('code', $uniqueCode)
|
||||
->increment('viewed');
|
||||
|
||||
self::saveRenderedWidgetArea($widgets);
|
||||
}
|
||||
|
||||
protected static function initWidgetAreas()
|
||||
{
|
||||
if (self::$initialized)
|
||||
return;
|
||||
|
||||
$widgetArea = new WidgetArea();
|
||||
$widgets = $widgetArea->getWidgets()
|
||||
->get();
|
||||
|
||||
self::saveRenderedWidgetArea($widgets);
|
||||
self::$initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderer for whole widget area.
|
||||
@@ -19,26 +59,14 @@ class WidgetAreas
|
||||
*/
|
||||
public static function render($uniqueCode)
|
||||
{
|
||||
if (isset(self::$widgetAreas[$uniqueCode])) {
|
||||
echo self::$widgetAreas[$uniqueCode];
|
||||
return;
|
||||
if (!self::$initialized) {
|
||||
self::initWidgetAreas();
|
||||
}
|
||||
|
||||
$widgetArea = new WidgetArea();
|
||||
$widgets = $widgetArea->getWidgets($uniqueCode)
|
||||
->get();
|
||||
|
||||
$content = '';
|
||||
foreach ($widgets as $widget) {
|
||||
$handler = $widget->widget_type_handler;
|
||||
$presenter = call_user_func([$handler, 'getPresenter']);
|
||||
|
||||
$content .= call_user_func([$presenter, 'render'], json_decode($widget->settings));
|
||||
if (!isset(self::$widgetAreas[$uniqueCode])) {
|
||||
self::loadWidgetArea($uniqueCode);
|
||||
}
|
||||
|
||||
// cache this widget area
|
||||
self::$widgetAreas[$uniqueCode] = $content;
|
||||
|
||||
echo $content;
|
||||
echo self::$widgetAreas[$uniqueCode];
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ class EditWidgetArea extends Controller
|
||||
$area->name = $request->name;
|
||||
$area->description = $request->description;
|
||||
|
||||
$area->timestamps = true;
|
||||
$area->save();
|
||||
|
||||
// fire event with new widget area
|
||||
|
||||
@@ -12,7 +12,8 @@ class EditWidgetRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required'
|
||||
'name' => 'required',
|
||||
'containerId' => 'unique:widgets,container_id,'.$this->containerId
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ class NewWidgetRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required'
|
||||
'name' => 'required',
|
||||
'containerId' => 'unique:widgets,container_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class Widget extends Model
|
||||
'settings',
|
||||
'language',
|
||||
'description',
|
||||
'viewed',
|
||||
'deletable'
|
||||
];
|
||||
protected $guarded = [];
|
||||
@@ -44,6 +45,8 @@ class Widget extends Model
|
||||
$widget->language = LaravelLocalization::getCurrentLocale();
|
||||
$widget->user_id = \Auth::user()->id;
|
||||
$widget->name = $data->name;
|
||||
$widget->container_class = $data->containerClass;
|
||||
$widget->container_id = $data->containerId;
|
||||
|
||||
// save description if available
|
||||
if (isset($data->description)) {
|
||||
|
||||
+14
-10
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
|
||||
/**
|
||||
@@ -11,7 +10,7 @@ use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
*/
|
||||
class WidgetArea extends Model
|
||||
{
|
||||
public $timestamps = true;
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
@@ -20,14 +19,19 @@ class WidgetArea extends Model
|
||||
];
|
||||
protected $guarded = [];
|
||||
|
||||
public function getWidgets($uniqueCode)
|
||||
public function getWidgets($uniqueCode = false)
|
||||
{
|
||||
return DB::table('widget_areas')
|
||||
->select('widget_areas.*', 'widgets.widget_type_handler', 'widgets.name as widget_name', 'widgets.settings')
|
||||
->where('code', $uniqueCode)
|
||||
->join('widget_in_widget_area', 'widget_in_widget_area.widget_area_id', '=', 'widget_areas.id')
|
||||
->join('widgets', 'widget_in_widget_area.widget_id', '=', 'widgets.id')
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->orderBy('widget_in_widget_area.position');
|
||||
$widgets = Widget::select('widgets.*', 'widgets.widget_type_handler', 'widget_areas.code as widget_area_code', 'widgets.name as widget_name', 'widgets.settings')
|
||||
->join('widget_in_widget_area', 'widget_in_widget_area.widget_id', '=', 'widgets.id')
|
||||
->join('widget_areas', 'widget_in_widget_area.widget_area_id', '=', 'widget_areas.id')
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->orderBy('widget_in_widget_area.position');
|
||||
if (!$uniqueCode) {
|
||||
$widgets = $widgets->where('widget_areas.viewed', '>=', setting('preloadFrequentedWidgetAreasTreshold', 10));
|
||||
} else {
|
||||
$widgets = $widgets->where('code', $uniqueCode);
|
||||
}
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
// register all available widgets
|
||||
$registrator->register(HtmlCode::class);
|
||||
$registrator->register(Menu::class);
|
||||
$registrator->register(OrbitSlider::class);
|
||||
// $registrator->register(OrbitSlider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Settings;
|
||||
use App\Shortcodes\Widget;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Webwizo\Shortcodes\Facades\Shortcode;
|
||||
|
||||
class GlobalViewDataProvider extends ServiceProvider
|
||||
{
|
||||
@@ -24,6 +26,8 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
view()->share('currentUrl', \Request::url());
|
||||
|
||||
$this->extendBlade();
|
||||
|
||||
Shortcode::register('widget', Widget::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,9 +133,11 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
<?php
|
||||
if ($2 instanceof \App\Models\Widget) {
|
||||
$handler = $2->widget_type_handler;
|
||||
$2->settings = json_decode($2->settings);
|
||||
|
||||
$presenter = call_user_func([$handler, "getPresenter"]);
|
||||
|
||||
echo call_user_func([$presenter, "render"], json_decode($2->settings));
|
||||
echo call_user_func([$presenter, "render"], $2);
|
||||
}
|
||||
?>
|
||||
';
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace App\Shortcodes;
|
||||
|
||||
use App\Models\Widget as WidgetModel;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
|
||||
class Widget
|
||||
{
|
||||
protected static $widgets = [];
|
||||
protected static $initialized = false;
|
||||
|
||||
protected function getRenderedWidget(WidgetModel $widget)
|
||||
{
|
||||
$widget->settings = json_decode($widget->settings);
|
||||
|
||||
$handler = $widget->widget_type_handler;
|
||||
$presenter = call_user_func([$handler, 'getPresenter']);
|
||||
|
||||
return call_user_func([$presenter, 'render'], $widget);
|
||||
}
|
||||
|
||||
protected function loadWidget($containerId)
|
||||
{
|
||||
$widget = WidgetModel::where('container_id', $containerId)
|
||||
->first();
|
||||
|
||||
if (!$widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
$widget->timestamps = false;
|
||||
$widget->viewed++;
|
||||
$widget->save();
|
||||
$widget->timestamps = true;
|
||||
|
||||
self::$widgets[$containerId] = $this->getRenderedWidget($widget);
|
||||
}
|
||||
|
||||
protected function initWidgets()
|
||||
{
|
||||
if (self::$initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
$widgets = WidgetModel::where('viewed', '>=', setting('preloadFrequentedWidgetsTreshold', 10))
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->get();
|
||||
|
||||
foreach ($widgets as $widget) {
|
||||
self::$widgets[$widget->container_id] = $this->getRenderedWidget($widget);
|
||||
}
|
||||
|
||||
self::$initialized = true;
|
||||
}
|
||||
|
||||
public function register($shortcode, $containerId, $compiler, $name)
|
||||
{
|
||||
$this->initWidgets();
|
||||
|
||||
if (!isset(self::$widgets[$containerId])) {
|
||||
$this->loadWidget($containerId);
|
||||
}
|
||||
|
||||
return self::$widgets[$containerId];
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ interface WidgetRenderer
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function render($settings);
|
||||
public static function render(Widget $settings);
|
||||
|
||||
/**
|
||||
* Display form for creating new instance of widget
|
||||
|
||||
@@ -12,14 +12,15 @@ class HtmlCode implements WidgetRenderer
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param object $settings
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function render($settings)
|
||||
public static function render(Widget $widget)
|
||||
{
|
||||
$settings = $widget->settings;
|
||||
$code = '
|
||||
<div class="html-code-widget ' . $settings->containerClass . '">
|
||||
<div class="html-code-widget ' . $widget->container_class . '">
|
||||
' . $settings->code . '
|
||||
</div>';
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@ class Menu implements WidgetRenderer
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param object $settings
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function render($settings)
|
||||
public static function render(Widget $widget)
|
||||
{
|
||||
$settings = $widget->settings;
|
||||
$links = (array)$settings->links;
|
||||
$pageIds = array_keys($links);
|
||||
|
||||
@@ -40,7 +41,12 @@ class Menu implements WidgetRenderer
|
||||
$parameters = Route::current()
|
||||
->parameters();
|
||||
|
||||
$code = '<ul class="menu ' . $settings->containerClass . '">';
|
||||
$code = '<ul class="menu ' . $widget->container_class . '"';
|
||||
|
||||
if ($widget->container_id)
|
||||
$code .= ' id="'.e($widget->container_id).'"';
|
||||
|
||||
$code .= '>';
|
||||
|
||||
foreach ($links as $pageId => $link) {
|
||||
if (!isset($pages[$pageId])) {
|
||||
|
||||
@@ -26,12 +26,13 @@ class OrbitSlider implements WidgetRenderer
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param object $settings
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function render($settings)
|
||||
public static function render(Widget $widget)
|
||||
{
|
||||
$settings = $widget->settings;
|
||||
$directoryId = $settings->directoryId;
|
||||
|
||||
$images = File::where('directory_id', $directoryId)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddUniqueCodeToWidgets extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->string('container_id')
|
||||
->nullable(true)
|
||||
->default(null)
|
||||
->after('name');
|
||||
$table->string('container_class')
|
||||
->nullable(true)
|
||||
->after('name')
|
||||
->default(null);
|
||||
|
||||
$table->unique(['language', 'container_id']);
|
||||
});
|
||||
|
||||
// migrate data
|
||||
$widgets = \App\Models\Widget::all();
|
||||
foreach ($widgets as $widget) {
|
||||
$widget->settings = json_decode($widget->settings);
|
||||
if (isset($widget->settings->containerClass)) {
|
||||
$widget->container_class = $widget->settings->containerClass;
|
||||
unset($widget->settings->containerClass);
|
||||
$widget->settings = json_encode($widget->settings);
|
||||
$widget->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->dropUnique('widgets_language_container_id_unique');
|
||||
});
|
||||
|
||||
// migrate data
|
||||
$widgets = \App\Models\Widget::all();
|
||||
foreach ($widgets as $widget) {
|
||||
$widget->settings = (object)json_decode($widget->settings);
|
||||
$widget->settings->containerClass = $widget->container_class;
|
||||
$widget->settings = json_encode($widget->settings);
|
||||
$widget->save();
|
||||
}
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->dropColumn('container_id');
|
||||
$table->dropColumn('container_class');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddNumberOfViewsToWidgets extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->integer('viewed')->comment('How many times was this widget displayed using shortcode?');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->dropColumn('viewed');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddNumberOfViewsToWidgetAreas extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('widget_areas', function (Blueprint $table) {
|
||||
$table->integer('viewed')->comment('How many times was this widget area rendered?');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('widget_areas', function (Blueprint $table) {
|
||||
$table->dropColumn('viewed');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
return [
|
||||
'new' => 'Create new HTML widget',
|
||||
'edit' => 'Editing widget :name',
|
||||
'containerClass' => 'HTML class used for container of this widget',
|
||||
'widgetDescription' => 'Simple widget for inserting html code',
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'containerId' => 'Unique name used as ID of widget'
|
||||
];
|
||||
@@ -1,25 +1,5 @@
|
||||
<form action="{{$action}}" method="POST">
|
||||
{!! csrf_field() !!}
|
||||
<label class="label-control">
|
||||
@lang('widgets/htmlCode.name')
|
||||
</label>
|
||||
<input class="form-control" type="text" name="name" value="{{old('name', $widget->name)}}"
|
||||
placeholder="@lang('widgets/htmlCode.name')" />
|
||||
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/htmlCode.description')
|
||||
</label>
|
||||
<input class="form-control" type="text" name="description" placeholder="@lang('widgets/htmlCode.description')"
|
||||
value="{{old('description', $widget->description)}}" />
|
||||
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/htmlCode.containerClass')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="containerClass" placeholder="@lang('widgets/htmlCode.containerClass')"
|
||||
value="{{old('containerClass', isset($settings->containerClass) ? $settings->containerClass : '')}}" />
|
||||
@include('admin.widgets.snippets.commonForm')
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/htmlCode.code')
|
||||
|
||||
@@ -1,28 +1,7 @@
|
||||
<form action="{{$formAction}}" id="widget-menu" method="POST">
|
||||
{!! csrf_field() !!}
|
||||
<input type="hidden" name="settings" id="widgetSettings" value="{{json_encode($widget->settingsObj->links)}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/menu.name')
|
||||
</label>
|
||||
<input class="form-control" required type="text" name="name" value="{{old("name", $widget->name)}}"
|
||||
placeholder="@lang('widgets/menu.name')" />
|
||||
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/menu.description')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="description" placeholder="@lang('widgets/menu.description')"
|
||||
value="{{old("description", $widget->description)}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/menu.containerClass')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="containerClass" placeholder="@lang('widgets/menu.containerClass')"
|
||||
value="{{old("containerClass", isset($widget->settingsObj->containerClass) ? $widget->settingsObj->containerClass : '')}}" />
|
||||
|
||||
@include('admin.widgets.snippets.commonForm')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{!! csrf_field() !!}
|
||||
<label class="label-control">
|
||||
@lang('widgets/common.name')
|
||||
</label>
|
||||
<input class="form-control" type="text" name="name" value="{{old('name', $widget->name)}}"
|
||||
placeholder="@lang('widgets/common.name')" />
|
||||
|
||||
|
||||
<label class="label-control">
|
||||
@lang('widgets/common.description')
|
||||
</label>
|
||||
<input class="form-control" type="text" name="description" placeholder="@lang('widgets/common.description')"
|
||||
value="{{old('description', $widget->description)}}" />
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6"><label class="label-control">
|
||||
@lang('widgets/common.containerClass')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="containerClass" placeholder="@lang('widgets/common.containerClass')"
|
||||
value="{{old('containerClass', $widget->container_class)}}" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="label-control">
|
||||
@lang('widgets/common.containerId')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="containerId" placeholder="@lang('widgets/common.containerId')"
|
||||
value="{{old('containerId', $widget->container_id)}}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
@section('content')
|
||||
<div class="col-lg-8">
|
||||
@include('admin.widgets.htmlCode.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])])
|
||||
@include('template::admin.widgets.onePageMenu.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])])
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<h3>@lang('widgets/htmlCode.preview')</h3>
|
||||
<h3>@lang('widgets/menu.preview')</h3>
|
||||
|
||||
@widgetPreview($widget)
|
||||
</div>
|
||||
|
||||
@@ -46,9 +46,7 @@ class OnePageMenu extends NonInstallableWidget
|
||||
*/
|
||||
public static function save(Widget $widget, stdClass $data)
|
||||
{
|
||||
$widgetSettings = ['containerClass' => isset($data->containerClass) ? $data->containerClass : ''];
|
||||
|
||||
$widget->settings = json_encode($widgetSettings);
|
||||
$widget->settings = json_encode([]);
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ class Presenter implements WidgetRenderer
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param object $settings
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public static function render($settings)
|
||||
public static function render(Widget $widget)
|
||||
{
|
||||
if (!self::$template) {
|
||||
throw new \ErrorException('Cannot render menu without template! Please, set Presenter::$template variable before rendering.');
|
||||
@@ -31,7 +31,7 @@ class Presenter implements WidgetRenderer
|
||||
|
||||
$pages = OnePage::getPagesOnHomepage();
|
||||
|
||||
return view(self::$template, ['pages' => $pages])->render();
|
||||
return view(self::$template, ['pages' => $pages, 'widget' => $widget])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="cs">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
@@ -43,44 +43,12 @@
|
||||
<footer class="page-footer grey lighten-2">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col l6 s12">
|
||||
<form class="col s12">
|
||||
<h5>Kontaktujte nás</h5>
|
||||
<div class="input-field s12">
|
||||
<input id="email" type="email" class="validate">
|
||||
<label for="email">Váš e-mail</label>
|
||||
</div>
|
||||
<div class="input-field s12">
|
||||
<textarea id="message" class="materialize-textarea validate"></textarea>
|
||||
<label for="message">Textarea</label>
|
||||
</div>
|
||||
<button class="btn orange waves-effect waves-light" type="submit" name="action">Submit
|
||||
<i class="material-icons right">send</i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col l3 s12">
|
||||
<h5>Menu</h5>
|
||||
<ul class="">
|
||||
<li><a href="#!">O nás</a></li>
|
||||
<li><a href="#">Novinky</a></li>
|
||||
<li><a href="#">Akce</a></li>
|
||||
<li><a href="#">Kontakt</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col l3 s12">
|
||||
<h5>Firma</h5>
|
||||
<span>Dobroty z pece</span>
|
||||
<span>ICO</span>
|
||||
<span>Adresa</span>
|
||||
<span>email@dobrotyzpece.cz</span>
|
||||
<p>www.dobrotyzpece.cz</p>
|
||||
</div>
|
||||
@widgetArea('footer')
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-copyright">
|
||||
<div class="container grey-text">
|
||||
Copyright © <a class="amber-text text-darken-3" href="https://www.binarity.cz/">www.binarity.cz</a>
|
||||
© {{date('Y')}} <a class="amber-text text-darken-3" href="https://www.binarity.cz/">www.binarity.cz</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user