diff --git a/app/Handlers/Handler.php b/app/Handlers/Handler.php index 11d0b742..63ddab59 100644 --- a/app/Handlers/Handler.php +++ b/app/Handlers/Handler.php @@ -56,6 +56,10 @@ abstract class Handler extends BaseHandler implements AppHandler // temporarily nothing to do } + public static function loadExtraData(Content $content) { + // temporarily nothing to do + } + public static function getExtendedFormInputsEdit() { return self::getExtendedFormInputsCreate(); diff --git a/app/Handlers/Registrators/TemplateRegistrator.php b/app/Handlers/Registrators/TemplateRegistrator.php index 0a7f5480..6788df67 100644 --- a/app/Handlers/Registrators/TemplateRegistrator.php +++ b/app/Handlers/Registrators/TemplateRegistrator.php @@ -73,6 +73,7 @@ class TemplateRegistrator public function unsetNamespace() { $this->namespace = null; + $this->setModuleId(null); } /** @@ -95,6 +96,8 @@ class TemplateRegistrator // register path $this->registerPath($this->registeredPath, $name); + + $this->unsetNamespace(); } /** @@ -194,6 +197,8 @@ class TemplateRegistrator 'editable' => 1 ]; + echo 'ukladam do db '.$templateName."\n"; + // save template into database $newTemplate = Template::create($params); diff --git a/app/Http/Controllers/Admin/CreateNewContent.php b/app/Http/Controllers/Admin/CreateNewContent.php index cf71a7e8..1beee33b 100644 --- a/app/Http/Controllers/Admin/CreateNewContent.php +++ b/app/Http/Controllers/Admin/CreateNewContent.php @@ -109,7 +109,7 @@ class CreateNewContent extends Controller $page->status = $request->status; $page->template = $request->template; $page->module_handler = $module->handler; - $page->category_id = $request->category; + $page->category_id = (int)$request->category > 0 ? $request->category : null; if ($request->parentPage) { $page->parent_id = $request->parentPage; 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..90d0f39d --- /dev/null +++ b/modules/Blog/Article/Handlers/Article.php @@ -0,0 +1,115 @@ +template, ['page' => $content]); + } + + public static function getExtendedFormInputsCreate() + { + $sections = parent::getExtendedFormInputsCreate(); + + $sections['basicInfo'] = 'article::admin.content.basicInfo'; + + return $sections; + } + + public static function getExtendedFormInputsEdit() + { + return self::getExtendedFormInputsCreate(); + } + + /** + * 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) + { + $content->module_settings = json_encode(['allowComments' => (int)$request->has('allowComments')]); + } + + /** + * 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) + { + $fields = ['allowComments' => 'allowComments']; + + // get data and try to save them + $data = EditContent::getFields($request, $fields); + + $data['allowComments'] = (int)$data['allowComments']; + + list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID); + + // return amount of changed columns + return $changedColumns; + } + + /** + * + * @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('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']); + } + + 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..0d52f03c --- /dev/null +++ b/modules/Blog/Article/Providers/ArticleServiceProvider.php @@ -0,0 +1,109 @@ +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'); + + /** + * @var $registrator TemplateRegistrator + */ + try { + // setup some global variables + $registrator = $this->app->make('registerTemplateDir'); + $registrator->setBaseDirectory('resources/views/modules/article/visitor'); + $registrator->setNamespace('article'); + $registrator->setModuleId(Article::getModuleId()); + + // register path with current template name + $registrator->register(config('app.theme'), 'article::admin/adminMenu.templatePath'); + } catch (InvalidArgumentException $e) { + // ignore this exception + } + } + + /** + * 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..2d1e8b44 --- /dev/null +++ b/modules/Blog/Article/Resources/lang/en/article.php @@ -0,0 +1,6 @@ + 'Allow comments?', + 'new' => 'Write new', + 'overview' => 'All articles' +]; \ No newline at end of file diff --git a/modules/Blog/Article/Resources/lang/en/module.php b/modules/Blog/Article/Resources/lang/en/module.php new file mode 100644 index 00000000..a448c978 --- /dev/null +++ b/modules/Blog/Article/Resources/lang/en/module.php @@ -0,0 +1,5 @@ + 'Article', + 'description' => 'Base submodule for blog' +]; \ No newline at end of file diff --git a/modules/Blog/Article/Resources/views/admin/content/basicInfo.blade.php b/modules/Blog/Article/Resources/views/admin/content/basicInfo.blade.php new file mode 100644 index 00000000..e150c58f --- /dev/null +++ b/modules/Blog/Article/Resources/views/admin/content/basicInfo.blade.php @@ -0,0 +1,89 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + @if (isset($errors) && $errors->has('status')) +
+ {{ $errors->first('status') }} +
+ @endif +
+
+ +
+ + @if($module->support_categories && count($categories)) +
+ +
+ + @endif +
+ +
+
+ +
+
\ No newline at end of file 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') + +

Hello World

+ +

