Commit 85040b57b24532d0907ecbbc18b72404f8b76951

Authored by Yarik
1 parent 97f27386

Comment added

backend/config/main.php
... ... @@ -158,12 +158,9 @@ return [
158 158 'product/manage/<action>' => 'product/manage/<action>',
159 159 'product/<controller>/<action>/<product_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'product/<controller>/<action>',
160 160 'product/<controller>/<action>/<product_id:[A-Za-z0-9_-]+>/' => 'product/<controller>/<action>',
161   -
162 161 'product/<action>/<product_id:[A-Za-z0-9_-]+>' => 'product/<action>',
163 162 'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
164 163 'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
165   -
166   -
167 164 ]
168 165 ]
169 166  
... ...
backend/controllers/CommentController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use developeruz\db_rbac\behaviors\AccessBehavior;
  6 +use Yii;
  7 +use common\modules\comment\models\Comment;
  8 +use backend\models\CommentSearch;
  9 +use yii\web\Controller;
  10 +use yii\web\NotFoundHttpException;
  11 +use yii\filters\VerbFilter;
  12 +
  13 +/**
  14 + * CommentController implements the CRUD actions for Comment model.
  15 + */
  16 +class CommentController extends Controller
  17 +{
  18 + /**
  19 + * @inheritdoc
  20 + */
  21 + public function behaviors()
  22 + {
  23 + return [
  24 + 'access'=>[
  25 + 'class' => AccessBehavior::className(),
  26 + 'rules' =>
  27 + ['site' =>
  28 + [
  29 + [
  30 + 'actions' => ['login', 'error'],
  31 + 'allow' => true,
  32 + ]
  33 + ]
  34 + ]
  35 + ],
  36 + 'verbs' => [
  37 + 'class' => VerbFilter::className(),
  38 + 'actions' => [
  39 + 'delete' => ['POST'],
  40 + ],
  41 + ],
  42 + ];
  43 + }
  44 +
  45 + /**
  46 + * Lists all Comment models.
  47 + * @return mixed
  48 + */
  49 + public function actionIndex()
  50 + {
  51 + $searchModel = new CommentSearch();
  52 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  53 + $query = $dataProvider->query;
  54 + $query->with(['rating', 'user']);
  55 + $sort = $dataProvider->sort;
  56 + $sort->defaultOrder = [
  57 + 'status' => SORT_ASC,
  58 + ];
  59 +
  60 + return $this->render('index', [
  61 + 'searchModel' => $searchModel,
  62 + 'dataProvider' => $dataProvider,
  63 + ]);
  64 + }
  65 +
  66 + /**
  67 + * Displays a single Comment model.
  68 + * @param integer $id
  69 + * @return mixed
  70 + */
  71 +// public function actionView($id)
  72 +// {
  73 +// return $this->render('view', [
  74 +// 'model' => $this->findModel($id),
  75 +// ]);
  76 +// }
  77 +
  78 + /**
  79 + * Creates a new Comment model.
  80 + * If creation is successful, the browser will be redirected to the 'view' page.
  81 + * @return mixed
  82 + */
  83 +// public function actionCreate()
  84 +// {
  85 +// $model = new Comment();
  86 +//
  87 +// if ($model->load(Yii::$app->request->post()) && $model->save()) {
  88 +// return $this->redirect(['view', 'id' => $model->comment_id]);
  89 +// } else {
  90 +// return $this->render('create', [
  91 +// 'model' => $model,
  92 +// ]);
  93 +// }
  94 +// }
  95 +
  96 + /**
  97 + * Updates an existing Comment model.
  98 + * If update is successful, the browser will be redirected to the 'view' page.
  99 + * @param integer $id
  100 + * @return mixed
  101 + */
  102 + public function actionUpdate($id)
  103 + {
  104 + $model = $this->findModel($id);
  105 +
  106 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  107 + return $this->redirect(['view', 'id' => $model->comment_id]);
  108 + } else {
  109 + return $this->render('update', [
  110 + 'model' => $model,
  111 + ]);
  112 + }
  113 + }
  114 +
  115 + public function actionApprove($id) {
  116 + $model = $this->findModel($id);
  117 + $model->status = Comment::STATUS_ACTIVE;
  118 + $model->save(false);
  119 +
  120 + return $this->redirect(['index']);
  121 + }
  122 +
  123 + public function actionDisapprove($id) {
  124 + $model = $this->findModel($id);
  125 + $model->status = Comment::STATUS_HIDDEN;
  126 + $model->save(false);
  127 +
  128 + return $this->redirect(['index']);
  129 + }
  130 +
  131 + /**
  132 + * Deletes an existing Comment model.
  133 + * If deletion is successful, the browser will be redirected to the 'index' page.
  134 + * @param integer $id
  135 + * @return mixed
  136 + */
  137 + public function actionDelete($id)
  138 + {
  139 + $this->findModel($id)->delete();
  140 +
  141 + return $this->redirect(['index']);
  142 + }
  143 +
  144 + /**
  145 + * Finds the Comment model based on its primary key value.
  146 + * If the model is not found, a 404 HTTP exception will be thrown.
  147 + * @param integer $id
  148 + * @return Comment the loaded model
  149 + * @throws NotFoundHttpException if the model cannot be found
  150 + */
  151 + protected function findModel($id)
  152 + {
  153 + if (($model = Comment::findOne($id)) !== null) {
  154 + return $model;
  155 + } else {
  156 + throw new NotFoundHttpException('The requested page does not exist.');
  157 + }
  158 + }
  159 +}
... ...
backend/models/CommentSearch.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +use yii\data\ActiveDataProvider;
  8 +use common\modules\comment\models\Comment;
  9 +
  10 +/**
  11 + * CommentSearch represents the model behind the search form about `common\modules\comment\models\Comment`.
  12 + */
  13 +class CommentSearch extends Comment
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public function rules()
  19 + {
  20 + return [
  21 + [['comment_id', 'user_id', 'comment_pid', 'status', 'model_id'], 'integer'],
  22 + [['text', 'user_name', 'user_email', 'date_add', 'date_update', 'date_delete', 'model'], 'safe'],
  23 + ];
  24 + }
  25 +
  26 + /**
  27 + * @inheritdoc
  28 + */
  29 + public function scenarios()
  30 + {
  31 + // bypass scenarios() implementation in the parent class
  32 + return Model::scenarios();
  33 + }
  34 +
  35 + /**
  36 + * Creates data provider instance with search query applied
  37 + *
  38 + * @param array $params
  39 + *
  40 + * @return ActiveDataProvider
  41 + */
  42 + public function search($params)
  43 + {
  44 + $query = Comment::find();
  45 +
  46 + // add conditions that should always apply here
  47 +
  48 + $dataProvider = new ActiveDataProvider([
  49 + 'query' => $query,
  50 + ]);
  51 +
  52 + $this->load($params);
  53 +
  54 + if (!$this->validate()) {
  55 + // uncomment the following line if you do not want to return any records when validation fails
  56 + // $query->where('0=1');
  57 + return $dataProvider;
  58 + }
  59 +
  60 + // grid filtering conditions
  61 + $query->andFilterWhere([
  62 + 'comment_id' => $this->comment_id,
  63 + 'user_id' => $this->user_id,
  64 + 'comment_pid' => $this->comment_pid,
  65 + 'status' => $this->status,
  66 + 'date_add' => $this->date_add,
  67 + 'date_update' => $this->date_update,
  68 + 'date_delete' => $this->date_delete,
  69 + 'model_id' => $this->model_id,
  70 + ]);
  71 +
  72 + $query->andFilterWhere(['like', 'text', $this->text])
  73 + ->andFilterWhere(['like', 'user_name', $this->user_name])
  74 + ->andFilterWhere(['like', 'user_email', $this->user_email])
  75 + ->andFilterWhere(['like', 'model', $this->model]);
  76 +
  77 + return $dataProvider;
  78 + }
  79 +}
