FEATURE: add support for writing blog posts
This commit is contained in:
@@ -3,6 +3,7 @@ namespace Modules\Blog\Article\Handlers;
|
|||||||
|
|
||||||
use App\Enumerations\ModulesHandlerToId;
|
use App\Enumerations\ModulesHandlerToId;
|
||||||
use App\Handlers\Handler;
|
use App\Handlers\Handler;
|
||||||
|
use App\Http\Controllers\Admin\EditContent;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Content;
|
use App\Models\Content;
|
||||||
@@ -23,15 +24,18 @@ class Article extends Handler
|
|||||||
return Controller::VisitorsView($content->template, ['page' => $content]);
|
return Controller::VisitorsView($content->template, ['page' => $content]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static function getExtendedFormInputsCreate()
|
||||||
* Load some extra data for content management form?
|
|
||||||
*
|
|
||||||
* @param Content $content
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function loadExtraData(Content $content)
|
|
||||||
{
|
{
|
||||||
|
$sections = parent::getExtendedFormInputsCreate();
|
||||||
|
|
||||||
|
$sections['basicInfo'] = 'article::admin.content.basicInfo';
|
||||||
|
|
||||||
|
return $sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getExtendedFormInputsEdit()
|
||||||
|
{
|
||||||
|
return self::getExtendedFormInputsCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,6 +49,7 @@ class Article extends Handler
|
|||||||
*/
|
*/
|
||||||
public static function createNew(Content &$content, Request $request)
|
public static function createNew(Content &$content, Request $request)
|
||||||
{
|
{
|
||||||
|
$content->module_settings = json_encode(['allowComments' => (int)$request->has('allowComments')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +66,17 @@ class Article extends Handler
|
|||||||
*/
|
*/
|
||||||
public static function edit(Content &$content, Request $request, $revisionID)
|
public static function edit(Content &$content, Request $request, $revisionID)
|
||||||
{
|
{
|
||||||
// TODO: Implement edit() method.
|
$fields = ['allowComments' => 'allowComments'];
|
||||||
|
|
||||||
|
// get data and try to save them
|
||||||
|
$data = EditContent::getFields($request, $fields);
|
||||||
|
|
||||||
|
$data['allowComments'] = (int) $data['allowComments'];
|
||||||
|
|
||||||
|
list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID);
|
||||||
|
|
||||||
|
// return amount of changed columns
|
||||||
|
return $changedColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
|
'allowComments' => 'Allow comments?',
|
||||||
|
'new' => 'Write new',
|
||||||
|
'overview' => 'All articles'
|
||||||
];
|
];
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="columns large-6">
|
||||||
|
<label>
|
||||||
|
@lang('admin/contents.field_title')
|
||||||
|
|
||||||
|
<input type="text" name="title" class="slug-source" placeholder="@lang('admin/contents.field_title')"
|
||||||
|
value="{{old('title', $page->title)}}" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="columns large-4">
|
||||||
|
<label>
|
||||||
|
@lang('admin/contents.field_url')
|
||||||
|
|
||||||
|
<input type="text" name="url" class="slug-target" 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 class="column large-2 text-center">
|
||||||
|
<label>
|
||||||
|
@lang('admin/contents.lockUrl')<br />
|
||||||
|
|
||||||
|
<input type="checkbox" value="1" id="lockUrl"
|
||||||
|
@if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked
|
||||||
|
@endif name="lockUrl" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="columns large-6">
|
||||||
|
<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 class="column large-6">
|
||||||
|
<label>
|
||||||
|
@lang('article::article.allowComments')
|
||||||
|
<input type="checkbox" value="1" @if(old('allowComments', isset($page->module_settings->allowComments) ? $page->module_settings->allowComments : true)) checked @endif name="allowComments" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($module->support_categories && count($categories))
|
||||||
|
<div class="column large-12">
|
||||||
|
<label>
|
||||||
|
@lang('admin/contents.category')
|
||||||
|
|
||||||
|
<select name="category">
|
||||||
|
<option value=""> ---</option>
|
||||||
|
@foreach($categories as $category)
|
||||||
|
<option value="{{$category->id}}"
|
||||||
|
@if($category->id == old('category', $page->category_id)) selected @endif>
|
||||||
|
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
</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>
|
||||||
Reference in New Issue
Block a user