FEATURE: add basic article list
This commit is contained in:
@@ -103,14 +103,20 @@ class Article extends Handler
|
||||
|
||||
$menu = \Menu::instance('mainMenu');
|
||||
|
||||
$menu->dropdown(trans('article::module.name'), function ($sub) {
|
||||
$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' => 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']);
|
||||
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
||||
|
||||
$menu->dropdown(trans('article::module.comments'), function ($sub) {
|
||||
$blogSubmenu->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']);
|
||||
}, 20, ['icon' => 'fa fa-fw fa-comments-o']);
|
||||
}
|
||||
|
||||
public static function getModuleId()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
"approve" => "Schválit komentář a zobrazovat ho u článku",
|
||||
"approved" => "Komentář úspěšně schválen",
|
||||
"commentedArticle" => "Komentovaný článek",
|
||||
"createdAt" => "Vloženo :date",
|
||||
"deleted" => "Komentář smazán",
|
||||
];
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
"allArticles" => "Všechny články",
|
||||
"blog" => "Blog",
|
||||
"comments" => "Komentáře",
|
||||
"commentsOverview" => "Všechny komentáře",
|
||||
"description" => "Základní submodul pro blog. Tento modul umožňuje psát články.",
|
||||
"name" => "Článek",
|
||||
"name" => "Články",
|
||||
];
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'name' => 'Article',
|
||||
'name' => 'Articles',
|
||||
'description' => 'Base submodule for blog',
|
||||
'comments' => 'Comments',
|
||||
'commentsOverview' => 'All comments',
|
||||
'allArticles' => 'All articles'
|
||||
'allArticles' => 'All articles',
|
||||
'blog' => 'Blog'
|
||||
];
|
||||
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'ArticleList'
|
||||
'name' => 'Article list',
|
||||
'translatedName' => 'articlelist::module.name',
|
||||
'translatedDescription' => 'articlelist::module.description',
|
||||
'alias' => 'blog-articlelist',
|
||||
'handler' => \Modules\Blog\ArticleList\Handlers\ArticleList::class,
|
||||
'providers' => [\Modules\Blog\ArticleList\Providers\ArticleListServiceProvider::class],
|
||||
'files' => ['start.php'],
|
||||
'order' => 0,
|
||||
];
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php namespace Modules\Blog\ArticleList\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticleListDatabaseSeeder extends Seeder {
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace Modules\Blog\ArticleList\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;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Blog\Article\Handlers\Article;
|
||||
|
||||
class ArticleList extends Handler
|
||||
{
|
||||
public static function registerAdminMenu(User $user)
|
||||
{
|
||||
parent::registerAdminMenu($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->route('content.new', trans('articlelist::module.name'), ['id' => self::getModuleId()], 100, ['icon' => 'fa fa-fw fa-list-alt']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$articles = Content::where('module_handler', Article::class);
|
||||
|
||||
if (!Auth::user()) {
|
||||
$articles = $articles->where('status', Content::STATUS_PUBLIC);
|
||||
} else {
|
||||
$articles = $articles->whereIn('status', [Content::STATUS_PUBLIC, Content::STATUS_PROTECTED]);
|
||||
}
|
||||
|
||||
$articles = $articles->orderBy('created_at')
|
||||
->paginate(20);
|
||||
|
||||
return Controller::VisitorsView($content->template, ['page' => $content, 'articles' => $articles]);
|
||||
}
|
||||
|
||||
public static function getModuleId()
|
||||
{
|
||||
$handler = config('articlelist.handler');
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
||||
|
||||
return $moduleId;
|
||||
}
|
||||
|
||||
public static function supportCategories()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Install module
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function install()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php namespace Modules\Blog\ArticleList\Providers;
|
||||
|
||||
use App\Handlers\Registrators\TemplateRegistrator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use InvalidArgumentException;
|
||||
use Modules\Blog\ArticleList\Handlers\ArticleList;
|
||||
|
||||
class ArticleListServiceProvider extends ServiceProvider {
|
||||
|
||||
@@ -30,7 +33,6 @@ class ArticleListServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,12 +42,8 @@ class ArticleListServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../Config/config.php' => config_path('articlelist.php'),
|
||||
]);
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__.'/../Config/config.php', 'articlelist'
|
||||
);
|
||||
$this->publishes([__DIR__.'/../Config/config.php' => config_path('articlelist.php')]);
|
||||
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'articlelist');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,16 +54,30 @@ class ArticleListServiceProvider extends ServiceProvider {
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = base_path('resources/views/modules/articlelist');
|
||||
|
||||
$sourcePath = __DIR__.'/../Resources/views';
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
]);
|
||||
$this->publishes([$sourcePath => $viewPath]);
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/articlelist';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), 'articlelist');
|
||||
|
||||
|
||||
/**
|
||||
* @var $registrator TemplateRegistrator
|
||||
*/
|
||||
try {
|
||||
// setup some global variables
|
||||
$registrator = $this->app->make('registerTemplateDir');
|
||||
$registrator->setBaseDirectory('resources/views/modules/articlelist/visitor');
|
||||
$registrator->setNamespace('articlelist');
|
||||
$registrator->setModuleId(ArticleList::getModuleId());
|
||||
|
||||
// register path with current template name
|
||||
$registrator->register(config('app.theme'), 'articlelist::module.templatePath');
|
||||
} catch (InvalidArgumentException $e) {
|
||||
// ignore this exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
"description" => "Modul pro zobrazování seznamu článků na webu.",
|
||||
"name" => "Seznam článků",
|
||||
];
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'name' => 'Article list',
|
||||
'description' => 'Module for displaying list of articles on web',
|
||||
];
|
||||
@@ -1,11 +0,0 @@
|
||||
@extends('articlelist::layouts.master')
|
||||
|
||||
@section('content')
|
||||
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>
|
||||
This view is loaded from module: {!! config('articlelist.name') !!}
|
||||
</p>
|
||||
|
||||
@stop
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Module ArticleList</title>
|
||||
</head>
|
||||
<body>
|
||||
@yield('content')
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
return [
|
||||
'name' => 'Blog',
|
||||
'description' => '',
|
||||
'hasSubmodules' => true,
|
||||
'name' => 'Blog',
|
||||
'translatedName' => 'article::module.blog',
|
||||
'description' => 'article.module.blogDescription',
|
||||
'hasSubmodules' => true,
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
{{dd($page)}}
|
||||
Reference in New Issue
Block a user