... ...
backend/views/comment/_form.php 0 → 100644
  1 +<?php
  2 +
  3 + use common\modules\comment\models\Comment;
  4 + use yii\helpers\Html;
  5 + use yii\widgets\ActiveForm;
  6 +
  7 + /* @var $this yii\web\View */
  8 + /* @var $model Comment */
  9 + /* @var $form yii\widgets\ActiveForm */
  10 + $status_list = [
  11 + Comment::STATUS_ACTIVE => 'Активный',
  12 + Comment::STATUS_HIDDEN => 'Новый',
  13 + Comment::STATUS_DELETED => 'Удаленный',
  14 + ]
  15 +?>
  16 +
  17 +<div class="comment-form">
  18 +
  19 + <?php $form = ActiveForm::begin(); ?>
  20 +
  21 + <?= $form->field($model, 'text')
  22 + ->textarea([ 'rows' => 6 ]) ?>
  23 +
  24 + <?= $form->field($model, 'status')
  25 + ->dropDownList($status_list) ?>
  26 +
  27 + <div class="form-group">
  28 + <?= Html::submitButton('Обновить', [ 'class' => 'btn btn-primary' ]) ?>
  29 + </div>
  30 +
  31 + <?php ActiveForm::end(); ?>
  32 +
  33 +</div>
... ...
backend/views/comment/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model backend\models\CommentSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="comment-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'comment_id') ?>
  19 +
  20 + <?= $form->field($model, 'text') ?>
  21 +
  22 + <?= $form->field($model, 'user_id') ?>
  23 +
  24 + <?= $form->field($model, 'user_name') ?>
  25 +
  26 + <?= $form->field($model, 'user_email') ?>
  27 +
  28 + <?php // echo $form->field($model, 'comment_pid') ?>
  29 +
  30 + <?php // echo $form->field($model, 'status') ?>
  31 +
  32 + <?php // echo $form->field($model, 'date_add') ?>
  33 +
  34 + <?php // echo $form->field($model, 'date_update') ?>
  35 +
  36 + <?php // echo $form->field($model, 'date_delete') ?>
  37 +
  38 + <?php // echo $form->field($model, 'model') ?>
  39 +
  40 + <?php // echo $form->field($model, 'model_id') ?>
  41 +
  42 + <div class="form-group">
  43 + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
  44 + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
  45 + </div>
  46 +
  47 + <?php ActiveForm::end(); ?>
  48 +
  49 +</div>
... ...
backend/views/comment/index.php 0 → 100644
  1 +<?php
  2 +
  3 + use common\modules\comment\models\Comment;
  4 + use yii\helpers\Html;
  5 + use yii\grid\GridView;
  6 + use yii\helpers\Url;
  7 +
  8 + /* @var $this yii\web\View */
  9 + /* @var $dataProvider yii\data\ActiveDataProvider */
  10 +
  11 + $this->title = 'Комменты';
  12 + $this->params[ 'breadcrumbs' ][] = $this->title;
  13 +?>
  14 +<div class="comment-index">
  15 +
  16 + <h1><?= Html::encode($this->title) ?></h1>
  17 +
  18 + <?= GridView::widget([
  19 + 'dataProvider' => $dataProvider,
  20 + 'columns' => [
  21 + [
  22 + 'class' => 'yii\grid\ActionColumn',
  23 + 'template' => '{approve} {update} {delete}',
  24 + 'buttons' => [
  25 + 'approve' => function($url, $model, $key) {
  26 + /**
  27 + * @var Comment $model
  28 + */
  29 + $options = array_merge([
  30 + 'title' => "Подтвердить",
  31 + 'aria-label' => "Подтвердить",
  32 + 'data-confirm' => "Комментарий и оценка отобразится на публичной части сайта, подтвердить?",
  33 + 'data-method' => 'post',
  34 + 'data-pjax' => '0',
  35 + ]);
  36 + $glyphicon = 'glyphicon-ok';
  37 + if($model->status == $model::STATUS_ACTIVE) {
  38 + $url = Url::to(['comment/disapprove', 'id' => $model->comment_id]);
  39 + $glyphicon = 'glyphicon-remove';
  40 + }
  41 + return Html::a('<span class="glyphicon '.$glyphicon.'"></span>', $url, $options);
  42 + }
  43 + ]
  44 + ],
  45 + 'comment_id',
  46 + [
  47 + 'attribute' => 'rating.value',
  48 + 'label' => 'Оценка',
  49 + ],
  50 + 'text:ntext',
  51 + [
  52 + 'content' => function($model) {
  53 + /**
  54 + * @var Comment $model
  55 + */
  56 + if(!empty( $model->user )) {
  57 + return $model->user->username . " (ID: " . $model->user->id . ")";
  58 + } else {
  59 + return $model->user_name . " (Гость: " . $model->user_email . ")";
  60 + }
  61 + },
  62 + 'label' => 'Пользователь',
  63 + ],
  64 + [
  65 + 'attribute' => 'status',
  66 + 'value' => function($model) {
  67 + /**
  68 + * @var Comment $model
  69 + */
  70 + $status = '';
  71 + switch($model->status) {
  72 + case Comment::STATUS_ACTIVE:
  73 + $status = 'Активный';
  74 + break;
  75 + case Comment::STATUS_HIDDEN:
  76 + $status = 'Новый';
  77 + break;
  78 + case Comment::STATUS_DELETED:
  79 + $status = 'Удаленный';
  80 + break;
  81 + default:
  82 + $status = 'Неизвестно';
  83 + };
  84 + return $status;
  85 + },
  86 + ],
  87 + 'date_add',
  88 + [
  89 + 'attribute' => 'model',
  90 + 'value' => function($model) {
  91 + /**
  92 + * @var Comment $model
  93 + */
  94 + return $model->model . " (ID: " . $model->model_id . ")";
  95 + },
  96 + ],
  97 + ],
  98 + ]); ?>
  99 +</div>
... ...
backend/views/comment/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model common\modules\comment\models\Comment */
  7 +
  8 +$this->title = 'Редактировать коммент: ' . $model->comment_id;
  9 +$this->params['breadcrumbs'][] = ['label' => 'Комментарии', 'url' => ['index']];
  10 +$this->params['breadcrumbs'][] = ['label' => $model->comment_id, 'url' => ['view', 'id' => $model->comment_id]];
  11 +$this->params['breadcrumbs'][] = 'Редактировать';
  12 +?>
  13 +<div class="comment-update">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
... ...
backend/views/comment/view.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\modules\comment\models\Comment */
  8 +
  9 +$this->title = $model->comment_id;
  10 +$this->params['breadcrumbs'][] = ['label' => 'Comments', 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="comment-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a('Update', ['update', 'id' => $model->comment_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a('Delete', ['delete', 'id' => $model->comment_id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => 'Are you sure you want to delete this item?',
  23 + 'method' => 'post',
  24 + ],
  25 + ]) ?>
  26 + </p>
  27 +
  28 + <?= DetailView::widget([
  29 + 'model' => $model,
  30 + 'attributes' => [
  31 + 'comment_id',
  32 + 'text:ntext',
  33 + 'user_id',
  34 + 'user_name',
  35 + 'user_email:email',
  36 + 'comment_pid',
  37 + 'status',
  38 + 'date_add',
  39 + 'date_update',
  40 + 'date_delete',
  41 + 'model',
  42 + 'model_id',
  43 + ],
  44 + ]) ?>
  45 +
  46 +</div>
