<?php
$pages=glob(CONTENTS."pages/*.yaml");

// charger les pages dans un array avec leur "order" comme clé
$np=array();
foreach($pages as $page_url){
    $page=new yamlReadwriter();
    $page->loadYaml($page_url);
    $num=intval( $page->get('order'));

    while(isset($np[$num])){
        $num++;
    }

    $np[$num]=array(
        "url"=>$page_url,
        "obj"=>$page
    );
}

ksort($np, SORT_NUMERIC);

foreach($np as $p=>$pc){
    if(trim($pc['obj']->get('lien'))){
        echo "<a href='".$pc['obj']->get('lien')."' class='decoration-hover' target='_blank'>".$pc['obj']->get('titre')."</a>";
        if(isadmin()){
            echo "<div class=\"v-icon edit\" onclick=\"yc_editPage('".basename($pc['url'])."')\"><img src=\"app/images/pencil-fill.svg\"></div>";
        }
    } else {
        echo "<div class='' onclick=\"yc_showPage('".basename($pc['url'])."')\">";
        echo $pc['obj']->get('titre');
        echo "</div>";  
    }

}
foreach(MODULES['insert_pages'] as $insert){
    include(CHEMIN.$insert);
}
?>