mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-02-17 08:58:42 +00:00
load comments if applicabe
This commit is contained in:
parent
a3c367cde6
commit
e26e820fd0
|
|
@ -28,6 +28,7 @@ use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Model\Message\FormValidation;
|
use phpOMS\Model\Message\FormValidation;
|
||||||
|
use phpOMS\Module\NullModule;
|
||||||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -166,6 +167,15 @@ final class ApiController extends Controller
|
||||||
$newsArticle->setStatus((int) ($request->getData('status') ?? NewsStatus::VISIBLE));
|
$newsArticle->setStatus((int) ($request->getData('status') ?? NewsStatus::VISIBLE));
|
||||||
$newsArticle->setFeatured((bool) ($request->getData('featured') ?? true));
|
$newsArticle->setFeatured((bool) ($request->getData('featured') ?? true));
|
||||||
|
|
||||||
|
// allow comments
|
||||||
|
if (!empty($request->getData('allow_comments'))
|
||||||
|
&& !($commentApi = $this->app->moduleManager->get('Comments') instanceof NullModule)
|
||||||
|
) {
|
||||||
|
/** @var \Modules\Comments\Controller\ApiController $commentApi */
|
||||||
|
$commnetList = $commentApi->createCommentList();
|
||||||
|
$newsArticle->setCommentList($commnetList);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($tags = $request->getDataJson('tags'))) {
|
if (!empty($tags = $request->getDataJson('tags'))) {
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (!isset($tag['id'])) {
|
if (!isset($tag['id'])) {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ use phpOMS\Message\Http\RequestStatusCode;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Views\View;
|
use phpOMS\Views\View;
|
||||||
|
use phpOMS\Module\NullModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* News controller class.
|
* News controller class.
|
||||||
|
|
@ -134,6 +135,17 @@ final class BackendController extends Controller implements DashboardElementInte
|
||||||
PermissionType::MODIFY, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::NEWS, $article->getId())
|
PermissionType::MODIFY, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::NEWS, $article->getId())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// allow comments
|
||||||
|
if (!$article->getComments() !== null
|
||||||
|
&& !($this->app->moduleManager->get('Comments') instanceof NullModule)
|
||||||
|
) {
|
||||||
|
$commentCreateView = new \Modules\Comments\Theme\Backend\Components\Comment\CreateView($this->app->l11nManager, $request, $response);
|
||||||
|
$commentListView = new \Modules\Comments\Theme\Backend\Components\Comment\ListView($this->app->l11nManager, $request, $response);
|
||||||
|
|
||||||
|
$view->addData('commentCreate', $commentCreateView);
|
||||||
|
$view->addData('commentList', $commentListView);
|
||||||
|
}
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,20 @@ class NewsArticle implements ArrayableInterface, \JsonSerializable
|
||||||
return $this->plain;
|
return $this->plain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set comment list
|
||||||
|
*
|
||||||
|
* @param CommentList $comments
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function setCommentList($comments) : void
|
||||||
|
{
|
||||||
|
$this->comments = $comments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get comments
|
* Get comments
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
return ['News' => [
|
return ['News' => [
|
||||||
'Accounts/Groups' => 'Benutyer/Gruppen',
|
'Accounts/Groups' => 'Benutyer/Gruppen',
|
||||||
'Additional' => 'Zusätzlich',
|
'Additional' => 'Zusätzlich',
|
||||||
|
'AllowComments' => 'Kommentare erlauben',
|
||||||
'Archive' => 'Archiv',
|
'Archive' => 'Archiv',
|
||||||
'Author' => 'Autor',
|
'Author' => 'Autor',
|
||||||
'Date' => 'Datum',
|
'Date' => 'Datum',
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
return ['News' => [
|
return ['News' => [
|
||||||
'Accounts/Groups' => 'Accounts/Groups',
|
'Accounts/Groups' => 'Accounts/Groups',
|
||||||
'Additional' => 'Additional',
|
'Additional' => 'Additional',
|
||||||
|
'AllowComments' => 'Allow comments',
|
||||||
'Archive' => 'Archive',
|
'Archive' => 'Archive',
|
||||||
'Author' => 'Author',
|
'Author' => 'Author',
|
||||||
'Date' => 'Date',
|
'Date' => 'Date',
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,14 @@ echo $this->getData('nav')->render(); ?>
|
||||||
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $news->getLanguage() ? ' selected' : ''); ?>><?= $this->printHtml($language); ?>
|
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $news->getLanguage() ? ' selected' : ''); ?>><?= $this->printHtml($language); ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
|
<tr><td>
|
||||||
|
<label for="iComment"><?= $this->getHtml('AllowComments'); ?></label>
|
||||||
|
<tr><td>
|
||||||
|
<label class="checkbox" for="iComment">
|
||||||
|
<input id="iComment" type="checkbox" name="allow_comments" value="1">
|
||||||
|
<span class="checkmark"></span>
|
||||||
|
<?= $this->getHtml('AllowComments'); ?>
|
||||||
|
</label>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="portlet-foot">
|
<div class="portlet-foot">
|
||||||
|
|
|
||||||
|
|
@ -52,3 +52,13 @@ echo $this->getData('nav')->render(); ?>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$commentList = $news->getComments();
|
||||||
|
if (!empty($commentList) && $commentList->isActive()) :
|
||||||
|
/* @todo: check if user has permission to create a comment here, maybe he is only allowed to read comments */
|
||||||
|
/* @todo: instead of creating a custom news list or news textarea I should create a component which simply gets loaded on the pages by passing the commentList id and the comments to show */
|
||||||
|
$this->getData('commentCreate')->render(1);
|
||||||
|
|
||||||
|
$this->getData('commentList')->render(1);
|
||||||
|
endif; ?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user