8 Commits
12 changed files with 315 additions and 145 deletions
+26 -13
View File
@@ -12,9 +12,10 @@ use Illuminate\Support\Facades\Route;
class Menu implements WidgetRenderer class Menu implements WidgetRenderer
{ {
public static $template = null;
/** /**
* Method used for displaying widget. * Method used for displaying widget.
*
* This method renders some HTML code for displaying. * This method renders some HTML code for displaying.
* *
* @param Widget $widget * @param Widget $widget
@@ -27,6 +28,11 @@ class Menu implements WidgetRenderer
$links = (array)$settings->links; $links = (array)$settings->links;
$pageIds = array_keys($links); $pageIds = array_keys($links);
if (!self::$template) {
throw new \Exception('neni nastavena sablona');
return;
}
// get pages // get pages
$pages = WidgetMenu::selectContentPages($pageIds); $pages = WidgetMenu::selectContentPages($pageIds);
@@ -40,14 +46,15 @@ class Menu implements WidgetRenderer
$parameters = Route::current() $parameters = Route::current()
->parameters(); ->parameters();
$code = '<ul class="menu ' . $widget->container_class . '"'; // $code = '<ul class="menu ' . $widget->container_class . '"';
if ($widget->container_id) { // if ($widget->container_id) {
$code .= ' id="' . e($widget->container_id) . '"'; // $code .= ' id="' . e($widget->container_id) . '"';
} // }
$code .= '>'; // $code .= '>';
$menuItems = [];
foreach ($links as $pageId => $link) { foreach ($links as $pageId => $link) {
if (!isset($pages[$pageId])) { if (!isset($pages[$pageId])) {
continue; continue;
@@ -57,16 +64,22 @@ class Menu implements WidgetRenderer
$active = ($page->isHomepage && $routeName == 'page.index') || ($routeName == 'page.content' && isset($parameters['url']) && $parameters['url'] == $page->url); $active = ($page->isHomepage && $routeName == 'page.index') || ($routeName == 'page.content' && isset($parameters['url']) && $parameters['url'] == $page->url);
$route = $page->isHomepage ? route('page.index') : route('page.content', ['url' => $page->url]); $route = $page->isHomepage ? route('page.index') : route('page.content', ['url' => $page->url]);
$code .= '<li'; $menuItems[] = compact('page', 'active', 'route');
if ($active) {
$code .= ' class="is-active active"'; // $code .= '<li';
} // if ($active) {
$code .= '><a href="' . $route . '">' . e($page->title) . '</a></li>'; // $code .= ' class="is-active active"';
} }
// $code .= '><a href="' . $route . '">' . e($page->title) . '</a></li>';
// }
$code .= "</ul>"; // $code .= "</ul>";
return $code; return view(self::$template, [
'containerClass' => $widget->container_class,
'containerId' => $widget->container_id,
'menuItems' => $menuItems
]);
} }
/** /**
@@ -35,7 +35,7 @@ class UploadedFilesOverview extends Controller
// include hidden directories? // include hidden directories?
$subdirectories = $this->directoryRepository->getAllSubdirectories($directory); $subdirectories = $this->directoryRepository->getAllSubdirectories($directory);
if (!Input::get('hidden', true)) { if (!Input::get('hidden', false)) {
$subdirectories = $subdirectories->where('hidden', false); $subdirectories = $subdirectories->where('hidden', false);
} }
+6 -6
View File
@@ -5136,12 +5136,6 @@
"integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=",
"dev": true "dev": true
}, },
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
},
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
@@ -5153,6 +5147,12 @@
"strip-ansi": "3.0.1" "strip-ansi": "3.0.1"
} }
}, },
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
},
"stringstream": { "stringstream": {
"version": "0.0.5", "version": "0.0.5",
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
@@ -0,0 +1,46 @@
<html>
<head>
<meta charset="utf-8">
<script src="multiselectcomponent.js"></script>
</head>
<body>
<div style="width: 50%; float: left;" id="left"></div>
<div style="width: 50%; float: right;" id="right"></div>
<script type="application/javascript">
// Sample data.
var data1 = [
{id: 1, name: 'Peter', surname: 'Hrdlica'},
{id: 6, name: 'Vojtěch', surname: 'Hrdlica'},
{id: 2, name: 'Michal', surname: 'Kváček'},
{id: 19, name: 'Miček', surname: 'Je kokot!'},
{id: 13, name: 'Mirek', surname: 'Mráček'},
{id: 11, name: 'Naděžda', surname: 'Zímová'}
];
var data2 = [
{id: 2, name: 'wanna', surname: 'know'},
{id: 6, name: 'Batman', surname: 'insulted'},
{id: 58, name: 'scream', surname: 'pushed'},
{id: 19, name: 'Mob', surname: 'why'},
{id: 63, name: 'eight', surname: 'begin'},
{id: 4, name: 'you', surname: 'emotions'}
];
data1.sort(function(a, b) { return a.id > b.id; }); // Sort by ID, lowest first.
data2.sort(function(a, b) { return a.id > b.id; }); // Sort by ID, lowest first.
// Js component instance
var mscL = new MultiSelectComponent('contacts', data1, 'id', function(item) { return item.name + ' ' + item.surname; });
var mscR = new MultiSelectComponent('users', data2, 'id', function(item) { return item.name + ' ' + item.surname; });
// Generated data added to template
var left = document.getElementById('left');
var right = document.getElementById('right');
left.innerHTML = mscL.createTemplate();
right.innerHTML = mscR.createTemplate();
// Initialization. May be done in more elegant way if the template is created ie. on server.
mscL.init();
mscR.init();
</script>
</body>
</html>
@@ -0,0 +1,121 @@
/**
* Multi-select component
*
* @param identifier Identifier parameter that makes each instance unique and is used in DOM datasets used by this component.
* @param data Data (array of objects)
* @param field Field parameter that will be send as list with form
* @param itemString String that should be shown as selector in select and a item label in item list
*/
function MultiSelectComponent(identifier, data, field, itemString) {
// Private variables
var selectBox, addButton, itemHolder;
/**
* This is the method that generates template for multiselect component.
* This method is easily rewriteable into PHP.
* It is necessary to keep html datasets with prefix data-ms- intact for the javascript component to work.
* ECMAScript 5 version, does not need any compilers, nor jQuery or other framework.
* This method is not required to stay inside the MultiSelectComponent and may be rendered in any way;
*
* identifier is inherited from the instance creation.
* data is inherited from the instance creation.
* field is inherited from the instance creation.
* itemString is inherited from the instance creation.
*
*/
function createTemplate () {
var html = '<select data-ms-select="'+identifier+'">';
for(var idx in data) {
if(data.hasOwnProperty(idx)) {
html += '<option value="'+data[idx][field]+'">'+itemString(data[idx])+'</value>' //createSelectOption(data[idx]);
}
}
return html += '</select><input type="button" data-ms-add="'+identifier+'" value="add"><div data-ms-list="'+identifier+'"></div>';
}
/**
* This method creates an item list item that works as visual representation of selected values.
*/
function createItemListItem (value) {
return html = '<span>'+itemString(getDataItem(value))+
' <span data-ms-remove="'+identifier+'" data-ms-value="'+value+'">x</span>'+
'<input style="display: none" type="checkbox" value="'+value+'" name="'+identifier+'[]" checked>'+
'</span>';
}
/**
* Returns a requested data item that matches <field> (class instance variable field) value of passed value.
*/
function getDataItem (value) {
for(var idx in data) {
if(data.hasOwnProperty(idx)){
if(data[idx][field] == value){
return data[idx];
}
}
}
}
/**
* By selecting an item, that item is removed from list of available items and is added to list of selected items.
* If no more items are available for adding, add button and selectbox are disabled and list gets an informative item.
*/
function selectItem (value) {
selectBox.removeChild(selectBox.querySelector('option[value="' + value + '"]'));
itemHolder.innerHTML += createItemListItem(value);
if(selectBox.children.length === 0) {
selectBox.options.add(new Option('no more items to add', 0));
addButton.setAttribute('disabled', 'disabled');
selectBox.setAttribute('disabled', 'disabled');
}
}
/**
* By deselecting (removing) an item, that item is removed from selected list and added again into select box of available items;
* If add button was disabled (mostly because of no selectable items in list) it and the selectbox are now re-enabled and informative item is removed.
*/
function deselectItem (element) {
var id = element.getAttribute('data-ms-value');
selectBox.options.add(new Option(itemString(getDataItem(id)), id));
itemHolder.removeChild(element.parentNode);
if(addButton.getAttribute('disabled')) {
selectBox.options.remove(0);
addButton.removeAttribute('disabled');
selectBox.removeAttribute('disabled');
}
}
/**
* Initializes javascript part of the component.
*/
function init () {
// Cached elements only for JS to be a little more optimized.
selectBox = document.querySelector('[data-ms-select="'+identifier+'"]');
addButton = document.querySelector('[data-ms-add="'+identifier+'"]');
itemHolder = document.querySelector('[data-ms-list="'+identifier+'"]');
// Add button
addButton.addEventListener('click', function() {
selectItem(selectBox.value);
});
// Remove item button
itemHolder.addEventListener('click', function(e) {
if(e.target.getAttribute('data-ms-remove')) {
deselectItem(e.target);
}
})
}
// Publicly exposed static methods and variables.
return {
init: init,
createTemplate: createTemplate
};
}
@@ -49,11 +49,6 @@
********************************************** */ ********************************************** */
.item-list { .item-list {
.subpage {
padding-left: 35px;
}
.thumbnail { .thumbnail {
width: 100%; width: 100%;
height: 80px; height: 80px;
+4
View File
@@ -16,6 +16,10 @@ body {
overflow-x: hidden; overflow-x: hidden;
} }
.p-l-25 {
padding-left: 25px;
}
.main-wrapper { .main-wrapper {
width: 100%; width: 100%;
position: absolute; position: absolute;
@@ -1,139 +1,129 @@
<div data-id="{{$page->id}}" class="row p-tb-15 parent-page-{{$page->parentId or 'none'}} {{$extraClass or ''}}"> <div class="{{$page->parentId ? 'p-l-25' : ''}}">
<div class="col-md-1 hidden-sm-down text-center with-placeholder"> <div data-id="{{$page->id}}" class="row p-tb-15 parent-page-{{$page->parentId or 'none'}} {{$extraClass or ''}}">
@can('update', $page) <div class="col-md-1 hidden-sm-down text-center with-placeholder">
<a href="{{route('content.edit', ['page' => $page])}}"> @can('update', $page)
@if(!view()->exists(template_name($page->template, false))) <a href="{{route('content.edit', ['page' => $page])}}">
<i class="fa fa-2x text-warning fa-warning" data-toggle="tooltip" @if(!view()->exists(template_name($page->template, false)))
title="@lang('admin/contents.invalidTemplateSelected')"></i> <i class="fa fa-2x text-warning fa-warning" data-toggle="tooltip" title="@lang('admin/contents.invalidTemplateSelected')"></i>
@else
@if(!empty($page->titlePhoto))
<div class="thumbnail" style="background-image: url(@thumbnail($page->titlePhoto))"></div>
@else @else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" @if(!empty($page->titlePhoto))
class="placeholder" <div class="thumbnail" style="background-image: url(@thumbnail($page->titlePhoto))"></div>
alt="{{$page->title}}" /> @else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" class="placeholder" alt="{{$page->title}}" />
@endif
@endif @endif
</a>
@else
@if(!empty($page->titlePhoto))
<img src="@thumbnail($page->titlePhoto)" class="placeholder" alt="{{$page->title}}" />
@endif @endif
</a> @endcan
@else </div>
@if(!empty($page->titlePhoto)) <div class="col-xs-10 col-md-3 col-lg-4">
<img src="@thumbnail($page->titlePhoto)" class="placeholder" @can('update', $page)
alt="{{$page->title}}" /> <a href="{{route('content.edit', ['page' => $page])}}">
@endif {{$page->title}}
@endcan </a>
</div> @else
<div class="col-xs-10 col-md-3 col-lg-4">
@can('update', $page)
<a href="{{route('content.edit', ['page' => $page])}}">
{{$page->title}} {{$page->title}}
</a> @endcan
@else
{{$page->title}}
@endcan
@if ($page->subpages->count() > 0)
&nbsp;({{$page->subpages->count()}})
@endif
@if($page->isHomepage) <span @if($page->isHomepage) <span class="m-l-10 tag tag-primary">@lang('admin/contents.homepage')</span> @endif
class="m-l-10 tag tag-primary">@lang('admin/contents.homepage')</span> @endif </div>
</div> <div class="col-lg-2 col-md-3 hidden-sm-down">
<div class="col-lg-2 col-md-3 hidden-sm-down">
<span class="tag @if($page->isPublic()) tag-success <span class="tag @if($page->isPublic()) tag-success
@elseif ($page->isDraft()) tag-danger @elseif ($page->isDraft()) tag-danger
@else tag-warning @endif">{{$statuses[$page->status]}}</span> @else tag-warning @endif">{{$statuses[$page->status]}}</span>
</div> </div>
<div class="col-lg-2 col-md-3 hidden-sm-down"> <div class="col-lg-2 col-md-3 hidden-sm-down">
<a href="{{route('content.overview', ['module' => $page->module->alias])}}"> <a href="{{route('content.overview', ['module' => $page->module->alias])}}">
@lang($page->module->name) @lang($page->module->name)
</a> </a>
<br> <br>
@if(!is_null($page->templateModel)) @if(!is_null($page->templateModel))
<small>({{$page->templateModel->name}})</small> <small>({{$page->templateModel->name}})</small>
@endif @endif
</div> </div>
<div class="col-lg-2 hidden-md-down">@date($page->created_at)</div> <div class="col-lg-2 hidden-md-down">@date($page->created_at)</div>
<div class="col-xs-2 col-lg-1 text-center"> <div class="col-xs-2 col-lg-1 text-center">
<div class="item-actions-dropdown"> <div class="item-actions-dropdown">
<a class="item-actions-toggle-btn"> <a class="item-actions-toggle-btn">
<span class="inactive"> <span class="inactive">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
</span> </span>
<span class="active"> <span class="active">
<i class="fa fa-chevron-circle-right"></i> <i class="fa fa-chevron-circle-right"></i>
</span> </span>
</a> </a>
<div class="item-actions-block"> <div class="item-actions-block">
<ul class="item-actions-list"> <ul class="item-actions-list">
@if(!$page->isHomepage) @if(!$page->isHomepage)
@can('set-homepage', $page) @can('set-homepage', $page)
<li>
<a href="{{route('content.setHomepage', ['page' => $page])}}" data-toggle="tooltip" title="@lang('admin/contents.setHomepage')">
<i class="fa fa-home"></i>
</a>
</li>
@endcan
@endif
@can('update', $page)
<li> <li>
<a href="{{route('content.setHomepage', ['page' => $page])}}" <a class="edit" href="{{route('content.edit', ['page' => $page])}}" data-toggle="tooltip" title="@lang('admin/contents.editPlain')">
data-toggle="tooltip" <i class="fa fa-pencil"></i>
title="@lang('admin/contents.setHomepage')">
<i class="fa fa-home"></i>
</a> </a>
</li> </li>
@endcan @endcan
@endif
@can('update', $page) @if($page->isDraft())
<li> @can('publish', $page)
<a class="edit" href="{{route('content.edit', ['page' => $page])}}" <li>
data-toggle="tooltip" title="@lang('admin/contents.editPlain')"> <a href="{{route('content.changeStatus', ['page' => $page, 'status' => 'public'])}}" class="confirm" data-toggle="tooltip" title="@lang('admin/contents.makePublic')">
<i class="fa fa-pencil"></i> <i class="fa fa-eye"></i>
</a> </a>
</li> </li>
@endcan @endcan
@can('protect', $page)
@if($page->isDraft()) <li>
@can('publish', $page) <a href="{{route('content.changeStatus', ['page' => $page, 'status' => 'protected'])}}" class="confirm" data-toggle="tooltip" title="@lang('admin/contents.makeProtected')">
<i class="fa fa-lock"></i>
</a>
</li>
@endcan
@else
<li> <li>
<a href="{{route('content.changeStatus', ['page' => $page, 'status' => 'public'])}}" <a href="{{route('page.content', ['url' => $page->url])}}" target="_blank" data-toggle="tooltip" title="@lang('admin/contents.viewPage')" class="button tiny secondary"><i class="fa fa-globe"></i>
class="confirm" data-toggle="tooltip" </a>
title="@lang('admin/contents.makePublic')"> </li>
<i class="fa fa-eye"></i> @can('draft', $page)
<li>
<a href="{{route('content.changeStatus', ['page' => $page, 'status' => 'draft'])}}" class="button tiny warning confirm" data-toggle="tooltip" title="@lang('admin/contents.makeDraft')">
<i class="fa fa-eye-slash"></i>
</a>
</li>
@endcan
@endif
@can('delete', $page)
<li>
<a href="{{route('content.delete', ['page' => $page])}}" class="button tiny alert remove confirm" data-toggle="tooltip" title="@lang('admin/contents.deletePage')"><i class="fa fa-trash-o"></i>
</a> </a>
</li> </li>
@endcan @endcan
@can('protect', $page)
<li>
<a href="{{route('content.changeStatus', ['page' => $page, 'status' => 'protected'])}}"
class="confirm" data-toggle="tooltip"
title="@lang('admin/contents.makeProtected')">
<i class="fa fa-lock"></i>
</a>
</li>
@endcan
@else
<li>
<a href="{{route('page.content', ['url' => $page->url])}}"
target="_blank"
data-toggle="tooltip" title="@lang('admin/contents.viewPage')"
class="button tiny secondary"><i class="fa fa-globe"></i>
</a>
</li>
@can('draft', $page)
<li>
<a href="{{route('content.changeStatus', ['page' => $page, 'status' => 'draft'])}}"
class="button tiny warning confirm" data-toggle="tooltip"
title="@lang('admin/contents.makeDraft')">
<i class="fa fa-eye-slash"></i>
</a>
</li>
@endcan
@endif
@can('delete', $page) </ul>
<li> </div>
<a href="{{route('content.delete', ['page' => $page])}}"
class="button tiny alert remove confirm" data-toggle="tooltip"
title="@lang('admin/contents.deletePage')"><i
class="fa fa-trash-o"></i>
</a>
</li>
@endcan
</ul>
</div> </div>
</div> </div>
</div> </div>
@foreach($page->subpages as $s)
@include('admin.content._partials.overviewRow', ['page' => $s, 'extraClass' => $s->subpages->isEmpty() ? 'subpage hidden-xs-up' : 'subpage hidden-xs-up has-subpages'])
@endforeach
</div> </div>
@@ -0,0 +1,8 @@
<option value="{{$optionPage->id}}"
@if(old('parentId', $page->parentId) == $optionPage->id) selected @endif>
{{$prefix}} {{$optionPage->title}}
</option>
@foreach($optionPage->subpages as $subpage)
@include('admin.content._partials.subpages', ['optionPage' => $subpage, 'prefix' => $prefix.' - '])
@endforeach
@@ -43,10 +43,7 @@
<option value="">@lang('admin/contents.noParentPage')</option> <option value="">@lang('admin/contents.noParentPage')</option>
@foreach($rootPages as $rootPage) @foreach($rootPages as $rootPage)
<option value="{{$rootPage->id}}" @include('admin.content._partials.subpages', ['optionPage' => $rootPage, 'prefix' => ''])
@if(old('parentId', $page->parentId) == $rootPage->id) selected @endif>
{{$rootPage->title}}
</option>
@endforeach @endforeach
</select> </select>
@@ -51,10 +51,6 @@
</div> </div>
@foreach($pages as $page) @foreach($pages as $page)
@include('admin.content._partials.overviewRow', ['extraClass' => $page->subpages->isEmpty() ?: 'has-subpages']) @include('admin.content._partials.overviewRow', ['extraClass' => $page->subpages->isEmpty() ?: 'has-subpages'])
@foreach($page->subpages as $subpage)
@include('admin.content._partials.overviewRow', ['page' => $subpage, 'extraClass' => 'subpage hidden-xs-up'])
@endforeach
@endforeach @endforeach
</div> </div>
</div> </div>
+2 -2
View File
@@ -17,9 +17,9 @@ Route::group([
], function () { ], function () {
// include all routes in routes/admin subfolder // include all routes in routes/admin subfolder
$files = File::allFiles('routes/admin'); $files = File::allFiles(base_path('routes/admin'));
foreach ($files as $file) { foreach ($files as $file) {
require_once base_path($file); require_once $file;
} }
// display dashboard with some usefull information // display dashboard with some usefull information