|
|
@ -1,8 +1,6 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
use Engelsystem\Database\DB;
|
|
|
|
|
|
|
|
use Engelsystem\Models\News;
|
|
|
|
use Engelsystem\Models\News;
|
|
|
|
use Engelsystem\Models\User\User;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
* @return string
|
|
|
@ -116,7 +114,7 @@ function display_news(News $news): string
|
|
|
|
. '<span class="glyphicon glyphicon-comment"></span> '
|
|
|
|
. '<span class="glyphicon glyphicon-comment"></span> '
|
|
|
|
. __('Comments') . ' »</a> '
|
|
|
|
. __('Comments') . ' »</a> '
|
|
|
|
. '<span class="badge">'
|
|
|
|
. '<span class="badge">'
|
|
|
|
. count(DB::select('SELECT `ID` FROM `NewsComments` WHERE `Refid`=?', [$news->id]))
|
|
|
|
. $news->comments()->count()
|
|
|
|
. '</span>';
|
|
|
|
. '</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
@ -141,17 +139,10 @@ function user_news_comments()
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if ($request->hasPostData('submit') && $request->has('text')) {
|
|
|
|
if ($request->hasPostData('submit') && $request->has('text')) {
|
|
|
|
$text = $request->input('text');
|
|
|
|
$text = $request->input('text');
|
|
|
|
DB::insert('
|
|
|
|
$news->comments()->create([
|
|
|
|
INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`)
|
|
|
|
'text' => $text,
|
|
|
|
VALUES (?, ?, ?, ?)
|
|
|
|
'user_id' => $user->id,
|
|
|
|
',
|
|
|
|
]);
|
|
|
|
[
|
|
|
|
|
|
|
|
$nid,
|
|
|
|
|
|
|
|
date('Y-m-d H:i:s'),
|
|
|
|
|
|
|
|
$text,
|
|
|
|
|
|
|
|
$user->id,
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
engelsystem_log('Created news_comment: ' . $text);
|
|
|
|
engelsystem_log('Created news_comment: ' . $text);
|
|
|
|
$html .= success(__('Entry saved.'), true);
|
|
|
|
$html .= success(__('Entry saved.'), true);
|
|
|
@ -159,18 +150,12 @@ function user_news_comments()
|
|
|
|
|
|
|
|
|
|
|
|
$html .= display_news($news);
|
|
|
|
$html .= display_news($news);
|
|
|
|
|
|
|
|
|
|
|
|
$comments = DB::select(
|
|
|
|
foreach ($news->comments as $comment) {
|
|
|
|
'SELECT * FROM `NewsComments` WHERE `Refid`=? ORDER BY \'ID\'',
|
|
|
|
|
|
|
|
[$nid]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($comments as $comment) {
|
|
|
|
|
|
|
|
$user_source = User::find($comment['UID']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$html .= '<div class="panel panel-default">';
|
|
|
|
$html .= '<div class="panel panel-default">';
|
|
|
|
$html .= '<div class="panel-body">' . nl2br(htmlspecialchars($comment['Text'])) . '</div>';
|
|
|
|
$html .= '<div class="panel-body">' . nl2br(htmlspecialchars($comment->text)) . '</div>';
|
|
|
|
$html .= '<div class="panel-footer text-muted">';
|
|
|
|
$html .= '<div class="panel-footer text-muted">';
|
|
|
|
$html .= '<span class="glyphicon glyphicon-time"></span> ' . $comment['Datum'] . ' ';
|
|
|
|
$html .= '<span class="glyphicon glyphicon-time"></span> ' . $comment->created_at->format('Y-m-d H:i') . ' ';
|
|
|
|
$html .= User_Nick_render($user_source);
|
|
|
|
$html .= User_Nick_render($comment->user);
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|