diff --git a/modules/Blog/Article/Config/config.php b/modules/Blog/Article/Config/config.php new file mode 100644 index 00000000..f509e809 --- /dev/null +++ b/modules/Blog/Article/Config/config.php @@ -0,0 +1,12 @@ + 'Articles', + 'translatedName' => 'article::module.name', + 'translatedDescription' => 'article::module.description', + 'alias' => 'blog-article', + 'handler' => \Modules\Blog\Article\Handlers\Article::class, + 'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class], + 'files' => ['start.php'], + 'order' => 0, +]; \ No newline at end of file diff --git a/modules/Blog/Article/Handlers/Article.php b/modules/Blog/Article/Handlers/Article.php new file mode 100644 index 00000000..aa8ec0c8 --- /dev/null +++ b/modules/Blog/Article/Handlers/Article.php @@ -0,0 +1,100 @@ +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() + { + } +} \ No newline at end of file diff --git a/modules/Blog/Article/Http/Controllers/.gitkeep b/modules/Blog/Article/Http/Controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/Article/Http/routes.php b/modules/Blog/Article/Http/routes.php new file mode 100644 index 00000000..b9ad36f4 --- /dev/null +++ b/modules/Blog/Article/Http/routes.php @@ -0,0 +1,25 @@ + 'web', + 'prefix' => 'article', + 'namespace' => 'Modules\Blog\Article\Http\Controllers' + ], function () { + Route::get('/', 'CategoriesOverview@getOverview') + ->name('article.overview'); + + Route::get('/new', 'CreateNewCategory@getNew') + ->name('article.new'); + + Route::post('/new', 'CreateNewCategory@postNew') + ->name('article.postNew'); + + Route::get('/edit/{id}', 'EditCategory@getEdit') + ->name('article.edit'); + + Route::post('/edit/{id}', 'EditCategory@postEdit') + ->name('article.postEdit'); + + Route::get('/delete/{id}', 'EditCategory@delete') + ->name('article.delete'); +}); \ No newline at end of file diff --git a/modules/Blog/Article/Providers/ArticleServiceProvider.php b/modules/Blog/Article/Providers/ArticleServiceProvider.php new file mode 100644 index 00000000..888c0ed8 --- /dev/null +++ b/modules/Blog/Article/Providers/ArticleServiceProvider.php @@ -0,0 +1,94 @@ +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('article.php'), + ]); + $this->mergeConfigFrom( + __DIR__.'/../Config/config.php', 'article' + ); + } + + /** + * Register views. + * + * @return void + */ + public function registerViews() + { + $viewPath = base_path('resources/views/modules/article'); + $sourcePath = __DIR__.'/../Resources/views'; + + $this->publishes([$sourcePath => $viewPath]); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/article'; + }, \Config::get('view.paths')), [$sourcePath]), 'article'); + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = base_path('resources/lang/modules/article'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'article'); + } else { + $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'article'); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + +} diff --git a/modules/Blog/Article/Resources/lang/en/article.php b/modules/Blog/Article/Resources/lang/en/article.php new file mode 100644 index 00000000..05e0b10e --- /dev/null +++ b/modules/Blog/Article/Resources/lang/en/article.php @@ -0,0 +1,4 @@ + 'Article', + 'description' => 'Base submodule for blog' +]; \ No newline at end of file diff --git a/modules/Blog/Article/Resources/views/.gitkeep b/modules/Blog/Article/Resources/views/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/Article/composer.json b/modules/Blog/Article/composer.json new file mode 100644 index 00000000..a7baacdf --- /dev/null +++ b/modules/Blog/Article/composer.json @@ -0,0 +1,15 @@ +{ + "name": "pingpong-modules/article", + "description": "", + "authors": [ + { + "name": "Pingpong Labs", + "email": "pingpong.labs@gmail.com" + } + ], + "autoload": { + "psr-4": { + "Modules\\Article\\": "" + } + } +} \ No newline at end of file diff --git a/modules/Blog/Article/start.php b/modules/Blog/Article/start.php new file mode 100644 index 00000000..7be329cb --- /dev/null +++ b/modules/Blog/Article/start.php @@ -0,0 +1,15 @@ + 'ArticleList' +]; \ No newline at end of file diff --git a/modules/Blog/ArticleList/Console/.gitkeep b/modules/Blog/ArticleList/Console/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Database/Migrations/.gitkeep b/modules/Blog/ArticleList/Database/Migrations/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Database/Seeders/.gitkeep b/modules/Blog/ArticleList/Database/Seeders/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Database/Seeders/ArticleListDatabaseSeeder.php b/modules/Blog/ArticleList/Database/Seeders/ArticleListDatabaseSeeder.php new file mode 100644 index 00000000..5daa172d --- /dev/null +++ b/modules/Blog/ArticleList/Database/Seeders/ArticleListDatabaseSeeder.php @@ -0,0 +1,20 @@ +call("OthersTableSeeder"); + } + +} \ No newline at end of file diff --git a/modules/Blog/ArticleList/Entities/.gitkeep b/modules/Blog/ArticleList/Entities/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Http/Controllers/.gitkeep b/modules/Blog/ArticleList/Http/Controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Http/Controllers/ArticleListController.php b/modules/Blog/ArticleList/Http/Controllers/ArticleListController.php new file mode 100644 index 00000000..df742323 --- /dev/null +++ b/modules/Blog/ArticleList/Http/Controllers/ArticleListController.php @@ -0,0 +1,12 @@ + 'web', 'prefix' => 'articlelist', 'namespace' => 'Modules\Blog\ArticleList\Http\Controllers'], function() +{ + Route::get('/', 'ArticleListController@index'); +}); \ No newline at end of file diff --git a/modules/Blog/ArticleList/Providers/.gitkeep b/modules/Blog/ArticleList/Providers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Providers/ArticleListServiceProvider.php b/modules/Blog/ArticleList/Providers/ArticleListServiceProvider.php new file mode 100644 index 00000000..510a581e --- /dev/null +++ b/modules/Blog/ArticleList/Providers/ArticleListServiceProvider.php @@ -0,0 +1,97 @@ +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('articlelist.php'), + ]); + $this->mergeConfigFrom( + __DIR__.'/../Config/config.php', 'articlelist' + ); + } + + /** + * Register views. + * + * @return void + */ + public function registerViews() + { + $viewPath = base_path('resources/views/modules/articlelist'); + + $sourcePath = __DIR__.'/../Resources/views'; + + $this->publishes([ + $sourcePath => $viewPath + ]); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/articlelist'; + }, \Config::get('view.paths')), [$sourcePath]), 'articlelist'); + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = base_path('resources/lang/modules/articlelist'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'articlelist'); + } else { + $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'articlelist'); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + +} diff --git a/modules/Blog/ArticleList/Repositories/.gitkeep b/modules/Blog/ArticleList/Repositories/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Resources/lang/.gitkeep b/modules/Blog/ArticleList/Resources/lang/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Resources/views/.gitkeep b/modules/Blog/ArticleList/Resources/views/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/Resources/views/index.blade.php b/modules/Blog/ArticleList/Resources/views/index.blade.php new file mode 100644 index 00000000..bbb855f0 --- /dev/null +++ b/modules/Blog/ArticleList/Resources/views/index.blade.php @@ -0,0 +1,11 @@ +@extends('articlelist::layouts.master') + +@section('content') + +
+ This view is loaded from module: {!! config('articlelist.name') !!} +
+ +@stop \ No newline at end of file diff --git a/modules/Blog/ArticleList/Resources/views/layouts/master.blade.php b/modules/Blog/ArticleList/Resources/views/layouts/master.blade.php new file mode 100644 index 00000000..0519dc92 --- /dev/null +++ b/modules/Blog/ArticleList/Resources/views/layouts/master.blade.php @@ -0,0 +1,12 @@ + + + + + + +