_question_comment_view.php 4.02 KB
<?php
    use common\models\User;
    use common\modules\comment\widgets\CommentWidget;
    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;
    if(empty( $model->comment_pid )) {
        $model->buildButtons([
            'reply',
            'delete',
        ]);
    }
?>
    <div class="<?= ( ( !empty( $model->child ) ) ? 'has-child' : '' ) ?>">
        <div class="header-cabinet-foto" style="background: none;"><?= Html::img(( !empty( $model->user ) && !empty( $model->user->userInfo->image ) ) ? $model->user->minImg($model->user->userInfo->image, 48, 48) : '/images/ico-profile.png') ?></div>
        <div style="width: 500px; float: left; margin-left: 12px;">
            <div class="comments-name style <?= CommentWidget::$baseClass[ 'comment_author' ] ?>">
                <a href="/"><?= $model->getAuthor(' (Гость)') ?></a>

            </div>

            <?php
                /* == STATUS PRO ==
                ?>
                <div class="comments-status"><span>Pro</span></div>
                <?php
                */
            ?>
            <div class="blog-post-date style">
                <span></span>
                <p><?= \Yii::$app->formatter->asDate($model->date_add, 'php:d.m.Y') ?></p>
            </div>
            <!--            <div class="comments-date style">--><? //= \Yii::$app->formatter->asDate($model->date_add, 'php:d.m.Y') ?><!--</div>-->
        </div>
        <div class="comments-content">
            <div class="style" style="font-weight: 700;">Вопрос</div>
            <div class="style" style="margin-top: 2px"><?= $model->text ?></div>
        </div>
        <?php
            if(!empty( $model->child )) {
                echo Html::tag('div', $this->render('@common/modules/comment/widgets/views/_question_comment_view', [
                    'model'  => $model->child,
                    'key'    => $key,
                    'index'  => $index,
                    'widget' => $widget,
                ]), [
                    'class' => CommentWidget::$baseClass[ 'comment_container' ],
                    'data'  => [
                        'key'  => $model->child->comment_id,
                        'form' => $model->formName(),
                    ],
                ]);
            }
        ?>
        <?php
            if(array_filter($model->buttons)) {
                ?>
                <div class="buutons_comm style" style="margin-top: 15px">
                    <?php
                        if(!empty( $model->buttons[ 'delete' ] )) {
                            echo Html::a(( $model->user_id != NULL && $model->user_id == \Yii::$app->user->id ) ? 'Удалить' : 'Пожаловаться   ', $model->buttons[ 'delete' ], [ 'class' => 'artbox_comment_delete_answer' ]);
                        }
                        if(!empty( $model->buttons[ 'update' ] )) {
                            echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => 'artbox_comment_update_answer' ]);
                        }
                        if(!empty( $model->buttons[ 'reply' ] )) {
                            echo Html::a('Ответить', $model->buttons[ 'reply' ], [ 'class' => CommentWidget::$baseClass[ 'comment_reply' ] . ' artbox_comment_reply_answer' ]);
                        }
                    ?>
                </div>
                <?php
            }
        ?>
    </div>
<?php
    /* == PROJECT INFO ==
    ?>
    <div class="comments-project-link">Проект: <a href="#">Ремонт спальни</a></div>
    <?php
    */
?>