 <?php 
  $curso = $this->obj;
  
  $url = BASE_URL.'cursos/ver/'.$curso->id.'-'.Pampa_Util_String::url($curso->shortname);
  $urlInscricao = BASE_URL.'cursos/inscricao/'.$curso->id.'-'.Pampa_Util_String::url($curso->shortname);
  
  $dataInicio = $curso->startdate;// strtotime(date('d/m/Y',$curso->startdate));
  $dataHj = strtotime(date("Y-m-d"));
                            
 ?>
  <div id="conteudo">

            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-10">
                        
                        <article class="noticia detalhe">

                            <div class="row navegacao hidden-xs">
                                <div class="col-sm-12">
                                    <a class="btn btn-grey inverse" href="javascript:history.back();" role="button"><img style="top: -1px; position: relative;" src="assets/images/seta-left.svg" alt="">&nbsp;VOLTAR</a>
                                </div>
                            </div>
                            
                            <div class="row alinhamento-vertical">

                                <div class="col-sm-6">
                                    <header>
                                        <span class="pagina"><a href="<?=BASE_URL?>cursos">Cursos Ofertados</a></span>
                                        <h3><?=$curso->fullname?></h3>
                                    </header>

                                        <?php 
                                        if($curso->ativo == 'S'){
                                        if($dataInicio>=$dataHj){
                                            ?>
                                    <div class="acoes">
                                       <?php 
                                        $inscrito = false;
                                        $preinscrito = false;
                                        foreach ($this->inscritos as $inscricoes) {
                                            if($inscricoes->id == $curso->id){
                                                $inscrito = true;
                                                break;
                                            }
                                        }
                                        if(!$inscrito){
                                        foreach ($this->preinscritos as $preinsc) {
                                            if( $curso->id == $preinsc->curso_id){
                                                $preinscrito = true;
                                            }
                                            
                                        }
                                        }
                                        if($inscrito||$preinscrito ){
                                            ?>
                                            <!-- <a class="btn btn-grey inverse" href="<?=BASE_URL.'cursos/formulario/id/'.$curso->id?>" role="button">Inscrito</a> -->
                                            <a class="btn btn-grey inverse" href="javascript:;" role="button"><?=($preinscrito ? 'Aguardando homologação' : 'Inscrito')?></a>
                                            <?php
                                        }else{
                                        ?>
                                        <a class="btn btn-orange btn-inscricao" href="<?=$urlInscricao?>" role="button">Inscreva-se</a>
                                        <?php    
                                        }
                                       ?>
                                        
                                    </div>
                                            <?php 
                                        }
                                        }
                                        ?>

                                    <div class="meta">
                                        <p>COMPARTILHAR:</p>

                                        <ul class="social bw">
                                            <li class="facebook">
                                                    <a target="_blank" href="https://www.facebook.com/dialog/share?app_id=212441672592866&display=popup&href=<?=$url?>&redirect_uri=<?=$url?>"><img src="assets/images/icone-facebook.svg" alt=""></a>
                                                </li>

                                                <li class="linkedin">
                                                    <a  target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?=$url?>
&summary=<?=$curso->shortname?>&source=LinkedIn"><img src="assets/images/icone-linkedin.svg" alt=""></a>
                                                </li>

                                                <li class="twitter">
                                                    <a  target="_blank" href="https://twitter.com/share?url=<?=$url?>&via=ceped&related=ceped&hashtags=ceped&text=<?=$curso->shortname?>"><img src="assets/images/icone-twitter.svg" alt=""></a>
                                                </li>
                                        </ul>
                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="thumb">
                                        <img src="<?=BASE_URL.'uploads/cursos/'.$curso->imagem?>" class="img-responsive" alt="Miniatura da noticia">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="texto">
                                        <br>
                                       <?php
                                       $txt = $curso->summary;
                                       $img = "<img>";
                                       $img = "";
                                       if(strpos($txt,"@@PLUGINFILE@@")) {
                                        $context = $curso->getContext();
                                        if(!empty($context)){
                                            $txt =  str_replace("@@PLUGINFILE@@",MOODLE_URL."pluginfile.php/".$context->id."/course/summary/",$txt);
                                            
                                        }else{
                                            $img = "";
                                        }
                                       }
                                        $txt = strip_tags($txt,'<a>'.$img.'<p><ul><li><ol>');
                                        echo $txt;
                                       ?>
                                    </div>
                                </div>
                            </div>

                        </article>

                    </div>
                </div>
            </div>

        </div>