Merge branch 'dev' into binarity.cz
This commit is contained in:
@@ -35,7 +35,9 @@ class PageRenderer
|
|||||||
// get handler
|
// get handler
|
||||||
$handler = new $page->module_handler;
|
$handler = new $page->module_handler;
|
||||||
|
|
||||||
|
$page->content = Shortcode::compile($page->content);
|
||||||
|
|
||||||
// render page
|
// render page
|
||||||
return Shortcode::compile($handler->render($page, $parameters));
|
return $handler->render($page, $parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-14
@@ -38,7 +38,7 @@ class Content extends Model
|
|||||||
'status'
|
'status'
|
||||||
];
|
];
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
protected $subpages = [];
|
protected $foundSubpages = [];
|
||||||
protected $subpagesInit = false;
|
protected $subpagesInit = false;
|
||||||
const STATUS_DRAFT = 'draft';
|
const STATUS_DRAFT = 'draft';
|
||||||
const STATUS_PROTECTED = 'protected';
|
const STATUS_PROTECTED = 'protected';
|
||||||
@@ -60,7 +60,11 @@ class Content extends Model
|
|||||||
*/
|
*/
|
||||||
public function getPageQuery()
|
public function getPageQuery()
|
||||||
{
|
{
|
||||||
return Content::where('status', '!=', Content::STATUS_DRAFT);
|
return Content::where('status', '!=', Content::STATUS_DRAFT)
|
||||||
|
->select('contents.*')
|
||||||
|
->join('modules', 'modules.handler', '=', 'contents.module_handler')
|
||||||
|
->where('language', LaravelLocalization::getCurrentLocale())
|
||||||
|
->where('modules.enabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,7 +74,6 @@ class Content extends Model
|
|||||||
public function getHomepage()
|
public function getHomepage()
|
||||||
{
|
{
|
||||||
return $this->getPageQuery()
|
return $this->getPageQuery()
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->where('is_homepage', 1)
|
->where('is_homepage', 1)
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
@@ -86,32 +89,39 @@ class Content extends Model
|
|||||||
{
|
{
|
||||||
return $this->getPageQuery()
|
return $this->getPageQuery()
|
||||||
->where('url', $url)
|
->where('url', $url)
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of all subpages
|
* Get list of all subpages
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
* @param bool $orderBy
|
||||||
|
* @param bool $orderDirection
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function subpages()
|
public function subpages($orderBy = false, $orderDirection = false)
|
||||||
{
|
{
|
||||||
if (!$this->subpagesInit) {
|
if (!$this->subpagesInit) {
|
||||||
$this->subpages = $this->getPageQuery()
|
$subpages = $this->getPageQuery()
|
||||||
->where('parent_id', $this->id)
|
->where('contents.parent_id', $this->id);
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->get();
|
if ($orderBy) {
|
||||||
|
$subpages->orderBy($orderBy, $orderDirection ? $orderDirection : 'ASC');
|
||||||
|
}
|
||||||
|
|
||||||
|
$subpages = $subpages->get();
|
||||||
|
|
||||||
// convert JSON settings into stdClass
|
// convert JSON settings into stdClass
|
||||||
foreach ($this->subpages as $subpage) {
|
foreach ($subpages as $i => $subpage) {
|
||||||
$subpage->module_settings = json_decode($subpage->module_settings);
|
$subpages[$i]->module_settings = json_decode($subpage->module_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->subpagesInit = true;
|
$this->subpagesInit = true;
|
||||||
|
$this->foundSubpages = $subpages;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->subpages;
|
return $this->foundSubpages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +172,6 @@ class Content extends Model
|
|||||||
public function rootPages()
|
public function rootPages()
|
||||||
{
|
{
|
||||||
$rootPages = $this->getPageQuery()
|
$rootPages = $this->getPageQuery()
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->where('parent_id', null);
|
->where('parent_id', null);
|
||||||
|
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input class="form-control" type="text" name="containerClass" placeholder="@lang('widgets/menu.containerClass')"
|
<input class="form-control" type="text" name="containerClass" placeholder="@lang('widgets/menu.containerClass')"
|
||||||
value="{{old("containerClass")}}" />
|
value="{{old("containerClass", $widget->settingsObj->containerClass)}}" />
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<div id="menu-items-container">
|
<div id="menu-items-container">
|
||||||
@foreach($widget->settingsObj->links as $pageId => $details)
|
@foreach($widget->settingsObj->links as $pageId => $details)
|
||||||
<span class="btn btn-sm btn-info" data-page-id="{{$pageId}}"
|
<span class="added-menu-item btn btn-sm btn-info" data-page-id="{{$pageId}}"
|
||||||
id="item-{{$pageId}}">{{$details->text}}</span>
|
id="item-{{$pageId}}">{{$details->text}}</span>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
@@ -78,6 +78,20 @@
|
|||||||
$ ('#widgetSettings').val (JSON.stringify (items));
|
$ ('#widgetSettings').val (JSON.stringify (items));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function bindRemovingItems() {
|
||||||
|
$ ('.added-menu-item').click (function () {
|
||||||
|
var id = $ (this).data ('page-id');
|
||||||
|
var elem = $ ('#page-' + id);
|
||||||
|
|
||||||
|
if (elem.length != 0)
|
||||||
|
elem.click ();
|
||||||
|
else
|
||||||
|
$ (this).remove ();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bindRemovingItems();
|
||||||
|
|
||||||
$ ('.menu-item').click (function () {
|
$ ('.menu-item').click (function () {
|
||||||
var url = $ (this).data ('page-url');
|
var url = $ (this).data ('page-url');
|
||||||
var text = $ (this).text ();
|
var text = $ (this).text ();
|
||||||
@@ -91,9 +105,10 @@
|
|||||||
$ (this).removeClass ('btn-secondary')
|
$ (this).removeClass ('btn-secondary')
|
||||||
} else {
|
} else {
|
||||||
// add
|
// add
|
||||||
$ ('#menu-items-container').append ('<span class="btn btn-sm btn-info" id="item-' + id + '" data-page-id="' + id + '">' + text + '</span> ');
|
$ ('#menu-items-container').append ('<span class="added-menu-item btn btn-sm btn-info" id="item-' + id + '" data-page-id="' + id + '">' + text + '</span> ');
|
||||||
$ (this).addClass ('btn-secondary');
|
$ (this).addClass ('btn-secondary');
|
||||||
$ (this).removeClass ('btn-info');
|
$ (this).removeClass ('btn-info');
|
||||||
|
bindRemovingItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
// distinguish between added and not-added page
|
// distinguish between added and not-added page
|
||||||
|
|||||||
Reference in New Issue
Block a user