<?php

$pages = Array(
    'index' => Array(
        'key' => 'index',
        'name' => 'Accueil',
        'desc' => 'Retour à l\'accueil du site'
    ),
    'solutions' => Array(
        'key' => 'solutions',
        'name' => 'Solutions',
        'desc' => 'Solutions proposées',
    ),
    'cgu' => Array(
        'key' => 'cgu',
        'name' => 'C.G.U.',
        'desc' => 'Conditions Générales d\'Utilisation',
    ),
    'cgv' => Array(
        'key' => 'cgv',
        'name' => 'C.G.V.',
        'desc' => 'Conditions Générales de Vente',
    ),
    'interventions' => Array(
        'key' => 'interventions',
        'name' => 'Interventions',
        'desc' => 'Interventions passées et à venir',
    ),
    'faq' => Array(
        'key' => 'faq',
        'name' => 'F.A.Q.',
        'desc' => 'Foire Aux Questions',
    ),
    'aide' => Array(
        'key' => 'aide',
        'name' => 'Aide',
        'desc' => 'Obtenir de l\'aide',
    ),
    'contact' => Array(
        'key' => 'contact',
        'name' => 'Contact',
        'desc' => 'Page de Contact',
    ),
    'mentions' => Array(
        'key' => 'mentionslegales',
        'name' => 'Mentions Légales',
        'desc' => 'Consulter les mentions légales du site',
    ),
    'transparence' => Array(
        'key' => 'transparence',
        'name' => 'Transparence',
        'desc' => 'Découvrir mon activité en détails',
    )
);

$mainMenu = [
    $pages['index'],
    $pages['transparence'],
    $pages['solutions'],
    $pages['interventions']
];

$currentPage = $pages['index'];

function pageLink(Array $p, Array $override=[]) {
    global $currentPage;

    if (!empty($override)) $p = array_replace($p, $override);

    $active = $currentPage==$p? 'active ': '';
    $anchor = isset($p['anchor'])? '#'.$p['anchor']: '';
    $key = $p['key']=='index'? '': $p['key'];
    $url = '/'.$key.$anchor;

    return '<a class="'.$active.'item" href="'.$url.'" target="_self" title="'.$p['desc'].'">'.$p['name'].'</a>';
}