+ 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 @@ + + + + + + + Module ArticleList + + + @yield('content') + + \ No newline at end of file diff --git a/modules/Blog/ArticleList/Tests/.gitkeep b/modules/Blog/ArticleList/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/ArticleList/start.php b/modules/Blog/ArticleList/start.php new file mode 100644 index 00000000..7be329cb --- /dev/null +++ b/modules/Blog/ArticleList/start.php @@ -0,0 +1,15 @@ + 'Comments', + 'translatedName' => 'comments::module.name', + 'translatedDescription' => 'comments::module.description', + 'alias' => 'blog-comments', + 'handler' => \Modules\Blog\Comments\Handlers\Comments::class, + 'providers' => [\Modules\Blog\Comments\Providers\CommentsServiceProvider::class], + 'files' => ['start.php'], + 'order' => 0, +]; \ No newline at end of file diff --git a/modules/Blog/Comments/Entities/.gitkeep b/modules/Blog/Comments/Entities/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/Comments/Handlers/Comments.php b/modules/Blog/Comments/Handlers/Comments.php new file mode 100644 index 00000000..b2674d0d --- /dev/null +++ b/modules/Blog/Comments/Handlers/Comments.php @@ -0,0 +1,37 @@ +dropdown(trans('comments::module.name'), function ($sub) { + $sub->route('comments.overview', trans('comments::module.overview'), [], 10, ['icon' => 'fa fa-fw fa-commenting-o']); + }, 10, ['icon' => 'fa fa-fw fa-comments-o']); + } +} \ No newline at end of file diff --git a/modules/Blog/Comments/Http/Controllers/ArticleListController.php b/modules/Blog/Comments/Http/Controllers/ArticleListController.php new file mode 100644 index 00000000..33ad274f --- /dev/null +++ b/modules/Blog/Comments/Http/Controllers/ArticleListController.php @@ -0,0 +1,12 @@ + 'web', 'prefix' => 'comments', 'namespace' => 'Modules\Blog\Comments\Http\Controllers'], function() +{ + Route::get('/', 'CommentsController@index')->name('comments.overview'); +}); \ No newline at end of file diff --git a/modules/Blog/Comments/Providers/CommentsServiceProvider.php b/modules/Blog/Comments/Providers/CommentsServiceProvider.php new file mode 100644 index 00000000..adb026f2 --- /dev/null +++ b/modules/Blog/Comments/Providers/CommentsServiceProvider.php @@ -0,0 +1,89 @@ +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('comments.php')]); + $this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'comments'); + } + + /** + * Register views. + * + * @return void + */ + public function registerViews() + { + $viewPath = base_path('resources/views/modules/comments'); + $sourcePath = __DIR__.'/../Resources/views'; + + $this->publishes([$sourcePath => $viewPath]); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/comments'; + }, \Config::get('view.paths')), [$sourcePath]), 'comments'); + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = base_path('resources/lang/modules/comments'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'comments'); + } else { + $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'comments'); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + +} diff --git a/modules/Blog/Comments/Resources/lang/en/module.php b/modules/Blog/Comments/Resources/lang/en/module.php new file mode 100644 index 00000000..e83dd573 --- /dev/null +++ b/modules/Blog/Comments/Resources/lang/en/module.php @@ -0,0 +1,6 @@ + 'Comments', + 'description' => "Bring comment support to blog module", + 'overview' => 'All comments' +]; \ No newline at end of file diff --git a/modules/Blog/Comments/start.php b/modules/Blog/Comments/start.php new file mode 100644 index 00000000..7be329cb --- /dev/null +++ b/modules/Blog/Comments/start.php @@ -0,0 +1,15 @@ + 'Blog', + 'description' => '', + 'hasSubmodules' => true, +]; \ No newline at end of file diff --git a/resources/lang/cs/admin/history.php b/resources/lang/cs/admin/history.php index a82b3831..f263f9ba 100644 --- a/resources/lang/cs/admin/history.php +++ b/resources/lang/cs/admin/history.php @@ -1,25 +1,26 @@ "Zpět na editaci obsahu", -"backToOverview" => "Zpět na přehled historie", -"changedFromTo" => "Změna z :from na :to", -"columnFile" => "Přiřazené soubory", -"columnIs_homepage" => "Domovská stránka", -"columnMetaDescription" => "Popis", -"columnMetaKeywords" => "Klíčová slova", -"columnPageContent" => "Obsah stránky", -"columnParentPage" => "Nadřazená stránka", -"columnStatus" => "Viditelnost stránky", -"columnTemplate" => "Šablona", -"columnTitle" => "Titulek", -"columnTitlePhotoFilename" => "Titulní obrázek", -"columnUrl" => "URL", -"deletedFile" => "Odebrán soubor :file.", -"diff" => "Rozdíl", -"diffPageName" => "Rozdíl v :column", -"emptyValue" => "nic", -"numOfChanges" => "Jedna změna|:count změny|:count změn", -"pageName" => "Historie :name", -"setupAsHomepage" => "Nastaveno jako domovská stránka", -"uploadedFile" => "Nahrán soubor :file.", + "backToEdit" => "Zpět na editaci obsahu", + "backToOverview" => "Zpět na přehled historie", + "changedFromTo" => "Změna z :from na :to", + "columnCategory" => "Kategorie", + "columnFile" => "Přiřazené soubory", + "columnIs_homepage" => "Domovská stránka", + "columnMetaDescription" => "Popis", + "columnMetaKeywords" => "Klíčová slova", + "columnPageContent" => "Obsah stránky", + "columnParentPage" => "Nadřazená stránka", + "columnStatus" => "Viditelnost stránky", + "columnTemplate" => "Šablona", + "columnTitle" => "Titulek", + "columnTitlePhotoFilename" => "Titulní obrázek", + "columnUrl" => "URL", + "deletedFile" => "Odebrán soubor :file.", + "diff" => "Rozdíl", + "diffPageName" => "Rozdíl v :column", + "emptyValue" => "nic", + "numOfChanges" => "Jedna změna|:count změny|:count změn", + "pageName" => "Historie :name", + "setupAsHomepage" => "Nastaveno jako domovská stránka", + "uploadedFile" => "Nahrán soubor :file.", ];