1 | <?php |
||
24 | abstract class BaseComment extends Widget |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | public $tag = 'ul'; |
||
30 | /** |
||
31 | * @var |
||
32 | */ |
||
33 | public $model; |
||
34 | /** |
||
35 | * @var |
||
36 | */ |
||
37 | public $enableThreadComments; |
||
38 | /** |
||
39 | * @var |
||
40 | */ |
||
41 | public $maxDepth; |
||
42 | /** |
||
43 | * @var |
||
44 | */ |
||
45 | public $commentOrder; |
||
46 | /** |
||
47 | * @var int |
||
48 | */ |
||
49 | public $avatarSize = 48; |
||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | public $options = ['class' => 'comments']; |
||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | public $childOptions = ['class' => 'child']; |
||
58 | /** |
||
59 | * @var array |
||
60 | */ |
||
61 | public $itemOptions = ['class' => 'media']; |
||
62 | |||
63 | /** |
||
64 | * @var |
||
65 | */ |
||
66 | protected $pageSize; |
||
67 | /** |
||
68 | * @var |
||
69 | */ |
||
70 | protected $pages; |
||
71 | /** |
||
72 | * @var |
||
73 | */ |
||
74 | protected $comments; |
||
75 | /** |
||
76 | * @var |
||
77 | */ |
||
78 | protected $tagItem; |
||
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | public function init() |
||
114 | |||
115 | /** |
||
116 | * @inheritdoc |
||
117 | */ |
||
118 | public function run() |
||
138 | |||
139 | |||
140 | /** |
||
141 | * @param \common\models\BaseComment $comment |
||
142 | * @param int $depth |
||
143 | * @throws \Exception |
||
144 | */ |
||
145 | protected function displayComment($comment, $depth = 0) |
||
146 | { |
||
147 | echo Html::beginTag('div', [ |
||
148 | 'id' => 'comment-' . $comment->id, |
||
149 | 'class' => $comment->child ? 'parent depth-' . $depth : 'depth-' . $depth, |
||
150 | ]); |
||
151 | |||
152 | if (Option::get('show_avatars')) { |
||
153 | ?> |
||
154 | <div class="media-left avatar"> |
||
155 | <?= Gravatar::widget([ |
||
156 | 'email' => $comment->email, |
||
157 | 'options' => [ |
||
158 | 'alt' => $comment->author, |
||
159 | 'class' => 'avatar', |
||
160 | 'width' => $this->avatarSize, |
||
161 | 'height' => $this->avatarSize, |
||
162 | ], |
||
163 | 'defaultImage' => Option::get('avatar_default'), |
||
164 | 'rating' => Option::get('avatar_rating'), |
||
165 | 'size' => $this->avatarSize, |
||
166 | ]) ?> |
||
167 | |||
168 | </div> |
||
169 | <?php |
||
170 | |||
171 | } |
||
172 | ?> |
||
173 | <div class="media-body comment-body"> |
||
174 | <p class="meta"> |
||
175 | <strong class="author vcard"> |
||
176 | <span class="fn"> |
||
177 | <?= $comment->author ? $comment->author : \Yii::t('writesdown', 'Anonymous') ?> |
||
178 | |||
179 | </span> |
||
180 | </strong> |
||
181 | - |
||
182 | <time class="date published" datetime="<?= \Yii::$app |
||
183 | ->formatter |
||
184 | ->asDatetime($comment->date) ?>"> |
||
185 | <?= \Yii::$app->formatter->asDate($comment->date) ?> |
||
186 | |||
187 | </time> |
||
188 | |||
189 | <?php if ($depth < $this->maxDepth && $this->enableThreadComments) { |
||
190 | echo Html::a(\Yii::t('writesdown', 'Reply'), '#', [ |
||
191 | 'class' => 'comment-reply-link', |
||
192 | 'data-id' => $comment->id, |
||
193 | ]); |
||
194 | } |
||
195 | ?> |
||
196 | |||
197 | </p> |
||
198 | <div class="comment-content"> |
||
199 | <?= $comment->content ?> |
||
200 | |||
201 | </div> |
||
202 | </div> |
||
203 | <?php |
||
204 | echo Html::endTag('div'); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @param $comments |
||
209 | * @param int $depth |
||
210 | */ |
||
211 | protected function renderComments($comments, $depth = 0) |
||
228 | |||
229 | /** |
||
230 | * Get comment children. |
||
231 | * |
||
232 | * @param int $id |
||
233 | */ |
||
234 | protected function getChildren($id) |
||
237 | |||
238 | /** |
||
239 | * Set comment model and pagination. |
||
240 | */ |
||
241 | protected function setComments() |
||
244 | } |
||
245 |