Merge branch 'refactoring' into binarity.cz
This commit is contained in:
@@ -27,6 +27,6 @@ class Controller extends BaseController
|
||||
{
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ return [
|
||||
'name' => 'Articles',
|
||||
'translatedName' => 'article::module.name',
|
||||
'translatedDescription' => 'article::module.description',
|
||||
'alias' => 'blog-article',
|
||||
'alias' => 'article',
|
||||
'handler' => \Modules\Blog\Article\Handlers\Article::class,
|
||||
'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class],
|
||||
'files' => ['start.php'],
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\ActionLog\ActionLogType;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Module;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Modules\Blog\Article\Entities\Comment;
|
||||
|
||||
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)
|
||||
{
|
||||
$content->comments = [];
|
||||
if (isset($content->moduleSettings->allowComments) && $content->moduleSettings->allowComments) {
|
||||
$content->comments = new Collection();
|
||||
if (isset($content->moduleSettings['allowComments']) && $content->moduleSettings['allowComments']) {
|
||||
$content->comments = Comment::where('content_id', $content->id)
|
||||
->with('author')
|
||||
->where('approved', 1)
|
||||
|
||||
@@ -11,15 +11,9 @@ use Pingpong\Modules\Routing\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)
|
||||
->where('moduleHandler', Article::class)
|
||||
->firstOrFail();
|
||||
|
||||
$article->moduleSettings = json_decode($article->moduleSettings);
|
||||
|
||||
if (!isset($article->moduleSettings->allowComments) || !$article->moduleSettings->allowComments) {
|
||||
if (!isset($article->moduleSettings['allowComments']) || !$article->moduleSettings['allowComments']) {
|
||||
return redirect()
|
||||
->route('page.content', ['url' => $article->url])
|
||||
->with('error', trans('article::comments.disabledComments'));
|
||||
@@ -28,7 +22,7 @@ class CreateNewComment extends Controller
|
||||
$content = $request->message;
|
||||
$user = Auth::user();
|
||||
if ($user) {
|
||||
$name = $user->name;
|
||||
$name = is_null($user->name) ? $user->email : $user->name;
|
||||
$email = $user->email;
|
||||
} else {
|
||||
$name = $request->name;
|
||||
|
||||
@@ -22,7 +22,7 @@ Route::group([
|
||||
// public routes
|
||||
Route::group(['middleware' => ['web'], 'namespace' => 'Visitor'], function () {
|
||||
|
||||
Route::post('comments/new/{id}', 'CreateNewComment@postNew')
|
||||
Route::post('comments/new/{article}', 'CreateNewComment@store')
|
||||
->name('comments.new');
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@ return [
|
||||
'name' => 'Article list',
|
||||
'translatedName' => 'articlelist::module.name',
|
||||
'translatedDescription' => 'articlelist::module.description',
|
||||
'alias' => 'blog-articlelist',
|
||||
'alias' => 'articlelist',
|
||||
'handler' => \Modules\Blog\ArticleList\Handlers\ArticleList::class,
|
||||
'providers' => [\Modules\Blog\ArticleList\Providers\ArticleListServiceProvider::class],
|
||||
'files' => ['start.php'],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Modules\Blog\ArticleList\Handlers;
|
||||
|
||||
use App\CMS\Contracts\Repositories\Content as IContent;
|
||||
use App\CMS\Handlers\Handler;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Content\Content;
|
||||
@@ -109,11 +110,10 @@ class ArticleList extends Handler
|
||||
->orderBy('created_at', 'DESC');
|
||||
|
||||
// show articles for not-logged users of even for logged onew?
|
||||
if (!Auth::user()) {
|
||||
$articles = $articles->where('status', Content::STATUS_PUBLIC);
|
||||
} else {
|
||||
$articles = $articles->whereIn('status', [Content::STATUS_PUBLIC, Content::STATUS_PROTECTED]);
|
||||
}
|
||||
$articles = !Auth::user() ? $articles->where('status', IContent::STATUS_PUBLIC) : $articles->whereIn('status', [
|
||||
IContent::STATUS_PUBLIC,
|
||||
IContent::STATUS_PROTECTED
|
||||
]);
|
||||
|
||||
// selected articles from archive?
|
||||
self::archive($articles);
|
||||
@@ -129,12 +129,7 @@ class ArticleList extends Handler
|
||||
$articles = $articles->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
$articles = $articles->paginate(20);
|
||||
|
||||
// decode module settings
|
||||
foreach ($articles as $article) {
|
||||
$article->moduleSettings = json_decode($article->moduleSettings);
|
||||
}
|
||||
$articles = $articles->paginate(setting('articlesPerPage', 20));
|
||||
|
||||
return Controller::VisitorsView($content->template, [
|
||||
'page' => $content,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Module;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class UpdateAliasForSubdomodules extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Module::where('alias', 'blog-articlelist')
|
||||
->update(['alias' => 'articlelist']);
|
||||
Module::where('alias', 'blog-article')
|
||||
->update(['alias' => 'article']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Module::where('alias', 'articlelist')
|
||||
->update(['alias' => 'blog-articlelist']);
|
||||
Module::where('alias', 'article')
|
||||
->update(['alias' => 'blog-article']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user