Commit d85e218176a79beb9136462fdca28106f4cbad7b
Merge remote-tracking branch 'origin/master'
Showing
12 changed files
with
390 additions
and
25 deletions
Show diff stats
.gitignore
common/modules/comment/interfaces/CommentInterface.php
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | interface CommentInterface { | 4 | interface CommentInterface { |
5 | public function load($data, $formName = null); | 5 | public function load($data, $formName = null); |
6 | public function formName(); | 6 | public function formName(); |
7 | - public function getComments($model, $model_id); | 7 | + public static function getComments($model, $model_id); |
8 | public function postComment(); | 8 | public function postComment(); |
9 | public function deleteComment(); | 9 | public function deleteComment(); |
10 | public function updateComment(); | 10 | public function updateComment(); |
common/modules/comment/models/Comment.php
@@ -173,9 +173,9 @@ | @@ -173,9 +173,9 @@ | ||
173 | * | 173 | * |
174 | * @return ActiveQuery | 174 | * @return ActiveQuery |
175 | */ | 175 | */ |
176 | - public function getComments($model, $model_id) | 176 | + public static function getComments($model, $model_id) |
177 | { | 177 | { |
178 | - return $this->find() | 178 | + return self::find() |
179 | ->where([ | 179 | ->where([ |
180 | 'comment.model' => $model, | 180 | 'comment.model' => $model, |
181 | 'comment.model_id' => $model_id, | 181 | 'comment.model_id' => $model_id, |
@@ -258,8 +258,9 @@ | @@ -258,8 +258,9 @@ | ||
258 | return true; | 258 | return true; |
259 | } else { | 259 | } else { |
260 | return \Yii::$app->user->can(\common\modules\comment\Permissions::CREATE, [ | 260 | return \Yii::$app->user->can(\common\modules\comment\Permissions::CREATE, [ |
261 | - 'model' => $this->model, | ||
262 | - 'model_id' => $this->model_id, | 261 | + 'model' => $this->model, |
262 | + 'model_id' => $this->model_id, | ||
263 | + 'comment_model' => $this, | ||
263 | ]); | 264 | ]); |
264 | } | 265 | } |
265 | } | 266 | } |
@@ -333,11 +334,11 @@ | @@ -333,11 +334,11 @@ | ||
333 | 334 | ||
334 | public function getAuthor($guestMark = '') | 335 | public function getAuthor($guestMark = '') |
335 | { | 336 | { |
336 | - if(!empty($this->user)) { | 337 | + if(!empty( $this->user )) { |
337 | return $this->user->name; | 338 | return $this->user->name; |
338 | } else { | 339 | } else { |
339 | $name = $this->user_name; | 340 | $name = $this->user_name; |
340 | - if(!empty($guestMark)) { | 341 | + if(!empty( $guestMark )) { |
341 | $name .= $guestMark; | 342 | $name .= $guestMark; |
342 | } | 343 | } |
343 | return $name; | 344 | return $name; |
@@ -395,8 +396,13 @@ | @@ -395,8 +396,13 @@ | ||
395 | return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); | 396 | return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); |
396 | } | 397 | } |
397 | 398 | ||
398 | - public function buildButtons($buttons = ['delete', 'update', 'reply']) | ||
399 | - { | 399 | + public function buildButtons( |
400 | + $buttons = [ | ||
401 | + 'delete', | ||
402 | + 'update', | ||
403 | + 'reply', | ||
404 | + ] | ||
405 | + ) { | ||
400 | if(in_array('delete', $buttons)) { | 406 | if(in_array('delete', $buttons)) { |
401 | if($this->checkDelete()) { | 407 | if($this->checkDelete()) { |
402 | $this->buttons[ 'delete' ] = Url::to([ | 408 | $this->buttons[ 'delete' ] = Url::to([ |
common/modules/comment/models/CommentProject.php
@@ -222,7 +222,7 @@ | @@ -222,7 +222,7 @@ | ||
222 | * | 222 | * |
223 | * @return ActiveQuery | 223 | * @return ActiveQuery |
224 | */ | 224 | */ |
225 | - public function getComments($model, $model_id) | 225 | + public static function getComments($model, $model_id) |
226 | { | 226 | { |
227 | /** | 227 | /** |
228 | * @var User $user | 228 | * @var User $user |
@@ -231,7 +231,7 @@ | @@ -231,7 +231,7 @@ | ||
231 | if(!empty($user)) { | 231 | if(!empty($user)) { |
232 | $project = Project::findOne($model_id); | 232 | $project = Project::findOne($model_id); |
233 | if(!empty($project) && $user->id == $project->user_id) { | 233 | if(!empty($project) && $user->id == $project->user_id) { |
234 | - return $this->find() | 234 | + return self::find() |
235 | ->where([ | 235 | ->where([ |
236 | 'comment_project.model' => $model, | 236 | 'comment_project.model' => $model, |
237 | 'comment_project.model_id' => $model_id, | 237 | 'comment_project.model_id' => $model_id, |
@@ -240,7 +240,7 @@ | @@ -240,7 +240,7 @@ | ||
240 | ->with('currency', 'user', 'user.userInfo', 'user.companyInfo', 'user.comments'); | 240 | ->with('currency', 'user', 'user.userInfo', 'user.companyInfo', 'user.comments'); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | - $query = $this->find() | 243 | + $query = self::find() |
244 | ->where([ | 244 | ->where([ |
245 | 'comment_project.model' => $model, | 245 | 'comment_project.model' => $model, |
246 | 'comment_project.model_id' => $model_id, | 246 | 'comment_project.model_id' => $model_id, |
common/modules/comment/models/CommentProjectAnswer.php
0 → 100644
1 | +<?php | ||
2 | + namespace common\modules\comment\models; | ||
3 | + | ||
4 | + use common\models\Project; | ||
5 | + use common\models\User; | ||
6 | + use yii\db\ActiveQuery; | ||
7 | + use yii\helpers\Url; | ||
8 | + | ||
9 | + /** | ||
10 | + * Class Comment | ||
11 | + * @property bool $guestComment | ||
12 | + * @property integer $comment_id | ||
13 | + * @property string $text | ||
14 | + * @property int $user_id | ||
15 | + * @property string $user_name | ||
16 | + * @property string $user_email | ||
17 | + * @property int $comment_pid | ||
18 | + * @property int $status | ||
19 | + * @property string $date_add | ||
20 | + * @property string $date_update | ||
21 | + * @property string $date_delete | ||
22 | + * @property string $model | ||
23 | + * @property int $model_id | ||
24 | + * @property Rating $rating | ||
25 | + * @property User $user | ||
26 | + * @property User $author | ||
27 | + * @package common\modules\comment\models | ||
28 | + */ | ||
29 | + class CommentProjectAnswer extends Comment | ||
30 | + { | ||
31 | + | ||
32 | + public function rules() | ||
33 | + { | ||
34 | + return [ | ||
35 | + [ | ||
36 | + [ | ||
37 | + 'text', | ||
38 | + 'user_name', | ||
39 | + 'user_email', | ||
40 | + ], | ||
41 | + 'required', | ||
42 | + ], | ||
43 | + [ | ||
44 | + [ | ||
45 | + 'rating', | ||
46 | + ], | ||
47 | + 'safe', | ||
48 | + ], | ||
49 | + [ | ||
50 | + [ 'user_email' ], | ||
51 | + 'email', | ||
52 | + ], | ||
53 | + [ | ||
54 | + [ 'user_name' ], | ||
55 | + 'string', | ||
56 | + ], | ||
57 | + [ | ||
58 | + [ | ||
59 | + 'comment_id', | ||
60 | + 'comment_pid', | ||
61 | + ], | ||
62 | + 'integer', | ||
63 | + ], | ||
64 | + [ | ||
65 | + [ 'status' ], | ||
66 | + 'default', | ||
67 | + 'value' => 1, | ||
68 | + ], | ||
69 | + [ | ||
70 | + [ 'comment_pid' ], | ||
71 | + 'exist', | ||
72 | + 'targetAttribute' => 'comment_id', | ||
73 | + 'filter' => [ | ||
74 | + 'model' => $this->model, | ||
75 | + 'model_id' => $this->model_id, | ||
76 | + ], | ||
77 | + ], | ||
78 | + ]; | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * @param string $model | ||
83 | + * @param integer $model_id | ||
84 | + * | ||
85 | + * @return ActiveQuery | ||
86 | + */ | ||
87 | + public static function getComments($model, $model_id) | ||
88 | + { | ||
89 | + $query = self::find() | ||
90 | + ->where([ | ||
91 | + 'comment.model' => $model, | ||
92 | + 'comment.model_id' => $model_id, | ||
93 | + 'comment.status' => 1, | ||
94 | + 'comment.comment_pid' => NULL, | ||
95 | + ]) | ||
96 | + ->with('parent'); | ||
97 | + $project = Project::findOne($model_id); | ||
98 | + $user = \Yii::$app->user; | ||
99 | + if(empty( $user ) || $project->user_id != $user->id) { | ||
100 | + $query->innerJoin([ 'child' => 'comment' ], 'comment.comment_id = child.comment_pid') | ||
101 | + ->andWhere([ | ||
102 | + 'not', | ||
103 | + [ 'child.comment_id' => NULL ], | ||
104 | + ]); | ||
105 | + } | ||
106 | + return $query; | ||
107 | + } | ||
108 | + | ||
109 | + public function checkCreate() | ||
110 | + { | ||
111 | + if($this->getGuestComment()) { | ||
112 | + return true; | ||
113 | + } else { | ||
114 | + return \Yii::$app->user->can(\common\modules\comment\Permissions::CREATE, [ | ||
115 | + 'model' => $this->model, | ||
116 | + 'model_id' => $this->model_id, | ||
117 | + 'comment_model' => $this, | ||
118 | + ]); | ||
119 | + } | ||
120 | + } | ||
121 | + | ||
122 | + public function checkUpdate() | ||
123 | + { | ||
124 | + if($this->scenario == self::SCENARIO_GUEST) { | ||
125 | + return false; | ||
126 | + } else { | ||
127 | + return \Yii::$app->user->can(\common\modules\comment\Permissions::UPDATE, [ | ||
128 | + 'model' => $this->model, | ||
129 | + 'model_id' => $this->model_id, | ||
130 | + 'comment' => $this, | ||
131 | + ]) || \Yii::$app->user->can(\common\modules\comment\Permissions::UPDATE_OWN, [ | ||
132 | + 'model' => $this->model, | ||
133 | + 'model_id' => $this->model_id, | ||
134 | + 'comment' => $this, | ||
135 | + ]); | ||
136 | + } | ||
137 | + } | ||
138 | + | ||
139 | + public function checkDelete() | ||
140 | + { | ||
141 | + if($this->scenario == self::SCENARIO_GUEST) { | ||
142 | + return false; | ||
143 | + } else { | ||
144 | + return ( \Yii::$app->user->can(\common\modules\comment\Permissions::DELETE, [ | ||
145 | + 'model' => $this->model, | ||
146 | + 'model_id' => $this->model_id, | ||
147 | + 'comment' => $this, | ||
148 | + ]) || \Yii::$app->user->can(\common\modules\comment\Permissions::DELETE_OWN, [ | ||
149 | + 'model' => $this->model, | ||
150 | + 'model_id' => $this->model_id, | ||
151 | + 'comment' => $this, | ||
152 | + ]) ); | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + public function checkReply() | ||
157 | + { | ||
158 | + if($this->scenario != self::SCENARIO_GUEST) { | ||
159 | + if(!$this->isNewRecord && empty( $this->comment_pid )) { | ||
160 | + $project = Project::findOne($this->model_id); | ||
161 | + if($project->user_id == \Yii::$app->user->id) { | ||
162 | + return true; | ||
163 | + } | ||
164 | + } | ||
165 | + } | ||
166 | + return false; | ||
167 | + } | ||
168 | + | ||
169 | + public function getChild() | ||
170 | + { | ||
171 | + return $this->hasOne($this->className(), [ 'comment_pid' => 'comment_id' ]); | ||
172 | + } | ||
173 | + | ||
174 | + } |
common/modules/comment/rbac/ArtboxCommentCreateRule.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | namespace common\modules\comment\rbac; | 3 | namespace common\modules\comment\rbac; |
4 | 4 | ||
5 | + use common\modules\comment\models\CommentProject; | ||
5 | use yii\rbac\Rule; | 6 | use yii\rbac\Rule; |
6 | 7 | ||
7 | class ArtboxCommentCreateRule extends Rule | 8 | class ArtboxCommentCreateRule extends Rule |
@@ -11,7 +12,7 @@ | @@ -11,7 +12,7 @@ | ||
11 | 12 | ||
12 | public function execute($user, $item, $params) | 13 | public function execute($user, $item, $params) |
13 | { | 14 | { |
14 | - if($params[ 'model' ] == \common\models\Project::className()) { | 15 | + if($params[ 'model' ] == \common\models\Project::className() && !empty($params['comment_model']) && $params['comment_model'] == CommentProject::className()) { |
15 | return $this->checkProject($user, $item, $params); | 16 | return $this->checkProject($user, $item, $params); |
16 | } | 17 | } |
17 | return true; | 18 | return true; |
common/modules/comment/widgets/CommentWidget.php
@@ -57,6 +57,8 @@ | @@ -57,6 +57,8 @@ | ||
57 | */ | 57 | */ |
58 | public $class_options = [ ]; | 58 | public $class_options = [ ]; |
59 | 59 | ||
60 | + public $provider_options = [ ]; | ||
61 | + | ||
60 | /** | 62 | /** |
61 | * @var bool Wheather to display comment list | 63 | * @var bool Wheather to display comment list |
62 | */ | 64 | */ |
@@ -76,6 +78,7 @@ | @@ -76,6 +78,7 @@ | ||
76 | * @var bool Whether to allow one user post multiple comments | 78 | * @var bool Whether to allow one user post multiple comments |
77 | */ | 79 | */ |
78 | public $allow_multiple = true; | 80 | public $allow_multiple = true; |
81 | + | ||
79 | public $allow_reply = true; | 82 | public $allow_reply = true; |
80 | 83 | ||
81 | /** | 84 | /** |
@@ -197,10 +200,10 @@ | @@ -197,10 +200,10 @@ | ||
197 | if($this->display_comment_form && $this->comment_class->checkCreate()) { | 200 | if($this->display_comment_form && $this->comment_class->checkCreate()) { |
198 | $tag = ArrayHelper::remove($this->form_options, 'tag', 'div'); | 201 | $tag = ArrayHelper::remove($this->form_options, 'tag', 'div'); |
199 | $view = ArrayHelper::remove($this->form_options, 'view'); | 202 | $view = ArrayHelper::remove($this->form_options, 'view'); |
200 | - if(!empty($this->form_options['class'])) { | ||
201 | - $this->form_options['class'] .= ' '.self::$baseClass['form_container']; | 203 | + if(!empty( $this->form_options[ 'class' ] )) { |
204 | + $this->form_options[ 'class' ] .= ' ' . self::$baseClass[ 'form_container' ]; | ||
202 | } else { | 205 | } else { |
203 | - $this->form_options['class'] = self::$baseClass['form_container']; | 206 | + $this->form_options[ 'class' ] = self::$baseClass[ 'form_container' ]; |
204 | } | 207 | } |
205 | $this->parts[ 'form' ] = Html::tag($tag, $this->renderForm($view), $this->form_options); | 208 | $this->parts[ 'form' ] = Html::tag($tag, $this->renderForm($view), $this->form_options); |
206 | } | 209 | } |
@@ -209,15 +212,15 @@ | @@ -209,15 +212,15 @@ | ||
209 | public function createDataProvider() | 212 | public function createDataProvider() |
210 | { | 213 | { |
211 | $this->dataProvider = new \yii\data\ActiveDataProvider([ | 214 | $this->dataProvider = new \yii\data\ActiveDataProvider([ |
212 | - 'query' => $this->comment_class->getComments($this->model, $this->model_id), | ||
213 | - 'sort' => new Sort([ | 215 | + 'query' => ArrayHelper::remove($this->provider_options, 'query', $this->comment_class->getComments($this->model, $this->model_id)), |
216 | + 'sort' => ArrayHelper::remove($this->provider_options, 'sort', new Sort([ | ||
214 | 'defaultOrder' => [ | 217 | 'defaultOrder' => [ |
215 | 'date_add' => SORT_DESC, | 218 | 'date_add' => SORT_DESC, |
216 | ], | 219 | ], |
217 | - ]), | ||
218 | - 'pagination' => [ | 220 | + ])), |
221 | + 'pagination' => ArrayHelper::remove($this->provider_options, 'query', [ | ||
219 | 'pageSize' => 10, | 222 | 'pageSize' => 10, |
220 | - ], | 223 | + ]), |
221 | ]); | 224 | ]); |
222 | } | 225 | } |
223 | 226 | ||
@@ -258,10 +261,10 @@ | @@ -258,10 +261,10 @@ | ||
258 | $template = preg_replace('/{list}/', ArrayHelper::remove($parts, 'list', ''), $template); | 261 | $template = preg_replace('/{list}/', ArrayHelper::remove($parts, 'list', ''), $template); |
259 | $template = preg_replace('/{form}/', ArrayHelper::remove($parts, 'form', ''), $template); | 262 | $template = preg_replace('/{form}/', ArrayHelper::remove($parts, 'form', ''), $template); |
260 | $tag = ArrayHelper::remove($options, 'tag', 'div'); | 263 | $tag = ArrayHelper::remove($options, 'tag', 'div'); |
261 | - if(!empty($options['class'])) { | ||
262 | - $options['class'] .= ' '.self::$baseClass['widget_container']; | 264 | + if(!empty( $options[ 'class' ] )) { |
265 | + $options[ 'class' ] .= ' ' . self::$baseClass[ 'widget_container' ]; | ||
263 | } else { | 266 | } else { |
264 | - $options['class'] = self::$baseClass['widget_container']; | 267 | + $options[ 'class' ] = self::$baseClass[ 'widget_container' ]; |
265 | } | 268 | } |
266 | return Html::tag($tag, $template, $options); | 269 | return Html::tag($tag, $template, $options); |
267 | } | 270 | } |
common/modules/comment/widgets/views/_question_comment_view.php
0 → 100644
1 | +<?php | ||
2 | + use common\models\User; | ||
3 | + use common\modules\comment\widgets\CommentWidget; | ||
4 | + use yii\helpers\Html; | ||
5 | + use yii\web\View; | ||
6 | + | ||
7 | + /** | ||
8 | + * @var View $this | ||
9 | + * @var \common\modules\comment\models\Comment $model Current comment model | ||
10 | + * @var integer $key ID of current comment | ||
11 | + * @var integer $index index of current element according | ||
12 | + * to current page, starting from 0 | ||
13 | + * @var \yii\widgets\ListView $widget current ListView instance | ||
14 | + * @var User $user | ||
15 | + */ | ||
16 | + $user = $model->user; | ||
17 | + $model->buildButtons(['reply']); | ||
18 | +?> | ||
19 | + <div class="comments-name <?= CommentWidget::$baseClass[ 'comment_author' ] ?>"> | ||
20 | + <?= $model->getAuthor(' (Гость)') ?> | ||
21 | + </div> | ||
22 | +<?php | ||
23 | + /* == STATUS PRO == | ||
24 | + ?> | ||
25 | + <div class="comments-status"><span>Pro</span></div> | ||
26 | + <?php | ||
27 | + */ | ||
28 | +?> | ||
29 | + <div class="comments-date"><?= \Yii::$app->formatter->asDate($model->date_add, 'php:d.m.Y') ?></div> | ||
30 | + <div class="comments-content"> | ||
31 | + <?= $model->text ?> | ||
32 | + </div> | ||
33 | + <div> | ||
34 | + <?php | ||
35 | + if(!empty( $model->buttons[ 'delete' ] )) { | ||
36 | + echo Html::a(($model->user_id != NULL && $model->user_id == \Yii::$app->user->id)?'Удалить':'Пожаловаться ', $model->buttons[ 'delete' ], [ 'class' => CommentWidget::$baseClass[ 'comment_delete' ] ]); | ||
37 | + } | ||
38 | + if(!empty( $model->buttons[ 'update' ] )) { | ||
39 | + echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => CommentWidget::$baseClass[ 'comment_update' ] ]); | ||
40 | + } | ||
41 | + if(!empty( $model->buttons[ 'reply' ] )) { | ||
42 | + echo Html::a('Ответить', $model->buttons[ 'reply' ], [ 'class' => CommentWidget::$baseClass[ 'comment_reply' ] ]); | ||
43 | + } | ||
44 | + ?> | ||
45 | + </div> | ||
46 | +<?php | ||
47 | + if(!$model->isNewRecord) { | ||
48 | + $this->registerJs("$('div.rating').rating( | ||
49 | + { | ||
50 | + fx : 'full', readOnly : 'true', url : 'rating.php' | ||
51 | + } | ||
52 | + );"); | ||
53 | + } | ||
54 | +?> | ||
55 | +<?php | ||
56 | + /* == PROJECT INFO == | ||
57 | + ?> | ||
58 | + <div class="comments-project-link">Проект: <a href="#">Ремонт спальни</a></div> | ||
59 | + <?php | ||
60 | + */ | ||
61 | +?> | ||
0 | \ No newline at end of file | 62 | \ No newline at end of file |
common/modules/comment/widgets/views/form-comment-answer.php
0 → 100644
1 | +<?php | ||
2 | + /** | ||
3 | + * @var \common\modules\comment\models\Comment $model | ||
4 | + * @var \common\models\User $user | ||
5 | + * @var \yii\data\ActiveDataProvider $dataProvider | ||
6 | + * @var null|\common\modules\comment\models\Rating $rating | ||
7 | + */ | ||
8 | + use yii\widgets\ActiveForm; | ||
9 | + use yii\helpers\Html; | ||
10 | + | ||
11 | +?> | ||
12 | +<div class="new-portf-comm-count">Вопросов: <?= $dataProvider->totalCount ?></div> | ||
13 | + | ||
14 | +<div class="new-portf-add-comm style"> | ||
15 | + | ||
16 | + <?php | ||
17 | + $form = ActiveForm::begin(); | ||
18 | + if($model->scenario == $model::SCENARIO_GUEST) { | ||
19 | + echo $form->field($model, 'user_name', [ | ||
20 | + 'options' => [ | ||
21 | + 'class' => 'input-blocks-comm', | ||
22 | + ], | ||
23 | + 'inputOptions' => [ | ||
24 | + 'class' => 'custom-input-4', | ||
25 | + ], | ||
26 | + ]) | ||
27 | + ->textInput(); | ||
28 | + echo $form->field($model, 'user_email', [ | ||
29 | + 'options' => [ | ||
30 | + 'class' => 'input-blocks-comm', | ||
31 | + ], | ||
32 | + 'inputOptions' => [ | ||
33 | + 'class' => 'custom-input-4', | ||
34 | + ], | ||
35 | + ]) | ||
36 | + ->textInput(); | ||
37 | + } | ||
38 | + | ||
39 | + ?> | ||
40 | + <div class="artbox_comment_reply_block"></div> | ||
41 | + <?php | ||
42 | + | ||
43 | + echo $form->field($model, 'text', [ | ||
44 | + 'options' => [ | ||
45 | + 'class' => 'input-blocks-comm area-comm', | ||
46 | + ], | ||
47 | + 'inputOptions' => [ | ||
48 | + 'class' => 'custom-area-4', | ||
49 | + ], | ||
50 | + ]) | ||
51 | + ->label('Вопрос') | ||
52 | + ->textarea(); | ||
53 | + ?> | ||
54 | + <div class="input-blocks-comm-button style"> | ||
55 | + <?= Html::submitButton('Задать вопрос') ?> | ||
56 | + </div> | ||
57 | + <?php | ||
58 | + $form->end(); | ||
59 | + ?> | ||
60 | +</div> | ||
0 | \ No newline at end of file | 61 | \ No newline at end of file |
common/modules/comment/widgets/views/form-comment-review.php
@@ -38,6 +38,16 @@ | @@ -38,6 +38,16 @@ | ||
38 | 3 => 3, | 38 | 3 => 3, |
39 | 4 => 4, | 39 | 4 => 4, |
40 | 5 => 5, | 40 | 5 => 5, |
41 | + ], [ | ||
42 | + 'item' => function($index, $label, $name, $checked, $value) { | ||
43 | + $return = '<div class="admin-who-check">'; | ||
44 | + $return .= '<input class="custom-radio" id="select_admin_' . $value . '" type="radio" name="' . $name . '" value="' . $value . '" ' . ( $checked ? "checked" : "" ) . ' >'; | ||
45 | + $return .= '<label for="select_admin_' . $value . '" >'; | ||
46 | + $return .= '<span></span>' . ucwords($label); | ||
47 | + $return .= '</label>'; | ||
48 | + $return .= '</div>'; | ||
49 | + return $return; | ||
50 | + }, | ||
41 | ]); | 51 | ]); |
42 | if($model->scenario == $model::SCENARIO_GUEST) { | 52 | if($model->scenario == $model::SCENARIO_GUEST) { |
43 | echo $form->field($model, 'user_name', [ | 53 | echo $form->field($model, 'user_name', [ |
@@ -62,7 +72,7 @@ | @@ -62,7 +72,7 @@ | ||
62 | if(!empty( $model->comment_pid )) { | 72 | if(!empty( $model->comment_pid )) { |
63 | echo Html::tag('div', Html::activeHiddenInput($model, 'comment_pid') . Html::tag('p', $model->parent->authorName, [ 'class' => 'artbox_comment_reply_author' ]), [ 'class' => CommentWidget::$baseClass[ 'reply_block' ] ]); | 73 | echo Html::tag('div', Html::activeHiddenInput($model, 'comment_pid') . Html::tag('p', $model->parent->authorName, [ 'class' => 'artbox_comment_reply_author' ]), [ 'class' => CommentWidget::$baseClass[ 'reply_block' ] ]); |
64 | } else { | 74 | } else { |
65 | - echo Html::tag('div', '', [ 'class' => CommentWidget::$baseClass[ 'reply_block' ] ]); | 75 | + echo Html::tag('div', '', [ 'class' => CommentWidget::$baseClass[ 'reply_block' ].' test_class' ]); |
66 | } | 76 | } |
67 | echo $form->field($model, 'text', [ | 77 | echo $form->field($model, 'text', [ |
68 | 'options' => [ | 78 | 'options' => [ |
common/modules/comment/widgets/views/list-comment-question.php
0 → 100644
1 | +<?php | ||
2 | + /** | ||
3 | + * @var \yii\data\DataProviderInterface $dataProvider | ||
4 | + * @var Comment $commentClass | ||
5 | + */ | ||
6 | + use common\modules\comment\models\Comment; | ||
7 | + use common\modules\comment\widgets\CommentWidget; | ||
8 | + echo \yii\widgets\ListView::widget([ | ||
9 | + 'dataProvider' => $dataProvider, | ||
10 | + 'itemView' => '_question_comment_view', | ||
11 | + 'options' => [ | ||
12 | + 'tag' => 'ul', | ||
13 | + 'class' => 'proektant-comments style', | ||
14 | + ], | ||
15 | + 'itemOptions' => [ | ||
16 | + 'tag' => 'li', | ||
17 | + 'class' => CommentWidget::$baseClass[ 'comment_container' ], | ||
18 | + 'data' => [ | ||
19 | + 'form' => $commentClass->formName(), | ||
20 | + ], | ||
21 | + ], | ||
22 | + 'layout' => "{items}\n{pager}", | ||
23 | + ]); | ||
0 | \ No newline at end of file | 24 | \ No newline at end of file |
frontend/views/tender/view.php
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | * @var Project $model | 5 | * @var Project $model |
6 | */ | 6 | */ |
7 | use common\models\Project; | 7 | use common\models\Project; |
8 | + use common\modules\comment\models\Comment; | ||
8 | use \yii\helpers\Html; | 9 | use \yii\helpers\Html; |
9 | use yii\helpers\Url; | 10 | use yii\helpers\Url; |
10 | use yii\web\View; | 11 | use yii\web\View; |
@@ -224,6 +225,30 @@ $this->title = 'My Yii Application'; | @@ -224,6 +225,30 @@ $this->title = 'My Yii Application'; | ||
224 | <?php | 225 | <?php |
225 | echo \common\modules\comment\widgets\CommentWidget::widget([ | 226 | echo \common\modules\comment\widgets\CommentWidget::widget([ |
226 | 'context' => $this, | 227 | 'context' => $this, |
228 | + 'model' => $model->className(), | ||
229 | + 'model_id' => $model->project_id, | ||
230 | + 'comment_class' => \common\modules\comment\models\CommentProjectAnswer::className(), | ||
231 | + 'class_options' => [ | ||
232 | + 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, | ||
233 | + 'user_id' => \Yii::$app->user->getId(), | ||
234 | + 'guestComment' => false, | ||
235 | + 'status' => \common\modules\comment\models\Comment::STATUS_ACTIVE, | ||
236 | + ], | ||
237 | + 'list_options' => [ | ||
238 | + 'view' => 'list-comment-question', | ||
239 | + ], | ||
240 | + 'form_options' => [ | ||
241 | + 'view' => 'form-comment-answer', | ||
242 | + 'tag' => 'span', | ||
243 | + ], | ||
244 | + 'options' => [ | ||
245 | + 'class' => 'proektant-comments-wr style', | ||
246 | + ], | ||
247 | + ]); | ||
248 | + ?> | ||
249 | + <?php | ||
250 | + echo \common\modules\comment\widgets\CommentWidget::widget([ | ||
251 | + 'context' => $this, | ||
227 | 'model' => $model::className(), | 252 | 'model' => $model::className(), |
228 | 'model_id' => $model->project_id, | 253 | 'model_id' => $model->project_id, |
229 | 'comment_class' => \common\modules\comment\models\CommentProject::className(), | 254 | 'comment_class' => \common\modules\comment\models\CommentProject::className(), |