FEATURE: add comments into articles
This commit is contained in:
@@ -93,6 +93,10 @@ class Article extends Handler
|
|||||||
$sub->route('content.new', trans('article::article.new'), ['id' => self::getModuleId()], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
$sub->route('content.new', trans('article::article.new'), ['id' => self::getModuleId()], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
||||||
$sub->route('content.overview', trans('article::article.overview'), ['id' => self::getModuleId()], 30, ['icon' => 'fa fa-fw fa-book']);
|
$sub->route('content.overview', trans('article::article.overview'), ['id' => self::getModuleId()], 30, ['icon' => 'fa fa-fw fa-book']);
|
||||||
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
||||||
|
|
||||||
|
$menu->dropdown(trans('article::module.comments'), function ($sub) {
|
||||||
|
$sub->route('comments.overview', trans('article::module.commentsOverview'), [], 10, ['icon' => 'fa fa-fw fa-commenting-o']);
|
||||||
|
}, 10, ['icon' => 'fa fa-fw fa-comments-o']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getModuleId()
|
public static function getModuleId()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
Route::group([
|
Route::group([
|
||||||
'middleware' => 'web',
|
'middleware' => 'web',
|
||||||
'prefix' => 'article',
|
'prefix' => 'article',
|
||||||
@@ -23,3 +22,15 @@ Route::group([
|
|||||||
Route::get('/delete/{id}', 'EditCategory@delete')
|
Route::get('/delete/{id}', 'EditCategory@delete')
|
||||||
->name('article.delete');
|
->name('article.delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// routes for comments
|
||||||
|
|
||||||
|
Route::group([
|
||||||
|
'middleware' => 'web',
|
||||||
|
'prefix' => 'comments',
|
||||||
|
'namespace' => 'Modules\Blog\Article\Http\Controllers'
|
||||||
|
], function () {
|
||||||
|
|
||||||
|
Route::get('/', 'CommentsOverview@getOverview')
|
||||||
|
->name('comments.overview');
|
||||||
|
});
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'name' => 'Article',
|
'name' => 'Article',
|
||||||
'description' => 'Base submodule for blog'
|
'description' => 'Base submodule for blog',
|
||||||
|
'comments' => 'Comments',
|
||||||
|
'commentsOverview' => 'All comments'
|
||||||
];
|
];
|
||||||
@@ -1,69 +1,69 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="columns large-6">
|
<div class="col-lg-6">
|
||||||
<label>
|
<input type="text" name="title" required class="form-control slug-source"
|
||||||
@lang('admin/contents.field_title')
|
placeholder="@lang('admin/contents.field_title')"
|
||||||
|
|
||||||
<input type="text" name="title" class="slug-source" placeholder="@lang('admin/contents.field_title')"
|
|
||||||
value="{{old('title', $page->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')"
|
@include('admin.snippets.hasError', ['field' => 'title'])
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
|
||||||
|
<input type="text" name="url" required class="form-control slug-target"
|
||||||
|
placeholder="@lang('admin/contents.field_url')"
|
||||||
value="{{old('url', $page->url)}}" />
|
value="{{old('url', $page->url)}}" />
|
||||||
|
|
||||||
@if (isset($errors) && $errors->has('url'))
|
@include('admin.snippets.hasError', ['field' => 'url'])
|
||||||
<div class="callout alert">
|
|
||||||
{{ $errors->first('url') }}
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
<div class="col-lg-2 text-center">
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="column large-2 text-center">
|
|
||||||
<label>
|
<label>
|
||||||
@lang('admin/contents.lockUrl')<br />
|
<input class="checkbox" value="1" id="lockUrl"
|
||||||
|
|
||||||
<input type="checkbox" value="1" id="lockUrl"
|
|
||||||
@if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked
|
@if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked
|
||||||
@endif name="lockUrl" />
|
@endif name="lockUrl" type="checkbox">
|
||||||
|
<span>@lang('admin/contents.lockUrl')</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="columns large-6">
|
<div class="col-lg-6">
|
||||||
<label>
|
<select class="form-control" name="status">
|
||||||
<select name="status">
|
|
||||||
@foreach($contentStatuses as $status => $translation)
|
@foreach($contentStatuses as $status => $translation)
|
||||||
<option value="{{$status}}" @if(old('status', $page->status) == $status) selected @endif>
|
<option value="{{$status}}" @if(old('status', $page->status) == $status) selected @endif>
|
||||||
{{$translation}}
|
{{$translation}}
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</label>
|
|
||||||
|
|
||||||
@if (isset($errors) && $errors->has('status'))
|
@include('admin.snippets.hasError', ['field' => 'status'])
|
||||||
<div class="callout alert">
|
|
||||||
{{ $errors->first('status') }}
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
<div class="col-lg-4">
|
||||||
|
<select class="form-control" name="parentPage">
|
||||||
|
<option value="">@lang('admin/contents.noParentPage')</option>
|
||||||
|
|
||||||
|
@foreach($rootPages as $rootPage)
|
||||||
|
<option value="{{$rootPage->id}}"
|
||||||
|
@if(old('parent_page', $page->parent_id) == $rootPage->id) selected @endif>
|
||||||
|
{{$rootPage->title}}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
|
||||||
|
@include('admin.snippets.hasError', ['field' => 'parentPage'])
|
||||||
</div>
|
</div>
|
||||||
<div class="column large-6">
|
|
||||||
|
<div class="col-lg-2 text-center">
|
||||||
<label>
|
<label>
|
||||||
@lang('article::article.allowComments')
|
<input class="checkbox" value="1"
|
||||||
<input type="checkbox" value="1" @if(old('allowComments', isset($page->module_settings->allowComments) ? $page->module_settings->allowComments : true)) checked @endif name="allowComments" />
|
@if(old('allowComments', isset($page->module_settings->allowComments) ? $page->module_settings->allowComments : true)) checked
|
||||||
|
@endif name="allowComments" type="checkbox">
|
||||||
|
<span>@lang('article::article.allowComments')</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if($module->support_categories && count($categories))
|
@if($module->support_categories && count($categories))
|
||||||
<div class="column large-12">
|
<div class="col-lg-12">
|
||||||
<label>
|
<select class="form-control" name="category">
|
||||||
@lang('admin/contents.category')
|
<option value="">@lang('admin/contents.noCategory')</option>
|
||||||
|
|
||||||
<select name="category">
|
|
||||||
<option value=""> ---</option>
|
|
||||||
@foreach($categories as $category)
|
@foreach($categories as $category)
|
||||||
<option value="{{$category->id}}"
|
<option value="{{$category->id}}"
|
||||||
@if($category->id == old('category', $page->category_id)) selected @endif>
|
@if($category->id == old('category', $page->category_id)) selected @endif>
|
||||||
@@ -71,19 +71,19 @@
|
|||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="columns large-12">
|
<div class="col-lg-12">
|
||||||
<label>
|
|
||||||
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
|
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
|
||||||
{{old('pageContent', $page->content)}}
|
{{old('pageContent', $page->content)}}
|
||||||
</textarea>
|
</textarea>
|
||||||
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "pingpong-modules/article",
|
|
||||||
"description": "",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Pingpong Labs",
|
|
||||||
"email": "pingpong.labs@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Modules\\Article\\": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => 'Comments',
|
|
||||||
'translatedName' => 'comments::module.name',
|
|
||||||
'translatedDescription' => 'comments::module.description',
|
|
||||||
'alias' => 'blog-comments',
|
|
||||||
'handler' => \Modules\Blog\Comments\Handlers\Comments::class,
|
|
||||||
'providers' => [\Modules\Blog\Comments\Providers\CommentsServiceProvider::class],
|
|
||||||
'files' => ['start.php'],
|
|
||||||
'order' => 0,
|
|
||||||
];
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Modules\Blog\Comments\Handlers;
|
|
||||||
|
|
||||||
use App\Enumerations\ModulesHandlerToId;
|
|
||||||
use App\Handlers\BaseHandler;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class Comments extends BaseHandler
|
|
||||||
{
|
|
||||||
public static function getModuleId()
|
|
||||||
{
|
|
||||||
$handler = config('comments.handler');
|
|
||||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
|
||||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
|
||||||
|
|
||||||
return $moduleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install module
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function install()
|
|
||||||
{
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function registerAdminMenu(User $user)
|
|
||||||
{
|
|
||||||
$menu = \Menu::instance('mainMenu');
|
|
||||||
|
|
||||||
$menu->dropdown(trans('comments::module.name'), function ($sub) {
|
|
||||||
$sub->route('comments.overview', trans('comments::module.overview'), [], 10, ['icon' => 'fa fa-fw fa-commenting-o']);
|
|
||||||
}, 10, ['icon' => 'fa fa-fw fa-comments-o']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php namespace Modules\Blog\Comments\Http\Controllers;
|
|
||||||
|
|
||||||
use Pingpong\Modules\Routing\Controller;
|
|
||||||
|
|
||||||
class CommentsController extends Controller {
|
|
||||||
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
return view('articlelist::index');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
Route::group(['middleware' => 'web', 'prefix' => 'comments', 'namespace' => 'Modules\Blog\Comments\Http\Controllers'], function()
|
|
||||||
{
|
|
||||||
Route::get('/', 'CommentsController@index')->name('comments.overview');
|
|
||||||
});
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php namespace Modules\Blog\Comments\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
|
|
||||||
class CommentsServiceProvider extends ServiceProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if loading of the provider is deferred.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $defer = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Boot the application events.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function boot()
|
|
||||||
{
|
|
||||||
$this->registerTranslations();
|
|
||||||
$this->registerConfig();
|
|
||||||
$this->registerViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the service provider.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function register()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register config.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function registerConfig()
|
|
||||||
{
|
|
||||||
$this->publishes([__DIR__.'/../Config/config.php' => config_path('comments.php')]);
|
|
||||||
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'comments');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register views.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function registerViews()
|
|
||||||
{
|
|
||||||
$viewPath = base_path('resources/views/modules/comments');
|
|
||||||
$sourcePath = __DIR__.'/../Resources/views';
|
|
||||||
|
|
||||||
$this->publishes([$sourcePath => $viewPath]);
|
|
||||||
|
|
||||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
|
||||||
return $path . '/modules/comments';
|
|
||||||
}, \Config::get('view.paths')), [$sourcePath]), 'comments');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register translations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function registerTranslations()
|
|
||||||
{
|
|
||||||
$langPath = base_path('resources/lang/modules/comments');
|
|
||||||
|
|
||||||
if (is_dir($langPath)) {
|
|
||||||
$this->loadTranslationsFrom($langPath, 'comments');
|
|
||||||
} else {
|
|
||||||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'comments');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the services provided by the provider.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function provides()
|
|
||||||
{
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'name' => 'Comments',
|
|
||||||
'description' => "Bring comment support to blog module",
|
|
||||||
'overview' => 'All comments'
|
|
||||||
];
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Register Namespaces And Routes
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| When a module starting, this file will executed automatically. This helps
|
|
||||||
| to register some namespaces like translator or view. Also this file
|
|
||||||
| will load the routes file for each module. You may also modify
|
|
||||||
| this file as you want.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
require __DIR__ . '/Http/routes.php';
|
|
||||||
Reference in New Issue
Block a user