FEATURE: merge template namespace and module alias

This commit is contained in:
Michal Kváček
2017-02-10 13:45:41 +01:00
parent 9451357e02
commit 35bda2828c
7 changed files with 16 additions and 26 deletions
+1 -1
View File
@@ -27,6 +27,6 @@ class Controller extends BaseController
{ {
$view = Template::name($template); $view = Template::name($template);
return view($view, $data, $mergeData); return response(view($view, $data, $mergeData))->header('X-Powered-By', strrev('zc.ytiranib.www//:sptth | .o.r.s ytiranib | SMCiniM'));
} }
} }
+1 -1
View File
@@ -4,7 +4,7 @@ return [
'name' => 'Articles', 'name' => 'Articles',
'translatedName' => 'article::module.name', 'translatedName' => 'article::module.name',
'translatedDescription' => 'article::module.description', 'translatedDescription' => 'article::module.description',
'alias' => 'blog-article', 'alias' => 'article',
'handler' => \Modules\Blog\Article\Handlers\Article::class, 'handler' => \Modules\Blog\Article\Handlers\Article::class,
'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class], 'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class],
'files' => ['start.php'], 'files' => ['start.php'],
+3 -2
View File
@@ -11,6 +11,7 @@ use App\Models\ActionLog\ActionLogType;
use App\Models\Content\Content; use App\Models\Content\Content;
use App\Models\Module; use App\Models\Module;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Collection;
use Modules\Blog\Article\Entities\Comment; use Modules\Blog\Article\Entities\Comment;
class Article extends Handler implements ContentTitles, AdvancedContentModifier, InstallableModule class Article extends Handler implements ContentTitles, AdvancedContentModifier, InstallableModule
@@ -25,8 +26,8 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
*/ */
public function render(Content $content, $parameters) public function render(Content $content, $parameters)
{ {
$content->comments = []; $content->comments = new Collection();
if (isset($content->moduleSettings->allowComments) && $content->moduleSettings->allowComments) { if (isset($content->moduleSettings['allowComments']) && $content->moduleSettings['allowComments']) {
$content->comments = Comment::where('content_id', $content->id) $content->comments = Comment::where('content_id', $content->id)
->with('author') ->with('author')
->where('approved', 1) ->where('approved', 1)
@@ -11,15 +11,9 @@ use Pingpong\Modules\Routing\Controller;
class CreateNewComment extends Controller class CreateNewComment extends Controller
{ {
public function postNew(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, $articleId) public function store(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, \Modules\Blog\Article\Entities\Article $article)
{ {
$article = Content::where('id', $articleId) if (!isset($article->moduleSettings['allowComments']) || !$article->moduleSettings['allowComments']) {
->where('moduleHandler', Article::class)
->firstOrFail();
$article->moduleSettings = json_decode($article->moduleSettings);
if (!isset($article->moduleSettings->allowComments) || !$article->moduleSettings->allowComments) {
return redirect() return redirect()
->route('page.content', ['url' => $article->url]) ->route('page.content', ['url' => $article->url])
->with('error', trans('article::comments.disabledComments')); ->with('error', trans('article::comments.disabledComments'));
@@ -28,7 +22,7 @@ class CreateNewComment extends Controller
$content = $request->message; $content = $request->message;
$user = Auth::user(); $user = Auth::user();
if ($user) { if ($user) {
$name = $user->name; $name = is_null($user->name) ? $user->email : $user->name;
$email = $user->email; $email = $user->email;
} else { } else {
$name = $request->name; $name = $request->name;
+1 -1
View File
@@ -22,7 +22,7 @@ Route::group([
// public routes // public routes
Route::group(['middleware' => ['web'], 'namespace' => 'Visitor'], function () { Route::group(['middleware' => ['web'], 'namespace' => 'Visitor'], function () {
Route::post('comments/new/{id}', 'CreateNewComment@postNew') Route::post('comments/new/{article}', 'CreateNewComment@store')
->name('comments.new'); ->name('comments.new');
}); });
}); });
+1 -1
View File
@@ -4,7 +4,7 @@ return [
'name' => 'Article list', 'name' => 'Article list',
'translatedName' => 'articlelist::module.name', 'translatedName' => 'articlelist::module.name',
'translatedDescription' => 'articlelist::module.description', 'translatedDescription' => 'articlelist::module.description',
'alias' => 'blog-articlelist', 'alias' => 'articlelist',
'handler' => \Modules\Blog\ArticleList\Handlers\ArticleList::class, 'handler' => \Modules\Blog\ArticleList\Handlers\ArticleList::class,
'providers' => [\Modules\Blog\ArticleList\Providers\ArticleListServiceProvider::class], 'providers' => [\Modules\Blog\ArticleList\Providers\ArticleListServiceProvider::class],
'files' => ['start.php'], 'files' => ['start.php'],
@@ -1,6 +1,7 @@
<?php <?php
namespace Modules\Blog\ArticleList\Handlers; namespace Modules\Blog\ArticleList\Handlers;
use App\CMS\Contracts\Repositories\Content as IContent;
use App\CMS\Handlers\Handler; use App\CMS\Handlers\Handler;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Content\Content; use App\Models\Content\Content;
@@ -109,11 +110,10 @@ class ArticleList extends Handler
->orderBy('created_at', 'DESC'); ->orderBy('created_at', 'DESC');
// show articles for not-logged users of even for logged onew? // show articles for not-logged users of even for logged onew?
if (!Auth::user()) { $articles = !Auth::user() ? $articles->where('status', IContent::STATUS_PUBLIC) : $articles->whereIn('status', [
$articles = $articles->where('status', Content::STATUS_PUBLIC); IContent::STATUS_PUBLIC,
} else { IContent::STATUS_PROTECTED
$articles = $articles->whereIn('status', [Content::STATUS_PUBLIC, Content::STATUS_PROTECTED]); ]);
}
// selected articles from archive? // selected articles from archive?
self::archive($articles); self::archive($articles);
@@ -129,12 +129,7 @@ class ArticleList extends Handler
$articles = $articles->where('user_id', $user->id); $articles = $articles->where('user_id', $user->id);
} }
$articles = $articles->paginate(20); $articles = $articles->paginate(setting('articlesPerPage', 20));
// decode module settings
foreach ($articles as $article) {
$article->moduleSettings = json_decode($article->moduleSettings);
}
return Controller::VisitorsView($content->template, [ return Controller::VisitorsView($content->template, [
'page' => $content, 'page' => $content,