diff --git a/app/Http/Controllers/Admin/TemplateOverview.php b/app/Http/Controllers/Admin/TemplateOverview.php new file mode 100644 index 00000000..f766b14e --- /dev/null +++ b/app/Http/Controllers/Admin/TemplateOverview.php @@ -0,0 +1,25 @@ + $path, + 'isWritable' => is_writable(base_path($path->path)), + 'templates' => $path->templates() + ->get(), + 'subdirectories' => $path->subdirectories() + ->get() + ]); + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php index 61dc7b9a..4c6a8d30 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -51,6 +51,21 @@ Route::group([ Route::get('customfields/delete/{id}', 'EditCustomField@deleteCustomField') ->name('customfields.delete'); + + Route::get('templates/overview/path/{id}', 'TemplateOverview@getPath') + ->name('templates.overview'); + + Route::get('templates/copy/{id}', 'TemplateOverview@getPath') + ->name('templates.copy'); + + Route::get('templates/new/{pathId}', 'TemplateOverview@getPath') + ->name('templates.new'); + + Route::get('templates/edit/{id}', 'TemplateOverview@getPath') + ->name('templates.edit'); + + Route::post('templates/edit/{id}', 'TemplateOverview@getPath') + ->name('templates.postEdit'); }); // these routes are available for all logged (authenticated) users diff --git a/app/Models/TemplatePath.php b/app/Models/TemplatePath.php index 07271869..68337c6a 100644 --- a/app/Models/TemplatePath.php +++ b/app/Models/TemplatePath.php @@ -18,7 +18,18 @@ class TemplatePath extends Model * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ - public function templates() { + public function templates() + { return $this->hasMany('App\Models\Template', 'path'); } + + /** + * List of all subdirectories of given path + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function subdirectories() + { + return $this->hasMany('App\Models\TemplatePath', 'parent_id'); + } } \ No newline at end of file diff --git a/app/Providers/AdminMenusProvider.php b/app/Providers/AdminMenusProvider.php index 6f8b1094..c7304339 100644 --- a/app/Providers/AdminMenusProvider.php +++ b/app/Providers/AdminMenusProvider.php @@ -2,6 +2,8 @@ namespace App\Providers; +use App\Enumerations\TemplatePathsHumanReadable; +use App\Enumerations\TemplatePathsHumanReadableRootOnly; use App\Enumerations\WidgetTypes; use Illuminate\Support\ServiceProvider; @@ -54,6 +56,13 @@ class AdminMenusProvider extends ServiceProvider $sub->route('widgetareas.overview', trans('admin/mainMenu.widgetAreaOverview'), [], 2, ['icon' => 'fa fa-list']); }, 50, ['icon' => 'fa fa-object-group']); }, 28, ['icon' => 'fa fa-gears']); + $menu->dropdown(trans('admin/mainMenu.templates'), function ($sub) { + $i = 1; + $templatePaths = TemplatePathsHumanReadableRootOnly::getWithTranslations(); + foreach ($templatePaths as $id => $name) { + $sub->route('templates.overview', $name, ['id' => $id], $i++); + } + }, 29, ['icon' => 'fa fa-folder-open']); $menu->dropdown(trans('admin/mainMenu.customFields'), function ($sub) { $sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-code']); $sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-code-fork']); diff --git a/resources/lang/en/admin/mainMenu.php b/resources/lang/en/admin/mainMenu.php index 60154a18..5edb8b1b 100644 --- a/resources/lang/en/admin/mainMenu.php +++ b/resources/lang/en/admin/mainMenu.php @@ -21,5 +21,6 @@ return [ 'newWidget' => 'New widget', 'widgetAreas' => 'Widget areas', 'widgetsOverview' => 'All widgets', - 'assignWidgets' => 'Assign widgets' + 'assignWidgets' => 'Assign widgets', + 'templates' => 'Templates' ]; \ No newline at end of file diff --git a/resources/lang/en/admin/templates.php b/resources/lang/en/admin/templates.php new file mode 100644 index 00000000..d0036699 --- /dev/null +++ b/resources/lang/en/admin/templates.php @@ -0,0 +1,11 @@ + 'Core templates', + 'homepage' => 'Home page', + 'overview' => 'Templates', + 'noSubdirectories' => 'No directories available', + 'parentDirectory' => 'Parent directory', + 'noTemplates' => 'No templates available', + 'new' => 'New template', + 'subdirectories' => 'Subdirectories' +]; \ No newline at end of file diff --git a/resources/views/admin/templates/directoriesList.blade.php b/resources/views/admin/templates/directoriesList.blade.php new file mode 100644 index 00000000..5c4609b6 --- /dev/null +++ b/resources/views/admin/templates/directoriesList.blade.php @@ -0,0 +1,25 @@ +@if($directory->parent_id) + + @lang('admin/templates.parentDirectory') + +
+@endif + +

@lang($directory->name)

+ +@if (true || isset($isWritable) && $isWritable) +
+ @lang('admin/templates.new')
+
+@endif + +
+ +
@lang('admin/templates.subdirectories')
+ + @forelse($subdirectories as $subdirectory) + {{trans($subdirectory->name)}} + @empty + @lang('admin/templates.noSubdirectories') + @endforelse +
\ No newline at end of file diff --git a/resources/views/admin/templates/list.blade.php b/resources/views/admin/templates/list.blade.php new file mode 100644 index 00000000..de5a99ef --- /dev/null +++ b/resources/views/admin/templates/list.blade.php @@ -0,0 +1,20 @@ +@extends('admin.layout') + +@section('pageName', @trans('admin/templates.overview')) + +@section('content') +

@lang('admin/templates.overview')

+ +
+
+ @include('admin.templates.templatesTiles') +
+ +
+
+ @include('admin.templates.directoriesList') +
+
+
+ +@stop \ No newline at end of file diff --git a/resources/views/admin/templates/templatesTiles.blade.php b/resources/views/admin/templates/templatesTiles.blade.php new file mode 100644 index 00000000..bf9aff98 --- /dev/null +++ b/resources/views/admin/templates/templatesTiles.blade.php @@ -0,0 +1,31 @@ +
+ @forelse($templates as $template) +
+
+
+
+ {{str_limit($template->name, 15)}} +
+
+ {{str_limit($template->description, 150)}} +
+
+ +
+ + + + + @if ($template->editable) + + + + @endif +
+
+
+ + @empty + @lang('admin/templates.noTemplates') + @endforelse +
\ No newline at end of file diff --git a/resources/views/visitor/default_theme/homepage/list.blade.php b/resources/views/visitor/default_theme/homepage/list.blade.php new file mode 100644 index 00000000..e69de29b