Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 350 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/** Exemple lancement:
 * /opt/lampp/bin/php -d memory_limit=3500M cli.php vigie_flore -a chargerTous
*/
class Photoflora extends EfloreScript {

        public function executer() {
                // Lancement de l'action demandée
                try {
                        $this->initialiserProjet('photoflora');

                        $cmd = $this->getParametre('a');
                        switch ($cmd) {
                                case 'chargerTous' :
                                        $this->chargerStructureSql();
                                        $this->chargerDonnees();
                                        $this->ajouterOntologie();
                                        break;
                                case 'chargerStructureSql' :
                                        $this->chargerStructureSql();
                                        break;
                                case 'chargerDonnees' :
                                        $this->chargerDonnees();
                                        $this->ajouterOntologie();
                                        break;
                                case 'ajouterOntologie' :
                                        $this->ajouterOntologie();
                                        break;
                                case 'supprimerTous' :
                                        $this->supprimerTous();
                                        break;
                                default :
                                        throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
                        }
                } catch (Exception $e) {
                        $this->traiterErreur($e->getMessage());
                }
        }

        protected function chargerDonnees() {
                $chemin = Config::get('chemins.donnees');
                $table = Config::get('tables.donnees');
                $requete = "LOAD DATA INFILE '$chemin' ".
                        "REPLACE INTO TABLE $table ".
                        'CHARACTER SET utf8 '.
                        'FIELDS '.
                        "       TERMINATED BY '\t' ".
                        "       ENCLOSED BY '' ".
                        "       ESCAPED BY '\\\' ".
                        'IGNORE 1 LINES';
                $this->getBdd()->requeter($requete);
        }
        

        private function ajouterOntologie() {
                $requete = "INSERT INTO `eflore_ontologies` (`id`, `classe_id`, `nom`, `description`, `code`, `complements`) VALUES
                                (26, 10, 'PhotoFlora', 'données issues de la <a href=\"http://www.photoflora.fr\" title=\"PhotoFlora\" onclick=\"window.open(this.href); return false;\">Base de données de photos de plantes essentiellement de la flore européenne</a>', 'PF', 'legende=#00D8D8');";
                $this->getBdd()->requeter($requete);
        }
        
        private function supprimerTous() {
                $requete = "DROP TABLE IF EXISTS photoflora_meta;";
                $this->getBdd()->requeter($requete);
                Debug::printr('suppression');
        }
}
?>