... ...
common/config/main.php
... ... @@ -353,46 +353,5 @@ return [
353 353 ]*/
354 354 ]
355 355 ],
356   - 'comment' => [
357   - 'class' => 'common\modules\comment\Module',
358   - 'useRbac' => false,
359   - 'rbac' => [
360   - 'rules' => [
361   - \common\modules\comment\rbac\ArtboxCommentCreateRule::className(),
362   - \common\modules\comment\rbac\ArtboxCommentDeleteRule::className(),
363   - \common\modules\comment\rbac\ArtboxCommentUpdateRule::className(),
364   - \common\modules\comment\rbac\ArtboxCommentUpdateOwnRule::className(),
365   - \common\modules\comment\rbac\ArtboxCommentDeleteOwnRule::className(),
366   - ],
367   - 'permissions' => [
368   - [
369   - 'name' => common\modules\comment\Permissions::CREATE,
370   - 'description' => 'Can create comments',
371   - 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentCreateRule())->name,
372   - ],
373   - [
374   - 'name' => common\modules\comment\Permissions::UPDATE,
375   - 'description' => 'Can update comments',
376   - 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentUpdateRule())->name,
377   - ],
378   - [
379   - 'name' => common\modules\comment\Permissions::DELETE,
380   - 'description' => 'Can delete comments',
381   - 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentDeleteRule())->name,
382   - ],
383   - [
384   - 'name' => common\modules\comment\Permissions::UPDATE_OWN,
385   - 'description' => 'Can update own comments',
386   - 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentUpdateOwnRule())->name,
387   - ],
388   - [
389   - 'name' => common\modules\comment\Permissions::DELETE_OWN,
390   - 'description' => 'Can delete own comments',
391   - 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentDeleteOwnRule())->name,
392   - ],
393   - ],
394   - ],
395   -
396   - ],
397 356 ],
398 357 ];
... ...
common/modules/comment/assets/CommentAsset.php
1 1 <?php
2 2 namespace common\modules\comment\assets;
3   -
  3 +
