Subversion Repositories Applications.framework

Rev

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

<?php
/**
 * Fichier contenant la fonction __autoload
 * 
 * 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
 * 
 * @category  Fichier_De_Fonctions
 * @package   Framework
 * @author    aurelien <aurelien@tela-botanica.org>
 * @copyright 2009 Tela-Botanica
 * @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL  
 * @version   SVN: <svn_id> 
 * @link      /doc/framework/ 
 */

// 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);  
}

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');

function autoloadAppliDefaut($nom_classe) {
        $dossiers_classes = array(      Config::get('dossier_controleurs'),
                                                                Config::get('dossier_modeles'),
                                                                Config::get('dossier_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');

if (function_exists('__autoload')) {
        spl_autoload_register('__autoload');
}

?>