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