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