artbox_comment_list.php
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
use artbox\webcomment\models\CommentModel;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\Html;
use yii\web\View;
use yii\widgets\ListView;
use yii\widgets\Pjax;
/**
* @var CommentModel $comment_model
* @var array $list_params
* @var array $item_options
* @var string $item_view
* @var Model $model
* @var ActiveDataProvider $comments
* @var View $this
* @var string $display_name
* @var boolean $reply ,
* @var boolean $delete
*/
Pjax::begin();
if(( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) {
echo Html::tag('p', $success);
}
echo '<div class="comments-border"></div>';
echo '<h4 class="text-uppercase">'.Yii::t('artbox-comment', 'Комментарии').'</h4>';
echo ListView::widget([
'dataProvider' => $comments,
'itemOptions' => $item_options,
'itemView' => $item_view,
'emptyText' => false,
'summary' => '',
'viewParams' => [
'display_name' => $display_name,
'reply' => $reply,
'delete' => $delete,
'more' => $more,
'last' => $comments->count,
],
'beforeItem' => function ($model, $key, $index, $widget) use ($more, $comments) {
if ($more['key'] == $index and $more['show_'] ){
return "<a id='show_more_link' style='cursor:pointer'>".Yii::t('app', 'Показать еще')."</a>
<div id='show_more' style='display: none'>";
}
},
'afterItem' => function ($model, $key, $index, $widget) use ($more, $comments) {
if ($index == ($comments->count-1) and $more['show_'] and $more['key'] < $comments->count){
return "<a id='hide_more_link' style='cursor:pointer'>".Yii::t('app', 'Скрыть комментарии')."</a></div>";
}
}
]);
Pjax::end();