Subversion Repositories eFlore/Applications.del

Rev

Rev 1683 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
// Encodage : UTF-8
// +-------------------------------------------------------------------------------------------------------------------+
/**
* Initialise le chargement et l'exécution des scripts
*
* Lancer ce fichier en ligne de commande avec :
* <code>/opt/lampp/bin/php cli.php mon_script -a test</code>
*
//Auteur original :
* @author       Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author       Delphine CAUQUIL <delphine@tela-botanica.org>
* @copyright    Tela-Botanica 1999-2008
* @licence      GPL v3 & CeCILL v2
* @version      $Id$
*/
// +-------------------------------------------------------------------------------------------------------------------+



// Autoloader pour les namespaces, à base de routes
function __autoload($nom_classe) {
        //echo "AUTOLOAD\n";
        $dernierAS = strrpos($nom_classe, "\\");
        $ns = substr($nom_classe, 0, $dernierAS);
        $nom = substr($nom_classe, strrpos($nom_classe, "\\") + 1);
        //echo "Recherche : $nom / $ns\n";
        // Routes selon les namespaces
        $routes = array(
                'TelaBotanica\Del\Commun' => Config::get('cheminDelCommun')
        );
        if (array_key_exists($ns, $routes)) {
                //echo "Route trouvée: " . $routes[$ns] . "\n";
                $fichier_a_inclure = dirname(__FILE__) . DS . $routes[$ns] . DS . $nom . '.php';
                if (file_exists($fichier_a_inclure)) {
                        include_once $fichier_a_inclure;
                        return null;
                }
        }
}

// Le fichier Framework.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
// Sinon, rien ne sera chargé.
// Chemin du fichier chargeant le framework requis
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
if (!file_exists($framework)) {
        $e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
        trigger_error($e, E_USER_ERROR);
} else {
        // Inclusion du Framework
        require_once $framework;

        // Ajout d'information concernant cette application
        Framework::setCheminAppli(__FILE__);// Obligatoire
        Framework::setInfoAppli(Config::get('info'));

        // Initialisation et lancement du script appelé en ligne de commande
        Cli::executer();
}
?>