<?php
if (!empty($seo->getData()['seoData'])):
    extract($seo->getData());
    $cover_capa = image($post_cover, 800);
    $video = '';
    if ($post_emcorpora):
        $Link_video1 = explode('src="', html_entity_decode($post_emcorpora));
        $Link_video2 = explode('"', $Link_video1[1]);
        $post_emcorpora = $Link_video2[0];
    endif;

    $video = str_replace(['https://', 'http://'], ['//', '//'], ($post_emcorpora ? $post_emcorpora : $post_video));
    $youtube = (strripos($video, "youtube") !== false || strripos($video, "youtu.be") !== false ? true : false);
    $url = explode("=", $video);
    if (count($url) < 2) {
        $url = array_reverse(explode("/", $video));
    }


    if ($youtube) {
        $video = "https://www.youtube.com/embed/{$url[0]}";
    }
    ?>

    <div class="py-5 text-center text-white background-cover d-none" style="	background-image: url(<?= $cover_capa ?>);">
        <div class="container-fluid section-head">
            <div class="row">
                <div class="mx-auto p-5 col-md-7">

                </div>
            </div>

        </div>
    </div>
    <div class="bg-light">
        <div class="pt-5 pb-2  text-center">   
            <div class="section-head">  
                <div class="container section-title section-head"> 
                    <h1><?= $post_title ?></h1>        
                </div>
            </div>
        </div>
        <div class="pb-5">
            <div class="container">                
                <div class="row">
                    <div class="mx-auto p-5 col-md-8">
                        <img class="img-fluid mx-auto d-block" src="<?= $cover_capa ?>">
                    </div>
                </div>
                <p class=" text-lead mb-0 text-justify justified" >
    <?= $post_content ?>
                </p>
                    <?php if ($post_video || $post_emcorpora): ?>
                    <div class="article-main-img py-3">       
                        <iframe id="player" src="<?= $video ?>" style="width:100%; position: relative; min-height: 380px; height:660px; display:inline-block " title="<?= $post_title ?>" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                    </div>
    <?php endif; ?>
                <h4>Compartilhe:</h4>

    <?php require_once ('plugins/shared/socialshared.php'); ?>
            </div>
        </div>
    </div>

    <div class="text-center bg-light py-3" id="noticias">
        <div class="container section-head section-title">
            <h2 class='section-heading'>OUTRAS PUBLICAÇÕES</h2>
        </div>
    </div>
    <div class="py-3 bg-light">
        <div class="container">
            <div class="row">          
    <?php
    $Read->ExeRead(DB_POST, "WHERE POST_TYPE!='post' AND POST_STATUS=1 AND POST_ID!='$post_id' ORDER BY POST_DATE DESC LIMIT 4");
    if ($Read->getResult()):
        foreach ($Read->getResult() as $mais):
            extract($mais);
            $cover_capa = image($post_cover, 400);
//                        $categoria = systen::ReadFlash(DB_CATEGORY, "WHERE category_id='{$post_category}'", 'category_title');
            ?>

                        <div class="col-md-3 col-sm-12 col-lg-3  wow animated zoomInDown card-noticia"> <a href="<?= SITE . "blog/" . $post_name ?>"><img class="img-fluid d-block" src="<?= $cover_capa ?>"></a>
                            <h2 class="text-title"> <a  href="<?= SITE . "blog/" . $post_name ?>"><?= $post_title ?></a></h2>
                            <p class="text-muted"><?= date_fmt($post_date) ?></p>
                            <p class="text-body text-dark text-justify"><?= str_limit_words($post_content, 25, '') ?></p>
                            <a class="leia_mais" href="<?= SITE . "blog/" . $post_name ?>">Leia Mais</a>
                        </div>   
            <?php
        endforeach;
    endif;
    ?>  
            </div>
        </div>
    </div>
    <script src="<?= SITE ?>plugins/shared/sharebox.js" type="text/javascript"></script>
    <link href="<?= SITE ?>plugins/shared/style.css" rel="stylesheet" type="text/css"/>
    <?php
else:
    ?>
    <div class="py-5 text-center text-white background-cover d-none" style="	background-image:'';">
        <div class="container-fluid section-head">
            <div class="row">
                <div class="mx-auto p-5 col-md-7">

                </div>
            </div>

        </div>
    </div>
    <div class="text-center bg-light py-3 " id="noticias">
        <div class="section-title">
            <h2 class="section-heading"><?= $site['page_title'] ?></h2>
        </div>
    </div>
    <div class="py-3 bg-light">
        <div class="container">
            <div class="row">          
    <?php
    $Read->ExeRead(DB_POST, "WHERE POST_TYPE!='post' AND POST_STATUS=1 ORDER BY POST_DATE DESC LIMIT 4");
    if ($Read->getResult()):
        foreach ($Read->getResult() as $mais):
            extract($mais);
            $cover_capa = image($post_cover, 300);
//            $categoria = systen::ReadFlash(DB_CATEGORY, "WHERE category_id='{$post_category}'", 'category_title');
            ?>

                        <div class="col-md-3 col-sm-12 col-lg-3  wow animated zoomInDown card-noticia"> <a href="<?= SITE . "blog/" . $post_name ?>"><img class="img-fluid d-block" src="<?= $cover_capa ?>"></a>
                            <h2 class="text-title"> <a  href="<?= SITE . "blog/" . $post_name ?>"><?= $post_title ?></a></h2>
                            <p class="text-muted"><?= date_fmt($post_date) ?></p>
                            <p class="text-body text-dark text-justify"><?= str_limit_words($post_content, 25, '') ?></p>
                            <a class="leia_mais" href="<?= SITE . "blog/" . $post_name ?>">Leia Mais</a>
                        </div>     
            <?php
        endforeach;
    endif;
    ?>  
            </div>
        </div>
    </div>
<?php
endif;
?>