4 4 class CommentAsset extends \yii\web\AssetBundle
5 5 {
6   -
  6 +
7 7 public $sourcePath = '@common/modules/comment/resources';
8   -
  8 +
9 9 public $css = [
10 10 'comment.css',
  11 + 'rateit.css',
11 12 ];
12   -
  13 +
13 14 public $js = [
14 15 'comment.js',
  16 + 'jquery.rateit.min.js',
15 17 ];
16   -
  18 +
17 19 public $depends = [
18 20 '\yii\web\YiiAsset',
19 21 '\yii\web\JqueryAsset',
20 22 ];
21   -
  23 +
22 24 public $jsOptions = [
23 25 'position' => \yii\web\View::POS_HEAD,
24 26 ];
25   -
  27 +
26 28 }
27 29 \ No newline at end of file
... ...
common/modules/comment/resources/comment.css
... ... @@ -220,7 +220,8 @@
220 220  
221 221 /***proektant_comments***/
222 222 ul.proektant-comments {
223   - margin-top: 15px
  223 + margin-top: 15px;
  224 + padding-left: 0;
224 225 }
225 226  
226 227 .proektant-comments li {
... ... @@ -235,6 +236,8 @@ ul.proektant-comments {
235 236 .proektant-comments .pagination li {
236 237 width: auto;
237 238 margin-top: 0;
  239 + float: none;
  240 + border-bottom: none;
238 241 }
239 242  
240 243 .proektant-comments li:first-child {
... ...
common/modules/comment/resources/delete.gif 0 → 100644

752 Bytes

common/modules/comment/resources/jquery.rateit.min.js 0 → 100644
  1 +/*! RateIt | v1.0.24 / 06/14/2016
  2 + https://github.com/gjunge/rateit.js | Twitter: @gjunge
  3 +*/
  4 +(function(n){function t(n){var u=n.originalEvent.changedTouches,t=u[0],i="",r;switch(n.type){case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}r=document.createEvent("MouseEvent");r.initMouseEvent(i,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null);t.target.dispatchEvent(r);n.preventDefault()}n.rateit={aria:{resetLabel:"reset rating",ratingLabel:"rating"}};n.fn.rateit=function(i,r){var e=1,u={},o="init",s=function(n){return n.charAt(0).toUpperCase()+n.substr(1)},f;if(this.length===0)return this;if(f=n.type(i),f=="object"||i===undefined||i===null)u=n.extend({},n.fn.rateit.defaults,i);else{if(f=="string"&&i!=="reset"&&r===undefined)return this.data("rateit"+s(i));f=="string"&&(o="setvalue")}return this.each(function(){var c=n(this),f=function(n,t){if(t!=null){var i="aria-value"+(n=="value"?"now":n),r=c.find(".rateit-range");r.attr(i)!=undefined&&r.attr(i,t)}return arguments[0]="rateit"+s(n),c.data.apply(c,arguments)},p,w,v,h,b,g,nt,l,y,k,a;if(i=="reset"){p=f("init");for(w in p)c.data(w,p[w]);f("backingfld")&&(h=n(f("backingfld")),h.val(f("value")),h.trigger("change"),h[0].min&&(h[0].min=f("min")),h[0].max&&(h[0].max=f("max")),h[0].step&&(h[0].step=f("step")));c.trigger("reset")}if(c.hasClass("rateit")||c.addClass("rateit"),v=c.css("direction")!="rtl",o=="setvalue"){if(!f("init"))throw"Can't set value before init";i!="readonly"||r!=!0||f("readonly")||(c.find(".rateit-range").unbind(),f("wired",!1));i=="value"&&(r=r==null?f("min"):Math.max(f("min"),Math.min(f("max"),r)));f("backingfld")&&(h=n(f("backingfld")),i=="value"&&h.val(r),i=="min"&&h[0].min&&(h[0].min=r),i=="max"&&h[0].max&&(h[0].max=r),i=="step"&&h[0].step&&(h[0].step=r));f(i,r)}f("init")||(f("min",isNaN(f("min"))?u.min:f("min")),f("max",isNaN(f("max"))?u.max:f("max")),f("step",f("step")||u.step),f("readonly",f("readonly")!==undefined?f("readonly"):u.readonly),f("resetable",f("resetable")!==undefined?f("resetable"):u.resetable),f("backingfld",f("backingfld")||u.backingfld),f("starwidth",f("starwidth")||u.starwidth),f("starheight",f("starheight")||u.starheight),f("value",Math.max(f("min"),Math.min(f("max"),isNaN(f("value"))?isNaN(u.value)?u.min:u.value:f("value")))),f("ispreset",f("ispreset")!==undefined?f("ispreset"):u.ispreset),f("backingfld")&&(h=n(f("backingfld")).hide(),(h.attr("disabled")||h.attr("readonly"))&&f("readonly",!0),h[0].nodeName=="INPUT"&&(h[0].type=="range"||h[0].type=="text")&&(f("min",parseInt(h.attr("min"))||f("min")),f("max",parseInt(h.attr("max"))||f("max")),f("step",parseInt(h.attr("step"))||f("step"))),h[0].nodeName=="SELECT"&&h[0].options.length>1?(f("min",isNaN(f("min"))?Number(h[0].options[0].value):f("min")),f("max",Number(h[0].options[h[0].length-1].value)),f("step",Number(h[0].options[1].value)-Number(h[0].options[0].value)),b=h.find("option[selected]"),b.length==1&&f("value",b.val())):f("value",h.val())),g=c[0].nodeName=="DIV"?"div":"span",e++,nt='<button id="rateit-reset-{{index}}" type="button" data-role="none" class="rateit-reset" aria-label="'+n.rateit.aria.resetLabel+'" aria-controls="rateit-range-{{index}}"><\/button><{{element}} id="rateit-range-{{index}}" class="rateit-range" tabindex="0" role="slider" aria-label="'+n.rateit.aria.ratingLabel+'" aria-owns="rateit-reset-{{index}}" aria-valuemin="'+f("min")+'" aria-valuemax="'+f("max")+'" aria-valuenow="'+f("value")+'"><{{element}} class="rateit-selected" style="height:'+f("starheight")+'px"><\/{{element}}><{{element}} class="rateit-hover" style="height:'+f("starheight")+'px"><\/{{element}}><\/{{element}}>',c.append(nt.replace(/{{index}}/gi,e).replace(/{{element}}/gi,g)),v||(c.find(".rateit-reset").css("float","right"),c.find(".rateit-selected").addClass("rateit-selected-rtl"),c.find(".rateit-hover").addClass("rateit-hover-rtl")),f("init",JSON.parse(JSON.stringify(c.data()))));c.find(".rateit-selected, .rateit-hover").height(f("starheight"));l=c.find(".rateit-range");l.width(f("starwidth")*(f("max")-f("min"))).height(f("starheight"));y="rateit-preset"+(v?"":"-rtl");f("ispreset")?c.find(".rateit-selected").addClass(y):c.find(".rateit-selected").removeClass(y);f("value")!=null&&(k=(f("value")-f("min"))*f("starwidth"),c.find(".rateit-selected").width(k));a=c.find(".rateit-reset");a.data("wired")!==!0&&a.bind("click",function(t){t.preventDefault();a.blur();var i=n.Event("beforereset");if(c.trigger(i),i.isDefaultPrevented())return!1;c.rateit("value",null);c.trigger("reset")}).data("wired",!0);var tt=function(t,i){var u=i.changedTouches?i.changedTouches[0].pageX:i.pageX,r=u-n(t).offset().left;return v||(r=l.width()-r),r>l.width()&&(r=l.width()),r<0&&(r=0),k=Math.ceil(r/f("starwidth")*(1/f("step")))},it=function(n){var t=n*f("starwidth")*f("step"),r=l.find(".rateit-hover"),i;r.data("width")!=t&&(l.find(".rateit-selected").hide(),r.width(t).show().data("width",t),i=[n*f("step")+f("min")],c.trigger("hover",i).trigger("over",i))},d=function(t){var i=n.Event("beforerated");return(c.trigger(i,[t]),i.isDefaultPrevented())?!1:(f("value",t),f("backingfld")&&n(f("backingfld")).val(t).trigger("change"),f("ispreset")&&(l.find(".rateit-selected").removeClass(y),f("ispreset",!1)),l.find(".rateit-hover").hide(),l.find(".rateit-selected").width(t*f("starwidth")-f("min")*f("starwidth")).show(),c.trigger("hover",[null]).trigger("over",[null]).trigger("rated",[t]),!0)};f("readonly")?a.hide():(f("resetable")||a.hide(),f("wired")||(l.bind("touchmove touchend",t),l.mousemove(function(n){var t=tt(this,n);it(t)}),l.mouseleave(function(){l.find(".rateit-hover").hide().width(0).data("width","");c.trigger("hover",[null]).trigger("over",[null]);l.find(".rateit-selected").show()}),l.mouseup(function(n){var t=tt(this,n),i=t*f("step")+f("min");d(i);l.blur()}),l.keyup(function(n){(n.which==38||n.which==(v?39:37))&&d(Math.min(f("value")+f("step"),f("max")));(n.which==40||n.which==(v?37:39))&&d(Math.max(f("value")-f("step"),f("min")))}),f("wired",!0)),f("resetable")&&a.show());l.attr("aria-readonly",f("readonly"))})};n.fn.rateit.defaults={min:0,max:5,step:.5,starwidth:16,starheight:16,readonly:!1,resetable:!0,ispreset:!1};n(function(){n("div.rateit, span.rateit").rateit()})})(jQuery);
  5 +/*
  6 +//# sourceMappingURL=jquery.rateit.min.js.map
  7 +*/
... ...
common/modules/comment/resources/rateit.css 0 → 100644
  1 +.rateit {
  2 + display: -moz-inline-box;
  3 + display: inline-block;
  4 + position: relative;
  5 + -webkit-user-select: none;
  6 + -khtml-user-select: none;
  7 + -moz-user-select: none;
  8 + -o-user-select: none;
  9 + -ms-user-select: none;
  10 + user-select: none;
  11 + -webkit-touch-callout: none;
  12 +}
  13 +
  14 +.rateit .rateit-range
  15 +{
  16 + position: relative;
  17 + display: -moz-inline-box;
  18 + display: inline-block;
  19 + background: url(star.gif);
  20 + height: 16px;
  21 + outline: none;
  22 +}
  23 +
  24 +.rateit .rateit-range * {
  25 + display:block;
  26 +}
  27 +
  28 +/* for IE 6 */
  29 +* html .rateit, * html .rateit .rateit-range
  30 +{
  31 + display: inline;
  32 +}
  33 +
  34 +/* for IE 7 */
  35 +* + html .rateit, * + html .rateit .rateit-range
  36 +{
  37 + display: inline;
  38 +}
  39 +
  40 +.rateit .rateit-hover, .rateit .rateit-selected
  41 +{
  42 + position: absolute;
  43 + left: 0px;
  44 +}
  45 +
  46 +.rateit .rateit-hover-rtl, .rateit .rateit-selected-rtl
  47 +{
  48 + left: auto;
  49 + right: 0px;
  50 +}
  51 +
  52 +.rateit .rateit-hover
  53 +{
  54 + background: url(star.gif) left -32px;
  55 +}
  56 +
  57 +.rateit .rateit-hover-rtl
  58 +{
  59 + background-position: right -32px;
  60 +}
  61 +
  62 +.rateit .rateit-selected
  63 +{
  64 + background: url(star.gif) left -16px;
  65 +}
  66 +
  67 +.rateit .rateit-selected-rtl
  68 +{
  69 + background-position: right -16px;
  70 +}
  71 +
  72 +.rateit .rateit-preset
  73 +{
  74 + background: url(star.gif) left -48px;
  75 +}
  76 +
  77 +.rateit .rateit-preset-rtl
  78 +{
  79 + background: url(star.gif) left -48px;
  80 +}
  81 +
  82 +.rateit button.rateit-reset
  83 +{
  84 + background: url(delete.gif) 0 0;
  85 + width: 16px;
  86 + height: 16px;
  87 + display: -moz-inline-box;
  88 + display: inline-block;
  89 + float: left;
  90 + outline: none;
  91 + border:none;
  92 + padding: 0;
  93 +}
  94 +
  95 +.rateit button.rateit-reset:hover, .rateit button.rateit-reset:focus
  96 +{
  97 + background-position: 0 -16px;
  98 +}
... ...
common/modules/comment/resources/star.gif 0 → 100644

2.4 KB

common/modules/comment/widgets/CommentWidget.php
... ... @@ -178,7 +178,7 @@
178 178  
179 179 public function createParts()
180 180 {
181   - if($this->display_comment_success && $this->isSuccess) {
  181 + if($this->display_comment_success && ($this->isSuccess || \Yii::$app->session->getFlash('comment-success'))) {
182 182 $tag = ArrayHelper::remove($this->success_options, 'tag', 'div');
183 183 if(is_callable($this->success_options[ 'content' ])) {
184 184 $result = call_user_func(ArrayHelper::remove($this->success_options, 'content'), $this->success_text);
... ... @@ -277,6 +277,7 @@
277 277 $this->comment_class->checkRating();
278 278 if($this->comment_class->rating->load($data) && $this->comment_class->rating->save()) {
279 279 $this->isSuccess = true;
  280 + \Yii::$app->session->setFlash('comment-success', $this->success_text);
280 281 \Yii::$app->response->redirect('');
281 282 }
282 283 } else {
... ...
common/modules/comment/widgets/views/_review_comment_view.php
1 1 <?php
2 2 use common\models\User;
3 3 use common\modules\comment\widgets\CommentWidget;
4   - use kartik\rating\StarRating;
5 4 use yii\helpers\Html;
6 5 use yii\web\View;
7 6  
... ... @@ -29,18 +28,10 @@
29 28 ?>
30 29 <div class="comments-date"><?= \Yii::$app->formatter->asDate($model->date_add, 'php:d.m.Y') ?></div>
31 30 <?php
32   - if(!empty( $model->rating )) {
33   - echo StarRating::widget([
34   - 'name' => 'rating_review_comment',
35   - 'value' => $model->rating->value,
36   - 'pluginOptions' => [
37   - 'size' => 'xxs',
38   - 'displayOnly' => true,
39   - 'min' => 0,
40   - 'max' => 5,
41   - 'stars' => 5,
42   - ],
43   - ]);
  31 + if(!empty( $model->rating ) && $model->rating->value > 0) {
  32 + ?>
  33 + <div class="rateit" data-rateit-value="<?php echo $model->rating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
  34 + <?php
44 35 }
45 36 ?>
46 37 <div class="comments-content">
... ...
common/modules/comment/widgets/views/form-comment-review.php
... ... @@ -7,11 +7,9 @@
7 7 * @var null|\common\modules\comment\models\Rating $rating
8 8 */
9 9 use common\modules\comment\widgets\CommentWidget;
10   - use kartik\rating\StarRating;
11 10 use yii\web\View;
12 11 use yii\widgets\ActiveForm;
13 12 use yii\helpers\Html;
14   -
15 13 ?>
16 14 <div class="new-portf-add-comm style">
17 15 <?php
... ... @@ -24,17 +22,24 @@
24 22 }
25 23 echo $form->field(( !empty( $model->rating ) ? $model->rating : $rating ), 'value')
26 24 ->label(false)
27   - ->widget(StarRating::className(), [
28   - 'pluginOptions' => [
29   - 'size' => 'xxs',
30   - 'step' => 1,
31   - 'value' => 2,
32   - 'showCaption' => false,
33   - 'stars' => 5,
34   - 'min' => 0,
35   - 'max' => 5,
36   - ],
37   - ]);
  25 + ->hiddenInput();
  26 + ?>
  27 + <div id="rateit-form"></div>
  28 + <?php
  29 + $js =
  30 + "rateit = $('#rateit-form').rateit({
  31 + step: 1
  32 + });
  33 + $(rateit).bind('rated', function() {
  34 + $('#rating-value').val($(this).rateit('value'));
  35 + });
  36 + $(rateit).bind('reset', function() {
  37 + $('#rating-value').val('');
  38 + });";
  39 + $this->registerJs($js);
  40 + ?>
  41 + <?php
  42 + //rating-value
38 43 if($model->scenario == $model::SCENARIO_GUEST) {
39 44 echo $form->field($model, 'user_name', [
40 45 'options' => [
... ...
common/modules/comment/widgets/views/list-comment-review.php
... ... @@ -19,5 +19,5 @@
19 19 'form' => $commentClass->formName(),
20 20 ],
21 21 ],
22   - 'layout' => "{items}\n<div class='navi-buttons-wr style'>{pager}</div>",
  22 + 'layout' => "{items}\n<div class='navi-buttons-wr style content'>{pager}</div>",
23 23 ]);
24 24 \ No newline at end of file
... ...
common/modules/product/models/Product.php
... ... @@ -404,7 +404,7 @@ class Product extends \yii\db\ActiveRecord
404 404 }
405 405  
406 406 public function getComments() {
407   - return $this->hasMany(Comment::className(), ['model_id' => 'product_id'])->where(['comment.model' => self::className()]);
  407 + return $this->hasMany(Comment::className(), ['model_id' => 'product_id'])->where(['comment.model' => self::className(), 'comment.status' => Comment::STATUS_ACTIVE]);
408 408 }
409 409  
410 410 public function getAverageRating() {
... ...
frontend/config/main.php
... ... @@ -14,6 +14,49 @@ return [
14 14 'frontend\components\SeoComponent',
15 15 ],
16 16 'controllerNamespace' => 'frontend\controllers',
  17 + 'modules' => [
  18 + 'comment' => [
  19 + 'class' => 'common\modules\comment\Module',
  20 + 'useRbac' => false,
  21 + 'rbac' => [
  22 + 'rules' => [
  23 + \common\modules\comment\rbac\ArtboxCommentCreateRule::className(),
  24 + \common\modules\comment\rbac\ArtboxCommentDeleteRule::className(),
  25 + \common\modules\comment\rbac\ArtboxCommentUpdateRule::className(),
  26 + \common\modules\comment\rbac\ArtboxCommentUpdateOwnRule::className(),
  27 + \common\modules\comment\rbac\ArtboxCommentDeleteOwnRule::className(),
  28 + ],
  29 + 'permissions' => [
  30 + [
  31 + 'name' => common\modules\comment\Permissions::CREATE,
  32 + 'description' => 'Can create comments',
  33 + 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentCreateRule())->name,
  34 + ],
  35 + [
  36 + 'name' => common\modules\comment\Permissions::UPDATE,
  37 + 'description' => 'Can update comments',
  38 + 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentUpdateRule())->name,
  39 + ],
  40 + [
  41 + 'name' => common\modules\comment\Permissions::DELETE,
  42 + 'description' => 'Can delete comments',
  43 + 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentDeleteRule())->name,
  44 + ],
  45 + [
  46 + 'name' => common\modules\comment\Permissions::UPDATE_OWN,
  47 + 'description' => 'Can update own comments',
  48 + 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentUpdateOwnRule())->name,
  49 + ],
  50 + [
  51 + 'name' => common\modules\comment\Permissions::DELETE_OWN,
  52 + 'description' => 'Can delete own comments',
  53 + 'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentDeleteOwnRule())->name,
  54 + ],
  55 + ],
  56 + ],
  57 +
  58 + ],
  59 + ],
17 60 'components' => [
18 61 'authManager' => [
19 62 'class' => 'yii\rbac\DbManager',
... ...
frontend/views/catalog/product.php
... ... @@ -4,29 +4,38 @@
4 4 use common\modules\comment\widgets\CommentWidget;
5 5 use kartik\rating\StarRating;
6 6 use yii\widgets\Breadcrumbs;
7   -use yii\web\View;
8   -use yii\helpers\Url;
9   -use frontend\widgets\Seo;
  7 + use yii\web\View;
  8 + use yii\helpers\Url;
  9 + use frontend\widgets\Seo;
10 10  
11   -$this->params['seo']['key'] = $product->category->categoryName->value;
12   -$this->params['seo']['fields']['name'] = $product->fullname;
13   -$this->params['seo']['h1'] = !empty(Seo::widget([ 'row'=>'h1'])) ? Seo::widget([ 'row'=>'h1']) : $product->fullname;
14   -
15   -//$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
16   -//$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
17   -$this->title = $product->fullname;
18   -//$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname;
19   -//$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]);
20   -//$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]);
21   -
22   -//foreach($product->category->getParents()->all() as $parent) {
23   -// $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
24   -//}
25   -$this->params['breadcrumbs'][] = ['label' => 'Каталог', 'url' => ['catalog/category']];
26   -$this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]];
27   -$this->params['breadcrumbs'][] = $product->fullname .' #'. $product->enabledVariants[0]->sku;
28   -
29   -$this->registerJs ('
  11 + $this->params[ 'seo' ][ 'key' ] = $product->category->categoryName->value;
  12 + $this->params[ 'seo' ][ 'fields' ][ 'name' ] = $product->fullname;
  13 + $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullname;
  14 +
  15 + //$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
  16 + //$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
  17 + $this->title = $product->fullname;
  18 + //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname;
  19 + //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]);
  20 + //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]);
  21 +
  22 + //foreach($product->category->getParents()->all() as $parent) {
  23 + // $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
  24 + //}
  25 + $this->params[ 'breadcrumbs' ][] = [
  26 + 'label' => 'Каталог',
  27 + 'url' => [ 'catalog/category' ],
  28 + ];
  29 + $this->params[ 'breadcrumbs' ][] = [
  30 + 'label' => $product->category->categoryName->value,
  31 + 'url' => [
  32 + 'catalog/category',
  33 + 'category' => $product->category,
  34 + ],
  35 + ];
  36 + $this->params[ 'breadcrumbs' ][] = $product->fullname . ' #' . $product->enabledVariants[ 0 ]->sku;
  37 +
  38 + $this->registerJs('
30 39  
31 40 var checkData = function($index)
32 41 {
... ... @@ -67,8 +76,8 @@ $this-&gt;registerJs (&#39;
67 76 checkData(0);
68 77  
69 78 ', View::POS_READY, 'fasovka');
70   -
71   -$this->registerJs ("
  79 +
  80 + $this->registerJs("
72 81 $('#nav_product li a').addClass('active');
73 82 $('#nav_product li').find('.info').toggle();
74 83  
... ... @@ -81,111 +90,116 @@ $this-&gt;registerJs (&quot;
81 90 return false;
82 91 });
83 92 ", View::POS_READY, 'nav_product');
84   -
85   -$this->registerCssFile (Yii::$app->request->BaseUrl . '/js/shadowbox-3.0.3/shadowbox.css');
86   -$this->registerJsFile (Yii::$app->request->baseUrl . '/js/shadowbox-3.0.3/shadowbox.js', ['position' => View::POS_END, 'depends' => ['yii\web\JqueryAsset']]);
87   -$this->registerJs ("
  93 +
  94 + $this->registerCssFile(Yii::$app->request->BaseUrl . '/js/shadowbox-3.0.3/shadowbox.css');
  95 + $this->registerJsFile(Yii::$app->request->baseUrl . '/js/shadowbox-3.0.3/shadowbox.js', [
  96 + 'position' => View::POS_END,
  97 + 'depends' => [ 'yii\web\JqueryAsset' ],
  98 + ]);
  99 + $this->registerJs("
88 100 Shadowbox.init({
89 101  
90 102 });
91 103 ", View::POS_READY, 'Shadowbox');
92 104 ?>
93 105  
94   -<nav class="bread-crumbs">
95   - <?= Breadcrumbs::widget ([
96   - 'links' => $this->params['breadcrumbs'],
97   - ])
98   - ?>
99   - <div class="both"></div>
100   -</nav>
101   -<?php if ($flash = Yii::$app->session->getFlash ('success')): ?>
  106 + <nav class="bread-crumbs">
  107 + <?= Breadcrumbs::widget([
  108 + 'links' => $this->params[ 'breadcrumbs' ],
  109 + ]) ?>
  110 + <div class="both"></div>
  111 + </nav>
  112 +<?php if($flash = Yii::$app->session->getFlash('success')): ?>
102 113 <div class="alert-success"><?= $flash ?></div>
103 114 <?php endif; ?>
104   -<div class="loyout">
105   - <div itemscope itemtype="http://schema.org/Product">
106   - <div class="productLeftBar">
107   - <div itemprop="name"><h1><?= Seo::widget([ 'row'=>'h1'])?></h1></div>
108   - <?php foreach($product->enabledVariantsGrouped as $variantGroup) :?>
109   - <div class="begin"><?= $variantGroup->name2?></div>
110   - <ul class="product_mod">
111   - <?php foreach ($variantGroup->_variants as $variant): ?>
112   - <li>
113   - <a id='m<?= $variant->product_variant_id ?>' href="#<?=$variant->product_variant_id ?>"
114   - data-cost="<?= $variant->price ?>"
115   - data-old_cost="<?= $variant->price_old ?>" data-id="<?= $variant->product_variant_id ?>" data-art="<?= $variant->sku ?>"
116   - data-color="<?= $variant->name ?>"
117   - data-image="<?= \common\components\artboximage\ArtboxImageHelper::getImageSrc($variant->imageUrl, 'product_view') ?>"
118   - data-imageoriginal="<?= $variant->imageUrl ?>"
119   - title="<?= $product->fullname ?>">
120   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant', ['alt' => $product->category->categoryName->value . ' ' .
121   - $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
122   - $product->fullname])?>
123   - </a>
124   - </li>
125   - <?php endforeach; ?>
126   - </ul>
127   - <div class="both"></div>
128   - <?php endforeach; ?>
129   -
130   - <div class="cost_box product_read_">
131   - <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
132   - <div class='params'>код: <span id='art'></span><br/> цвет: <span id='color'></span></div>
133   - <div class="product_read_price">
134   - <div class="w">
135   - <strike><span itemprop="price"><span id='old_cost'>0</span></span> грн.</strike>
136   - <span class="cost"><span itemprop="price"><span id='cost'>0</span></span> <span class="valute">грн.</span></span>
137   - <meta itemprop="priceCurrency" content = "UAH">
138   - </div>
139   - <input type='hidden' id='product_id'/>
140   - <a href="#" rel='product' class="link_buy fl">Купить</a>
141   - <div class="both"></div>
142   - </div>
143   - </div>
144   -
145   - <div class="product_service">
146   - <ul>
147   - <?php if (Yii::$app->user->id) :?>
148   - <li class="item1"><a href="<?= Url::to (['iam/share', 'id' => $product->product_id]) ?>">Добавить в закладки</a></li>
149   - <?php endif?>
150   - <?php if (FALSE && Yii::$app->user->id) :?>
151   - <li class="item2"><a href="<?= Url::to (['iam/price', 'id' => $product->product_id]) ?>">Узнать о снижение цены</a></li>
152   - <?php endif?>
153   - <?php if (FALSE) :?>
154   - <li class="item3"><a href="<?= Url::to (['products/compare', 'id' => $product->product_id]) ?>">Добавить в сравнение</a></li>
155   - <?php endif?>
156   - </ul>
157   - </div>
158   - <div class="artbox_comment_description">
159   - <?php
160   - if(!empty($product->averageRating)) {
161   - echo StarRating::widget([
162   - 'name' => 'rating_product',
163   - 'value' => $product->averageRating->value,
164   - 'pluginOptions' => [
165   - 'displayOnly' => true,
166   - 'size' => 'xxs',
167   - 'min' => 0,
168   - 'max' => 5,
169   - 'stars' => 5,
170   - ],
171   - ]);
172   - }
173   - ?>
174   - <p><a href="#artbox-comment">
  115 + <div class="loyout">
  116 + <div itemscope itemtype="http://schema.org/Product">
  117 + <div class="productLeftBar">
  118 + <div itemprop="name"><h1><?= Seo::widget([ 'row' => 'h1' ]) ?></h1></div>
  119 + <?php foreach($product->enabledVariantsGrouped as $variantGroup) : ?>
  120 + <div class="begin"><?= $variantGroup->name2 ?></div>
  121 + <ul class="product_mod">
  122 + <?php foreach($variantGroup->_variants as $variant): ?>
  123 + <li>
  124 + <a id='m<?= $variant->product_variant_id ?>' href="#<?= $variant->product_variant_id ?>"
  125 + data-cost="<?= $variant->price ?>"
  126 + data-old_cost="<?= $variant->price_old ?>" data-id="<?= $variant->product_variant_id ?>" data-art="<?= $variant->sku ?>"
  127 + data-color="<?= $variant->name ?>"
  128 + data-image="<?= \common\components\artboximage\ArtboxImageHelper::getImageSrc($variant->imageUrl, 'product_view') ?>"
  129 + data-imageoriginal="<?= $variant->imageUrl ?>"
  130 + title="<?= $product->fullname ?>">
  131 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant', [
  132 + 'alt' => $product->category->categoryName->value . ' ' . $product->fullname,
  133 + 'title' => $product->category->categoryName->value . ' ' . $product->fullname,
  134 + ]) ?>
  135 + </a>
  136 + </li>
  137 + <?php endforeach; ?>
  138 + </ul>
  139 + <div class="both"></div>
  140 + <?php endforeach; ?>
  141 +
  142 + <div class="cost_box product_read_">
  143 + <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
  144 + <div class='params'>код: <span id='art'></span><br/> цвет:
  145 + <span id='color'></span></div>
  146 + <div class="product_read_price">
  147 + <div class="w">
  148 + <strike><span itemprop="price"><span id='old_cost'>0</span></span> грн.</strike>
  149 + <span class="cost"><span itemprop="price"><span id='cost'>0</span></span> <span class="valute">грн.</span></span>
  150 + <meta itemprop="priceCurrency" content="UAH">
  151 + </div>
  152 + <input type='hidden' id='product_id'/>
  153 + <a href="#" rel='product' class="link_buy fl">Купить</a>
  154 + <div class="both"></div>
  155 + </div>
  156 + </div>
  157 +
  158 + <div class="product_service">
  159 + <ul>
  160 + <?php if(Yii::$app->user->id) : ?>
  161 + <li class="item1"><a href="<?= Url::to([
  162 + 'iam/share',
  163 + 'id' => $product->product_id,
  164 + ]) ?>">Добавить в закладки</a></li>
  165 + <?php endif ?>
  166 + <?php if(false && Yii::$app->user->id) : ?>
  167 + <li class="item2"><a href="<?= Url::to([
  168 + 'iam/price',
  169 + 'id' => $product->product_id,
  170 + ]) ?>">Узнать о снижение цены</a></li>
  171 + <?php endif ?>
  172 + <?php if(false) : ?>
  173 + <li class="item3"><a href="<?= Url::to([
  174 + 'products/compare',
  175 + 'id' => $product->product_id,
  176 + ]) ?>">Добавить в сравнение</a></li>
  177 + <?php endif ?>
  178 + </ul>
  179 + </div>
  180 + <div class="artbox_comment_description">
