2022-04-15 15:44:56 +02:00
|
|
|
<?php if (!empty($data['answers'])) : ?>
|
2022-06-09 23:06:22 +02:00
|
|
|
<div>
|
2022-06-03 15:27:36 +02:00
|
|
|
<h2 class="lowercase mb15 text-2xl">
|
2022-05-03 23:05:50 +02:00
|
|
|
<?= Html::numWord($post['amount_content'], __('app.num_answer'), true); ?>
|
2021-08-25 17:20:18 +02:00
|
|
|
</h2>
|
|
|
|
<?php $n = 0;
|
2022-04-15 15:44:56 +02:00
|
|
|
foreach ($data['answers'] as $answer) :
|
2021-09-15 21:56:59 +02:00
|
|
|
$n++;
|
2022-04-26 19:56:14 +02:00
|
|
|
$post_url = url('post', ['id' => $post['post_id'], 'slug' => $post['post_slug']]);
|
2021-09-15 21:56:59 +02:00
|
|
|
?>
|
2021-08-25 17:20:18 +02:00
|
|
|
|
2022-02-01 20:39:48 +01:00
|
|
|
<div class="block-answer mb15">
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if ($n != 1) : ?><div class="br-top-dotted mt10 mb10"></div><?php endif; ?>
|
2021-08-25 17:20:18 +02:00
|
|
|
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if ($answer['answer_is_deleted'] == 1 && !UserData::checkAdmin()) continue; ?>
|
2021-08-25 17:20:18 +02:00
|
|
|
|
2022-11-06 18:37:12 +01:00
|
|
|
<ol class="list-none<?php if ($answer['answer_is_deleted'] == 1) : ?> m5 bg-red-200<?php endif; ?>">
|
|
|
|
<li class="content_tree" id="answer_<?= $answer['answer_id']; ?>">
|
|
|
|
<div class="content-body">
|
|
|
|
<div class="flex text-sm gap">
|
|
|
|
<a class="gray-600" href="<?= url('profile', ['login' => $answer['login']]); ?>">
|
|
|
|
<?= Img::avatar($answer['avatar'], $answer['login'], 'img-sm mr5', 'small'); ?>
|
|
|
|
<span <?php if (Html::loginColor($answer['created_at'])) : ?> class="green" <?php endif; ?>>
|
2022-03-20 20:53:03 +01:00
|
|
|
<?= $answer['login']; ?>
|
|
|
|
</span>
|
2022-04-15 15:44:56 +02:00
|
|
|
</a>
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if ($post['post_user_id'] == $answer['answer_user_id']) : ?>
|
2022-07-28 10:22:59 +02:00
|
|
|
<svg class="icons icon-small sky">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#mic"></use>
|
|
|
|
</svg>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php endif; ?>
|
2022-06-03 08:54:43 +02:00
|
|
|
<span class="gray-600 lowercase">
|
2022-11-06 18:37:12 +01:00
|
|
|
<?= Html::langDate($answer['answer_date']); ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
</span>
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if (empty($answer['edit'])) : ?>
|
|
|
|
<span class="gray-600">
|
|
|
|
(<?= __('app.ed'); ?>.)
|
|
|
|
</span>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php endif; ?>
|
2022-11-06 18:37:12 +01:00
|
|
|
<a rel="nofollow" class="gray-600" href="<?= $post_url; ?>#answer_<?= $answer['answer_id']; ?>"><svg class="icons icon-small">
|
2022-07-28 10:22:59 +02:00
|
|
|
<use xlink:href="/assets/svg/icons.svg#anchor"></use>
|
|
|
|
</svg></a>
|
2022-11-06 18:37:12 +01:00
|
|
|
<?= insert('/_block/admin-show-ip', ['ip' => $answer['answer_ip'], 'publ' => $answer['answer_published']]); ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
</div>
|
|
|
|
<div class="max-w780 ind-first-p">
|
2022-11-06 18:37:12 +01:00
|
|
|
<?= markdown($answer['answer_content'], 'text'); ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
</div>
|
2022-11-06 18:37:12 +01:00
|
|
|
</div>
|
|
|
|
<div class="flex text-sm gap">
|
|
|
|
<?= Html::votes($answer, 'answer'); ?>
|
2021-10-25 06:25:11 +02:00
|
|
|
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if ($post['post_closed'] == 0) : ?>
|
|
|
|
<?php if ($post['post_is_deleted'] == 0 || UserData::checkAdmin()) : ?>
|
|
|
|
<a data-answer_id="<?= $answer['answer_id']; ?>" class="add-comment gray-600"><?= __('app.reply'); ?></a>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php endif; ?>
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php endif; ?>
|
ADD: Middleware (first part)
Refactoring the code, dropping the `users_trust_level` table, classes, merging methods (for example, getPostId and getPostSlug), and changing the names and types of variables.
* The following classes have been removed: Authorization, DefaultMiddlewareBefore, DefaultMiddlewareBefore, Base, BanController.
* Added: MiddlewareModel, UserData, Designator.
* Fixed N+1 query on the post page
* The detailed page of the sent invites in the admin section has been changed.
etc.
2022-01-04 20:54:03 +01:00
|
|
|
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if (Access::author('answer', $answer, 30) === true) : ?>
|
|
|
|
<a class="editansw gray-600" href="<?= url('content.edit', ['type' => 'answer', 'id' => $answer['answer_id']]); ?>">
|
|
|
|
<?= __('app.edit'); ?>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php if (UserData::checkAdmin()) : ?>
|
|
|
|
<a data-type="answer" data-id="<?= $answer['answer_id']; ?>" class="type-action gray-600">
|
|
|
|
<?= $answer['answer_is_deleted'] == 1 ? __('app.recover') : __('app.remove'); ?>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?= Html::favorite($answer['answer_id'], 'answer', $answer['tid']); ?>
|
|
|
|
|
|
|
|
<?php if (UserData::getUserId() != $answer['answer_user_id'] && UserData::getRegType(config('trust-levels.tl_add_report'))) : ?>
|
|
|
|
<a data-post_id="<?= $post['post_id']; ?>" data-type="answer" data-content_id="<?= $answer['answer_id']; ?>" class="msg-flag gray-600">
|
|
|
|
<svg class="icons">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#flag"></use>
|
|
|
|
</svg>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<div data-insert="<?= $answer['answer_id']; ?>" id="insert_id_<?= $answer['answer_id']; ?>" class="none"></div>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php foreach ($answer['comments'] as $comment) : ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php if ($comment['comment_is_deleted'] == 1 && !UserData::checkAdmin()) continue; ?>
|
|
|
|
|
|
|
|
<ol class="list-none<?php if ($comment['comment_is_deleted'] == 1) : ?> m5 bg-red-200<?php endif; ?>">
|
|
|
|
<li class="content_tree mb20 ml15<?php if ($comment['comment_comment_id'] > 0) : ?> ml30<?php endif; ?>" id="comment_<?= $comment['comment_id']; ?>">
|
|
|
|
<div class="text-sm flex gap">
|
|
|
|
<a class="gray-600" href="<?= url('profile', ['login' => $comment['login']]); ?>">
|
|
|
|
<?= Img::avatar($comment['avatar'], $comment['login'], 'img-sm', 'small'); ?>
|
|
|
|
<span class="<?php if (Html::loginColor($comment['created_at'])) : ?> green<?php endif; ?>">
|
|
|
|
<?= $comment['login']; ?>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
<?php if ($post['post_user_id'] == $comment['comment_user_id']) : ?>
|
|
|
|
<svg class="icons icon-small sky">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#mic"></use>
|
|
|
|
</svg>
|
|
|
|
<?php endif; ?>
|
|
|
|
<span class="gray-600 lowercase">
|
|
|
|
<?= Html::langDate($comment['comment_date']); ?>
|
|
|
|
</span>
|
|
|
|
<?php if ($comment['comment_comment_id'] > 0) : ?>
|
|
|
|
<a class="gray-600" rel="nofollow" href="<?= $post_url; ?>#comment_<?= $comment['comment_comment_id']; ?>"><svg class="icons icon-small">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#arrow-up"></use>
|
|
|
|
</svg></a>
|
|
|
|
<?php else : ?>
|
|
|
|
<a class="gray-600" rel="nofollow" href="<?= $post_url; ?>#answer_<?= $comment['comment_answer_id']; ?>"><svg class="icons icon-small">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#arrow-up"></use>
|
|
|
|
</svg></a>
|
|
|
|
<?php endif; ?>
|
|
|
|
<a class="gray-600" rel="nofollow" href="<?= $post_url; ?>#comment_<?= $comment['comment_id']; ?>"><svg class="icons icon-small">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#anchor"></use>
|
|
|
|
</svg></a>
|
|
|
|
<?= insert('/_block/admin-show-ip', ['ip' => $comment['comment_ip'], 'publ' => $comment['comment_published']]); ?>
|
|
|
|
</div>
|
|
|
|
<div class="max-w780 ind-first-p">
|
|
|
|
<?= markdown($comment['comment_content'], 'text'); ?>
|
|
|
|
</div>
|
|
|
|
<div class="text-sm flex gap">
|
|
|
|
<?= Html::votes($comment, 'comment'); ?>
|
|
|
|
|
|
|
|
<?php if ($post['post_closed'] == 0) : ?>
|
|
|
|
<?php if ($post['post_is_deleted'] == 0 || UserData::checkAdmin()) : ?>
|
|
|
|
<a data-answer_id="<?= $answer['answer_id']; ?>" data-comment_id="<?= $comment['comment_id']; ?>" class="add-comment gray">
|
|
|
|
<?= __('app.reply'); ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
2022-11-06 18:37:12 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php if (Access::author('comment', $comment, 30) === true) : ?>
|
|
|
|
<a data-post_id="<?= $post['post_id']; ?>" data-comment_id="<?= $comment['comment_id']; ?>" class="editcomm gray">
|
|
|
|
<?= __('app.edit'); ?>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (UserData::checkAdmin()) : ?>
|
|
|
|
<a data-type="comment" data-id="<?= $comment['comment_id']; ?>" class="type-action gray">
|
|
|
|
<?= $comment['comment_is_deleted'] == 1 ? __('app.recover') : __('app.remove'); ?>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php if (UserData::getUserId() != $comment['comment_user_id'] && UserData::getRegType(config('trust-levels.tl_add_report'))) : ?>
|
|
|
|
<a data-post_id="<?= $post['post_id']; ?>" data-type="comment" data-content_id="<?= $comment['comment_id']; ?>" class="msg-flag gray-600">
|
|
|
|
<svg class="icons">
|
|
|
|
<use xlink:href="/assets/svg/icons.svg#flag"></use>
|
|
|
|
</svg>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<div data-insert="<?= $comment['comment_id']; ?>" id="insert_id_<?= $comment['comment_id']; ?>" class="none"></div>
|
|
|
|
</li>
|
|
|
|
</ol>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php endforeach; ?>
|
|
|
|
<?php endforeach; ?>
|
2021-08-25 17:20:18 +02:00
|
|
|
</div>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php else : ?>
|
|
|
|
<?php if ($post['post_closed'] != 1) : ?>
|
|
|
|
<?php if (UserData::checkActiveUser()) : ?>
|
2022-06-28 22:21:28 +02:00
|
|
|
<?= insert('/_block/no-content', ['type' => 'small', 'text' => __('app.no_comments'), 'icon' => 'info']); ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php else : ?>
|
2022-06-28 22:21:28 +02:00
|
|
|
<?= insert('/_block/no-content', ['type' => 'small', 'text' => __('app.no_auth'), 'icon' => 'info']); ?>
|
2022-04-15 15:44:56 +02:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
2022-06-30 14:23:17 +02:00
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php if ($post['post_closed'] == 1) :
|
2022-10-17 09:05:08 +02:00
|
|
|
echo insert('/_block/no-content', ['type' => 'small', 'text' => __('app.close'), 'icon' => 'closed']);
|
2022-06-30 14:23:17 +02:00
|
|
|
endif; ?>
|