100 lines
2.6 KiB
PHP
100 lines
2.6 KiB
PHP
<?php
|
|
namespace Modules\Blog\Article\Handlers;
|
|
|
|
use App\Enumerations\ModulesHandlerToId;
|
|
use App\Handlers\Handler;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Request;
|
|
use App\Models\Content;
|
|
use App\Models\User;
|
|
|
|
class Article extends Handler
|
|
{
|
|
/**
|
|
* Render given module into visitor area.
|
|
*
|
|
* @param Content $content DB model from table contents
|
|
* @param array $parameters parameters used for modifications/custom settings of given model
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function render(Content $content, $parameters)
|
|
{
|
|
return Controller::VisitorsView($content->template, ['page' => $content]);
|
|
}
|
|
|
|
/**
|
|
* Load some extra data for content management form?
|
|
*
|
|
* @param Content $content
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function loadExtraData(Content $content)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
// TODO: Implement edit() method.
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param User $user
|
|
*/
|
|
public static function registerAdminMenu(User $user)
|
|
{
|
|
parent::registerAdminMenu($user);
|
|
|
|
$menu = \Menu::instance('mainMenu');
|
|
|
|
$menu->dropdown(trans('article::module.name'), function ($sub) {
|
|
$sub->route('article.new', trans('article::article.new'), [], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
|
$sub->route('article.overview', trans('article::article.overview'), [], 30, ['icon' => 'fa fa-fw fa-book']);
|
|
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
|
}
|
|
|
|
public static function getModuleId()
|
|
{
|
|
$handler = config('article.handler');
|
|
$allModules = ModulesHandlerToId::getWithTranslations();
|
|
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
|
|
|
return $moduleId;
|
|
}
|
|
|
|
/**
|
|
* Install module
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function install()
|
|
{
|
|
}
|
|
} |