175 181 <?php
176   - $comment_count = count($product->comments);
177   - if($comment_count) {
178   - echo "Отзывов: ".$comment_count;
179   - } else {
180   - echo "Оставть отзыв";
  182 + if(!empty( $product->averageRating ) && $product->averageRating->value) {
  183 + ?>
  184 + <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
  185 + <?php
181 186 }
182 187 ?>
183   - </a></p>
184   - </div>
185   - <br>
186   - <div class="ya-share2" data-services="vkontakte,facebook,odnoklassniki,gplus,twitter" data-size="s"></div>
187   - </div>
188   - <?php /*
  188 + <p><a href="#artbox-comment">
  189 + <?php
  190 + $comment_count = count($product->comments);
  191 + if($comment_count) {
  192 + echo "Отзывов: " . $comment_count;
  193 + } else {
  194 + echo "Оставть отзыв";
  195 + }
  196 + ?>
  197 + </a></p>
  198 + </div>
  199 + <br>
  200 + <div class="ya-share2" data-services="vkontakte,facebook,odnoklassniki,gplus,twitter" data-size="s"></div>
  201 + </div>
  202 + <?php /*
189 203 <div class="product_service">
190 204 <ul>
191 205 <li class="item1"><a href="<?= Url::to (['iam/share', 'id' => $product->product_id]) ?>">Добавить в закладки</a>
... ... @@ -195,70 +209,78 @@ $this-&gt;registerJs (&quot;
195 209 <li class="item3"><a href="<?= Url::to (['products/compare', 'id' => $product->product_id]) ?>">Добавить в
196 210 сравнение</a></li>
197 211 </ul>
198   - </div>*/?>
199   - </div>
200   -
201   - <div class="productRightBar">
202   - <ul id="nav_product">
203   - <li><a href="#">Характеристики</a>
204   - <div class="info">
205   - <p>Бренд: <?= $product->brand->name ?></p>
206   - <?php foreach ($product->properties as $group): ?>
207   - <p><?= $group->name ?> <?php foreach($group->_options as $option) :?>&nbsp;<?= $option->ValueRenderHTML?><?php endforeach?></p>
208   - <?php endforeach; ?>
209   - </div>
210   - </li>
211   - <li><a href="#">Описание</a>
212   - <div itemprop="description"> <div class="info">
213   - <?= $product->description ?>
214   - </div></div>
215   - </li>
216   - <?php if(!empty($product->video) && strpos($product->video, '.jpg') === FALSE && strpos($product->video, '.png') === FALSE) :?>
217   - <li><a href="#">Видео</a>
218   - <div class="info product-thumb-video">
219   - <?php if (strpos($product->video, '<iframe') !== FALSE || strpos($product->video, '<object') !== FALSE) :?>
220   - <?= $product->video?>
221   - <?php else :?>
222   - <?= \cics\widgets\VideoEmbed::widget(['responsive' => false, 'url' => $product->video]) ?>
223   - <?php endif?>
224   - </div>
225   - </li>
226   - <?php endif?>
227   - </ul>
228   - </div>
229   - </div>
230   - <div class="content">
231   - <div class="pic">
232   - <center>
233   - <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'product_view',['id'=>'pic', 'alt' => $product->category->categoryName->value . ' ' .
234   - $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
235   - $product->fullname])?></a>
236   - </center>
  212 + </div>*/ ?>
  213 + </div>
  214 +
  215 + <div class="productRightBar">
  216 + <ul id="nav_product">
  217 + <li><a href="#">Характеристики</a>
  218 + <div class="info">
  219 + <p>Бренд: <?= $product->brand->name ?></p>
  220 + <?php foreach($product->properties as $group): ?>
  221 + <p><?= $group->name ?> <?php foreach($group->_options as $option) : ?>&nbsp;<?= $option->ValueRenderHTML ?><?php endforeach ?></p>
  222 + <?php endforeach; ?>
  223 + </div>
  224 + </li>
  225 + <li><a href="#">Описание</a>
  226 + <div itemprop="description">
  227 + <div class="info">
  228 + <?= $product->description ?>
  229 + </div>
  230 + </div>
  231 + </li>
  232 + <?php if(!empty( $product->video ) && strpos($product->video, '.jpg') === false && strpos($product->video, '.png') === false) : ?>
  233 + <li><a href="#">Видео</a>
  234 + <div class="info product-thumb-video">
  235 + <?php if(strpos($product->video, '<iframe') !== false || strpos($product->video, '<object') !== false) : ?>
  236 + <?= $product->video ?>
  237 + <?php else : ?>
  238 + <?= \cics\widgets\VideoEmbed::widget([
  239 + 'responsive' => false,
  240 + 'url' => $product->video,
  241 + ]) ?>
  242 + <?php endif ?>
  243 + </div>
  244 + </li>
  245 + <?php endif ?>
  246 + </ul>
  247 + </div>
