153 lines
4.4 KiB
PHP
Executable File
153 lines
4.4 KiB
PHP
Executable File
<?php
|
|
namespace Modules\Blog\Article\Handlers;
|
|
|
|
use App\CMS\Contracts\Content\AdvancedContentModifier;
|
|
use App\CMS\Contracts\Content\ContentTitles;
|
|
use App\CMS\Contracts\Modules\InstallableModule;
|
|
use App\CMS\Handlers\AdminHandler;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Request;
|
|
use App\Models\ActionLog\ActionLogType;
|
|
use App\Models\Content\Content;
|
|
use App\Models\Module;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Collection;
|
|
use Modules\Blog\Article\Entities\Comment;
|
|
|
|
class Article extends AdminHandler implements ContentTitles, AdvancedContentModifier, InstallableModule
|
|
{
|
|
public static function getExtendedFormInputsCreate()
|
|
{
|
|
$sections = parent::getExtendedFormInputsCreate();
|
|
|
|
$sections['basicInfo'] = 'article::admin.content.basicInfo';
|
|
|
|
return $sections;
|
|
}
|
|
|
|
public static function getExtendedFormInputsEdit()
|
|
{
|
|
return self::getExtendedFormInputsCreate();
|
|
}
|
|
|
|
/**
|
|
* Register admin menu
|
|
*
|
|
* @param User $user
|
|
*/
|
|
public static function registerAdminMenu(User $user)
|
|
{
|
|
$menu = \Menu::instance('mainMenu');
|
|
|
|
$blogSubmenu = $menu->whereTitle(trans('article::module.blog'));
|
|
if (!$blogSubmenu) {
|
|
$blogSubmenu = $menu->dropdown(trans('article::module.blog'), function ($sub) {
|
|
}, 20, ['icon' => 'fa fa-fw fa-book']);
|
|
}
|
|
|
|
$blogSubmenu->dropdown(trans('article::module.name'), function ($sub) {
|
|
$sub->route('content.new', trans('article::article.new'), ['id' => config('article.alias')], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
|
$sub->route('content.overview', trans('article::article.overview'), ['id' => config('article.alias')], 30, ['icon' => 'fa fa-fw fa-book']);
|
|
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
|
|
|
$blogSubmenu->route('comments.overview', trans('article::module.commentsOverview'), [], 20, ['icon' => 'fa fa-fw fa-commenting-o']);
|
|
}
|
|
|
|
/**
|
|
* Install module
|
|
*/
|
|
public static function install()
|
|
{
|
|
$types = [
|
|
[
|
|
'string_id' => 'commentCreated',
|
|
'name' => 'article::comments.events.names.commentCreated',
|
|
'value' => 'article::comments.events.descriptions.commentCreated',
|
|
],
|
|
[
|
|
'string_id' => 'commentDeleted',
|
|
'name' => 'article::comments.events.names.commentDeleted',
|
|
'value' => 'article::comments.events.descriptions.commentDeleted',
|
|
],
|
|
[
|
|
'string_id' => 'commentApproved',
|
|
'name' => 'article::comments.events.names.commentApproved',
|
|
'value' => 'article::comments.events.descriptions.commentApproved',
|
|
],
|
|
|
|
];
|
|
foreach ($types as $type) {
|
|
ActionLogType::create($type);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Uninstalls module
|
|
*
|
|
* @param Module $module
|
|
*
|
|
* @return mixed|void
|
|
*/
|
|
public static function uninstall(Module $module)
|
|
{
|
|
ActionLogType::whereIn('string_id', ['commentCreated', 'commentDeleted', 'commentApproved'])
|
|
->delete();
|
|
}
|
|
|
|
/**
|
|
* Get translated title for pages overview of given type.
|
|
*
|
|
* This value is used for rendering list of all content pages of given type in administration.
|
|
*
|
|
* @return string
|
|
*/
|
|
public static function getOverviewTitle()
|
|
{
|
|
return trans('article::module.allArticles');
|
|
}
|
|
|
|
/**
|
|
* Title displayed above for for creating new content page
|
|
*
|
|
* @return string
|
|
*/
|
|
public static function getCreateNewTitle()
|
|
{
|
|
return trans('article::module.newArticle');
|
|
}
|
|
|
|
/**
|
|
* Title for form displayed for editin content page
|
|
*
|
|
* @param Content $content
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function getEditTitle(Content $content)
|
|
{
|
|
return trans('article::module.editArticle');
|
|
}
|
|
|
|
/**
|
|
* Method called right after content page is marked as deleted
|
|
*
|
|
* This method is supposed to clean after "deleted" page.
|
|
*
|
|
* @param Content $content
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function delete(Content $content)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Does this module support categories?
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public static function supportCategories()
|
|
{
|
|
return true;
|
|
}
|
|
} |