Commit 877ea4b2b3619a86e31e7ff64b41cca143441cb4
1 parent
1b09a6ee
test
Showing
7 changed files
with
94 additions
and
26 deletions
Show diff stats
common/models/Portfolio.php
@@ -2,9 +2,12 @@ | @@ -2,9 +2,12 @@ | ||
2 | 2 | ||
3 | namespace common\models; | 3 | namespace common\models; |
4 | 4 | ||
5 | + use common\modules\comment\models\Comment; | ||
6 | + use common\modules\comment\models\Rating; | ||
5 | use Yii; | 7 | use Yii; |
6 | use yii\behaviors\BlameableBehavior; | 8 | use yii\behaviors\BlameableBehavior; |
7 | use yii\behaviors\TimestampBehavior; | 9 | use yii\behaviors\TimestampBehavior; |
10 | + use yii\db\ActiveQuery; | ||
8 | use yii\db\Expression; | 11 | use yii\db\Expression; |
9 | 12 | ||
10 | /** | 13 | /** |
@@ -26,6 +29,9 @@ | @@ -26,6 +29,9 @@ | ||
26 | * @property PortfolioSpecialization[] $portfolioSpecializations | 29 | * @property PortfolioSpecialization[] $portfolioSpecializations |
27 | * @property Specialization[] $specializations | 30 | * @property Specialization[] $specializations |
28 | * @property User $user | 31 | * @property User $user |
32 | + * @property Comment[] $comment | ||
33 | + * @property Rating[] $rating | ||
34 | + * @property string $ratingValue | ||
29 | */ | 35 | */ |
30 | class Portfolio extends \yii\db\ActiveRecord | 36 | class Portfolio extends \yii\db\ActiveRecord |
31 | { | 37 | { |
@@ -199,4 +205,37 @@ | @@ -199,4 +205,37 @@ | ||
199 | { | 205 | { |
200 | return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); | 206 | return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); |
201 | } | 207 | } |
208 | + | ||
209 | + /** | ||
210 | + * @return ActiveQuery | ||
211 | + */ | ||
212 | + public function getComments() | ||
213 | + { | ||
214 | + return $this->hasMany(Comment::className(), [ 'model_id' => 'portfolio_id' ]) | ||
215 | + ->andWhere([ 'comment.model' => $this->className(), 'comment.status' => Comment::STATUS_ACTIVE ]); | ||
216 | + } | ||
217 | + | ||
218 | + /** | ||
219 | + * @return ActiveQuery | ||
220 | + */ | ||
221 | + public function getRating() | ||
222 | + { | ||
223 | + return $this->hasMany(Rating::className(), [ 'model_id' => 'comment_id' ]) | ||
224 | + ->via('comments') | ||
225 | + ->andWhere([ | ||
226 | + 'not', | ||
227 | + [ 'rating.value' => NULL ], | ||
228 | + ]); | ||
229 | + } | ||
230 | + | ||
231 | + /** | ||
232 | + * @return string | ||
233 | + */ | ||
234 | + public function getRatingValue() | ||
235 | + { | ||
236 | + return $this->getRating() | ||
237 | + ->asArray() | ||
238 | + ->select([ 'sum' => 'ROUND(SUM(rating.value)/COUNT(rating.value)::numeric, 1)' ]) | ||
239 | + ->scalar(); | ||
240 | + } | ||
202 | } | 241 | } |
common/modules/comment/widgets/views/form-comment.php
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | * @var \yii\data\ActiveDataProvider $dataProvider | 5 | * @var \yii\data\ActiveDataProvider $dataProvider |
6 | * @var null|\common\modules\comment\models\Rating $rating | 6 | * @var null|\common\modules\comment\models\Rating $rating |
7 | */ | 7 | */ |
8 | + use kartik\rating\StarRating; | ||
8 | use yii\widgets\ActiveForm; | 9 | use yii\widgets\ActiveForm; |
9 | use yii\helpers\Html; | 10 | use yii\helpers\Html; |
10 | 11 | ||
@@ -15,16 +16,16 @@ | @@ -15,16 +16,16 @@ | ||
15 | 16 | ||
16 | <?php | 17 | <?php |
17 | $form = ActiveForm::begin(); | 18 | $form = ActiveForm::begin(); |
18 | - | ||
19 | - echo $form->field($rating, 'value') | ||
20 | - ->label(false) | ||
21 | - ->radioList([ | ||
22 | - 1 => 1, | ||
23 | - 2 => 2, | ||
24 | - 3 => 3, | ||
25 | - 4 => 4, | ||
26 | - 5 => 5, | ||
27 | - ]); | 19 | + if($rating) { |
20 | + echo $form->field(( !empty( $model->rating ) ? $model->rating : $rating ), 'value') | ||
21 | + ->label(false) | ||
22 | + ->widget(StarRating::className(), [ 'pluginOptions' => [ 'size' => 'xxs', | ||
23 | + 'step' => 1, | ||
24 | + 'value' => 2, | ||
25 | + 'showCaption' => false, | ||
26 | + ], | ||
27 | + ]); | ||
28 | + } | ||
28 | 29 | ||
29 | if($model->scenario == $model::SCENARIO_GUEST) { | 30 | if($model->scenario == $model::SCENARIO_GUEST) { |
30 | echo $form->field($model, 'user_name', [ | 31 | echo $form->field($model, 'user_name', [ |
@@ -44,7 +45,8 @@ | @@ -44,7 +45,8 @@ | ||
44 | 'class' => 'custom-input-4', | 45 | 'class' => 'custom-input-4', |
45 | ], | 46 | ], |
46 | ]) | 47 | ]) |
47 | - ->textInput(); | 48 | + ->textInput() |
49 | + ->hint('Ваш email не будет доступен к просмотру.'); | ||
48 | } | 50 | } |
49 | 51 | ||
50 | ?> | 52 | ?> |
common/modules/comment/widgets/views/project_comment_view.php
1 | <?php | 1 | <?php |
2 | use common\models\User; | 2 | use common\models\User; |
3 | + use common\modules\comment\widgets\CommentWidget; | ||
3 | use kartik\rating\StarRating; | 4 | use kartik\rating\StarRating; |
4 | use yii\helpers\Html; | 5 | use yii\helpers\Html; |
5 | 6 | ||
@@ -18,8 +19,9 @@ | @@ -18,8 +19,9 @@ | ||
18 | ->with('userInfo') | 19 | ->with('userInfo') |
19 | ->one(); | 20 | ->one(); |
20 | } | 21 | } |
22 | + $model->buildButtons(['delete']); | ||
21 | ?> | 23 | ?> |
22 | -<div class="new-portf-comm-read artbox_comment_container" data-comment_id="<?= $model->comment_id ?>" data-form_name="<?= $model->formName() ?>"> | 24 | +<div class="new-portf-comm-read artbox_comment_container" data-key="<?= $model->comment_id ?>" data-form="<?= $model->formName() ?>"> |
23 | <div class="style"> | 25 | <div class="style"> |
24 | <div class="header-cabinet-foto"> | 26 | <div class="header-cabinet-foto"> |
25 | <?php | 27 | <?php |
@@ -64,6 +66,19 @@ | @@ -64,6 +66,19 @@ | ||
64 | <?= Html::encode($model->text) ?> | 66 | <?= Html::encode($model->text) ?> |
65 | </div> | 67 | </div> |
66 | <div style="clear:both"></div> | 68 | <div style="clear:both"></div> |
69 | + <div> | ||
70 | + <?php | ||
71 | + if(!empty( $model->buttons[ 'delete' ] )) { | ||
72 | + echo Html::a(($model->user_id != NULL && $model->user_id == \Yii::$app->user->id)?'Удалить':'Пожаловаться ', $model->buttons[ 'delete' ], [ 'class' => CommentWidget::$baseClass[ 'comment_delete' ] ]); | ||
73 | + } | ||
74 | + if(!empty( $model->buttons[ 'update' ] )) { | ||
75 | + echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => CommentWidget::$baseClass[ 'comment_update' ] ]); | ||
76 | + } | ||
77 | + if(!empty( $model->buttons[ 'reply' ] )) { | ||
78 | + echo Html::a('Ответить', $model->buttons[ 'reply' ], [ 'class' => CommentWidget::$baseClass[ 'comment_reply' ] ]); | ||
79 | + } | ||
80 | + ?> | ||
81 | + </div> | ||
67 | <?php | 82 | <?php |
68 | /* | 83 | /* |
69 | ?> | 84 | ?> |
frontend/views/performer/_portfolio_list_view.php
@@ -37,21 +37,21 @@ | @@ -37,21 +37,21 @@ | ||
37 | <div class="portfolio-project-views-img"> | 37 | <div class="portfolio-project-views-img"> |
38 | <img src="/images/portfolio-project/ico-1.png"/></div> | 38 | <img src="/images/portfolio-project/ico-1.png"/></div> |
39 | </div> | 39 | </div> |
40 | - <div class="portfolio-project-views-txt">127</div> | 40 | + <div class="portfolio-project-views-txt"><?=$model->view_count?></div> |
41 | </div> | 41 | </div> |
42 | <div class="portfolio-project-rati ico-views-bl"> | 42 | <div class="portfolio-project-rati ico-views-bl"> |
43 | <div class="portfolio-project-views-img-wr"> | 43 | <div class="portfolio-project-views-img-wr"> |
44 | <div class="portfolio-project-views-img"> | 44 | <div class="portfolio-project-views-img"> |
45 | <img src="/images/portfolio-project/ico-2.png"/></div> | 45 | <img src="/images/portfolio-project/ico-2.png"/></div> |
46 | </div> | 46 | </div> |
47 | - <div class="portfolio-project-views-txt">10.0</div> | 47 | + <div class="portfolio-project-views-txt"><?=($model->getRatingValue()?:'Нет')?></div> |
48 | </div> | 48 | </div> |
49 | <div class="ico-views-bl"> | 49 | <div class="ico-views-bl"> |
50 | <div class="portfolio-project-views-img-wr"> | 50 | <div class="portfolio-project-views-img-wr"> |
51 | <div class="portfolio-project-views-img"> | 51 | <div class="portfolio-project-views-img"> |
52 | <img src="/images/portfolio-project/ico-3.png"/></div> | 52 | <img src="/images/portfolio-project/ico-3.png"/></div> |
53 | </div> | 53 | </div> |
54 | - <div class="portfolio-project-views-txt">14</div> | 54 | + <div class="portfolio-project-views-txt"><?=count($model->comments)?></div> |
55 | </div> | 55 | </div> |
56 | </div> | 56 | </div> |
57 | <div title="<?= implode(', ', ArrayHelper::getColumn($model->specializations, 'specialization_name')) ?>" class="portfolio-project-blocks-tags"><?= implode(', ', ArrayHelper::getColumn($model->specializations, 'specialization_name')) ?></div> | 57 | <div title="<?= implode(', ', ArrayHelper::getColumn($model->specializations, 'specialization_name')) ?>" class="portfolio-project-blocks-tags"><?= implode(', ', ArrayHelper::getColumn($model->specializations, 'specialization_name')) ?></div> |
frontend/views/performer/portfolio-view.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | use common\models\Portfolio; | 3 | use common\models\Portfolio; |
4 | use common\models\User; | 4 | use common\models\User; |
5 | + use kartik\rating\StarRating; | ||
5 | use yii\helpers\Html; | 6 | use yii\helpers\Html; |
6 | use yii\web\ViewAction; | 7 | use yii\web\ViewAction; |
7 | use yii\web\View; | 8 | use yii\web\View; |
@@ -15,6 +16,7 @@ | @@ -15,6 +16,7 @@ | ||
15 | $this->params[ 'user' ] = $user; | 16 | $this->params[ 'user' ] = $user; |
16 | 17 | ||
17 | $this->title = 'My Yii Application'; | 18 | $this->title = 'My Yii Application'; |
19 | + $rating = $portfolio->getRatingValue(); | ||
18 | ?> | 20 | ?> |
19 | <div class="portfolio-new-page-wrapper style"> | 21 | <div class="portfolio-new-page-wrapper style"> |
20 | <div class="new-portfolio-bg style "> | 22 | <div class="new-portfolio-bg style "> |
@@ -35,24 +37,25 @@ | @@ -35,24 +37,25 @@ | ||
35 | <div class="portfolio-project-views-img"> | 37 | <div class="portfolio-project-views-img"> |
36 | <img src="/images/portfolio-project/ico-2.png"></div> | 38 | <img src="/images/portfolio-project/ico-2.png"></div> |
37 | </div> | 39 | </div> |
38 | - <div class="portfolio-project-views-txt">XX.X</div> | 40 | + <div class="portfolio-project-views-txt"><?=(!empty($rating)?$rating:'Нет')?></div> |
39 | </div> | 41 | </div> |
40 | <div class="ico-views-bl"> | 42 | <div class="ico-views-bl"> |
41 | <div class="portfolio-project-views-img-wr"> | 43 | <div class="portfolio-project-views-img-wr"> |
42 | <div class="portfolio-project-views-img"> | 44 | <div class="portfolio-project-views-img"> |
43 | <img src="/images/portfolio-project/ico-3.png"></div> | 45 | <img src="/images/portfolio-project/ico-3.png"></div> |
44 | </div> | 46 | </div> |
45 | - <div class="portfolio-project-views-txt"></div> | 47 | + <div class="portfolio-project-views-txt"><?=count($portfolio->comments)?></div> |
46 | </div> | 48 | </div> |
47 | </div> | 49 | </div> |
48 | </div> | 50 | </div> |
49 | <div class="new-portfolio-rating"> | 51 | <div class="new-portfolio-rating"> |
50 | - <div class="rating new-portf-rat"> | ||
51 | - <!--оценка--> | ||
52 | - <input type="hidden" class="val" value="4"/> | ||
53 | - <!--количество голосов--> | ||
54 | - <input type="hidden" class="votes" value="12"/> | ||
55 | - </div> | 52 | + <?php |
53 | + echo StarRating::widget([ | ||
54 | + 'name' => 'rating_portfolio', | ||
55 | + 'value' => $portfolio->getRatingValue(), | ||
56 | + 'pluginOptions' => ['displayOnly' => true, 'size' => 'xxs'] | ||
57 | + ]); | ||
58 | + ?> | ||
56 | </div> | 59 | </div> |
57 | </div> | 60 | </div> |
58 | 61 | ||
@@ -60,13 +63,15 @@ | @@ -60,13 +63,15 @@ | ||
60 | <div class="new-portf-slider-title"><?= $portfolio->name ?></div> | 63 | <div class="new-portf-slider-title"><?= $portfolio->name ?></div> |
61 | <?php | 64 | <?php |
62 | if(!empty( $portfolio->gallery ) || !empty( $portfolio->gallery->photo )) { | 65 | if(!empty( $portfolio->gallery ) || !empty( $portfolio->gallery->photo )) { |
66 | + $gallery = explode(',', $portfolio->gallery->photo); | ||
67 | + array_pop($gallery); | ||
63 | ?> | 68 | ?> |
64 | <div class="new-portf-slider style"> | 69 | <div class="new-portf-slider style"> |
65 | <div class="slider-video-wr"> | 70 | <div class="slider-video-wr"> |
66 | <div id="demo5" class="scroll-img"> | 71 | <div id="demo5" class="scroll-img"> |
67 | <ul> | 72 | <ul> |
68 | <?php | 73 | <?php |
69 | - foreach( explode(',', $portfolio->gallery->photo) as $one_photo ) { | 74 | + foreach($gallery as $one_photo) { |
70 | ?> | 75 | ?> |
71 | <li><img src="<?= $one_photo ?>" alt=""/> | 76 | <li><img src="<?= $one_photo ?>" alt=""/> |
72 | <?php | 77 | <?php |
@@ -117,7 +122,7 @@ | @@ -117,7 +122,7 @@ | ||
117 | 'model' => $portfolio::className(), | 122 | 'model' => $portfolio::className(), |
118 | 'model_id' => $portfolio->portfolio_id, | 123 | 'model_id' => $portfolio->portfolio_id, |
119 | 'comment_class' => \common\modules\comment\models\Comment::className(), | 124 | 'comment_class' => \common\modules\comment\models\Comment::className(), |
120 | - 'rating_class' => \common\modules\comment\models\Rating::className(), | 125 | + 'rating_class' => (\Yii::$app->user->id?\common\modules\comment\models\Rating::className():false), |
121 | 'class_options' => [ | 126 | 'class_options' => [ |
122 | 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, | 127 | 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, |
123 | 'user_id' => \Yii::$app->user->getId(), | 128 | 'user_id' => \Yii::$app->user->getId(), |
frontend/views/performer/portfolio.php
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | use \yii\helpers\Html; | 4 | use \yii\helpers\Html; |
5 | use yii\helpers\Url; | 5 | use yii\helpers\Url; |
6 | use yii\widgets\ListView; | 6 | use yii\widgets\ListView; |
7 | + use yii\widgets\Pjax; | ||
7 | 8 | ||
8 | /* @var $this yii\web\View | 9 | /* @var $this yii\web\View |
9 | * @var $portfolio yii\data\ArrayDataProvider | 10 | * @var $portfolio yii\data\ArrayDataProvider |
@@ -13,6 +14,9 @@ | @@ -13,6 +14,9 @@ | ||
13 | ?> | 14 | ?> |
14 | <div class="performer-vacancy-vacant-title-reclam-wr style"> | 15 | <div class="performer-vacancy-vacant-title-reclam-wr style"> |
15 | 16 | ||
17 | + <?php | ||
18 | + Pjax::begin(); | ||
19 | + ?> | ||
16 | <div class="portfolio-project-wr style"> | 20 | <div class="portfolio-project-wr style"> |
17 | <div class="workplace-title style"><p>Проектов: <?= $portfolio->totalCount ?></p></div> | 21 | <div class="workplace-title style"><p>Проектов: <?= $portfolio->totalCount ?></p></div> |
18 | <div class="portfolio-project-tags style"> | 22 | <div class="portfolio-project-tags style"> |
@@ -44,5 +48,8 @@ | @@ -44,5 +48,8 @@ | ||
44 | 48 | ||
45 | </div> | 49 | </div> |
46 | </div> | 50 | </div> |
51 | + <?php | ||
52 | + Pjax::end(); | ||
53 | + ?> | ||
47 | 54 | ||
48 | </div> | 55 | </div> |
49 | \ No newline at end of file | 56 | \ No newline at end of file |
frontend/web/css/style.css
@@ -6650,7 +6650,7 @@ input[disabled], select[disabled] { | @@ -6650,7 +6650,7 @@ input[disabled], select[disabled] { | ||
6650 | .admin-portfolio-foto .btn {margin-top: 0} | 6650 | .admin-portfolio-foto .btn {margin-top: 0} |
6651 | .admin-portfolio-foto.success_download .btn {margin-top: 15px} | 6651 | .admin-portfolio-foto.success_download .btn {margin-top: 15px} |
6652 | .admin-portfolio-foto #cover_buttons_block { | 6652 | .admin-portfolio-foto #cover_buttons_block { |
6653 | - top: 173px; | 6653 | + top: 188px; |
6654 | left: 116px; | 6654 | left: 116px; |
6655 | } | 6655 | } |
6656 | .admin-portfolio-foto .admin-ava-wr { | 6656 | .admin-portfolio-foto .admin-ava-wr { |