Subversion Repositories Applications.framework

Rev

Rev 98 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

<?php
// declare(encoding='UTF-8');
/**
 * Fichier contenant la fonction de chargement automatique de classes, il doit toujours rester à la racine
 * du framework car il initialise le chemin de l'application en se basant sur son propre emplacement.
 * 
 * PHP Version 5.1.2
 * 
 * @category  Fichier_De_Fonctions
 * @package   Framework
 // Auteur principal : 
 * @author Aurelien PERONNET <aurelien@tela-botanica.org>
 // Autres auteurs :
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org> 
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
 * @version $$Id$$
 * @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
 */

// Redéfinition de la constante DIRECTORY_SEPARATOR
if (!defined('DS')) { 
        define('DS', DIRECTORY_SEPARATOR);  
}
// Redéfinition de la constante PATH_SEPARATOR
if (!defined('PS')) { 
        define('PS', PATH_SEPARATOR);  
}

// Autoload pour le Framework
function autoloadFw($nom_classe_fw) {
        $fichier_a_inclure = dirname(__FILE__).DS.$nom_classe_fw.'.php';
        if (file_exists($fichier_a_inclure)) {
                include_once $fichier_a_inclure;
                return null;
        }
}
spl_autoload_register('autoloadFw');

// Autoload par défaut pour l'application
function autoloadAppliDefaut($nom_classe) {
        $dossiers_classes = array(      Config::get('chemin_controleurs'),
                                                                Config::get('chemin_modeles'),
                                                                Config::get('chemin_bibliotheque'));
        
        foreach ($dossiers_classes as $chemin) {
                $fichier_a_tester = $chemin.$nom_classe.'.php';
                if (file_exists($fichier_a_tester)) {
                        include_once $fichier_a_tester;
                        return null;
                }
        }
}
spl_autoload_register('autoloadAppliDefaut');

// Autoload défini par l'application
if (function_exists('__autoload')) {
        spl_autoload_register('__autoload');
}
?>