<?php
    
    use artbox\core\helpers\ImageHelper;
    use common\models\blog\Article;
    use common\models\blog\Tag;
    use artbox\core\helpers\Url;
    use yii\web\View;
    
    /**
     * @var View    $this
     * @var Article $model
     * @var Tag[]   $tags
     * @var \artbox\core\forms\Module $moduleComment
     * @var $jsMicrodata ==> JsonLD article microdata
     */

    $this->params[ 'breadcrumbs' ][] = [
        'label' => \Yii::t('app', 'Blog'),
        'url'   => [ 'blog/index' ],
    ];

    $this->params[ 'breadcrumbs' ][] = $model->title;
    
    $moduleComment = \Yii::$app->getModule('comments');
    $moduleComment->inputOptions = array_merge($moduleComment->inputOptions, ['entity_id' => [
        'type'    => 'hiddenInput',
        'options' => ['value' => $model->id],
    ],
                                                                              'entity' => [
                                                                                  'type'    => 'hiddenInput',
                                                                                  'options' => ['value' => Article::className()],
                                                                              ]]);
    
    
    $moduleComment->buttonTemplate = '<div class="button-wr submit-close-wr-c-a">{button}</div>';
    
    $moduleComment->successCallback = 'function (data) {
                 document.getElementById("comment-form").reset();
                              var data = $("#comment-form").data(\'yiiActiveForm\');
                              $("#comment-form").find(".submit-close-c-a span").click();
                              $("#comment-form").find(".field-comment-comment").parent().after("<p>Ваш отзыв появиться после проверки модератором</p>")
                              data.validated = false;
                    }'
?>


<?= $jsMicrodata; ?>
<section class="section-service-page section-package-page">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12">
                <div class="row">
                    <div class="col-xs-12">
                        <h1 class="title-pages"><?=$model->title?></h1>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 service-text-table-wrapp editor-text">
                        <?php
                        $alt=(isset($model->image->lang->attributes['alt']))?$model->image->lang->attributes['alt']:'';
                        $title=(isset($model->image->lang->attributes['title']))?$model->image->lang->attributes['title']:'';
                        ?>
                        <!---555X370-->
                        <?=ImageHelper::set(($model->image) ? $model->image->getPath() : null)
                                      ->cropResize(555, 370)
                                      ->quality(84)
                                      ->renderImage(['alt'=>$alt,'title'=>$title, 'class' => 'blog-view-img'])?>
                        <div   class="blog-view-date-all">
                            <span class="blog-view-date"><?=date('d.m.Y', $model->created_at)?></span>
                            <span class="blog-view-comments-ico"><?=count($model->comments)?></span>
                            <span class="blog-view-views-ico"><?=$model->views?></span>
                        </div>
                        <?=$model->body?>
                      <?php if (!empty($model->tags)){?>
                        <div class="style tags-view-blog">
                            <div class="blog-list-tags">
                              <?php foreach ($model->tags as $tag){?>
                                <a href="<?=Url::to(['alias' => $tag->language->alias])?>"><?=$tag->title?></a>
                              <?php } ?>
                            </div>
                        </div>
                      <?php }?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<section class="section-comments-blog">
    <div class="container">
        <div class="row">
          
            <div class="col-xs-12 col-sm-6">
                
                <div class="title-c-a"><?=\Yii::t('app','Callbacks');?></div>
                <?php if(!empty($model->comments)){?>
                <div class="service-comments-wr style">
                  <?php foreach ($model->comments as $comment){?>
                    <div class="service-comments style">
                        <div class="style comments-h-autor"><?=$comment->name?></div>
                        <div class="style comments-h-text"><?=$comment->comment?></div>
                        <div class="style comments-h-date"><?=date('d.m.Y', $comment->created_at)?></div>
                    </div>
                   <?php } ?>
                </div>

<!--                <div class="style service-links-c-a"><a href="#">Все отзывы</a></div>-->
                <?php } ?>
            </div>
          
            <div class="col-xs-12 col-sm-6">
                <div class="style blog-view-comments-form">
                    <div class="style hidden-form-c-a">
                        <div class="title-forms-c-a style"><?=\Yii::t('app','Give feedback');?></div>
                        <?=$moduleComment->renderForm($this)?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<!--<section class="section-blog-view-min-bl">-->
<!--    <div class="container">-->
<!--        <div class="row">-->
<!--            <div class="col-xs-12">-->
<!--                <div class="style title-view-mins-bl">--><?//=\Yii::t('app','More by theme');?><!--</div>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="row">-->
<!--            <div class="col-xs-12 col-sm-4 col-md-4 blog-list-col">-->
<!--                <div class="blog-list-wr">-->
<!--                    <div class="img-blog-list">-->
<!--                        <a href="#">-->
<!--                            <!--360x240-->-->
<!--                            <img src="/images/blog/blog-img-1.jpg" alt="">-->
<!--                        </a>-->
<!--                    </div>-->
<!--                    <div class="blog-all-date-views">-->
<!--                        <div class="blog-date">20.05.2018</div>-->
<!--                        <div class="blog-views-comments-ico">-->
<!--                            <div class="blog-comments-ico">246</div>-->
<!--                            <div class="blog-views-ico">317</div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="blog-list-link"><a href="#">-->
<!--                            <span>Желающие забеременеть женщины должны заниматься спортом не менее 4 часов в неделю – ученые</span></a></div>-->
<!--                    <div class="blog-list-tags">-->
<!--                        <a href="#">гинекология</a>-->
<!--                        <a href="#">роды</a>-->
<!--                        <a href="#">беременность</a>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="col-xs-12 col-sm-4 col-md-4 blog-list-col">-->
<!--                <div class="blog-list-wr">-->
<!--                    <div class="img-blog-list">-->
<!--                        <a href="#">-->
<!--                            <img src="/images/blog/blog-img-2.jpg" alt="">-->
<!--                        </a>-->
<!--                    </div>-->
<!--                    <div class="blog-all-date-views">-->
<!--                        <div class="blog-date">20.05.2018</div>-->
<!--                        <div class="blog-views-comments-ico">-->
<!--                            <div class="blog-comments-ico">246</div>-->
<!--                            <div class="blog-views-ico">317</div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="blog-list-link"><a href="#"><span>Ученые установили связь между насморком и женским оргазмом</span></a></div>-->
<!--                    <div class="blog-list-tags">-->
<!--                        <a href="#">гинекология</a>-->
<!--                        <a href="#">роды</a>-->
<!--                        <a href="#">беременность</a>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="col-xs-12 col-sm-4 col-md-4 blog-list-col">-->
<!--                <div class="blog-list-wr">-->
<!--                    <div class="img-blog-list">-->
<!--                        <a href="#">-->
<!--                            <img src="/images/blog/blog-img-3.jpg" alt="">-->
<!--                        </a>-->
<!--                    </div>-->
<!--                    <div class="blog-all-date-views">-->
<!--                        <div class="blog-date">20.05.2018</div>-->
<!--                        <div class="blog-views-comments-ico">-->
<!--                            <div class="blog-comments-ico">246</div>-->
<!--                            <div class="blog-views-ico">317</div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="blog-list-link"><a href="#"><span>В грудном молоке содержится ещё один секрет</span></a></div>-->
<!--                    <div class="blog-list-tags">-->
<!--                        <a href="#">гинекология</a>-->
<!--                        <a href="#">роды</a>-->
<!--                        <a href="#">беременность</a>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<!--</section>-->