diff --git a/backend/config/main.php b/backend/config/main.php index 089ca47..2bbc0cc 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -26,6 +26,7 @@ 'blog' => 'artbox\weblog\controllers\ArticleController', 'blog-category' => 'artbox\weblog\controllers\CategoryController', 'blog-tag' => 'artbox\weblog\controllers\TagController', + 'comment' => 'artbox\webcomment\controllers\ManageController', ], 'components' => [ 'assetManager' => [ diff --git a/backend/views/comment/answer.php b/backend/views/comment/answer.php new file mode 100755 index 0000000..513296f --- /dev/null +++ b/backend/views/comment/answer.php @@ -0,0 +1,69 @@ +title = \Yii::t('artbox-comment', 'Ответить на комментарий') . '# ' . $model->id; + + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('artbox-comment', 'Комментарии'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + +
+ + +
+ field($answer, 'text') + ->textarea() ?> + + field($answer, 'parent_id') + ->hiddenInput( + [ + 'value' => $model->id, + ] + ) + ->label(false) ?> + + field($answer, 'customer_id') + ->hiddenInput( + [ + 'value' => 1, + ] + ) + ->label(false) ?> + + field($answer, 'entity') + ->hiddenInput( + [ + 'value' => $model->entity, + ] + ) + ->label(false) ?> + + field($answer, 'entity_id') + ->hiddenInput( + [ + 'value' => $model->entity_id, + ] + ) + ->label(false) ?> + + 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/backend/views/comment/index.php b/backend/views/comment/index.php new file mode 100755 index 0000000..3af5138 --- /dev/null +++ b/backend/views/comment/index.php @@ -0,0 +1,145 @@ +title = \Yii::t('artbox-comment', 'Комментарии'); + + $this->params[ 'breadcrumbs' ][] = $this->title; + + $statuses = [ + $searchModel::STATUS_ACTIVE => \Yii::t('artbox-comment', 'Активный'), + $searchModel::STATUS_HIDDEN => \Yii::t('artbox-comment', 'Скрытый'), + $searchModel::STATUS_DELETED => \Yii::t('artbox-comment', 'Удаленный'), + ]; + Pjax::begin(); + if (( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != null) { + echo Html::tag('p', $success); + } + echo GridView::widget( + [ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'id', + [ + 'attribute' => 'created_at', + 'format' => [ + 'date', + 'php:d.m.Y', + ], + 'filter' => false, + ], + [ + 'label' => \Yii::t('artbox-comment', 'Комментарий'), + 'content' => function (CommentModel $model) { + return StringHelper::truncate($model->text, 40, '...'); + }, + ], + [ + 'label' => \Yii::t('artbox-comment', 'Сущность '), + 'content' => function (CommentModel $model) { + try { + $entity = call_user_func($model->entity . '::find'); + } catch (Exception $exception) { + return \Yii::$app->formatter->asText(''); + } + $item = $entity->where([ 'id' => $model->entity_id ]) + ->with( + [ + 'lang', + 'lang.alias', + ] + ) + ->one(); + if ($item !== null) { + if ($urlManagerFrontend = \Yii::$app->get('urlManagerFrontend', false)) { + + return "" . $item->lang->title . ""; + } + + return $item->lang->title; + } + return 'Товар удален'; + }, + ], + [ + 'attribute' => 'customer_id', + 'value' => function ($model) { + /** + * @var CommentModel $model + */ + if (!empty($model->customer)) { + return $model->customer->username . ' (id:' . $model->customer->id . ')'; + } else { + return $model->username . ' ' . $model->email . ' (' . \Yii::t( + 'artbox-comment', + 'Гость' + ) . ')'; + } + }, + ], + [ + 'attribute' => 'status', + 'filter' => $statuses, + 'value' => function ($model) use ($statuses) { + /** + * @var CommentModel $model + */ + if (array_key_exists($model->status, $statuses)) { + return $statuses[ $model->status ]; + } else { + return null; + } + }, + ], + [ + 'attribute' => 'ratingValue', + 'value' => function ($model) { + /** + * @var CommentModel $model + */ + if (!empty($model->rating)) { + return $model->rating->value; + } + return null; + }, + ], + [ + 'attribute' => 'childrenCount', + 'value' => function ($model) { + /** + * @var CommentModel $model + */ + return count($model->children); + }, + ], + [ + 'class' => 'yii\grid\ActionColumn', + 'buttons' => [ + 'answer' => function (string $url) { + return Html::a(Html::tag('i', '', [ 'class' => 'glyphicon glyphicon-bullhorn' ]), $url); + }, + ], + 'template' => '{update} {answer} {delete}', + ], + ], + ] + ); + Pjax::end(); \ No newline at end of file diff --git a/backend/views/comment/update.php b/backend/views/comment/update.php new file mode 100755 index 0000000..bfb418e --- /dev/null +++ b/backend/views/comment/update.php @@ -0,0 +1,20 @@ + \Yii::t('artbox-comment', 'Активный'), + $model::STATUS_HIDDEN => \Yii::t('artbox-comment', 'Скрытый'), + $model::STATUS_DELETED => \Yii::t('artbox-comment', 'Удаленный'), + ]; + $form = ActiveForm::begin(); + echo $form->field($model, 'text') + ->textarea(); + echo $form->field($model, 'status') + ->dropDownList($statuses); + echo Html::submitButton(\Yii::t('artbox-comment', 'Обновить')); + $form->end(); \ No newline at end of file diff --git a/backend/views/layouts/menu_items.php b/backend/views/layouts/menu_items.php index 7c27fe2..e52be49 100755 --- a/backend/views/layouts/menu_items.php +++ b/backend/views/layouts/menu_items.php @@ -110,5 +110,10 @@ 'url' => ['/objectkb/index'], 'icon' => 'sun-o', ], + [ + 'label' => \Yii::t('core', 'Комментарии'), + 'url' => ['/comment/index'], + 'icon' => 'sun-o', + ], ] ); \ No newline at end of file diff --git a/common/config/bootstrap.php b/common/config/bootstrap.php index 9dee74a..b46a156 100644 --- a/common/config/bootstrap.php +++ b/common/config/bootstrap.php @@ -9,4 +9,7 @@ } if (!Yii::getAlias('@artbox/weblog', false)) { Yii::setAlias('@artbox/weblog', dirname(dirname(__DIR__)) . '/artweb/artbox-weblog'); + } + if (!Yii::getAlias('@artbox/webcomment', false)) { + Yii::setAlias('@artbox/webcomment', dirname(dirname(__DIR__)) . '/artweb/artbox-webcomment'); } \ No newline at end of file diff --git a/common/config/main.php b/common/config/main.php index 5a0efdf..b0719fa 100644 --- a/common/config/main.php +++ b/common/config/main.php @@ -17,6 +17,9 @@ 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css', ], ], + 'artbox-comment' => [ + 'class' => 'artbox\webcomment\Module', + ], ], 'components' => [ 'cache' => [ @@ -36,6 +39,10 @@ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@artbox/weblog/messages', ], + 'artbox-comment' => [ + 'class' => 'yii\i18n\PhpMessageSource', + 'basePath' => '@artbox/webcomment/messages', + ], ], ], 'filedb' => [ diff --git a/common/models/User.php b/common/models/User.php new file mode 100644 index 0000000..5bb6954 --- /dev/null +++ b/common/models/User.php @@ -0,0 +1,29 @@ +createTable( + 'customer', + [ + 'id' => $this->primaryKey(), + 'username' => $this->string() + ->notNull() + ->unique(), + 'auth_key' => $this->string(32) + ->notNull(), + 'password_hash' => $this->string() + ->notNull(), + 'password_reset_token' => $this->string() + ->unique(), + 'email' => $this->string() + ->unique(), + + 'status' => $this->smallInteger() + ->notNull() + ->defaultValue(10), + 'created_at' => $this->integer() + ->notNull(), + 'updated_at' => $this->integer() + ->notNull(), + 'name' => $this->string(), + 'phone' => $this->string(), + 'gender' => $this->smallInteger(1), + 'birthday' => $this->integer(), + 'city' => $this->string(), + 'address' => $this->string(), + 'social_id' => $this->string(), + ] + ); + } + + /** + * @inheritdoc + */ + public function safeDown() + { + $this->dropTable('customer'); + } +} diff --git a/frontend/views/blog/view.php b/frontend/views/blog/view.php index 92e3af0..be24eec 100644 --- a/frontend/views/blog/view.php +++ b/frontend/views/blog/view.php @@ -4,7 +4,7 @@ * Date: 26.01.18 * Time: 9:22 * - * @var Article $article + * @var Article $article * @var SeoComponent $seo */ @@ -15,17 +15,17 @@ use common\models\Settings; use artbox\core\components\SeoComponent; use yii\helpers\Url; - + use artbox\webcomment\widgets\CommentWidget; $settings = Settings::getInstance(); $seo = Yii::$app->get('seo'); $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('app', "menu-blog"), - 'url' => Url::toRoute(['blog/index']) + 'url' => Url::toRoute([ 'blog/index' ]), ]; $this->params[ 'breadcrumbs' ][] = $seo->h1 - + ?>
@@ -39,47 +39,28 @@

- lang->title?> + lang->title ?>

- image->getImg( + image->getImg( [ - 'class' => "img-responsive" + 'class' => "img-responsive", ] - )?> + ) ?>

- lang->body?> + lang->body ?>
- -
- - - - - + + $article ]) ?> + + + @@ -93,104 +74,126 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -207,11 +210,11 @@ - + - + - + -- libgit2 0.21.4