Merge branch 'dev' into binarity.cz
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace App\Helpers;
|
||||
|
||||
class Date
|
||||
{
|
||||
/**
|
||||
* Print date in configured format
|
||||
*
|
||||
* @param $datestamp
|
||||
* @param bool $withTime
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public static function date($datestamp, $withTime = true)
|
||||
{
|
||||
$timestamp = strtotime($datestamp);
|
||||
|
||||
if ($timestamp <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$format = $withTime ? config('app.datetime_format') : config('app.date_format');
|
||||
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
|
||||
public static function dateFormatted($format, $datestamp)
|
||||
{
|
||||
$timestamp = strtotime($datestamp);
|
||||
|
||||
if ($timestamp <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
|
||||
public static function monthName($datestamp) {
|
||||
$timestamp = strtotime($datestamp);
|
||||
|
||||
if ($timestamp <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$months = [
|
||||
trans('common.months.january'),
|
||||
trans('common.months.february'),
|
||||
trans('common.months.march'),
|
||||
trans('common.months.april'),
|
||||
trans('common.months.may'),
|
||||
trans('common.months.june'),
|
||||
trans('common.months.july'),
|
||||
trans('common.months.august'),
|
||||
trans('common.months.semptember'),
|
||||
trans('common.months.october'),
|
||||
trans('common.months.november'),
|
||||
trans('common.months.december'),
|
||||
];
|
||||
|
||||
$monthNumber = date('n', $timestamp);
|
||||
|
||||
return $months[$monthNumber - 1];
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
view()->share('currentUrl', \Request::url());
|
||||
view()->share('loggedUser', \Auth::user());
|
||||
|
||||
$this->extendBlade();
|
||||
}
|
||||
@@ -100,6 +101,21 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
return preg_replace($pattern, $code, $view);
|
||||
});
|
||||
|
||||
Blade::extend(function ($view) {
|
||||
$pattern = $this->createPattern('customDate');
|
||||
$code = '<?php echo \App\Helpers\Date::dateFormatted($2); ?>';
|
||||
|
||||
return preg_replace($pattern, $code, $view);
|
||||
});
|
||||
|
||||
Blade::extend(function ($view) {
|
||||
$pattern = $this->createPattern('monthName');
|
||||
$code = '<?php echo \App\Helpers\Date::monthName($2); ?>';
|
||||
|
||||
return preg_replace($pattern, $code, $view);
|
||||
});
|
||||
|
||||
|
||||
// register extension for rendering widget areas
|
||||
Blade::extend(function ($view) {
|
||||
$pattern = $this->createPattern('widgetArea');
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Modules\Blog\Article\Entities;
|
||||
|
||||
use App\Models\Content;
|
||||
|
||||
class Article extends Content
|
||||
{
|
||||
protected $table = 'contents';
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'content_id')
|
||||
->where('approved', true);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,12 @@
|
||||
Route::group([
|
||||
'prefix' => LaravelLocalization::setLocale(),
|
||||
'middleware' => ['localeSessionRedirect', 'localizationRedirect'],
|
||||
'namespace' => 'Modules\Blog\Article\Http\Controllers\Admin'
|
||||
'namespace' => 'Modules\Blog\Article\Http\Controllers'
|
||||
], function () {
|
||||
Route::group([
|
||||
'middleware' => ['web', 'auth', 'adminMenu'],
|
||||
'prefix' => 'admin/comments',
|
||||
'namespace' => 'Admin'
|
||||
], function () {
|
||||
|
||||
Route::get('/', 'CommentsOverview@getOverview')
|
||||
@@ -20,7 +21,7 @@ Route::group([
|
||||
});
|
||||
|
||||
// public routes
|
||||
Route::group(['middleware' => ['web']], function () {
|
||||
Route::group(['middleware' => ['web'], 'namespace' => 'Visitor'], function () {
|
||||
|
||||
Route::post('comments/new/{id}', 'CreateNewComment@postNew')
|
||||
->name('comments.new');
|
||||
|
||||
@@ -9,6 +9,7 @@ use Modules\Blog\Article\Events\CreatedComment;
|
||||
use Modules\Blog\Article\Events\DeletedComment;
|
||||
use Modules\Blog\Article\Listeners\LogCommentApproval;
|
||||
use Modules\Blog\Article\Listeners\LogDeletedComment;
|
||||
use Modules\Blog\Article\Listeners\LogNewComment;
|
||||
|
||||
class ArticleEventServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Modules\Blog\Article\Entities\Article as ArticleModel;
|
||||
use Modules\Blog\Article\Handlers\Article;
|
||||
use Modules\Categories\Entities\Category;
|
||||
|
||||
@@ -40,7 +41,9 @@ class ArticleList extends Handler
|
||||
*/
|
||||
public function render(Content $content, $parameters)
|
||||
{
|
||||
$articles = Content::where('module_handler', Article::class);
|
||||
$articles = ArticleModel::where('module_handler', Article::class)
|
||||
->with('comments')
|
||||
->with('category');
|
||||
|
||||
// selected category?
|
||||
|
||||
@@ -98,7 +101,11 @@ class ArticleList extends Handler
|
||||
$articles = $articles->orderBy('created_at', 'DESC')
|
||||
->paginate(20);
|
||||
|
||||
return Controller::VisitorsView($content->template, ['page' => $content, 'articles' => $articles, 'extra' => $parameters]);
|
||||
return Controller::VisitorsView($content->template, [
|
||||
'page' => $content,
|
||||
'articles' => $articles,
|
||||
'extra' => $parameters
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getModuleId()
|
||||
|
||||
@@ -5,8 +5,24 @@ return [
|
||||
"goToWeb" => "Jít na web",
|
||||
"graphics" => "Grafika",
|
||||
"header" => "Záhlaví",
|
||||
"lang" => ["czech" => "Čeština",
|
||||
"lang" => [
|
||||
"czech" => "Čeština",
|
||||
"english" => "Angličtina",
|
||||
'slovak' => 'Slovenština'
|
||||
],
|
||||
"months" => [
|
||||
"april" => "Duben",
|
||||
"august" => "Srpen",
|
||||
"december" => "Prosinec",
|
||||
"february" => "Únor",
|
||||
"january" => "Leden",
|
||||
"july" => "Červenec",
|
||||
"june" => "Červen",
|
||||
"march" => "Březen",
|
||||
"may" => "Květen",
|
||||
"november" => "Listopad",
|
||||
"october" => "Říjen",
|
||||
"september" => "Září",
|
||||
],
|
||||
"positionFixed" => "fixní",
|
||||
"positionStatic" => "statické",
|
||||
|
||||
@@ -2,7 +2,22 @@
|
||||
return [
|
||||
'lang' => [
|
||||
'english' => 'English',
|
||||
'czech' => 'Czech'
|
||||
'czech' => 'Czech',
|
||||
'slovak' => 'Slovak'
|
||||
],
|
||||
'months' => [
|
||||
'january' => 'January',
|
||||
'february' => 'February',
|
||||
'march' => 'March',
|
||||
'april' => 'April',
|
||||
'may' => 'May',
|
||||
'june' => 'June',
|
||||
'july' => 'July',
|
||||
'august' => 'August',
|
||||
'september' => 'September',
|
||||
'october' => 'October',
|
||||
'november' => 'November',
|
||||
'december' => 'December'
|
||||
],
|
||||
'customize' => 'Customize',
|
||||
'header' => 'Header',
|
||||
|
||||
Reference in New Issue
Block a user