New file |
0,0 → 1,70 |
<?php |
/** |
* |
* fonctions |
* @author mathilde |
* |
*/ |
class EfloreCommun { |
|
private $Conteneur = null; |
private $Bdd = null; |
private $projetNom = ''; |
private $scriptChemin = ''; |
|
public function __construct($conteneur) { |
$this->Conteneur = $conteneur; |
$this->Bdd = $this->Conteneur->getBdd(); |
} |
|
public function initialiserProjet($projetNom) { |
$this->projetNom = $projetNom; |
$this->chargerConfigDuProjet(); |
} |
|
|
//+------------------------------------------------------------------------------------------------------+ |
// Méthodes communes aux projets d'eFlore |
|
public function chargerConfigDuProjet() { |
$scriptChemin = $this->Conteneur->getParametre('scriptChemin'); |
$fichierIni = $scriptChemin.$this->projetNom.'.ini'; |
if (file_exists($fichierIni)) { |
Config::charger($fichierIni); |
} else { |
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ". |
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'."; |
throw new Exception($m); |
} |
} |
|
//changée |
public function chargerStructureSql() { |
$this->chargerFichierSql('chemins.structureSql'); |
} |
|
|
public function chargerFichierSql($param_chemin) { |
$fichierStructureSql = $this->Conteneur->getParametre($param_chemin); |
$contenuSql = $this->recupererContenu($fichierStructureSql); |
$this->executerScriptSql($contenuSql); |
} |
|
|
|
public function executerScriptSql($sql) { |
$requetes = Outils::extraireRequetes($sql); |
foreach ($requetes as $requete) { |
$this->Bdd->requeter($requete); |
} |
} |
|
public function recupererContenu($chemin) { |
$contenu = file_get_contents($chemin); |
if ($contenu === false){ |
throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin"); |
} |
return $contenu; |
} |
} |
?> |