_review_comment_view.php 2.32 KB
<?php
    use common\models\User;
    use common\modules\comment\widgets\CommentWidget;
    use kartik\rating\StarRating;
    use yii\helpers\Html;
    use yii\web\View;

    /**
     * @var View                                   $this
     * @var \common\modules\comment\models\Comment $model  Current comment model
     * @var integer                                $key    ID of current comment
     * @var integer                                $index  index of current element according
     *      to current page, starting from 0
     * @var \yii\widgets\ListView                  $widget current ListView instance
     * @var User                                   $user
     */
    $user = $model->user;
    $model->buildButtons(['delete']);
?>
    <div class="comments-name <?= CommentWidget::$baseClass[ 'comment_author' ] ?>">
        <?= $model->getAuthor(' (Гость)') ?>
    </div>
<?php
    /* == STATUS PRO ==
    ?>
    <div class="comments-status"><span>Pro</span></div>
    <?php
    */
?>
    <div class="comments-date"><?= \Yii::$app->formatter->asDate($model->date_add, 'php:d.m.Y') ?></div>
<?php
    if(!empty( $model->rating )) {
        echo StarRating::widget([
            'name' => 'rating_review_comment',
            'value' => $model->rating->value,
            'pluginOptions' => ['displayOnly' => true]
        ]);
    }
?>
    <div class="comments-content">
        <?= $model->text ?>
    </div>
    <div>
        <?php
            if(!empty( $model->buttons[ 'delete' ] )) {
                echo Html::a(($model->user_id != NULL && $model->user_id == \Yii::$app->user->id)?'Удалить':'Пожаловаться   ', $model->buttons[ 'delete' ], [ 'class' => CommentWidget::$baseClass[ 'comment_delete' ] ]);
            }
            if(!empty( $model->buttons[ 'update' ] )) {
                echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => CommentWidget::$baseClass[ 'comment_update' ] ]);
            }
            if(!empty( $model->buttons[ 'reply' ] )) {
                echo Html::a('Ответить', $model->buttons[ 'reply' ], [ 'class' => CommentWidget::$baseClass[ 'comment_reply' ] ]);
            }
        ?>
    </div>
<?php
    /* == PROJECT INFO ==
    ?>
    <div class="comments-project-link">Проект: <a href="#">Ремонт спальни</a></div>
    <?php
    */
?>