1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Comments;
13
14 use ICanBoogie\ActiveRecord\Query;
15 use ICanBoogie\I18n;
16
17 class ViewProvider extends \Icybee\Modules\Views\ActiveRecordProvider
18 {
19 protected function alter_conditions(array $conditions)
20 {
21 if (isset($this->context['this']) && $this->context['this'] instanceof \Icybee\Modules\Nodes\Node)
22 {
23 $conditions['nid'] = $this->context['this']->nid;
24 }
25
26 return $conditions;
27 }
28
29 protected function alter_query(Query $query, array $conditions)
30 {
31 if (isset($conditions['nid']))
32 {
33 $query->where('nid = ?', (int) $conditions['nid']);
34 }
35
36 $query->where('status != "spam" && status != "pending"');
37
38 return $query->order('created_at');
39 }
40
41 protected function alter_context(\BlueTihi\Context $context, Query $query, array $conditions)
42 {
43 $count = $query->count;
44
45 $context['count'] = I18n\t('comments.count', array(':count' => $count));
46
47 return $context;
48 }
49 }