FEATURE #1507: modularize content management

This commit is contained in:
Michal Kváček
2016-03-11 15:43:11 +01:00
parent 3407707046
commit 9f5bd46ca3
23 changed files with 1018 additions and 19 deletions
@@ -0,0 +1,18 @@
<?php
namespace App\Enumerations;
use App\Models\Content;
class ActiveContentStatuses extends BaseEnumeration
{
protected static function init()
{
foreach (ContentStatuses::getWithTranslations() as $key => $value) {
if ($key == Content::STATUS_DELETED) {
continue;
}
self::push($key, $value);
}
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Enumerations;
use App\Models\Module;
class ModuleNamesWithIds extends BaseEnumeration
{
/**
* Init list of all installed modules
*
* @throws Exceptions\EnumerationExistsException
*/
protected static function init()
{
$modules = Module::all(['id', 'name']);
foreach ($modules as $module) {
self::push($module->id, $module->name);
}
}
}
+60
View File
@@ -1,6 +1,7 @@
<?php
namespace App\Handlers\Contracts;
use App\Http\Requests\Request;
use App\Models\Content;
use App\Models\User;
@@ -18,6 +19,65 @@ interface AppHandler
public static function getHistoryHandler();
/**
* Save module-specific values into database
*
* @param Content $content
* @param Request $request
*
* @return mixed
* @internal param Widget $widget
*/
public static function createNew(Content &$content, Request $request);
/**
* Method used for editing existing content page.
*
* Reason why it is separated from createNew() method is simple - we need to save history of changes.
*
* @param Content $content
* @param Request $request
*
* @param $revisionID string ID of revision used
*
* @return int number of edited fields
*/
public static function edit(Content &$content, Request $request, $revisionID);
/**
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
*
* @return bool
*/
public static function managesContent();
public static function getModuleId();
/**
* Getter for section names in creating/editing content resource
*
* @return mixed
*/
public static function getExtendedFormSections();
/**
* Getter for views used in extended part of form for creating new content
*
* This method should return pairs <section, view-name>. View is returned only as name in plain text
*
* @return array of views/templates/html codes divided into section
*/
public static function getExtendedFormInputsCreate();
/**
* Getter for extended part of form for editing existing content
*
* Basically, this method may be
*
* @return array of views/templates/html codes divided into section
*/
public static function getExtendedFormInputsEdit();
/**
* Register admin menu (or multiple ones)
*
+38 -1
View File
@@ -1,6 +1,7 @@
<?php
namespace App\Handlers;
use App\Enumerations\ModuleNamesWithIds;
use App\Enumerations\TemplatePathsHumanReadableRootOnly;
use App\Enumerations\WidgetTypes;
use App\Handlers\Contracts\AppHandler;
@@ -21,6 +22,31 @@ abstract class Handler implements AppHandler
return History::class;
}
public static function getExtendedFormSections()
{
return [
'basicInfo' => trans('admin/contents.basicInfo'),
'meta' => trans('admin/contents.metaOptions'),
'publication' => trans('admin/contents.publicationOptions'),
'appearance' => trans('admin/contents.appearance')
];
}
public static function getExtendedFormInputsCreate()
{
return [
'basicInfo' => 'admin.content.formParts.basicInformation',
'meta' => 'admin.content.formParts.metaInformation',
'publication' => 'admin.content.formParts.publicationSetup',
'appearance' => 'admin.content.formParts.appearance',
];
}
public static function getExtendedFormInputsEdit()
{
return self::getExtendedFormInputsCreate();
}
/**
* Register admin menu (or multiple ones)
*
@@ -55,6 +81,18 @@ abstract class Handler implements AppHandler
$sub->route('users.detail', trans('admin/mainMenu.userDetail'), [], 20, ['icon' => 'fa fa-user']);
$sub->route('users.overview', trans('admin/mainMenu.usersOverview'), [], 30, ['icon' => 'fa fa-users']);
}, 20, ['icon' => 'fa fa-users']);
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
$sub->dropdown(trans('admin/mainMenu.newContentPage'), function ($sub) {
$i = 1;
$modules = ModuleNamesWithIds::getWithTranslations();
foreach ($modules as $module => $name) {
$sub->route('content.new', trans($name), ['moduleId' => $module], $i++);
}
}, 10, ['icon' => 'fa fa-plus']);
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 20, ['icon' => 'fa fa-list']);
}, 15, ['icon' => 'fa fa-database']);
$menu->dropdown(trans('admin/mainMenu.fileManager'), function ($sub) {
$sub->route('upload.file', trans('admin/mainMenu.uploadFile'), [], 10, ['icon' => 'fa fa-file']);
$sub->route('upload.image', trans('admin/mainMenu.uploadImage'), [], 50, ['icon' => 'fa fa-image']);
@@ -99,6 +137,5 @@ abstract class Handler implements AppHandler
$menu->route('users.detail', trans('admin/userManagement.profile'));
$menu->route('logout', trans('admin/common.logout'));
});
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Models\Content;
use App\Models\Module;
use Illuminate\Support\Facades\Input;
class ContentOverview extends Controller
{
/**
* Overview for all content pages.
*
* @param bool|false $moduleId
* @param null $status
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getOverview($moduleId = false, $status = null)
{
$moduleFilterHandler = false;
$perPage = Input::get('perPage') ? Input::get('perPage') : 20;
// does user want to filter results using module?
if (is_numeric($moduleId)) {
$module = Module::findOrFail($moduleId);
$moduleFilterHandler = $module->handler;
}
// get pages for overview
$model = new Content();
$pages = $model->getOverview($moduleFilterHandler, $status, true)
->paginate($perPage);
return view('admin.content.overview', ['pages' => $pages]);
}
}
@@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Enumerations\ActiveContentStatuses;
use App\Models\Content;
use App\Models\Module;
use App\Models\Template;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str;
use Modules\StaticPages\Http\Requests\CreateNewStaticPageRequest;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class CreateNewContent extends Controller
{
/**
* Display form for new content page
*
* @param $moduleId
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getNew($moduleId)
{
$module = Module::findOrFail($moduleId);
$statuses = ActiveContentStatuses::getWithTranslations();
$templates = Template::where('module_id', $moduleId)
->select(['template_name', 'name', 'description'])
->get();
// create default content object
$page = new Content();
$page->status = Content::STATUS_DRAFT;
// render view
return view('admin.content.new', [
'contentStatuses' => $statuses,
'templates' => $templates,
'moduleId' => $moduleId,
'page' => $page,
'moduleName' => trans($module->name),
'formSectionNames' => call_user_func([$module->handler, 'getExtendedFormSections']),
'formSections' => call_user_func([$module->handler, 'getExtendedFormInputsCreate']),
]);
}
/**
* Save new content page
*
* @param CreateNewStaticPageRequest $request
*
* @param $moduleId
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postNew(CreateNewContentRequest $request, $moduleId)
{
$page = new Content();
try {
$module = Module::findOrFail($moduleId);
} catch (NotFoundHttpException $e) {
return redirect()
->route('content.overview')
->withInput()
->with('error', trans('admin/contents.invalidModule'));
}
// setup basic info
$page->user_id = \Auth::user()->id;
$page->title = $request->title;
$page->url = Str::slug($request->url);
$page->published_from = $request->publishedFrom;
$page->published_to = $request->publishedTo;
$page->meta_keywords = $request->meta_description;
$page->meta_description = $request->meta_description;
$page->content = $request->pageContent;
$page->status = $request->status;
$page->template = $request->template;
$page->module_handler = $module->handler;
// save module-specific stuff
call_user_func_array([$module->handler, 'createNew'], [&$page, $request]);
$page->save();
Event::fire(new \Modules\StaticPages\Events\CreateNewStaticPage($page));
return redirect()
->route('content.overview')
->with('success', trans('admin/contents.successfullyCreated'));
}
}
+266
View File
@@ -0,0 +1,266 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Enumerations\ContentStatuses;
use App\Enumerations\ModulesHandlerToId;
use App\Models\Content;
use App\Models\ContentHistory;
use App\Models\Template;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str;
use Modules\StaticPages\Events\DeleteStaticPage;
use Modules\StaticPages\Events\EditStaticPage as EditStaticPageEvent;
use Modules\StaticPages\Events\MakeDraftFromStaticPage;
use Modules\StaticPages\Events\PublishStaticPage;
use Modules\StaticPages\Http\Requests\EditStaticPageRequest;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class EditContent extends Controller
{
/**
* @var ContentHistory
*/
private $history;
public function __construct(ContentHistory $history)
{
$this->history = $history;
}
/**
* Display form for editing static page
*
* @param $id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getEdit($id)
{
// select all content statuses
$statuses = ContentStatuses::getWithTranslations();
// try to find requested page
$page = Content::where('module_handler', config('staticpages.handler'))
->findOrFail($id);
$allModules = ModulesHandlerToId::getWithTranslations();
$moduleId = $allModules[config('staticpages.handler')];
$templates = Template::where('module_id', $moduleId)
->select(['template_name', 'name', 'description'])
->get();
$history = $this->history->getStructuredHistoryOf($page);
// render view
return view('admin.content.edit', [
'contentStatuses' => $statuses,
'page' => $page,
'templates' => $templates,
'formSectionNames' => call_user_func([$page->module_handler, 'getExtendedFormSections']),
'formSections' => call_user_func([$page->module_handler, 'getExtendedFormInputsCreate']),
'historySize' => count($history['changesets'])
]);
}
/**
* Edit static page and save changes into history.
*
* @param EditStaticPageRequest $request
* @param $id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postEdit(EditStaticPageRequest $request, $id)
{
try {
$page = Content::findOrFail($id);
} catch (NotFoundHttpException $e) {
// page for editing not found
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidPage'));
}
$request->url = Str::slug($request->url);
// array of fields in database and fields from request
$fields = [
'title' => 'title',
'url' => 'url',
'template' => 'template',
'published_from' => 'publishedFrom',
'published_to' => 'publishedTo',
'meta_keywords' => 'metaKeywords',
'meta_description' => 'metaDescription',
'content' => 'pageContent',
'status' => 'status'
];
// save new values with history
list($revision, $changedColumns) = $page->updateWithHistory($fields, $request->all());
$changedColumns += call_user_func_array([$page->module_handler, 'edit'], [&$page, $request, $revision]);
// was something changed?
if ($changedColumns == 0) {
return redirect()
->route('content.edit', ['id' => $page->id])
->with('error', trans('admin/contents.nothingToEdit'));
}
// fire event with
Event::fire(new EditStaticPageEvent($page, $revision));
// something was changed, inform user
return redirect()
->route('content.edit', ['id' => $page->id])
->with('success', trans('admin/contents.successfullyEdited'));
}
/**
* Method for changing page status
*
* This method is called in static page overview from quick actions. It checks if status is valid, if page exists
* and updates status.
*
* @param $id
* @param $status
*
* @return \Illuminate\Http\RedirectResponse
*/
public function changeStatus($id, $status)
{
// get possible statuses
$statuses = ContentStatuses::getWithTranslations();
unset($statuses[Content::STATUS_DELETED]);
// check if given status is valid
if (!isset($statuses[$status])) {
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidStatus'));
}
try {
// try to find this page
$page = Content::findOrFail($id);
} catch (NotFoundHttpException $e) {
// page not found
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidPage'));
}
// try to change the page
list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => $status]);
// was something changed?
if ($changedColumns == 0) {
return redirect()
->route('content.edit', ['id' => $page->id])
->with('error', trans('admin/contents.nothingToEdit'));
}
// fire events
if ($status != Content::STATUS_DRAFT) {
Event::fire(new PublishStaticPage($page, $revision));
} else {
Event::fire(new MakeDraftFromStaticPage($page, $revision));
}
// redirect back to overview with info for user
return redirect()
->route('content.overview')
->with('success', trans('admin/contents.statusChanged'));
}
/**
* Delete page
*
* @param $id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function deletePage($id)
{
try {
// try to find this page
$page = Content::findOrFail($id);
} catch (NotFoundHttpException $e) {
// page not found
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidPage'));
}
list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => Content::STATUS_DELETED]);
// was something changed?
if ($changedColumns == 0) {
return redirect()
->route('content.edit', ['id' => $page->id])
->with('error', trans('admin/contents.nothingToEdit'));
}
// trigger delete event
Event::fire(new DeleteStaticPage($page, $revision));
// redirect back to overview with info for user
return redirect()
->route('content.overview')
->with('success', trans('admin/contents.pageDeleted', [
'name' => $page->title,
'url' => $page->url
]));
}
/**
* Sets page as homepage
*
* @param $id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function setHomepage($id)
{
try {
// try to find this page
/**
* @var $page Content
*/
$page = Content::findOrFail($id);
$homepage = $page->getHomepage();
} catch (NotFoundHttpException $e) {
// page not found
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidPage'));
}
list ($revision, $changedColumns) = $page->updateWithHistory(['is_homepage' => 'is_homepage'], ['is_homepage' => 1]);
if ($homepage)
$homepage->updateWithHistory(['isHomepage' => 'is_homepage'], ['ishomepage' => 0]);
// was something changed?
if ($changedColumns == 0) {
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.nothingToEdit'));
}
// trigger delete event
// Event::fire(new DeleteStaticPage($page, $revision));
// redirect back to overview with info for user
return redirect()
->route('content.overview')
->with('success', trans('admin/contents.homepageSetup', [
'name' => $page->title,
'url' => $page->url
]));
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
class CreateNewContentRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => 'required',
'url' => 'required|unique:contents,url',
'template' => 'required|exists:templates,template_name',
'published_from' => 'date',
'published_to' => 'date',
'title_photo' => 'exists:files,id',
'module_settings' => 'json',
'status' => 'required|in:draft,protected,public'
];
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use App\Enumerations\ContentStatuses;
class EditContentRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
// get all available statuses
$statuses = ContentStatuses::getSimple();
$statuses = implode(',', $statuses);
return [
'title' => 'required',
'url' => 'required|unique:contents,url,' . $this->id,
'template' => 'required|exists:templates,template_name',
'published_from' => 'date',
'published_to' => 'date',
'title_photo' => 'exists:files,id',
'status' => 'required|in:' . $statuses
];
}
}
+34
View File
@@ -68,6 +68,40 @@ Route::group([
->name('templates.postEdit');
});
// list of all static pages
Route::get('content/overview/{moduleId?}/{status?}', 'ContentOverview@getOverview')
->name('content.overview');
// form for creating new static page
Route::get('content/new/{moduleId}', 'CreateNewContent@getNew')
->name('content.new');
// form for editing existing static page
Route::get('content/edit/{id}', 'EditContent@getEdit')
->name('content.edit');
// post method for creating new static page
Route::post('content/new/{moduleId}', 'CreateNewContent@postNew')
->name('content.newPost');
// post method for creating new static page
Route::post('content/edit/{id}', 'EditContent@postEdit')
->name('content.editPost');
// routes for quick actions
// change status of page (protected, public or draft)
Route::get('content/status/{id}/{status}', 'EditContent@changeStatus')
->name('content.changeStatus');
// set homepage
Route::get('content/homepage/{id}', 'EditContent@setHomepage')
->name('content.setHomepage');
// delete page
Route::get('content/delete/{id}', 'EditContent@deletePage')
->name('content.delete');
// these routes are available for all logged (authenticated) users
// display dashboard with some usefull information
+33 -13
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use App\Enumerations\ContentStatuses;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
@@ -67,24 +68,39 @@ class Content extends Model
}
/**
* Getter for overview of all content pages of given handler (module type)
* Getter for overview of all content pages.
*
* @param $handler
* These content pages may be filtered by using some handler
*
* @param bool $handler
* @param bool $status
* @param bool $joinAuthor
*
* @return
*/
public function getByType($handler, $joinAuthor = false)
public function getOverview($handler = false, $status = false, $joinAuthor = false)
{
$query = DB::table('contents')
->select('contents.*')
->select('contents.*', 'modules.name AS module_name')
->where('contents.status', '<>', self::STATUS_DELETED)
->where('module_handler', $handler)
->orderBy('created_at');
->join('modules', 'modules.handler', '=', 'contents.module_handler')
->orderBy('created_at', 'DESC');
// filter results using handler
if ($handler) {
$query = $query->where('module_handler', $handler);
}
// join user email and user name to results when needed
if ($joinAuthor) {
$query = $query->join('users', 'users.id', '=', 'contents.user_id')
->select('contents.*', 'users.name AS author_name', 'users.email AS author_email');
->addSelect('users.name AS author_name')
->addSelect('users.email AS author_email');
}
// add filtering by status
if (in_array($status, ContentStatuses::getSimple())) {
$query = $query->where('contents.status', $status);
}
return $query;
@@ -93,14 +109,18 @@ class Content extends Model
/**
* Updates current model with information about changed columns
*
* @param array $fields
* @param array $request
* @param array $fields
* @param array $request
* @param string $revisionId
*
* @return int number of changed columns
*/
public function updateWithHistory(array $fields, array $request)
public function updateWithHistory(array $fields, array $request, $revisionId = null)
{
$editBatch = uniqid();
if (!$revisionId) {
$revisionId = uniqid();
}
$changed = 0;
foreach ($fields as $fieldDB => $fieldRequest) {
@@ -118,7 +138,7 @@ class Content extends Model
$history = [
'user_id' => \Auth::user()->id,
'content_id' => $this->id,
'edit_batch' => $editBatch,
'edit_batch' => $revisionId,
'column' => $fieldRequest,
'old_value' => $this->$fieldDB,
'new_value' => $request[$fieldRequest]
@@ -136,7 +156,7 @@ class Content extends Model
$this->save();
return [$editBatch, $changed];
return [$revisionId, $changed];
}
/**
+35 -4
View File
@@ -1,7 +1,38 @@
<?php
return [
'status_deleted' => 'Deleted',
'status_draft' => 'Draft',
'status_protected' => 'Protected',
'status_public' => 'Public'
'status_deleted' => 'Deleted',
'status_draft' => 'Draft',
'status_protected' => 'Protected',
'status_public' => 'Public',
'new' => 'Create new :name',
'edit' => 'Edit :name',
'content' => 'Page content',
'save' => 'Save new 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 page on web',
'deletePage' => 'Delete page (ireversible!)',
'makePublic' => 'Publish page',
'makeProtected' => 'Publish page only for logged users',
'makeDraft' => 'Disable page and make it 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.'
];
+4 -1
View File
@@ -22,5 +22,8 @@ return [
'widgetAreas' => 'Widget areas',
'widgetsOverview' => 'All widgets',
'assignWidgets' => 'Assign widgets',
'templates' => 'Templates'
'templates' => 'Templates',
'contentPages' => 'Web content',
'contentPageOverview' => 'Overview',
'newContentPage' => 'New content'
];
@@ -0,0 +1,14 @@
@extends('admin.layout')
@section('pageName', @trans('admin/contents.edit', ['name' => $page->title]))
@section('content')
<div class="row">
<h2>@lang('admin/contents.edit', ['name' => $page->title])</h2>
</div>
<div class="row">
@include('admin.content.editForm')
</div>
@stop
@@ -0,0 +1,37 @@
@if (session('success'))
<div data-alert class="callout success">
<strong>{{ session('success') }}</strong>
</div>
@endif
@if (session('error'))
<div data-alert class="callout alert">
<strong>{{ session('error') }}</strong>
</div>
@endif
<form method="POST" action="{{route('content.editPost', ['pageId' => $page->id])}}">
{!! csrf_field() !!}
@include('admin.content.formInputs')
<div class="row">
<div class="columns large-6">
<button type="submit" class="button success">@lang('admin/contents.edit', ['name' => $page->title])</button>
</div>
@if ($historySize > 0)
<div class="columns text-right large-6">
<a class="button warning" href="{{route('content.history', ['id' => $page->id])}}">@lang('admin/contents.showHistory', ['count' => $historySize])</a>
</div>
@endif
</div>
</form>
@section('javascripts')
<script src="{{asset('../resources/assets/js/vendor/ckeditor/ckeditor.js')}}"></script>
<script type="application/javascript">
CKEDITOR.replace ('pageContent');
</script>
@stop
@@ -0,0 +1,17 @@
<ul class="tabs" data-tabs id="static-page-controls">
@foreach($formSectionNames as $section => $sectionName)
<li class="tabs-title @if($sectionName == reset($formSectionNames)) is-active @endif">
<a href="#{{$section}}" @if($sectionName == reset($formSectionNames)) aria-selected="true" @endif>
{{trans($sectionName)}}
</a>
</li>
@endforeach
</ul>
<div class="tabs-content" data-tabs-content="static-page-controls">
@foreach($formSections as $section => $view)
<div class="tabs-panel @if($view == reset($formSections)) is-active @endif" id="{{$section}}">
@include($view)
</div>
@endforeach
</div>
@@ -0,0 +1,27 @@
<div class="row">
<div class="columns large-12">
<label>
@lang('admin/contents.template')
<select name="template">
@foreach($templates as $template)
<option value="{{$template->template_name}}"
@if(old('template', $page->template) == $template->template_name) selected @endif>
{{$template->name}}
@if($template->description != '')
- {{str_limit($template->description, 60)}}
@endif
</option>
@endforeach
</select>
@if (isset($errors) && $errors->has('template'))
<div class="callout alert">
{{ $errors->first('template') }}
</div>
@endif
</label>
</div>
</div>
@@ -0,0 +1,56 @@
<div class="row">
<div class="columns large-6">
<label>
@lang('admin/contents.field_title')
<input type="text" name="title" placeholder="@lang('admin/contents.field_title')"
value="{{old('title', $page->title)}}" />
</label>
</div>
<div class="columns large-6">
<label>
@lang('admin/contents.field_url')
<input type="text" name="url" placeholder="@lang('admin/contents.field_url')"
value="{{old('url', $page->url)}}" />
@if (isset($errors) && $errors->has('url'))
<div class="callout alert">
{{ $errors->first('url') }}
</div>
@endif
</label>
</div>
</div>
<div class="row">
<div class="columns large-12">
<label>
<select name="status">
@foreach($contentStatuses as $status => $translation)
<option value="{{$status}}" @if(old('status', $page->status) == $status) selected @endif>
{{$translation}}
</option>
@endforeach
</select>
</label>
@if (isset($errors) && $errors->has('status'))
<div class="callout alert">
{{ $errors->first('status') }}
</div>
@endif
</div>
</div>
<div class="row">
<div class="columns large-12">
<label>
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
{{old('pageContent', $page->content)}}
</textarea>
</label>
</div>
</div>
@@ -0,0 +1,21 @@
<div class="row">
<div class="columns large-12">
<label>
@lang('admin/contents.field_meta_keywords')
<input type="text" name="meta_keywords" value="{{old('meta_keywords', $page->meta_keywords)}}"
placeholder="@lang('admin/contents.field_meta_keywords')" />
</label>
</div>
</div>
<div class="row">
<div class="columns large-12">
<label>
@lang('admin/contents.field_meta_description')
<textarea name="meta_description"
placeholder="@lang('admin/contents.field_meta_description')" rows="5">{{old('meta_description', $page->meta_description)}}
</textarea>
</label>
</div>
</div>
@@ -0,0 +1,31 @@
<div class="row">
<div class="columns large-6">
<label>
@lang('admin/contents.field_published_from')
<input type="datetime" name="published_from" value="{{old('published_from', $page->published_from)}}"
placeholder="@lang('admin/contents.field_published_from')" />
@if (isset($errors) && $errors->has('published_from'))
<div class="callout alert">
{{ $errors->first('published_from') }}
</div>
@endif
</label>
</div>
<div class="columns large-6">
<label>
@lang('admin/contents.field_published_to')
<input type="datetime" name="published_to" value="{{old('published_to', $page->published_to)}}"
placeholder="@lang('admin/contents.field_published_to')" />
@if (isset($errors) && $errors->has('published_to'))
<div class="callout alert">
{{ $errors->first('published_to') }}
</div>
@endif
</label>
</div>
</div>
@@ -0,0 +1,14 @@
@extends('admin.layout')
@section('pageName', @trans('admin/contents.new', ['name' => $moduleName]))
@section('content')
<div class="row">
<h2>@lang('admin/contents.new', ['name' => $moduleName])</h2>
</div>
<div class="row">
@include('admin.content.newForm')
</div>
@stop
@@ -0,0 +1,31 @@
@if (session('success'))
<div data-alert class="callout success">
<strong>{{ session('success') }}</strong>
</div>
@endif
@if (session('error'))
<div data-alert class="callout alert">
<strong>{{ session('error') }}</strong>
</div>
@endif
<form method="POST" action="{{route('content.newPost', ['moduleId' => $moduleId])}}">
{!! csrf_field() !!}
@include('admin.content.formInputs')
<div class="row">
<div class="columns large-12">
<button type="submit" class="button success">@lang('admin/contents.save')</button>
</div>
</div>
</form>
@section('javascripts')
<script src="{{asset('../resources/assets/js/vendor/ckeditor/ckeditor.js')}}"></script>
<script type="application/javascript">
CKEDITOR.replace ('pageContent');
</script>
@stop
@@ -0,0 +1,77 @@
@extends('admin/layout')
@section('content')
<div class="row">
<h1>@lang('admin/contents.overview')</h1>
@if (session('success'))
<div data-alert class="callout success">
<strong>{{ session('success') }}</strong>
</div>
@endif
@if (session('error'))
<div data-alert class="callout alert">
<strong>{{ session('error') }}</strong>
</div>
@endif
</div>
<div class="row" id="static-page-overview" data-equalizer>
@forelse($pages as $page)
<div class="columns large-3">
<div class="page callout" data-equalizer-watch>
<h4>{{$page->title}}</h4>
<span class="date">{{date('d.m.Y', strtotime($page->created_at))}}</span>
<span class="author">{{$page->author_name}}</span>
<br />
<span class="moduleName">@lang($page->module_name)</span>
<p class="perex">
@if (trim($page->meta_description))
{{str_limit($page->meta_description)}}
@else
{{str_limit(strip_tags($page->content))}}
@endif
</p>
@if ($page->meta_keywords)
<p class="keywords">{{$page->meta_keywords}}</p>
@endif
<p class="controls row text-center">
<a href="{{route('page.content', ['url' => $page->url])}}" class="button tiny secondary has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.viewPage')"><i class="fa fa-desktop"></i></a>
@if($page->is_homepage)
<a class="button tiny disabled"><i class="fa fa-home"></i></a>
@else
<a href="{{route('content.setHomepage', ['id' => $page->id])}}" class="button tiny success has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.setHomepage', ['name' => $page->title])"><i class="fa fa-home"></i></a>
@endif
<a href="{{route('content.edit', ['id' => $page->id])}}" class="button tiny success has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.edit', ['name' => $page->title])"><i class="fa fa-edit"></i></a>
@if($page->status == \App\Models\Content::STATUS_DRAFT)
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PUBLIC])}}" class="button tiny success confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.makePublic')"><i class="fa fa-eye"></i></a>
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PROTECTED])}}" class="button tiny warning confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.makeProtected')"><i class="fa fa-lock"></i></a>
@endif
@if(in_array($page->status, [\App\Models\Content::STATUS_PROTECTED, \App\Models\Content::STATUS_PUBLIC]))
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_DRAFT])}}" class="button tiny warning confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.makeDraft')"><i class="fa fa-eye-slash"></i></a>
@endif
<a href="{{route('content.delete', ['id' => $page->id])}}" class="button tiny alert confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.deletePage')"><i class="fa fa-remove"></i></a>
</p>
</div>
</div>
@empty
<em>@lang('admin/contents.noPagesAvailable')</em>
@endforelse
</div>
<div class="row">
{{$pages->render()}}
</div>
@stop