<?php
include("../custom/config.php"); // fichier de config
include("../includes/inc-functions.php");

$url=false;
if(isset($_GET['selection'])){
    $url=$_GET['selection'];
} else {
    echo "nothing answered !";
    die();
}

?>
<div id="main-editor-tools" class="clearfix">
    <div class='editor-tools-left'>
     <a id='editor-back' class='tool-button' title='Back' href='#' onclick='dispatch_interface(this)' data-class='selection' data-load='ajax/ajax-load-selections.php' data-clic-action='one' data-cas='form'><i class='fa fa-chevron-left'></i></a><?php
    if(isset($_SESSION['nom'])){
        echo "<a class='tool-button carefull' title='delete' href='javascript:selection_delete(\"".$url."\");'><i class='fa fa-times'></i></a>";

  echo "<a class='tool-button' title='Editer sélection' onclick='dispatch_interface(this);' href='#' data-load='ajax/ajax-add-selection.php?selection=".$url."' data-class='selection' data-clic-action='multi' data-cas='form'><i class='fa fa-pencil'></i></a>";

    }
    ?>
    </div>
    <div class='editor-tools-right'><a class='tool-button small-carefull' title='delete' href='javascript:cache_colonne_display();'>Cancel <i class='fa fa-chevron-right fa-fw'></i></a>
    </div>
</div>

<?php
if($url){
    $selection = read_xml($url);
    $n=count($selection['item']);
    echo "<article id='selection'>";
    echo "<h2>"._c($selection,'title')."</h2>\n";
    echo "<div class='texte mini'>".$n." items</div>\n";
    echo "<div class='texte mini'>"._c($selection,'auteur')."</div>\n";
    echo "<div class='texte'>"._c($selection,'note')."</div>\n";
    echo "</article>";
    //print_r($selection);
} 
?>
<script>
 $(document).ready(function(){
        switche_affichage_main("selection-display");
        $.ajax({
            url: "includes/inc-load-selection.php?selection=<?php echo $url; ?>",
            cache: false
        }).done(function( html ) {
            $(".waiter").fadeOut("fast");
            $( "#selection-list" ).empty().append( html );
            search_selection_init();
        });

    });
</script>

<script>
    var t=$("#selection h2").html();
    $("#display-statut").append("<span id='display-statut-selection'><a href='#' onclick='dispatch_interface(this)' data-load='ajax/ajax-load-selection.php?selection=<?php echo $url; ?>' data-clic-action='one' data-cas='form' data-class='selection' class='tool-button'>Sélection  &#34;"+t+"&#34;</a><a href='javascript:remove_selection();' class='tool-button'><i class='fa fa-times small-carefull'></i></a></span>");
</script>