Rev 2007 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/**** Fichier contenant les fonctions d'initialisation de code igniter* permettant de l'utiliser en combinaison avec Papyrus.**//*** Initialise la configuration de code igniter pour une application* donnée. Normalement, cette fonction ne doit pas être appelée directement* @param string le nom de l'application à initialiser*/function initialiserCodeIgniter($nom_appli) {error_reporting(E_ALL);$system_folder = PAP_CHEMIN_RACINE.'papyrus/bibliotheque/system';$application_folder = GEN_CHEMIN_APPLICATION.$nom_appli;if (strpos($system_folder, '/') === FALSE) {if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE) {$system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;}} else {// Swap directory separators to Unix style for consistency$system_folder = str_replace("\\", "/", $system_folder);}define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));define('FCPATH', __FILE__);define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));define('BASEPATH', $system_folder.'/');if (is_dir($application_folder)) {define('APPPATH', $application_folder.'/');} else {if ($application_folder == '') {$application_folder = 'application';}define('APPPATH', BASEPATH.$application_folder.'/');}$GLOBALS[$nom_appli] = array('ci' => true) ;}/*** Fonction intermédiaire entre Papyrus et code igniter,* appelant une application et une fonction donnée* @param string le nom de l'application à éxécuter* @param string le nom de la fonction à éxécuter (optionnel)* @return string le code html à afficher généré par l'application*/function executerCodeIgniter($nom_appli,$nom_fonction = '') {// si l'application n'a pas encore été initialiséeif(!isset($GLOBALS[$nom_appli]['ci']) || $GLOBALS[$nom_appli]['ci'] != true) {// on appelle la fonction d'initialisation de code igniterinitialiserCodeIgniter($nom_appli) ;}// code igniter fonctionnant grâce à l'url, faute de mieux, on ajoute les bons// paramètres au tableau superglobal GET$_GET['c'] = $nom_appli ;if($nom_fonction != '') {$_GET['m'] = $nom_fonction ;}// N'ayant aucun moyen de récupérer directement le html généré par code igniter// on le stockera dans une globale qui sera remplie par le controleur appelé.$GLOBALS['retour'] = '' ;// enfin on appelle le fichier principal de code igniter// TODO: trouver comment faire pour l'appeller plusieurs fois dans une page// sans que ça pose de problèmesrequire_once BASEPATH.'codeigniter/CodeIgniter'.EXT;// on renvoie la variable globale remplie par le codereturn $GLOBALS['retour'] ;}?>