<?php 
include("includes/inc-config.php");
include(CHEMIN."includes/inc-fonctions.php");
include("includes/inc-header.php");
include(CHEMIN."includes/Spyc.php");
include(CHEMIN."includes/yaml-readwriteclass.php");
?>

<main id="main" class="container-fluid px-4">
    <!-- colonne des zines -->
    <div class="row my-4">
        <div class="col-12 col-sm-6 col-lg-8 mb-4 mb-sm-0">

            <div class="texte-small">
                <?php
                $liste=array_reverse(glob(DOSSIER_ZINES."/*",GLOB_ONLYDIR));
                foreach($liste as $element){
                    $zine=new yamlreadwrite();
                    $zine->yamlread($element."/config_zine.yaml");

                    $infos=$zine->yaml_simple_array();
                    echo "<div class='mb-3 translucide zine-cartouche-principale'>";
                    echo "<div class='row'>";
                    echo "<div class='col-12 col-md-6 col-lg-4 mb-3 mb-md-0'>";
                    
                    deployer_diaporama($element);

                    echo "</div>";
                    echo "<div class='col-12 col-md-6 col-lg-8'>";
                    echo "<div class=\"d-flex h-100 flex-column justify-content-between\"><div>";
                    echo "<h3>".$infos['titre_zine']."</h3>";
                    
                    echo "<div class=\"mb-3\">".$infos["descriptif_zine"]."</div>";

                    //echo "<div class='texte-tiny'><span class='texte-fat'>Publié par :</span> ".$infos["editeur_zine"].", le ".$infos["date_creation"]."</div>";
                   
                    echo "</div><div>";
                    
                    $pdfs=trouve_pdf($element);
                    if(isset($pdfs['single_page'])){
                        echo "\n<div class=''><a href='".$pdfs['single_page']."' target='_blank' class='btn btn-sm btn-primary'>Télécharger le PDF simple</a></div>";
                    }
                    if(isset($pdfs['impose'])){
                        echo "\n<div class='mt-2'><a href='".$pdfs['impose']."' target='_blank' class='btn btn-sm btn-primary'>Télécharger le PDF imposé</a></div>";
                    }
                    echo "</div>";
                    echo "</div>";
                    echo "</div>";
                    echo "</div>";
                    echo "</div>";
                }

                if(!count($liste)){
                    echo "<div class='mb-5'><h3>No zine!</h3>Encore rien de publié pour le moment!<br>Il faudra attendre un peu!</div>";
                }
                ?>
            </div>
        </div>

        <div class="col-12 col-sm-6 col-lg-4">
            <div class="bg-primary text-light rounded p-5 mb-5 zine-cartouche-color">
                <?php 
                echo $GLOBALS['descriptif_site'];
                ?>
            </div>
            <?php 
            // afficher les appels à participation
            $liste=glob(DOSSIER_COURANT."/*",GLOB_ONLYDIR);
            foreach($liste as $element){
                $zine=new yamlreadwrite();
                $zine->yamlread($element."/config_zine.yaml");

                $infos=$zine->yaml_simple_array();
                echo "<div class='mb-3 border border-primary translucide rounded p-3 zine-cartouche-appel'>";
                echo "<span class='badge bg-primary'>Appel à participation</span>";
                echo "<h2 class='text-big mt-2 mb-1'>".$infos['titre_zine']."</h2>";
                echo "<div class='mb-3'>".$infos["descriptif_zine"]."</div>";
                echo "<div class='mb-3 texte-small'>".$infos["consignes_zine"]."</div>";
                
                $li=images_zine_to_array($element);
                echo "Nombre de participations: ".count($li);

                echo "<div><a class='btn btn-sm btn-primary text-light mt-3' href='participer.php?zine=".basename($element)."'>Je participe</a></div>";
                echo "</div>";
            }
            ?>
        </div>

    </div>
</main>

<?php 
include("includes/inc-footer.php");