1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use yii\helpers\Url; |
4
|
|
|
use yii\widgets\Pjax; |
5
|
|
|
use yii\widgets\ListView; |
6
|
|
|
use ogheo\comments\helpers\CommentsHelper; |
7
|
|
|
use ogheo\comments\Module as CommentsModule; |
8
|
|
|
|
9
|
|
|
/** @var $commentModel */ |
10
|
|
|
/** @var $commentsCounter */ |
11
|
|
|
/** @var $dataProvider */ |
12
|
|
|
/** @var $widget */ |
13
|
|
|
|
14
|
|
|
$cacheKey = $commentModel->url . $commentModel->model . $commentModel->model_key; |
15
|
|
|
$cacheTag = Url::previous(CommentsModule::getInstance()->urlCacheSessionKey); |
16
|
|
|
$cacheProperties = CommentsHelper::getCacheProperties($cacheTag); |
17
|
|
|
|
18
|
|
|
?> |
19
|
|
|
|
20
|
|
|
<div id="<?= $widget->wrapperId ?>" class="comments"> |
21
|
|
|
|
22
|
|
|
<?php if ($widget->defaultCommentsView === 'restricted') : ?> |
23
|
|
|
<div id="<?= $widget->showCommentsId ?>" class="show-comments text-center"> |
24
|
|
|
<a href="#" data-action="show-comments"> |
25
|
|
|
<?= Yii::t('comments', 'Comments') ?> |
26
|
|
|
</a> |
27
|
|
|
</div> |
28
|
|
|
<?php endif; ?> |
29
|
|
|
|
30
|
|
|
<div id="<?= $widget->fullCommentsId ?>" <?= $widget->defaultCommentsView === 'restricted' ? 'class="hidden"' : '' ?>> |
31
|
|
|
|
32
|
|
|
<?php Pjax::begin([ |
33
|
|
|
'id' => $widget->pjaxContainerId |
34
|
|
|
]); ?> |
35
|
|
|
|
36
|
|
|
<div id="comments-container-header" class="row"> |
37
|
|
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comments-header"> |
38
|
|
|
|
39
|
|
|
<?php if ($widget->defaultCommentsView === 'restricted') : ?> |
40
|
|
|
<div class="hide-comments"> |
41
|
|
|
<a href="#" data-action="hide-comments"> |
42
|
|
|
<?= Yii::t('comments', 'Hide') ?> <i class="glyphicon glyphicon-remove"></i> |
43
|
|
|
</a> |
44
|
|
|
</div> |
45
|
|
|
<?php endif; ?> |
46
|
|
|
|
47
|
|
|
<?php if ($this->beginCache($cacheKey . '-counter', $cacheProperties)) { ?> |
48
|
|
|
<h2 class="page-header"> |
49
|
|
|
<?= Yii::t('comments', 'Comments') ?> |
50
|
|
|
<small> |
51
|
|
|
(<?= $commentsCounter->count() ?>) |
52
|
|
|
</small> |
53
|
|
|
</h2> |
54
|
|
|
<?php $this->endCache(); } ?> |
55
|
|
|
|
56
|
|
|
</div> |
57
|
|
|
</div> |
58
|
|
|
|
59
|
|
View Code Duplication |
<?php if ($widget->formPosition === 'top') { |
|
|
|
|
60
|
|
|
echo $this->render($widget->formView, [ |
61
|
|
|
'commentModel' => $commentModel, |
62
|
|
|
'widget' => $widget |
63
|
|
|
]); |
64
|
|
|
} ?> |
65
|
|
|
|
66
|
|
|
<?php if ($this->beginCache($cacheKey, $cacheProperties)) { ?> |
67
|
|
|
<div class="row"> |
68
|
|
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> |
69
|
|
|
<?= ListView::widget( |
70
|
|
|
array_merge( |
71
|
|
|
[ |
72
|
|
|
'dataProvider' => $dataProvider, |
73
|
|
|
], $widget->getListViewConfig() |
74
|
|
|
) |
75
|
|
|
) ?> |
76
|
|
|
</div> |
77
|
|
|
</div> |
78
|
|
|
<?php $this->endCache(); } ?> |
79
|
|
|
|
80
|
|
View Code Duplication |
<?php if ($widget->formPosition === 'bottom') { |
|
|
|
|
81
|
|
|
echo $this->render($widget->formView, [ |
82
|
|
|
'commentModel' => $commentModel, |
83
|
|
|
'widget' => $widget |
84
|
|
|
]); |
85
|
|
|
} ?> |
86
|
|
|
|
87
|
|
|
<?php Pjax::end(); ?> |
88
|
|
|
|
89
|
|
|
</div> |
90
|
|
|
|
91
|
|
|
</div> |
92
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.