237 248 </div>
238   - <ul class="product_colors">
239   - <?php foreach ($product->images as $image): ?>
240   - <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]">
241   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2',['alt' => $product->category->categoryName->value . ' ' .
242   - $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
243   - $product->fullname])?>
244   - </a></li>
245   - <?php endforeach; ?>
246   - </ul>
247   - </div>
248   - <div class="both"></div>
249   - <div class="comment-wrapper">
250   - <?php
251   - echo CommentWidget::widget([
  249 + <div class="content">
  250 + <div class="pic">
  251 + <center>
  252 + <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[ 0 ]->imageUrl, 'product_view', [
  253 + 'id' => 'pic',
  254 + 'alt' => $product->category->categoryName->value . ' ' . $product->fullname,
  255 + 'title' => $product->category->categoryName->value . ' ' . $product->fullname,
  256 + ]) ?></a>
  257 + </center>
  258 + </div>
  259 + <ul class="product_colors">
  260 + <?php foreach($product->images as $image): ?>
  261 + <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]">
  262 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2', [
  263 + 'alt' => $product->category->categoryName->value . ' ' . $product->fullname,
  264 + 'title' => $product->category->categoryName->value . ' ' . $product->fullname,
  265 + ]) ?>
  266 + </a></li>
  267 + <?php endforeach; ?>
  268 + </ul>
  269 + </div>
  270 + <div class="both"></div>
  271 + <div class="comment-wrapper">
  272 + <?php
  273 + echo CommentWidget::widget([
252 274 'comment_class' => Comment::className(),
253   - 'rating_class' => Rating::className(),
254   - 'success_text' => 'Комментарий успешно добавлен',
  275 + 'rating_class' => Rating::className(),
  276 + 'success_text' => 'Комментарий успешно добавлен и отобразится после проверки модератором',
255 277 'class_options' => [
256   - 'scenario' => \Yii::$app->user->isGuest?Comment::SCENARIO_GUEST:Comment::SCENARIO_USER,
257   - 'status' => Comment::STATUS_ACTIVE,
258   - 'user_id' => \Yii::$app->user->isGuest?NULL:\Yii::$app->user->id,
  278 + 'scenario' => \Yii::$app->user->isGuest ? Comment::SCENARIO_GUEST : Comment::SCENARIO_USER,
  279 + 'status' => Comment::STATUS_HIDDEN,
  280 + 'user_id' => \Yii::$app->user->isGuest ? NULL : \Yii::$app->user->id,
259 281 ],
260   - 'model' => $product->className(),
261   - 'model_id' => $product->product_id,
  282 + 'model' => $product->className(),
  283 + 'model_id' => $product->product_id,
262 284 'list_options' => [
263 285 'view' => 'list-comment-review',
264 286 ],
... ... @@ -268,20 +290,20 @@ $this-&gt;registerJs (&quot;
268 290 ],
269 291 'options' => [
270 292 'class' => 'proektant-comments-wr style',
271   - 'id' => 'artbox-comment',
  293 + 'id' => 'artbox-comment',
272 294 ],
273 295 ]);
274   - ?>
  296 + ?>
  297 + </div>
  298 +
  299 + <?= \common\modules\product\widgets\similarProducts::widget([ 'product' => $product ]) ?>
  300 + <?= \common\modules\product\widgets\specialProducts::widget([ 'type' => 'promo' ]) ?>
  301 + <?= \common\modules\product\widgets\specialProducts::widget([ 'type' => 'new' ]) ?>
  302 + <?= \common\modules\product\widgets\specialProducts::widget([ 'type' => 'top' ]) ?>
  303 + <?= \common\modules\product\widgets\lastProducts::widget() ?>
