1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-08 01:14:24 +03:00
ifhub.club/application/frontend/components/comment/comments.tpl

156 lines
5.1 KiB
Smarty
Raw Normal View History

{**
* Комментарии
*
* @param array $comments
* @param integer $count
* @param integer $targetId
* @param string $targetType
* @param string $dateReadLast
* @param boolean $forbidAdd
* @param integer $authorId
* @param integer $lastCommentId
* @param array $pagination
* @param boolean $isSubscribed
* @param integer $maxLevel
*
* @param array $commentParams
* @param boolean $useSubscribe
*
* @param string $forbidText
* @param string $authorText
* @param string $addCommentText
* @param string $title
* @param string $titleNoComments
*
* @param string $classes
* @param array $attributes
* @param string $mods
*}
{$component = 'ls-comments'}
{component_define_params params=[ 'addCommentText', 'authorId', 'authorText', 'commentParams', 'comments', 'count', 'dateReadLast', 'forbidAdd',
2016-04-07 12:40:28 +03:00
'forbidText', 'isSubscribed', 'lastCommentId', 'maxLevel', 'pagination', 'targetId', 'targetType', 'title', 'titleNoComments',
'useSubscribe', 'mods', 'classes', 'attributes' ]}
{block 'comment-list-options'}
{* Максимальная вложенность *}
2016-04-07 12:40:28 +03:00
{$maxLevel = $maxLevel|default:Config::Get('module.comment.max_tree')}
{if $forbidAdd}
{$mods = "$mods forbid"}
{/if}
{/block}
{if $oUserCurrent && ! $pagination['total']}
{add_block group='toolbar' name='component@comment.toolbar'}
{/if}
2016-04-07 12:40:28 +03:00
<div class="{$component} js-comments {cmods name=$component mods=$mods} {$classes}"
data-target-type="{$targetType}"
data-target-id="{$targetId}"
2016-04-07 12:40:28 +03:00
data-comment-last-id="{$lastCommentId}"
{cattr list=$attributes}>
{* @hook Начало блока с комментариями *}
2016-04-07 12:40:28 +03:00
{hook run='comments_begin' params=$params}
{**
* Заголовок
*}
<header class="{$component}-header">
<h3 class="comments-title js-comments-title">
{if $count}
2016-04-07 12:40:28 +03:00
{lang "{$title|default:'comments.comments_declension'}" count=$count plural=true}
{else}
2016-04-07 12:40:28 +03:00
{lang "{$titleNoComments|default:'comments.no_comments'}"}
{/if}
</h3>
{* @hook Конец шапки *}
2016-04-07 12:40:28 +03:00
{hook run='comments_header_end' params=$params}
</header>
{**
* Экшнбар
*}
{$items = []}
{* Свернуть/развернуть все комментарии *}
{* Не показываем если древовидные комментарии отключены *}
{if $maxLevel > 0}
{$items[] = [ 'buttons' => [[
'classes' => 'js-comments-fold-all-toggle',
'text' => $aLang.comments.folding.fold_all
]]]}
{/if}
{* Подписка на комментарии *}
2016-04-07 12:40:28 +03:00
{if $useSubscribe && $oUserCurrent}
{$items[] = [ 'buttons' => [[
'classes' => "{$component}-subscribe js-comments-subscribe {if $isSubscribed}active{/if}",
'text' => ( $isSubscribed ) ? $aLang.comments.unsubscribe : $aLang.comments.subscribe
]]]}
{/if}
{if $items}
{component 'actionbar' name='comments_actionbar' items=$items classes="{$component}-actions"}
{/if}
2015-06-13 13:30:14 +03:00
{* @hook Хук перед списком комментариев *}
2016-04-07 12:40:28 +03:00
{hook run='comments_list_before' params=$params}
{**
* Комментарии
*}
2016-04-07 12:40:28 +03:00
<div class="ls-comment-list js-comment-list" {if ! $comments}style="display: none"{/if}>
{component 'comment' template='tree'
2016-04-07 12:40:28 +03:00
comments = $comments
forbidAdd = $forbidAdd
maxLevel = $maxLevel
authorId = $authorId
2016-04-07 12:40:28 +03:00
authorText = $authorText
dateReadLast = $dateReadLast
commentParams = $commentParams}
</div>
2015-06-13 13:30:14 +03:00
{* @hook Хук после списка комментариев *}
2016-04-07 12:40:28 +03:00
{hook run='comments_list_after' params=$params}
{**
* Пагинация
*}
{component 'pagination' classes="{$component}-pagination" params=$pagination}
{**
* Форма добавления комментария
*}
{* Проверяем запрещено комментирование или нет *}
{if $forbidAdd}
2016-04-07 12:40:28 +03:00
{component 'alert' mods='info' text=$forbidText}
{* Если разрешено то показываем форму добавления комментария *}
{else}
{if $oUserCurrent}
{* Кнопка открывающая форму *}
<h4 class="ls-comment-reply-root js-comment-reply js-comment-reply-root" data-id="0">
2016-04-07 12:40:28 +03:00
<a href="#" class="ls-link-dotted">{$addCommentText|default:$aLang.comments.form.title}</a>
</h4>
{else}
{component 'alert' mods='info' text=$aLang.comments.alerts.unregistered}
{/if}
{/if}
{* Форма добавления комментария *}
{if $oUserCurrent && ( ! $forbidAdd || ( $forbidAdd && $count ) )}
{component 'comment' template='form' classes='js-comment-form' targetType=$targetType targetId=$targetId}
{/if}
{* @hook Конец блока с комментариями *}
2016-04-07 12:40:28 +03:00
{hook run='comments_end' params=$params}
2015-06-13 13:30:14 +03:00
</div>