project_comment_view.php 4.16 KB
<?php
    use common\models\User;
    use common\modules\comment\widgets\CommentWidget;
    use kartik\rating\StarRating;
    use yii\helpers\Html;

    /**
     * @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 = NULL;
    if(!empty( $model->user_id )) {
        $user = User::find()
                    ->where([ 'id' => $model->user_id ])
                    ->with('userInfo')
                    ->one();
    }
    $model->buildButtons(['delete']);
?>
<div class="new-portf-comm-read artbox_comment_container" data-key="<?= $model->comment_id ?>" data-form="<?= $model->formName() ?>">
    <div class="style">
        <div class="header-cabinet-foto">
            <?php
                if(!empty( $user ) && !empty( $user->userInfo->image )) {
                    echo "<img src='{$user->userInfo->image}' alt=''>";
                } else {
                    echo "<img src='/images/ico-profile.png' alt=''>";
                }
            ?>
        </div>
        <div style="width: 500px; float: left; margin-left: 12px;">
            <div class="comments-name style artbox_comment_author">
                <?php
                    if(!empty( $user )) {
                        echo Html::a('<span class="artbox_comment_author">' . $user->firstname . ' ' . $user->lastname . '</span>', [
                            'performer/common',
                            'performer_id' => $user->id,
                        ]);
                    } else {
                        echo '<span class="artbox_comment_author">' . $model->user_name . '</span>' . '(Гость)';
                    }
                ?>
            </div>
            <div class="new-portf-comm-read-rating">
                <?php
                    if($rating = $model->hasRating()) {
                        echo StarRating::widget([
                            'name' => 'rating_project_comment',
                            'value' => $rating->value,
                            'pluginOptions' => ['displayOnly' => true, 'size' => 'xxs']
                        ]);
                    }
                ?>
            </div>
            <div class="blog-post-date style">
                <span></span>
                <p><?= date('d.m.Y', strtotime($model->date_add)) ?></p>
            </div>
        </div>

        <div class="new-portf-answer artbox_comment_text">
            <?= Html::encode($model->text) ?>
        </div>
        <div style="clear:both"></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
            /*
            ?>
            <div class="action_panel">
                <ul>
                    <li style="display:inline-block" class="artbox_comment_reply">Ответить</li>
                    <li style="display:inline-block" class="artbox_comment_update">Редактировать</li>
                    <li style="display:inline-block" class="artbox_comment_delete">Удалить</li>
                </ul>
            </div>
            <?php
            */
        ?>
    </div>
    <div class="style"></div>
</div>