<?php
require("../config/config.php");
require(CHEMIN."inc/inc-functions.php");
require(CHEMIN."inc/inc-display-functions.php");
require(CHEMIN."inc/classe_xml.php");

if(isset($_GET['display'])){
    if(isset($_GET['xml'])){
        $xml=new classe_xml(MODELE);
        $item=CHEMIN.DOSSIER_XML.$_GET['xml'];
        $xml->lire_xml($item);

        if($_GET['display']=='item-mosaique'){
            display_mosaique_item($xml);
        }
        if($_GET['display']=='item-lateral'){
            display_lateral_item($xml);
        }
        if($_GET['display']=='item-fullpage'){
            display_fullpage_item($xml);
        }
        if($_GET['display']=='item-galerie'){
            display_galerie_item($xml);
        }
    }
    if($_GET['display']=='item-page'){  
        $url=CHEMIN.DOSSIER_CUSTOM.$_GET['page'];
        $page=contenu_xml($url);
        display_page($page,$url);
    }
    if($_GET['display']=='collection'){  
        $xml=new classe_xml(MODELE_COLLECTION);
        $item=CHEMIN.DOSSIER_COLLECTION.$_GET['collection'];
        $xml->lire_xml($item);
        display_menu_collection($xml);
    }
}
if(isset($_GET['vider_cache'])){
    if($_GET['vider_cache']=='items'){
        supprimer_cache();
    }
    if($_GET['vider_cache']=='vignettes'){
        supprimer_cache_images();
    } 
}

if(isset($_POST['rotation_image'])){ 
    ini_set('memory_limit', '256M');
    $filename = $_POST['url'];
    $degrees=$_POST['angle'];
    traiter_rotation_image($filename, $degrees);
    echo filectime(CHEMIN.DOSSIER_FICHIERS.$filename);
        //donne_lien( DOSSIER_FICHIERS.$filename,$l_vignette=ILLU_WIDTH,$h_vignette=ILLU_HEIGHT,false);
}

if(isset($_POST['rotate_all'])){
    $liste_items=$_POST['item'];
    $degrees=$_POST['rotate_all'];

    foreach($liste_items as $item){
        $c=read_xml($item,true);
        traiter_rotation_image($GLOBALS['root'].$c['illustration'], $degrees);
    }    
}
?>