275 304 </div>
276   -
277   - <?= \common\modules\product\widgets\similarProducts::widget(['product' => $product])?>
278   - <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'promo'])?>
279   - <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'new'])?>
280   - <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'top'])?>
281   - <?= \common\modules\product\widgets\lastProducts::widget()?>
282   -</div>
283 305 <?php
284   -$this->registerJs ("
  306 + $this->registerJs("
285 307 var productHash = window.location.hash;
286 308 productHash = productHash.replace('#','')
287 309  
... ...
frontend/views/catalog/product_item.php
1 1 <?php
2 2 /** @var \common\modules\product\models\Product $product */
3   - use kartik\rating\StarRating;
  3 + use common\modules\comment\assets\CommentAsset;
4 4 use yii\helpers\Html;
5 5 use yii\helpers\Url;
6   -
  6 +
  7 + CommentAsset::register($this);
7 8 ?>
8 9 <li class="item" itemscope itemtype="http://schema.org/Product">
9 10 <div class="boxitem">
... ... @@ -40,26 +41,22 @@
40 41 <?php endif ?>
41 42 <div class="comment_display_block">
42 43 <?php
43   - if(!empty( $product->averageRating )) {
44   - echo StarRating::widget([
45   - 'name' => 'rating_product',
46   - 'value' => $product->averageRating->value,
47   - 'pluginOptions' => [
48   - 'displayOnly' => true,
49   - 'size' => 'xxs',
50   - 'min' => 0,
51   - 'max' => 5,
52   - 'stars' => 5,
53   - ],
54   - ]);
  44 + if(!empty( $product->averageRating && $product->averageRating->value > 0)) {
  45 + ?>
  46 + <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
  47 + <?php
55 48 }
  49 + ?>
  50 + <p>
  51 + <?php
  52 + $comment_count = count($product->comments);
  53 + echo Html::a(( $comment_count ? 'Отзывов: ' . count($product->comments) : "Оставить отзыв" ), [
  54 + 'catalog/product',
  55 + 'product' => $product,
  56 + '#' => 'artbox-comment',
  57 + ]);
56 58 ?>
57   - <p>
58   - <?php
59   - $comment_count = count($product->comments);
60   - echo Html::a(($comment_count?'Отзывов: ' . count($product->comments):"Оставить отзыв"), ['catalog/product', 'product' => $product, '#' => 'artbox-comment'])
61   - ?>
62   - </p>
  59 + </p>
63 60 </div>
64 61 <div itemprop="name"><a href="<?= Url::to([
65 62 'catalog/product',
... ...