136 lines
3.7 KiB
PHP
136 lines
3.7 KiB
PHP
<?php
|
|
namespace Modules\StaticPages\Handlers;
|
|
|
|
use App\Enumerations\ModulesHandlerToId;
|
|
use App\Handlers\Contracts\ContentTitles;
|
|
use App\Handlers\Handler;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Request;
|
|
use App\Models\Content;
|
|
use App\Models\User;
|
|
|
|
class StaticPage extends Handler implements ContentTitles
|
|
{
|
|
public static function registerAdminMenu(User $user)
|
|
{
|
|
parent::registerAdminMenu($user);
|
|
|
|
// register links in admin menu
|
|
$menu = \Menu::instance('mainMenu');
|
|
$submenu = $menu->whereTitle(trans('admin/mainMenu.contentPages'));
|
|
|
|
$submenu->dropdown(trans('staticpages::adminMenu.staticPages'), function ($submenu) use ($user) {
|
|
$submenu->route('content.new', trans('staticpages::adminMenu.new'), ['moduleId' => self::getModuleId()], 10, ['icon' => 'fa fa-plus']);
|
|
$submenu->route('content.overview', trans('staticpages::adminMenu.overview'), ['moduleId' => self::getModuleId()], 20, ['icon' => 'fa fa-list']);
|
|
}, 15, ['icon' => 'fa fa-newspaper-o']);
|
|
}
|
|
|
|
public static function getModuleId()
|
|
{
|
|
$handler = config('staticpages.handler');
|
|
$allModules = ModulesHandlerToId::getWithTranslations();
|
|
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
|
|
|
return $moduleId;
|
|
}
|
|
|
|
/**
|
|
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function managesContent()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Save module-specific values into database
|
|
*
|
|
* @param Content $content
|
|
* @param Request $request
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function createNew(Content &$content, Request $request)
|
|
{
|
|
// There is nothing more we can save. Static pages are only text saved into database.
|
|
// This funcionality is already covered in saving content page alone.
|
|
}
|
|
|
|
/**
|
|
* 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 string $revisionId
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function edit(Content &$content, Request $request, $revisionId)
|
|
{
|
|
// There is nothing more we can save. Static pages are only text saved into database.
|
|
// This funcionality is already covered in saving content page alone.
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Install module
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function install()
|
|
{
|
|
// nothing to do
|
|
}
|
|
|
|
/**
|
|
* Load some extra data for content management form?
|
|
*
|
|
* @param Content $content
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function loadExtraData(Content $content)
|
|
{
|
|
// nothing to do
|
|
}
|
|
|
|
|
|
/**
|
|
* 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('staticpages::module.allPages');
|
|
}
|
|
|
|
/**
|
|
* Title displayed above for for creating new content page
|
|
*
|
|
* @return string
|
|
*/
|
|
public static function getCreateNewTitle()
|
|
{
|
|
return trans('staticpages::module.newPage');
|
|
}
|
|
|
|
/**
|
|
* Title for form displayed for editin content page
|
|
*
|
|
* @param Content $content
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function getEditTitle(Content $content)
|
|
{
|
|
return trans('staticpages::module.editPage');
|
|
}
|
|
} |