92 lines
3.8 KiB
Smarty
92 lines
3.8 KiB
Smarty
{$currentAdmin = getAdminUser()}
|
|
{$allowAnonymous = false}
|
|
{ifmodule COMMENTS__COMMENTS_ANONYMOUS}
|
|
{$allowAnonymous = true}
|
|
{/ifmodule}
|
|
{$allowReplies = ($ctrl.user || ($currentAdmin.id > 0) || $allowAnonymous)}
|
|
{function renderComments}
|
|
|
|
{foreach $comments as $comment}
|
|
{$user = $comment->getUser()}
|
|
{$admin = $comment->getAdmin()}
|
|
|
|
{if $user}
|
|
{$name = join(' ', [$user.name, $user.surname])}
|
|
{else}
|
|
{$name = $admin.name|default:$admin.login}
|
|
{/if}
|
|
<div data-comment="{$comment.id}"
|
|
class="comment-item comment-item-level-{$level}{if $comment.id_admin} comment-item-admin-answer{/if}">
|
|
<div class="comment-info">
|
|
<h6 class="name">{$name|default:"{t}Anonymní{/t}"}</h6>
|
|
<div>
|
|
{if $allowReplies}
|
|
<p>
|
|
<a href="" data-comment-reply="{$comment.id}">{t}reagovat{/t}</a>
|
|
</p>
|
|
{/if}
|
|
<p class="comment-report">
|
|
<a href="" data-wpj-focus="{path('kupshop_content_contactform_sendform', ['type'=>'report-inappropriate-content', 'report_type'=>'Comments', 'content_id'=>{$comment.id}])}" data-wpj-focus-ajax="1">
|
|
{t}Nahlásit{/t}
|
|
</a>
|
|
</p>
|
|
<span class="date">{$comment.date|format_date_locale_pretty:'d. L. Y'}</span>
|
|
</div>
|
|
</div>
|
|
{if $comment.parent}
|
|
<p class="comment-reaction">{t}Reakce na{/t}: {$comment.parent.content nofilter}</p>
|
|
{/if}
|
|
<p class="comment-text">{$comment.content nofilter}</p>
|
|
|
|
{* Sem se nacte formulat po kliknuti na tlacitko "Odpovedet" *}
|
|
<div data-comment-form-wrapper="{$comment.id}"></div>
|
|
</div>
|
|
{* Pokud ma komentar odpovedi, tak je vyrenderovat *}
|
|
{if $comment.children}
|
|
<div class="comment-answers comment-answers-{$level}">
|
|
<a href="" class="show-answers" data-opener="[data-comment-answer='{$comment.id}']">
|
|
<span class="show">{$comment->getChildrenCount()} {t plural="odpovědi" plural5="odpovědí" count=$comment->getChildrenCount()}odpověď{/t}</span>
|
|
<span class="hide">{t}skrýt odpovědi{/t}</span>
|
|
</a>
|
|
<div data-comment-answer="{$comment.id}" style="display: none;">
|
|
{renderComments comments=$comment.children level=($level + 1)}
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
{/foreach}
|
|
{/function}
|
|
|
|
<div data-comments-wrapper="{$data.config|json_encode}">
|
|
<div>
|
|
{block "comments-header"}
|
|
<div class="comments-header">
|
|
<div>
|
|
<h6>{$comments.totalCount} {t plural="příspěvky" plural5="příspěvků" count=$comments.totalCount}příspěvek{/t}</h6>
|
|
<h2>{t}Zeptejte se{/t}</h2>
|
|
<p>{t}Máte dotaz k tomuto produktu? Využijte této diskuze.{/t}</p>
|
|
{if !$ctrl.user && !$allowAnonymous}
|
|
<p>{t escape=false url={url s=login}}Pro využití diskuze se <a href="{url}" class="cart-signin">přihlašte</a>.{/t}</p>
|
|
{/if}
|
|
</div>
|
|
{if $ctrl.user || $allowAnonymous}
|
|
<div>
|
|
<button class="btn btn-primary" data-comment-add="">{t}Položit dotaz{/t}</button>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/block}
|
|
{* sem se nacte formular po kliknu na tlacitko "Pridat komentar" *}
|
|
<div data-comment-form-wrapper=""></div>
|
|
</div>
|
|
|
|
<div data-comments="" data-reload="comments-{$data.pager.number}">
|
|
{renderComments comments=$data.comments level=0}
|
|
</div>
|
|
|
|
{if $data.pager.number < $data.pager.count}
|
|
<button data-comments-load-more="{$data.pager.number}" data-comments-total-pages="{$data.pager.count}" class="btn btn-secondary">
|
|
{t}Načíst další{/t}
|
|
</button>
|
|
{/if}
|
|
</div>
|