diff --git a/app/Helpers/CurrentTemplate.php b/app/Helpers/CurrentTemplate.php index 9f88dd88..ba04b6d8 100644 --- a/app/Helpers/CurrentTemplate.php +++ b/app/Helpers/CurrentTemplate.php @@ -2,6 +2,9 @@ namespace App\Helpers; use App\Models\Module; +use DebugBar\Bridge\MonologCollector; +use Illuminate\Database\QueryException; +use Monolog\Logger; class CurrentTemplate { @@ -10,16 +13,19 @@ class CurrentTemplate /** * Getter for currently set template - * * @return Module + * @throws \ErrorException */ public static function get() { if (!self::$initialized) { + try { self::$template = Module::where('is_template', true) ->where('enabled', true) ->first(); - + } catch (QueryException $e) { + throw new \ErrorException('DB not migrated, please, do so!'); + } if (self::$template) { self::$template->module_settings = json_decode(self::$template->module_settings); } diff --git a/app/Http/Requests/CreateNewContentRequest.php b/app/Http/Requests/CreateNewContentRequest.php index df25858b..c488149c 100644 --- a/app/Http/Requests/CreateNewContentRequest.php +++ b/app/Http/Requests/CreateNewContentRequest.php @@ -12,14 +12,14 @@ class CreateNewContentRequest extends Request public function rules() { return [ - 'titlePhoto' => 'image', - 'title' => 'required', - 'url' => 'required|unique:contents,url', - 'status' => 'required|in:draft,protected,public', - 'title_photo' => 'exists:files,id', - 'parentPage' => 'exists:contents,id', - 'published_from' => 'date', - 'published_to' => 'date', + 'titlePhoto' => 'image', + 'title' => 'required', + 'url' => 'required|unique:contents,url', + 'status' => 'required|in:draft,protected,public', + 'title_photo' => 'exists:files,id', + 'parentPage' => 'exists:contents,id', + 'publishedFrom' => 'date', + 'publishedTo' => 'date', ]; } } diff --git a/app/Http/Requests/EditContentRequest.php b/app/Http/Requests/EditContentRequest.php index e04878e6..040fac90 100644 --- a/app/Http/Requests/EditContentRequest.php +++ b/app/Http/Requests/EditContentRequest.php @@ -18,13 +18,13 @@ class EditContentRequest extends Request $statuses = implode(',', $statuses); return [ - 'title' => 'required', - 'url' => 'required|unique:contents,url,' . $this->id, - 'published_from' => 'date', - 'published_to' => 'date', - 'title_photo' => 'exists:files,id', - 'status' => 'required|in:' . $statuses, - 'parentPage' => 'exists:contents,id' + 'title' => 'required', + 'url' => 'required|unique:contents,url,' . $this->id, + 'publishedFrom' => 'date', + 'publishedTo' => 'date', + 'title_photo' => 'exists:files,id', + 'status' => 'required|in:' . $statuses, + 'parentPage' => 'exists:contents,id' ]; } } diff --git a/modules/Blog/Article/Resources/lang/en/module.php b/modules/Blog/Article/Resources/lang/en/module.php index 8b9f7e18..1e272945 100644 --- a/modules/Blog/Article/Resources/lang/en/module.php +++ b/modules/Blog/Article/Resources/lang/en/module.php @@ -7,5 +7,6 @@ return [ 'blog' => 'Blog', 'allArticles' => 'All articles', 'newArticle' => 'Write new article', - 'editArticle' => 'Editing article' + 'editArticle' => 'Editing article', + 'templatePath' => 'Articles', ]; \ No newline at end of file diff --git a/modules/Blog/ArticleList/Handlers/ArticleList.php b/modules/Blog/ArticleList/Handlers/ArticleList.php index c65ba273..c387d4ac 100644 --- a/modules/Blog/ArticleList/Handlers/ArticleList.php +++ b/modules/Blog/ArticleList/Handlers/ArticleList.php @@ -32,22 +32,12 @@ class ArticleList extends Handler } /** - * Render given module into visitor area. + * Filter articles on article list using archive * - * @param Content $content DB model from table contents - * @param array $parameters parameters used for modifications/custom settings of given model - * - * @return mixed + * @param $articles */ - public function render(Content $content, $parameters) + protected static function archive(&$articles) { - $articles = ArticleModel::where('module_handler', Article::class) - ->with('comments') - ->with('category'); - - // selected category? - - // selected articles from archive? $year = Input::get('y'); $month = Input::get('m'); $day = Input::get('d'); @@ -63,12 +53,23 @@ class ArticleList extends Handler if ($day) { $articles = $articles->where(DB::raw('DAY(created_at)'), $day); } + } - // is given any category? + /** + * Filter article list to some specified category + * + * Category URL is specified as GET attribute "category" + * + * @param $articles + */ + protected static function category(&$articles) + { $categoryUrl = Input::get('category'); - if ($categoryUrl && \Module::get('Categories') - ->enabled() - ) { + + $categoriesEnabled = \Module::get('Categories') + ->enabled(); + + if ($categoryUrl && $categoriesEnabled) { $category = Category::where('url', $categoryUrl) ->firstOrFail(); @@ -82,6 +83,23 @@ class ArticleList extends Handler $articles = $articles->whereIn('category_id', $categories); } + } + + /** + * 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 = ArticleModel::where('module_handler', Article::class) + ->with('comments') + ->with('category') + ->orderBy('published_from', 'DESC') + ->orderBy('created_at', 'DESC'); // show articles for not-logged users of even for logged onew? if (!Auth::user()) { @@ -90,6 +108,12 @@ class ArticleList extends Handler $articles = $articles->whereIn('status', [Content::STATUS_PUBLIC, Content::STATUS_PROTECTED]); } + // selected articles from archive? + self::archive($articles); + + // is given any category? + self::category($articles); + // show articles only from specified user $author = Input::get('author'); if ($author) { @@ -98,8 +122,7 @@ class ArticleList extends Handler $articles = $articles->where('user_id', $user->id); } - $articles = $articles->orderBy('created_at', 'DESC') - ->paginate(20); + $articles = $articles->paginate(20); // decode module settings foreach ($articles as $article) { diff --git a/modules/Blog/ArticleList/Resources/lang/en/module.php b/modules/Blog/ArticleList/Resources/lang/en/module.php index 581543b4..98b22ac7 100644 --- a/modules/Blog/ArticleList/Resources/lang/en/module.php +++ b/modules/Blog/ArticleList/Resources/lang/en/module.php @@ -2,4 +2,5 @@ return [ 'name' => 'Article list', 'description' => 'Module for displaying list of articles on web', + 'templatePath' => 'Article list', ]; \ No newline at end of file diff --git a/resources/lang/cs/admin/contents.php b/resources/lang/cs/admin/contents.php index 73b3b8fc..b3ef981b 100644 --- a/resources/lang/cs/admin/contents.php +++ b/resources/lang/cs/admin/contents.php @@ -24,7 +24,7 @@ return [ "invalidPage" => "Požadovaná stránka neexistuje.", "invalidStatus" => "Nelze změnit stav stránky na něco nedefinovaného.", "invalidTemplateSelected" => "Není zvolena šablona pro vykreslení stránky! Stránka nebude pro návštěvníky vykreslena!", -"lockUrl" => "Zachovat URL?", +"lockUrl" => "Zamknout URL?", "makeDraft" => "Převést na koncept", "makeProtected" => "Zobrazit jen pro přihlášené", "makePublic" => "Publikovat", diff --git a/resources/lang/en/admin/contents.php b/resources/lang/en/admin/contents.php index d9567cd4..dad9cd1b 100644 --- a/resources/lang/en/admin/contents.php +++ b/resources/lang/en/admin/contents.php @@ -46,7 +46,7 @@ return [ 'parentPage' => 'Parent page', 'alreadyHomepage' => 'Homepage', 'files' => 'Files', - 'lockUrl' => 'Keep URL', + 'lockUrl' => 'Lock URL', 'noCategory' => ' -- No category -- ', 'noTemplates' => 'Cannot create content page. There are no available templates for this module.', 'title' => 'Title', diff --git a/resources/lang/sk/admin/contents.php b/resources/lang/sk/admin/contents.php index 83fdab00..5c44e1e2 100644 --- a/resources/lang/sk/admin/contents.php +++ b/resources/lang/sk/admin/contents.php @@ -23,7 +23,7 @@ return [ "invalidPage" => "Požadovaná stránka neexistuje.", "invalidStatus" => "Nie je možné zmeniť stav stránky na niečo nedefinovaného.", "invalidTemplateSelected" => "Zvolená nesprávna šablóna! Táto stránka sa nedá zobraziť!", - "lockUrl" => "Zachovať URL?", + "lockUrl" => "Zamknout URL?", "makeDraft" => "Previesť na koncept", "makeProtected" => "Zobraziť iba prihláseným užívateľom", "makePublic" => "Publikovať", diff --git a/resources/views/admin/content/formParts/publicationSetup.blade.php b/resources/views/admin/content/formParts/publicationSetup.blade.php index b19aa138..8664f708 100644 --- a/resources/views/admin/content/formParts/publicationSetup.blade.php +++ b/resources/views/admin/content/formParts/publicationSetup.blade.php @@ -4,7 +4,7 @@ @lang('admin/contents.field_published_from') - @include('admin.snippets.hasError', ['field' => 'published_from']) @@ -15,7 +15,7 @@ @lang('admin/contents.field_published_to') - @include('admin.snippets.hasError', ['field' => 'published_to']) diff --git a/templates/Binarity/Handler.php b/templates/Binarity/Handler.php index 86915a03..faf5bf2c 100644 --- a/templates/Binarity/Handler.php +++ b/templates/Binarity/Handler.php @@ -76,11 +76,11 @@ class Handler implements TemplateHandler ], [ 'module' => 'ArticleList', - 'templateName' => 'articlelist::admin.templatePath' + 'templateName' => 'articlelist::module.templatePath' ], [ 'module' => 'Article', - 'templateName' => 'article::admin.templatePath' + 'templateName' => 'article::module.templatePath' ], ]; } diff --git a/templates/Binarity/Resources/assets/css/app.css b/templates/Binarity/Resources/assets/css/app.css index 8bfaeabf..1c328042 100644 --- a/templates/Binarity/Resources/assets/css/app.css +++ b/templates/Binarity/Resources/assets/css/app.css @@ -5355,6 +5355,9 @@ table.hover tr:nth-of-type(even):hover { .m-0 { margin: 0 !important; } +.m-t-5 { + margin-top: 5px; +} .m-t-25 { margin-top: 25px; } @@ -9287,7 +9290,8 @@ article h2 { article h3 { margin-top: 20px; - font-size: 1.2em; + font-size: 1.15em; + color: #414042; } .off-canvas-content .article-list-item div { diff --git a/templates/Binarity/Resources/views/modules/article/visitor/default.blade.php b/templates/Binarity/Resources/views/modules/article/visitor/default.blade.php index 13b19183..e7055fb4 100644 --- a/templates/Binarity/Resources/views/modules/article/visitor/default.blade.php +++ b/templates/Binarity/Resources/views/modules/article/visitor/default.blade.php @@ -7,8 +7,8 @@