From 518c4e3f1e0bd2cdb83b8925409c7f87737f983a Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 27 Sep 2017 12:41:56 +0300 Subject: [PATCH] -Article with comments ready --- backend/config/main.php | 6 ------ common/config/main.php | 14 +++++++++----- frontend/views/blog/article.php | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------- frontend/views/comment/artbox_comment_form.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/comment/artbox_comment_item.php | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/comment/artbox_comment_list.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/comment/artbox_comment_reply.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 475 insertions(+), 103 deletions(-) create mode 100755 frontend/views/comment/artbox_comment_form.php create mode 100755 frontend/views/comment/artbox_comment_item.php create mode 100755 frontend/views/comment/artbox_comment_list.php create mode 100755 frontend/views/comment/artbox_comment_reply.php diff --git a/backend/config/main.php b/backend/config/main.php index 7477702..216d1c3 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -1,7 +1,6 @@ dirname(__DIR__), 'controllerNamespace' => 'backend\controllers', 'bootstrap' => [ 'log' ], - 'modules' => [ - 'artbox-comment' => [ - 'class' => Module::className(), - ], - ], 'controllerMap' => [ 'profile' => 'artbox\core\controllers\ProfileController', 'page' => 'artbox\core\controllers\PageController', diff --git a/common/config/main.php b/common/config/main.php index bcd8416..025ffa8 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -1,12 +1,13 @@ dirname(dirname(__DIR__)) . '/vendor', 'modules' => [ - 'imagemanager' => [ + 'imagemanager' => [ 'class' => 'artbox\core\components\imagemanager\Module', 'canUploadImage' => true, 'canRemoveImage' => function () { @@ -17,6 +18,9 @@ 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css', ], ], + 'artbox-comment' => [ + 'class' => Module::className(), + ], ], 'components' => [ 'cache' => [ @@ -24,15 +28,15 @@ ], 'i18n' => [ 'translations' => [ - 'core' => [ + 'core' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@artbox/core/messages', ], - 'app' => [ + 'app' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@common/messages', ], - 'blog' => [ + 'blog' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@artbox/weblog/messages', ], @@ -71,7 +75,7 @@ 'port' => '587', 'encryption' => 'tls', ], - 'viewPath' => '@common/mail' + 'viewPath' => '@common/mail', ], ], ]; diff --git a/frontend/views/blog/article.php b/frontend/views/blog/article.php index 649d5b2..14d6a97 100644 --- a/frontend/views/blog/article.php +++ b/frontend/views/blog/article.php @@ -1,5 +1,6 @@ 'alias' => $model->category->lang->alias, ] ); - } + } ?> | created_at @@ -52,100 +53,117 @@ _________________________________________________________ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + $model, + 'display_name' => 'name', + 'reply' => true, + 'delete' => false, + 'more' => [ + 'show_' => true, + 'key' => 2, + ], + 'formView' => '@frontend/views/comment/artbox_comment_form', + 'listView' => '@frontend/views/comment/artbox_comment_list', + 'replyView' => '@frontend/views/comment/artbox_comment_reply', + 'itemView' => '@frontend/views/comment/artbox_comment_item', + ] + ); + ?> diff --git a/frontend/views/comment/artbox_comment_form.php b/frontend/views/comment/artbox_comment_form.php new file mode 100755 index 0000000..46b8132 --- /dev/null +++ b/frontend/views/comment/artbox_comment_form.php @@ -0,0 +1,70 @@ + $formId, + 'action' => Url::to( + [ + 'artbox-comment/default/create', + 'entity' => $comment_model->encryptedEntity, + ] + ), + ] + ); +?> +
+ +
+ field($rating_model, 'value', [ 'enableClientValidation' => false ]) + ->hiddenInput() + ->label(false); + echo Html::tag( + 'div', + '', + [ + 'class' => 'rateit', + 'data-rateit-backingfld' => '#' . Html::getInputId($rating_model, 'value'), + ] + ); + ?> +
+ user->isGuest) { + echo $form->field($comment_model, 'username', [ 'options' => [ 'class' => 'form-group input_bl' ] ]) + ->textInput(); + echo $form->field($comment_model, 'email', [ 'options' => [ 'class' => 'form-group input_bl' ] ]) + ->textInput(); + } + echo $form->field($comment_model, 'text', [ 'options' => [ 'class' => 'form-group input_bl area_bl' ] ]) + ->textarea(); + echo Html::tag( + 'div', + Html::submitButton( + Yii::t('app', 'Submit comment') + ), + [ 'class' => 'input_bl submit_btn' ] + ); + ?> +
+ \ No newline at end of file diff --git a/frontend/views/comment/artbox_comment_item.php b/frontend/views/comment/artbox_comment_item.php new file mode 100755 index 0000000..2c7d1c6 --- /dev/null +++ b/frontend/views/comment/artbox_comment_item.php @@ -0,0 +1,166 @@ + + +
+
+
+ username, 0,1); + ?> +
+ + + rating)) { + ?> +
+ 1 + rating->value; ?> + 5 +
+
+ +
+ text; + ?> +
+
+
+ user->isGuest && $reply && \Yii::$app->user->id != $model->customer_id) { + ?> + + user->isGuest && \Yii::$app->user->id == $model->customer_id && $delete) { + ?> + + + + Dislike + +
+
+
+
+ children)) { + foreach ($model->children as $index => $child) { + ?> +
+
+
+ +
+
+ created_at); + ?> +
+
+ customer)) { + echo $child->customer->$nameField; + } else { + echo $child->username . ' (' . Yii::t('artbox-comment', 'Guest') . ')'; + } + ?> +
+
+ text; + ?> +
+
+
+ user->isGuest && $reply && \Yii::$app->user->id != $child->customer_id) { + ?> + + user->isGuest && \Yii::$app->user->id == $child->customer_id && $delete) { + ?> + + + + Dislike + +
+
+
+ +
+ + diff --git a/frontend/views/comment/artbox_comment_list.php b/frontend/views/comment/artbox_comment_list.php new file mode 100755 index 0000000..612d929 --- /dev/null +++ b/frontend/views/comment/artbox_comment_list.php @@ -0,0 +1,56 @@ +session->getFlash('artbox_comment_success') ) != NULL) { + echo Html::tag('p', $success); + } + echo ListView::widget([ + 'dataProvider' => $comments, + 'itemOptions' => $item_options, + 'itemView' => $item_view, + 'emptyText' => false, + 'summary' => '', + 'viewParams' => [ + 'display_name' => $display_name, + 'reply' => $reply, + 'delete' => $delete, + 'more' => $more, + 'last' => $comments->count, + ], + 'beforeItem' => function ($model, $key, $index, $widget) use ($more, $comments) { + if ($more['key'] == $index and $more['show_'] ){ + + return "Показать еще + "; + } +} + + + ]); + Pjax::end(); + \ No newline at end of file diff --git a/frontend/views/comment/artbox_comment_reply.php b/frontend/views/comment/artbox_comment_reply.php new file mode 100755 index 0000000..082a96e --- /dev/null +++ b/frontend/views/comment/artbox_comment_reply.php @@ -0,0 +1,64 @@ + '.field-' . $text_input_id, + 'input' => '#' . $text_input_id, + ]; + $parent_id_input_selectors = [ + 'container' => '.field-' . $parent_id_input_id, + 'input' => '#' . $parent_id_input_id, + ]; + $form = ActiveForm::begin([ + 'id' => $formId . '-reply', + 'action' => Url::to([ + 'artbox-comment/default/create', + 'entity' => $comment_model->encryptedEntity, + ]), + ]); +?> +
+ field( + $comment_model, + 'parent_id', + [ + 'selectors' => $parent_id_input_selectors, + 'inputOptions' => [ + 'id' => $parent_id_input_id, + 'class' => 'form-control', + ], + ]) + ->hiddenInput() + ->label(false); + echo $form->field($comment_model, 'text', [ + 'selectors' => $text_input_selectors, + 'inputOptions' => [ + 'id' => $text_input_id, + 'class' => 'form-control', + 'cols' => 30, + 'rows' => 10, + ], + ]) + ->textarea(); + echo Html::submitButton(Yii::t('artbox-comment', 'Submit')); + echo Html::button(Yii::t('artbox-comment', 'Cancel'), [ 'data-action' => 'reply-cancel' ]); + ?> +
+ \ No newline at end of file -- libgit2 0.21.4