<?php
/* 
 * Fonctions interface d'administration
 * RR : 26/10/2011
 */

function headerPage($title) {
    return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                        <title>'.$title.'</title>
                        <link rel="stylesheet" type="text/css" href="css/styles.css" />
                        <link rel="shortcut icon" type="image/x-icon" href="css/images/favicon.ico" />
                        <script type="text/javascript" src="yui/build/yahoo/yahoo-min.js"></script>
                        <script type="text/javascript" src="yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
                        <script type="text/javascript" src="yui/build/element/element-min.js"></script>
                        <script type="text/javascript" src="yui/build/event/event-min.js"></script>
                        <script type="text/javascript" src="yui/build/dragdrop/dragdrop-min.js"></script>
                        <script type="text/javascript" src="yui/build/treeview/treeview-min.js"></script>
                        <script type="text/javascript" src="yui/build/connection/connection-min.js"></script>
                        <script type="text/javascript" src="yui/build/tabview/tabview-min.js"></script>
                        <script type="text/javascript" src="yui/build/container/container-min.js"></script>
                        <script type="text/javascript" src="yui/build/animation/animation-min.js"></script>
                        <script type="text/javascript" src="yui/build/utilities/utilities.js"></script>
                        <script type="text/javascript" src="yui/build/datasource/datasource-min.js"></script>
                        <script type="text/javascript" src="js/admin.js"></script>
                    </head>
                    <body>
                        <h1>'.$title.'</h1>';
}

function footerPage() {
    return '<div id="helpBalloon"></div>
            <div>
                <p><a href="javascript:window.history.back();">&larr; Retour</a></p>
                <p><a style="float:left" href="index.html">&uarr; Accueil</a></p>
            </div>
            </body>
            </html>';
}

function readHelp($message) {
    global $helpArray;
    if (empty($helpArray)) $helpArray = parse_ini_file('help.ini');
    return 'onmousemove="admin.helpBalloon(event, \''.addslashes($helpArray[$message]).'\');" onmouseout="javascript:document.getElementById(\'helpBalloon\').style.display=\'none\';"';
}

function connect($url) {
    $url = parse_url($url);
    $url['user'] = urldecode($url['user']);
    $url['pass'] = (isset($url['pass']))  ? urldecode($url['pass']) : '';
    $url['host'] = urldecode($url['host']);
    $url['path'] = urldecode($url['path']);
    if (isset($url['port'])) {
        $mysqli = new mysqli($url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port']);
    } else {
        $mysqli = new mysqli($url['host'], $url['user'], $url['pass'], substr($url['path'], 1));
    }
    if ($mysqli->connect_error=='') {
        $mysqli->query('SET NAMES "utf8"');
        return $mysqli;           
    }
}
?>
