FEATURE: make own page for template overview
This commit is contained in:
@@ -111,15 +111,7 @@ abstract class BaseHandler implements BaseModuleHandler
|
||||
* Templates
|
||||
*/
|
||||
if ($user->can('manage', Template::class)) {
|
||||
$templatePaths = TemplatePathsHumanReadableRootOnly::getWithTranslations();
|
||||
if (!empty($templatePaths)) {
|
||||
$sub->dropdown(trans('admin/mainMenu.templates'), function ($sub) use ($templatePaths) {
|
||||
$i = 1;
|
||||
foreach ($templatePaths as $id => $name) {
|
||||
$sub->route('templates.overview', $name, ['id' => $id], $i++);
|
||||
}
|
||||
}, 60, ['icon' => 'fa fa-fw fa-file-code-o']);
|
||||
}
|
||||
$sub->route('templates.index', trans('admin/mainMenu.templates'), [], 70, ['icon' => 'fa fa-fw fa-file-code-o']);
|
||||
}
|
||||
|
||||
if ($user->can('manage', ActionLog::class)) {
|
||||
|
||||
@@ -207,6 +207,7 @@ class TemplateRegistrator
|
||||
protected function registerTemplates($path, $templatePathId)
|
||||
{
|
||||
$templates = File::files($path);
|
||||
$registeredTemplates = Templates::getWithTranslations();
|
||||
|
||||
foreach ($templates as $template) {
|
||||
|
||||
@@ -217,7 +218,6 @@ class TemplateRegistrator
|
||||
|
||||
// get all templates and template name (path/to/template.blade.php -> path.to.template)
|
||||
$templateName = $this->getTemplateName($template);
|
||||
$registeredTemplates = Templates::getWithTranslations();
|
||||
|
||||
if (!in_array($templateName, $registeredTemplates)) {
|
||||
$params = [
|
||||
@@ -316,4 +316,14 @@ class TemplateRegistrator
|
||||
|
||||
return $this->namespace . trim($templateName, '.');
|
||||
}
|
||||
|
||||
public function deleteNonExistingPaths()
|
||||
{
|
||||
$paths = TemplatePath::all();
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (!is_dir(base_path($path->path)))
|
||||
\File::deleteDirectory($path->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\CMS\Enumerations\ContentStatuses;
|
||||
use App\CMS\Repositories\Repository;
|
||||
use App\Models\Content\Content as ContentModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
|
||||
class Content extends Repository implements IContent
|
||||
@@ -113,7 +112,7 @@ class Content extends Repository implements IContent
|
||||
->whereNull('contents.parentId')
|
||||
->where('contents.language', LaravelLocalization::getCurrentLocale())
|
||||
->where('modules.enabled', 1)
|
||||
->with('module', 'subpages', 'templateModel')
|
||||
->with('module', 'subpages', 'subpages.module', 'subpages.templateModel', 'templateModel')
|
||||
->orderBy('contents.order')
|
||||
->orderBy('contents.created_at', 'DESC');
|
||||
|
||||
|
||||
@@ -7,6 +7,16 @@ use App\Models\Templates\TemplatePath;
|
||||
|
||||
class TemplateOverview extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
$templatePaths = TemplatePath::with('subdirectories')
|
||||
->whereNull('parent_id')
|
||||
->get();
|
||||
|
||||
return view('admin.templates.index', compact('templatePaths'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display overview of all templates in given path
|
||||
*
|
||||
@@ -17,12 +27,8 @@ class TemplateOverview extends Controller
|
||||
public function getPath(TemplatePath $templatePath)
|
||||
{
|
||||
return view('admin.templates.list', [
|
||||
'directory' => $templatePath,
|
||||
'isWritable' => is_writable(base_path($templatePath->path)),
|
||||
'templates' => $templatePath->templates()
|
||||
->get(),
|
||||
'subdirectories' => $templatePath->subdirectories()
|
||||
->get()
|
||||
'directory' => $templatePath,
|
||||
'isWritable' => is_writable(base_path($templatePath->path))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ class TemplatePathInstaller
|
||||
// install registered widgets
|
||||
$registator->saveTemplates();
|
||||
|
||||
$registator->deleteNonExistingPaths();
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
@section('pageHeading', @trans('admin/fileManager.edit', ['name' => $file->original_filename]))
|
||||
@section('headerButtons')
|
||||
|
||||
<a href="{{route('upload.overview')}}" class="btn btn-secondary rounded btn-sm"><i class="fa fa-list"></i></a>
|
||||
|
||||
@can('delete', $file)
|
||||
<a href="{{route('upload.delete', ['id' => $file->id])}}" class="btn btn-danger btn-sm confirm rounded"
|
||||
title="@lang('admin/fileManager.delete')">
|
||||
@@ -15,34 +18,44 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="large-preview">
|
||||
{!! \App\CMS\Helpers\FileManager::getLargePreview($file) !!}
|
||||
<div class="card items">
|
||||
<div class="card-block">
|
||||
{!! \App\CMS\Helpers\FileManager::getLargePreview($file) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
||||
<div class="row callout secondary">
|
||||
<h3>{{$file->original_filename}}</h3>
|
||||
<div class="card items">
|
||||
<div class="card-block">
|
||||
|
||||
<ul>
|
||||
<li>@lang('admin/fileManager.createdAt'): {{$file->created_at}}</li>
|
||||
<li>@lang('admin/fileManager.updatedAt'): {{$file->updated_at}}</li>
|
||||
<li>@lang('admin/fileManager.mime'): {{$file->mime_type}}</li>
|
||||
<li>@lang('admin/fileManager.hash'): <span
|
||||
title="{{$file->file_hash}}">{{str_limit($file->file_hash, 10)}}</span></li>
|
||||
<li>@lang('admin/fileManager.url'): <a
|
||||
href="{{config('app.upload_url')}}/{{$file->filename}}">{{$file->filename}}</a></li>
|
||||
<li>@lang('admin/fileManager.fileSize')
|
||||
: {{\App\CMS\Helpers\FileManager::getFormattedSize($file)}}</li>
|
||||
<div class="row callout secondary">
|
||||
<h3>{{$file->original_filename}}</h3>
|
||||
|
||||
@foreach($extraInfo as $column => $info)
|
||||
<li>{{$column}}: {{$info}}</li>
|
||||
@endforeach
|
||||
<ul>
|
||||
<li>@lang('admin/fileManager.createdAt'): {{$file->created_at}}</li>
|
||||
<li>@lang('admin/fileManager.updatedAt'): {{$file->updated_at}}</li>
|
||||
<li>@lang('admin/fileManager.mime'): {{$file->mime_type}}</li>
|
||||
<li>@lang('admin/fileManager.hash'): <span
|
||||
title="{{$file->file_hash}}">{{str_limit($file->file_hash, 10)}}</span></li>
|
||||
<li>@lang('admin/fileManager.url'): <a
|
||||
href="{{config('app.upload_url')}}/{{$file->filename}}">{{$file->filename}}</a>
|
||||
</li>
|
||||
<li>@lang('admin/fileManager.fileSize')
|
||||
: {{\App\CMS\Helpers\FileManager::getFormattedSize($file)}}</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
@foreach($extraInfo as $column => $info)
|
||||
<li>{{$column}}: {{$info}}</li>
|
||||
@endforeach
|
||||
|
||||
<div class="row">
|
||||
@include('admin.fileManager.editForm')
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@include('admin.fileManager.editForm')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,61 +15,66 @@
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div id="file-manager-controls" role="tablist" aria-multiselectable="true">
|
||||
@can('upload', \App\Models\FileManager\File::class)
|
||||
<div class="card items">
|
||||
<div class="card-block">
|
||||
<div id="file-manager-controls" role="tablist" aria-multiselectable="true">
|
||||
@can('upload', \App\Models\FileManager\File::class)
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="new-file-title">
|
||||
<h5 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#file-manager-controls"
|
||||
href="#new-file" aria-expanded="false" aria-controls="new-file">
|
||||
@lang('admin/fileManager.newFile')
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="new-file" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="new-file-title">
|
||||
@include('admin.fileManager.newFileForm')
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
|
||||
@if (!$directory->is_root)
|
||||
@can('update', $directory)
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="edit-dir-title">
|
||||
<h5 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#file-manager-controls"
|
||||
href="#edit-dir" aria-expanded="false" aria-controls="edit-dir">
|
||||
@lang('admin/fileManager.editDirectory')
|
||||
</a>
|
||||
</h5>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="new-file-title">
|
||||
<h5 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#file-manager-controls"
|
||||
href="#new-file" aria-expanded="false" aria-controls="new-file">
|
||||
@lang('admin/fileManager.newFile')
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="new-file" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="new-file-title">
|
||||
@include('admin.fileManager.newFileForm')
|
||||
</div>
|
||||
</div>
|
||||
<div id="edit-dir" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="edit-file-title">
|
||||
@include('admin.fileManager.directories.form', ['action' => route('upload.postEditDirectory', ['id' => $directory->id])])
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
@endif
|
||||
@endcan
|
||||
|
||||
@can('create', \App\Models\FileManager\Directory::class)
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="new-dir-title">
|
||||
<h5 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#file-manager-controls"
|
||||
href="#new-dir" aria-expanded="false" aria-controls="new-dir">
|
||||
@lang('admin/fileManager.newDirectory')
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="new-dir" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="new-dir-title">
|
||||
@include('admin.fileManager.directories.form', ['directory' => $newDirectory, 'action' => route('upload.postNewDirectory')])
|
||||
</div>
|
||||
|
||||
@if (!$directory->is_root)
|
||||
@can('update', $directory)
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="edit-dir-title">
|
||||
<h5 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse"
|
||||
data-parent="#file-manager-controls"
|
||||
href="#edit-dir" aria-expanded="false" aria-controls="edit-dir">
|
||||
@lang('admin/fileManager.editDirectory')
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="edit-dir" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="edit-file-title">
|
||||
@include('admin.fileManager.directories.form', ['action' => route('upload.postEditDirectory', ['id' => $directory->id])])
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
@endif
|
||||
|
||||
@can('create', \App\Models\FileManager\Directory::class)
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="new-dir-title">
|
||||
<h5 class="panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#file-manager-controls"
|
||||
href="#new-dir" aria-expanded="false" aria-controls="new-dir">
|
||||
@lang('admin/fileManager.newDirectory')
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="new-dir" class="panel-collapse collapse" role="tabpanel"
|
||||
aria-labelledby="new-dir-title">
|
||||
@include('admin.fileManager.directories.form', ['directory' => $newDirectory, 'action' => route('upload.postNewDirectory')])
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-4
@@ -14,11 +14,8 @@
|
||||
{{--@endif--}}
|
||||
|
||||
<div>
|
||||
|
||||
<h5>@lang('admin/templates.subdirectories')</h5>
|
||||
|
||||
<ul>
|
||||
@forelse($subdirectories as $subdirectory)
|
||||
@forelse($directory->subdirectories as $subdirectory)
|
||||
<li><a href="{{route('templates.overview', ['path' => $subdirectory->id])}}">{{trans($subdirectory->name)}}</a></li>
|
||||
@empty
|
||||
<li><em>@lang('admin/templates.noSubdirectories')</em></li>
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<div class="tile-overview sameheight-container">
|
||||
@forelse($templates as $template)
|
||||
@forelse($directory->templates as $template)
|
||||
<div class="col-lg-3">
|
||||
<div class="text-center bold" data-toggle="tooltip" title="{{$template->name}}">
|
||||
{{str_limit($template->name, 15)}}
|
||||
@@ -3,5 +3,5 @@
|
||||
@section('pageHeading', @trans('admin/templates.edit', ['name' => $template->template_name]))
|
||||
|
||||
@section('content')
|
||||
@include('admin.templates.editForm')
|
||||
@include('admin.templates._partials.editForm')
|
||||
@stop
|
||||
@@ -0,0 +1,13 @@
|
||||
@extends('admin.layoutWithNavigation')
|
||||
|
||||
@section('pageHeading', @trans('admin/templates.overview'))
|
||||
|
||||
@section('content')
|
||||
<div class="card items">
|
||||
<div class="card-block">
|
||||
@foreach($templatePaths as $directory)
|
||||
@include('admin.templates._partials.directoriesList')
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -3,14 +3,23 @@
|
||||
@section('pageHeading', @trans('admin/templates.overview'))
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
@include('admin.templates.templatesTiles')
|
||||
<div class="card items">
|
||||
<div class="card-block">
|
||||
@include('admin.templates._partials.templatesTiles')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="callout">
|
||||
@include('admin.templates.directoriesList')
|
||||
<div class="card items">
|
||||
<div class="card-block">
|
||||
@include('admin.templates._partials.directoriesList')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<?php
|
||||
// these routes are available only for user with role admin
|
||||
Route::group(['namespace' => 'Templates'], function () {
|
||||
Route::get('templates/overview/path/{templatePath}', 'TemplateOverview@getPath')
|
||||
|
||||
Route::get('templates', 'TemplateOverview@index')
|
||||
->name('templates.index')
|
||||
->middleware('can:manage,' . \App\Models\Templates\Template::class);
|
||||
|
||||
Route::get('templates/{templatePath}', 'TemplateOverview@getPath')
|
||||
->name('templates.overview')
|
||||
->middleware('can:manage,' . \App\Models\Templates\Template::class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user