Rev 122 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// declare(encoding='UTF-8');/*** EfloreScript est une classe abstraite qui doit être implémenté par les classes éxecutant des scripts* en ligne de commande pour les projets d'eFlore.** @category PHP 5.2* @package Eflore/Scripts* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>* @copyright Copyright (c) 2011, Tela Botanica (accueil@tela-botanica.org)* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2* @since 0.3* @version $Id$* @link /doc/framework/*/abstract class EfloreScript extends Script {private $Bdd = null;private $projetNom = null;public function getProjetNom() {return $this->projetNom;}protected function initialiserProjet($projetNom) {$this->projetNom = $projetNom;$this->chargerConfigDuProjet();}//+------------------------------------------------------------------------------------------------------+// Méthodes d'accès aux objets du Framework/*** Méthode de connection à la base de données sur demande.* Tous les scripts n'ont pas besoin de s'y connecter.*/protected function getBdd() {if (! isset($this->Bdd)) {$this->Bdd = new Bdd();}return $this->Bdd;}//+------------------------------------------------------------------------------------------------------+// Méthodes communes aux projets d'eFloreprotected function chargerConfigDuProjet() {$fichierIni = $this->getScriptChemin().$this->getProjetNom().'.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);}}protected function chargerStructureSql() {$contenuSql = $this->recupererContenu(Config::get('chemins.structureSql'));$this->executerScripSql($contenuSql);}protected function executerScripSql($sql) {$requetes = Outils::extraireRequetes($sql);foreach ($requetes as $requete) {$this->getBdd()->requeter($requete);}}protected function recupererContenu($chemin) {$contenu = file_get_contents($chemin);if ($contenu === false){throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");}return $contenu;}protected function stopperLaBoucle($limite = false) {$stop = false;if ($limite) {static $ligneActuelle = 1;if ($limite == $ligneActuelle++) {$stop = true;}}return $stop;}}?>