FEATURE: add template check on content overview

This commit is contained in:
Michal Kváček
2016-09-20 14:47:38 +02:00
parent df9ff7b259
commit e8b91db6f2
4 changed files with 85 additions and 64 deletions
+7 -3
View File
@@ -13,7 +13,7 @@ class Template
*
* @return null|string
*/
public static function name($template)
public static function name($template, $throwExceptions = true)
{
$namespace = null;
if (strpos($template, '::')) {
@@ -32,8 +32,12 @@ class Template
}
}
if (is_null($view)) {
throw new InvalidArgumentException('Cannot find template for ' . $namespace . $template);
if ($throwExceptions) {
if (is_null($view)) {
throw new InvalidArgumentException('Cannot find template for ' . $namespace . $template);
}
} else {
return false;
}
return $view;
+54 -53
View File
@@ -1,56 +1,57 @@
<?php
return [
'status_deleted' => 'Deleted',
'status_draft' => 'Draft',
'status_protected' => 'Protected',
'status_public' => 'Public',
'new' => 'Create new :name',
'category' => 'Category',
'edit' => 'Edit :name',
'editPlain' => 'Edit',
'content' => 'Page content',
'save' => 'Save page',
'basicInfo' => 'Basic information',
'metaOptions' => 'Meta information',
'publicationOptions' => 'Publication setup',
'field_title' => 'Page title',
'field_url' => 'URL',
'field_meta_keywords' => 'Keywords',
'field_meta_description' => 'Page description',
'field_published_from' => 'Published from',
'field_published_to' => 'Published to',
'successfullyCreated' => 'Page successfully created',
'noPagesAvailable' => 'No static pages available. Try to create one first.',
'viewPage' => 'View',
'deletePage' => 'Delete',
'makePublic' => 'Publish',
'makeProtected' => 'Logged users only',
'makeDraft' => 'Make draft',
'invalidStatus' => 'Cannot change status to something undefined.',
'statusChanged' => 'Status successfully changed.',
'invalidPage' => 'Specified page does not exist.',
'pageDeleted' => 'Page :name (:url) successfully deleted.',
'nothingToEdit' => 'You did not submit any changes. Nothing was edited.',
'successfullyEdited' => 'Edit successfull',
'showHistory' => 'History (:count)',
'appearance' => 'Appearance',
'template' => 'Template of this page',
'overview' => 'List of all content pages',
'homepageSetup' => 'Homepage successfully set up.',
'setHomepage' => 'Set page as homepage',
'noParentPage' => ' -- No parent page -- ',
'uploadTitleImage' => 'Upload title image',
'noHomepage' => 'You have not set up your homepage yet, or your current homepage is draft! Try to select another one.',
'homepageProtected' => 'Your homepage is displayed only for logged in users. This may or may not be an error.',
'parentPage' => 'Parent page',
'alreadyHomepage' => 'Homepage',
'files' => 'Files',
'lockUrl' => 'Keep URL',
'noCategory' => ' -- No category -- ',
'noTemplates' => 'Cannot create content page. There are no available templates for this module.',
'title' => 'Title',
'createdAt' => 'Created at',
'status' => 'Status',
'moduleName' => 'Module',
'actions' => 'Actions'
'status_deleted' => 'Deleted',
'status_draft' => 'Draft',
'status_protected' => 'Protected',
'status_public' => 'Public',
'new' => 'Create new :name',
'category' => 'Category',
'edit' => 'Edit :name',
'editPlain' => 'Edit',
'content' => 'Page content',
'save' => 'Save page',
'basicInfo' => 'Basic information',
'metaOptions' => 'Meta information',
'publicationOptions' => 'Publication setup',
'field_title' => 'Page title',
'field_url' => 'URL',
'field_meta_keywords' => 'Keywords',
'field_meta_description' => 'Page description',
'field_published_from' => 'Published from',
'field_published_to' => 'Published to',
'successfullyCreated' => 'Page successfully created',
'noPagesAvailable' => 'No static pages available. Try to create one first.',
'viewPage' => 'View',
'deletePage' => 'Delete',
'makePublic' => 'Publish',
'makeProtected' => 'Logged users only',
'makeDraft' => 'Make draft',
'invalidStatus' => 'Cannot change status to something undefined.',
'statusChanged' => 'Status successfully changed.',
'invalidPage' => 'Specified page does not exist.',
'pageDeleted' => 'Page :name (:url) successfully deleted.',
'nothingToEdit' => 'You did not submit any changes. Nothing was edited.',
'successfullyEdited' => 'Edit successfull',
'showHistory' => 'History (:count)',
'appearance' => 'Appearance',
'template' => 'Template of this page',
'overview' => 'List of all content pages',
'homepageSetup' => 'Homepage successfully set up.',
'setHomepage' => 'Set page as homepage',
'noParentPage' => ' -- No parent page -- ',
'uploadTitleImage' => 'Upload title image',
'noHomepage' => 'You have not set up your homepage yet, or your current homepage is draft! Try to select another one.',
'homepageProtected' => 'Your homepage is displayed only for logged in users. This may or may not be an error.',
'parentPage' => 'Parent page',
'alreadyHomepage' => 'Homepage',
'files' => 'Files',
'lockUrl' => 'Keep URL',
'noCategory' => ' -- No category -- ',
'noTemplates' => 'Cannot create content page. There are no available templates for this module.',
'title' => 'Title',
'createdAt' => 'Created at',
'status' => 'Status',
'moduleName' => 'Module',
'actions' => 'Actions',
'invalidTemplateSelected' => 'Invalid template selected! This page cannot be rendered!'
];
@@ -4,6 +4,12 @@
@section('content')
@if(!count($templates))
<div class="alert alert-warning">
@lang('admin/contents.noTemplates')
</div>
@endif
<form method="POST" enctype="multipart/form-data" action="{{route('content.editPost', ['pageId' => $page->id])}}">
{!! csrf_field() !!}
@@ -35,11 +35,17 @@
<div class="row p-tb-15">
<div class="col-md-1 hidden-sm-down text-center with-placeholder">
<a href="{{route('content.edit', ['id' => $page->id])}}">
@if(!empty($page->title_photo))
<img src="@upload($page->title_photo)" class="placeholder" alt="{{$page->title}}" />
@if(!view()->exists(\App\Helpers\Template::name($page->template, false)))
<i class="fa fa-2x text-warning fa-warning" data-toggle="tooltip"
title="@lang('admin/contents.invalidTemplateSelected')"></i>
@else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" class="placeholder"
alt="{{$page->title}}" />
@if(!empty($page->title_photo))
<img src="@upload($page->title_photo)" class="placeholder" alt="{{$page->title}}" />
@else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}"
class="placeholder"
alt="{{$page->title}}" />
@endif
@endif
</a>
</div>
@@ -71,14 +77,16 @@
@if(!$page->is_homepage)
<li>
<a href="{{route('content.setHomepage', ['id' => $page->id])}}" data-toggle="tooltip" title="@lang('admin/contents.setHomepage')">
<a href="{{route('content.setHomepage', ['id' => $page->id])}}"
data-toggle="tooltip" title="@lang('admin/contents.setHomepage')">
<i class="fa fa-home"></i>
</a>
</li>
@endif
<li>
<a class="edit" href="{{route('content.edit', ['id' => $page->id])}}" data-toggle="tooltip" title="@lang('admin/contents.editPlain')">
<a class="edit" href="{{route('content.edit', ['id' => $page->id])}}"
data-toggle="tooltip" title="@lang('admin/contents.editPlain')">
<i class="fa fa-pencil"></i>
</a>
</li>
@@ -86,7 +94,8 @@
@if($page->status == \App\Models\Content::STATUS_DRAFT)
<li>
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PUBLIC])}}"
class="confirm" data-toggle="tooltip" title="@lang('admin/contents.makePublic')">
class="confirm" data-toggle="tooltip"
title="@lang('admin/contents.makePublic')">
<i class="fa fa-eye"></i>
</a>
</li>
@@ -115,7 +124,8 @@
<li>
<a href="{{route('content.delete', ['id' => $page->id])}}"
class="button tiny alert remove confirm" data-toggle="tooltip" title="@lang('admin/contents.deletePage')"><i
class="button tiny alert remove confirm" data-toggle="tooltip"
title="@lang('admin/contents.deletePage')"><i
class="fa fa-trash-o"></i>
</a>
</li>