/tags/v5.8-aspergeraie/CHANGELOG |
---|
New file |
0,0 → 1,107 |
Changements <next>: |
Changements 2014-06-02 [création de la branche "v5.8-aspergeraie "]: |
* Amélioration puis finalement archivage des scripts générant les contours de communes OSM (remplacé par : https://github.com/telabotanica/osm-boundary-admin ) |
* Ajout d'un script permettant d'extraire les contours de zones administratives des tables Mysql produite par le script osm-boundary-admin |
* Amélioration du services NomCommune et création de ZoneAdmin (pour obtenir la hiérarchie de zones admin de coordonnées géo) |
* Mise à jour Baseflor et Baseveg |
* Correction d'un nom de fichier mal créé dans le script du CEL |
* Simplification de la création de la table cel_references |
* Amélioration du service chorodep (ajout exception si fichier svg de base de la carte introuvable). |
Changements 2014-04-08 [création de la branche "v5.7-arrayanal"]: |
* Les urls des images sont désormais un paramètre de config |
* changement du formatage des descriptions |
* changement de l'interrogation des images |
* Première version refactorisée et améliorée du script OSM. |
* Amélioration de la vitesse de l'ordonneur de chemin |
Changements 2014-03-24 [création de la branche "v5.6-arganeraie"]: |
* Services : renommage "bdtao" => "apd" |
* Scripts : renommage "bdtao" => "apd" |
* Apd: version "1_00" => "3_4_0" |
* derniere version baseveg |
* carte sans contours de département pour moissonnage petit format (png) |
* Légère amélioration de la gestion des couleurs pour les petites tailles de png |
* Prise en compte de la migration des données eFlore sur Agathis |
* Mise à jour des services, scripts et docs du projet OSM. |
* Ajout d'une condition dans les requetes sur les ids inférieurs et supérieurs des taxons qui les limite au nom retenu |
* Ajout du champ num type s'il n'est pas déjà demandé dans les requetes de synonymie |
Changements 2014-03-04 [création de la branche "v5.5-arbousiere"]: |
* Ajout du web service renvoyant des liens vers les cartes de flore probable isssue de sophy |
* nouvelle version de la bdtfx |
* debug graphique baseflor valeur vide ne s'affiche plus comme 0 |
* correction requete vue tapir |
* Script d'intégration du référentiel bdtao |
* Ajout des scripts eFlore pour bdtao ; utilisation de 'num_basionyme' à la place de 'basionyme'. |
Changements 2014-02-11 [création de la branche "v5.4-Arboretum"]: |
* nouvelle version baseflor |
* Les services Noms des trois référentiels (bdtfx, bdtxa, isfan) retournent maintenant en plus du libellé du rang, le code du rang dans "rang.code" lorsqu'on leur demande "champs.retour=rang" |
* script de création données ifn et vue tapir |
* script transformant les données des tables de tb_moissonnage à une table _tapir et une table meta dans tb_eflore |
* ajout du moissonage de l'ifn |
* interrogation ifn et baznat par num_nom et plus par nom_sci |
Changements 2014-01-06 [création de la branche "v5.3-Amandaie"]: |
* service presencemuseum |
* Protection du graphique Baseflor contre les données NULL |
* ajout de version chorodep |
* Coste/textes : REDIRECT_QUERY_STRING => QUERY_STRING |
* array_unique() sur les courriels de la carte de répartition |
Changements 20130912 [création de la branche "Acheb"]: |
* API change: coste |
* référentiels: bdtfx 2.00, ontologies 4.40 |
* config: |
- directives inutiles supprimées pour Coste [r857] |
- bdnt: ontologie: 4_40 |
* coste: réécriture du webservice |
Changements [[http://svn.tela-botanica.net/websvn/filedetails.php?repname=eFlore%2FProjets.eflore-projets&path=%2Ftrunk%2FChangelog&peg=839 v5.0-agropyraie-20130829]] : |
- tenue du Changelog |
- config: directives modifiées: |
- cache.miseEnCache |
- cache.dureeDeVie |
- cache.stockageChemin |
- ontologies: |
- support critères multiples bdnt |
- support critères multiples nvjfl |
- support critères multiples baseflor |
- cache d'appels pour bdtfx/meta-donnees |
- SQL hard-codé en place du HTTP dans certains cas |
- tests: nombreux ajouts et quelques changements de prototypes |
- scripts: |
- upgrades pour Cel |
- Makefile pour configuration/ |
- renommage de noms de classes en conflit: Cartes et Ontologies |
- améliorations dans l'usage du cache |
Changements v0.1-20130830-1: |
* nvjfl: fix notices |
* cache: correction du cache des synonymes (noms à 255 caractères) |
* cel/images: déduplication de auteurs au préalable de la requête d'identités |
* Note: erreur de tag sur "v0.1-20130830" |
Changements v0.1-20130829: |
* tenue du Changelog |
* config: directives modifiées: |
- cache.miseEnCache |
- cache.dureeDeVie |
- cache.stockageChemin |
* ontologies: |
* support critères multiples bdnt |
* support critères multiples nvjfl |
* support critères multiples baseflor |
* support critères multiples eflore |
* cache d'appels pour bdtfx/meta-donnees |
* SQL hard-codé en place du HTTP dans certains cas |
* tests: nombreux ajouts et quelques changements de prototypes |
* scripts: |
* upgrades pour Cel |
* Makefile pour configuration/ |
* renommage de noms de classes en conflit: Cartes et Ontologies |
* améliorations dans l'usage du cache |
v0.1-20130600 |
/tags/v5.8-aspergeraie/scripts/bibliotheque/Messages.php |
---|
New file |
0,0 → 1,124 |
<?php |
class Messages { |
/** Niveau de message de type LOG */ |
const MSG_LOG = 0; |
/** Niveau de message de type ERREUR */ |
const MSG_ERREUR = 1; |
/** Niveau de message de type AVERTISSEMENT */ |
const MSG_AVERTISSEMENT = 2; |
/** Niveau de message de type INFORMATION */ |
const MSG_INFO = 3; |
/** Inititulé des différents types de message. */ |
private static $msg_niveaux_txt = array('LOG', 'ERREUR','AVERTISSEMENT', 'INFO'); |
private $verbosite = ''; |
public function __construct($verbosite = 0) { |
$this->verbosite = $verbosite; |
} |
/** |
* Affiche un message d'erreur formaté. |
* Si le paramétre de verbosité (-v) vaut 1 ou plus, le message est écrit dans le fichier de log et afficher dans la console. |
* |
* @param string le message d'erreur avec des %s. |
* @param array le tableau des paramêtres à insérer dans le message d'erreur. |
* @return void. |
*/ |
public function traiterErreur($message, $tab_arguments = array()) { |
$this->traiterMessage($message, $tab_arguments, self::MSG_ERREUR); |
} |
/** |
* Affiche un message d'avertissement formaté. |
* Si le paramétre de verbosité (-v) vaut 1, le message est écrit dans le fichier de log. |
* Si le paramétre de verbosité (-v) vaut 2 ou plus, le message est écrit dans le fichier de log et afficher dans la console. |
* |
* @param string le message d'erreur avec des %s. |
* @param array le tableau des paramêtres à insérer dans le message d'erreur. |
* @return void. |
*/ |
public function traiterAvertissement($message, $tab_arguments = array()) { |
$this->traiterMessage($message, $tab_arguments, self::MSG_AVERTISSEMENT); |
} |
/** |
* Retourne un message d'information formaté. |
* Si le paramétre de verbosité (-v) vaut 1 ou 2 , le message est écrit dans le fichier de log. |
* Si le paramétre de verbosité (-v) vaut 3 ou plus, le message est écrit dans le fichier de log et afficher dans la console. |
* |
* @param string le message d'information avec des %s. |
* @param array le tableau des paramêtres à insérer dans le message d'erreur. |
* @return void. |
*/ |
public function traiterInfo($message, $tab_arguments = array()) { |
$this->traiterMessage($message, $tab_arguments, self::MSG_INFO); |
} |
/** |
* Retourne un message formaté en le stockant dans un fichier de log si nécessaire. |
* |
* @param string le message d'erreur avec des %s. |
* @param array le tableau des paramêtres à insérer dans le message d'erreur. |
* @param int le niveau de verbosité à dépasser pour afficher les messages. |
* @return void. |
*/ |
private function traiterMessage($message, $tab_arguments, $niveau = self::MSG_LOG) { |
$log = $this->formaterMsg($message, $tab_arguments, $niveau); |
if ($this->verbosite > ($niveau - 1)) { |
echo $log; |
if (Config::get('log_script')) { |
// TODO : lancer le log |
} |
} |
} |
/** |
* Retourne un message d'information formaté. |
* |
* @param string le message d'information avec des %s. |
* @param array le tableau des paramêtres à insérer dans le message d'erreur. |
* @return string le message d'erreur formaté. |
*/ |
public function formaterMsg($message, $tab_arguments = array(), $niveau = null) { |
$texte = vsprintf($message, $tab_arguments); |
$prefixe = date('Y-m-j_H:i:s', time()); |
$prefixe .= is_null($niveau) ? ' : ' : ' - '.self::getMsgNiveauTxt($niveau).' : '; |
$log = $prefixe.$texte."\n"; |
return $log; |
} |
private static function getMsgNiveauTxt($niveau) { |
return self::$msg_niveaux_txt[$niveau]; |
} |
/** |
* Utiliser cette méthode dans une boucle pour afficher un message suivi du nombre de tour de boucle effectué. |
* Vous devrez vous même gérer le retour à la ligne à la sortie de la boucle. |
* |
* @param string le message d'information. |
* @param int le nombre de départ à afficher. |
* @return void le message est affiché dans la console. |
*/ |
public static function afficherAvancement($message, $depart = 0) { |
static $avancement = array(); |
if (! array_key_exists($message, $avancement)) { |
$avancement[$message] = $depart; |
echo "$message : "; |
$actuel =& $avancement[$message]; |
echo $actuel++; |
} else { |
$actuel =& $avancement[$message]; |
// Cas du passage de 99 (= 2 caractères) à 100 (= 3 caractères) |
$passage = 0; |
if (strlen((string) ($actuel - 1)) < strlen((string) ($actuel))) { |
$passage = 1; |
} |
echo str_repeat(chr(8), (strlen((string) $actuel) - $passage)); |
echo $actuel++; |
} |
} |
} |
/tags/v5.8-aspergeraie/scripts/bibliotheque/EfloreCommun.php |
---|
New file |
0,0 → 1,66 |
<?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; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/excel_reader/excel_reader2.php |
---|
New file |
0,0 → 1,1610 |
<?php |
/** |
* A class for reading Microsoft Excel (97/2003) Spreadsheets. |
* |
* Version 2.22 |
* |
* Enhanced and maintained by Alex Frenkel < excell2@frenkel-online.com > |
* Maintained at http://code.google.com/p/php-excel-reader2/ |
* |
* Previosly mantained by Matt Kruse < http://mattkruse.com > |
* Maintained at http://code.google.com/p/php-excel-reader/ |
* |
* Format parsing and MUCH more contributed by: |
* Matt Roxburgh < http://www.roxburgh.me.uk > |
* |
* DOCUMENTATION |
* ============= |
* http://code.google.com/p/php-excel-reader2/wiki/Documentation |
* |
* CHANGE LOG |
* ========== |
* http://code.google.com/p/php-excel-reader2/wiki/ChangeHistory |
* |
* |
* -------------------------------------------------------------------------- |
* |
* Originally developed by Vadim Tkachenko under the name PHPExcelReader. |
* (http://sourceforge.net/projects/phpexcelreader) |
* Based on the Java version by Andy Khan (http://www.andykhan.com). Now |
* maintained by David Sanders. Reads only Biff 7 and Biff 8 formats. |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category Spreadsheet |
* @package Spreadsheet_Excel_Reader |
* @author Vadim Tkachenko <vt@apachephp.com> |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: reader.php 19 2007-03-13 12:42:41Z shangxiao $ |
* @link http://pear.php.net/package/Spreadsheet_Excel_Reader |
* @see OLE, Spreadsheet_Excel_Writer |
* -------------------------------------------------------------------------- |
*/ |
define ( 'NUM_BIG_BLOCK_DEPOT_BLOCKS_POS', 0x2c ); |
define ( 'SMALL_BLOCK_DEPOT_BLOCK_POS', 0x3c ); |
define ( 'ROOT_START_BLOCK_POS', 0x30 ); |
define ( 'BIG_BLOCK_SIZE', 0x200 ); |
define ( 'SMALL_BLOCK_SIZE', 0x40 ); |
define ( 'EXTENSION_BLOCK_POS', 0x44 ); |
define ( 'NUM_EXTENSION_BLOCK_POS', 0x48 ); |
define ( 'PROPERTY_STORAGE_BLOCK_SIZE', 0x80 ); |
define ( 'BIG_BLOCK_DEPOT_BLOCKS_POS', 0x4c ); |
define ( 'SMALL_BLOCK_THRESHOLD', 0x1000 ); |
// property storage offsets |
define ( 'SIZE_OF_NAME_POS', 0x40 ); |
define ( 'TYPE_POS', 0x42 ); |
define ( 'START_BLOCK_POS', 0x74 ); |
define ( 'SIZE_POS', 0x78 ); |
define ( 'IDENTIFIER_OLE', pack ( "CCCCCCCC", 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 ) ); |
function GetInt4d($data, $pos) { |
$value = ord ( $data [$pos] ) | (ord ( $data [$pos + 1] ) << 8) | (ord ( $data [$pos + 2] ) << 16) | (ord ( $data [$pos + 3] ) << 24); |
if ($value >= 4294967294) { |
$value = - 2; |
} |
return $value; |
} |
// http://uk.php.net/manual/en/function.getdate.php |
function gmgetdate($ts = null) { |
$k = array ('seconds', 'minutes', 'hours', 'mday', 'wday', 'mon', 'year', 'yday', 'weekday', 'month', 0 ); |
return (array_comb ( $k, explode ( ":", gmdate ( 's:i:G:j:w:n:Y:z:l:F:U', is_null ( $ts ) ? time () : $ts ) ) )); |
} |
// Added for PHP4 compatibility |
function array_comb($array1, $array2) { |
$out = array (); |
foreach ( $array1 as $key => $value ) { |
$out [$value] = $array2 [$key]; |
} |
return $out; |
} |
function v($data, $pos) { |
return ord ( $data [$pos] ) | ord ( $data [$pos + 1] ) << 8; |
} |
class OLERead { |
var $data = ''; |
function OLERead() { |
} |
function read($sFileName) { |
// check if file exist and is readable (Darko Miljanovic) |
if (! is_readable ( $sFileName )) { |
$this->error = 1; |
return false; |
} |
$this->data = @file_get_contents ( $sFileName ); |
if (! $this->data) { |
$this->error = 1; |
return false; |
} |
if (substr ( $this->data, 0, 8 ) != IDENTIFIER_OLE) { |
$this->error = 1; |
return false; |
} |
$this->numBigBlockDepotBlocks = GetInt4d ( $this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS ); |
$this->sbdStartBlock = GetInt4d ( $this->data, SMALL_BLOCK_DEPOT_BLOCK_POS ); |
$this->rootStartBlock = GetInt4d ( $this->data, ROOT_START_BLOCK_POS ); |
$this->extensionBlock = GetInt4d ( $this->data, EXTENSION_BLOCK_POS ); |
$this->numExtensionBlocks = GetInt4d ( $this->data, NUM_EXTENSION_BLOCK_POS ); |
$bigBlockDepotBlocks = array (); |
$pos = BIG_BLOCK_DEPOT_BLOCKS_POS; |
$bbdBlocks = $this->numBigBlockDepotBlocks; |
if ($this->numExtensionBlocks != 0) { |
$bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS) / 4; |
} |
for($i = 0; $i < $bbdBlocks; $i ++) { |
$bigBlockDepotBlocks [$i] = GetInt4d ( $this->data, $pos ); |
$pos += 4; |
} |
for($j = 0; $j < $this->numExtensionBlocks; $j ++) { |
$pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE; |
$blocksToRead = min ( $this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1 ); |
for($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i ++) { |
$bigBlockDepotBlocks [$i] = GetInt4d ( $this->data, $pos ); |
$pos += 4; |
} |
$bbdBlocks += $blocksToRead; |
if ($bbdBlocks < $this->numBigBlockDepotBlocks) { |
$this->extensionBlock = GetInt4d ( $this->data, $pos ); |
} |
} |
// readBigBlockDepot |
$pos = 0; |
$index = 0; |
$this->bigBlockChain = array (); |
for($i = 0; $i < $this->numBigBlockDepotBlocks; $i ++) { |
$pos = ($bigBlockDepotBlocks [$i] + 1) * BIG_BLOCK_SIZE; |
//echo "pos = $pos"; |
for($j = 0; $j < BIG_BLOCK_SIZE / 4; $j ++) { |
$this->bigBlockChain [$index] = GetInt4d ( $this->data, $pos ); |
$pos += 4; |
$index ++; |
} |
} |
// readSmallBlockDepot(); |
$pos = 0; |
$index = 0; |
$sbdBlock = $this->sbdStartBlock; |
$this->smallBlockChain = array (); |
while ( $sbdBlock != - 2 ) { |
$pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE; |
for($j = 0; $j < BIG_BLOCK_SIZE / 4; $j ++) { |
$this->smallBlockChain [$index] = GetInt4d ( $this->data, $pos ); |
$pos += 4; |
$index ++; |
} |
$sbdBlock = $this->bigBlockChain [$sbdBlock]; |
} |
// readData(rootStartBlock) |
$block = $this->rootStartBlock; |
$pos = 0; |
$this->entry = $this->__readData ( $block ); |
$this->__readPropertySets (); |
} |
function __readData($bl) { |
$block = $bl; |
$pos = 0; |
$data = ''; |
while ( $block != - 2 ) { |
$pos = ($block + 1) * BIG_BLOCK_SIZE; |
$data = $data . substr ( $this->data, $pos, BIG_BLOCK_SIZE ); |
$block = $this->bigBlockChain [$block]; |
} |
return $data; |
} |
function __readPropertySets() { |
$offset = 0; |
while ( $offset < strlen ( $this->entry ) ) { |
$d = substr ( $this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE ); |
$nameSize = ord ( $d [SIZE_OF_NAME_POS] ) | (ord ( $d [SIZE_OF_NAME_POS + 1] ) << 8); |
$type = ord ( $d [TYPE_POS] ); |
$startBlock = GetInt4d ( $d, START_BLOCK_POS ); |
$size = GetInt4d ( $d, SIZE_POS ); |
$name = ''; |
for($i = 0; $i < $nameSize; $i ++) { |
$name .= $d [$i]; |
} |
$name = str_replace ( "\x00", "", $name ); |
$this->props [] = array ('name' => $name, 'type' => $type, 'startBlock' => $startBlock, 'size' => $size ); |
if ((strtolower ( $name ) == "workbook") || (strtolower ( $name ) == "book")) { |
$this->wrkbook = count ( $this->props ) - 1; |
} |
if ($name == "Root Entry") { |
$this->rootentry = count ( $this->props ) - 1; |
} |
$offset += PROPERTY_STORAGE_BLOCK_SIZE; |
} |
} |
function getWorkBook() { |
if ($this->props [$this->wrkbook] ['size'] < SMALL_BLOCK_THRESHOLD) { |
$rootdata = $this->__readData ( $this->props [$this->rootentry] ['startBlock'] ); |
$streamData = ''; |
$block = $this->props [$this->wrkbook] ['startBlock']; |
$pos = 0; |
while ( $block != - 2 ) { |
$pos = $block * SMALL_BLOCK_SIZE; |
$streamData .= substr ( $rootdata, $pos, SMALL_BLOCK_SIZE ); |
$block = $this->smallBlockChain [$block]; |
} |
return $streamData; |
} else { |
$numBlocks = $this->props [$this->wrkbook] ['size'] / BIG_BLOCK_SIZE; |
if ($this->props [$this->wrkbook] ['size'] % BIG_BLOCK_SIZE != 0) { |
$numBlocks ++; |
} |
if ($numBlocks == 0) |
return ''; |
$streamData = ''; |
$block = $this->props [$this->wrkbook] ['startBlock']; |
$pos = 0; |
while ( $block != - 2 ) { |
$pos = ($block + 1) * BIG_BLOCK_SIZE; |
$streamData .= substr ( $this->data, $pos, BIG_BLOCK_SIZE ); |
$block = $this->bigBlockChain [$block]; |
} |
return $streamData; |
} |
} |
} |
define ( 'SPREADSHEET_EXCEL_READER_BIFF8', 0x600 ); |
define ( 'SPREADSHEET_EXCEL_READER_BIFF7', 0x500 ); |
define ( 'SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS', 0x5 ); |
define ( 'SPREADSHEET_EXCEL_READER_WORKSHEET', 0x10 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_BOF', 0x809 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_EOF', 0x0a ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET', 0x85 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_DIMENSION', 0x200 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_ROW', 0x208 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_DBCELL', 0xd7 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_FILEPASS', 0x2f ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_NOTE', 0x1c ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_TXO', 0x1b6 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_RK', 0x7e ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_RK2', 0x27e ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_MULRK', 0xbd ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_MULBLANK', 0xbe ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_INDEX', 0x20b ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_SST', 0xfc ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_EXTSST', 0xff ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_CONTINUE', 0x3c ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_LABEL', 0x204 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_LABELSST', 0xfd ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_NUMBER', 0x203 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_NAME', 0x18 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_ARRAY', 0x221 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_STRING', 0x207 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_FORMULA', 0x406 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_FORMULA2', 0x6 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_FORMAT', 0x41e ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_XF', 0xe0 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_BOOLERR', 0x205 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_FONT', 0x0031 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_PALETTE', 0x0092 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_UNKNOWN', 0xffff ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR', 0x22 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS', 0xE5 ); |
define ( 'SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS', 25569 ); |
define ( 'SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904', 24107 ); |
define ( 'SPREADSHEET_EXCEL_READER_MSINADAY', 86400 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_HYPER', 0x01b8 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_COLINFO', 0x7d ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_DEFCOLWIDTH', 0x55 ); |
define ( 'SPREADSHEET_EXCEL_READER_TYPE_STANDARDWIDTH', 0x99 ); |
define ( 'SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', "%s" ); |
/* |
* Main Class |
*/ |
class Spreadsheet_Excel_Reader { |
// MK: Added to make data retrieval easier |
var $colnames = array (); |
var $colindexes = array (); |
var $standardColWidth = 0; |
var $defaultColWidth = 0; |
function myHex($d) { |
if ($d < 16) |
return "0" . dechex ( $d ); |
return dechex ( $d ); |
} |
function dumpHexData($data, $pos, $length) { |
$info = ""; |
for($i = 0; $i <= $length; $i ++) { |
$info .= ($i == 0 ? "" : " ") . $this->myHex ( ord ( $data [$pos + $i] ) ) . (ord ( $data [$pos + $i] ) > 31 ? "[" . $data [$pos + $i] . "]" : ''); |
} |
return $info; |
} |
function getCol($col) { |
if (is_string ( $col )) { |
$col = strtolower ( $col ); |
if (array_key_exists ( $col, $this->colnames )) { |
$col = $this->colnames [$col]; |
} |
} |
return $col; |
} |
// PUBLIC API FUNCTIONS |
// -------------------- |
function val($row, $col, $sheet = 0) { |
$col = $this->getCol ( $col ); |
if (array_key_exists ( $row, $this->sheets [$sheet] ['cells'] ) && array_key_exists ( $col, $this->sheets [$sheet] ['cells'] [$row] )) { |
return $this->sheets [$sheet] ['cells'] [$row] [$col]; |
} |
return ""; |
} |
function value($row, $col, $sheet = 0) { |
return $this->val ( $row, $col, $sheet ); |
} |
function info($row, $col, $type = '', $sheet = 0) { |
$col = $this->getCol ( $col ); |
if (array_key_exists ( 'cellsInfo', $this->sheets [$sheet] ) && array_key_exists ( $row, $this->sheets [$sheet] ['cellsInfo'] ) && array_key_exists ( $col, $this->sheets [$sheet] ['cellsInfo'] [$row] ) && array_key_exists ( $type, $this->sheets [$sheet] ['cellsInfo'] [$row] [$col] )) { |
return $this->sheets [$sheet] ['cellsInfo'] [$row] [$col] [$type]; |
} |
return ""; |
} |
function type($row, $col, $sheet = 0) { |
return $this->info ( $row, $col, 'type', $sheet ); |
} |
function raw($row, $col, $sheet = 0) { |
return $this->info ( $row, $col, 'raw', $sheet ); |
} |
function rowspan($row, $col, $sheet = 0) { |
$val = $this->info ( $row, $col, 'rowspan', $sheet ); |
if ($val == "") { |
return 1; |
} |
return $val; |
} |
function colspan($row, $col, $sheet = 0) { |
$val = $this->info ( $row, $col, 'colspan', $sheet ); |
if ($val == "") { |
return 1; |
} |
return $val; |
} |
function hyperlink($row, $col, $sheet = 0) { |
$link = $this->sheets [$sheet] ['cellsInfo'] [$row] [$col] ['hyperlink']; |
if ($link) { |
return $link ['link']; |
} |
return ''; |
} |
function rowcount($sheet = 0) { |
return $this->sheets [$sheet] ['numRows']; |
} |
function colcount($sheet = 0) { |
return $this->sheets [$sheet] ['numCols']; |
} |
function colwidth($col, $sheet = 0) { |
// Col width is actually the width of the number 0. So we have to estimate and come close |
return $this->colInfo [$sheet] [$col] ['width'] / 9142 * 200; |
} |
function colhidden($col, $sheet = 0) { |
return ! ! $this->colInfo [$sheet] [$col] ['hidden']; |
} |
function rowheight($row, $sheet = 0) { |
return $this->rowInfo [$sheet] [$row] ['height']; |
} |
function rowhidden($row, $sheet = 0) { |
return ! ! $this->rowInfo [$sheet] [$row] ['hidden']; |
} |
// GET THE CSS FOR FORMATTING |
// ========================== |
function style($row, $col, $sheet = 0, $properties = '') { |
$css = ""; |
$font = $this->font ( $row, $col, $sheet ); |
if ($font != "") { |
$css .= "font-family:$font;"; |
} |
$align = $this->align ( $row, $col, $sheet ); |
if ($align != "") { |
$css .= "text-align:$align;"; |
} |
$height = $this->height ( $row, $col, $sheet ); |
if ($height != "") { |
$css .= "font-size:$height" . "px;"; |
} |
$bgcolor = $this->bgColor ( $row, $col, $sheet ); |
if ($bgcolor != "") { |
$bgcolor = $this->colors [$bgcolor]; |
$css .= "background-color:$bgcolor;"; |
} |
$color = $this->color ( $row, $col, $sheet ); |
if ($color != "") { |
$css .= "color:$color;"; |
} |
$bold = $this->bold ( $row, $col, $sheet ); |
if ($bold) { |
$css .= "font-weight:bold;"; |
} |
$italic = $this->italic ( $row, $col, $sheet ); |
if ($italic) { |
$css .= "font-style:italic;"; |
} |
$underline = $this->underline ( $row, $col, $sheet ); |
if ($underline) { |
$css .= "text-decoration:underline;"; |
} |
// Borders |
$bLeft = $this->borderLeft ( $row, $col, $sheet ); |
$bRight = $this->borderRight ( $row, $col, $sheet ); |
$bTop = $this->borderTop ( $row, $col, $sheet ); |
$bBottom = $this->borderBottom ( $row, $col, $sheet ); |
$bLeftCol = $this->borderLeftColor ( $row, $col, $sheet ); |
$bRightCol = $this->borderRightColor ( $row, $col, $sheet ); |
$bTopCol = $this->borderTopColor ( $row, $col, $sheet ); |
$bBottomCol = $this->borderBottomColor ( $row, $col, $sheet ); |
// Try to output the minimal required style |
if ($bLeft != "" && $bLeft == $bRight && $bRight == $bTop && $bTop == $bBottom) { |
$css .= "border:" . $this->lineStylesCss [$bLeft] . ";"; |
} else { |
if ($bLeft != "") { |
$css .= "border-left:" . $this->lineStylesCss [$bLeft] . ";"; |
} |
if ($bRight != "") { |
$css .= "border-right:" . $this->lineStylesCss [$bRight] . ";"; |
} |
if ($bTop != "") { |
$css .= "border-top:" . $this->lineStylesCss [$bTop] . ";"; |
} |
if ($bBottom != "") { |
$css .= "border-bottom:" . $this->lineStylesCss [$bBottom] . ";"; |
} |
} |
// Only output border colors if there is an actual border specified |
if ($bLeft != "" && $bLeftCol != "") { |
$css .= "border-left-color:" . $bLeftCol . ";"; |
} |
if ($bRight != "" && $bRightCol != "") { |
$css .= "border-right-color:" . $bRightCol . ";"; |
} |
if ($bTop != "" && $bTopCol != "") { |
$css .= "border-top-color:" . $bTopCol . ";"; |
} |
if ($bBottom != "" && $bBottomCol != "") { |
$css .= "border-bottom-color:" . $bBottomCol . ";"; |
} |
return $css; |
} |
// FORMAT PROPERTIES |
// ================= |
function format($row, $col, $sheet = 0) { |
return $this->info ( $row, $col, 'format', $sheet ); |
} |
function formatIndex($row, $col, $sheet = 0) { |
return $this->info ( $row, $col, 'formatIndex', $sheet ); |
} |
function formatColor($row, $col, $sheet = 0) { |
return $this->info ( $row, $col, 'formatColor', $sheet ); |
} |
// CELL (XF) PROPERTIES |
// ==================== |
function xfRecord($row, $col, $sheet = 0) { |
$xfIndex = $this->info ( $row, $col, 'xfIndex', $sheet ); |
if ($xfIndex != "") { |
return $this->xfRecords [$xfIndex]; |
} |
return null; |
} |
function xfProperty($row, $col, $sheet, $prop) { |
$xfRecord = $this->xfRecord ( $row, $col, $sheet ); |
if ($xfRecord != null) { |
return $xfRecord [$prop]; |
} |
return ""; |
} |
function align($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'align' ); |
} |
function bgColor($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'bgColor' ); |
} |
function borderLeft($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'borderLeft' ); |
} |
function borderRight($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'borderRight' ); |
} |
function borderTop($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'borderTop' ); |
} |
function borderBottom($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'borderBottom' ); |
} |
function borderLeftColor($row, $col, $sheet = 0) { |
return $this->colors [$this->xfProperty ( $row, $col, $sheet, 'borderLeftColor' )]; |
} |
function borderRightColor($row, $col, $sheet = 0) { |
return $this->colors [$this->xfProperty ( $row, $col, $sheet, 'borderRightColor' )]; |
} |
function borderTopColor($row, $col, $sheet = 0) { |
return $this->colors [$this->xfProperty ( $row, $col, $sheet, 'borderTopColor' )]; |
} |
function borderBottomColor($row, $col, $sheet = 0) { |
return $this->colors [$this->xfProperty ( $row, $col, $sheet, 'borderBottomColor' )]; |
} |
// FONT PROPERTIES |
// =============== |
function fontRecord($row, $col, $sheet = 0) { |
$xfRecord = $this->xfRecord ( $row, $col, $sheet ); |
if ($xfRecord != null) { |
$font = $xfRecord ['fontIndex']; |
if ($font != null) { |
return $this->fontRecords [$font]; |
} |
} |
return null; |
} |
function fontProperty($row, $col, $sheet = 0, $prop) { |
$font = $this->fontRecord ( $row, $col, $sheet ); |
if ($font != null) { |
return $font [$prop]; |
} |
return false; |
} |
function fontIndex($row, $col, $sheet = 0) { |
return $this->xfProperty ( $row, $col, $sheet, 'fontIndex' ); |
} |
function color($row, $col, $sheet = 0) { |
$formatColor = $this->formatColor ( $row, $col, $sheet ); |
if ($formatColor != "") { |
return $formatColor; |
} |
$ci = $this->fontProperty ( $row, $col, $sheet, 'color' ); |
return $this->rawColor ( $ci ); |
} |
function rawColor($ci) { |
if (($ci != 0x7FFF) && ($ci != '')) { |
return $this->colors [$ci]; |
} |
return ""; |
} |
function bold($row, $col, $sheet = 0) { |
return $this->fontProperty ( $row, $col, $sheet, 'bold' ); |
} |
function italic($row, $col, $sheet = 0) { |
return $this->fontProperty ( $row, $col, $sheet, 'italic' ); |
} |
function underline($row, $col, $sheet = 0) { |
return $this->fontProperty ( $row, $col, $sheet, 'under' ); |
} |
function height($row, $col, $sheet = 0) { |
return $this->fontProperty ( $row, $col, $sheet, 'height' ); |
} |
function font($row, $col, $sheet = 0) { |
return $this->fontProperty ( $row, $col, $sheet, 'font' ); |
} |
// DUMP AN HTML TABLE OF THE ENTIRE XLS DATA |
// ========================================= |
function dump($row_numbers = false, $col_letters = false, $sheet = 0, $table_class = 'excel') { |
$out = "<table class=\"$table_class\" cellspacing=0>"; |
if ($col_letters) { |
$out .= "<thead>\n\t<tr>"; |
if ($row_numbers) { |
$out .= "\n\t\t<th> </th>"; |
} |
for($i = 1; $i <= $this->colcount ( $sheet ); $i ++) { |
$style = "width:" . ($this->colwidth ( $i, $sheet ) * 1) . "px;"; |
if ($this->colhidden ( $i, $sheet )) { |
$style .= "display:none;"; |
} |
$out .= "\n\t\t<th style=\"$style\">" . strtoupper ( $this->colindexes [$i] ) . "</th>"; |
} |
$out .= "</tr></thead>\n"; |
} |
$out .= "<tbody>\n"; |
for($row = 1; $row <= $this->rowcount ( $sheet ); $row ++) { |
$rowheight = $this->rowheight ( $row, $sheet ); |
$style = "height:" . ($rowheight * (4 / 3)) . "px;"; |
if ($this->rowhidden ( $row, $sheet )) { |
$style .= "display:none;"; |
} |
$out .= "\n\t<tr style=\"$style\">"; |
if ($row_numbers) { |
$out .= "\n\t\t<th>$row</th>"; |
} |
for($col = 1; $col <= $this->colcount ( $sheet ); $col ++) { |
// Account for Rowspans/Colspans |
$rowspan = $this->rowspan ( $row, $col, $sheet ); |
$colspan = $this->colspan ( $row, $col, $sheet ); |
for($i = 0; $i < $rowspan; $i ++) { |
for($j = 0; $j < $colspan; $j ++) { |
if ($i > 0 || $j > 0) { |
$this->sheets [$sheet] ['cellsInfo'] [$row + $i] [$col + $j] ['dontprint'] = 1; |
} |
} |
} |
if (! $this->sheets [$sheet] ['cellsInfo'] [$row] [$col] ['dontprint']) { |
$style = $this->style ( $row, $col, $sheet ); |
if ($this->colhidden ( $col, $sheet )) { |
$style .= "display:none;"; |
} |
$out .= "\n\t\t<td style=\"$style\"" . ($colspan > 1 ? " colspan=$colspan" : "") . ($rowspan > 1 ? " rowspan=$rowspan" : "") . ">"; |
$val = $this->val ( $row, $col, $sheet ); |
if ($val == '') { |
$val = " "; |
} else { |
$val = htmlentities ( $val, ENT_COMPAT, $this->_defaultEncoding ); |
$link = $this->hyperlink ( $row, $col, $sheet ); |
if ($link != '') { |
$val = "<a href=\"$link\">$val</a>"; |
} |
} |
$out .= "<nobr>" . nl2br ( $val ) . "</nobr>"; |
$out .= "</td>"; |
} |
} |
$out .= "</tr>\n"; |
} |
$out .= "</tbody></table>"; |
return $out; |
} |
// -------------- |
// END PUBLIC API |
var $boundsheets = array (); |
var $formatRecords = array (); |
var $fontRecords = array (); |
var $xfRecords = array (); |
var $colInfo = array (); |
var $rowInfo = array (); |
var $sst = array (); |
var $sheets = array (); |
var $data; |
var $_ole; |
var $_defaultEncoding = "UTF-8"; |
var $_defaultFormat = SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT; |
var $_columnsFormat = array (); |
var $_rowoffset = 1; |
var $_coloffset = 1; |
/** |
* List of default date formats used by Excel |
*/ |
var $dateFormats = array (0xe => "m/d/Y", 0xf => "M-d-Y", 0x10 => "d-M", 0x11 => "M-Y", 0x12 => "h:i a", 0x13 => "h:i:s a", 0x14 => "H:i", 0x15 => "H:i:s", 0x16 => "d/m/Y H:i", 0x2d => "i:s", 0x2e => "H:i:s", 0x2f => "i:s.S" ); |
/** |
* Default number formats used by Excel |
*/ |
var $numberFormats = array (0x1 => "0", 0x2 => "0.00", 0x3 => "#,##0", 0x4 => "#,##0.00", 0x5 => "\$#,##0;(\$#,##0)", 0x6 => "\$#,##0;[Red](\$#,##0)", 0x7 => "\$#,##0.00;(\$#,##0.00)", 0x8 => "\$#,##0.00;[Red](\$#,##0.00)", 0x9 => "0%", 0xa => "0.00%", 0xb => "0.00E+00", 0x25 => "#,##0;(#,##0)", 0x26 => "#,##0;[Red](#,##0)", 0x27 => "#,##0.00;(#,##0.00)", 0x28 => "#,##0.00;[Red](#,##0.00)", 0x29 => "#,##0;(#,##0)", // Not exactly |
0x2a => "\$#,##0;(\$#,##0)", // Not exactly |
0x2b => "#,##0.00;(#,##0.00)", // Not exactly |
0x2c => "\$#,##0.00;(\$#,##0.00)", // Not exactly |
0x30 => "##0.0E+0" ); |
var $colors = Array (0x00 => "#000000", 0x01 => "#FFFFFF", 0x02 => "#FF0000", 0x03 => "#00FF00", 0x04 => "#0000FF", 0x05 => "#FFFF00", 0x06 => "#FF00FF", 0x07 => "#00FFFF", 0x08 => "#000000", 0x09 => "#FFFFFF", 0x0A => "#FF0000", 0x0B => "#00FF00", 0x0C => "#0000FF", 0x0D => "#FFFF00", 0x0E => "#FF00FF", 0x0F => "#00FFFF", 0x10 => "#800000", 0x11 => "#008000", 0x12 => "#000080", 0x13 => "#808000", 0x14 => "#800080", 0x15 => "#008080", 0x16 => "#C0C0C0", 0x17 => "#808080", 0x18 => "#9999FF", 0x19 => "#993366", 0x1A => "#FFFFCC", 0x1B => "#CCFFFF", 0x1C => "#660066", 0x1D => "#FF8080", 0x1E => "#0066CC", 0x1F => "#CCCCFF", 0x20 => "#000080", 0x21 => "#FF00FF", 0x22 => "#FFFF00", 0x23 => "#00FFFF", 0x24 => "#800080", 0x25 => "#800000", 0x26 => "#008080", 0x27 => "#0000FF", 0x28 => "#00CCFF", 0x29 => "#CCFFFF", 0x2A => "#CCFFCC", 0x2B => "#FFFF99", 0x2C => "#99CCFF", 0x2D => "#FF99CC", 0x2E => "#CC99FF", 0x2F => "#FFCC99", 0x30 => "#3366FF", 0x31 => "#33CCCC", 0x32 => "#99CC00", 0x33 => "#FFCC00", 0x34 => "#FF9900", 0x35 => "#FF6600", 0x36 => "#666699", 0x37 => "#969696", 0x38 => "#003366", 0x39 => "#339966", 0x3A => "#003300", 0x3B => "#333300", 0x3C => "#993300", 0x3D => "#993366", 0x3E => "#333399", 0x3F => "#333333", 0x40 => "#000000", 0x41 => "#FFFFFF", |
0x43 => "#000000", 0x4D => "#000000", 0x4E => "#FFFFFF", 0x4F => "#000000", 0x50 => "#FFFFFF", 0x51 => "#000000", |
0x7FFF => "#000000" ); |
var $lineStyles = array (0x00 => "", 0x01 => "Thin", 0x02 => "Medium", 0x03 => "Dashed", 0x04 => "Dotted", 0x05 => "Thick", 0x06 => "Double", 0x07 => "Hair", 0x08 => "Medium dashed", 0x09 => "Thin dash-dotted", 0x0A => "Medium dash-dotted", 0x0B => "Thin dash-dot-dotted", 0x0C => "Medium dash-dot-dotted", 0x0D => "Slanted medium dash-dotted" ); |
var $lineStylesCss = array ("Thin" => "1px solid", "Medium" => "2px solid", "Dashed" => "1px dashed", "Dotted" => "1px dotted", "Thick" => "3px solid", "Double" => "double", "Hair" => "1px solid", "Medium dashed" => "2px dashed", "Thin dash-dotted" => "1px dashed", "Medium dash-dotted" => "2px dashed", "Thin dash-dot-dotted" => "1px dashed", "Medium dash-dot-dotted" => "2px dashed", "Slanted medium dash-dotte" => "2px dashed" ); |
function read16bitstring($data, $start) { |
$len = 0; |
while ( ord ( $data [$start + $len] ) + ord ( $data [$start + $len + 1] ) > 0 ) |
$len ++; |
return substr ( $data, $start, $len ); |
} |
// ADDED by Matt Kruse for better formatting |
function _format_value($format, $num, $f) { |
// 49==TEXT format |
// http://code.google.com/p/php-excel-reader/issues/detail?id=7 |
if ((! $f && $format == "%s") || ($f == 49) || ($format == "GENERAL")) { |
return array ('string' => $num, 'formatColor' => null ); |
} |
// Custom pattern can be POSITIVE;NEGATIVE;ZERO |
// The "text" option as 4th parameter is not handled |
$parts = explode ( ";", $format ); |
$pattern = $parts [0]; |
// Negative pattern |
if (count ( $parts ) > 2 && $num == 0) { |
$pattern = $parts [2]; |
} |
// Zero pattern |
if (count ( $parts ) > 1 && $num < 0) { |
$pattern = $parts [1]; |
$num = abs ( $num ); |
} |
$color = ""; |
$matches = array (); |
$color_regex = "/^\[(BLACK|BLUE|CYAN|GREEN|MAGENTA|RED|WHITE|YELLOW)\]/i"; |
if (preg_match ( $color_regex, $pattern, $matches )) { |
$color = strtolower ( $matches [1] ); |
$pattern = preg_replace ( $color_regex, "", $pattern ); |
} |
// In Excel formats, "_" is used to add spacing, which we can't do in HTML |
$pattern = preg_replace ( "/_./", "", $pattern ); |
// Some non-number characters are escaped with \, which we don't need |
$pattern = preg_replace ( "/\\\/", "", $pattern ); |
// Some non-number strings are quoted, so we'll get rid of the quotes |
$pattern = preg_replace ( "/\"/", "", $pattern ); |
// TEMPORARY - Convert # to 0 |
$pattern = preg_replace ( "/\#/", "0", $pattern ); |
// Find out if we need comma formatting |
$has_commas = preg_match ( "/,/", $pattern ); |
if ($has_commas) { |
$pattern = preg_replace ( "/,/", "", $pattern ); |
} |
// Handle Percentages |
if (preg_match ( "/\d(\%)([^\%]|$)/", $pattern, $matches )) { |
$num = $num * 100; |
$pattern = preg_replace ( "/(\d)(\%)([^\%]|$)/", "$1%$3", $pattern ); |
} |
// Handle the number itself |
$number_regex = "/(\d+)(\.?)(\d*)/"; |
if (preg_match ( $number_regex, $pattern, $matches )) { |
$left = $matches [1]; |
$dec = $matches [2]; |
$right = $matches [3]; |
if ($has_commas) { |
$formatted = number_format ( $num, strlen ( $right ) ); |
} else { |
$sprintf_pattern = "%1." . strlen ( $right ) . "f"; |
$formatted = sprintf ( $sprintf_pattern, $num ); |
} |
$pattern = preg_replace ( $number_regex, $formatted, $pattern ); |
} |
return array ('string' => $pattern, 'formatColor' => $color ); |
} |
/** |
* Constructor |
* |
* Some basic initialisation |
*/ |
function Spreadsheet_Excel_Reader($file = '', $store_extended_info = true, $outputEncoding = '') { |
$this->_ole = new OLERead ( ); |
$this->setUTFEncoder ( 'iconv' ); |
if ($outputEncoding != '') { |
$this->setOutputEncoding ( $outputEncoding ); |
} |
for($i = 1; $i < 245; $i ++) { |
$name = strtolower ( ((($i - 1) / 26 >= 1) ? chr ( ($i - 1) / 26 + 64 ) : '') . chr ( ($i - 1) % 26 + 65 ) ); |
$this->colnames [$name] = $i; |
$this->colindexes [$i] = $name; |
} |
$this->store_extended_info = $store_extended_info; |
if ($file != "") { |
$this->read ( $file ); |
} |
} |
/** |
* Set the encoding method |
*/ |
function setOutputEncoding($encoding) { |
$this->_defaultEncoding = $encoding; |
} |
/** |
* $encoder = 'iconv' or 'mb' |
* set iconv if you would like use 'iconv' for encode UTF-16LE to your encoding |
* set mb if you would like use 'mb_convert_encoding' for encode UTF-16LE to your encoding |
*/ |
function setUTFEncoder($encoder = 'iconv') { |
$this->_encoderFunction = ''; |
if ($encoder == 'iconv') { |
$this->_encoderFunction = function_exists ( 'iconv' ) ? 'iconv' : ''; |
} elseif ($encoder == 'mb') { |
$this->_encoderFunction = function_exists ( 'mb_convert_encoding' ) ? 'mb_convert_encoding' : ''; |
} |
} |
function setRowColOffset($iOffset) { |
$this->_rowoffset = $iOffset; |
$this->_coloffset = $iOffset; |
} |
/** |
* Set the default number format |
*/ |
function setDefaultFormat($sFormat) { |
$this->_defaultFormat = $sFormat; |
} |
/** |
* Force a column to use a certain format |
*/ |
function setColumnFormat($column, $sFormat) { |
$this->_columnsFormat [$column] = $sFormat; |
} |
/** |
* Read the spreadsheet file using OLE, then parse |
*/ |
function read($sFileName) { |
$res = $this->_ole->read ( $sFileName ); |
// oops, something goes wrong (Darko Miljanovic) |
if ($res === false) { |
// check error code |
if ($this->_ole->error == 1) { |
// bad file |
die ( 'The filename ' . $sFileName . ' is not readable' ); |
} |
// check other error codes here (eg bad fileformat, etc...) |
} |
$this->data = $this->_ole->getWorkBook (); |
$this->_parse (); |
} |
/** |
* Parse a workbook |
* |
* @access private |
* @return bool |
*/ |
function _parse() { |
$pos = 0; |
$data = $this->data; |
$code = v ( $data, $pos ); |
$length = v ( $data, $pos + 2 ); |
$version = v ( $data, $pos + 4 ); |
$substreamType = v ( $data, $pos + 6 ); |
$this->version = $version; |
if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && ($version != SPREADSHEET_EXCEL_READER_BIFF7)) { |
return false; |
} |
if ($substreamType != SPREADSHEET_EXCEL_READER_WORKBOOKGLOBALS) { |
return false; |
} |
$pos += $length + 4; |
$code = v ( $data, $pos ); |
$length = v ( $data, $pos + 2 ); |
while ( $code != SPREADSHEET_EXCEL_READER_TYPE_EOF ) { |
switch ($code) { |
case SPREADSHEET_EXCEL_READER_TYPE_SST : |
$spos = $pos + 4; |
$limitpos = $spos + $length; |
$uniqueStrings = $this->_GetInt4d ( $data, $spos + 4 ); |
$spos += 8; |
for($i = 0; $i < $uniqueStrings; $i ++) { |
// Read in the number of characters |
if ($spos == $limitpos) { |
$opcode = v ( $data, $spos ); |
$conlength = v ( $data, $spos + 2 ); |
if ($opcode != 0x3c) { |
return - 1; |
} |
$spos += 4; |
$limitpos = $spos + $conlength; |
} |
$numChars = ord ( $data [$spos] ) | (ord ( $data [$spos + 1] ) << 8); |
$spos += 2; |
$optionFlags = ord ( $data [$spos] ); |
$spos ++; |
$asciiEncoding = (($optionFlags & 0x01) == 0); |
$extendedString = (($optionFlags & 0x04) != 0); |
// See if string contains formatting information |
$richString = (($optionFlags & 0x08) != 0); |
if ($richString) { |
// Read in the crun |
$formattingRuns = v ( $data, $spos ); |
$spos += 2; |
} |
if ($extendedString) { |
// Read in cchExtRst |
$extendedRunLength = $this->_GetInt4d ( $data, $spos ); |
$spos += 4; |
} |
$len = ($asciiEncoding) ? $numChars : $numChars * 2; |
if ($spos + $len < $limitpos) { |
$retstr = substr ( $data, $spos, $len ); |
$spos += $len; |
} else { |
// found countinue |
$retstr = substr ( $data, $spos, $limitpos - $spos ); |
$bytesRead = $limitpos - $spos; |
$charsLeft = $numChars - (($asciiEncoding) ? $bytesRead : ($bytesRead / 2)); |
$spos = $limitpos; |
while ( $charsLeft > 0 ) { |
$opcode = v ( $data, $spos ); |
$conlength = v ( $data, $spos + 2 ); |
if ($opcode != 0x3c) { |
return - 1; |
} |
$spos += 4; |
$limitpos = $spos + $conlength; |
$option = ord ( $data [$spos] ); |
$spos += 1; |
if ($asciiEncoding && ($option == 0)) { |
$len = min ( $charsLeft, $limitpos - $spos ); // min($charsLeft, $conlength); |
$retstr .= substr ( $data, $spos, $len ); |
$charsLeft -= $len; |
$asciiEncoding = true; |
} elseif (! $asciiEncoding && ($option != 0)) { |
$len = min ( $charsLeft * 2, $limitpos - $spos ); // min($charsLeft, $conlength); |
$retstr .= substr ( $data, $spos, $len ); |
$charsLeft -= $len / 2; |
$asciiEncoding = false; |
} elseif (! $asciiEncoding && ($option == 0)) { |
// Bummer - the string starts off as Unicode, but after the |
// continuation it is in straightforward ASCII encoding |
$len = min ( $charsLeft, $limitpos - $spos ); // min($charsLeft, $conlength); |
for($j = 0; $j < $len; $j ++) { |
$retstr .= $data [$spos + $j] . chr ( 0 ); |
} |
$charsLeft -= $len; |
$asciiEncoding = false; |
} else { |
$newstr = ''; |
for($j = 0; $j < strlen ( $retstr ); $j ++) { |
$newstr = $retstr [$j] . chr ( 0 ); |
} |
$retstr = $newstr; |
$len = min ( $charsLeft * 2, $limitpos - $spos ); // min($charsLeft, $conlength); |
$retstr .= substr ( $data, $spos, $len ); |
$charsLeft -= $len / 2; |
$asciiEncoding = false; |
} |
$spos += $len; |
} |
} |
if ($asciiEncoding) |
$retstr = preg_replace ( "/(.)/s", "$1\0", $retstr ); |
$retstr = $this->_encodeUTF16 ( $retstr ); |
if ($richString) { |
$spos += 4 * $formattingRuns; |
} |
// For extended strings, skip over the extended string data |
if ($extendedString) { |
$spos += $extendedRunLength; |
} |
$this->sst [] = $retstr; |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_FILEPASS : |
return false; |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_NAME : |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_FORMAT : |
$indexCode = v ( $data, $pos + 4 ); |
if ($version == SPREADSHEET_EXCEL_READER_BIFF8) { |
$numchars = v ( $data, $pos + 6 ); |
if (ord ( $data [$pos + 8] ) == 0) { |
$formatString = substr ( $data, $pos + 9, $numchars ); |
} else { |
$formatString = substr ( $data, $pos + 9, $numchars * 2 ); |
} |
} else { |
$numchars = ord ( $data [$pos + 6] ); |
$formatString = substr ( $data, $pos + 7, $numchars * 2 ); |
} |
$this->formatRecords [$indexCode] = $formatString; |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_FONT : |
$height = v ( $data, $pos + 4 ); |
$option = v ( $data, $pos + 6 ); |
$color = v ( $data, $pos + 8 ); |
$weight = v ( $data, $pos + 10 ); |
$under = ord ( $data [$pos + 14] ); |
$font = ""; |
// Font name |
$numchars = ord ( $data [$pos + 18] ); |
if ((ord ( $data [$pos + 19] ) & 1) == 0) { |
$font = substr ( $data, $pos + 20, $numchars ); |
} else { |
$font = substr ( $data, $pos + 20, $numchars * 2 ); |
$font = $this->_encodeUTF16 ( $font ); |
} |
$this->fontRecords [] = array ('height' => $height / 20, 'italic' => ! ! ($option & 2), 'color' => $color, 'under' => ! ($under == 0), 'bold' => ($weight == 700), 'font' => $font, 'raw' => $this->dumpHexData ( $data, $pos + 3, $length ) ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_PALETTE : |
$colors = ord ( $data [$pos + 4] ) | ord ( $data [$pos + 5] ) << 8; |
for($coli = 0; $coli < $colors; $coli ++) { |
$colOff = $pos + 2 + ($coli * 4); |
$colr = ord ( $data [$colOff] ); |
$colg = ord ( $data [$colOff + 1] ); |
$colb = ord ( $data [$colOff + 2] ); |
$this->colors [0x07 + $coli] = '#' . $this->myhex ( $colr ) . $this->myhex ( $colg ) . $this->myhex ( $colb ); |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_XF : |
$fontIndexCode = (ord ( $data [$pos + 4] ) | ord ( $data [$pos + 5] ) << 8) - 1; |
$fontIndexCode = max ( 0, $fontIndexCode ); |
$indexCode = ord ( $data [$pos + 6] ) | ord ( $data [$pos + 7] ) << 8; |
$alignbit = ord ( $data [$pos + 10] ) & 3; |
$bgi = (ord ( $data [$pos + 22] ) | ord ( $data [$pos + 23] ) << 8) & 0x3FFF; |
$bgcolor = ($bgi & 0x7F); |
// $bgcolor = ($bgi & 0x3f80) >> 7; |
$align = ""; |
if ($alignbit == 3) { |
$align = "right"; |
} |
if ($alignbit == 2) { |
$align = "center"; |
} |
$fillPattern = (ord ( $data [$pos + 21] ) & 0xFC) >> 2; |
if ($fillPattern == 0) { |
$bgcolor = ""; |
} |
$xf = array (); |
$xf ['formatIndex'] = $indexCode; |
$xf ['align'] = $align; |
$xf ['fontIndex'] = $fontIndexCode; |
$xf ['bgColor'] = $bgcolor; |
$xf ['fillPattern'] = $fillPattern; |
$border = ord ( $data [$pos + 14] ) | (ord ( $data [$pos + 15] ) << 8) | (ord ( $data [$pos + 16] ) << 16) | (ord ( $data [$pos + 17] ) << 24); |
$xf ['borderLeft'] = $this->lineStyles [($border & 0xF)]; |
$xf ['borderRight'] = $this->lineStyles [($border & 0xF0) >> 4]; |
$xf ['borderTop'] = $this->lineStyles [($border & 0xF00) >> 8]; |
$xf ['borderBottom'] = $this->lineStyles [($border & 0xF000) >> 12]; |
$xf ['borderLeftColor'] = ($border & 0x7F0000) >> 16; |
$xf ['borderRightColor'] = ($border & 0x3F800000) >> 23; |
$border = (ord ( $data [$pos + 18] ) | ord ( $data [$pos + 19] ) << 8); |
$xf ['borderTopColor'] = ($border & 0x7F); |
$xf ['borderBottomColor'] = ($border & 0x3F80) >> 7; |
if (array_key_exists ( $indexCode, $this->dateFormats )) { |
$xf ['type'] = 'date'; |
$xf ['format'] = $this->dateFormats [$indexCode]; |
if ($align == '') { |
$xf ['align'] = 'right'; |
} |
} elseif (array_key_exists ( $indexCode, $this->numberFormats )) { |
$xf ['type'] = 'number'; |
$xf ['format'] = $this->numberFormats [$indexCode]; |
if ($align == '') { |
$xf ['align'] = 'right'; |
} |
} else { |
$isdate = FALSE; |
$formatstr = ''; |
if ($indexCode > 0) { |
if (isset ( $this->formatRecords [$indexCode] )) |
$formatstr = $this->formatRecords [$indexCode]; |
if ($formatstr != "") { |
$tmp = preg_replace ( "/\;.*/", "", $formatstr ); |
$tmp = preg_replace ( "/^\[[^\]]*\]/", "", $tmp ); |
if (preg_match ( "/[^hmsday\/\-:\s\\\,AMP]/i", $tmp ) == 0) { // found day and time format |
$isdate = TRUE; |
$formatstr = $tmp; |
$formatstr = str_replace ( array ('AM/PM', 'mmmm', 'mmm' ), array ('a', 'F', 'M' ), $formatstr ); |
// m/mm are used for both minutes and months - oh SNAP! |
// This mess tries to fix for that. |
// 'm' == minutes only if following h/hh or preceding s/ss |
$formatstr = preg_replace ( "/(h:?)mm?/", "$1i", $formatstr ); |
$formatstr = preg_replace ( "/mm?(:?s)/", "i$1", $formatstr ); |
// A single 'm' = n in PHP |
$formatstr = preg_replace ( "/(^|[^m])m([^m]|$)/", '$1n$2', $formatstr ); |
$formatstr = preg_replace ( "/(^|[^m])m([^m]|$)/", '$1n$2', $formatstr ); |
// else it's months |
$formatstr = str_replace ( 'mm', 'm', $formatstr ); |
// Convert single 'd' to 'j' |
$formatstr = preg_replace ( "/(^|[^d])d([^d]|$)/", '$1j$2', $formatstr ); |
$formatstr = str_replace ( array ('dddd', 'ddd', 'dd', 'yyyy', 'yy', 'hh', 'h' ), array ('l', 'D', 'd', 'Y', 'y', 'H', 'g' ), $formatstr ); |
$formatstr = preg_replace ( "/ss?/", 's', $formatstr ); |
} |
} |
} |
if ($isdate) { |
$xf ['type'] = 'date'; |
$xf ['format'] = $formatstr; |
if ($align == '') { |
$xf ['align'] = 'right'; |
} |
} else { |
// If the format string has a 0 or # in it, we'll assume it's a number |
if (preg_match ( "/[0#]/", $formatstr )) { |
$xf ['type'] = 'number'; |
if ($align == '') { |
$xf ['align'] = 'right'; |
} |
} else { |
$xf ['type'] = 'other'; |
} |
$xf ['format'] = $formatstr; |
$xf ['code'] = $indexCode; |
} |
} |
$this->xfRecords [] = $xf; |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_NINETEENFOUR : |
$this->nineteenFour = (ord ( $data [$pos + 4] ) == 1); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET : |
$rec_offset = $this->_GetInt4d ( $data, $pos + 4 ); |
$rec_typeFlag = ord ( $data [$pos + 8] ); |
$rec_visibilityFlag = ord ( $data [$pos + 9] ); |
$rec_length = ord ( $data [$pos + 10] ); |
if ($version == SPREADSHEET_EXCEL_READER_BIFF8) { |
$chartype = ord ( $data [$pos + 11] ); |
if ($chartype == 0) { |
$rec_name = substr ( $data, $pos + 12, $rec_length ); |
} else { |
$rec_name = $this->_encodeUTF16 ( substr ( $data, $pos + 12, $rec_length * 2 ) ); |
} |
} elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7) { |
$rec_name = substr ( $data, $pos + 11, $rec_length ); |
} |
$this->boundsheets [] = array ('name' => $rec_name, 'offset' => $rec_offset ); |
break; |
} |
$pos += $length + 4; |
$code = ord ( $data [$pos] ) | ord ( $data [$pos + 1] ) << 8; |
$length = ord ( $data [$pos + 2] ) | ord ( $data [$pos + 3] ) << 8; |
} |
foreach ( $this->boundsheets as $key => $val ) { |
$this->sn = $key; |
$this->_parsesheet ( $val ['offset'] ); |
} |
return true; |
} |
/** |
* Parse a worksheet |
*/ |
function _parsesheet($spos) { |
$cont = true; |
$data = $this->data; |
// read BOF |
$code = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$length = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$version = ord ( $data [$spos + 4] ) | ord ( $data [$spos + 5] ) << 8; |
$substreamType = ord ( $data [$spos + 6] ) | ord ( $data [$spos + 7] ) << 8; |
if (($version != SPREADSHEET_EXCEL_READER_BIFF8) && ($version != SPREADSHEET_EXCEL_READER_BIFF7)) { |
return - 1; |
} |
if ($substreamType != SPREADSHEET_EXCEL_READER_WORKSHEET) { |
return - 2; |
} |
$spos += $length + 4; |
while ( $cont ) { |
$lowcode = ord ( $data [$spos] ); |
if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) |
break; |
$code = $lowcode | ord ( $data [$spos + 1] ) << 8; |
$length = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$spos += 4; |
$this->sheets [$this->sn] ['maxrow'] = $this->_rowoffset - 1; |
$this->sheets [$this->sn] ['maxcol'] = $this->_coloffset - 1; |
unset ( $this->rectype ); |
switch ($code) { |
case SPREADSHEET_EXCEL_READER_TYPE_DIMENSION : |
if (! isset ( $this->numRows )) { |
if (($length == 10) || ($version == SPREADSHEET_EXCEL_READER_BIFF7)) { |
$this->sheets [$this->sn] ['numRows'] = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$this->sheets [$this->sn] ['numCols'] = ord ( $data [$spos + 6] ) | ord ( $data [$spos + 7] ) << 8; |
} else { |
$this->sheets [$this->sn] ['numRows'] = ord ( $data [$spos + 4] ) | ord ( $data [$spos + 5] ) << 8; |
$this->sheets [$this->sn] ['numCols'] = ord ( $data [$spos + 10] ) | ord ( $data [$spos + 11] ) << 8; |
} |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS : |
$cellRanges = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
for($i = 0; $i < $cellRanges; $i ++) { |
$fr = ord ( $data [$spos + 8 * $i + 2] ) | ord ( $data [$spos + 8 * $i + 3] ) << 8; |
$lr = ord ( $data [$spos + 8 * $i + 4] ) | ord ( $data [$spos + 8 * $i + 5] ) << 8; |
$fc = ord ( $data [$spos + 8 * $i + 6] ) | ord ( $data [$spos + 8 * $i + 7] ) << 8; |
$lc = ord ( $data [$spos + 8 * $i + 8] ) | ord ( $data [$spos + 8 * $i + 9] ) << 8; |
if ($lr - $fr > 0) { |
$this->sheets [$this->sn] ['cellsInfo'] [$fr + 1] [$fc + 1] ['rowspan'] = $lr - $fr + 1; |
} |
if ($lc - $fc > 0) { |
$this->sheets [$this->sn] ['cellsInfo'] [$fr + 1] [$fc + 1] ['colspan'] = $lc - $fc + 1; |
} |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_RK : |
case SPREADSHEET_EXCEL_READER_TYPE_RK2 : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$rknum = $this->_GetInt4d ( $data, $spos + 6 ); |
$numValue = $this->_GetIEEE754 ( $rknum ); |
$info = $this->_getCellDetails ( $spos, $numValue, $column ); |
$this->addcell ( $row, $column, $info ['string'], $info ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_LABELSST : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$xfindex = ord ( $data [$spos + 4] ) | ord ( $data [$spos + 5] ) << 8; |
$index = $this->_GetInt4d ( $data, $spos + 6 ); |
$this->addcell ( $row, $column, $this->sst [$index], array ('xfIndex' => $xfindex ) ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_MULRK : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$colFirst = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$colLast = ord ( $data [$spos + $length - 2] ) | ord ( $data [$spos + $length - 1] ) << 8; |
$columns = $colLast - $colFirst + 1; |
$tmppos = $spos + 4; |
for($i = 0; $i < $columns; $i ++) { |
$numValue = $this->_GetIEEE754 ( $this->_GetInt4d ( $data, $tmppos + 2 ) ); |
$info = $this->_getCellDetails ( $tmppos - 4, $numValue, $colFirst + $i + 1 ); |
$tmppos += 6; |
$this->addcell ( $row, $colFirst + $i, $info ['string'], $info ); |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_NUMBER : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$tmp = unpack ( "ddouble", substr ( $data, $spos + 6, 8 ) ); // It machine machine dependent |
if ($this->isDate ( $spos )) { |
$numValue = $tmp ['double']; |
} else { |
$numValue = $this->createNumber ( $spos ); |
} |
$info = $this->_getCellDetails ( $spos, $numValue, $column ); |
$this->addcell ( $row, $column, $info ['string'], $info ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_FORMULA : |
case SPREADSHEET_EXCEL_READER_TYPE_FORMULA2 : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
if ((ord ( $data [$spos + 6] ) == 0) && (ord ( $data [$spos + 12] ) == 255) && (ord ( $data [$spos + 13] ) == 255)) { |
//String formula. Result follows in a STRING record |
// This row/col are stored to be referenced in that record |
// http://code.google.com/p/php-excel-reader/issues/detail?id=4 |
$previousRow = $row; |
$previousCol = $column; |
} elseif ((ord ( $data [$spos + 6] ) == 1) && (ord ( $data [$spos + 12] ) == 255) && (ord ( $data [$spos + 13] ) == 255)) { |
//Boolean formula. Result is in +2; 0=false,1=true |
// http://code.google.com/p/php-excel-reader/issues/detail?id=4 |
if (ord ( $this->data [$spos + 8] ) == 1) { |
$this->addcell ( $row, $column, "TRUE" ); |
} else { |
$this->addcell ( $row, $column, "FALSE" ); |
} |
} elseif ((ord ( $data [$spos + 6] ) == 2) && (ord ( $data [$spos + 12] ) == 255) && (ord ( $data [$spos + 13] ) == 255)) { |
//Error formula. Error code is in +2; |
} elseif ((ord ( $data [$spos + 6] ) == 3) && (ord ( $data [$spos + 12] ) == 255) && (ord ( $data [$spos + 13] ) == 255)) { |
//Formula result is a null string. |
$this->addcell ( $row, $column, '' ); |
} else { |
// result is a number, so first 14 bytes are just like a _NUMBER record |
$tmp = unpack ( "ddouble", substr ( $data, $spos + 6, 8 ) ); // It machine machine dependent |
if ($this->isDate ( $spos )) { |
$numValue = $tmp ['double']; |
} else { |
$numValue = $this->createNumber ( $spos ); |
} |
$info = $this->_getCellDetails ( $spos, $numValue, $column ); |
$this->addcell ( $row, $column, $info ['string'], $info ); |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_BOOLERR : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$string = ord ( $data [$spos + 6] ); |
$this->addcell ( $row, $column, $string ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_STRING : |
// http://code.google.com/p/php-excel-reader/issues/detail?id=4 |
if ($version == SPREADSHEET_EXCEL_READER_BIFF8) { |
// Unicode 16 string, like an SST record |
$xpos = $spos; |
$numChars = ord ( $data [$xpos] ) | (ord ( $data [$xpos + 1] ) << 8); |
$xpos += 2; |
$optionFlags = ord ( $data [$xpos] ); |
$xpos ++; |
$asciiEncoding = (($optionFlags & 0x01) == 0); |
$extendedString = (($optionFlags & 0x04) != 0); |
// See if string contains formatting information |
$richString = (($optionFlags & 0x08) != 0); |
if ($richString) { |
// Read in the crun |
$formattingRuns = ord ( $data [$xpos] ) | (ord ( $data [$xpos + 1] ) << 8); |
$xpos += 2; |
} |
if ($extendedString) { |
// Read in cchExtRst |
$extendedRunLength = $this->_GetInt4d ( $this->data, $xpos ); |
$xpos += 4; |
} |
$len = ($asciiEncoding) ? $numChars : $numChars * 2; |
$retstr = substr ( $data, $xpos, $len ); |
$xpos += $len; |
if ($asciiEncoding) |
$retstr = preg_replace ( "/(.)/s", "$1\0", $retstr ); |
$retstr = $this->_encodeUTF16 ( $retstr ); |
} elseif ($version == SPREADSHEET_EXCEL_READER_BIFF7) { |
// Simple byte string |
$xpos = $spos; |
$numChars = ord ( $data [$xpos] ) | (ord ( $data [$xpos + 1] ) << 8); |
$xpos += 2; |
$retstr = substr ( $data, $xpos, $numChars ); |
} |
$this->addcell ( $previousRow, $previousCol, $retstr ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_ROW : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$rowInfo = ord ( $data [$spos + 6] ) | ((ord ( $data [$spos + 7] ) << 8) & 0x7FFF); |
if (($rowInfo & 0x8000) > 0) { |
$rowHeight = - 1; |
} else { |
$rowHeight = $rowInfo & 0x7FFF; |
} |
$rowHidden = (ord ( $data [$spos + 12] ) & 0x20) >> 5; |
$this->rowInfo [$this->sn] [$row + 1] = Array ('height' => $rowHeight / 20, 'hidden' => $rowHidden ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_DBCELL : |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_MULBLANK : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$cols = ($length / 2) - 3; |
for($c = 0; $c < $cols; $c ++) { |
$xfindex = ord ( $data [$spos + 4 + ($c * 2)] ) | ord ( $data [$spos + 5 + ($c * 2)] ) << 8; |
$this->addcell ( $row, $column + $c, "", array ('xfIndex' => $xfindex ) ); |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_LABEL : |
$row = ord ( $data [$spos] ) | ord ( $data [$spos + 1] ) << 8; |
$column = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$this->addcell ( $row, $column, substr ( $data, $spos + 8, ord ( $data [$spos + 6] ) | ord ( $data [$spos + 7] ) << 8 ) ); |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_EOF : |
$cont = false; |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_HYPER : |
// Only handle hyperlinks to a URL |
$row = ord ( $this->data [$spos] ) | ord ( $this->data [$spos + 1] ) << 8; |
$row2 = ord ( $this->data [$spos + 2] ) | ord ( $this->data [$spos + 3] ) << 8; |
$column = ord ( $this->data [$spos + 4] ) | ord ( $this->data [$spos + 5] ) << 8; |
$column2 = ord ( $this->data [$spos + 6] ) | ord ( $this->data [$spos + 7] ) << 8; |
$linkdata = Array (); |
$flags = ord ( $this->data [$spos + 28] ); |
$udesc = ""; |
$ulink = ""; |
$uloc = 32; |
$linkdata ['flags'] = $flags; |
if (($flags & 1) > 0) { // is a type we understand |
// is there a description ? |
if (($flags & 0x14) == 0x14) { // has a description |
$uloc += 4; |
$descLen = ord ( $this->data [$spos + 32] ) | ord ( $this->data [$spos + 33] ) << 8; |
$udesc = substr ( $this->data, $spos + $uloc, $descLen * 2 ); |
$uloc += 2 * $descLen; |
} |
$ulink = $this->read16bitstring ( $this->data, $spos + $uloc + 20 ); |
if ($udesc == "") { |
$udesc = $ulink; |
} |
} |
$linkdata ['desc'] = $udesc; |
$linkdata ['link'] = $this->_encodeUTF16 ( $ulink ); |
for($r = $row; $r <= $row2; $r ++) { |
for($c = $column; $c <= $column2; $c ++) { |
$this->sheets [$this->sn] ['cellsInfo'] [$r + 1] [$c + 1] ['hyperlink'] = $linkdata; |
} |
} |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_DEFCOLWIDTH : |
$this->defaultColWidth = ord ( $data [$spos + 4] ) | ord ( $data [$spos + 5] ) << 8; |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_STANDARDWIDTH : |
$this->standardColWidth = ord ( $data [$spos + 4] ) | ord ( $data [$spos + 5] ) << 8; |
break; |
case SPREADSHEET_EXCEL_READER_TYPE_COLINFO : |
$colfrom = ord ( $data [$spos + 0] ) | ord ( $data [$spos + 1] ) << 8; |
$colto = ord ( $data [$spos + 2] ) | ord ( $data [$spos + 3] ) << 8; |
$cw = ord ( $data [$spos + 4] ) | ord ( $data [$spos + 5] ) << 8; |
$cxf = ord ( $data [$spos + 6] ) | ord ( $data [$spos + 7] ) << 8; |
$co = ord ( $data [$spos + 8] ); |
for($coli = $colfrom; $coli <= $colto; $coli ++) { |
$this->colInfo [$this->sn] [$coli + 1] = Array ('width' => $cw, 'xf' => $cxf, 'hidden' => ($co & 0x01), 'collapsed' => ($co & 0x1000) >> 12 ); |
} |
break; |
default : |
break; |
} |
$spos += $length; |
} |
if (! isset ( $this->sheets [$this->sn] ['numRows'] )) |
$this->sheets [$this->sn] ['numRows'] = $this->sheets [$this->sn] ['maxrow']; |
if (! isset ( $this->sheets [$this->sn] ['numCols'] )) |
$this->sheets [$this->sn] ['numCols'] = $this->sheets [$this->sn] ['maxcol']; |
} |
function isDate($spos) { |
$xfindex = ord ( $this->data [$spos + 4] ) | ord ( $this->data [$spos + 5] ) << 8; |
return ($this->xfRecords [$xfindex] ['type'] == 'date'); |
} |
// Get the details for a particular cell |
function _getCellDetails($spos, $numValue, $column) { |
$xfindex = ord ( $this->data [$spos + 4] ) | ord ( $this->data [$spos + 5] ) << 8; |
$xfrecord = $this->xfRecords [$xfindex]; |
$type = $xfrecord ['type']; |
$format = $xfrecord ['format']; |
$formatIndex = $xfrecord ['formatIndex']; |
$fontIndex = $xfrecord ['fontIndex']; |
$formatColor = ""; |
$rectype = ''; |
$string = ''; |
$raw = ''; |
if (isset ( $this->_columnsFormat [$column + 1] )) { |
$format = $this->_columnsFormat [$column + 1]; |
} |
if ($type == 'date') { |
// See http://groups.google.com/group/php-excel-reader-discuss/browse_frm/thread/9c3f9790d12d8e10/f2045c2369ac79de |
$rectype = 'date'; |
// Convert numeric value into a date |
$utcDays = floor ( $numValue - ($this->nineteenFour ? SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS1904 : SPREADSHEET_EXCEL_READER_UTCOFFSETDAYS) ); |
$utcValue = ($utcDays) * SPREADSHEET_EXCEL_READER_MSINADAY; |
$dateinfo = gmgetdate ( $utcValue ); |
$raw = $numValue; |
$fractionalDay = $numValue - floor ( $numValue ) + .0000001; // The .0000001 is to fix for php/excel fractional diffs |
$totalseconds = floor ( SPREADSHEET_EXCEL_READER_MSINADAY * $fractionalDay ); |
$secs = $totalseconds % 60; |
$totalseconds -= $secs; |
$hours = floor ( $totalseconds / (60 * 60) ); |
$mins = floor ( $totalseconds / 60 ) % 60; |
$string = date ( $format, mktime ( $hours, $mins, $secs, $dateinfo ["mon"], $dateinfo ["mday"], $dateinfo ["year"] ) ); |
} else if ($type == 'number') { |
$rectype = 'number'; |
$formatted = $this->_format_value ( $format, $numValue, $formatIndex ); |
$string = $formatted ['string']; |
$formatColor = $formatted ['formatColor']; |
$raw = $numValue; |
} else { |
if ($format == "") { |
$format = $this->_defaultFormat; |
} |
$rectype = 'unknown'; |
$formatted = $this->_format_value ( $format, $numValue, $formatIndex ); |
$string = $formatted ['string']; |
$formatColor = $formatted ['formatColor']; |
$raw = $numValue; |
} |
return array ('string' => $string, 'raw' => $raw, 'rectype' => $rectype, 'format' => $format, 'formatIndex' => $formatIndex, 'fontIndex' => $fontIndex, 'formatColor' => $formatColor, 'xfIndex' => $xfindex ); |
} |
function createNumber($spos) { |
$rknumhigh = $this->_GetInt4d ( $this->data, $spos + 10 ); |
$rknumlow = $this->_GetInt4d ( $this->data, $spos + 6 ); |
$sign = ($rknumhigh & 0x80000000) >> 31; |
$exp = ($rknumhigh & 0x7ff00000) >> 20; |
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); |
$mantissalow1 = ($rknumlow & 0x80000000) >> 31; |
$mantissalow2 = ($rknumlow & 0x7fffffff); |
$value = $mantissa / pow ( 2, (20 - ($exp - 1023)) ); |
if ($mantissalow1 != 0) |
$value += 1 / pow ( 2, (21 - ($exp - 1023)) ); |
$value += $mantissalow2 / pow ( 2, (52 - ($exp - 1023)) ); |
if ($sign) { |
$value = - 1 * $value; |
} |
return $value; |
} |
function addcell($row, $col, $string, $info = null) { |
$this->sheets [$this->sn] ['maxrow'] = max ( $this->sheets [$this->sn] ['maxrow'], $row + $this->_rowoffset ); |
$this->sheets [$this->sn] ['maxcol'] = max ( $this->sheets [$this->sn] ['maxcol'], $col + $this->_coloffset ); |
$this->sheets [$this->sn] ['cells'] [$row + $this->_rowoffset] [$col + $this->_coloffset] = $string; |
if ($this->store_extended_info && $info) { |
foreach ( $info as $key => $val ) { |
$this->sheets [$this->sn] ['cellsInfo'] [$row + $this->_rowoffset] [$col + $this->_coloffset] [$key] = $val; |
} |
} |
} |
function _GetIEEE754($rknum) { |
if (($rknum & 0x02) != 0) { |
$value = $rknum >> 2; |
} else { |
//mmp |
// I got my info on IEEE754 encoding from |
// http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html |
// The RK format calls for using only the most significant 30 bits of the |
// 64 bit floating point value. The other 34 bits are assumed to be 0 |
// So, we use the upper 30 bits of $rknum as follows... |
$sign = ($rknum & 0x80000000) >> 31; |
$exp = ($rknum & 0x7ff00000) >> 20; |
$mantissa = (0x100000 | ($rknum & 0x000ffffc)); |
$value = $mantissa / pow ( 2, (20 - ($exp - 1023)) ); |
if ($sign) { |
$value = - 1 * $value; |
} |
//end of changes by mmp |
} |
if (($rknum & 0x01) != 0) { |
$value /= 100; |
} |
return $value; |
} |
function _encodeUTF16($string) { |
$result = $string; |
if ($this->_defaultEncoding) { |
switch ($this->_encoderFunction) { |
case 'iconv' : |
$result = iconv ( 'UTF-16LE', $this->_defaultEncoding, $string ); |
break; |
case 'mb_convert_encoding' : |
$result = mb_convert_encoding ( $string, $this->_defaultEncoding, 'UTF-16LE' ); |
break; |
} |
} |
return $result; |
} |
function _GetInt4d($data, $pos) { |
$value = ord ( $data [$pos] ) | (ord ( $data [$pos + 1] ) << 8) | (ord ( $data [$pos + 2] ) << 16) | (ord ( $data [$pos + 3] ) << 24); |
if ($value >= 4294967294) { |
$value = - 2; |
} |
return $value; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/GenerateurNomSciHtml.php |
---|
New file |
0,0 → 1,283 |
<?php |
class GenerateurNomSciHtml { |
protected $bdd = null; |
protected $table = null; |
protected $num = null; |
protected $compo_nom = array(); |
protected $abbr = array ( |
'infra-gen.' => 'Infra-Genre', |
'sect.' => 'Section', |
'subsect.' => 'Sous-Section', |
'ser.' => 'Série', |
'subser.' => 'Sous-Série', |
'gr.' => 'Groupe', |
'agg.' => 'Agrégat', |
'sp.' => 'Espèce', |
'subsp.' => 'Sous-Espèce', |
'infra-sp.' => 'Infra-Espèce', |
'var.' => 'Variété', |
'subvar.' => 'Sous-Variété', |
'fa' => 'Forme', |
'subf.' => 'Sous-Forme', |
'f. sp.' => 'Forma species', |
'proles' => 'Race prole' |
); |
private $nomSciTpl = '<span class="sci">%s</span>'; |
private $nomSupraGenTpl = '<span class="supra_gen">%s</span>'; |
private $genTpl = '<span class="gen">%s</span>'; |
private $infraGenTpl = '<span class="infra-gen">%s</span>'; |
private $spFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span>'; |
private $typeEpitheteTpl = '<abbr class="type_epithete" title="%s">%s</abbr>'; |
private $infraSpFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span> <abbr class="type-epithete" title="%s">%s</abbr> <span class="infra-sp">%s</span>'; |
private $hybrideTpl = '<span class="hyb">× <span class="%s">%s</span></span>'; |
private $chimereTpl = '<span class="chimere">+ <span class="%s">%s</span></span>'; |
private $formuleHybTpl = '<span class="formule-hyb">%s</span>'; |
private $hybriditeTpl = '<span class="%s">%s</span>'; |
private $gpGxAvecCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>(%s <abbr title="groupe">Gp</abbr>)</span>'; |
private $gpGxSansCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>%s <abbr title="groupe">Gp</abbr></span>'; |
private $gxTpl = '<span class="gp">%s <abbr title="grex">gx</abbr></span>'; |
private $gpAvecCvarTpl = '<span class="gp">(%s <abbr title="groupe">Gp</abbr>)</span>'; |
private $gpSansCvarTpl = '<span class="gp">%s <abbr title="groupe">Gp</abbr></span>'; |
private $commTpl = '<span class="commercial">%s</span>'; |
private $cvarTpl = '<span class="cultivar">\'%s\'</span>'; |
public function generer(Array $nomsDecomposes) { |
$nomsSciHtml = array(); |
foreach ($nomsDecomposes as $infos) { |
$nom = $this->genererNomSciHtml($infos); |
if ($nom != '') { |
$nomsSciHtml[$this->num] = $nom; |
} |
} |
return $nomsSciHtml; |
} |
public function genererNomSciHtml(Array $nomDecomposes) { |
$this->initialiserVariables($nomDecomposes); |
$nomSciHtml = ''; |
$nomSciHtml .= $this->ajouterBaliseNomSupraGen(); |
$nomSciHtml .= $this->verifierHybridite($this->compo_nom['genre'], 'gen'); |
$nomSciHtml .= $this->ajouterBaliseInfraGen(); |
$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_sp'], 'sp'); |
$nomSciHtml .= $this->ajouterBaliseTypeInfraSp(); |
$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_infra_sp'], 'infra-sp'); |
$nomSciHtml .= $this->ajouterCultivarGpComm(); |
if ($nomSciHtml != '') { |
$nomSciHtml = sprintf($this->nomSciTpl, trim($nomSciHtml)); |
} else { |
$nomSciHtml = $this->verifierHybridite($this->compo_nom['nom_sci'], 'infra-sp'); |
} |
return $nomSciHtml; |
} |
private function initialiserVariables($infos) { |
$this->num = $infos['num_nom']; |
$this->compo_nom = $infos; |
} |
private function ajouterBaliseNomSupraGen() { |
$html = ''; |
if ($this->compo_nom['nom_supra_generique'] != '') { |
$html = sprintf($this->nomSupraGenTpl, $this->compo_nom['nom_supra_generique']); |
} |
return $html; |
} |
private function ajouterTypeEpithete($type) { |
if (!array_key_exists($type, $this->abbr)) { |
$this->abbr[$type] = $type; |
} |
} |
private function ajouterBaliseInfraGen() { |
$html = ''; |
if ($this->verifierTypeInfraGen()) { |
$html = $this->ajouterBaliseTypeInfraGen(); |
} else { |
if ($this->avoirInfo('epithete_infra_generique')) { |
$html = sprintf($this->infraGenTpl, $this->compo_nom['epithete_infra_generique']); |
} |
} |
return $html; |
} |
private function verifierTypeInfraGen() { |
$ok = false; |
if ($this->compo_nom['type_epithete'] != '' && $this->compo_nom['epithete_infra_generique'] != '') { |
$this->ajouterTypeEpithete($this->compo_nom['type_epithete']); |
$ok = true; |
} |
return $ok; |
} |
private function ajouterBaliseTypeInfraGen() { |
$html = ''; |
$type = $this->compo_nom['type_epithete']; |
if ($type == 'agg.') { |
// Ajout de l'infra gen avant le type s'il est égal à agg. |
$html = ' '.$this->ajouterBaliseInfraGen(). |
' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type); |
} else { |
$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type). |
' '.$this->ajouterBaliseInfraGen(); |
} |
return $html; |
} |
private function ajouterBaliseTypeInfraSp() { |
$html = ''; |
$type = $this->compo_nom['type_epithete']; |
$infraSp = $this->compo_nom['epithete_infra_sp']; |
if ($infraSp != '') { |
if ($type != '') { |
$this->ajouterTypeEpithete($type); |
$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type); |
} else { |
$message = "Nom #{$this->num} contient un épithète infra-spécifique mais son type n'est pas renseigné."; |
throw new Exception($message); |
} |
} |
return $html; |
} |
private function ajouterCultivarGpComm() { |
$html = ''; |
if ($this->avoirInfo('cultivar_groupe')) { |
$html .= ' '.$this->ajouterCultivarGroupe(); |
} |
if ($this->avoirInfo('nom_commercial')) { |
$html .= ' '.sprintf($this->commTpl, $this->compo_nom['nom_commercial']); |
} |
if ($this->avoirInfo('cultivar')) { |
$html .= ' '.sprintf($this->cvarTpl, $this->compo_nom['cultivar']); |
} |
return $html; |
} |
private function avoirInfo($valeur) { |
return (isset($this->compo_nom[$valeur]) && $this->compo_nom[$valeur] != '') ? true : false; |
} |
/** |
* Permet d'ajouter les groupes de cultivar en fonction de la présence d'un cultivar et de la présence d'un grex |
* |
* L'ensemble des individus obtenu par une fécondation particulière s'appelle un le Grex (que pour les orchidées). |
* Au sein du grex, certains individus peuvent se distinguer par des formes, des coloris ou autres qui font que |
* l'obtenteur du grex va les sélectionner. |
* les noms de groupes de cultivars sont suivis de l'abréviation « Gp » et placés entre parenthèses |
* les noms de grex, s'ils sont utilisés devant une épithète de cultivar, ne se mettent pas entre parenthèses |
* ex : Cymbidium Alexanderi gx 'Westonbirt' (cultivar_groupe = Alexanderi gx) ; |
* les noms de groupe se mettent entre parenthèses s'ils sont devant une épithète de cultivar |
* ex : Dracaena fragrans (Deremenis Gp) 'Christianne' (cultivar_groupe = Deremenis) |
* Un grex peut contenir des groupes (rédaction d'un exemple de l'ICNCP) |
* ex : × Rhyncosophrocattleya Marie Lemon Stick grex Francis Suzuki Group |
* ou : × Rhyncosophrocattleya Marie Lemon Stick gx Francis Suzuki Gp |
* @param unknown_type $val |
* |
*/ |
private function ajouterCultivarGroupe() { |
$html = ''; |
// si le champ cultivar_groupe n'est pas vide |
if ($this->avoirInfo('cultivar_groupe')) { |
$groupe = trim($this->compo_nom['cultivar_groupe']); |
// Sélection des templates |
$tplGx = $this->gxTpl; |
$tplGpGx = $this->gpGxSansCvarTpl; |
$tplGp = $this->gpSansCvarTpl; |
// s'il y a un cultivar, on ajoute des parenthèses au groupe (mais pas au grex) |
if ($this->avoirInfo('cultivar')) { |
$tplGpGx = $this->gpGxAvecCvarTpl; |
$tplGp = $this->gpAvecCvarTpl; |
} |
// Création du HTML du groupe de cultivar |
if (strrpos($groupe, ' gx ') !== false) {//si le grex est composé de groupe |
$gpEtGx = explode(' gx ', $groupe); |
$html = sprintf($tplGpGx, $gpEtGx[0], $gpEtGx[1]); |
} else if (preg_match('/ gx$/', $groupe)) {//s'il y a un grex et pas de groupe |
$gx = str_replace(' gx', '', $groupe); |
$html = sprintf($tplGx, $gx); |
} else { //s'il n'y a pas de grex mais un groupe |
$html = sprintf($tplGp, $groupe); |
} |
} |
return $html; |
} |
/** |
* |
* Permet de repérer s'il s'agit d'un hybride (infra-sp, genre, sp) ou d'une chimère. |
* @param unknown_type $val |
* @param unknown_type $type |
*/ |
private function verifierHybridite($epithete, $type) { |
$html = ''; |
if ($epithete != '') { |
if (substr($epithete, 0, 2) == 'x ') { |
$hybride = str_replace('x ', '', $epithete); |
$html = ' '.sprintf($this->hybrideTpl, $type, $hybride); |
} elseif (substr($epithete, 0, 2) == '+ ') { |
$hybride = str_replace('+ ', '', $epithete); |
$html = ' '.sprintf($this->chimereTpl, $type, $hybride); |
} else if (substr_count($epithete, ' x ') > 1) {// Cas d'une formule d'hybridité comprenant des parents hybrides |
$html = ' '.$this->insererBaliseFormuleHyb($epithete); |
} elseif (substr_count($epithete, ' x ') == 1) {// Cas d'une formule d'hybridité simple |
$html = ' '.$this->ajouterFomuleHybridite($epithete, $type); |
} else {// Autre cas... |
$html = ' '.sprintf($this->hybriditeTpl, $type, $epithete); |
} |
} |
return $html; |
} |
private function ajouterFomuleHybridite($formule, $type) { |
$tab_x = explode(' x ', $formule); |
$formule_hyb = array(); |
switch ($type) { |
case 'gen' : |
foreach ($tab_x as $hyb) { |
$formule_hyb[] = sprintf($this->genTpl, $hyb); |
} |
break; |
case 'sp' : |
foreach ($tab_x as $hyb) { |
if (substr_count($hyb, ' ') >= 1) { |
list($gen, $sp) = explode(' ', $hyb); |
$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp); |
} else if (preg_match('/^[A-Z]/', $hyb)) { |
$gen = $hyb; |
$formule_hyb[] = sprintf($this->genTpl, $gen); |
} |
} |
break; |
case 'infra-sp' : |
foreach ($tab_x as $hyb) { |
list($gen, $sp, $typeEpithete, $infraSp) = explode (' ', $hyb); |
if (isset($infraSp)) { |
$formule_hyb[] = sprintf($this->infraSpFHTpl, $gen, $sp, $this->abbr[$typeEpithete], $typeEpithete, $infraSp); |
} else { |
$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp); |
} |
} |
break; |
default : break; |
} |
return $this->insererBaliseFormuleHyb(implode(' x ', $formule_hyb)); |
} |
private function insererBaliseFormuleHyb($formule) { |
return sprintf($this->formuleHybTpl, $formule); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/Outils.php |
---|
New file |
0,0 → 1,86 |
<?php |
class Outils { |
public static function recupererTableauConfig($parametres) { |
$tableau = array(); |
$tableauPartiel = explode(',', $parametres); |
$tableauPartiel = array_map('trim', $tableauPartiel); |
foreach ($tableauPartiel as $champ) { |
if (strpos($champ, '=') === false) { |
$tableau[] = $champ; |
} else { |
list($cle, $val) = explode('=', $champ); |
$clePropre = trim($cle); |
$valeurPropre = trim($val); |
$tableau[$clePropre] = $valeurPropre; |
} |
} |
return $tableau; |
} |
public static function extraireRequetes($contenuSql) { |
$requetesExtraites = preg_split("/;\e*\t*\r*\n/", $contenuSql); |
if (count($requetesExtraites) == 0){ |
throw new Exception("Aucune requête n'a été trouvée dans le fichier SQL : $cheminFichierSql"); |
} |
$requetes = array(); |
foreach ($requetesExtraites as $requete) { |
if (trim($requete) != '') { |
$requetes[] = rtrim(trim($requete), ';'); |
} |
} |
return $requetes; |
} |
/** |
* Utiliser cette méthode dans une boucle pour afficher un message suivi du nombre de tour de boucle effectué. |
* Vous devrez vous même gérer le retour à la ligne à la sortie de la boucle. |
* |
* @param string le message d'information. |
* @param int le nombre de départ à afficher. |
* @return void le message est affiché dans la console. |
*/ |
public static function afficherAvancement($message, $depart = 0) { |
static $avancement = array(); |
if (! array_key_exists($message, $avancement)) { |
$avancement[$message] = $depart; |
echo "$message : "; |
$actuel =& $avancement[$message]; |
echo $actuel++; |
} else { |
$actuel =& $avancement[$message]; |
// Cas du passage de 99 (= 2 caractères) à 100 (= 3 caractères) |
$passage = 0; |
if (strlen((string) ($actuel - 1)) < strlen((string) ($actuel))) { |
$passage = 1; |
} |
echo str_repeat(chr(8), (strlen((string) $actuel) - $passage)); |
echo $actuel++; |
} |
} |
/** |
* @link http://gist.github.com/385876 |
*/ |
public function transformerTxtTsvEnTableau($file = '', $delimiter = "\t") { |
$str = file_get_contents($file); |
$lines = explode("\n", $str); |
$field_names = explode($delimiter, array_shift($lines)); |
foreach ($lines as $line) { |
// Skip the empty line |
if (empty($line)) continue; |
$fields = explode($delimiter, $line); |
$_res = array(); |
foreach ($field_names as $key => $f) { |
$_res[$f] = isset($fields[$key]) ? $fields[$key] : ''; |
} |
$res[] = $_res; |
} |
return $res; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/EfloreScript.php |
---|
New file |
0,0 → 1,89 |
<?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'eFlore |
protected 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; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/nom_sci/DecoupageCitation.php |
---|
New file |
0,0 → 1,106 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/** |
* Découpage des citations bibliographiques. |
* |
* Description : classe permettant de découper les citations. |
* |
//Auteur original : |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Tela-Botanica 1999-2009 |
* @licence GPL v3 & CeCILL v2 |
* @version $Id: DecoupageCitation.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
class DecoupageCitation extends Decoupage { |
private $expression_principale = array(); |
private $expression_page = array(); |
function DecoupageCitation() |
{ |
parent::__construct(); |
// Biblio |
$this->expression_principale[1] = '/^(?:, |)(?:('.$this->Com.')|)(?:('.$this->In.'), |)(?:'.$this->Bib.'|)(?: ('.$this->Inf.')|)$/u'; |
// Biblio à exclure |
$this->expression_principale[2] = '/^,? ('.$this->HomCourt.')$/u'; |
// Biblio : abréviation publi et précision (volume, tome, édition...) |
$this->expression_ref[1] = '/^([^,$]+)(.*)$/u';// |
// Pages début et fin |
$this->expression_page[1] = '/^(\d+)-(\d+)$/u';// |
// Page unique |
$this->expression_page[2] = '/^(\d+)(?:\.|)$/u';// |
} |
public function decouper($citation) |
{ |
$aso_nom_decompo = array( 'num_nomenc' => '', 'num_taxo' => '', |
'in_auteur' => '', 'abreviation' => '', 'precision' => '', |
'annee' => '', 'source_biblio_exclure' => '', |
'info_combinaison' => '', 'page_debut' => null,'page_fin' => null, |
'page_erreur_mark' => '', 'page_erreur_notes' => ''); |
$aso_nom_decompo['citation_complete'] = $citation; |
while ($citation != '') { |
$morceau = array(); |
if (preg_match($this->expression_principale[1], $citation, $morceau)) {// Biblio |
$aso_nom_decompo['info_combinaison'] = $morceau[1]; |
$aso_nom_decompo['in_auteur'] = $morceau[2]; |
$aso_publi = $this->decouperPubli($morceau[3]); |
$aso_nom_decompo['abreviation'] = $aso_publi['abreviation']; |
$aso_nom_decompo['precision'] = $aso_publi['precision']; |
$aso_nom_decompo['pages'] = $morceau[4]; |
$aso_pages = $this->decouperPages($morceau[4]); |
$aso_nom_decompo['page_debut'] = $aso_pages['page_debut']; |
$aso_nom_decompo['page_fin'] = $aso_pages['page_fin']; |
$aso_nom_decompo['page_erreur_mark'] = $aso_pages['erreur_mark']; |
$aso_nom_decompo['page_erreur_notes'] = $aso_pages['erreur_notes']; |
$aso_nom_decompo['annee'] = $morceau[5]; |
$citation = $morceau[6]; |
} else if (preg_match($this->expression_principale[2], $citation, $morceau)) {// Nom d'sp. |
$aso_nom_decompo['source_biblio_exclure'] = $morceau[1]; |
$citation = $morceau[2]; |
} else {// Erreurs |
$aso_nom_decompo['erreur_mark'] = 'erreur'; |
$aso_nom_decompo['erreur_notes'] = $citation; |
$citation = ''; |
} |
} |
return $aso_nom_decompo; |
} |
public function decouperPubli($ref) |
{ |
$ref = trim($ref); |
$aso_ref = array('abreviaton' => null,'precision' => null, 'erreur_mark' => '', 'erreur_notes' => ''); |
if (preg_match($this->expression_ref[1], $ref, $morceau)) { |
$aso_ref['abreviation'] = $morceau[1]; |
$aso_ref['precision'] = preg_replace('/^\s*,\s*/', '', $morceau[2]); |
} else {// Erreurs |
$aso_ref['erreur_mark'] = 'erreur'; |
$aso_ref['erreur_notes'] = $ref; |
} |
return $aso_ref; |
} |
public function decouperPages($pages) |
{ |
$pages = trim($pages); |
$aso_pages = array('page_debut' => null,'page_fin' => null, 'erreur_mark' => '', 'erreur_notes' => ''); |
if (preg_match($this->expression_page[1], $pages, $morceau)) { |
$aso_pages['page_debut'] = $morceau[1]; |
$aso_pages['page_fin'] = $morceau[2]; |
} else if (preg_match($this->expression_page[2], $pages, $morceau)) { |
$aso_pages['page_debut'] = $morceau[1]; |
} else {// Erreurs |
$aso_pages['erreur_mark'] = 'erreur'; |
$aso_pages['erreur_notes'] = $pages; |
} |
return $aso_pages; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/nom_sci/Decoupage.php |
---|
New file |
0,0 → 1,160 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/** |
* Découpage |
* |
* Description : classe abstraite mettant en comun des expressions régulière pour le découpage des noms latins. |
* |
//Auteur original : |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Tela-Botanica 1999-2009 |
* @licence GPL v3 & CeCILL v2 |
* @version $Id: Decoupage.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
abstract class Decoupage { |
protected $min = '[a-z\x{E0}-\x{FF}\x{153}]';// Lettres minuscules : a à z et à à ÿ et œ |
protected $maj = "[A-Z'\x{C0}-\x{DF}\x{152}]";// Lettres majuscules : A à Z, ' et À à ß et Œ |
protected $hyb = '[+xX]'; |
protected $SupraSp;// Nom de type suprasp. |
protected $GenHy;// Hybride intergénérique |
protected $Gen;// Genre |
protected $Dou = '(?:\(\?\)|\?)';// Doute |
protected $Epi_cv;// Epithete de cultivar |
protected $Epi_nn_hy = '(?:nsp\.|)';// Epithète non nommé hybride |
protected $Epi_nn = '(?:sp\.[1-9]?|spp\.|)';// Epithète non nommé |
protected $Epi;// Epithete |
//------------------------------------------------------------------------------------------------------------// |
protected $Ran_ig = '[Ss]ect\.|subg(?:en|)\.|ser\.|subser\.';// Rang taxonomique infragénérique de type : sous-genre |
protected $Ran_ig_gr = 'gr\.';// Rang taxonomique infragénérique de type : groupe |
protected $Ran_ig_agg = 'agg\.';// Rang taxonomique infragénérique de type : aggrégat |
protected $Ran_bo_i1 = 'subsp\.';// Rang taxonomique infraspécifique de niveau 1 |
protected $Ran_bo_i2 = 'var\.|subvar\.';// Rang taxonomique infraspécifique de niveau 2 |
protected $Ran_bo_i3 = 'f\.|fa\.|fa|forma';// Rang taxonomique infraspécifique de niveau 3 |
protected $Ran_bo_i4 = 'race|prole|proles|prol\.';// Rang taxonomique infraspécifique de niveau 4 |
protected $Ran_bo;// Rang taxonomique infraspécifique botanique non hybride |
protected $Ran_hy_i1 = 'n-subsp\.|\[subsp\.\]|\[n-subsp\.\]';// Rang taxonomique infraspécifique hybride de niveau 1 |
protected $Ran_hy_i2 = '\[var\.\]|n-var\.|\[n-var\.\]';// Rang taxonomique infraspécifique hybride de niveau 2 |
protected $Ran_hy_i3 = '';// Rang taxonomique infraspécifique hybride de niveau 3 |
protected $Ran_hy_i4 = 'n-proles\.';// Rang taxonomique infraspécifique hybride de niveau 4 |
protected $Ran_hy;// Rang taxonomique infraspécifique hybridre |
protected $Ran_ht = 'convar\.|[cC]v\.';// Rang taxonomique horticole |
protected $Ran;// Rang taxonomique infraspécifique non hybride, hybride et horticole |
//------------------------------------------------------------------------------------------------------------// |
protected $Ini;// Initiale de prénoms |
protected $Pre;// Prénoms |
protected $Par = '(?i:de|des|le|la|de la|von|van|st\.|el)';// Particules |
protected $ParSsEs = "(?i:st\.-|d)";// Particules sans espace après |
protected $Nom; // Abreviation d'un nom d'auteur. Le "f." c'est pour "filius" et c'est collé au nom |
protected $NomSpe = '(?:[A-Z]\. (?:DC\.|St\.-Hil\.))|\(?hort\.\)?|al\.';// Prénom + nom spéciaux : "hort." est utilisé comme un nom d'auteur mais cela signifie "des jardins". "DC." est une exception deux majuscule suivi d'un point. |
protected $Int;// Intitulé d'auteurs (Prénom + Nom) |
//------------------------------------------------------------------------------------------------------------// |
protected $AutNo;// Intitulé auteur sans "ex", ni "&", ni "et", ni parenthèses |
protected $AutNoTa;// Intitulé auteur sans "ex", ni "&", ni "et" mais avec parenthèses possible pour la nomenclature |
protected $AutEx;// Intitulé auteur avec "ex" |
protected $et = '(?:&|et)'; |
protected $AutExEt;// Intitulé auteur avec "ex" et "&" ou "et" |
protected $AutEt;// Intitulé auteur avec "&" ou "et" et sans parenthèse spécifique à la nomenclature |
protected $AutEtTa;// Intitulé auteur avec "&" ou "et" et avec ou sans parenthèse spécifique à la nomenclature |
protected $AutBib;// Intitulés auteurs pour la biblio |
protected $AutInc = 'AUTEUR\?';// Intitulé auteur spéciaux pouvant être trouvés entre parenthèses |
protected $AutSpe;// Intitulé auteur spéciaux pouvant être trouvés entre parenthèses |
protected $AutSpeSe;// Intitulé auteur spéciaux type "sensu" |
protected $AutSpeTa;// Intitulé auteur spéciaux propre à la nomenclature |
protected $Aut;// Tous les intitulés auteurs possibles |
protected $Auteur;// Tous les intitulés auteurs possibles |
//------------------------------------------------------------------------------------------------------------// |
protected $ComEmend;// Commentaires nomenclaturaux |
protected $ComPp = 'p\.p\.';// Commentaires nomenclaturaux |
protected $Com;// Intitulé auteur spéciaux type "sensu" |
protected $ComNom = '\(?(?:hort\. non .*|sensu .*|auct\..*|comb\.\s*(?:nov\.|ined\.)|comb?\.\s*nov\.\s*provis\.|stat\.\s*provis\.|nov\.\s*stat\.|stat\.\s*nov\.|p\.p\.|emend\.)\)?'; |
//------------------------------------------------------------------------------------------------------------// |
protected $In;// In auteur |
protected $AneMoCo = 'janvier|fevrier|mars|avril|mai|juin|juillet|ao\x{FB}t|septembre|octobre|novembre|decembre'; //Mois devant l'année |
protected $AneMoAb = 'janv\.|f[e\x{E9}]v\.|sept\.|oct\.|d\x{E9}c\.'; //Mois devant l'année |
protected $AneBaSi = '(?:\d{4}|\d{4} ?\?|DATE \?)';// Date |
protected $AneBaCo = '(?:\d{4}-\d{4}|\d{4}-\d{2})';// Date |
protected $AneDo = '\?';// Doute |
protected $AneBa;// Date |
protected $AneSpe;// Date |
protected $Ane;// Date |
//------------------------------------------------------------------------------------------------------------// |
// Spécial BDNFF : |
protected $Date = ' \[.*\]'; |
protected $Num = '[0-9]|3\*|4\*';# Gestion des numéros de flore |
protected $NumAuteur;# Gestion des numéros de flore mélangés ou pas au nom d'auteur |
//------------------------------------------------------------------------------------------------------------// |
protected $BibBa;// Biblio de base : \x{B0} = ° \x{AB}\x{BB} = «» \x{26} = & |
protected $Bib;// Biblio de taxon |
protected $BibAu = '.+';// Biblio supplémentaire |
//------------------------------------------------------------------------------------------------------------// |
protected $ErrDet;// Biblio à exclure base |
//------------------------------------------------------------------------------------------------------------// |
protected $HomNon = 'non';// Homonymes à exclure : négation |
protected $HomBa;// Homonymes à exclure base |
protected $Hom;// Homonymes à exclure avec non et nec |
protected $HomCourt;// Homonymes à exclure avec non et nec avec expression régulière plus courte! |
//------------------------------------------------------------------------------------------------------------// |
protected $Inf = '.*';// Informations supplémentaires |
public function __construct() |
{ |
//mb_internal_encoding('UTF-8'); |
//mb_regex_encoding('UTF-8'); |
//setlocale(LC_ALL, 'fr-fr'); |
$this->SupraSp = '(?:'.$this->maj.$this->min.'+|'.$this->maj.$this->min.'+-'.$this->maj.$this->min.'+)';// Nom de type suprasp. |
$this->GenHy = "[Xx] $this->SupraSp";// Hybride intergénérique |
$this->Gen = "$this->SupraSp|$this->GenHy"; |
$this->Epi_cv = "$this->maj.(?:$this->min|-)+";// Epithete de cultivar |
$this->Epi_nn = $this->Epi_nn.$this->Epi_nn_hy; |
$this->Epi = "(?:(?:$this->min|-|')+|$this->Epi_nn)";// Epithete |
$this->Ran_ig = $this->Ran_ig.'|'.$this->Ran_ig_gr; |
$this->Ran_bo = "$this->Ran_bo_i1|$this->Ran_bo_i2|$this->Ran_bo_i3|$this->Ran_bo_i4";// Rang taxonomique infraspécifique botanique non hybride |
$this->Ran_hy = "$this->Ran_hy_i1|$this->Ran_hy_i2|$this->Ran_hy_i3|$this->Ran_hy_i4";// Rang taxonomique infraspécifique hybridre |
$this->Ran = "(?:$this->Ran_ig|$this->Ran_bo|$this->Ran_hy|$this->Ran_ht)";// Rang taxonomique infraspécifique non hybride, hybride et horticole |
$this->Ini = '(?:'.$this->maj.'[.]|'.$this->maj.$this->min.'+[.]?)';// Initiale de prénoms |
$this->Pre = $this->Ini.'{1,3}|'.$this->Ini.'[\- ]'.$this->Ini;// Prénoms |
$this->Nom = '(?:'.$this->maj."'".$this->maj.'|'.$this->maj.'|'.$this->maj.$this->min."+'".$this->min.'+)'.$this->min.'*[.]?(?: ?f\.|)'; |
$this->Int = "(?:(?:$this->Pre ?|)(?:$this->Par |$this->ParSsEs|)(?:$this->Nom|$this->Nom".'[\- .]'."$this->Nom)|$this->NomSpe)";// Intitulé d'auteurs (Prénom + Nom) |
$this->AutNo = "$this->Int";// Intitulé auteur sans "ex", ni "&", ni "et", ni parenthèses |
$this->AutNoTa = "$this->AutNo|$this->NomSpe $this->Int|\($this->Int\) $this->Int";// Intitulé auteur sans "ex", ni "&", ni "et" mais avec parenthèses possible pour la nomenclature |
$this->AutEx = "\($this->Int\) $this->Int ex $this->Int|\($this->Int ex $this->Int\) $this->Int|$this->Int ex $this->Int";// Intitulé auteur avec "ex" |
$this->AutExEt = "$this->Int $this->et $this->Int ex $this->Int|$this->Int $this->et $this->Int ex $this->Int $this->et $this->Int|$this->Int ex $this->Int $this->et $this->Int|\($this->Int ex $this->Int $this->et $this->Int\) $this->Int|\($this->Int ex $this->Int\) $this->Int $this->et $this->Int|\($this->Int $this->et $this->Int\) $this->Int ex $this->Int|$this->NomSpe $this->Int ex $this->Int";// Intitulé auteur avec "ex" et "&" ou "et" |
$this->AutEt = "$this->Int $this->et $this->Int";// Intitulé auteur avec "&" ou "et" et sans parenthèse spécifique à la nomenclature |
$this->AutEtTa = "\($this->Int\) $this->Int $this->et $this->Int|\($this->Int $this->et $this->Int\) $this->Int|$this->AutEt";// Intitulé auteur avec "&" ou "et" et avec ou sans parenthèse spécifique à la nomenclature |
$this->AutBib = "(?:$this->AutNo|$this->AutEt)";// Intitulés auteurs pour la biblio |
$this->AutSpe = "(?:sensu |)auct\.|auct\. mult\.|$this->AutInc";// Intitulé auteur spéciaux pouvant être trouvés entre parenthèses |
$this->AutSpeSe = "sensu $this->AutBib";// Intitulé auteur spéciaux type "sensu" |
$this->AutSpeTa = "$this->AutSpe|\((?:$this->AutSpe)\)|$this->AutSpeSe";// Intitulé auteur spéciaux propre à la nomenclature |
$this->Aut = "(?:$this->AutExEt|$this->AutEx|$this->AutEtTa|$this->AutSpeTa|$this->AutNoTa)";// Tous les intitulés auteurs possibles |
$this->Auteur = $this->Int.'|'.$this->Int.' '.$this->et.' '.$this->Int.'|(?:'.$this->Int.', )+'.$this->Int.' '.$this->et.' '.$this->Int;// Intitulé auteur avec "&" ou "et"; |
$this->ComEmend = "emend\. $this->AutBib";// Commentaires nomenclaturaux |
$this->Com = "$this->ComEmend|$this->ComPp";// Intitulé auteur spéciaux type "sensu" |
$this->In = "[iI]n $this->AutBib";// In auteur |
$this->AneBa = "$this->AneBaSi|$this->AneBaCo";// Date |
$this->AneSpe = "(?:$this->AneBa ?\[$this->AneBa\]|(?:$this->AneMoCo|$this->AneMoAb) $this->AneBaSi|$this->AneBaSi $this->AneBaSi)";// Date |
$this->Ane = "$this->AneBa||$this->AneDo|$this->AneSpe";// Date |
$this->BibBa = "(?:$this->maj$this->min*[.]?|in|hort\.)(?:$this->min*[.]?|[\d\/\- ,()'\x{B0}\x{26}\x{AB}\x{BB}[\]?])*";// Biblio de base : \x{B0} = ° \x{AB}\x{BB} = «» \x{26} = & |
$this->Bib = "([^:]+):(.+?)\(($this->Ane)\)";// Biblio de taxon |
$this->ErrDet = "($this->AutSpe,? non $this->Aut): ($this->Bib;?)+";// Biblio à exclure base |
$this->HomBa = "$this->Aut \($this->Ane\)";// Homonymes à exclure base |
$this->Hom = "$this->HomNon $this->HomBa(?: nec $this->HomBa)*?";// Homonymes à exclure avec non et nec |
$this->HomCourt = "$this->HomNon .+?(?: nec .+?)*?";// Homonymes à exclure avec non et nec avec expression régulière plus courte! |
$this->NumAuteur = $this->Num.'|(?:(?:'.$this->Num.'|'.$this->Auteur.'), )+(?:'.$this->Num.'|'.$this->Auteur.')';# Gestion des numéros de flore mélangés ou pas au nom d'auteur |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/nom_sci/DecoupageNomLatin.php |
---|
New file |
0,0 → 1,378 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/** |
* Découpage des noms latins |
* |
* Description : classe permettant de découper les noms latins. |
* |
//Auteur original : |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Tela-Botanica 1999-2009 |
* @licence GPL v3 & CeCILL v2 |
* @version $Id: DecoupageNomLatin.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
class DecoupageNomLatin extends Decoupage { |
private $expression_principale = array(); |
private $expression_complement = array(); |
function DecoupageNomLatin() |
{ |
parent::__construct(); |
// Genre et nom supragénérique |
$this->expression_principale[1] = "/^((?:$this->hyb |)$this->Gen)(?:( $this->Inf)|)$/u"; |
// Sp |
$this->expression_principale[2] = "/^((?:$this->hyb |)$this->Gen) ((?:($this->hyb) |$this->Dou|)(?:$this->Epi|$this->Dou))(?:((?:,| $this->Ran) $this->Inf)| agg\.|)$/u"; |
// Rang infragénérique et supraspécifique |
$this->expression_principale[3] = '/^('.$this->Gen.') ('.$this->Ran.') ('.$this->Gen.'|.'.$this->Epi.')(?:(, '.$this->Inf.')|)$/u'; |
// Hybride interspécifique |
$this->expression_principale[4] = "/^((?:$this->Gen) $this->Epi (?:($this->Ran) $this->Epi )?x $this->Epi(?: ($this->Ran) $this->Epi)?)$/u"; |
// Aggrégat |
$this->expression_principale[5] = "/^($this->Gen) ($this->Epi) (agg\.)(?:( $this->Inf)|)$/u";// |
// Epithète infra-spécifique |
$this->expression_complement[1] = "/^ ($this->Ran) ((?:($this->hyb) |$this->Dou|)(?:$this->Epi|$this->Dou))(?:((?:,| $this->Ran) $this->Inf)|)$/Uu"; |
// Cultivar |
$this->expression_complement[5] = "/^ ($this->Ran_ht) ((?:(?:$this->Epi_cv) ?)+)$/u"; |
} |
public function decouper($nom_latin) |
{ |
$aso_nom_decompo = array( 'nom_genre' => '', 'nom_sp' => '', 'auteur_sp' => '', 'nom_complement' => '', |
'type_infrasp' => '', 'nom_infrasp' => '', |
'num_nomenc' => '', 'num_taxo' => '', 'rang_taxonomique' => '', |
'nom_courant' => '', 'nom_superieur' => '', 'agg' => ''); |
$aso_nom_decompo['nom_complet'] = $nom_latin; |
while ($nom_latin != '') { |
$morceau = array(); |
if (preg_match($this->expression_principale[4], $nom_latin, $morceau)) {// Formule d'hybridation |
// Nous tentons de déterminer le rang de l'hybride |
if (isset($morceau[2]) && isset($morceau[3]) && $morceau[2] == $morceau[3]) { |
$aso_nom_decompo['rang_taxonomique'] = $this->attribuerCodeRang('n-'.$morceau[2]); |
} else { |
$aso_nom_decompo['rang_taxonomique'] = 260;// Hybride instersp. |
} |
$aso_nom_decompo['mark_hybride_interspecifique'] = 'x'; |
$aso_nom_decompo['formule_hybridation'] = $morceau[0]; |
$nom_latin = ''; |
} else if (preg_match($this->expression_principale[5], $nom_latin, $morceau)) {// agg. |
$aso_nom_decompo['rang_taxonomique'] = 240;// agg. |
$aso_nom_decompo['nom_genre'] = $morceau[1]; |
$aso_nom_decompo['nom_sp'] = $morceau[2]; |
$aso_nom_decompo['agg'] = $morceau[3]; |
$nom_latin = $morceau[4]; |
$aso_nom_decompo['nom_superieur'] = $morceau[1]; |
$aso_nom_decompo['nom_courant'] = $morceau[2]; |
} else if (preg_match($this->expression_principale[2], $nom_latin, $morceau)) {// Nom d'sp. |
// Nous regardons si nous avons à faire à un hybride |
if (preg_match('/^'.$this->hyb.'$/', $morceau[3])) { |
$aso_nom_decompo['rang_taxonomique'] = 260;// hybride intersp. |
$aso_nom_decompo['mark_hybride_interspecifique'] = strtolower($morceau[3]); |
} else if (preg_match('/^'.$this->Epi_nn_hy.'$/', $morceau[2])) { |
$aso_nom_decompo['rang_taxonomique'] = 260;// hybride intersp. |
$aso_nom_decompo['mark_hybride_interspecifique'] = 'x'; |
} else { |
$aso_nom_decompo['rang_taxonomique'] = 250;// sp. |
} |
// Nous atribuons le genre |
$aso_nom_decompo['nom_genre'] = $morceau[1]; |
// Nous regardons si nous avons à faire à une phrase non nommé (ex : sp.1, spp., nsp.) |
if (preg_match('/^'.$this->Epi_nn.'$/', $morceau[2])) { |
$aso_nom_decompo['phrase_nom_non_nomme'] = $morceau[2];// hybride intersp. |
$aso_nom_decompo['nom_sp'] = ''; |
} else { |
$aso_nom_decompo['nom_sp'] = $morceau[2]; |
} |
$nom_latin = $morceau[4]; |
$aso_nom_decompo['nom_superieur'] = $morceau[1]; |
$aso_nom_decompo['nom_courant'] = $morceau[2]; |
} else if (preg_match($this->expression_principale[3], $nom_latin, $morceau)) {// Nom infragénérique et supraspécifique |
$aso_nom_decompo['nom_genre'] = $morceau[1]; |
$aso_nom_decompo['rang_taxonomique'] = $this->attribuerCodeRang($morceau[2]); |
// Nous regardons si nous avons à faire à un groupe |
if (preg_match('/^'.$this->Ran_ig_gr.'$/', $morceau[2])) { |
$aso_nom_decompo['nom_sp'] = $morceau[3]; |
} else { |
$aso_nom_decompo['nom_infra_genre'] = $morceau[3]; |
} |
$nom_latin = $morceau[4]; |
$aso_nom_decompo['nom_superieur'] = $morceau[1]; |
$aso_nom_decompo['nom_courant'] = $morceau[3]; |
} else if (preg_match($this->expression_principale[1], $nom_latin, $morceau)) {// Nom de genre et supragénérique |
$aso_nom_decompo['rang_taxonomique'] = $this->verifierTerminaisonLatine($nom_latin); |
$aso_nom_decompo['nom_suprasp'] = $morceau[1]; |
$nom_latin = $morceau[2]; |
$aso_nom_decompo['nom_superieur'] = null; |
$aso_nom_decompo['nom_courant'] = $morceau[1]; |
} else if (preg_match($this->expression_complement[5], $nom_latin, $morceau)) {// Cultivar |
$aso_nom_decompo['rang_cultivar'] = $this->attribuerCodeRang($morceau[1]); |
// Nous vérifions si nous avons à faire à un cultivar d'hybride |
if ($aso_nom_decompo['mark_hybride_interspecifique'] == 'x' && $aso_nom_decompo['rang_cultivar'] == 460) { |
$aso_nom_decompo['rang_cultivar'] = 470; |
} |
$aso_nom_decompo['cultivar'] = $morceau[2]; |
$nom_latin = ''; |
} else if (preg_match($this->expression_complement[1], $nom_latin, $morceau)) {// Nom infrasp. |
if (preg_match('/^'.$this->hyb.'$/', $morceau[3])) { |
$aso_nom_decompo['mark_hybride_interspecifique'] = strtolower($morceau[3]); |
} |
$aso_nom_decompo['rang_taxonomique'] = $this->attribuerCodeRang($morceau[1]); |
$aso_nom_decompo['type_infrasp'] = $morceau[1]; |
$aso_nom_decompo['nom_infrasp'] = $morceau[2]; |
$nom_latin = $morceau[4]; |
$aso_nom_decompo['nom_superieur'] = $aso_nom_decompo['nom_courant']; |
$aso_nom_decompo['nom_courant'] = $morceau[2]; |
} else {// Erreurs |
$aso_nom_decompo['erreur_mark'] = 'erreur'; |
$aso_nom_decompo['erreur_notes'] = $nom_latin; |
$nom_latin = ''; |
} |
} |
return $aso_nom_decompo; |
} |
public function verifierTerminaisonLatine($nom_latin) |
{ |
if (preg_match('/^Plantae$/', $nom_latin)) {// Règne |
return 10; |
} else if (preg_match('/phyta$/', $nom_latin)) {// Embranchement ou Division |
return 30; |
} else if (preg_match('/phytina$/', $nom_latin)) {// Sous-Embranchement ou Sous-Division |
return 40; |
} if (preg_match('/opsida$/', $nom_latin)) {// Classe |
return 70; |
} else if (preg_match('/idae$/', $nom_latin)) {// Sous-Classe |
return 80; |
} else if (preg_match('/ales$/', $nom_latin)) {// Ordre |
return 100; |
} else if (preg_match('/ineae$/', $nom_latin)) {// Sous-Ordre |
return 110; |
} else if (preg_match('/aceae$/', $nom_latin)) {// Famille |
return 120; |
} else if (preg_match('/oideae$/', $nom_latin)) {// Sous-Famille |
return 130; |
} else if (preg_match('/eae$/', $nom_latin)) {// Tribu |
return 140; |
} else if (preg_match('/inae$/', $nom_latin)) {// Sous-Tribu |
return 150; |
} else if (preg_match('/^[A-Z]/', $nom_latin)) {// Genre |
return 160; |
} else { |
return 1; |
} |
} |
static function fournirTableauAbreviationRang($type = 'tout') |
{ |
$rang_supra_sp = array('subgen.', 'subg.', 'sect.');// l'abréviation du rang est suivi par un nom supra spécifique commençant par une majuscule |
$rang_supra_gr = array('gr.');// l'abréviation du rang est suivi par un nom ne commençant pas par une majuscule |
$rang_supra_agg = array('agg.');// le nom latin est terminé par l'abréviation du rang |
$rang_infra_sp = array( 'subsp.', 'n-subsp.', '[subsp.]', '[n-subsp.]', |
'var.', 'nvar.', '[var.]', |
'prol.', 'proles', 'n-proles.', |
'f.', 'fa', 'fa.', 'forma', |
'subvar.', 'convar.', |
'cv.', 'Cv.', |
'n-f.', 'n-fa', 'n-fa.', |
'subf.', 'subfa', 'subfa.'); |
if ($type == 'supra') { |
return $rang_supra_sp; |
} else if ($type == 'supra-gr') { |
return $rang_supra_gr; |
} else if ($type == 'supra-agg') { |
return $rang_supra_agg; |
} else if ($type == 'infra') { |
return $rang_infra_sp; |
} else if ($type == 'tout') { |
return array_merge($rang_supra_sp, $rang_supra_gr, $rang_supra_agg, $rang_infra_sp); |
} |
} |
static function actualiserCodeRang($code_rang) |
{ |
$aso_rang = array( '1' => '10', // Règne |
'3' => '20', // Sous-Règne |
'5' => '30', // Phylum |
'7' => '40', // Sub-Phylum |
'9' => '50', // division |
'15' => '60', // sous-division |
'20' => '70', // classe |
'25' => '80', // sous-classe |
'30' => '100', // ordre |
'35' => '110', // sous-ordre |
'40' => '120', // famille |
'45' => '130', // sous-famille |
'50' => '140', // tribu |
'55' => '150', // sous-tribu |
'60' => '160', // genre |
'62' => '170', // genre hybride (nouveau compatibilité flore Réunion) |
'65' => '180', // sous-genre |
'65' => '190', // section |
'75' => '200', // sous-section |
'80' => '210', // série |
'85' => '220', // sous-série |
'90' => '230', // groupe |
'95' => '240', // aggrégat |
'100' => '250', // espèce |
'102' => '260', // espèce hybride intragénérique |
'104' => '260', // espèce hybride intergénérique |
'110' => '280', // sous-espèce |
'112' => '300', // sous-espèce hybride : hybride entre deux sous-espèces d'une espèce non hybride ; exemple : Polypodium vulgare L. nsubsp. mantoniae (Rothm.) Schidlay (Polypodium vulgare L. subsp. vulgare x Polypodium vulgare L. subsp. prionodes (Aschers.) Rothm.). |
'113' => '310', // sous-espèce hybride : sous-espèce d'espèce hybride sans spécification du rang parental (subspecies) (voir ICBN, art. H.12.1). |
'114' => '300', // sous-espèce hybride : sous-espèce hybride d'espèce hybride (nothosubspecies) (voir ICBN, art. H.12.1) ; exemple : Mentha x piperita L. nsubsp. piperita (Mentha aquatica L. x Mentha spicata L. subsp. glabrata (Lej. et Court.) Lebeau). |
'115' => '300', // sous-espèce hybride |
'120' => '1', // infra2 |
'122' => '330', // prole, race : peu employé souvent issu de nom ancien (antérieur au code). |
'124' => '340', // prole, race hybride : peu employé souvent issu de nom ancien (antérieur au code). |
'132' => '350', // convarietas : si on le conscidère comme un rang intermédiaire entre la sous-espèce et la variété. Voir aussi n°200. |
'130' => '1', // infra3 : niveau infra-spécifique de troisième niveau, sans plus de précision. |
'140' => '360', // variété |
'142' => '380', // variété : hybride entre deux variétés d'une espèce non hybride. |
'143' => '390', // variété : variété d'espèce hybride sans spécification du rang parental (varietas) (voir ICBN, art. H.12.1); exemple : Populus x canadensis Moench var. marilandica (Poir.) Rehder. |
'144' => '380', // variété : variété hybride d'espèce hybride (nothovarietas) ; exemple : Salix x sepulcralis Simonk. nvar. chrysocoma (Dode) Meikle. |
'145' => '380', // variété hybride |
'150' => '410', // sous-variété |
'160' => '420', // forme |
'162' => '430', // forme : hybride entre deux formes d'une espèce non hybride. |
'163' => '430', // forme : forme d'espèce hybride sans spécification du rang parental (forma) (voir ICBN, art. H.12.1); exemple : Mentha x piperita L. f. hirsuta Sole. |
'164' => '430', // forme : forme hybride d'espèce hybride (nothoforma). |
'170' => '440', // sous-forme |
'200' => '450', // groupe de cultivar |
'210' => '460', // cultivar |
'220' => '470', // cultivar d'hybride |
'0' => '480' // clade |
); |
return $aso_rang[$code_rang]; |
} |
public function attribuerCodeInfra($str_abreviation_type_infra) |
{ |
$aso_code_infra = array('type' => '', 'code' => 0, 'rang' => 2 ); |
switch ($str_abreviation_type_infra) { |
case 'subgen.' : |
case 'subg.' : |
$aso_code_infra['rang'] = 180; |
break; |
case 'sect.' : |
$aso_code_infra['rang'] = 190; |
break; |
case 'gr.' : |
$aso_code_infra['rang'] = 230; |
break; |
case 'subsp.' : |
$aso_code_infra['type'] = 'infra1'; |
$aso_code_infra['code'] = 1; |
$aso_code_infra['rang'] = 280; |
break; |
case 'n-subsp.' : |
$aso_code_infra['type'] = 'infra1'; |
$aso_code_infra['code'] = 2; |
$aso_code_infra['rang'] = 300; |
break; |
case '[subsp.]' : |
$aso_code_infra['type'] = 'infra1'; |
$aso_code_infra['code'] = 3; |
$aso_code_infra['rang'] = 290; |
break; |
case '[n-subsp.]' : |
$aso_code_infra['type'] = 'infra1'; |
$aso_code_infra['code'] = 4; |
$aso_code_infra['rang'] = 310; |
break; |
case 'var.' : |
$aso_code_infra['type'] = 'infra2'; |
$aso_code_infra['code'] = 1; |
$aso_code_infra['rang'] = 360; |
break; |
case '[var.]' : |
$aso_code_infra['type'] = 'infra2'; |
$aso_code_infra['code'] = 2; |
$aso_code_infra['rang'] = 370; |
break; |
case 'n-var.' : |
$aso_code_infra['type'] = 'infra2'; |
$aso_code_infra['code'] = 3; |
$aso_code_infra['rang'] = 380; |
break; |
case 'nvar.' : |
$aso_code_infra['type'] = 'infra2'; |
$aso_code_infra['code'] = 3; |
$aso_code_infra['rang'] = 384; |
break; |
case '[n-var.]' : |
$aso_code_infra['type'] = 'infra2'; |
$aso_code_infra['code'] = 5; |
$aso_code_infra['rang'] = 390; |
break; |
case 'prol.' : |
case 'proles' : |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 2; |
$aso_code_infra['rang'] = 330; |
break; |
case 'n-proles' : |
case 'n-proles.' : |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 1; |
$aso_code_infra['rang'] = 340; |
break; |
case 'f.': |
case 'fa': |
case 'fa.': |
case 'forma': |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 3; |
$aso_code_infra['rang'] = 420; |
break; |
case 'subvar.' : |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 4; |
$aso_code_infra['rang'] = 410; |
break; |
case 'convar.' : |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 5; |
$aso_code_infra['rang'] = 350; |
break; |
case 'cv.': |
case 'Cv.': |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 6; |
$aso_code_infra['rang'] = 460; |
break; |
case 'n-f.': |
case 'n-fa': |
case 'n-fa.': |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 7; |
$aso_code_infra['rang'] = 430; |
break; |
case 'subf.': |
case 'subfa': |
case 'subfa.': |
$aso_code_infra['type'] = 'infra3'; |
$aso_code_infra['code'] = 8; |
$aso_code_infra['rang'] = 440; |
break; |
default: |
$aso_code_infra['erreur_mark'] = 'erreur'; |
$aso_code_infra['erreur_notes'] = $str_abreviation_type_infra; |
$aso_code_infra['rang'] = 2; |
} |
return $aso_code_infra; |
} |
public function attribuerCodeRang($str_abreviation_type_infra) |
{ |
$aso_code_infra = $this->attribuerCodeInfra($str_abreviation_type_infra); |
return $aso_code_infra['rang']; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/nom_sci/DecoupageAuteur.php |
---|
New file |
0,0 → 1,189 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/** |
* Découpage des intitulés auteurs |
* |
* Description : classe permettant de découper les intitulés d'auteurs. |
* |
//Auteur original : |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Tela-Botanica 1999-2009 |
* @licence GPL v3 & CeCILL v2 |
* @version $Id: DecoupageAuteur.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
class DecoupageAuteur extends Decoupage { |
private $expression = array(); |
private $expression_in = array(); |
public function __construct() |
{ |
parent::__construct(); |
$this->expresion[2] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.') ex ('.$this->Auteur.')('.$this->Date.')?\s*$/u'; |
$this->expresion[3] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.')('.$this->Date.')?\s*$/u'; |
$this->expresion[5] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.')('.$this->Date.')?\s*$/u'; |
$this->expresion[6] = '/^\s*('.$this->Auteur.')('.$this->Date.')?\s*$/u'; |
$this->expresion[7] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u'; |
$this->expresion[8] = '/^\s*\(('.$this->Auteur.') ex ('.$this->Auteur.')\) ('.$this->ComNom.')\s*$/u'; |
$this->expresion[9] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u'; |
$this->expresion[10] = '/^\s*\(('.$this->Auteur.')\) ('.$this->ComNom.')\s*$/u'; |
$this->expresion[11] = '/^\s*('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u'; |
$this->expresion[12] = '/^\s*('.$this->ComNom.')\s*$/u'; |
$this->expresion[13] = '/^\s*\(('.$this->Auteur.')\) ('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u'; |
$this->expresion[14] = '/^\s*\(('.$this->Auteur.') ex ('.$this->Auteur.')\) ('.$this->InAut.')\s*$/u'; |
$this->expresion[15] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u'; |
$this->expresion[16] = '/^\s*\(('.$this->Auteur.')\) ('.$this->InAut.')\s*$/u'; |
$this->expresion[17] = '/^\s*('.$this->Auteur.') ('.$this->InAut.')\s*$/u'; |
$this->expresion[18] = '/^\s*('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u'; |
$this->expresion[19] = '/^\s*('.$this->InAut.')\s*$/u'; |
$this->expresion_in[1] = '/^\s*[iI]n ('.$this->Auteur.') ?('.$this->ComNom.')?\s*$/u'; |
$this->expresion_in[2] = '/^\s*[iI]n ('.$this->NumAuteur.') ?('.$this->ComNom.')?\s*$/u'; |
} |
public function decouper($str_intitule) |
{ |
$aso_intitule = array( 'auteur_basio_ex' => '', 'auteur_basio' => '', |
'auteur_modif_ex' => '', 'auteur_modif' => '', |
'date' => '', 'annee' => '', 'commentaires_nomenclaturaux' => '', |
'citation_in_auteur' => '', 'integration_ok' => 1, |
'erreur_mark' => '', 'erreur_notes' => ''); |
if ($str_intitule != '') { |
$morceau = array(); |
//Gestion des intitulés auteurs SANS commentaires nomenclaturaux |
if (preg_match($this->expresion[6], $str_intitule, $morceau)) { |
$aso_intitule['auteur_basio'] = $morceau[1]; |
$aso_intitule['date'] = $morceau[2]; |
$aso_date = $this->decouperDate($aso_intitule['date']); |
$aso_intitule['annee'] = $aso_date['annee']; |
} else if (preg_match($this->expresion[5], $str_intitule, $morceau)) { |
$aso_intitule['auteur_basio_ex'] = $morceau[1]; |
$aso_intitule['auteur_basio'] = $morceau[2]; |
$aso_intitule['date'] = $morceau[3]; |
$aso_date = $this->decouperDate($aso_intitule['date']); |
$aso_intitule['annee'] = $aso_date['annee']; |
} else if (preg_match($this->expresion[3], $str_intitule, $morceau)) { |
$aso_auteur = $this->decouperAuteurEx($morceau[1]); |
$aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex']; |
$aso_intitule{'auteur_basio'} = $aso_auteur['auteur']; |
$aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark']; |
$aso_intitule['erreur_notes'] = $str_intitule; |
$aso_intitule{'auteur_modif'} = $morceau[2]; |
$aso_intitule{'date'} = $morceau[3]; |
$aso_date = $this->decouperDate($aso_intitule['date']); |
$aso_intitule['annee'] = $aso_date['annee']; |
} else if (preg_match($this->expresion[2], $str_intitule, $morceau)) { |
$aso_auteur = $this->decouperAuteurEx($morceau[1]); |
$aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex']; |
$aso_intitule{'auteur_basio'} = $aso_auteur['auteur']; |
$aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark']; |
$aso_intitule['erreur_notes'] = $str_intitule; |
$aso_intitule{'auteur_modif_ex'} = $morceau[2]; |
$aso_intitule{'auteur_modif'} = $morceau[3]; |
$aso_intitule{'date'} = $morceau[4]; |
$aso_date = $this->decouperDate($aso_intitule['date']); |
$aso_intitule['annee'] = $aso_date['annee']; |
} else if (preg_match($this->expresion[7], $str_intitule, $morceau)) { |
// Gestion des intitulés auteurs AVEC commentaires nomenclaturaux |
$aso_auteur = $this->decouperAuteurEx($morceau[1]); |
$aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex']; |
$aso_intitule{'auteur_basio'} = $aso_auteur['auteur']; |
$aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark']; |
$aso_intitule['erreur_notes'] = $str_intitule; |
$aso_intitule{'auteur_modif'} = $morceau[2]; |
$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3]; |
} else if (preg_match($this->expresion[8], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio_ex'} = $morceau[1]; |
$aso_intitule{'auteur_basio'} = $morceau[2]; |
$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3]; |
} else if (preg_match($this->expresion[9], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio_ex'} = $morceau[1]; |
$aso_intitule{'auteur_basio'} = $morceau[2]; |
$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3]; |
} else if (preg_match($this->expresion[10], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio'} = $morceau[1]; |
$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[2]; |
} else if (preg_match($this->expresion[11], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio'} = $morceau[1]; |
$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[2]; |
} else if (preg_match($this->expresion[12], $str_intitule, $morceau)) { |
$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[1]; |
} else if (preg_match($this->expresion[13], $str_intitule, $morceau)) { |
// Gestion des intitulés auteurs AVEC "in" |
$aso_intitule{'auteur_basio'} = $morceau[1]; |
$aso_intitule{'auteur_modif'} = $morceau[2]; |
$aso_intitule{'citation_in_auteur'} = $morceau[3]; |
} else if (preg_match($this->expresion[14], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio_ex'} = $morceau[1]; |
$aso_intitule{'auteur_basio'} = $morceau[2]; |
$aso_intitule{'citation_in_auteur'} = $morceau[3]; |
} else if (preg_match($this->expresion[15], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio_ex'} = $morceau[1]; |
$aso_intitule{'auteur_basio'} = $morceau[2]; |
$aso_intitule{'citation_in_auteur'} = $morceau[3]; |
} else if (preg_match($this->expresion[16], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio'} = $morceau[1]; |
$aso_intitule{'citation_in_auteur'} = $morceau[2]; |
} else if (preg_match($this->expresion[17], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio'} = $morceau[1]; |
$aso_intitule{'citation_in_auteur'} = $morceau[2]; |
} else if (preg_match($this->expresion[18], $str_intitule, $morceau)) { |
$aso_intitule{'auteur_basio'} = $morceau[1]; |
$aso_intitule{'citation_in_auteur'} = $morceau[2]; |
} else if (preg_match($this->expresion[19], $str_intitule, $morceau)) { |
$aso_intitule{'citation_in_auteur'} = $morceau[1]; |
} else { |
$aso_intitule['erreur_mark'] = 'erreur'; |
$aso_intitule['erreur_notes'] .= $str_intitule; |
} |
} |
return $aso_intitule; |
} |
public function decouperIn($str_intitule) |
{ |
$aso_intitule = array( 'in_intitule_auteur' => '', 'in_commentaire_nomenclatural' => '', |
'erreur_mark' => '', 'erreur_notes' => ''); |
if ($str_intitule != '') { |
$morceau = array(); |
if (preg_match($this->expresion_in[1], $str_intitule, $morceau)) { |
$aso_intitule{'in_intitule_auteur'} = $morceau[1]; |
$aso_intitule{'in_commentaire_nomenclatural'} = $morceau[2]; |
} else if (preg_match($this->expresion_in[2], $str_intitule, $morceau)) { |
$aso_intitule{'in_intitule_auteur'} = $morceau[1]; |
$aso_intitule{'in_commentaire_nomenclatural'} = $morceau[2]; |
} else { |
$aso_intitule['erreur_mark'] = 'erreur'; |
$aso_intitule['erreur_notes'] .= $str_intitule; |
} |
} |
return $aso_intitule; |
} |
private function decouperAuteurEx($chaine) { |
$aso_retour = array('auteur_ex' => '', 'auteur' => '', 'erreur_mark' => '', 'erreur_notes' => ''); |
if (preg_match($this->expresion[5], $chaine, $morceau)) { |
$aso_retour['auteur_ex'] = $morceau[1]; |
$aso_retour['auteur'] = $morceau[2]; |
} else if (preg_match($this->expresion[6], $chaine, $morceau)) { |
$aso_retour['auteur'] = $morceau[1]; |
} else { |
$aso_retour['erreur_mark'] = 'erreur'; |
$aso_retour['erreur_notes'] = $chaine; |
} |
return $aso_retour; |
} |
private function decouperDate($chaine) |
{ |
$aso_retour = array('annee' => ''); |
if (preg_match('/^\[(\d{4})]\$/', $chaine, $morceau = array())) { |
$aso_retour['annee'] = $morceau[1]; |
} |
return $aso_retour; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/Conteneur.php |
---|
New file |
0,0 → 1,97 |
<?php |
/** |
* Le conteneur encapsule les classes servant aux scripts. |
* Il gère leur instanciation, ainsi que la récupération des paramètres depuis le fichier de configuration, et |
* de la ligne de commande. |
* |
* @category eFlore |
* @package Scripts |
* @subpackage Bibliotheque |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Copyright (c) 2014, Tela Botanica (accueil@tela-botanica.org) |
* @license CeCILL v2 http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt |
* @license GNU-GPL http://www.gnu.org/licenses/gpl.html |
*/ |
//TODO : initialiser tous les objets dans le conteneur |
class Conteneur { |
protected $parametres = array(); |
protected $partages = array(); |
public function __construct(array $parametres = null) { |
$this->parametres = is_null($parametres) ? array() : $parametres; |
} |
public function getParametre($cle) { |
$valeur = isset($this->parametres[$cle]) ? $this->parametres[$cle] : Config::get($cle); |
return $valeur; |
} |
/** |
* Obtenir un paramètre depuis le tableau de paramètres ou depuis le fichier de config |
* et le transformer en tableau s'il est de la forme : "cle=valeur,cle=valeur,..." |
* @param String $cle le nom du paramètre |
* @return la valeur du paramètre |
*/ |
public function getParametreTableau($cle) { |
$tableau = array(); |
$parametre = $this->getParametre($cle); |
if (empty($parametre) === false) { |
$tableauPartiel = explode(',', $parametre); |
foreach ($tableauPartiel as $champ) { |
if (strpos($champ, '=') === false) { |
$tableau[] = trim($champ); |
} else { |
list($cle, $val) = explode('=', $champ); |
$tableau[trim($cle)] = trim($val); |
} |
} |
} |
return $tableau; |
} |
public function setParametre($cle, $valeur) { |
$this->parametres[$cle] = $valeur; |
} |
public function getOutils() { |
if (!isset($this->partages['Outils'])){ |
$this->partages['Outils'] = new Outils(); |
} |
return $this->partages['Outils']; |
} |
public function getEfloreCommun() { |
if (!isset($this->partages['EfloreCommun'])){ |
$this->partages['EfloreCommun'] = new EfloreCommun($this); |
} |
return $this->partages['EfloreCommun']; |
} |
public function getMessages() { |
if (!isset($this->partages['Messages'])){ |
$this->partages['Messages'] = new Messages($this->getParametre('v')); |
} |
return $this->partages['Messages']; |
} |
public function getGenerateurNomSciHtml() { |
if (!isset($this->partages['GenerateurNomSciHtml'])){ |
$this->partages['GenerateurNomSciHtml'] = new GenerateurNomSciHtml(); |
} |
return $this->partages['GenerateurNomSciHtml']; |
} |
public function getRestClient() { |
if (!isset($this->partages['RestClient'])){ |
$this->partages['RestClient'] = new RestClient(); |
} |
return $this->partages['RestClient']; |
} |
public function getBdd() { |
if (!isset($this->partages['Bdd'])){ |
$this->partages['Bdd'] = new Bdd(); |
} |
return $this->partages['Bdd']; |
} |
} |
/tags/v5.8-aspergeraie/scripts/bibliotheque/LecteurExcel.php |
---|
New file |
0,0 → 1,64 |
<?php |
require_once dirname(__FILE__).DS.'excel_reader'.DS.'excel_reader2.php'; |
class LecteurExcel { |
private $lecteur = null; |
private $fichier = ''; |
private $feuille = 0; |
public function __construct($fichierExcel) { |
error_reporting(E_ALL ^ E_NOTICE); |
$this->fichier = $fichierExcel; |
$this->lecteur = new Spreadsheet_Excel_Reader(); |
$this->lecteur->setUTFEncoder('mb'); |
$this->lecteur->setOutputEncoding('UTF-8'); |
$this->lecteur->read($this->fichier); |
} |
public function getFichier() { |
return $this->fichier; |
} |
public function getFeuille() { |
return $this->feuille; |
} |
public function setFeuille($feuille) { |
return $this->feuille = $feuille; |
} |
public function getValeur($ligne, $colonne) { |
$val = $this->lecteur->val($ligne, $colonne, $this->feuille); |
return $val; |
} |
public function getValeurBrute($ligne, $colonne) { |
return $this->lecteur->raw($ligne, $colonne, $this->feuille); |
} |
public function getNbreLignes() { |
return $this->lecteur->rowcount($this->feuille); |
} |
public function getNbreColonne() { |
return $this->lecteur->colcount($this->feuille); |
} |
public function getDonnees() { |
return $this->lecteur->sheets[$this->feuille]; |
} |
public function afficherTxt() { |
foreach ($this->lecteur->sheets as $k => $data) { |
echo "Fichier : {$this->fichier}.\nFeuille $k\n"; |
foreach ($data['cells'] as $idRow => $row) { |
foreach ($row as $idCol => $cell) { |
echo $this->getValeur($idRow, $idCol)."\t"; |
} |
echo "\n"; |
} |
} |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/bibliotheque/VerificateurDonnees.php |
---|
New file |
0,0 → 1,135 |
<?php |
/** |
* |
* regroupement de fonctions de vérification des fichiers de données .tsv qui créé des fichiers log |
* les classes qui vérifie des données pour des projets peuvent l'étendre |
* @author mathilde |
* |
*/ |
abstract class VerificateurDonnees { |
private $projet; |
private $Message; |
private $Conteneur; |
private $ligne_num; //numéro de la ligne parcourue |
private $log = ''; //texte du journal |
protected $colonne_valeur; //valeur d'une colonne |
protected $colonne_num; // numéro d'un colonne |
private $nb_erreurs = 0; // nombre total |
private $erreurs_ligne; // consigne les erreurs d'une ligne : $erreurs_ligne[$num_col] = $valeur_erronnee |
public function __construct(Conteneur $conteneur, $projet) { |
$this->Conteneur = $conteneur; |
$this->Message = $this->Conteneur->getMessages(); |
$this->projet = $projet; |
} |
/** |
* |
* fonction principale qui parcourt chaque ligne du fichier pour en vérifier la cohérence |
* et déclenche l'écriture du fichier log |
* @param chaine, nom du fichier de données à vérifier |
*/ |
public function verifierFichier($fichierDonnees){ |
$lignes = file($fichierDonnees, FILE_IGNORE_NEW_LINES); |
if ($lignes != false) { |
foreach ($lignes as $this->ligne_num => $ligne) { |
$this->verifierErreursLigne($ligne); |
$this->Message->afficherAvancement("Vérification des lignes"); |
} |
echo "\n"; |
} else { |
$this->Message->traiterErreur("Le fichier $fichierDonnees ne peut pas être ouvert."); |
} |
if ($this->nb_erreurs == 0) { |
$this->ajouterAuLog("Il n'y a pas d'erreurs."); |
} |
$this->Message->traiterInfo($this->nb_erreurs." erreurs"); |
$this->ecrireFichierLog(); |
return $this->nb_erreurs; |
} |
/** |
* |
* découpe une ligne en colonnes pour en vérifier le contenu |
* @param chaine, une ligne du fichier |
*/ |
private function verifierErreursLigne($ligne){ |
$this->erreurs_ligne = array(); |
$colonnes = explode("\t", $ligne); |
if (isset($colonnes)) { |
foreach ($colonnes as $this->colonne_num => $this->colonne_valeur) { |
$this->definirTraitementsColonnes(); |
} |
} else { |
$message = "Ligne {$this->ligne_num} : pas de tabulation"; |
$this->ajouterAuLog($message); |
} |
$this->consignerErreursLigne(); |
} |
/** |
* |
* pour le traitement spécifique colonne par colonne |
* |
*/ |
abstract protected function definirTraitementsColonnes(); |
/** |
* |
* note dans le log s'il y a des erreurs dans une ligne |
*/ |
private function consignerErreursLigne() { |
$nbreErreursLigne = count($this->erreurs_ligne); |
$this->nb_erreurs += $nbreErreursLigne; |
if ($nbreErreursLigne != 0) { |
$this->ajouterAuLog("Erreurs sur la ligne {$this->ligne_num}"); |
$ligneLog = ''; |
foreach ($this->erreurs_ligne as $cle => $v){ |
$ligneLog .= "colonne $cle : $v - "; |
} |
$this->ajouterAuLog($ligneLog); |
} |
} |
/** |
* garde la trace d'une erreur dans une ligne |
* |
*/ |
protected function noterErreur() { |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur; |
} |
//+------------------------------------------------------------------------------------------------------+ |
// Gestion du Log |
private function ajouterAuLog($txt) { |
$this->log .= "$txt\n"; |
} |
private function ecrireFichierLog() { |
$base = Config::get('chemin_scripts'); |
$fichierLog = $base.'/modules/'.$this->projet.'/log/verification.log'; |
file_put_contents($fichierLog, $this->log); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/cli.php |
---|
New file |
0,0 → 1,37 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/** |
* Initialise le chargement et l'exécution des scripts |
* |
* Lancer ce fichier en ligne de commande avec : |
* <code>/opt/lampp/bin/php cli.php mon_script -a test</code> |
* |
//Auteur original : |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @author Delphine CAUQUIL <delphine@tela-botanica.org> |
* @copyright Tela-Botanica 1999-2008 |
* @licence GPL v3 & CeCILL v2 |
* @version $Id$ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
// Le fichier Framework.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application. |
// Sinon, rien ne sera chargé. |
// Chemin du fichier chargeant le framework requis |
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php'; |
if (!file_exists($framework)) { |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework"; |
trigger_error($e, E_USER_ERROR); |
} else { |
// Inclusion du Framework |
require_once $framework; |
// Ajout d'information concernant cette application |
Framework::setCheminAppli(__FILE__);// Obligatoire |
Framework::setInfoAppli(Config::get('info')); |
// Initialisation et lancement du script appelé en ligne de commande |
Cli::executer(); |
} |
?> |
/tags/v5.8-aspergeraie/scripts/tests/bibliotheque/GenerateurNomSciHtmlTest.php |
---|
New file |
0,0 → 1,82 |
<?php |
class GenerateurNomSciHtmlTest extends PHPUnit_Framework_TestCase { |
public static function setUpBeforeClass() { |
error_reporting(E_ALL); |
define('DS', DIRECTORY_SEPARATOR); |
require_once dirname(__FILE__).DS.'..'.DS.'..'.DS.'bibliotheque'.DS.'GenerateurNomSciHtml.php'; |
} |
public function testGenerer() { |
$nomsDecomposes[] = array( |
'num_nom' => 1009, |
'rang' => 340, |
'nom_supra_generique' => '', |
'genre' => 'Aegilops', |
'epithete_infra_generique' => '', |
'epithete_sp' => 'triuncialis', |
'type_epithete' => 'var.', |
'epithete_infra_sp' => 'nigroferruginea', |
'cultivar_groupe' => '', |
'nom_commercial' => '', |
'cultivar' => '', |
'annee' => '1923', |
'auteur' => 'Popova', |
'biblio_origine' => 'Trudy Prikl. Bot. Selekc., 13 : 476'); |
$generateur = new GenerateurNomSciHtml(); |
$nomsSciHtml = $generateur->generer($nomsDecomposes); |
$nomSciHtmlGenere = $nomsSciHtml[1009]; |
$nomSciHtmlAttendu = '<span class="sci"><span class="gen">Aegilops</span> <span class="sp">triuncialis</span> <abbr class="type_epithete" title="Variété">var.</abbr> <span class="infra-sp">nigroferruginea</span></span>'; |
$this->assertEquals($nomSciHtmlAttendu, $nomSciHtmlGenere); |
} |
public function testGenererHybride() { |
$nomsDecomposes[] = array( |
'num_nom' => 179, |
'rang' => 290, |
'nom_supra_generique' => '', |
'genre' => 'Acer', |
'epithete_infra_generique' => '', |
'epithete_sp' => 'x martinii', |
'type_epithete' => '', |
'epithete_infra_sp' => '', |
'cultivar_groupe' => '', |
'nom_commercial' => '', |
'cultivar' => '', |
'annee' => '1852', |
'auteur' => 'Jord.', |
'biblio_origine' => 'Pugill. Pl. Nov., 52' |
); |
$generateur = new GenerateurNomSciHtml(); |
$nomsSciHtml = $generateur->generer($nomsDecomposes); |
$nomSciHtmlGenere = $nomsSciHtml[179]; |
$nomSciHtmlAttendu = '<span class="sci"><span class="gen">Acer</span> <span class="hyb">x <span class="sp">martinii</span></span></span>'; |
$this->assertEquals($nomSciHtmlAttendu, $nomSciHtmlGenere); |
} |
public function testGenererChimere() { |
$nomsDecomposes[] = array( |
'num_nom' => 80380, |
'rang' => 290, |
'nom_supra_generique' => '', |
'genre' => '+ Cytisus', |
'epithete_infra_generique' => '', |
'epithete_sp' => 'adami', |
'type_epithete' => '', |
'epithete_infra_sp' => '', |
'cultivar_groupe' => '', |
'nom_commercial' => '', |
'cultivar' => '', |
'annee' => '1830', |
'auteur' => 'Poit.', |
'biblio_origine' => 'Ann. Soc. Hort. Paris, 7 : 96' |
); |
$generateur = new GenerateurNomSciHtml(); |
$nomsSciHtml = $generateur->generer($nomsDecomposes); |
$nomSciHtmlGenere = $nomsSciHtml[80380]; |
$nomSciHtmlAttendu = '<span class="sci"><span class="chimere">+ <span class="gen">Cytisus</span></span> <span class="sp">adami</span></span>'; |
$this->assertEquals($nomSciHtmlAttendu, $nomSciHtmlGenere); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/tests/bibliotheque/OutilsTest.php |
---|
New file |
0,0 → 1,63 |
<?php |
require_once dirname(__FILE__).'/../ScriptEflorePhpUnit.php'; |
class OutilsTest extends ScriptEflorePhpUnit { |
public function testRecupererTableauConfigAssociatif() { |
$chaineDeParametres = "param1=valeur1,\nparam2=valeur2"; |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres); |
$tableauDeParametresAttendus = array('param1' => 'valeur1','param2' => 'valeur2'); |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres); |
} |
public function testRecupererTableauConfigAssociatifAvecEspace() { |
$chaineDeParametres = "param1 =valeur1 , \nparam2 = valeur2"; |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres); |
$tableauDeParametresAttendus = array('param1' => 'valeur1','param2' => 'valeur2'); |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres); |
} |
public function testRecupererTableauConfigSimple() { |
$chaineDeParametres = "param1,\nparam2"; |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres); |
$tableauDeParametresAttendus = array('param1', 'param2'); |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres); |
} |
public function testRecupererTableauConfigSimpleAvecEspace() { |
$chaineDeParametres = " param1 ,\n param2 "; |
$tableauDeParametres = Outils::recupererTableauConfig($chaineDeParametres); |
$tableauDeParametresAttendus = array('param1', 'param2'); |
$this->assertEquals($tableauDeParametresAttendus, $tableauDeParametres); |
} |
public function testExtraireRequetes() { |
$contenuSql = "CREATE TABLE IF NOT EXISTS bdtfx_v1_01 (". |
"num_nom int(9) NOT NULL DEFAULT '0',". |
"num_nom_retenu varchar(9) CHARACTER SET utf8 DEFAULT NULL,". |
") ENGINE=MyISAM DEFAULT CHARSET=utf8;\n\n". |
"INSERT INTO bdtfx_meta (guid) VALUES". |
"('urn:lsid:tela-botanica.org:bdtfx:1.01');\n". |
"SELECT * FROM ma_table;"; |
$tableauDeRequetes = Outils::extraireRequetes($contenuSql); |
$tableauDeRequetesAttendus = array("CREATE TABLE IF NOT EXISTS bdtfx_v1_01 (". |
"num_nom int(9) NOT NULL DEFAULT '0',". |
"num_nom_retenu varchar(9) CHARACTER SET utf8 DEFAULT NULL,". |
") ENGINE=MyISAM DEFAULT CHARSET=utf8", |
"INSERT INTO bdtfx_meta (guid) VALUES". |
"('urn:lsid:tela-botanica.org:bdtfx:1.01')", |
"SELECT * FROM ma_table"); |
$this->assertEquals($tableauDeRequetesAttendus, $tableauDeRequetes); |
} |
public function testAfficherAvancement() { |
ob_start(); |
for ($i = 0; $i < 10; $i++) { |
$tableauDeRequetes = Outils::afficherAvancement("Test"); |
} |
$messageFinal = ob_get_clean(); |
$messageFinalAttendu = 'Test : 0'.chr(8).'1'.chr(8).'2'.chr(8).'3'.chr(8).'4'.chr(8).'5'.chr(8).'6'.chr(8).'7'.chr(8).'8'.chr(8).'9'; |
$this->assertEquals($messageFinalAttendu, $messageFinal); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/tests/bibliotheque/EfloreScriptTest.php |
---|
New file |
0,0 → 1,48 |
<?php |
require_once dirname(__FILE__).'/../ScriptEflorePhpUnit.php'; |
class EfloreScriptTest extends ScriptEflorePhpUnit { |
public function testChargerConfigDuProjetAvecFichiersIni() { |
$cheminRacine = realpath(dirname(__FILE__).'/../tmp/').'/'; |
if (!file_exists($cheminRacine.'test.ini')) { |
file_put_contents($cheminRacine.'test.ini', "[tables]\ntest=OK"); |
} |
$script = $this->getMock('EfloreScript', array('getScriptChemin', 'getProjetNom', 'executer')); |
$script->expects($this->any())->method('getScriptChemin')->will($this->returnValue($cheminRacine)); |
$script->expects($this->any())->method('getProjetNom')->will($this->returnValue('test')); |
$chargerConfigDuProjet = self::getProtectedMethode($script, 'chargerConfigDuProjet'); |
$chargerConfigDuProjet->invoke($script); |
$parametreConfig = Config::get('tables.test'); |
$this->assertEquals('OK', $parametreConfig); |
} |
public function testGetBdd() { |
$nomDuScript = 'Test'; |
$parametresCli = array('-a' => 'tester', '-v' => '3'); |
$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli)); |
$getBdd = self::getProtectedMethode($script, 'getBdd'); |
$bdd = $getBdd->invoke($script); |
$this->assertTrue(is_object($bdd)); |
$this->assertEquals('Bdd', get_class($bdd)); |
} |
public function testStopperLaBoucle() { |
$nomDuScript = 'Test'; |
$parametresCli = array('-a' => 'tester', '-v' => '3'); |
$script = $this->getClasseAbstraite('EfloreScript', array($nomDuScript, $parametresCli)); |
$stopperLaBoucle = self::getProtectedMethode($script, 'stopperLaBoucle'); |
for ($i = 0; $i < 100; $i++) { |
if ($stopperLaBoucle->invoke($script, '10')) { |
break; |
} |
} |
$this->assertEquals('9', $i); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/tests/ScriptEflorePhpUnit.php |
---|
New file |
0,0 → 1,92 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Classe contenant des méthodes : |
* - d'intialisation des tests, |
* - refactorisant le code des tests, |
* - facilitant les tests. |
* |
* @category php 5.3 |
* @package Tests/Scripts |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Copyright (c) 2011, Tela Botanica (accueil@tela-botanica.org) |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
* @version $Id$ |
*/ |
abstract class ScriptEflorePhpUnit extends PHPUnit_Framework_TestCase { |
public static function setUpBeforeClass() { |
error_reporting(E_ALL); |
self::chargerFramework(); |
} |
private static function chargerFramework() { |
$cheminRacine = realpath(dirname(__FILE__).'/../').'/'; |
$framework = $cheminRacine.'framework.php'; |
if (!file_exists($framework)) { |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework"; |
trigger_error($e, E_USER_ERROR); |
} else { |
// Inclusion du Framework |
require_once $framework; |
// Ajout d'information concernant cette application |
Framework::setCheminAppli($cheminRacine);// Obligatoire |
} |
} |
//+------------------------------------------------------------------------------------------------------+ |
// Méthodes facilitant les tests |
/** |
* Récupère un bouchon de classe abstraite. |
* Comment l'utiliser : |
* $classeAstraite = $this->getClasseAbstraite('MaClasse', array('param1', 'param2')); |
* $foo = $classeAstraite->methodeConcretePublique(); |
* |
* @param String $classeNom Le nom de la classe |
* @param Array $parametres Les paramètres à passer au constructeur. |
* @return Object Le bouchon de la classe abstraite |
*/ |
public function getClasseAbstraite($classeNom, Array $parametres) { |
$efloreScript = $this->getMockForAbstractClass($classeNom, $parametres); |
return $efloreScript; |
} |
/** |
* Récupère une méthode privée d'une classe pour tester/documenter. |
* Comment l'utiliser : |
* MyClass->foo(): |
* $cls = new MyClass(); |
* $foo = self::getPrivateMethode($cls, 'foo'); |
* $foo->invoke($cls, $...); |
* |
* @param object $objet Une instance de votre classe |
* @param string $methode Le nom de la méthode private |
* @return ReflectionMethod La méthode demandée |
*/ |
public static function getPrivateMethode($objet, $nomMethode) { |
$classe = new ReflectionClass($objet); |
$methode = $classe->getMethod($nomMethode); |
$methode->setAccessible(true); |
return $methode; |
} |
/** |
* Récupère une méthode protégée d'une classe pour tester/documenter. |
* Comment l'utiliser : |
* MyClass->foo(): |
* $cls = new MyClass(); |
* $foo = self::getProtectedMethode($cls, 'foo'); |
* $foo->invoke($cls, $...); |
* @param object $objet Une instance de votre classe |
* @param string $methode Le nom de la méthode protected |
* @return ReflectionMethod La méthode demandée |
*/ |
public static function getProtectedMethode($objet, $nomMethode) { |
return self::getPrivateMethode($objet, $nomMethode); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/tests/tmp |
---|
New file |
Property changes: |
Added: svn:ignore |
+test.defaut.ini |
+test.ini |
/tags/v5.8-aspergeraie/scripts/modules/sauvages/Sauvages.php |
---|
New file |
0,0 → 1,400 |
<?php |
/** Exemple lancement: |
* /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php sauvages -a chargerTous |
*/ |
class Sauvages extends EfloreScript { |
private $contenu_fichier = array(); |
protected $parametres_autorises = array( |
'-f' => array(true, true, 'Nom du fichier ou du dossier à traiter')); |
private $caracteresAccentues = array( |
'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', |
'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', |
'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', |
'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', |
'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', |
'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', |
'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', |
'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', |
'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', |
'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', |
'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', |
'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', |
'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', |
'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ'); |
private $caracteresNormaux = array( |
'A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', |
'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', |
'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', |
'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', |
'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', |
'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', |
'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', |
'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', |
'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', |
'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', |
'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', |
'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', |
'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o'); |
public function executer() { |
// Lancement de l'action demandée |
try { |
$this->initialiserProjet('sauvages'); |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->creerXmlTaxons(); |
$this->creerXmlCriteres(); |
break; |
case 'creerXmlCriteres' : |
$this->creerXmlCriteres(); |
break; |
case 'creerXmlTaxons' : |
$this->creerXmlTaxons(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
public function creerXmlCriteres() { |
$this->recupererContenuFichier(); |
$criteres_nom = $this->contenu_fichier[0]; |
unset($this->contenu_fichier[0]); |
$criteres_label = $this->contenu_fichier[1]; |
unset($this->contenu_fichier[1]); |
$description_label = $this->contenu_fichier[2]; |
unset($this->contenu_fichier[2]); |
$criteres_valeurs = $this->extraireValeurs(); |
$xml = $this->formerXmlCriteres($criteres_nom, $criteres_label, $description_label, $criteres_valeurs);//print_r($xml); |
file_put_contents("./xml_criteres.xml", $xml); |
} |
public function formerXmlCriteres($nom, $label, $description, $valeurs) { |
$xml='<keys> |
<groupe id="1"> |
<nom>Arbres</nom> |
<media>images/pictos/icone_arbre.png</media> |
<criteres>'; |
foreach ($label as $id=>$criteres) { |
if ($id > 3) { |
$xml .= '<critere id="1.'.$id.'"> |
<label>'.$criteres.'</label> |
<description>'.$description[$id].'</description> |
<valeurs>'; |
foreach ($valeurs[$id] as $id_val=>$valeur) { |
if ($valeur != "0") { |
$crit = str_replace(" ", "_", $this->supprimerAccents($nom[$id])); |
$val = str_replace(" ", "_", $this->supprimerAccents($valeur)); |
$image = $crit."_".$val; |
$xml .= '<valeur code="1.'.$id.'.'.$id_val.'" media="images/pictos/'.$image.'.png">'.$valeur.'</valeur>'; |
} |
} |
$xml .= '</valeurs></critere>'; |
} |
} |
$xml .= "</criteres> |
</groupe> |
</keys>"; |
return $xml; |
} |
private function extraireValeurs() { |
$valeurs = array(); |
foreach ($this->contenu_fichier as $ligne) { |
$i = 0; |
if ($ligne != "") { |
foreach ($ligne as $critere) { |
$valeur_multiple = explode("/", $critere); |
foreach ($valeur_multiple as $valeur) { |
if (!isset($valeurs[$i]) || !in_array(trim($valeur), $valeurs[$i])) { |
$valeurs[$i][] = trim($valeur); |
} |
} |
$i++; |
} |
} |
} |
return $valeurs; |
} |
public function creerXmlTaxons() { |
$this->recupererContenuFichier(); |
$criteres_label = array_flip($this->contenu_fichier[0]); |
unset($this->contenu_fichier[0]); |
unset($this->contenu_fichier[1]); |
unset($this->contenu_fichier[2]); |
$criteres_valeurs = $this->extraireValeurs(); |
$xml = $this->formerXmlTaxons($criteres_label, $criteres_valeurs); //print_r($xml); |
file_put_contents("./xml_taxons.xml", $xml); |
} |
public function formerXmlTaxons($criteres_label, $criteres_valeurs) { |
$xml='<?xml version="1.0" ?><TAXONS SUBJECT="XML">'; |
$rest = new RestClient(); |
foreach ($this->contenu_fichier as $id=>$taxon) { |
if ($taxon != "") { |
$infos_taxon = $this->rechercherInfosTaxon($rest, $taxon[$criteres_label["nom scientifique"]]); |
$xml .= '<TAXON id="'.$id.'" value="'. |
ucfirst($taxon[$criteres_label["nom vernaculaire"]]).'" sciName="'.trim($taxon[$criteres_label["nom scientifique"]]).'" groupe="1"> |
<DESCRIPTION>'.$infos_taxon["description"].'</DESCRIPTION> |
<PICTURES>'; |
if ($infos_taxon["images"] != array()) { |
if (isset($infos_taxon["images"][$taxon[$criteres_label["image priorite"]]])) { |
$auteur = $this->rechercherInfosAuteurImage($infos_taxon["images"][$taxon[$criteres_label["image priorite"]]], $rest).", www.tela-botanica.org, CC-Licence (by-sa)"; |
$xml .= '<PICTURE media="'.$infos_taxon["images"][$taxon[$criteres_label["image priorite"]]]["binaire.href"].'"><author>'.$auteur.'</author></PICTURE>'; |
unset($infos_taxon["images"][$taxon[$criteres_label["image priorite"]]]); |
} |
foreach ($infos_taxon["images"] as $image) { |
$auteur = $this->rechercherInfosAuteurImage($image, $rest).", www.tela-botanica.org, CC-Licence (by-sa)"; |
$xml .= '<PICTURE media="'.$image["binaire.href"].'"><author>'.$auteur.'</author></PICTURE>'; |
} |
} |
$xml .= '</PICTURES><CRITERIAS>'; |
for ($i=4; $i < count($taxon); $i++) { |
if (trim($taxon[$i]) !== "0") { |
$valeurs = array(); |
foreach (explode("/",$taxon[$i]) as $valeur) { |
$valeurs[] = '1.'.$i.'.'.array_search(trim($valeur), $criteres_valeurs[$i]); |
} |
$xml .= '<VALUE code="'.implode(',', $valeurs).'"/>'; |
} |
} |
$xml .= '</CRITERIAS></TAXON>'; |
} |
} |
$xml .= "</TAXONS>"; |
return $xml; |
} |
// interroge l'annuaire pour récupérer le pseudo |
private function rechercherInfosAuteurImage($image, $rest) { |
$courriel = $image["observation"]["auteur.courriel"]; |
$url_auteur = "http://www.tela-botanica.org/service:annuaire:utilisateur/identite-par-courriel/".$courriel; |
$reponse = $rest->consulter($url_auteur); |
$reponse = json_decode($reponse, true); |
if (isset($reponse[$courriel]) && $reponse[$courriel]["pseudoUtilise"] == true) { |
$auteur = $reponse[$courriel]["pseudo"]; |
} else{ |
$auteur = $image["observation"]["auteur.prenom"]." ".$image["observation"]["auteur.nom"]; |
} |
return $auteur; |
} |
private function rechercherInfosTaxon($rest, $ns) { |
$info = array("description" => "", "images" => array()); |
$reponse = $this->consulterWebService($rest, "bdtfx", |
"noms", "?retour.champs=nom_retenu.id,num_taxonomique&retour.tri=retenu&masque=".urlencode(trim($ns))); |
if (is_array($reponse["resultat"])) { |
$num_nom = $reponse["resultat"][key($reponse["resultat"])]["nom_retenu.id"]; |
$num_taxon = $reponse["resultat"][key($reponse["resultat"])]['num_taxonomique']; |
} |
$info["description"] = $this->rechercherDescription($num_taxon, $num_nom, $rest); |
$info["images"] =array(); |
$tags = array('fleur', 'feuille', 'rameau', 'port', 'fruit'); |
$cles = array(); |
foreach ($tags as $tag) { |
$url_image = "http://www.tela-botanica.org/service:del:0.1/images". |
"?masque.referentiel=bdtfx&masque.tag={$tag}&tri=votes&ordre=desc&protocole=3&navigation.limite=1&format=CRS&masque.nn=".$num_nom; |
$image = $rest->consulter($url_image); |
$image = json_decode($image, true); |
if ($image["resultats"] !== array()) { |
$info["images"][$tag]["binaire.href"] = $image["resultats"][key($image["resultats"])]["binaire.href"]; |
$info["images"][$tag]["observation"] = $image["resultats"][key($image["resultats"])]["observation"]; |
$cles[key($image["resultats"])] = ""; |
} |
} |
//si image taguée absente |
$url_image = "http://www.tela-botanica.org/service:del:0.1/images". |
"?masque.referentiel=bdtfx&tri=votes&ordre=desc&protocole=3&navigation.limite=5&format=CRS&masque.nn=".$num_nom; |
$reponse = $rest->consulter($url_image); |
$reponse = json_decode($reponse, true); |
if ($cles !== array()) { |
// supprimer les images communes au tag et les mieux notés |
$reponse["resultats"] = array_diff_key($reponse["resultats"], $cles); |
for ($i = 0; $i < 5-count($cles); $i++) { |
$image = array_shift($reponse["resultats"]); |
$info["images"][$i]["binaire.href"] = $image["binaire.href"]; |
$info["images"][$i]["observation"] = $image["observation"]; |
} |
} else { |
$info["images"] = $reponse["resultats"]; |
} |
return $info; |
} |
private function rechercherDescription($num_taxon, $num_nom, $rest) { |
$url_wiki = "http://www.tela-botanica.org/wikini/eFloreRedaction/api/rest/0.5/pages/SmartFloreBDTFXnt". |
$num_taxon."?txt.format=text/plain&txt.section.titre=Comment%20la%20reconnaître%20%3F"; |
$wiki = $rest->consulter($url_wiki); $wiki = json_decode($wiki, true); |
if ($wiki['texte'] != "" && strstr($wiki['texte'], 'Brève phrase sur son type biologique (simplifié)') === false ){ |
$description = $this->formaterSmartflore($wiki['texte']); |
} else { |
$coste = $this->consulterWebService($rest, "coste", "textes", "/bdtfx.nn:".$num_nom); |
if ($coste['resultats'] != array() && $coste['resultats'][key($coste["resultats"])]['texte'] != "") { |
$description = $this->formaterCoste($coste['resultats']); |
} else { |
$baseflor = $this->consulterWebService($rest, "baseflor", "informations", "/bdtfx.nn:".$num_nom); |
$description = $this->formaterBaseflor($baseflor); |
} |
} |
return $description; |
} |
//remplacement des \n par <br /> |
private function formaterSmartflore($texte) { |
$a_enlever = array(Chr(10).'=', '='.Chr(10), Chr(10).''.Chr(10), '*'); |
$texte = str_replace($a_enlever, '', $texte); |
$texte = str_replace(Chr(10), '<br />', $texte); |
//supprimer image et lien |
$texte = preg_replace('/\[\[http\:\/\/upload.*\.jpg [a-z| |A-Z]*\]\]/', '', $texte); |
$texte = str_replace('[[http://fr.wikipedia.org/wiki/Corymbe corymbes]]', 'corymbes', $texte); |
$texte = preg_replace('/\[\[SmartFlore.*[0-9] (.*)\]\]/', '\1', $texte); |
$texte = preg_replace('/\[\[http\:\/\/www\..* (.*)\]\]/', '\1', $texte); |
$texte = trim(str_replace('<br /><br />', '<br />', $texte)); |
return $texte; |
} |
private function formaterCoste($coste) { |
$texte = $this->mettreEnFormeCoste($coste[key($coste)]['texte']); |
return $texte; |
} |
static function mettreEnFormeCoste($texte) { |
$txt_fmt = array(); |
//decouper elements remarquables avant le texte |
self::separerNomScientifique_a_NomCommun($texte, $txt_fmt); |
$txt_fmt = array(); |
$texte = preg_replace('/\//','',$texte); |
//decouper elements remarquables après le texte |
self::separerEcologie_a_Usages($texte, $txt_fmt); |
//le morceau qui reste est le gros de la description |
$texte = str_replace(';','</br> -','- '.$texte); |
$texte = str_replace('–','',$texte); |
$txt_fmt['description'] = $texte; |
$retour = ""; |
foreach ($txt_fmt as $titre=>$parag) { |
$parag = preg_replace('/\- \. /','- ',$parag); |
$parag = preg_replace('/\. \./','.',$parag); |
$retour .= ucfirst($titre)." : ".trim($parag)." ; "; |
} |
return $retour; |
} |
static function separerNomScientifique_a_NomCommun(&$txt, &$txt_fmt){ |
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $txt, $retour)){ |
/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */ |
$a_enlever = array('/–/','/\./' ); |
$txt_fmt['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]); |
if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){ |
$txt_fmt['synonymes'] = $synonymes[1]; |
} else { |
$txt_fmt['nom_scientifique'] .= $retour[2]; |
} |
$txt = str_replace($retour[0],'',$txt); |
} |
/* !! attention il y a un espace avant les // du début !! */ |
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $txt, $retour)){ |
$a_enlever = array('/–/','/\./' ); |
$txt_fmt['nom_commun'] = preg_replace($a_enlever,'',$retour[1]); |
$txt = str_replace($retour[0],'',$txt); |
} |
} |
static function separerEcologie_a_Usages(&$txt, &$txt_fmt) { |
if (preg_match('/\.\s*([A-ZÉÀÈ].+)$/',$txt, $retour)) { |
$txt_fmt['ecologie'] = $retour[1]; |
$txt = str_replace($retour[0],'.',$txt); |
if (isset($txt_fmt['ecologie']) && preg_match('/–(.+)/', $txt_fmt['ecologie'] , $retour)){ |
$txt_fmt['repartition'] = $retour[1]; |
$txt_fmt['ecologie'] = str_replace($retour[0],'',$txt_fmt['ecologie']); |
} |
if (isset($txt_fmt['repartition']) && preg_match('/=(.+)$/', $txt_fmt['repartition'], $retour)){ |
$txt_fmt['floraison'] = $retour[1]; |
$txt_fmt['repartition'] = str_replace($retour[0],'',$txt_fmt['repartition']); |
$txt_fmt['repartition'] = str_replace(';',',',$txt_fmt['repartition']); |
} |
if (isset($txt_fmt['floraison']) && preg_match('/–(.+)$|\n(.+)$/',$txt_fmt['floraison'], $retour)){ |
$txt_fmt['usages'] = isset($retour[1]) ? $retour[1] : $retour[2]; |
$txt_fmt['floraison'] = str_replace($retour[0],'.',$txt_fmt['floraison']); |
} |
if (isset($txt_fmt['floraison']) && preg_match('/([Ff]l\.) (.+)/',$txt_fmt['floraison'], $retour)){ |
$txt_fmt['floraison'] = $retour[2]; |
$txt_fmt['floraison'] = str_replace($retour[1],'',$txt_fmt['floraison']); |
} |
if (isset($txt_fmt['floraison']) && preg_match('/([Ff]r\.) (.+)/',$txt_fmt['floraison'], $retour)){ |
$txt_fmt['fructification'] = $retour[2]; |
$txt_fmt['floraison'] = str_replace($retour[0],'',$txt_fmt['floraison']); |
$txt_fmt['floraison'] = str_replace(',','',$txt_fmt['floraison']); |
$txt_fmt['fructification'] = str_replace($retour[1],'',$txt_fmt['fructification']); |
$txt_fmt['fructification'] = str_replace('.','',$txt_fmt['fructification']); |
} |
} |
} |
private function formaterBaseflor($reponse) { |
$description = "En cours de rédaction."; |
if (isset($reponse["nom_sci"]) && $reponse["nom_sci"] != "") { |
$description = "Formation végétale : ".$reponse["form_vegetale"]."; ". |
"Inflorescence : ".$reponse["inflorescence"]."; ". |
"Couleur de la fleur : ".$reponse["couleur_fleur"]."; ". |
"Sexualité : ".$reponse["sexualite"]."; ". |
"Fruit : ".$reponse["fruit"]."; ". |
"Pollinisation : ".$reponse["pollinisation"]."; ". |
"Dissémination : ".$reponse["dissemination"]."; ". |
"Ecologie : ".$reponse["carac_ecolo"]." – ". |
"Chorologie : ".$reponse["chorologie"]."; ". |
"Floraison : ".$reponse["floraison"]; |
} |
return $description; |
} |
private function consulterWebService($rest, $projet,$resssource,$parametres) { |
$url_id = "http://api.tela-botanica.org/service:eflore:0.1/".$projet."/".$resssource.$parametres; |
$reponse = $rest->consulter($url_id); |
return json_decode($reponse, true); |
} |
private function recupererContenuFichier() { |
$nomFichier = Config::get('dossierCsv').Config::get('projet'); |
if ($nomFichier && file_exists($nomFichier) ){ |
$extensionFichier = strtolower(strrchr($nomFichier, '.')); |
if ($extensionFichier === ".csv"){ |
$file = new SplFileObject($nomFichier); |
$file->setFlags(SplFileObject::SKIP_EMPTY); |
$i = 0; |
echo "Traitement du fichier : "; |
while (!$file->eof()){ |
$ligne_csv = $file->fgetcsv($delimiter = ';'); |
$this->contenu_fichier[$i] = $ligne_csv; |
echo str_repeat(chr(8), ( strlen( $i ) + 1 ))."\t".$i++; |
} |
echo "\n"; |
} else { |
$this->traiterErreur("Le fichier : $nomFichier n'est pas au format csv."); |
} |
} else { |
$this->traiterErreur("Le fichier : $nomFichier n'existe pas."); |
} |
} |
public function supprimerAccents($chaine) { |
return str_replace($this->caracteresAccentues, $this->caracteresNormaux, $chaine); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/sauvages/sauvages.ini |
---|
New file |
0,0 → 1,5 |
version="1" |
projet="cles_sauvages.csv" |
dossierCsv = "{ref:dossierDonneesEflore}sauvages/3/" |
chemin_appli = "php:Framework::getCheminAppli()" |
/tags/v5.8-aspergeraie/scripts/modules/nvjfl/Nvjfl.php |
---|
New file |
0,0 → 1,180 |
<?php |
/** Exemple lancement: |
* /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php nvjfl |
* -a chargerTous |
* Options : |
* -t : Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes). |
*/ |
class Nvjfl extends EfloreScript { |
private $nomsIndex = array(); |
private $numeroIndex = 1; |
protected $parametres_autorises = array( |
'-t' => array(false, false, 'Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes).')); |
public function executer() { |
// Lancement de l'action demandée |
try { |
$this->initialiserProjet('nvjfl'); |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->chargerStructureSql(); |
$this->chargerNvjfl(); |
$this->chargerBiblio(); |
$this->chargerBiblioLien(); |
$this->chargerOntologies(); |
break; |
case 'chargerStructure' : |
$this->chargerStructureSql(); |
break; |
case 'chargerNvjfl' : |
$this->chargerNvjfl(); |
break; |
case 'chargerBiblio' : |
$this->chargerBiblio(); |
break; |
case 'chargerBiblioLien' : |
$this->chargerBiblioLien(); |
break; |
case 'chargerOntologies' : |
$this->chargerOntologies(); |
break; |
case 'supprimerTous' : |
$this->supprimerTous(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
/** |
* Charge le fichier en créant un id pour chaque nom vernaculaire. |
*/ |
private function chargerNvjfl() { |
//Debug::printr(Config::get('fichiers')); |
$fichierOuvert = $this->ouvrirFichier(Config::get('chemins.nvjfl')); |
$donnees = $this->analyserFichier($fichierOuvert); |
fclose($fichierOuvert); |
foreach ($donnees as $donnee) { |
$requete = 'INSERT INTO '.Config::get('tables.nvjfl').' VALUES ('.implode(', ', $donnee).')'; |
$this->getBdd()->requeter($requete); |
$this->afficherAvancement("Insertion des noms vernaculaires dans la base de données"); |
if ($this->stopperLaBoucle($this->getParametre('t'))) { |
break; |
} |
} |
echo "\n"; |
} |
private function analyserFichier($fichierOuvert) { |
$donnees = array(); |
$entetesCsv = fgets($fichierOuvert); |
while ($ligneCsv = fgets($fichierOuvert)) { |
$champs = explode("\t", trim($ligneCsv)); |
if (count($champs) > 0) { |
if (isset($champs[2])) { |
$nomVernaculaire = $champs[2]; |
$indexCourrant = $this->getIndexNomVernaculaire($nomVernaculaire); |
$champs = array_merge(array($indexCourrant), $champs); |
$donnees[] = $this->protegerValeursDesChamps($champs); |
} |
} |
$this->afficherAvancement("Analyse du fichier des noms vernaculaires"); |
if ($this->stopperLaBoucle()) { |
break; |
} |
} |
echo "\n"; |
return $donnees; |
} |
private function getIndexNomVernaculaire($nomVernaculaire) { |
$indexCourrant = null; |
if (array_key_exists($nomVernaculaire, $this->nomsIndex) == false) { |
$this->nomsIndex[$nomVernaculaire] = $this->numeroIndex++; |
} |
$indexCourrant = $this->nomsIndex[$nomVernaculaire]; |
return $indexCourrant; |
} |
private function ouvrirFichier($chemin) { |
$fichierOuvert = false; |
if ($chemin) { |
if (file_exists($chemin) === true) { |
$fichierOuvert = fopen($chemin, 'r'); |
if ($fichierOuvert == false) { |
throw new Exception("Le fichier $chemin n'a pas pu être ouvert."); |
} |
} else { |
throw new Exception("Le fichier $chemin est introuvable."); |
} |
} else { |
throw new Exception("Aucun chemin de fichier n'a été fourni."); |
} |
return $fichierOuvert; |
} |
private function protegerValeursDesChamps($champs) { |
$champsProteges = array(); |
for ($i = 0; $i < 9; $i++) { |
$valeur = isset($champs[$i]) ? $champs[$i] : ''; |
$champsProteges[] = $this->getBdd()->proteger($valeur); |
} |
return $champsProteges; |
} |
private function chargerBiblio() { |
$cheminsNvjflBiblio = Config::get('chemins.nvjflBiblio'); |
$tableNvjflBiblio = Config::get('tables.nvjflBiblio'); |
$requete = "LOAD DATA INFILE '$cheminsNvjflBiblio' ". |
"REPLACE INTO TABLE $tableNvjflBiblio ". |
'CHARACTER SET utf8 '. |
'FIELDS '. |
" TERMINATED BY '\t' ". |
" ENCLOSED BY '' ". |
" ESCAPED BY '\\\' ". |
'IGNORE 1 LINES'; |
$this->getBdd()->requeter($requete); |
} |
private function chargerBiblioLien() { |
$cheminNvjflLienBiblio = Config::get('chemins.nvjflLienBiblio'); |
$tableNvjflLienBiblio = Config::get('tables.nvjflLienBiblio'); |
$requete = "LOAD DATA INFILE '$cheminNvjflLienBiblio' ". |
"REPLACE INTO TABLE $tableNvjflLienBiblio ". |
'CHARACTER SET utf8 '. |
'FIELDS '. |
" TERMINATED BY '\t' ". |
" ENCLOSED BY '' ". |
" ESCAPED BY '\\\' ". |
'IGNORE 1 LINES'; |
$this->getBdd()->requeter($requete); |
} |
private function chargerOntologies() { |
$cheminOntologies = Config::get('chemins.ontologies'); |
$tableOntologies = Config::get('tables.ontologies'); |
$requete = "LOAD DATA INFILE '$cheminOntologies' ". |
"REPLACE INTO TABLE $tableOntologies ". |
'CHARACTER SET utf8 '. |
'FIELDS '. |
" TERMINATED BY '\t' ". |
" ENCLOSED BY '' ". |
" ESCAPED BY '\\\' ". |
'IGNORE 1 LINES'; |
$this->getBdd()->requeter($requete); |
} |
private function supprimerTous() { |
$requete = "DROP TABLE IF EXISTS nvjfl_biblio_v2007, nvjfl_lien_biblio_v2007, nvjfl_meta, nvjfl_ontologies_v2007, nvjfl_v2007"; |
$this->getBdd()->requeter($requete); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/nvjfl/nvjfl.ini |
---|
New file |
0,0 → 1,23 |
version = "2007" |
dossierTsv = "{ref:dossierDonneesEflore}nvjfl/2007-10-29/" |
dossierSql = "{ref:dossierTsv}" |
[tables] |
nvjfl = "nvjfl_v{ref:version}" |
nvjflLienBiblio = "nvjfl_lien_biblio_v{ref:version}" |
nvjflBiblio = "nvjfl_biblio_v{ref:version}" |
ontologies = "nvjfl_ontologies_v{ref:version}" |
[fichiers] |
structureSql = "nvjfl_v{ref:version}.sql" |
nvjfl = "{ref:tables.nvjfl}.tsv" |
nvjflBiblio = "{ref:tables.nvjflBiblio}.tsv" |
nvjflLienBiblio = "{ref:tables.nvjflLienBiblio}.tsv" |
ontologies = "{ref:tables.ontologies}.tsv" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:fichiers.structureSql}" |
nvjfl = "{ref:dossierTsv}{ref:fichiers.nvjfl}" |
nvjflBiblio = "{ref:dossierTsv}{ref:fichiers.nvjflBiblio}" |
nvjflLienBiblio = "{ref:dossierTsv}{ref:fichiers.nvjflLienBiblio}" |
ontologies = "{ref:dossierTsv}{ref:fichiers.ontologies}" |
/tags/v5.8-aspergeraie/scripts/modules/nvjfl |
---|
New file |
Property changes: |
Added: svn:ignore |
+nvjfl.ini |
/tags/v5.8-aspergeraie/scripts/modules/liste_rouge/liste_rouge.ini |
---|
New file |
0,0 → 1,17 |
version="2012" |
dossierTsv = "{ref:dossierDonneesEflore}liste_rouge/{ref:version}/" |
dossierSql = "{ref:dossierTsv}" |
[tables] |
listeRouge = "liste_rouge_v{ref:version}" |
referentielTaxo = "bdtfx_v2_00" |
[fichiers] |
structureSql = "liste_rouge_v{ref:version}.sql" |
listeRouge = "liste_rouge_v{ref:version}.tsv" |
listeRougeCorresp = "liste_rouge_correspondance_v{ref:version}.sql" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:fichiers.structureSql}" |
listeRouge = "{ref:dossierTsv}{ref:fichiers.listeRouge}" |
listeRougeCorresp = "{ref:dossierTsv}{ref:fichiers.listeRougeCorresp}" |
/tags/v5.8-aspergeraie/scripts/modules/liste_rouge/ListeRouge.php |
---|
New file |
0,0 → 1,114 |
<?php |
/** Exemple lancement: |
* /opt/lampp/bin/php -d memory_limit=3500M cli.php sptb -a chargerTous |
*/ |
class ListeRouge extends EfloreScript { |
public function executer() { |
// Lancement de l'action demandée |
try { |
$this->initialiserProjet('liste_rouge'); |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->chargerStructureSql(); |
$this->chargerDonnees(); |
$this->genererChampNumNomRetenu(); |
break; |
case 'chargerStructureSql' : |
$this->chargerStructureSql(); |
break; |
case 'chargerDonnees' : |
$this->chargerDonnees(); |
$this->genererChampNumNomRetenu(); |
break; |
case 'genererChampNumNomRetenu' : |
$this->genererChampNumNomRetenu(); |
break; |
case 'ajouterChampNumNomRetenu' : |
$this->ajouterChampNumNomRetenu(); |
break; |
case 'supprimerTous' : |
$this->supprimerTous(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
private function chargerDonnees() { |
$chemin = Config::get('chemins.listeRouge'); |
$table = Config::get('tables.listeRouge'); |
$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 genererChampNumNomRetenu() { |
$this->preparerTablePrChpNumNomRetenu(); |
$this->genererNumNomRetenu(); |
$this->recupererNumNomNonTrouve(); |
} |
private function preparerTablePrChpNumNomRetenu() { |
$table = Config::get('tables.listeRouge'); |
$requete = "SHOW COLUMNS FROM $table LIKE 'num_nom_retenu' "; |
$resultat = $this->getBdd()->recuperer($requete); |
if ($resultat === false) { |
$requete = "ALTER TABLE $table ". |
' ADD `num_nom_retenu` VARCHAR( 10 ) NOT NULL ,'. |
' ADD `nom_sci` VARCHAR( 500 ) NOT NULL ,'. |
' ADD INDEX ( `num_nom_retenu` ) '; |
$this->getBdd()->requeter($requete); |
} |
} |
private function genererNumNomRetenu() { |
$table = Config::get('tables.listeRouge'); |
$table_referentiel = Config::get('tables.referentielTaxo'); |
$requete = 'UPDATE '.$table.' s, '.$table_referentiel.' r '. |
'SET s.num_nom_retenu = r.num_nom_retenu, s.nom_sci = r.nom_complet '. |
'WHERE s.nom_sci_orig = r.nom_complet '; |
$this->getBdd()->requeter($requete); |
} |
private function recupererNumNomNonTrouve() { |
$table = Config::get('tables.listeRouge'); |
$requete = 'SELECT `id`, `nom_sci_orig`'. |
' FROM '.$table. |
' WHERE `num_nom_retenu` = ""'; |
$noms = $this->getBdd()->recupererTous($requete); |
$debug = "Noms sans correspondance avec bdtfx :\n"; |
foreach ($noms as $nom) { |
$debug .= $nom['id']." ".$nom['nom_sci_orig']."\n"; |
} |
Debug::printr($debug); |
} |
private function ajouterChampNumNomRetenu() { |
$chemin = Config::get('chemins.listeRougeCorresp'); |
$table = Config::get('tables.listeRouge'); |
$requetes = $this->recupererContenu($chemin); |
$this->executerScripSql($requetes); |
} |
private function supprimerTous() { |
$requete = "DROP TABLE IF EXISTS liste_rouge_meta, liste_rouge_v2012"; |
$this->getBdd()->requeter($requete); |
Debug::printr('suppression'); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/moissonnage/moissonnage.ini |
---|
New file |
0,0 → 1,35 |
code = "ifn" |
versions = "2005,2006,2007,2008,2009,2010,2011,2012" |
categories = "arbresForet,arbresPeupleraie,couvertsForet,documentation,ecologie,flore,placettesForet,placettesPeupleraie" |
dossierTsv = "{ref:dossierDonneesEflore}{ref:code}/" |
dossierSql = "{ref:dossierTsv}" |
[tables] |
ifnMeta = "if_meta" |
documentationFlore = "ifn_documentation_flore" |
arbresForet = "ifn_arbres_foret" |
arbresPeupleraie = "ifn_arbres_peupleraie" |
couvertsForet = "ifn_couverts_foret" |
documentation = "ifn_documentation" |
ecologie = "ifn_ecologie" |
flore = "ifn_flore" |
placettesForet = "ifn_placettes_foret" |
placettesPeupleraie = "ifn_placettes_peupleraie" |
ifnTest = "ifn" |
[fichiers] |
structureSql = "{ref:code}.sql" |
arbresForet = "arbres_foret.csv" |
arbresPeupleraie = "arbres_peupleraie.csv" |
couvertsForet = "couverts_foret.csv" |
documentation = "documentation.csv" |
ecologie = "ecologie.csv" |
flore = "flore.csv" |
placettesForet = "placettes_foret.csv" |
placettesPeupleraie = "placettes_peupleraie.csv" |
documentationFlore = "documentation_flore.csv" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:fichiers.structureSql}" |
documentation_flore = "{ref:dossierTsv}{ref:documentation_flore}" |
/tags/v5.8-aspergeraie/scripts/modules/moissonnage/Moissonnage.php |
---|
New file |
0,0 → 1,120 |
<?php |
/** Exemple lancement: |
* /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php moissonnage -a chargerTous -n baznat |
* Options : |
* -n : nom du projet |
*/ |
class Moissonnage extends EfloreScript { |
private $projet = ""; |
protected $parametres_autorises = array( |
'-n' => array(true, true, 'Préciser le nom du dataset que vous souhaitez ajouter ex. baznat, naturedugard-flore')); |
public function executer() { |
// Lancement de l'action demandée |
try { |
$this->initialiserProjet('moissonnage'); |
$cmd = $this->getParametre('a'); |
$this->projet = $this->getParametre('n'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->chargerDonnees(); |
$this->chargerMetaDonnees(); |
break; |
case 'chargerDonnees' : |
$this->chargerDonnees(); |
break; |
case 'chargerMetadonnees' : |
$this->chargerMetaDonnees(); |
break; |
case 'supprimerTous' : |
$this->supprimerTous(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
private function chargerDonnees() { |
$requete = "CREATE TABLE tb_eflore.".$this->projet."_tapir2 ". |
"AS SELECT concat('urn:lsid:',institutionCode,':',collectionCode,':', catalogNumber) AS guid, ". |
"`catalogNumber` AS observation_id, `scientificName` AS nom_scientifique_complet, `referencess` AS num_nom, ". |
"`county` AS lieu_station_nom, `locality` AS lieu_commune_code_insee, ". |
"`decimalLatitude` AS lieu_station_latitude, `decimalLongitude` AS lieu_station_longitude, `geodeticDatum` , ". |
"`eventDate` AS observation_date, `identifiedBy` AS observateur_nom_complet ". |
"FROM tb_moissonnage.Occurrence ". |
"WHERE dataset_id = (SELECT dataset_id FROM tb_moissonnage.Dataset WHERE name = '$this->projet')"; |
$this->getBdd()->requeter($requete); |
} |
private function chercherInfosMetaDonnees() { |
$infos = array(); |
$requeteOccurrence = "SELECT institutionCode, collectionCode FROM tb_moissonnage.Occurrence WHERE dataset_id = |
(SELECT id FROM tb_moissonnage.Dataset WHERE name='$this->projet');"; |
$infos['occurrence'] = $this->getBdd()->recuperer($requeteOccurrence); |
$requeteDataset = "SELECT * FROM tb_moissonnage.DataPublisher WHERE id = |
(SELECT dataPublisher_id FROM tb_moissonnage.Dataset WHERE name='$this->projet')"; |
$infos['dataPublisher'] = $this->getBdd()->recuperer($requeteDataset); |
return $infos; |
} |
private function chargerMetaDonnees() { |
$this->chargerStructureSqlMetaDonnees(); |
$infos = $this->chercherInfosMetaDonnees(); |
$date = date('Y_m_d'); |
$requete = "INSERT INTO tb_eflore.".$this->projet."_tapir_meta (guid, citation, url_projet, createurs) ". |
"VALUES ('urn:lsid:{$infos['occurrence']['institutionCode']}:{$infos['occurrence']['collectionCode']}:{$date}', '". |
$this->projet." : {$infos['dataPublisher']['description']} du ". |
"<a href=\"{$infos['occurrence']['institutionCode']}\" title=\"{$infos['occurrence']['collectionCode']}\" ". |
"onclick=\"window.open(this.href); return false;\">{$this->projet}</a>', ". |
"'{$infos['occurrence']['institutionCode']}', ". |
"'p.courriel={$infos['dataPublisher']['administrativeContact']}, p.courriel={$infos['dataPublisher']['technicalContact']}')"; |
$this->getBdd()->requeter($requete); |
} |
private function chargerStructureSqlMetaDonnees() { |
$date = date('Y_m_d'); |
$requete = "CREATE TABLE IF NOT EXISTS tb_eflore.".$this->projet."_tapir_meta ". |
"(`guid` varchar(255) NOT NULL , |
`langue_meta` varchar(2) NOT NULL DEFAULT 'fr', |
`code` varchar(20) NOT NULL DEFAULT '{$this->projet}', |
`version` varchar(20) NOT NULL DEFAULT '{$date}', |
`titre` varchar(255) NOT NULL DEFAULT '{$this->projet}', |
`description` text, |
`mots_cles` varchar(510) NOT NULL DEFAULT 'flore, observation, {$this->projet}', |
`citation` varchar(255) NOT NULL, |
`url_tech` varchar(510) DEFAULT NULL, |
`url_projet` varchar(510) NOT NULL, |
`source` text, |
`createurs` text NOT NULL, |
`editeur` text, |
`contributeurs` text, |
`droits` text, |
`url_droits` varchar(510) DEFAULT 'http://creativecommons.org/licenses/by-sa/2.0/fr/', |
`langue` varchar(255) DEFAULT 'fr', |
`date_creation` varchar(30) DEFAULT NULL, |
`date_validite` varchar(255) DEFAULT NULL, |
`couverture_spatiale` varchar(510) DEFAULT NULL, |
`couverture_temporelle` varchar(510) DEFAULT NULL, |
`web_services` varchar(255) DEFAULT 'meta-donnees:0.1;ontologies:0.1;cartes:0.1', |
PRIMARY KEY (`guid`,`langue_meta`) |
) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; |
$this->getBdd()->requeter($requete); |
} |
private function supprimerTous() { |
$requete = "DROP TABLE IF EXISTS `ifn_arbres_forets`, `ifn_arbres_peupleraie`, `ifn_couverts_foret`, |
`ifn_documentation`, `ifn_documentation_flore`, `ifn_ecologie`, `ifn_flore`, `ifn_placettes_foret`, |
`ifn_placettes_peupleraie`; |
"; |
$this->getBdd()->requeter($requete); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/robot/configuration/cassini.ini |
---|
New file |
0,0 → 1,3 |
; Encodage : UTF-8 |
; Source des données : http://cassini.ehess.fr/ |
cache_chemin = "php:'/home/'.$_ENV['USER'].'/importation/robots/cassini.ehess.fr/'" |
/tags/v5.8-aspergeraie/scripts/modules/robot/configuration/wp_commune.ini |
---|
New file |
0,0 → 1,4 |
; Encodage : UTF-8 |
; Source des données : http://fr.wikipedia.org/wiki/ |
; Version des noms de commune utilisé pour intéroger Wikipedia: Code géographique de l'INSEE version 2008-01-01 |
cache_chemin = "php:'/home/'.$_ENV['USER'].'/importation/robots/fr.wikipedia.org/'" |
/tags/v5.8-aspergeraie/scripts/modules/robot/configuration/utm_converter.ini |
---|
New file |
0,0 → 1,3 |
; Encodage : UTF-8 |
; Source des données : http://www.rcn.montana.edu/resources/tools/coordinates.aspx |
cache_chemin = "php:'/home/'.$_ENV['USER'].'/importation/robots/rcn.montana.edu/'" |
/tags/v5.8-aspergeraie/scripts/modules/robot/configuration/cookieconf.txt |
---|
New file |
0,0 → 1,4 |
-b ../../../../../../../importation/robots/cookie.txt |
-c ../../../../../../../importation/robots/cookie.txt |
--max-time 50 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/robot/configuration/ipni_auteur.ini |
---|
New file |
0,0 → 1,3 |
; Encodage : UTF-8 |
; Source des données : http://ipni.org/ |
cache_chemin = "php:'/home/'.$_ENV['USER'].'/importation/robots/ipni.org/'" |
/tags/v5.8-aspergeraie/scripts/modules/robot/Robot.php |
---|
New file |
0,0 → 1,432 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/** |
* Robots |
* |
* Description : classe permettant d'analyser les pages d'un site web. |
* Notes : les noms des pages doivent être dans la bonne casse. http://fr.wikipedia.org/wiki/ambronay ne renvera rien alors que |
* http://fr.wikipedia.org/wiki/Ambronay renvera un résultat (Notez le A ou a). |
* |
//Auteur original : |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Tela-Botanica 1999-2009 |
* @link http://www.tela-botanica.org/wikini/eflore |
* @licence GPL v3 & CeCILL v2 |
* @version $Id: Robot.class.php 2057 2011-05-13 16:39:06Z Jean-Pascal MILCENT $ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
class Robot extends ScriptCommande { |
/** |
* Indique le nom du Robot. |
*/ |
private $robot_nom; |
/** |
* Indique le fichier de config de la gestion des cookies du Robot. |
*/ |
private $cookie; |
/** |
* Indique l'url de départ du Robot. |
*/ |
private $page; |
/** |
* Tableau des URLs à analyse |
*/ |
private $pages = array(); |
/** |
* Chemin vers un fichier contenant les noms des pages à analyser (un nom de page par ligne). |
*/ |
private $page_fichier; |
/** |
* Contient soit False soit le chemin vers le dossier où mettre les pages en cache. |
*/ |
private $cache = false; |
/** |
* Contient le squelette de l'url à utiliser pour récupérer les pages web. |
*/ |
private $url_tpl = ''; |
/** |
* Contient false ou l'encodage des pages d'un site web si celui-ci n'est pas en UTF-8. |
*/ |
private $encodage = false; |
/** |
* Contient la chaine de caractères indiquant où commencer une recherche d'informations dans la page web. |
*/ |
private $chaine_debut = ''; |
/** |
* Contient la chaine de caractères indiquant où terminer une recherche d'informations dans la page web. |
*/ |
private $chaine_fin = ''; |
/** |
* Tableau des expressions régulières récupérant des données lors de l'analyse |
*/ |
private $regexps = array(); |
/** |
* Indique le dossier ou fichier où le Robot doit sotcker les informations collectées. |
*/ |
private $sortie; |
public $parametres = array( '-pgf' => array(false, '', 'Fichier contenant les pages que le Robot doit analyser'), |
'-s' => array(false, '', 'Fichier où stocker les données récupérées par le Robot'), |
'-pg' => array(false, '', 'Nom de la page que le Robot doit analyser')); |
public function executer() { |
$this->page = $this->getParam('pg'); |
$this->page_fichier = $this->getParam('pgf'); |
$this->cookie = dirname(__FILE__).DS.'configuration'.DS.'cookieconf.txt'; |
$this->sortie = $this->getParam('s'); |
// Construction du tableau contenant les noms des pages à analyser |
if (empty($this->page_fichier)) { |
$this->pages[] = $this->page; |
} else { |
$this->pages = $this->convertirFichierEnTableau($this->page_fichier); |
} |
// Création du chemin du cache si le fichier ini du projet l'indique |
if ($this->getIni('cache_chemin')) { |
$this->cache = $this->getIni('cache_chemin'); |
} |
// Lancement du Robot demandé |
$cmd = $this->getParam('a'); |
switch ($cmd) { |
case 'wp' : |
$this->lancerRobotWikipedia(); |
break; |
case 'wp-pays' : |
$this->lancerRobotWikipediaPays(); |
break; |
case 'wp-liste-communes' : |
$this->lancerRobotWikipediaListeCommunes(); |
break; |
case 'ipni' : |
$this->lancerRobotIpni(); |
break; |
case 'cassini' : |
$this->lancerRobotCassini(); |
break; |
case 'utm' : |
$this->lancerRobotUtmConverter(); |
break; |
default : |
$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd)); |
} |
} |
/** |
* Robot analysant les pages de Wikipedia correspondant à des communes. |
* Exemples d'utilisation : |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp -pgf ~/importation/robots/eFloreBotWp_INSEE_C.txt -s ~/importation/robots/wp_communes.tsv |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp -pg Montpellier -s ~/importation/robots/wp_communes.tsv |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp -pg Montpellier |
* |
* @return unknown_type |
*/ |
private function lancerRobotWikipedia() { |
// Valeur spécifique de ce Robot |
$this->robot_nom = 'eFloreBotWp'; |
$this->url_tpl = 'http://fr.wikipedia.org/wiki/%s'; |
$this->regexp_ligne = '/<!-- bodytext -->(.*)<!-- \/bodytext -->/umsi'; |
$this->regexps = array( 'CodeInsee' => 'Code commune<\/a><\/th>(?:\n|\r\n)<td>(\d+)<\/td>', |
'Nom' => 'class="entete map" style="[^"]+">(.*)<', |
'Latitutde' => '<span class="geo-dec geo" title=".*"><span class="latitude">(.*)<\/span>', |
'Longitude' => '<span class="geo-dec geo" title=".*">.*<\/span>, <span class="longitude">(.*)<\/span>', |
'Superficie' => 'Superficie<\/a>(?:<\/b><\/td>|<\/th>)(?:\n|\r\n)<td>((?:[0-9]| | )+(?:,[0-9]+)?) km<sup>2<\/sup>', |
'AltitudeMin' => 'Altitudes<\/a><\/th>(?:\n|\r\n)<td>mini. (-?[0-9]+) m — maxi. [ 0-9]+ m<\/td>', |
'AltitudeMax' => 'Altitudes<\/a><\/th>(?:\n|\r\n)<td>mini. -?[0-9]+ m — maxi. ([ 0-9]+) m<\/td>', |
'Population' => 'Population<\/a><\/th>(?:\n|\r\n)<td>(.*) hab.', |
'PopulationAnnee' => 'Population<\/a><\/th>(?:\n|\r\n)<td>.* hab. <small>\(<a href="\/wiki\/[0-9]+"(?: title="[0-9]+")?>([0-9]+)<\/a>', |
'CodePostal' => 'Code postal<\/a><\/th>(?:\n|\r\n)<td>([0-9]{5}).*<\/td>', |
'PageWikipedia' => '(?:Ce document provient|Récupérée) de « <a href="http:\/\/fr.wikipedia.org\/wiki\/(.*)">' |
); |
// Préparation des noms des pages |
foreach ($this->pages as $id => $nom) { |
$this->pages[$id] = str_replace(' ', '_', $nom); |
} |
$this->analyserUrls(); |
} |
/** |
* Robot analysant les pages de Wikipedia correspondant à des pays. |
* Exemples d'utilisation : |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp-pays -pgf ~/importation/robots/eFloreBotWp_pays.txt -s ~/importation/robots/wp-pays.tsv |
* |
* @return unknown_type |
*/ |
private function lancerRobotWikipediaPays() { |
// Valeur spécifique de ce Robot |
$this->robot_nom = 'eFloreBotWp'; |
$this->url_tpl = 'http://fr.wikipedia.org/wiki/%s'; |
$this->regexp_ligne = '/<!-- bodytext -->(.*)<!-- \/bodytext -->/umsi'; |
$this->regexps = array( 'Nom' => '<table class="infobox_v2" cellspacing="[^"]+" style="[^"]+">(?:\n|\r\n)<caption style="[^"]+"><b>(.*)<\/b>', |
'Latitutde' => '<span class="geo-dec geo" title=".*"><span class="latitude">(.*)<\/span>', |
'Longitude' => '<span class="geo-dec geo" title=".*">.*<\/span>, <span class="longitude">(.*)<\/span>', |
'Superficie' => 'Superficie<\/a><\/b><\/td>(?:\n|\r\n)<td>((?:[0-9]|\s*| )+(?:,[0-9]+)?)(?: |\s*)km<sup>2<\/sup>', |
'Population' => 'Population<\/a><\/b>(?: |\s)*<small>\([0-9]+\)<\/small><\/td>(?:\n|\r\n)<td>(.*)(?: |\s*)hab.', |
'PopulationAnnee' => 'Population<\/a><\/b>(?: |\s)*<small>\(([0-9]+)\)', |
'Capitale' => 'Capitale<\/a><\/b><\/td>(?:\n|\r\n)<td>(?:<a href="\/wiki\/[^"]+" title="[^"]+">|)(.+)<', |
'PageWikipedia' => '(?:Ce document provient|Récupérée) de « <a href="http:\/\/fr.wikipedia.org\/wiki\/(.*)">' |
); |
// Préparation des noms des pages |
foreach ($this->pages as $id => $nom) { |
$this->pages[$id] = str_replace(' ', '_', $nom); |
} |
$this->analyserUrls(); |
} |
/** |
* Robot analysant une page de wikipedia à la recherche de plusieurs données par page. |
* Exemples d'utilisation : |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp -pgf ~/importation/robots/eFloreBotWp_INSEE_C.txt -s ~/importation/robots/wp_communes.tsv |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp -pg Montpellier -s ~/importation/robots/wp_communes.tsv |
* /opt/lampp/bin/php script.php robot -p wp_commune -a wp -pg Montpellier |
* |
* @return unknown_type |
*/ |
private function lancerRobotWikipediaListeCommunes() { |
// Valeur spécifique de ce Robot |
$this->robot_nom = 'eFloreBotWpListe'; |
$this->url_tpl = 'http://fr.wikipedia.org/wiki/%s'; |
$this->regexp_ligne = '/<tr>(.*)?<\/tr>/Uumsi'; |
$this->mode = 'MULTI'; |
$this->regexps = array( 'PageWikipedia' => '^<td align="left"><a href="\/wiki\/([^"]+)"', |
'CodeInsee' => '^<td>.+<\/td>(?:\n|\r\n)<td>(\d+)<\/td>', |
'CodePostal' => '^(?:<td>.+<\/td>(?:\n|\r\n)){2}<td>(\d+)<\/td>', |
'Superficie' => '^(?:<td>.+<\/td>(?:\n|\r\n)){4}<td><span.+span>((?:[0-9]| | )+(?:,[0-9]+)?)<\/td>', |
'Population' => '^(?:<td>.+<\/td>(?:\n|\r\n)){5}<td><span.+span>((?:[0-9]| | )+)<\/td>' |
); |
// Préparation des noms des pages |
foreach ($this->pages as $id => $nom) { |
$this->pages[$id] = str_replace(' ', '_', $nom); |
} |
$this->analyserUrls(); |
} |
/** |
* Robot analysant les pages du site de l'IPNI. |
* Exemples d'utilisation : |
* /opt/lampp/bin/php script.php robot -p ipni_auteur -a wp -pgf ~/importation/robots/eFloreBotIpni_auteur.txt -s ~/importation/robots/ipni_auteurs.tsv |
* /opt/lampp/bin/php script.php robot -p ipni_auteur -a wp -pg Z -s ~/importation/robots/ipni_auteurs.tsv |
* /opt/lampp/bin/php script.php robot -p ipni_auteur -a wp -pg Z |
* |
* @return unknown_type |
*/ |
private function lancerRobotIpni() { |
// Valeur spécifique de ce Robot |
$this->robot_nom = 'eFloreBotIpni'; |
$this->url_tpl = 'http://ipni.org/ipni/advAuthorSearch.do?output_format=delimited&find_surname=%s*'; |
$this->regexp_ligne = '/^(.*)$/umi'; |
$this->regexps = array( 'Id' => '^([^%]+)%' , |
'Version' => '^(?:[^%]*%){1,}([^%]*)%' , |
'DefaultAuthorName' => '^(?:[^%]*%){2,}([^%]*)%' , |
'DefaultAuthorForename' => '^(?:[^%]*%){3,}([^%]*)%' , |
'DefaultAuthorSurname' => '^(?:[^%]*%){4,}([^%]*)%' , |
'StandardForm' => '^(?:[^%]*%){5,}([^%]*)%' , |
'NameNotes' => '^(?:[^%]*%){6,}([^%]*)%' , |
'NameSource' => '^(?:[^%]*%){7,}([^%]*)%' , |
'Dates' => '^(?:[^%]*%){8,}([^%]*)%' , |
'DateTypeCode' => '^(?:[^%]*%){9,}([^%]*)%' , |
'DateTypeString' => '^(?:[^%]*%){10,}([^%]*)%' , |
'AlternativeAbbreviations' => '^(?:[^%]*%){11,}([^%]*)%' , |
'AlternativeNames' => '^(?:[^%]*%){12,}([^%]*)%' , |
'TaxonGroups' => '^(?:[^%]*%){13,}([^%]*)%' , |
'ExampleOfNamePublished' => '^(?:[^%]*%){14,}([^%]*)$' ); |
$this->analyserUrls(); |
} |
/** |
* Robot analysant les pages du site de Cassini. |
* Exemples d'utilisation : |
* /opt/lampp/bin/php script.php robot -p cassini -a cassini -pgf ~/importation/robots/eFloreBotCassini.txt -s ~/importation/robots/cassini.tsv |
* /opt/lampp/bin/php script.php robot -p cassini -a cassini -pg 1 -s ~/importation/robots/cassini.tsv |
* /opt/lampp/bin/php script.php robot -p cassini -a cassini -pg 1 |
* |
* @return unknown_type |
*/ |
private function lancerRobotCassini() { |
// Valeur spécifique de ce Robot |
$this->robot_nom = 'eFloreBotCassini'; |
$this->url_tpl = 'http://cassini.ehess.fr/cassini/fr/html/fiche.php?select_resultat=%s'; |
$this->encodage = 'ISO-8859-1'; |
$this->regexp_ligne = '/\s*var\s+chaine1\s+\t=\s+"(.*?)";/umsi'; |
$this->regexps = array( 'NomCommune' => '^([^\\\\]+)\\\\n' , |
'Superficie' => '\\\\nsuperficie;([^\\\\]+)\\\\n', |
'AltitudeMin' => '\\\\naltitude;([^;]+);', |
'AltitudeMax' => '\\\\naltitude;[^;]+;([^\\\\]+)\\\\n', |
'LambertIIEtenduX' => '\\\\ncoordonnées;Lambert II étendu\\\\n;x;([^\\\\]+)\\\\n', |
'LambertIIEtenduY' => '\\\\ncoordonnées;Lambert II étendu\\\\n;x;[^\\\\]+\\\\n;y;([^\\\\]+)\\\\n', |
'Latitude' => '\\\\n;Latitude;(.+)?\\\\ncode', |
'Longitude' => '\\\\n;Longitude;(.+?)\\\\n;Latitude', |
'CodeInsee' => '\\\\ncode insee;([^\\\\]+)\\\\nstatut', |
'Statut' => '\\\\nstatut\(s\);([^\\\\]+)\\\\n\\\\n'); |
$this->analyserUrls(); |
} |
/** |
* Robot analysant les pages du site de Cassini. |
* Exemples d'utilisation : |
* /opt/lampp/bin/php script.php robot -p cassini -a cassini -pgf ~/importation/robots/eFloreBotCassini.txt -s ~/importation/robots/cassini.tsv |
* /opt/lampp/bin/php script.php robot -p cassini -a cassini -pg 1 -s ~/importation/robots/cassini.tsv |
* /opt/lampp/bin/php script.php robot -p cassini -a cassini -pg 1 |
* |
* @return unknown_type |
*/ |
private function lancerRobotUtmConverter() { |
// Valeur spécifique de ce Robot |
$this->robot_nom = 'eFloreBotUtmConverter'; |
$this->url_tpl = 'http://www.rcn.montana.edu/resources/tools/coordinates.aspx?nav=11&c=DD&md=83&mdt=NAD83/WGS84&lat=%s&lath=N&lon=%s&lonh=E'; |
$this->encodage = 'ISO-8859-1'; |
$this->regexp_ligne = '/Universal Transverse Mercator \(UTM\):<\/td>(.*?)<\/table><\/td>/umsi'; |
$this->regexps = array( 'UTM_Zone' => 'Zone: ([0-9]+)<' , |
'UTM_Est_x' => 'Easting: ([0-9]+)<', |
'UTM_Nord_y' => 'Northing: ([0-9]+)<'); |
$this->analyserUrls(); |
} |
private function analyserUrls() { |
// Lancement de l'analyse |
$heure_debut = date('c',time()); |
echo "Analyse de l'URL # : "; |
$pagesNum = 0;// Pages |
$lignesNum = 0;// Lignes |
$sortie = ''; |
foreach ($this->pages as $paramsPage) { |
$xhtml_page = $this->getHtml($this->url_tpl, $paramsPage); |
$xhtml_lignes = $this->extraireChaine($this->regexp_ligne, $xhtml_page); |
// Pour chaque chaine début/fin trouvées au sein de la page, nous recherchons les regexps des données. |
if (count($xhtml_lignes) > 1 && $this->mode != 'MULTI') { |
$this->traiterAttention("Plusieurs lignes correspondent à votre expression régulière de limitation du contenu :\n %s", array($this->regexp_ligne)); |
} else if ($xhtml_lignes) { |
print_r($xhtml_lignes ); |
foreach ($xhtml_lignes as $xhtml) { |
$champsNum = 1;// Champs |
$ligne = ''; |
foreach ($this->regexps as $chp => $regexp) { |
// Si nous traitons la première ligne nous ajoutons les noms des champs en début de fichier de sortie |
if ($lignesNum == 0) { |
$sortie .= $chp.(($champsNum == count($this->regexps)) ? "\n" : "\t"); |
$champsNum++; |
} |
// Ajout de la valeur trouvée grâce à l'expression régulière à la ligne de sortie |
if (preg_match('/'.$regexp.'/Umsi', $xhtml, $match)) { |
$ligne .= $this->nettoyer($match[1])."\t"; |
} else { |
$ligne .= "\t"; |
} |
} |
$lignesNum++; |
$ligne = trim($ligne); |
$sortie .= $ligne."\n"; |
// Affichage en console... |
if (empty($this->sortie)) { |
echo "\t".$ligne."\n"; |
} |
} |
} else { |
$this->traiterAttention("Impossible de trouver les chaines début et fin dans la page «%s» avec la regexp :\n%s", array($this->getNomPage($paramsPage), $this->regexp_ligne)); |
} |
// Affichage en console... |
echo str_repeat(chr(8), ( strlen( $pagesNum ) + 1 ))."\t".$pagesNum++; |
} |
echo "\n"; |
$heure_fin = date('c',time()); |
// Ajout de métadonnées |
$metadonnees = "Début d'importation : $heure_debut\nFin d'importation : $heure_fin\n"; |
$metadonnees .= "Source des données : ".$this->url_tpl."\n"; |
$sortie = $metadonnees.$sortie; |
// Écriture du fichier de sortie ou retour dans la console |
if (!empty($this->sortie)) { |
file_put_contents($this->sortie, $sortie); |
} |
} |
private function nettoyer($txt) { |
$txt = trim($txt); |
$txt = preg_replace('/(?: | )/', ' ', $txt); |
return $txt; |
} |
private function getHtml($url_tpl, $paramsPage) { |
// Lancement en ligne de commande pour tester : |
//curl -v --url "http://fr.wikipedia.org/wiki/Montpellier" --config /home/jpm/web/eflore_bp/consultation/scripts/modules/robot/configuration/cookieconf.txt |
if ($this->cache && file_exists($fichier_cache = $this->cache.$this->getNomPage($paramsPage))) { |
$html = file_get_contents($fichier_cache); |
} else { |
$url = vsprintf($url_tpl, $paramsPage); |
$this->traiterAttention(" Url : ".$url); |
// Initialisation CURL |
$curl = curl_init(); |
curl_setopt($curl, CURLOPT_COOKIEFILE, $this->cookie); |
curl_setopt($curl, CURLOPT_URL, $url); |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); |
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1'); |
$html = curl_exec($curl); |
// Mise en cache |
if ($this->cache) { |
file_put_contents($fichier_cache, $html); |
} |
} |
// Nettoyage des entités html |
$html = $this->encoderUtf8($html, 'HTML-ENTITIES'); |
// Nettoyage de l'encodage des urls |
$html = urldecode($html); |
// Convertion en UTF-8 si nécessaire |
if ($this->encodage) { |
$html = $this->encoderUtf8($html, $this->encodage); |
} |
return $html; |
} |
/** |
* Méthode récupérant seulement une partie du texte passé en paramétre. |
* |
* @param $debut chaine de caractère indiquant le début du texte à prendre en compte. |
* @param $fin chaine de caractère indiquant la fin du texte à prendre en compte. |
* @param $txt le texte duquel extraire une partie bornée par $debut et $fin. |
* @return le texte extrait. |
*/ |
private function extraireChaine($regexp, $txt) { |
if (preg_match_all($regexp, $txt, $match)) { |
return $match[1]; |
} else { |
return false; |
} |
} |
/** |
* Charge les lignes d'un fichier dans un tableau et le retourne. |
* Supprime les caractères blancs et les nouvelles lignes. |
* |
* @param $fichier |
* @return unknown_type |
*/ |
private function convertirFichierEnTableau($fichier) { |
$tableau = array(); |
$handle = fopen($fichier,'r'); |
if ($handle) { |
while ($ligne = fgets($handle)) { |
$tableau[] = explode("\t", trim($ligne)); |
} |
fclose($handle); |
} |
return $tableau; |
} |
private function getNomPage($paramsPage) { |
return str_replace(' ', '_', implode('_', $paramsPage)).'.html'; |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/bdnt/Bdnt.php |
---|
New file |
0,0 → 1,54 |
<?php |
/** Exemple lancement: |
* /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php bdnt -a chargerTous |
*/ |
class Bdnt extends EfloreScript { |
public function executer() { |
// Lancement de l'action demandée |
try { |
$this->initialiserProjet('bdnt'); |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->chargerStructureSql(); |
$this->chargerOntologies(); |
break; |
case 'chargerStructureSql' : |
$this->chargerStructureSql(); |
break; |
case 'chargerOntologies' : |
$this->chargerOntologies(); |
break; |
case 'supprimerTous' : |
$this->supprimerTous(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
private function chargerOntologies() { |
$chemin = Config::get('chemins.ontologies'); |
$table = Config::get('tables.ontologies'); |
$requete = "LOAD DATA INFILE '$chemin' ". |
"REPLACE INTO TABLE $table ". |
'CHARACTER SET utf8 '. |
'FIELDS '. |
" TERMINATED BY '\t' ". |
" ENCLOSED BY '' ". |
" ESCAPED BY '\\\' ". |
'IGNORE 0 LINES'; |
$this->getBdd()->requeter($requete); |
} |
private function supprimerTous() { |
$requete = "DROP TABLE IF EXISTS bdnt_meta, bdnt_ontologies_v4_30"; |
$this->getBdd()->requeter($requete); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/bdnt/bdnt.ini |
---|
New file |
0,0 → 1,14 |
version="4_40" |
dossierTsv = "{ref:dossierDonneesEflore}bdnt/2013-07-01/" |
dossierSql = "{ref:dossierTsv}" |
[tables] |
ontologies = "bdnt_ontologies_v{ref:version}" |
[fichiers] |
structureSql = "bdnt_ontologies_v2013-07-01.sql" |
ontologies = "bdnt_ontologies_v2013-07-01.tsv" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:fichiers.structureSql}" |
ontologies = "{ref:dossierTsv}{ref:fichiers.ontologies}" |
/tags/v5.8-aspergeraie/scripts/modules/bdnt |
---|
New file |
Property changes: |
Added: svn:ignore |
+bdnt.ini |
/tags/v5.8-aspergeraie/scripts/modules/fournier/Fournier.php |
---|
New file |
0,0 → 1,138 |
<?php |
//declare(encoding='UTF-8'); |
/** |
* Exemple de lancement du script : : |
* /opt/lampp/bin/php cli.php bdtfx -a chargerTous |
* |
* @category php 5.2 |
* @package eFlore/Scripts |
* @author Jennifer DHÉ <jennifer@tela-botanica.org> |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright Copyright (c) 2011, Tela Botanica (accueil@tela-botanica.org) |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
* @version $Id$ |
*/ |
class Fournier extends EfloreScript { |
private $table = null; |
private $tableMeta = null; |
private $pasInsertion = 1000; |
private $departInsertion = 0; |
protected $parametres_autorises = array( |
'-t' => array(false, false, 'Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes).')); |
public function executer() { |
try { |
$this->initialiserProjet('fournier'); |
$this->initialiserTables(); |
// Lancement de l'action demandée |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->chargerStructureSql(); |
$this->chargerFournier(); |
$this->genererNomSciHtml(); |
break; |
case 'chargerStructureSql' : |
$this->chargerStructureSql(); |
break; |
case 'chargerFournier' : |
$this->chargerFournier(); |
break; |
case 'genererNomSciHtml' : |
$this->genererNomSciHtml(); |
break; |
case 'supprimerTous' : |
$this->supprimerTous(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
private function chargerFournier() { |
$chemin = Config::get('chemins.fournier'); |
$table = Config::get('tables.fournier'); |
$requete = "LOAD DATA INFILE '$chemin' ". |
"REPLACE INTO TABLE $table ". |
'CHARACTER SET utf8 '. |
'FIELDS '. |
" TERMINATED BY ',' ". |
" ENCLOSED BY '\"' ". |
" ESCAPED BY '\\\' ". |
'IGNORE 1 LINES'; |
$this->getBdd()->requeter($requete); |
} |
private function genererNomSciHtml() { |
$this->preparerTable(); |
$generateur = new GenerateurNomSciHtml(); |
$nbreTotal = $this->recupererNbTotalTuples(); |
while ($this->departInsertion < $nbreTotal) { |
$resultat = $this->recupererTuples(); |
$nomsSciEnHtml = $generateur->generer($resultat); |
$this->lancerRequeteModification($nomsSciEnHtml); |
$this->departInsertion += $this->pasInsertion; |
$this->afficherAvancement("Insertion des noms scientifique au format HTML dans la base par paquet de {$this->pasInsertion} en cours"); |
if ($this->stopperLaBoucle($this->getParametre('t'))) break; |
} |
echo "\n"; |
} |
private function initialiserTables() { |
$this->table = Config::get('tables.fournier'); |
$this->tableMeta = Config::get('tables.fournierMeta'); |
} |
private function preparerTable() { |
$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'nom_sci_html' "; |
$resultat = $this->getBdd()->recuperer($requete); |
if ($resultat === false) { |
$requete = "ALTER TABLE {$this->table} ". |
'ADD nom_sci_html VARCHAR( 500 ) '. |
'CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL '; |
$this->getBdd()->requeter($requete); |
} |
} |
private function recupererNbTotalTuples(){ |
$requete = "SELECT count(*) AS nb FROM {$this->table} "; |
$resultat = $this->getBdd()->recuperer($requete); |
return $resultat['nb']; |
} |
private function recupererTuples() { |
$requete = 'SELECT num_nom, rang, nom_supra_generique, genre, epithete_infra_generique, '. |
' epithete_sp, type_epithete, epithete_infra_sp, cultivar_groupe, '. |
' nom_commercial, cultivar '. |
"FROM {$this->table} ". |
"LIMIT {$this->departInsertion},{$this->pasInsertion} "; |
$resultat = $this->getBdd()->recupererTous($requete); |
return $resultat; |
} |
private function lancerRequeteModification($nomsSciHtm) { |
foreach ($nomsSciHtm as $id => $html) { |
$html = $this->getBdd()->proteger($html); |
$requete = "UPDATE {$this->table} ". |
"SET nom_sci_html = $html ". |
"WHERE num_nom = $id "; |
$resultat = $this->getBdd()->requeter($requete); |
if ($resultat === false) { |
throw new Exception("Erreur d'insertion pour le tuple $id"); |
} |
} |
} |
private function supprimerTous() { |
$requete = "DROP TABLE IF EXISTS {$this->tableMeta}, {$this->table}"; |
$this->getBdd()->requeter($requete); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/fournier/fournier.ini |
---|
New file |
0,0 → 1,15 |
version="1_00" |
dossierTsv = "{ref:dossierDonneesEflore}fournier/1.00/" |
dossierSql = "{ref:dossierTsv}" |
[tables] |
fournierMeta = "fournier_meta" |
fournier = "fournier_v{ref:version}" |
[fichiers] |
structureSql = "{ref:tables.fournier}.sql" |
fournier = "{ref:tables.fournier}.csv" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:fichiers.structureSql}" |
fournier = "{ref:dossierTsv}{ref:fichiers.fournier}" |
/tags/v5.8-aspergeraie/scripts/modules/prometheus/Prometheus.php |
---|
New file |
0,0 → 1,639 |
<?php |
/** |
* Exemple de lancement du script : /opt/lampp/bin/php cli.php ontologie -a analyser |
* |
*/ |
require_once dirname(__FILE__).DS.'Traduction.php'; |
class Prometheus extends EfloreScript { |
private $projetDossier = ''; |
private $lecteur = null; |
private $fichier = ''; |
private $lotsTermes = array(); |
private $lotsRelations = array(); |
private $lotsImages = array(); |
private $lotsPublications = array(); |
private $lotsAuteurs = array(); |
private $lotsHierarchie = array(); |
private $baseIdGroupe = 10000; |
private $baseIdSousGroupe = 20000; |
private $types = array( |
'FREQUENCY_MODIFIERS' => 2, |
'QUALIFIERS' => 3, |
'RELATIVE_MODIFIERS' => 4, |
'RELATIVE_VALUES' => 5, |
'SPATIAL_MODIFIERS' => 6, |
'LOCATER_REGIONS' => 7, |
'TEMPORAL_MODIFIERS' => 8, |
'UNIT_TERMS' => 9, |
'QUANTITATIVE_PROPERTIES' => 10, |
'NEW_QUALITATIVE_PROPERTIES' => 11, |
'DISALLOWED_TERMS' => 20, |
'QUALITATIVE_STATES' => 13, |
'TYPE_OF_STRUCTURE_TERMS' => 14, |
'STRUCTURE_TERMS' => 15, |
'REGION_TERMS' => 16, |
'GENERIC_STRUCTURES' => 17); |
public function executer() { |
try { |
$this->initialiserProjet('prometheus'); |
$this->projetDossier = Config::get('dossierTsv'); |
$this->fichier = $this->projetDossier.'Ontology.xml'; |
// Lancement de l'action demandée |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerTous' : |
$this->chargerStructureSql(); |
$this->lireFichierXml(); |
break; |
case 'chargerStructureSql' : |
$this->chargerStructureSql(); |
break; |
case 'analyser' : |
$this->vider(); |
$this->lireFichierXml(); |
break; |
case 'chargerTraductions' : |
$this->viderTraductions(); |
$this->chargerTraductions(); |
break; |
case 'vider' : |
$this->vider(); |
case 'viderTraductions' : |
$this->viderTraductions(); |
break; |
case 'supprimerTous' : |
$this->supprimerTous(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
/** |
* Lit le fichier OSM et lance l'analyse des noeuds xml en fonction de leur type. |
*/ |
private function lireFichierXml() { |
$termes = array_keys($this->types); |
$this->lecteur = new XMLReader(); |
if ($this->ouvrirFichierXml()) { |
while ($this->lecteur->read()) { |
if ($this->lecteur->nodeType == XMLREADER::ELEMENT) { |
if (in_array($this->lecteur->localName, $termes)) { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$type = $this->lecteur->localName; |
$this->traiterTermes($this->types[$type], $noeud->children()); |
} else if ($this->lecteur->localName == 'STATE_GROUPS') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterGroupes($noeud->children()); |
} else if ($this->lecteur->localName == 'NewQualitativeProperties') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterNouvellesQualites($noeud->children()); |
} else if ($this->lecteur->localName == 'RELATIONSHIPS') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterRelations($noeud->children()); |
} else if ($this->lecteur->localName == 'PICTURES') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterImages($noeud->children()); |
} else if ($this->lecteur->localName == 'CITATIONS') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterCitations($noeud->children()); |
} else if ($this->lecteur->localName == 'AUTHORS') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterAuteurs($noeud->children()); |
} else if ($this->lecteur->localName == 'TreeNode') { |
$noeud = $this->obtenirNoeudSimpleXml(); |
$this->traiterHierarchie($noeud); |
} |
} |
} |
if (count($this->lotsTermes) > 0) { |
$this->insererLotDeTermes(); |
} |
if (count($this->lotsRelations) > 0) { |
$this->insererLotDeRelations(); |
} |
if (count($this->lotsImages) > 0) { |
$this->insererLotImages(); |
} |
if (count($this->lotsPublications) > 0) { |
$this->insererLotDePublications(); |
} |
if (count($this->lotsAuteurs) > 0) { |
$this->insererLotAuteurs(); |
} |
if (count($this->lotsHierarchie) > 0) { |
$this->insererLotHierarchie(); |
} |
} |
} |
private function ouvrirFichierXml() { |
if ($this->lecteur->open($this->fichier) === false) { |
throw new Exception("Impossible d'ouvrir le fichier XML : $this->fichier"); |
} |
return true; |
} |
private function obtenirNoeudSimpleXml() { |
$doc = new DOMDocument; |
$element = $this->lecteur->expand(); |
$noeud = simplexml_import_dom($doc->importNode($element, true)); |
return $noeud; |
} |
private function traiterTermes($type, $termes) { |
foreach ($termes as $terme) { |
$id = (int) $terme->attributes()->GLOBALID; |
if (isset($this->lotsTermes[$id]) === false) { |
$valeur = array(); |
$valeur[] = (int) $id; |
$valeur[] = (int) $type; |
$valeur[] = (string) $terme->attributes()->term; |
$valeur[] = (string) $this->obtenirDefinition($terme); |
$valeur[] = (int) $this->obtenirPreference($terme); |
$valeur[] = (int) $this->obtenirAuteur($terme); |
$valeur[] = (int) $this->obtenirCitation($terme); |
$valeur[] = (int) $this->obtenirImage($terme); |
$this->lotsTermes[$id] = $valeur; |
} |
if (isset($terme->attributes()->parentID)) { |
$relation = array(); |
$relation[] = (int) $terme->attributes()->GLOBALID; |
$relation[] = (int) $terme->attributes()->parentID; |
$relation[] = 'A POUR PARENT'; |
$this->ajouterRelation($relation); |
} |
if (isset($terme->attributes()->PARENT_STRUCTURE_ID)) { |
$relation = array(); |
$relation[] = (int) $terme->attributes()->GLOBALID; |
$relation[] = (int) $terme->attributes()->PARENT_STRUCTURE_ID; |
$relation[] = 'A POUR STRUCTURE PARENTE'; |
$this->ajouterRelation($relation); |
} |
if (isset($terme->attributes()->stateOfNEWPROPERTYID)) { |
$relation = array(); |
$relation[] = (int) $terme->attributes()->GLOBALID; |
$relation[] = (int) $terme->attributes()->stateOfNEWPROPERTYID; |
$relation[] = 'A POUR NOUVELLE QUALITE'; |
$this->ajouterRelation($relation); |
} |
} |
} |
private function obtenirDefinition($terme) { |
$definition = null; |
if (isset($terme->DEFINITION)) { |
$definition = $terme->DEFINITION; |
} |
return $definition; |
} |
private function obtenirPreference($terme) { |
$preference = '1'; |
if (isset($terme->attributes()->PREFERRED_TERM)) { |
$valeur = (string) $terme->attributes()->PREFERRED_TERM; |
$preference = (trim($valeur) == 'Disallowed Term') ? '0' : '1'; |
} |
return $preference; |
} |
private function obtenirAuteur($terme) { |
$auteur = 0; |
if (isset($terme->attributes()->authorID)) { |
$auteur = $terme->attributes()->authorID; |
} elseif (isset($terme->attributes()->authorREF)) { |
$auteur = $terme->attributes()->authorREF; |
} |
return $auteur; |
} |
private function obtenirCitation($terme) { |
$citation = 0; |
if (isset($terme->attributes()->citationID)) { |
$citation = $terme->attributes()->citationID; |
} elseif (isset($terme->attributes()->citationREF)) { |
$citation = $terme->attributes()->citationREF; |
} |
return $citation; |
} |
private function obtenirImage($terme) { |
$image = 0; |
if (isset($terme->attributes()->pictureREF)) { |
$image = $terme->attributes()->pictureREF; |
} |
return $image; |
} |
private function traiterGroupes($groupes) { |
foreach ($groupes as $groupe) { |
$id = $this->baseIdGroupe + (int) $groupe->attributes()->GROUP_ID; |
if (isset($this->lotsTermes[$id]) === false) { |
$valeur = array(); |
$valeur[] = (int) $id; |
$valeur[] = 18; |
$valeur[] = (string) $groupe->attributes()->groupName; |
$valeur[] = ''; |
$valeur[] = 1; |
$valeur[] = 0; |
$valeur[] = 0; |
$valeur[] = 0; |
$this->lotsTermes[$id] = $valeur; |
} |
if (isset($groupe->STRUCTURES_LINKED_TO_GROUP)) { |
foreach ($groupe->STRUCTURES_LINKED_TO_GROUP->children() as $structure) { |
$relation = array(); |
$relation[] = (int) $structure->attributes()->GLOBALID; |
$relation[] = (int) $id; |
$relation[] = 'A POUR GROUPE'; |
$this->ajouterRelation($relation); |
} |
} |
if (isset($groupe->STATES_IN_GROUP)) { |
foreach ($groupe->STATES_IN_GROUP->children() as $etat) { |
$relation = array(); |
$relation[] = (int) $id; |
$relation[] = (int) $etat->attributes()->GLOBALID; |
$relation[] = 'A POUR ETAT'; |
$this->ajouterRelation($relation); |
} |
} |
if (isset($groupe->STATESUBGROUPS)) { |
$this->traiterSousGroupes($id, $groupe->STATESUBGROUPS->children()); |
} |
} |
} |
private function traiterSousGroupes($idGroupe, $sousGroupes) { |
foreach ($sousGroupes as $sg) { |
$id = $this->baseIdSousGroupe + (int) $sg->attributes()->STATESUBGROUP_GLOBALID; |
if (isset($this->lotsTermes[$id]) === false) { |
$valeur = array(); |
$valeur[] = (int) $id; |
$valeur[] = 19; |
$valeur[] = (string) $sg->attributes()->subgGroupName; |
$valeur[] = ''; |
$valeur[] = 1; |
$valeur[] = 0; |
$valeur[] = 0; |
$valeur[] = 0; |
$this->lotsTermes[$id] = $valeur; |
$relation = array(); |
$relation[] = (int) $idGroupe; |
$relation[] = (int) $id; |
$relation[] = 'A POUR SOUS-GROUPE'; |
$this->ajouterRelation($relation); |
} |
if (isset($sg->STATES_IN_SUBGROUP)) { |
foreach ($sg->STATES_IN_SUBGROUP->children() as $etat) { |
$relation = array(); |
$relation[] = (int) $id; |
$relation[] = (int) $etat->attributes()->GLOBALID; |
$relation[] = 'A POUR ETAT'; |
$this->ajouterRelation($relation); |
} |
} |
} |
} |
private function traiterNouvellesQualites($qualites) { |
foreach ($qualites as $qualite) { |
$id = (int) $qualite->attributes()->IDSEQ; |
if (isset($this->lotsTermes[$id]) === false) { |
$valeur = array(); |
$valeur[] = (int) $id; |
$valeur[] = 11; |
$valeur[] = (string) $qualite->attributes()->term; |
$valeur[] = (string) $this->obtenirDefinition($terme); |
$valeur[] = (int) $this->obtenirPreference($terme); |
$valeur[] = (int) $this->obtenirAuteur($terme); |
$valeur[] = (int) $this->obtenirCitation($terme); |
$valeur[] = (int) $this->obtenirImage($terme); |
$this->lotsTermes[$id] = $valeur; |
} |
if (isset($qualite->attributes()->ParentPropertyID)) { |
$relation = array(); |
$relation[] = (int) $qualite->attributes()->IDSEQ; |
$relation[] = (int) $qualite->attributes()->ParentPropertyID; |
$relation[] = 'A POUR PARENT'; |
$this->ajouterRelation($relation); |
} |
if (isset($qualite->MemberStates)) { |
$etats = $qualite->MemberStates->children(); |
$idParent = $qualite->attributes()->IDSEQ; |
$this->traiterEtatsMembre($etats, $idParent); |
} |
if (isset($qualite->Structures_linked_to_Property)) { |
$structures = $qualite->Structures_linked_to_Property->children(); |
$idParent = $qualite->attributes()->IDSEQ; |
$this->traiterStructuresLiees($structures, $idParent); |
} |
if (isset($qualite->ContextGroups)) { |
$contextes = $qualite->ContextGroups->children(); |
if (count($contextes) > 0) { |
foreach ($contextes as $contexte) { |
$idParent = $contexte->attributes()->ID; |
$structures = $contexte->Structures_linked_to_Context->children(); |
$this->traiterStructuresLiees($structures, $idParent); |
$etats = $contexte->MemberStates->children(); |
$this->traiterEtatsMembre($etats, $idParent); |
} |
} |
} |
} |
} |
private function ajouterRelation($relation) { |
$id = implode('-', $relation); |
if (isset($this->lotsRelations[$id]) === false) { |
$this->lotsRelations[$id] = $relation; |
} |
} |
private function traiterEtatsMembre($etats, $idParent) { |
if (count($etats) > 0) { |
foreach ($etats as $etat) { |
$relation = array(); |
$relation[] = (int) $idParent; |
$relation[] = (int) $etat->attributes()->RefID; |
$relation[] = 'A POUR ETAT'; |
$this->ajouterRelation($relation); |
} |
} |
} |
private function traiterStructuresLiees($structures, $idParent) { |
if (count($structures) > 0) { |
foreach ($structures as $structure) { |
$relation = array(); |
$relation[] = (int) $structure->attributes()->RefID; |
$relation[] = (int) $idParent; |
$relation[] = 'A POUR PROPRIETE'; |
$this->ajouterRelation($relation); |
} |
} |
} |
private function traiterRelations($relations) { |
foreach ($relations as $rel) { |
$relation = array(); |
$relation[] = (int) $rel->attributes()->term1REF; |
$relation[] = (int) $rel->attributes()->term2REF; |
$relation[] = (string) $this->obtenirTypeRelation($rel->attributes()->relationship); |
$this->ajouterRelation($relation); |
} |
} |
private function obtenirTypeRelation($type) { |
switch ($type) { |
case 'ASSOCIATED WITH' : |
$relation = 'ASSOCIE AVEC'; |
break; |
case 'IS A PART OF' : |
$relation = 'EST UNE PARTIE DE'; |
break; |
case 'IS A TYPE OF' : |
$relation = 'EST UN TYPE DE'; |
break; |
default : |
$relation = ''; |
} |
return $relation; |
} |
private function traiterImages($images) { |
foreach ($images as $img) { |
$valeur = array(); |
$valeur[] = (int) $img->attributes()->ID; |
$valeur[] = (string) $img->attributes()->NAME; |
$valeur[] = (int) $img->attributes()->CITATION_REFID; |
$this->lotsImages[] = $valeur; |
} |
} |
private function traiterCitations($citations) { |
foreach ($citations as $publi) { |
$valeur = array(); |
$valeur[] = (int) $publi->attributes()->ID; |
$valeur[] = (int) $publi->attributes()->primaryAuthorREF; |
$valeur[] = (string) $publi->PUBLICATION; |
$valeur[] = (string) $publi->DATE; |
$valeur[] = (string) $publi->PAGE; |
$this->lotsPublications[] = $valeur; |
} |
} |
private function traiterAuteurs($auteurs) { |
foreach ($auteurs as $auteur) { |
$valeur = array(); |
$valeur[] = (int) $auteur->attributes()->ID; |
$valeur[] = (string) $auteur->attributes()->givenNames; |
$valeur[] = (string) $auteur->attributes()->surname; |
$valeur[] = $this->obtenirDateNaissance((string) $auteur->attributes()->born); |
$valeur[] = (string) $auteur->attributes()->died; |
$this->lotsAuteurs[] = $valeur; |
} |
} |
private function obtenirDateNaissance($annee) { |
$date = $annee.'-00-00'; |
return $date; |
} |
private function traiterHierarchie($noeud) { |
$valeur = array(); |
$valeur[] = (int) $noeud->attributes()->ID; |
$valeur[] = (int) $noeud->attributes()->ParentNodeID; |
$valeur[] = (string) $noeud->attributes()->pathAsNames; |
$valeur[] = (string) $noeud->attributes()->pathAsID; |
$valeur[] = (int) $noeud->attributes()->TermID; |
$this->lotsHierarchie[] = $valeur; |
} |
private function insererLotDeTermes() { |
$champs = implode(',', array('id_terme', 'ce_type', 'nom_en', 'description_en', 'preference', 'ce_auteur', 'ce_publication', 'ce_image')); |
$values = $this->creerValues($this->lotsTermes); |
$requete = "INSERT INTO prometheus_ontologies_terme_v1_00 ($champs) VALUES $values"; |
$this->executerSql($requete); |
} |
private function insererLotDeRelations() { |
$champs = implode(',', array('id_terme_01', 'id_terme_02', 'relation')); |
$values = $this->creerValues($this->lotsRelations); |
$requete = "INSERT INTO prometheus_ontologies_relation_v1_00 ($champs) VALUES $values"; |
$this->executerSql($requete); |
} |
private function insererLotImages() { |
$champs = implode(',', array('id_image', 'uri', 'ce_publication')); |
$values = $this->creerValues($this->lotsImages); |
$requete = "INSERT INTO prometheus_ontologies_image_v1_00 ($champs) VALUES $values"; |
$this->executerSql($requete); |
} |
private function insererLotDePublications() { |
$champs = implode(',', array('id_publication', 'ce_auteur_principal', 'titre', 'date', 'uri')); |
$values = $this->creerValues($this->lotsPublications); |
$requete = "INSERT INTO prometheus_ontologies_publication_v1_00 ($champs) VALUES $values"; |
$this->executerSql($requete); |
} |
private function insererLotAuteurs() { |
$champs = implode(',', array('id_auteur', 'prenom', 'nom', 'naissance_date', 'deces_date')); |
$values = $this->creerValues($this->lotsAuteurs); |
$requete = "INSERT INTO prometheus_ontologies_auteur_v1_00 ($champs) VALUES $values"; |
$this->executerSql($requete); |
} |
private function insererLotHierarchie() { |
$champs = implode(',', array('id_noeud', 'id_noeud_parent', 'chemin_noms', 'chemin_ids', 'ce_terme')); |
$values = $this->creerValues($this->lotsHierarchie); |
$requete = "INSERT INTO prometheus_ontologies_hierarchie_v1_00 ($champs) VALUES $values"; |
$this->executerSql($requete); |
} |
private function creerValues($valeurs) { |
$values = array(); |
foreach ($valeurs as $valeur) { |
foreach ($valeur as $id => $val) { |
$valeur[$id] = $this->etreVide($val) ? 'NULL' : $this->proteger(trim($val)); |
} |
$values[] = '('.implode(',', $valeur).')'; |
} |
$values = implode(',', $values); |
return $values; |
} |
private function etreVide($val) { |
$vide = ($val === null || trim($val) === '') ? true : false; |
return $vide; |
} |
private function executerSql($requete) { |
$this->getBdd()->requeter($requete); |
} |
private function proteger($chaine) { |
return $this->getBdd()->proteger($chaine); |
} |
private function viderTraductions() { |
$requete = 'UPDATE prometheus_ontologies_terme_v1_00 '. |
'SET nom = NULL, description = NULL, notes = NULL'; |
$this->executerSql($requete); |
} |
private function chargerTraductions() { |
$dossier = $this->projetDossier.'traductions'.DS; |
$pointeur = opendir($dossier); |
while ($fichierNom = readdir($pointeur)) { |
if (preg_match('/^[.]{1,2}/', $fichierNom) == false) { |
$fichierChemin = $dossier.$fichierNom; |
$lecteur = new LecteurExcel($fichierChemin); |
//$this->verifierStructureFichierExcel($lecteur); |
for ($ligne = 2; $ligne < $lecteur->getNbreLignes(); $ligne++) { |
$traduction = new Traduction(); |
$traduction->type = $lecteur->getValeur($ligne, 1); |
$traduction->en = $lecteur->getValeur($ligne, 2); |
$traduction->fr = $lecteur->getValeur($ligne, 3); |
$traduction->sourcesTraduction = $lecteur->getValeur($ligne, 4); |
$traduction->remarques = $lecteur->getValeur($ligne, 5); |
$traduction->sources = $lecteur->getValeur($ligne, 6); |
$traduction->relectureRemarques = $lecteur->getValeur($ligne, 7); |
$this->genererNotes($traduction); |
$this->insererTraduction($traduction); |
} |
} |
} |
closedir($pointeur); |
} |
private function verifierStructureFichierExcel($lecteur) { |
$messages = array(); |
$colonnes = array("Type d'élément", "Élément en anglais", "Traduction en français", "Sources de la traduction", "Remarques", "Sources", "Relecture/ Remarques"); |
foreach ($colonnes as $numero => $intitule) { |
$valeurBrute = $lecteur->getValeur(1, ($numero + 1)); |
if ($valeurBrute != $intitule) { |
$messages[] = "Le fichier {$lecteur->getFichier()} ne contient pas la bonne colonne #$numero : $intitule != $valeurBrute"; |
} |
} |
if (count($messages) > 0) { |
throw new Exception(implode("\n", $messages)); |
} |
} |
private function genererNotes(Traduction $traduction) { |
$notes = array(); |
if ($this->etreVide($traduction->sourcesTraduction) === false) { |
$notes[] = "Sources de la traduction : ".$traduction->sourcesTraduction; |
} |
if ($this->etreVide($traduction->remarques) === false) { |
$notes[] = "Remarques : ".$traduction->remarques; |
} |
if ($this->etreVide($traduction->sources) === false) { |
$notes[] = "Sources : ".$traduction->sources; |
} |
if ($this->etreVide($traduction->relectureRemarques) === false) { |
$notes[] = "Remarques sur la relecture : ".$traduction->relectureRemarques; |
} |
if (count($notes) > 0) { |
$traduction->notes = implode("\n", $notes); |
} |
} |
private function insererTraduction($traduction) { |
$requete = null; |
$notes = $traduction->notes; |
if ($traduction->type == 'term') { |
$notes = $this->proteger("Nom :\n".$notes); |
$nom = $this->proteger($traduction->fr); |
$nomEn = $this->proteger($traduction->en); |
$requete = "UPDATE prometheus_ontologies_terme_v1_00 ". |
"SET nom = $nom, notes = $notes ". |
"WHERE nom_en = $nomEn "; |
} else if ($traduction->type == 'DEFINITION') { |
$notes = $this->proteger("Description :\n".$notes); |
$description = $this->proteger($traduction->fr); |
$descriptionEn = $this->proteger($traduction->en); |
$requete = "UPDATE prometheus_ontologies_terme_v1_00 ". |
"SET description = $description, notes = CONCAT(notes, '\n', $notes) ". |
"WHERE description_en = $descriptionEn "; |
} |
if ($requete != null) { |
$this->executerSql($requete); |
} |
} |
private function vider() { |
$requete = 'TRUNCATE TABLE IF EXISTS prometheus_ontologies_auteur_v1_00'; |
$this->executerSql($requete); |
$requete = 'TRUNCATE TABLE IF EXISTS prometheus_ontologies_hierarchie_v1_00'; |
$this->executerSql($requete); |
$requete = 'TRUNCATE TABLE IF EXISTS prometheus_ontologies_image_v1_00'; |
$this->executerSql($requete); |
$requete = 'TRUNCATE TABLE IF EXISTS prometheus_ontologies_publication_v1_00'; |
$this->executerSql($requete); |
$requete = 'TRUNCATE TABLE IF EXISTS prometheus_ontologies_relation_v1_00'; |
$this->executerSql($requete); |
$requete = 'TRUNCATE TABLE IF EXISTS prometheus_ontologies_terme_v1_00'; |
$this->executerSql($requete); |
} |
private function supprimerTous() { |
$requete = "DROP TABLE IF EXISTS prometheus_meta, prometheus_ontologies_auteur_v1_00, prometheus_ontologies_hierarchie_v1_00, |
prometheus_ontologies_image_v1_00, prometheus_ontologies_publication_v1_00, prometheus_ontologies_relation_v1_00, |
prometheus_ontologies_terme_v1_00, prometheus_ontologies_type_v1_00"; |
$this->getBdd()->requeter($requete); |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/prometheus/Traduction.php |
---|
New file |
0,0 → 1,11 |
<?php |
class Traduction { |
public $type = null; |
public $en = null; |
public $fr = null; |
public $sourcesTraduction = null; |
public $remarques = null; |
public $sources = null; |
public $relectureRemarques = null; |
public $notes = null; |
} |
/tags/v5.8-aspergeraie/scripts/modules/prometheus/prometheus.ini |
---|
New file |
0,0 → 1,12 |
version="1_00" |
dossierTsv = "{ref:dossierDonneesEflore}prometheus/v1.00_2003-02-18/" |
dossierSql = "{ref:dossierTsv}" |
[tables] |
ontologies = "prometheus_ontologies_v{ref:version}" |
[fichiers] |
structureSql = "prometheus_v1_00.sql" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:fichiers.structureSql}" |
/tags/v5.8-aspergeraie/scripts/modules/bonnier/Bonnier.php |
---|
New file |
0,0 → 1,508 |
<?php |
// Encodage : UTF-8 |
// +-------------------------------------------------------------------------------------------------------------------+ |
/* Importation des fichiers excel de Bonnier pour créer une version HTML pour PDA. |
* Utilisation au préalable des utillitaire de traitement de fichier mdb sous Unix (voir ci après) |
* |
* Pré-requis : |
* 1. Installer le paquet pour Perl nommé ParseExcel : urpmi perl-spreadsheet-parseexcel |
* 2. Télécharger les fichiers Excel de Bonnier : http://www.tela-botanica.org/projets/74/documents/16211 |
* 3. Créer un dossier où vous dézipperez l'archive des fichiers Excel |
* 4. Copier dans ce dossier les fichier xls2sql.pl et generer_sql.sh que vous trouverez dans le dossier shell de ce module |
* 5. Donner les droits d'execution au fichier generer_sql.sh et lancer le : ./generer_sql.sh |
* 6. Vous devez obtenir un fichier SQL par fichier Excel. |
* |
* Pour lancer ce script fichier par fichier : |
* 1. Ouvrir une console et se positionner dans le dossier "scripts" |
* 2. Pour charger le 1er fichier Excel, taper la commande : /opt/lampp/bin/php script.php bonnier -p bonnier -a charger -table renonculacees |
* 3. Pour generer le html issu du chargement precedent : |
* /opt/lampp/bin/php script.php bonnier -p bonnier -a html -dossier "menus/001-Renonculacees" -table renonculacees |
* |
* // Auteur original : |
* @author David DELON <david@clapas.net> |
* @copyright David DELON 2009 |
* @link http://www.tela-botanica.org/wikini/eflore |
* @licence GPL v3 & CeCILL v2 |
* @version $Id$ |
*/ |
// +-------------------------------------------------------------------------------------------------------------------+ |
class Bonnier extends ScriptCommandeEflore { |
/** |
* Paramêtres disponible pour la ligne de commande |
* le tableau se construit de la forme suivnate : |
* - clé = nom du paramêtre '-foo' |
* - value = contient un nouveau tableau composé de cette façaon : |
* - booléen: true si le paramêtre est obligatoire |
* - booléen ou var : true si le paramêtre nécessite un valeur à sa suite ou la valeur par défaut |
* - string: description du contenu du paramêtre |
* Les paramêtres optionels devraient être déclaré à la fin du tableau. |
* Le dernier parametre du tableau peut avoir la valeur '...', |
* il contiendra alors l'ensemble des paramêtres suivant trouvés sur la ligne de commande. |
* @var array |
*/ |
public $parametres = array( '-table' => array(true, true, "Nom de la table où seront stockées les données d'une famille"), |
'-dossier' => array(true, true, "Dossier où sont générés les fichiers html pour la table")); |
public function executer() { |
error_reporting(E_ALL & ~E_DEPRECATED ); |
$table = $this->getParam('table'); |
$dossier = $this->getParam('dossier'); |
@mkdir($this->getIni('chemin_fichier_sortie').$dossier); |
$cmd = $this->getParam('a'); |
switch ($cmd) { |
// chargement des fichiers sql issus de la transformation xls dans la base de donnee, une table par fichir sql, 2 tables par |
// familles : texte (navigation / clef) et plantes : description des plantes. |
case 'charger' : |
$this->creerTableBonnier($this->version, $table); |
$this->chargerDonnees($table); |
break; |
case 'html' : |
// tranformation sql vers html : pour la famille considerée : parcours de l'ensemble de ses clef et generation html pour |
// les feuilles. |
$this->realiserHtml($dossier, $table); |
break; |
default : |
trigger_error('Erreur : la commande "'.$cmd.'" n\'existe pas!'."\n", E_USER_ERROR); |
} |
} |
private function realiserHtml($dossier, $table) { |
// Parcours de l'ensemble des données ? ou famille par famille ? |
// on charge plante et texte dans des tableaux |
$this->type_donnee = $table.'_texte'; |
$requete = 'SELECT * '. |
'FROM '.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee.' '. |
'ORDER BY uid'; |
$lignesTexte = $this->retournerDonneesRequete($requete); |
// Analyse des données |
echo "Analyse des données : ".$this->type_donnee."\n"; |
foreach ($lignesTexte as $ligneTexte) { |
if (!isset($aso_lignes[$ligneTexte['identifiant']])) { |
$aso_lignes[$ligneTexte['identifiant']] = $ligneTexte; |
} else { |
echo "identifiant en double : ".$ligneTexte['identifiant']."\n"; |
} |
} |
$this->type_donnee = $table.'_plante'; |
$requete = 'SELECT * '. |
'FROM '.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee.' '. |
'ORDER BY uid'; |
$lignesPlante = $this->retournerDonneesRequete($requete); |
foreach ($lignesPlante as $lignePlante) { |
if (!isset($aso_lignes[$lignePlante['identifiant']])) { |
$aso_lignes[$lignePlante['identifiant']] = $lignePlante; |
} else { |
echo "identifiant en double : ".$lignePlante['identifiant']."\n"; |
} |
} |
//print_r($aso_lignes_texte[$lignesTexte[0]['identifiant']] ['titre']); |
// $ariane : tableau des identifiants parcourus dans la branche |
// $niveau : niveau dans l'arbre |
$ariane = array(); |
$niveau = 0; |
// Parcours de l'arbre des clefs depuis la racine |
$this->genererHtmlTexte($lignesTexte[1]['identifiant'], $aso_lignes, $ariane, $niveau, $dossier); |
} |
// Generation des elements de navigation (clef) |
private function genererHtmlTexte($identifiant, $lignesTexteIdentifiant, $ariane, $niveau, $dossier) { |
$ariane[] = $identifiant; |
$niveau++; |
if (isset ($lignesTexteIdentifiant[$identifiant])) { // Si des identifiants sont en doubles |
$ligneIdentifiant = $lignesTexteIdentifiant[$identifiant]; |
} |
else { |
// initialiser valeur par defaut indiquant une erreur |
} |
$f_html = fopen($this->getIni('chemin_fichier_sortie').$dossier.'/'.$identifiant.'.html', 'wb'); |
$html = |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n". |
'<head>'."\n". |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n". |
'<title>Flore BONNIER sur PDA</title>'."\n". |
'<link rel="stylesheet" type="text/css" href="../../style/style640.css" media="screen" />'."\n". |
'</head>'."\n"; |
$html .= '<body>'."\n"; |
$html .= '<div class="titre">'."\n"; |
$html .= '<p id="titre">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['titre']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
// print "identifiant : ".$ligneIdentifiant['identifiant']."\n"; |
// Destinations |
// Branche niveau inferieur |
$html.='<div class="fenetreMenu">'."\n"; |
for ($i = 1; $i < 6; $i++) { |
if (isset($ligneIdentifiant['texte_'.$i]) && $ligneIdentifiant['texte_'.$i] != "") { |
$html .= '<div class="menu'.($i-1).'">'."\n"; |
$html .= '<a href="'.$ligneIdentifiant['destination_'.$i].'.html">'; |
$html .= $ligneIdentifiant['texte_'.$i]; |
$html .= '</a>'."\n"; |
$html .= '</div>'."\n"; |
} |
} |
$html .= '</div>'."\n"; |
$html .= '<div class="espace" style="top:518px;">'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="navigation">'."\n"; |
$html .= '<p id="navigation">'."\n"; |
// Navigation |
for ($i = 0; $i < $niveau; $i++) { |
if (($ariane[$i]) && $ariane[$i] != '') { |
$html .= '<a href="'.$ariane[$i].'.html">'; |
if (isset ($lignesTexteIdentifiant[$ariane[$i]])) { // Si des identifiants sont en doubles |
$html .= $lignesTexteIdentifiant[$ariane[$i]]['titre']; |
} |
$html .= '</a>'."\n"; |
} |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="retour">'."\n"; |
$html .= '<p id="retour">'."\n"; |
// Retour niveau superieur |
if (isset($ariane[$niveau - 2]) && $ariane[$niveau - 2] != '') { |
$html .= '<a href="'.$ariane[$niveau - 2].'.html">'; |
$html .= $lignesTexteIdentifiant[$ariane[$niveau - 2]]['titre']; |
$html .= '</a>'."\n"; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="glossaire">'."\n"; |
$html .= '<p id="glossaire">'."\n"; |
$html .= '<a href="../000-general/glossaire0_640.html">'."\n"; |
$html .= 'Glossaire'."\n"; |
$html .= '</a>'."\n"; |
$html .= '</p></div><div class="text">'."\n"; |
$html .= '<p id="Text">'."\n"; |
$html .= '<a href="../000-general/accueil1_640.html">'."\n"; |
$html .= ' Top'."\n"; |
$html .= '</a>'."\n"; |
$html .= ' </p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '</body>'."\n"; |
$html .= '</html>'."\n"; |
fwrite($f_html, $html); |
fclose($f_html); |
// Ecriture des feuilles (description plantes) |
for ($i = 1; $i < 6; $i++) { |
if (isset($ligneIdentifiant['destination_'.$i]) && $ligneIdentifiant['destination_'.$i] != '') { |
if (substr($ligneIdentifiant['destination_'.$i], 0, 1) == 'p') { |
$this->genererHtmlPlante($ligneIdentifiant['destination_'.$i], $lignesTexteIdentifiant, $ariane, $niveau, $dossier); |
} else { |
$this->genererHtmlTexte($ligneIdentifiant['destination_'.$i], $lignesTexteIdentifiant, $ariane, $niveau, $dossier); |
} |
} |
} |
} |
// Plante |
private function genererHtmlPlante($identifiant, $lignesTexteIdentifiant, $ariane, $niveau, $dossier) { |
$ariane[] = $identifiant; |
$niveau++; |
if (isset ($lignesTexteIdentifiant[$identifiant])) { // Au cas ou des identifiants sont en doubles |
$ligneIdentifiant = $lignesTexteIdentifiant[$identifiant]; |
} |
$nom_latin = ''; |
if (isset($ariane[($niveau - 2)]) && isset($lignesTexteIdentifiant[$ariane[($niveau - 2)]]['texte_1'])) { |
$nom_latin = trim(strrchr($lignesTexteIdentifiant[$ariane[($niveau - 2)]]['texte_1'], ':'), ' :'); |
} |
$f_html = fopen($this->getIni('chemin_fichier_sortie').$dossier.'/'.$identifiant.'.html', 'wb'); |
$html= |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n". |
'<head>'."\n". |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n". |
'<title>Flore BONNIER sur PDA</title>'."\n". |
'<link rel="stylesheet" type="text/css" href="../../style/style_plante.css" media="screen" />'."\n". |
'</head>'."\n"; |
$html .= '<body>'."\n"; |
$html .= '<div class="titre">'."\n"; |
$html .= '<p id="titre">'; |
$html .= $nom_latin; |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="famille">'."\n"; |
$html .= '<p id="famille1">Famille : </p>'."\n"; |
$html .= '<p id="famille2">'; |
$html .= $lignesTexteIdentifiant[$ariane[0]]['titre']; |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="genre">'."\n"; |
$html .= '<p id="genre1">Genre : </p>'."\n"; |
$html .= '<p id="genre2">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['genre']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="nom_latin">'."\n"; |
$html .= '<p id="nom_latin1">Nom Latin : </p>'."\n"; |
$html .= '<p id="nom_latin2">'; |
$html .= $nom_latin; |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="nom_francais">'."\n"; |
$html .= '<p id="nom_francais1">Nom Francais : </p>'."\n"; |
$html .= '<p id="nom_francais2">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['nom_francais']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="nom_commun">'."\n"; |
$html .= '<p id="nom_commun1">Nom Vulgaire : </p>'."\n"; |
$html .= '<p id="nom_commun2">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['nom_vulgaire']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="caracteres">'."\n"; |
$html .= '<p id="caracteres1">Caractéristiques spécifiques : </p>'."\n"; |
$html .= '<p id="caracteres2">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['description']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="habitat">'."\n"; |
$html .= '<p id="habitat1">Habitat / taille / floraison : </p>'."\n"; |
$html .= '<p id="habitat2">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['habitat']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="aire">'."\n"; |
$html .= '<p id="aire1">Aire géographique : </p>'."\n"; |
$html .= '<p id="aire2">'; |
if (isset($ligneIdentifiant)) { |
$html .= $ligneIdentifiant['geographie']; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="identifiant">'."\n"; |
$html .= '<p id="identifiant">'; |
$html .= 'Bonnier : '.$identifiant; |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="planche">'."\n"; |
$html .= '<p id="planche">'; |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="retour">'."\n"; |
$html .= '<p id="retour">'."\n"; |
if (($ariane[$niveau - 2]) && $ariane[$niveau - 2] != '') { |
$html .= '<a href="'.$ariane[$niveau - 2].'.html">'; |
$html .= $lignesTexteIdentifiant[$ariane[$niveau - 2]]['titre']; |
$html .= '</a>'."\n"; |
} |
$html .= '</p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '<div class="glossaire">'."\n"; |
$html .= '<p id="glossaire">'."\n"; |
$html .= '<a href="../000-general/glossaire0_640.html">'."\n"; |
$html .= 'Glossaire'."\n"; |
$html .= '</a>'."\n"; |
$html .= '</p></div><div class="text">'."\n"; |
$html .= '<p id="Text">'."\n"; |
$html .= '<a href="../000-general/accueil1_640.html">'."\n"; |
$html .= ' Top'."\n"; |
$html .= '</a>'."\n"; |
$html .= ' </p>'."\n"; |
$html .= '</div>'."\n"; |
$html .= '</body>'."\n"; |
$html .= '</html>'."\n"; |
fwrite($f_html, $html); |
fclose($f_html); |
} |
private function creerTableBonnier($version, $table) { |
//+------------------------------------------------------------------------------------------------------------+ |
// texte |
$this->type_donnee = $table.'_texte'; |
$requete = 'DROP TABLE IF EXISTS '.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee; |
$this->traiterRequete($requete); |
$requete = 'CREATE TABLE '.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee.' ('. |
'uid int(11) not null auto_increment,'. |
'identifiant varchar(25),'. |
'titre varchar(100),'. |
'texte_1 varchar(255),'. |
'texte_2 varchar(255),'. |
'texte_3 varchar(255),'. |
'texte_4 varchar(255),'. |
'texte_5 varchar(255),'. |
'texte_6 varchar(255),'. |
'destination_1 varchar(25),'. |
'destination_2 varchar(25),'. |
'destination_3 varchar(25),'. |
'destination_4 varchar(25),'. |
'destination_5 varchar(25),'. |
'destination_6 varchar(25),'. |
'planche_croquis varchar(25),'. |
'PRIMARY KEY (uid)'. |
') DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ' ; |
$this->traiterRequete($requete); |
//+------------------------------------------------------------------------------------------------------------+ |
//plante |
$this->type_donnee = $table.'_plante'; |
$requete = 'DROP TABLE IF EXISTS '.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee; |
$this->traiterRequete($requete); |
$requete = 'CREATE TABLE '.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee.' ('. |
'uid int(11) not null auto_increment,'. |
'identifiant varchar(25),'. |
'genre varchar(100),'. |
'nom_francais varchar(100),'. |
'nom_vulgaire varchar(100),'. |
'description varchar(512),'. |
'habitat varchar(255),'. |
'geographie varchar(255),'. |
'planche_croquis varchar(25),'. |
'PRIMARY KEY (uid)'. |
') DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ' ; |
$this->traiterRequete($requete); |
} |
protected function chargerDonnees($table) { |
print "Chargements des données ..."; |
print "\n"; |
$this->type_donnee = $table.'_texte'; |
$this->chargerDonneesSql($table); |
$this->type_donnee = $table.'_plante'; |
$this->chargerDonneesSql($table); |
return; |
} |
protected function chargerDonneesSql($table) { |
echo $this->type_donnee."\n"; |
$fichier_sql = $this->chemin_fichier_tab.$this->projet_nom.'_v'.$this->version.'_'.$this->sous_version.'_'.$this->type_donnee.'.sql'; |
print $fichier_sql."\n"; |
if (file_exists($fichier_sql)) { |
// Des champs textes sont multilignes, d'ou la boucle sur INSERT, marqueur de fin de la requete precedente. |
if ($lines = file($fichier_sql)) { |
$i = 0; |
$ligne_courante = $lines[$i]; |
if (($i + 1) >= count($lines)) { |
$ligne_suivante = 'FIN'; |
} else { |
$ligne_suivante = $lines[$i+1]; |
} |
while ($i < count($lines)) { |
$line_in = $ligne_courante; |
while (($i < count($lines)) && (substr($ligne_suivante, 0, 6) != 'INSERT') && ($ligne_suivante != 'FIN')) { |
$line_in .= $ligne_suivante; |
$i++; |
$ligne_courante = $lines[$i]; |
if (($i + 1) >= count($lines)) { |
$ligne_suivante = 'FIN'; |
} else { |
$ligne_suivante = $lines[$i + 1]; |
} |
} |
$requete = $line_in; |
if (substr($requete, 0, 6) == 'INSERT') { |
$requete = preg_replace('/ VALUES\(/',' VALUES(0,', $requete); |
$this->traiterRequete(utf8_encode($requete)); |
} |
$i++; |
if (($i + 1) >= count($lines)) { |
$ligne_suivante = 'FIN'; |
} else { |
$ligne_courante = $lines[$i]; |
$ligne_suivante = $lines[$i + 1]; |
} |
if ($i == (int) $this->getParam('t')) { |
break; |
} |
} |
} |
} else { |
echo 'Fichier sql introuvable'."\n"; |
} |
} |
} |
?> |
/tags/v5.8-aspergeraie/scripts/modules/bonnier/shell/generer_sql.sh |
---|
New file |
0,0 → 1,298 |
perl xls2sql.pl file="001-Renonculacées-Plante.xls" skip=0 table="bonnier_v0_00_renonculacees_plante" > bonnier_v0_00_renonculacees_plante.sql |
perl xls2sql.pl file="001-Renonculacées-Texte.xls" skip=0 table="bonnier_v0_00_renonculacees_texte" > bonnier_v0_00_renonculacees_texte.sql |
perl xls2sql.pl file="002-Berbéridées-Plante.xls" skip=0 table="bonnier_v0_00_berberidees_plante" > bonnier_v0_00_berberidees_plante.sql |
perl xls2sql.pl file="002-Berbéridées-Texte.xls" skip=0 table="bonnier_v0_00_berberidees_texte" > bonnier_v0_00_berberidees_texte.sql |
perl xls2sql.pl file="003-Nymphéacées-Plante.xls" skip=0 table="bonnier_v0_00_nympheacees_plante" > bonnier_v0_00_nympheacees_plante.sql |
perl xls2sql.pl file="003-Nymphéacées-Texte.xls" skip=0 table="bonnier_v0_00_nympheacees_texte" > bonnier_v0_00_nympheacees_texte.sql |
perl xls2sql.pl file="004-Papavéracées-Plante.xls" skip=0 table="bonnier_v0_00_papaveracees_plante" > bonnier_v0_00_papaveracees_plante.sql |
perl xls2sql.pl file="004-Papavéracées-Texte.xls" skip=0 table="bonnier_v0_00_papaveracees_texte" > bonnier_v0_00_papaveracees_texte.sql |
perl xls2sql.pl file="005-Fumariacées-Plante.xls" skip=0 table="bonnier_v0_00_fumariacees_plante" > bonnier_v0_00_fumariacees_plante.sql |
perl xls2sql.pl file="005-Fumariacées-Texte.xls" skip=0 table="bonnier_v0_00_fumariacees_texte" > bonnier_v0_00_fumariacees_texte.sql |
perl xls2sql.pl file="006-Crucifères-Plante.xls" skip=0 table="bonnier_v0_00_cruciferes_plante" > bonnier_v0_00_cruciferes_plante.sql |
perl xls2sql.pl file="006-Crucifères-Texte.xls" skip=0 table="bonnier_v0_00_cruciferes_texte" > bonnier_v0_00_cruciferes_texte.sql |
perl xls2sql.pl file="007-Capparidées-Plante.xls" skip=0 table="bonnier_v0_00_capparidees_plante" > bonnier_v0_00_capparidees_plante.sql |
perl xls2sql.pl file="007-Capparidées-Texte.xls" skip=0 table="bonnier_v0_00_capparidees_texte" > bonnier_v0_00_capparidees_texte.sql |
perl xls2sql.pl file="008-Cistinées-Plante.xls" skip=0 table="bonnier_v0_00_cistinees_plante" > bonnier_v0_00_cistinees_plante.sql |
perl xls2sql.pl file="008-Cistinées-Texte.xls" skip=0 table="bonnier_v0_00_cistinees_texte" > bonnier_v0_00_cistinees_texte.sql |
perl xls2sql.pl file="009-Violariées-Plante.xls" skip=0 table="bonnier_v0_00_violariees_plante" > bonnier_v0_00_violariees_plante.sql |
perl xls2sql.pl file="009-Violariées-Texte.xls" skip=0 table="bonnier_v0_00_violariees_texte" > bonnier_v0_00_violariees_texte.sql |
perl xls2sql.pl file="010-Résédacées-Plante.xls" skip=0 table="bonnier_v0_00_résedacees_plante" > bonnier_v0_00_résedacees_plante.sql |
perl xls2sql.pl file="010-Résédacées-Texte.xls" skip=0 table="bonnier_v0_00_résedacees_texte" > bonnier_v0_00_résedacees_texte.sql |
perl xls2sql.pl file="011-Droséracées-Plante.xls" skip=0 table="bonnier_v0_00_droseracees_plante" > bonnier_v0_00_droseracees_plante.sql |
perl xls2sql.pl file="011-Droséracées-Texte.xls" skip=0 table="bonnier_v0_00_droseracees_texte" > bonnier_v0_00_droseracees_texte.sql |
perl xls2sql.pl file="012-Polygalées-Plante.xls" skip=0 table="bonnier_v0_00_polygalees_plante" > bonnier_v0_00_polygalees_plante.sql |
perl xls2sql.pl file="012-Polygalées-Texte.xls" skip=0 table="bonnier_v0_00_polygalees_texte" > bonnier_v0_00_polygalees_texte.sql |
perl xls2sql.pl file="013-Frankéniacées-Plante.xls" skip=0 table="bonnier_v0_00_frankeniacees_plante" > bonnier_v0_00_frankeniacees_plante.sql |
perl xls2sql.pl file="013-Frankéniacées-Texte.xls" skip=0 table="bonnier_v0_00_frankeniacees_texte" > bonnier_v0_00_frankeniacees_texte.sql |
perl xls2sql.pl file="014-Caryophyllées-Plante.xls" skip=0 table="bonnier_v0_00_caryophyllees_plante" > bonnier_v0_00_caryophyllees_plante.sql |
perl xls2sql.pl file="014-Caryophyllées-Texte.xls" skip=0 table="bonnier_v0_00_caryophyllees_texte" > bonnier_v0_00_caryophyllees_texte.sql |
perl xls2sql.pl file="015-Elatinées-Plante.xls" skip=0 table="bonnier_v0_00_elatinees_plante" > bonnier_v0_00_elatinees_plante.sql |
perl xls2sql.pl file="015-Elatinées-Texte.xls" skip=0 table="bonnier_v0_00_elatinees_texte" > bonnier_v0_00_elatinees_texte.sql |
perl xls2sql.pl file="016-Linées-Plante.xls" skip=0 table="bonnier_v0_00_linees_plante" > bonnier_v0_00_linees_plante.sql |
perl xls2sql.pl file="016-Linées-Texte.xls" skip=0 table="bonnier_v0_00_linees_texte" > bonnier_v0_00_linees_texte.sql |
perl xls2sql.pl file="017-Tiliacées-Plante.xls" skip=0 table="bonnier_v0_00_tiliacees_plante" > bonnier_v0_00_tiliacees_plante.sql |
perl xls2sql.pl file="017-Tiliacées-Texte.xls" skip=0 table="bonnier_v0_00_tiliacees_texte" > bonnier_v0_00_tiliacees_texte.sql |
perl xls2sql.pl file="018-Malvacées-Plante.xls" skip=0 table="bonnier_v0_00_malvacees_plante" > bonnier_v0_00_malvacees_plante.sql |
perl xls2sql.pl file="018-Malvacées-Texte.xls" skip=0 table="bonnier_v0_00_malvacees_texte" > bonnier_v0_00_malvacees_texte.sql |
perl xls2sql.pl file="019-Géraniées-Plante.xls" skip=0 table="bonnier_v0_00_geraniees_plante" > bonnier_v0_00_geraniees_plante.sql |
perl xls2sql.pl file="019-Géraniées-Texte.xls" skip=0 table="bonnier_v0_00_geraniees_texte" > bonnier_v0_00_geraniees_texte.sql |
perl xls2sql.pl file="020-Hypéricinées-Plante.xls" skip=0 table="bonnier_v0_00_hypericinees_plante" > bonnier_v0_00_hypericinees_plante.sql |
perl xls2sql.pl file="020-Hypéricinées-Texte.xls" skip=0 table="bonnier_v0_00_hypericinees_texte" > bonnier_v0_00_hypericinees_texte.sql |
perl xls2sql.pl file="021-Acérinées-Plante.xls" skip=0 table="bonnier_v0_00_acerinees_plante" > bonnier_v0_00_acerinees_plante.sql |
perl xls2sql.pl file="021-Acérinées-Texte.xls" skip=0 table="bonnier_v0_00_acerinees_texte" > bonnier_v0_00_acerinees_texte.sql |
perl xls2sql.pl file="022-Ampélidées-Plante.xls" skip=0 table="bonnier_v0_00_ampelidees_plante" > bonnier_v0_00_ampelidees_plante.sql |
perl xls2sql.pl file="022-Ampélidées-Texte.xls" skip=0 table="bonnier_v0_00_ampelidees_texte" > bonnier_v0_00_ampelidees_texte.sql |
perl xls2sql.pl file="023-Hippocastanées-Plante.xls" skip=0 table="bonnier_v0_00_hippocastanees_plante" > bonnier_v0_00_hippocastanees_plante.sql |
perl xls2sql.pl file="023-Hippocastanées-Texte.xls" skip=0 table="bonnier_v0_00_hippocastanees_texte" > bonnier_v0_00_hippocastanees_texte.sql |
perl xls2sql.pl file="024-Méliacées-Plante.xls" skip=0 table="bonnier_v0_00_meliacees_plante" > bonnier_v0_00_meliacees_plante.sql |
perl xls2sql.pl file="024-Méliacées-Texte.xls" skip=0 table="bonnier_v0_00_meliacees_texte" > bonnier_v0_00_meliacees_texte.sql |
perl xls2sql.pl file="025-Balsaminées-Plante.xls" skip=0 table="bonnier_v0_00_balsaminees_plante" > bonnier_v0_00_balsaminees_plante.sql |
perl xls2sql.pl file="025-Balsaminées-Texte.xls" skip=0 table="bonnier_v0_00_balsaminees_texte" > bonnier_v0_00_balsaminees_texte.sql |
perl xls2sql.pl file="026-Oxalidées-Plante.xls" skip=0 table="bonnier_v0_00_oxalidees_plante" > bonnier_v0_00_oxalidees_plante.sql |
perl xls2sql.pl file="026-Oxalidées-Texte.xls" skip=0 table="bonnier_v0_00_oxalidees_texte" > bonnier_v0_00_oxalidees_texte.sql |
perl xls2sql.pl file="027-Zygophyllées-Plante.xls" skip=0 table="bonnier_v0_00_zygophyllees_plante" > bonnier_v0_00_zygophyllees_plante.sql |
perl xls2sql.pl file="027-Zygophyllées-Texte.xls" skip=0 table="bonnier_v0_00_zygophyllees_texte" > bonnier_v0_00_zygophyllees_texte.sql |
perl xls2sql.pl file="028-Hespéridées-Plante.xls" skip=0 table="bonnier_v0_00_hesperidees_plante" > bonnier_v0_00_hesperidees_plante.sql |
perl xls2sql.pl file="028-Hespéridées-Texte.xls" skip=0 table="bonnier_v0_00_hesperidees_texte" > bonnier_v0_00_hesperidees_texte.sql |
perl xls2sql.pl file="029-Rutacées-Plante.xls" skip=0 table="bonnier_v0_00_rutacees_plante" > bonnier_v0_00_rutacees_plante.sql |
perl xls2sql.pl file="029-Rutacées-Texte.xls" skip=0 table="bonnier_v0_00_rutacees_texte" > bonnier_v0_00_rutacees_texte.sql |
perl xls2sql.pl file="030-Coriariées-Plante.xls" skip=0 table="bonnier_v0_00_coriariees_plante" > bonnier_v0_00_coriariees_plante.sql |
perl xls2sql.pl file="030-Coriariées-Texte.xls" skip=0 table="bonnier_v0_00_coriariees_texte" > bonnier_v0_00_coriariees_texte.sql |
perl xls2sql.pl file="031-Celastrinées-Plante.xls" skip=0 table="bonnier_v0_00_celastrinees_plante" > bonnier_v0_00_celastrinees_plante.sql |
perl xls2sql.pl file="031-Celastrinées-Texte.xls" skip=0 table="bonnier_v0_00_celastrinees_texte" > bonnier_v0_00_celastrinees_texte.sql |
perl xls2sql.pl file="032-Staphyléacées-Plante.xls" skip=0 table="bonnier_v0_00_staphyleacees_plante" > bonnier_v0_00_staphyleacees_plante.sql |
perl xls2sql.pl file="032-Staphyléacées-Texte.xls" skip=0 table="bonnier_v0_00_staphyleacees_texte" > bonnier_v0_00_staphyleacees_texte.sql |
perl xls2sql.pl file="033-Ilicinées-Plante.xls" skip=0 table="bonnier_v0_00_ilicinees_plante" > bonnier_v0_00_ilicinees_plante.sql |
perl xls2sql.pl file="033-Ilicinées-Texte.xls" skip=0 table="bonnier_v0_00_ilicinees_texte" > bonnier_v0_00_ilicinees_texte.sql |
perl xls2sql.pl file="034-Rhamnées-Plante.xls" skip=0 table="bonnier_v0_00_rhamnees_plante" > bonnier_v0_00_rhamnees_plante.sql |
perl xls2sql.pl file="034-Rhamnées-Texte.xls" skip=0 table="bonnier_v0_00_rhamnees_texte" > bonnier_v0_00_rhamnees_texte.sql |
perl xls2sql.pl file="035-Térébinthacées-Plante.xls" skip=0 table="bonnier_v0_00_térebinthacees_plante" > bonnier_v0_00_térebinthacees_plante.sql |
perl xls2sql.pl file="035-Térébinthacées-Texte.xls" skip=0 table="bonnier_v0_00_térebinthacees_texte" > bonnier_v0_00_térebinthacees_texte.sql |
perl xls2sql.pl file="036-Papilionacées-Plante.xls" skip=0 table="bonnier_v0_00_papilionacees_plante" > bonnier_v0_00_papilionacees_plante.sql |
perl xls2sql.pl file="036-Papilionacées-Texte.xls" skip=0 table="bonnier_v0_00_papilionacees_texte" > bonnier_v0_00_papilionacees_texte.sql |
perl xls2sql.pl file="037-Césalpiniées-Plante.xls" skip=0 table="bonnier_v0_00_cesalpiniees_plante" > bonnier_v0_00_cesalpiniees_plante.sql |
perl xls2sql.pl file="037-Césalpiniées-Texte.xls" skip=0 table="bonnier_v0_00_cesalpiniees_texte" > bonnier_v0_00_cesalpiniees_texte.sql |
perl xls2sql.pl file="038-Rosacées-Plante.xls" skip=0 table="bonnier_v0_00_rosacees_plante" > bonnier_v0_00_rosacees_plante.sql |
perl xls2sql.pl file="038-Rosacées-Texte.xls" skip=0 table="bonnier_v0_00_rosacees_texte" > bonnier_v0_00_rosacees_texte.sql |
perl xls2sql.pl file="039-Granatées-Plante.xls" skip=0 table="bonnier_v0_00_granatees_plante" > bonnier_v0_00_granatees_plante.sql |
perl xls2sql.pl file="039-Granatées-Texte.xls" skip=0 table="bonnier_v0_00_granatees_texte" > bonnier_v0_00_granatees_texte.sql |
perl xls2sql.pl file="040-Onagrariées-Plante.xls" skip=0 table="bonnier_v0_00_onagrariees_plante" > bonnier_v0_00_onagrariees_plante.sql |
perl xls2sql.pl file="040-Onagrariées-Texte.xls" skip=0 table="bonnier_v0_00_onagrariees_texte" > bonnier_v0_00_onagrariees_texte.sql |
perl xls2sql.pl file="041-Myriophyllées-Plante.xls" skip=0 table="bonnier_v0_00_myriophyllees_plante" > bonnier_v0_00_myriophyllees_plante.sql |
perl xls2sql.pl file="041-Myriophyllées-Texte.xls" skip=0 table="bonnier_v0_00_myriophyllees_texte" > bonnier_v0_00_myriophyllees_texte.sql |
perl xls2sql.pl file="042-Hippuridées-Plante.xls" skip=0 table="bonnier_v0_00_hippuridees_plante" > bonnier_v0_00_hippuridees_plante.sql |
perl xls2sql.pl file="042-Hippuridées-Texte.xls" skip=0 table="bonnier_v0_00_hippuridees_texte" > bonnier_v0_00_hippuridees_texte.sql |
perl xls2sql.pl file="043-Callitrichinées-Plante.xls" skip=0 table="bonnier_v0_00_callitrichinees_plante" > bonnier_v0_00_callitrichinees_plante.sql |
perl xls2sql.pl file="043-Callitrichinées-Texte.xls" skip=0 table="bonnier_v0_00_callitrichinees_texte" > bonnier_v0_00_callitrichinees_texte.sql |
perl xls2sql.pl file="044-Ceratophyllées-Plante.xls" skip=0 table="bonnier_v0_00_ceratophyllees_plante" > bonnier_v0_00_ceratophyllees_plante.sql |
perl xls2sql.pl file="044-Ceratophyllées-Texte.xls" skip=0 table="bonnier_v0_00_ceratophyllees_texte" > bonnier_v0_00_ceratophyllees_texte.sql |
perl xls2sql.pl file="045-Lythrariées-Plante.xls" skip=0 table="bonnier_v0_00_lythrariees_plante" > bonnier_v0_00_lythrariees_plante.sql |
perl xls2sql.pl file="045-Lythrariées-Texte.xls" skip=0 table="bonnier_v0_00_lythrariees_texte" > bonnier_v0_00_lythrariees_texte.sql |
perl xls2sql.pl file="046-Philadelphées-Plante.xls" skip=0 table="bonnier_v0_00_philadelphees_plante" > bonnier_v0_00_philadelphees_plante.sql |
perl xls2sql.pl file="046-Philadelphées-Texte.xls" skip=0 table="bonnier_v0_00_philadelphees_texte" > bonnier_v0_00_philadelphees_texte.sql |
perl xls2sql.pl file="047-Tamariscinées-Plante.xls" skip=0 table="bonnier_v0_00_tamariscinees_plante" > bonnier_v0_00_tamariscinees_plante.sql |
perl xls2sql.pl file="047-Tamariscinées-Texte.xls" skip=0 table="bonnier_v0_00_tamariscinees_texte" > bonnier_v0_00_tamariscinees_texte.sql |
perl xls2sql.pl file="048-Myrtacées-Plante.xls" skip=0 table="bonnier_v0_00_myrtacees_plante" > bonnier_v0_00_myrtacees_plante.sql |
perl xls2sql.pl file="048-Myrtacées-Texte.xls" skip=0 table="bonnier_v0_00_myrtacees_texte" > bonnier_v0_00_myrtacees_texte.sql |
perl xls2sql.pl file="049-Cucurbitacées-Plante.xls" skip=0 table="bonnier_v0_00_cucurbitacees_plante" > bonnier_v0_00_cucurbitacees_plante.sql |
perl xls2sql.pl file="049-Cucurbitacées-Texte.xls" skip=0 table="bonnier_v0_00_cucurbitacees_texte" > bonnier_v0_00_cucurbitacees_texte.sql |
perl xls2sql.pl file="050-Portulacées-Plante.xls" skip=0 table="bonnier_v0_00_portulacees_plante" > bonnier_v0_00_portulacees_plante.sql |
perl xls2sql.pl file="050-Portulacées-Texte.xls" skip=0 table="bonnier_v0_00_portulacees_texte" > bonnier_v0_00_portulacees_texte.sql |
perl xls2sql.pl file="051-Paronychiées-Plante.xls" skip=0 table="bonnier_v0_00_paronychiees_plante" > bonnier_v0_00_paronychiees_plante.sql |
perl xls2sql.pl file="051-Paronychiées-Texte.xls" skip=0 table="bonnier_v0_00_paronychiees_texte" > bonnier_v0_00_paronychiees_texte.sql |
perl xls2sql.pl file="052-Crassulacées-Plante.xls" skip=0 table="bonnier_v0_00_crassulacees_plante" > bonnier_v0_00_crassulacees_plante.sql |
perl xls2sql.pl file="052-Crassulacées-Texte.xls" skip=0 table="bonnier_v0_00_crassulacees_texte" > bonnier_v0_00_crassulacees_texte.sql |
perl xls2sql.pl file="053-Cactées-Plante.xls" skip=0 table="bonnier_v0_00_cactees_plante" > bonnier_v0_00_cactees_plante.sql |
perl xls2sql.pl file="053-Cactées-Texte.xls" skip=0 table="bonnier_v0_00_cactees_texte" > bonnier_v0_00_cactees_texte.sql |
perl xls2sql.pl file="054-Ficoïdées-Plante.xls" skip=0 table="bonnier_v0_00_ficoïdees_plante" > bonnier_v0_00_ficoïdees_plante.sql |
perl xls2sql.pl file="054-Ficoïdées-Texte.xls" skip=0 table="bonnier_v0_00_ficoïdees_texte" > bonnier_v0_00_ficoïdees_texte.sql |
perl xls2sql.pl file="055-Grossulariées-Plante.xls" skip=0 table="bonnier_v0_00_grossulariees_plante" > bonnier_v0_00_grossulariees_plante.sql |
perl xls2sql.pl file="055-Grossulariées-Texte.xls" skip=0 table="bonnier_v0_00_grossulariees_texte" > bonnier_v0_00_grossulariees_texte.sql |
perl xls2sql.pl file="056-Saxifragées-Plante.xls" skip=0 table="bonnier_v0_00_saxifragees_plante" > bonnier_v0_00_saxifragees_plante.sql |
perl xls2sql.pl file="056-Saxifragées-Texte.xls" skip=0 table="bonnier_v0_00_saxifragees_texte" > bonnier_v0_00_saxifragees_texte.sql |
perl xls2sql.pl file="057-Ombelliféres-Plante.xls" skip=0 table="bonnier_v0_00_ombelliferes_plante" > bonnier_v0_00_ombelliferes_plante.sql |
perl xls2sql.pl file="057-Ombelliféres-Texte.xls" skip=0 table="bonnier_v0_00_ombelliferes_texte" > bonnier_v0_00_ombelliferes_texte.sql |
perl xls2sql.pl file="058-Araliacées-Plante.xls" skip=0 table="bonnier_v0_00_araliacees_plante" > bonnier_v0_00_araliacees_plante.sql |
perl xls2sql.pl file="058-Araliacées-Texte.xls" skip=0 table="bonnier_v0_00_araliacees_texte" > bonnier_v0_00_araliacees_texte.sql |
perl xls2sql.pl file="059-Cornées-Plante.xls" skip=0 table="bonnier_v0_00_cornees_plante" > bonnier_v0_00_cornees_plante.sql |
perl xls2sql.pl file="059-Cornées-Texte.xls" skip=0 table="bonnier_v0_00_cornees_texte" > bonnier_v0_00_cornees_texte.sql |
perl xls2sql.pl file="060-Loranthacées-Plante.xls" skip=0 table="bonnier_v0_00_loranthacees_plante" > bonnier_v0_00_loranthacees_plante.sql |
perl xls2sql.pl file="060-Loranthacées-Texte.xls" skip=0 table="bonnier_v0_00_loranthacees_texte" > bonnier_v0_00_loranthacees_texte.sql |
perl xls2sql.pl file="061-Caprifoliacées-Plante.xls" skip=0 table="bonnier_v0_00_caprifoliacees_plante" > bonnier_v0_00_caprifoliacees_plante.sql |
perl xls2sql.pl file="061-Caprifoliacées-Texte.xls" skip=0 table="bonnier_v0_00_caprifoliacees_texte" > bonnier_v0_00_caprifoliacees_texte.sql |
perl xls2sql.pl file="062-Rubiacées-Plante.xls" skip=0 table="bonnier_v0_00_rubiacees_plante" > bonnier_v0_00_rubiacees_plante.sql |
perl xls2sql.pl file="062-Rubiacées-Texte.xls" skip=0 table="bonnier_v0_00_rubiacees_texte" > bonnier_v0_00_rubiacees_texte.sql |
perl xls2sql.pl file="063-Valérianées-Plante.xls" skip=0 table="bonnier_v0_00_valerianees_plante" > bonnier_v0_00_valerianees_plante.sql |
perl xls2sql.pl file="063-Valérianées-Texte.xls" skip=0 table="bonnier_v0_00_valerianees_texte" > bonnier_v0_00_valerianees_texte.sql |
perl xls2sql.pl file="064-Dipsacées-Plante.xls" skip=0 table="bonnier_v0_00_dipsacees_plante" > bonnier_v0_00_dipsacees_plante.sql |
perl xls2sql.pl file="064-Dipsacées-Texte.xls" skip=0 table="bonnier_v0_00_dipsacees_texte" > bonnier_v0_00_dipsacees_texte.sql |
perl xls2sql.pl file="065-Composées-Plante.xls" skip=0 table="bonnier_v0_00_composees_plante" > bonnier_v0_00_composees_plante.sql |
perl xls2sql.pl file="065-Composées-Texte.xls" skip=0 table="bonnier_v0_00_composees_texte" > bonnier_v0_00_composees_texte.sql |
perl xls2sql.pl file="066-Ambrosiacées-Plante.xls" skip=0 table="bonnier_v0_00_ambrosiacees_plante" > bonnier_v0_00_ambrosiacees_plante.sql |
perl xls2sql.pl file="066-Ambrosiacées-Texte.xls" skip=0 table="bonnier_v0_00_ambrosiacees_texte" > bonnier_v0_00_ambrosiacees_texte.sql |
perl xls2sql.pl file="067-Lobéliacées-Plante.xls" skip=0 table="bonnier_v0_00_lobeliacees_plante" > bonnier_v0_00_lobeliacees_plante.sql |
perl xls2sql.pl file="067-Lobéliacées-Texte.xls" skip=0 table="bonnier_v0_00_lobeliacees_texte" > bonnier_v0_00_lobeliacees_texte.sql |
perl xls2sql.pl file="068-Campanulacées-Plante.xls" skip=0 table="bonnier_v0_00_campanulacees_plante" > bonnier_v0_00_campanulacees_plante.sql |
perl xls2sql.pl file="068-Campanulacées-Texte.xls" skip=0 table="bonnier_v0_00_campanulacees_texte" > bonnier_v0_00_campanulacees_texte.sql |
perl xls2sql.pl file="069-Vacciniées-Plante.xls" skip=0 table="bonnier_v0_00_vacciniees_plante" > bonnier_v0_00_vacciniees_plante.sql |
perl xls2sql.pl file="069-Vacciniées-Texte.xls" skip=0 table="bonnier_v0_00_vacciniees_texte" > bonnier_v0_00_vacciniees_texte.sql |
perl xls2sql.pl file="070-Ericinées-Plante.xls" skip=0 table="bonnier_v0_00_ericinees_plante" > bonnier_v0_00_ericinees_plante.sql |
perl xls2sql.pl file="070-Ericinées-Texte.xls" skip=0 table="bonnier_v0_00_ericinees_texte" > bonnier_v0_00_ericinees_texte.sql |
perl xls2sql.pl file="071-Pyrolacées-Plante.xls" skip=0 table="bonnier_v0_00_pyrolacees_plante" > bonnier_v0_00_pyrolacees_plante.sql |
perl xls2sql.pl file="071-Pyrolacées-Texte.xls" skip=0 table="bonnier_v0_00_pyrolacees_texte" > bonnier_v0_00_pyrolacees_texte.sql |
perl xls2sql.pl file="072-Monotropées-Plante.xls" skip=0 table="bonnier_v0_00_monotropees_plante" > bonnier_v0_00_monotropees_plante.sql |
perl xls2sql.pl file="072-Monotropées-Texte.xls" skip=0 table="bonnier_v0_00_monotropees_texte" > bonnier_v0_00_monotropees_texte.sql |
perl xls2sql.pl file="073-Lentibulariées-Plante.xls" skip=0 table="bonnier_v0_00_lentibulariees_plante" > bonnier_v0_00_lentibulariees_plante.sql |
perl xls2sql.pl file="073-Lentibulariées-Texte.xls" skip=0 table="bonnier_v0_00_lentibulariees_texte" > bonnier_v0_00_lentibulariees_texte.sql |
perl xls2sql.pl file="074-Primulacées-Plante.xls" skip=0 table="bonnier_v0_00_primulacees_plante" > bonnier_v0_00_primulacees_plante.sql |
perl xls2sql.pl file="074-Primulacées-Texte.xls" skip=0 table="bonnier_v0_00_primulacees_texte" > bonnier_v0_00_primulacees_texte.sql |
perl xls2sql.pl file="075-Ebénacées-Plante.xls" skip=0 table="bonnier_v0_00_ebenacees_plante" > bonnier_v0_00_ebenacees_plante.sql |
perl xls2sql.pl file="075-Ebénacées-Texte.xls" skip=0 table="bonnier_v0_00_ebenacees_texte" > bonnier_v0_00_ebenacees_texte.sql |
perl xls2sql.pl file="076-Styracées-Plante.xls" skip=0 table="bonnier_v0_00_styracees_plante" > bonnier_v0_00_styracees_plante.sql |
perl xls2sql.pl file="076-Styracées-Texte.xls" skip=0 table="bonnier_v0_00_styracees_texte" > bonnier_v0_00_styracees_texte.sql |
perl xls2sql.pl file="077-Oléinées-Plante.xls" skip=0 table="bonnier_v0_00_oleinees_plante" > bonnier_v0_00_oleinees_plante.sql |
perl xls2sql.pl file="077-Oléinées-Texte.xls" skip=0 table="bonnier_v0_00_oleinees_texte" > bonnier_v0_00_oleinees_texte.sql |
perl xls2sql.pl file="078-Jasminées-Plante.xls" skip=0 table="bonnier_v0_00_jasminees_plante" > bonnier_v0_00_jasminees_plante.sql |
perl xls2sql.pl file="078-Jasminées-Texte.xls" skip=0 table="bonnier_v0_00_jasminees_texte" > bonnier_v0_00_jasminees_texte.sql |
perl xls2sql.pl file="079-Apocynées-Plante.xls" skip=0 table="bonnier_v0_00_apocynees_plante" > bonnier_v0_00_apocynees_plante.sql |
perl xls2sql.pl file="079-Apocynées-Texte.xls" skip=0 table="bonnier_v0_00_apocynees_texte" > bonnier_v0_00_apocynees_texte.sql |
perl xls2sql.pl file="080-Asclépiadées-Plante.xls" skip=0 table="bonnier_v0_00_asclepiadees_plante" > bonnier_v0_00_asclepiadees_plante.sql |
perl xls2sql.pl file="080-Asclépiadées-Texte.xls" skip=0 table="bonnier_v0_00_asclepiadees_texte" > bonnier_v0_00_asclepiadees_texte.sql |
perl xls2sql.pl file="081-Gentianées-Plante.xls" skip=0 table="bonnier_v0_00_gentianees_plante" > bonnier_v0_00_gentianees_plante.sql |
perl xls2sql.pl file="081-Gentianées-Texte.xls" skip=0 table="bonnier_v0_00_gentianees_texte" > bonnier_v0_00_gentianees_texte.sql |
perl xls2sql.pl file="082-Polémoniacées-Plante.xls" skip=0 table="bonnier_v0_00_polemoniacees_plante" > bonnier_v0_00_polemoniacees_plante.sql |
perl xls2sql.pl file="082-Polémoniacées-Texte.xls" skip=0 table="bonnier_v0_00_polemoniacees_texte" > bonnier_v0_00_polemoniacees_texte.sql |
perl xls2sql.pl file="083-Convolvulacées-Plante.xls" skip=0 table="bonnier_v0_00_convolvulacees_plante" > bonnier_v0_00_convolvulacees_plante.sql |
perl xls2sql.pl file="083-Convolvulacées-Texte.xls" skip=0 table="bonnier_v0_00_convolvulacees_texte" > bonnier_v0_00_convolvulacees_texte.sql |
perl xls2sql.pl file="084-Cuscutacées-Plante.xls" skip=0 table="bonnier_v0_00_cuscutacees_plante" > bonnier_v0_00_cuscutacees_plante.sql |
perl xls2sql.pl file="084-Cuscutacées-Texte.xls" skip=0 table="bonnier_v0_00_cuscutacees_texte" > bonnier_v0_00_cuscutacees_texte.sql |
perl xls2sql.pl file="085-Ramondiacées-Plante.xls" skip=0 table="bonnier_v0_00_ramondiacees_plante" > bonnier_v0_00_ramondiacees_plante.sql |
perl xls2sql.pl file="085-Ramondiacées-Texte.xls" skip=0 table="bonnier_v0_00_ramondiacees_texte" > bonnier_v0_00_ramondiacees_texte.sql |
perl xls2sql.pl file="086-Borraginées-Plante.xls" skip=0 table="bonnier_v0_00_borraginees_plante" > bonnier_v0_00_borraginees_plante.sql |
perl xls2sql.pl file="086-Borraginées-Texte.xls" skip=0 table="bonnier_v0_00_borraginees_texte" > bonnier_v0_00_borraginees_texte.sql |
perl xls2sql.pl file="087-Solanées-Plante.xls" skip=0 table="bonnier_v0_00_solanees_plante" > bonnier_v0_00_solanees_plante.sql |
perl xls2sql.pl file="087-Solanées-Texte.xls" skip=0 table="bonnier_v0_00_solanees_texte" > bonnier_v0_00_solanees_texte.sql |
perl xls2sql.pl file="088-Verbascées-Plante.xls" skip=0 table="bonnier_v0_00_verbascees_plante" > bonnier_v0_00_verbascees_plante.sql |
perl xls2sql.pl file="088-Verbascées-Texte.xls" skip=0 table="bonnier_v0_00_verbascees_texte" > bonnier_v0_00_verbascees_texte.sql |
perl xls2sql.pl file="089-Scrofularinées-Plante.xls" skip=0 table="bonnier_v0_00_scrofularinees_plante" > bonnier_v0_00_scrofularinees_plante.sql |
perl xls2sql.pl file="089-Scrofularinées-Texte.xls" skip=0 table="bonnier_v0_00_scrofularinees_texte" > bonnier_v0_00_scrofularinees_texte.sql |
perl xls2sql.pl file="090-Orobanchées-Plante.xls" skip=0 table="bonnier_v0_00_orobanchees_plante" > bonnier_v0_00_orobanchees_plante.sql |
perl xls2sql.pl file="090-Orobanchées-Texte.xls" skip=0 table="bonnier_v0_00_orobanchees_texte" > bonnier_v0_00_orobanchees_texte.sql |
perl xls2sql.pl file="091-Labiées-Plante.xls" skip=0 table="bonnier_v0_00_labiees_plante" > bonnier_v0_00_labiees_plante.sql |
perl xls2sql.pl file="091-Labiées-Texte.xls" skip=0 table="bonnier_v0_00_labiees_texte" > bonnier_v0_00_labiees_texte.sql |
perl xls2sql.pl file="092-Acanthacées-Plante.xls" skip=0 table="bonnier_v0_00_acanthacees_plante" > bonnier_v0_00_acanthacees_plante.sql |
perl xls2sql.pl file="092-Acanthacées-Texte.xls" skip=0 table="bonnier_v0_00_acanthacees_texte" > bonnier_v0_00_acanthacees_texte.sql |
perl xls2sql.pl file="093-Verbénacées-Plante.xls" skip=0 table="bonnier_v0_00_verbenacees_plante" > bonnier_v0_00_verbenacees_plante.sql |
perl xls2sql.pl file="093-Verbénacées-Texte.xls" skip=0 table="bonnier_v0_00_verbenacees_texte" > bonnier_v0_00_verbenacees_texte.sql |
perl xls2sql.pl file="094-Plantaginées-Plante.xls" skip=0 table="bonnier_v0_00_plantaginees_plante" > bonnier_v0_00_plantaginees_plante.sql |
perl xls2sql.pl file="094-Plantaginées-Texte.xls" skip=0 table="bonnier_v0_00_plantaginees_texte" > bonnier_v0_00_plantaginees_texte.sql |
perl xls2sql.pl file="095-Plombaginées-Plante.xls" skip=0 table="bonnier_v0_00_plombaginees_plante" > bonnier_v0_00_plombaginees_plante.sql |
perl xls2sql.pl file="095-Plombaginées-Texte.xls" skip=0 table="bonnier_v0_00_plombaginees_texte" > bonnier_v0_00_plombaginees_texte.sql |
perl xls2sql.pl file="096-Globulariées-Plante.xls" skip=0 table="bonnier_v0_00_globulariees_plante" > bonnier_v0_00_globulariees_plante.sql |
perl xls2sql.pl file="096-Globulariées-Texte.xls" skip=0 table="bonnier_v0_00_globulariees_texte" > bonnier_v0_00_globulariees_texte.sql |
perl xls2sql.pl file="097-Phytolaccées-Plante.xls" skip=0 table="bonnier_v0_00_phytolaccees_plante" > bonnier_v0_00_phytolaccees_plante.sql |
perl xls2sql.pl file="097-Phytolaccées-Texte.xls" skip=0 table="bonnier_v0_00_phytolaccees_texte" > bonnier_v0_00_phytolaccees_texte.sql |
perl xls2sql.pl file="098-Amarantacées-Plante.xls" skip=0 table="bonnier_v0_00_amarantacees_plante" > bonnier_v0_00_amarantacees_plante.sql |
perl xls2sql.pl file="098-Amarantacées-Texte.xls" skip=0 table="bonnier_v0_00_amarantacees_texte" > bonnier_v0_00_amarantacees_texte.sql |
perl xls2sql.pl file="099-Salsolacées-Plante.xls" skip=0 table="bonnier_v0_00_salsolacees_plante" > bonnier_v0_00_salsolacees_plante.sql |
perl xls2sql.pl file="099-Salsolacées-Texte.xls" skip=0 table="bonnier_v0_00_salsolacees_texte" > bonnier_v0_00_salsolacees_texte.sql |
perl xls2sql.pl file="100-Polygonées-Plante.xls" skip=0 table="bonnier_v0_00_polygonees_plante" > bonnier_v0_00_polygonees_plante.sql |
perl xls2sql.pl file="100-Polygonées-Texte.xls" skip=0 table="bonnier_v0_00_polygonees_texte" > bonnier_v0_00_polygonees_texte.sql |
perl xls2sql.pl file="101-Daphnoidées-Plante.xls" skip=0 table="bonnier_v0_00_daphnoidees_plante" > bonnier_v0_00_daphnoidees_plante.sql |
perl xls2sql.pl file="101-Daphnoidées-Texte.xls" skip=0 table="bonnier_v0_00_daphnoidees_texte" > bonnier_v0_00_daphnoidees_texte.sql |
perl xls2sql.pl file="102-Laurinées-Plante.xls" skip=0 table="bonnier_v0_00_laurinees_plante" > bonnier_v0_00_laurinees_plante.sql |
perl xls2sql.pl file="102-Laurinées-Texte.xls" skip=0 table="bonnier_v0_00_laurinees_texte" > bonnier_v0_00_laurinees_texte.sql |
perl xls2sql.pl file="103-Santalacées-Plante.xls" skip=0 table="bonnier_v0_00_santalacees_plante" > bonnier_v0_00_santalacees_plante.sql |
perl xls2sql.pl file="103-Santalacées-Texte.xls" skip=0 table="bonnier_v0_00_santalacees_texte" > bonnier_v0_00_santalacees_texte.sql |
perl xls2sql.pl file="104-Eléagnées-Plante.xls" skip=0 table="bonnier_v0_00_eleagnees_plante" > bonnier_v0_00_eleagnees_plante.sql |
perl xls2sql.pl file="104-Eléagnées-Texte.xls" skip=0 table="bonnier_v0_00_eleagnees_texte" > bonnier_v0_00_eleagnees_texte.sql |
perl xls2sql.pl file="105-Cytinées-Plante.xls" skip=0 table="bonnier_v0_00_cytinees_plante" > bonnier_v0_00_cytinees_plante.sql |
perl xls2sql.pl file="105-Cytinées-Texte.xls" skip=0 table="bonnier_v0_00_cytinees_texte" > bonnier_v0_00_cytinees_texte.sql |
perl xls2sql.pl file="106-Aristolochiées-Plante.xls" skip=0 table="bonnier_v0_00_aristolochiees_plante" > bonnier_v0_00_aristolochiees_plante.sql |
perl xls2sql.pl file="106-Aristolochiées-Texte.xls" skip=0 table="bonnier_v0_00_aristolochiees_texte" > bonnier_v0_00_aristolochiees_texte.sql |
perl xls2sql.pl file="107-Empétrées-Plante.xls" skip=0 table="bonnier_v0_00_empetrees_plante" > bonnier_v0_00_empetrees_plante.sql |
perl xls2sql.pl file="107-Empétrées-Texte.xls" skip=0 table="bonnier_v0_00_empetrees_texte" > bonnier_v0_00_empetrees_texte.sql |
perl xls2sql.pl file="108-Euphorbiacées-Plante.xls" skip=0 table="bonnier_v0_00_euphorbiacees_plante" > bonnier_v0_00_euphorbiacees_plante.sql |
perl xls2sql.pl file="108-Euphorbiacées-Texte.xls" skip=0 table="bonnier_v0_00_euphorbiacees_texte" > bonnier_v0_00_euphorbiacees_texte.sql |
perl xls2sql.pl file="109-Morées-Plante.xls" skip=0 table="bonnier_v0_00_morees_plante" > bonnier_v0_00_morees_plante.sql |
perl xls2sql.pl file="109-Morées-Texte.xls" skip=0 table="bonnier_v0_00_morees_texte" > bonnier_v0_00_morees_texte.sql |
perl xls2sql.pl file="110-Ficacées-Plante.xls" skip=0 table="bonnier_v0_00_ficacees_plante" > bonnier_v0_00_ficacees_plante.sql |
perl xls2sql.pl file="110-Ficacées-Texte.xls" skip=0 table="bonnier_v0_00_ficacees_texte" > bonnier_v0_00_ficacees_texte.sql |
perl xls2sql.pl file="111-Celtidées-Plante.xls" skip=0 table="bonnier_v0_00_celtidees_plante" > bonnier_v0_00_celtidees_plante.sql |
perl xls2sql.pl file="111-Celtidées-Texte.xls" skip=0 table="bonnier_v0_00_celtidees_texte" > bonnier_v0_00_celtidees_texte.sql |
perl xls2sql.pl file="112-Ulmacées-Plante.xls" skip=0 table="bonnier_v0_00_ulmacees_plante" > bonnier_v0_00_ulmacees_plante.sql |
perl xls2sql.pl file="112-Ulmacées-Texte.xls" skip=0 table="bonnier_v0_00_ulmacees_texte" > bonnier_v0_00_ulmacees_texte.sql |
perl xls2sql.pl file="113-Urticées-Plante.xls" skip=0 table="bonnier_v0_00_urticees_plante" > bonnier_v0_00_urticees_plante.sql |
perl xls2sql.pl file="113-Urticées-Texte.xls" skip=0 table="bonnier_v0_00_urticees_texte" > bonnier_v0_00_urticees_texte.sql |
perl xls2sql.pl file="114-Cannabinées-Plante.xls" skip=0 table="bonnier_v0_00_cannabinees_plante" > bonnier_v0_00_cannabinees_plante.sql |
perl xls2sql.pl file="114-Cannabinées-Texte.xls" skip=0 table="bonnier_v0_00_cannabinees_texte" > bonnier_v0_00_cannabinees_texte.sql |
perl xls2sql.pl file="115-Juglandées-Plante.xls" skip=0 table="bonnier_v0_00_juglandees_plante" > bonnier_v0_00_juglandees_plante.sql |
perl xls2sql.pl file="115-Juglandées-Texte.xls" skip=0 table="bonnier_v0_00_juglandees_texte" > bonnier_v0_00_juglandees_texte.sql |
perl xls2sql.pl file="116-Cupulifères-Plante.xls" skip=0 table="bonnier_v0_00_cupuliferes_plante" > bonnier_v0_00_cupuliferes_plante.sql |
perl xls2sql.pl file="116-Cupulifères-Texte.xls" skip=0 table="bonnier_v0_00_cupuliferes_texte" > bonnier_v0_00_cupuliferes_texte.sql |
perl xls2sql.pl file="117-Salicinées-Plante.xls" skip=0 table="bonnier_v0_00_salicinees_plante" > bonnier_v0_00_salicinees_plante.sql |
perl xls2sql.pl file="117-Salicinées-Texte.xls" skip=0 table="bonnier_v0_00_salicinees_texte" > bonnier_v0_00_salicinees_texte.sql |
perl xls2sql.pl file="118-Platanées-Plante.xls" skip=0 table="bonnier_v0_00_platanees_plante" > bonnier_v0_00_platanees_plante.sql |
perl xls2sql.pl file="118-Platanées-Texte.xls" skip=0 table="bonnier_v0_00_platanees_texte" > bonnier_v0_00_platanees_texte.sql |
perl xls2sql.pl file="119-Bétulinèes-Plante.xls" skip=0 table="bonnier_v0_00_betulinees_plante" > bonnier_v0_00_betulinees_plante.sql |
perl xls2sql.pl file="119-Bétulinèes-Texte.xls" skip=0 table="bonnier_v0_00_betulinees_texte" > bonnier_v0_00_betulinees_texte.sql |
perl xls2sql.pl file="120-Myricèes-Plante.xls" skip=0 table="bonnier_v0_00_myricees_plante" > bonnier_v0_00_myricees_plante.sql |
perl xls2sql.pl file="120-Myricèes-Texte.xls" skip=0 table="bonnier_v0_00_myricees_texte" > bonnier_v0_00_myricees_texte.sql |
perl xls2sql.pl file="121-Alismacées-Plante.xls" skip=0 table="bonnier_v0_00_alismacees_plante" > bonnier_v0_00_alismacees_plante.sql |
perl xls2sql.pl file="121-Alismacées-Texte.xls" skip=0 table="bonnier_v0_00_alismacees_texte" > bonnier_v0_00_alismacees_texte.sql |
perl xls2sql.pl file="122-Butomées-Plante.xls" skip=0 table="bonnier_v0_00_butomees_plante" > bonnier_v0_00_butomees_plante.sql |
perl xls2sql.pl file="122-Butomées-Texte.xls" skip=0 table="bonnier_v0_00_butomees_texte" > bonnier_v0_00_butomees_texte.sql |
perl xls2sql.pl file="123-Colchicacées-Plante.xls" skip=0 table="bonnier_v0_00_colchicacees_plante" > bonnier_v0_00_colchicacees_plante.sql |
perl xls2sql.pl file="123-Colchicacées-Texte.xls" skip=0 table="bonnier_v0_00_colchicacees_texte" > bonnier_v0_00_colchicacees_texte.sql |
perl xls2sql.pl file="124-Liliacées-Plante.xls" skip=0 table="bonnier_v0_00_liliacees_plante" > bonnier_v0_00_liliacees_plante.sql |
perl xls2sql.pl file="124-Liliacées-Texte.xls" skip=0 table="bonnier_v0_00_liliacees_texte" > bonnier_v0_00_liliacees_texte.sql |
perl xls2sql.pl file="125-Dioscorées-Plante.xls" skip=0 table="bonnier_v0_00_dioscorees_plante" > bonnier_v0_00_dioscorees_plante.sql |
perl xls2sql.pl file="125-Dioscorées-Texte.xls" skip=0 table="bonnier_v0_00_dioscorees_texte" > bonnier_v0_00_dioscorees_texte.sql |
perl xls2sql.pl file="126-Iridées-Plante.xls" skip=0 table="bonnier_v0_00_iridees_plante" > bonnier_v0_00_iridees_plante.sql |
perl xls2sql.pl file="126-Iridées-Texte.xls" skip=0 table="bonnier_v0_00_iridees_texte" > bonnier_v0_00_iridees_texte.sql |
perl xls2sql.pl file="127-Amaryllidées-Plante.xls" skip=0 table="bonnier_v0_00_amaryllidees_plante" > bonnier_v0_00_amaryllidees_plante.sql |
perl xls2sql.pl file="127-Amaryllidées-Texte.xls" skip=0 table="bonnier_v0_00_amaryllidees_texte" > bonnier_v0_00_amaryllidees_texte.sql |
perl xls2sql.pl file="128-Orchidées-Plante.xls" skip=0 table="bonnier_v0_00_orchidees_plante" > bonnier_v0_00_orchidees_plante.sql |
perl xls2sql.pl file="128-Orchidées-Texte.xls" skip=0 table="bonnier_v0_00_orchidees_texte" > bonnier_v0_00_orchidees_texte.sql |
perl xls2sql.pl file="129-Hydrocharidées-Plante.xls" skip=0 table="bonnier_v0_00_hydrocharidees_plante" > bonnier_v0_00_hydrocharidees_plante.sql |
perl xls2sql.pl file="129-Hydrocharidées-Texte.xls" skip=0 table="bonnier_v0_00_hydrocharidees_texte" > bonnier_v0_00_hydrocharidees_texte.sql |
perl xls2sql.pl file="130-Joncaginées-Plante.xls" skip=0 table="bonnier_v0_00_joncaginees_plante" > bonnier_v0_00_joncaginees_plante.sql |
perl xls2sql.pl file="130-Joncaginées-Texte.xls" skip=0 table="bonnier_v0_00_joncaginees_texte" > bonnier_v0_00_joncaginees_texte.sql |
perl xls2sql.pl file="131-Potamées-Plante.xls" skip=0 table="bonnier_v0_00_potamees_plante" > bonnier_v0_00_potamees_plante.sql |
perl xls2sql.pl file="131-Potamées-Texte.xls" skip=0 table="bonnier_v0_00_potamees_texte" > bonnier_v0_00_potamees_texte.sql |
perl xls2sql.pl file="132-Naiadees-Plante.xls" skip=0 table="bonnier_v0_00_naiadees_plante" > bonnier_v0_00_naiadees_plante.sql |
perl xls2sql.pl file="132-Naiadees-Texte.xls" skip=0 table="bonnier_v0_00_naiadees_texte" > bonnier_v0_00_naiadees_texte.sql |
perl xls2sql.pl file="133-Zosteracées-Plante.xls" skip=0 table="bonnier_v0_00_zosteracees_plante" > bonnier_v0_00_zosteracees_plante.sql |
perl xls2sql.pl file="133-Zosteracées-Texte.xls" skip=0 table="bonnier_v0_00_zosteracees_texte" > bonnier_v0_00_zosteracees_texte.sql |
perl xls2sql.pl file="134-Lemnacées-Plante.xls" skip=0 table="bonnier_v0_00_lemnacees_plante" > bonnier_v0_00_lemnacees_plante.sql |
perl xls2sql.pl file="134-Lemnacées-Texte.xls" skip=0 table="bonnier_v0_00_lemnacees_texte" > bonnier_v0_00_lemnacees_texte.sql |
perl xls2sql.pl file="135-Aroidées-Plante.xls" skip=0 table="bonnier_v0_00_aroidees_plante" > bonnier_v0_00_aroidees_plante.sql |
perl xls2sql.pl file="135-Aroidées-Texte.xls" skip=0 table="bonnier_v0_00_aroidees_texte" > bonnier_v0_00_aroidees_texte.sql |
perl xls2sql.pl file="136-Typhacées-Plante.xls" skip=0 table="bonnier_v0_00_typhacees_plante" > bonnier_v0_00_typhacees_plante.sql |
perl xls2sql.pl file="136-Typhacées-Texte.xls" skip=0 table="bonnier_v0_00_typhacees_texte" > bonnier_v0_00_typhacees_texte.sql |
perl xls2sql.pl file="137-Joncées-Plante.xls" skip=0 table="bonnier_v0_00_joncees_plante" > bonnier_v0_00_joncees_plante.sql |
perl xls2sql.pl file="137-Joncées-Texte.xls" skip=0 table="bonnier_v0_00_joncees_texte" > bonnier_v0_00_joncees_texte.sql |
perl xls2sql.pl file="138-Cyperacées-Plante.xls" skip=0 table="bonnier_v0_00_cyperacees_plante" > bonnier_v0_00_cyperacees_plante.sql |
perl xls2sql.pl file="138-Cyperacées-Texte.xls" skip=0 table="bonnier_v0_00_cyperacees_texte" > bonnier_v0_00_cyperacees_texte.sql |
perl xls2sql.pl file="139-Graminées-Plante.xls" skip=0 table="bonnier_v0_00_graminees_plante" > bonnier_v0_00_graminees_plante.sql |
perl xls2sql.pl file="139-Graminées-Texte.xls" skip=0 table="bonnier_v0_00_graminees_texte" > bonnier_v0_00_graminees_texte.sql |
perl xls2sql.pl file="140-Abietinées-Plante.xls" skip=0 table="bonnier_v0_00_abietinees_plante" > bonnier_v0_00_abietinees_plante.sql |
perl xls2sql.pl file="140-Abietinées-Texte.xls" skip=0 table="bonnier_v0_00_abietinees_texte" > bonnier_v0_00_abietinees_texte.sql |
perl xls2sql.pl file="141-Cupressinées-Plante.xls" skip=0 table="bonnier_v0_00_cupressinees_plante" > bonnier_v0_00_cupressinees_plante.sql |
perl xls2sql.pl file="141-Cupressinées-Texte.xls" skip=0 table="bonnier_v0_00_cupressinees_texte" > bonnier_v0_00_cupressinees_texte.sql |
perl xls2sql.pl file="142-Taxinées-Plante.xls" skip=0 table="bonnier_v0_00_taxinees_plante" > bonnier_v0_00_taxinees_plante.sql |
perl xls2sql.pl file="142-Taxinées-Texte.xls" skip=0 table="bonnier_v0_00_taxinees_texte" > bonnier_v0_00_taxinees_texte.sql |
perl xls2sql.pl file="143-Gnetacées-Plante.xls" skip=0 table="bonnier_v0_00_gnetacees_plante" > bonnier_v0_00_gnetacees_plante.sql |
perl xls2sql.pl file="143-Gnetacées-Texte.xls" skip=0 table="bonnier_v0_00_gnetacees_texte" > bonnier_v0_00_gnetacees_texte.sql |
perl xls2sql.pl file="144-Fougères-Plante.xls" skip=0 table="bonnier_v0_00_fougeres_plante" > bonnier_v0_00_fougeres_plante.sql |
perl xls2sql.pl file="144-Fougères-Texte.xls" skip=0 table="bonnier_v0_00_fougeres_texte" > bonnier_v0_00_fougeres_texte.sql |
perl xls2sql.pl file="145-Ophioglossées-Plante.xls" skip=0 table="bonnier_v0_00_ophioglossees_plante" > bonnier_v0_00_ophioglossees_plante.sql |
perl xls2sql.pl file="145-Ophioglossées-Texte.xls" skip=0 table="bonnier_v0_00_ophioglossees_texte" > bonnier_v0_00_ophioglossees_texte.sql |
perl xls2sql.pl file="146-Marsiliacées-Plante.xls" skip=0 table="bonnier_v0_00_marsiliacees_plante" > bonnier_v0_00_marsiliacees_plante.sql |
perl xls2sql.pl file="146-Marsiliacées-Texte.xls" skip=0 table="bonnier_v0_00_marsiliacees_texte" > bonnier_v0_00_marsiliacees_texte.sql |
perl xls2sql.pl file="147-Equisétacées-Plante.xls" skip=0 table="bonnier_v0_00_equisetacees_plante" > bonnier_v0_00_equisetacees_plante.sql |
perl xls2sql.pl file="147-Equisétacées-Texte.xls" skip=0 table="bonnier_v0_00_equisetacees_texte" > bonnier_v0_00_equisetacees_texte.sql |
perl xls2sql.pl file="148-Isoétées-Plante.xls" skip=0 table="bonnier_v0_00_isoetees_plante" > bonnier_v0_00_isoetees_plante.sql |
perl xls2sql.pl file="148-Isoétées-Texte.xls" skip=0 table="bonnier_v0_00_isoetees_texte" > bonnier_v0_00_isoetees_texte.sql |
perl xls2sql.pl file="149-Lycopodiacées-Plante.xls" skip=0 table="bonnier_v0_00_lycopodiacees_plante" > bonnier_v0_00_lycopodiacees_plante.sql |
perl xls2sql.pl file="149-Lycopodiacées-Texte.xls" skip=0 table="bonnier_v0_00_lycopodiacees_texte" > bonnier_v0_00_lycopodiacees_texte.sql |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/bonnier/shell/xls2sql.pl |
---|
New file |
0,0 → 1,205 |
#!/usr/bin/perl |
# $Date: 2005/10/19 10:14:00 $ |
# Excel to SQL statements translator. |
# Needs the Spreadsheet::ParseExcel module from CPAN |
# |
# Example usage: |
# |
# xls2sql.pl help |
# xls2sql.pl file=6960_TS_Bressanone_Brixen.xls \ |
# coldefs="year INTEGER,MEAN1 DOUBLE PRECISION,MEAN2 DOUBLE PRECISION,MEAN3 DOUBLE PRECISION" |
# |
# Released under GPLv2.0 |
# by Daniel Calvelo Aros (dca@users.sf.net) |
# |
# few modifications by MN (why not reading 'Learning Perl' O'Reilly book) |
#use strict; |
use English; |
use Spreadsheet::ParseExcel; |
# gparser-like options: |
# option label => [ref to var to hold opt value, "description", default value or undef for no default] |
%gopts = ( file => [\$file, "Name of input excel spreadsheet file", undef], |
skip => [\$skip, "Number of rows to skip at the beginning of sheet", 0], |
table => [\$tablename,"Name of output table", "mytable"], |
rows => [\$nrows, "Number of rows to extract", undef], |
sheet => [\$sheetn, "Sheet number to convert from the workbook, counting from 1", 1], |
coldefs=> [\$coldefs, "Column definitions as in SQL", "auto"], |
nodata => [\$nodata, "No data character(s) used in the Excel table", ""], |
help => [\$help, "Help, of course", undef], |
debug => [\$DEBUG, "Debugging flag, for developers only", 0]); |
#function defined below: |
&parse_opts(); |
#-- Open and look for obvious errors |
my $wkbk = |
Spreadsheet::ParseExcel::Workbook->Parse($file); |
if( !defined $wkbk->{Worksheet}) {die "Error:couldn't parse file $file\n"} |
my($iR, $iC, $sheet, $ncols, $roffset, $rsize); |
$sheet = @{$wkbk->{Worksheet}}[--$sheetn]; #-- Numbering starts at 1 for the user |
$ncols = $sheet->{MaxCol} or die "Error:the specified sheet $sheetn does not contain data\n"; |
$ncols -= $sheet->{MinCol} if defined $sheet->{MinCol} ; |
$roffset = $sheet->{MinRow}-1; |
$rsize = $sheet->{MaxRow} - $sheet->{MinRow}; |
die "Error:the specified worksheet seems to contain only one line\n" if $rsize == 0; |
$roffset += $skip; |
$lastrow = ( defined $nrows |
? $nrows + $roffset -1 |
: $sheet->{MaxRow} ); |
die "Invalid skip option: the sheet only has $rsize rows" if $roffset >= $rsize - 1; |
my (@types, @sqltypes, @firstrow, @titlerow); |
if($coldefs ne "auto"){ |
#-- We have user-defined column definitions |
#-- Check them |
$coldefs =~ s/^\s*//; |
$coldefs =~ s/\s*$//; |
@defs = split ",", $coldefs; |
foreach $i (0..$#defs){ |
($colname, $typedef) = split /\s+/,$defs[$i],2; |
die "Column specification $i: can't parse SQL type definition '$typedef' (should be INTEGER, DOUBLE PRECISION, CHAR).\n" if $typedef !~ /INTEGER|DOUBLE PRECISION|CHAR/i; |
die "Column name '$colname' for column $i contains spurious characters (no spaces permitted in list).\n" if $colname !~ /[a-zA-Z][a-zA-Z_0-9]*/; |
push @sqltypes, $typedef; |
push @titles, $colname; |
} |
}else{ |
#-- Inspect file for types: |
#-- First estimate initial types from the first row of data |
@firstrow = @{$sheet->{Cells}[$roffset+1]}; |
@types = map { $_->{Type}} @firstrow; |
%cvt = (Text=>'CHAR',Numeric=>'INTEGER',Date=>'DOUBLE'); |
@sqltypes = map { $cvt{$_} } @types; |
@lens = map { 0 } @types; |
print STDERR "\nTypes:", join ";", @types if $DEBUG; |
print STDERR "\nInitial sqltypes:", join ";", @sqltypes if $DEBUG; |
#-- Then adjust widths and numeric type from the data |
for(my $iR = $roffset ; $iR <= $lastrow ; $iR++) { |
for(my $iC = $sheet->{MinCol} ;$iC <= $sheet->{MaxCol} ; $iC++) { |
$cell = $sheet->{Cells}[$iR][$iC]; |
next if !defined $cell; |
$cellvalue = $cell->Value; |
if($types[$iC] eq 'Text'){ |
$thislength = length( $cellvalue ); |
$lens[$iC] = $thislength if $thislength > $lens[$iC]; |
}else{ |
if( $cellvalue =~ /[\.,]/ ){ |
$sqltypes[$iC] = 'DOUBLE PRECISION'; |
} |
if( $cellvalue =~ /[a-df-z]/ ){ |
$sqltypes[$iC] = 'CHAR'; $lens[$iC] = length( $cellvalue); |
} |
} |
} |
} |
foreach $i (0..$#sqltypes){ |
if( $sqltypes[$i] eq 'CHAR' ){ |
$sqltypes[$i] .= "($lens[$i])"; |
} |
} |
print STDERR "\nAdjusted sqltypes:", join ";", @sqltypes if $DEBUG; |
#-- Generate field names from the title row |
@titlerow = @{$sheet->{Cells}[$roffset]}; |
print STDERR "\nTitlerow:", join ";", map { defined $_ ? $_->Value : "" } @titlerow if $DEBUG; |
$varname = "V000"; |
@titles = map { |
/^[^a-zA-Z]/ ? $varname++ : $_ |
} map { |
if( defined $_ && length > 0 ) {$_=$_->Value;y/a-z/A-Z/;s/[^a-zA-Z_0-9]/_/g} |
else { $_=$varname++ } |
$_; |
} @titlerow; |
map { $istitle{$_}++ } @titles; |
foreach $i (reverse 0..$#titles){ |
if( $istitle{$titles[$i]} > 1){ |
$titles[$i] .= --$istitle{$titles[$i]}; |
} |
} |
while( $#titles < $ncols ){ #Missing titles, according to the size of the sheet |
push @titles, $varname++; |
push @sqltypes, "CHAR(32)"; |
} |
print STDERR "\nTitles:" ,join ";", @titles if $DEBUG; |
print STDERR "\n" if $DEBUG; |
} |
#-- Write out |
print "CREATE TABLE $tablename ("; |
print join ",", map {"$titles[$_] $sqltypes[$_]"} (0..$#titles); |
print ");\n"; |
if($coldefs eq "auto"){ |
$lastcol = $sheet->{MaxCol}; |
}else{ |
$lastcol = $#sqltypes + $sheet->{MinCol}; |
foreach $i (reverse 0..$#sqltypes){ |
$sqltypes[$i + $sheet->{MinCol}] = $sqltypes[$i]; |
} |
} |
for(my $iR = $roffset+1 ; $iR <= $lastrow ; $iR++) { |
print "INSERT INTO $tablename VALUES("; |
print join ",", map { |
my $c = $sheet->{Cells}[$iR][$_]; |
# defined $c ? '"'.&cast($c->Value,$sqltypes[$_]).'"' : NULL |
defined $c ? ''.&cast($c->Value,$sqltypes[$_]).'' : NULL |
} ($sheet->{MinCol}..$lastcol); |
print ");\n" |
} |
sub cast($$){ |
my ($value, $sqltype) = @_; |
if( length($value)>0 ){ |
if ($value eq $nodata){ |
$value = "NULL"; # no data coded with char |
}else{ |
if( $sqltype =~ /CHAR\s*\((\d+)\)/i ){ |
$value =~ s/[\n\r]/ /gm; |
$value =~ s/"/\\"/g; |
$value =~ s/'/\\'/g; |
# $value = substr( $value, 0, $1 ); |
$value = '\''.substr( $value, 0, $1 ).'\''; |
}elsif( $sqltype =~ /DOUBLE PRECISION/i ){ |
$value += 0; |
}elsif( $sqltype =~ /INTEGER/i ){ |
$value = int $value; |
}else{ |
die "Unknown SQL type '$sqltype'; can't typecast '$value' to that type.\n"; |
} |
} |
}else{ |
$value = "NULL"; # no data |
} |
} |
sub parse_opts(){ |
for $o (sort keys %gopts){ |
if( defined $gopts{$o}[2] ){ |
${$gopts{$o}[0]} = $gopts{$o}[2]; |
} |
for $arg (@ARGV){ |
$arg =~ /^\Q$o\E(?:\s*=\s*(.+)$)?/; |
if( length($1)>0 ){ |
${$gopts{$o}[0]} = $1; |
}elsif( $& ){ |
${$gopts{$o}[0]} = 1; |
} |
} |
} |
if($help){ |
select STDERR; |
print "\n$PROGRAM_NAME : extract sheets from an excel workbook and\n"; |
print "produce SQL statements that create the database\n"; |
print "\nArguments (use grass style, i.e. arg=value):\n"; |
foreach (keys %gopts){ $longest = $longest < length() ? length() : $longest } |
foreach $arg (grep {!/help/} keys %gopts){ |
print " $arg".(" "x($longest+2-length $arg)); |
print $gopts{$arg}[1]; |
print " (default: ".$gopts{$arg}[2].")" if defined $gopts{$arg}[2]; |
print "\n"; |
} |
select STDOUT; |
die "\n"; |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/bonnier/shell/charger_sql.sh |
---|
New file |
0,0 → 1,149 |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/001-Renonculacees" -table renonculacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/002-Berberidees" -table berberidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/003-Nympheacees" -table nympheacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/004-Papaveracees" -table papaveracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/005-Fumariacees" -table fumariacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/006-Cruciferes" -table cruciferes |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/007-Capparidees" -table capparidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/008-Cistinees" -table cistinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/009-Violariees" -table violariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/010-Resedacees" -table resedacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/011-Droseracees" -table droseracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/012-Polygalees" -table polygalees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/013-Frankeniacees" -table frankeniacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/014-Caryophyllees" -table caryophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/015-Elatinees" -table elatinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/016-Linees" -table linees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/017-Tiliacees" -table tiliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/018-Malvacees" -table malvacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/019-Geraniees" -table geraniees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/020-Hypericinees" -table hypericinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/021-Acerinees" -table acerinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/022-Ampelidees" -table ampelidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/023-Hippocastanees" -table hippocastanees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/024-Meliacees" -table meliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/025-Balsaminees" -table balsaminees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/026-tablexalidees" -table oxalidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/027-Zygophyllees" -table zygophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/028-Hesperidees" -table hesperidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/029-Rutacees" -table rutacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/030-Coriariees" -table coriariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/031-Celastrinees" -table celastrinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/032-Staphyleacees" -table staphyleacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/033-Ilicinees" -table ilicinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/034-Rhamnees" -table rhamnees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/035-Terebinthacees" -table terebinthacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/036-Papilionacees" -table papilionacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/037-Cesalpiniees" -table cesalpiniees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/038-Rosacees" -table rosacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/039-Granatees" -table granatees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/040-tablenagrariees" -table onagrariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/041-Myriophyllees" -table myriophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/042-Hippuridees" -table hippuridees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/043-Callitrichinees" -table callitrichinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/044-Ceratophyllees" -table ceratophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/045-Lythrariees" -table lythrariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/046-Philadelphees" -table philadelphees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/047-Tamariscinees" -table tamariscinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/048-Myrtacees" -table myrtacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/049-Cucurbitacees" -table cucurbitacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/050-Portulacees" -table portulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/051-Paronychiees" -table paronychiees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/052-Crassulacees" -table crassulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/053-Cactees" -table cactees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/054-Ficoïdees" -table ficoïdees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/055-Grossulariees" -table grossulariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/056-Saxifragees" -table saxifragees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/057-tablembelliferes" -table ombelliferes |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/058-Araliacees" -table araliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/059-Cornees" -table cornees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/060-Loranthacees" -table loranthacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/061-Caprifoliacees" -table caprifoliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/062-Rubiacees" -table rubiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/063-Valerianees" -table valerianees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/064-Dipsacees" -table dipsacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/065-Composees" -table composees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/066-Ambrosiacees" -table ambrosiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/067-Lobeliacees" -table lobeliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/068-Campanulacees" -table campanulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/069-Vacciniees" -table vacciniees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/070-Ericinees" -table ericinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/071-Pyrolacees" -table pyrolacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/072-Monotropees" -table monotropees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/073-Lentibulariees" -table lentibulariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/074-Primulacees" -table primulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/075-Ebenacees" -table ebenacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/076-Styracees" -table styracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/077-tableleinees" -table oleinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/078-Jasminees" -table jasminees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/079-Apocynees" -table apocynees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/080-Asclepiadees" -table asclepiadees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/081-Gentianees" -table gentianees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/082-Polemoniacees" -table polemoniacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/083-Convolvulacees" -table convolvulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/084-Cuscutacees" -table cuscutacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/085-Ramondiacees" -table ramondiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/086-Borraginees" -table borraginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/087-Solanees" -table solanees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/088-Verbascees" -table verbascees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/089-Scrofularinees" -table scrofularinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/090-tablerobanchees" -table orobanchees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/091-Labiees" -table labiees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/092-Acanthacees" -table acanthacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/093-Verbenacees" -table verbenacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/094-Plantaginees" -table plantaginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/095-Plombaginees" -table plombaginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/096-Globulariees" -table globulariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/097-Phytolaccees" -table phytolaccees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/098-Amarantacees" -table amarantacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/099-Salsolacees" -table salsolacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/100-Polygonees" -table polygonees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/101-Daphnoidees" -table daphnoidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/102-Laurinees" -table laurinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/103-Santalacees" -table santalacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/104-Eleagnees" -table eleagnees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/105-Cytinees" -table cytinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/106-Aristolochiees" -table aristolochiees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/107-Empetrees" -table empetrees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/108-Euphorbiacees" -table euphorbiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/109-Morees" -table morees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/110-Ficacees" -table ficacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/111-Celtidees" -table celtidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/112-Ulmacees" -table ulmacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/113-Urticees" -table urticees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/114-Cannabinees" -table cannabinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/115-Juglandees" -table juglandees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/116-Cupuliferes" -table cupuliferes |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/117-Salicinees" -table salicinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/118-Platanees" -table platanees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/119-Betulinees" -table betulinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/120-Myricees" -table myricees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/121-Alismacees" -table alismacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/122-Butomees" -table butomees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/123-Colchicacees" -table colchicacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/124-Liliacees" -table liliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/125-Dioscorees" -table dioscorees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/126-Iridees" -table iridees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/127-Amaryllidees" -table amaryllidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/128-tablerchidees" -table orchidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/129-Hydrocharidees" -table hydrocharidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/130-Joncaginees" -table joncaginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/131-Potamees" -table potamees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/132-Naiadees" -table naiadees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/133-Zosteracees" -table zosteracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/134-Lemnacees" -table lemnacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/135-Aroidees" -table aroidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/136-Typhacees" -table typhacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/137-Joncees" -table joncees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/138-Cyperacees" -table cyperacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/139-Graminees" -table graminees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/140-Abietinees" -table abietinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/141-Cupressinees" -table cupressinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/142-Taxinees" -table taxinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/143-Gnetacees" -table gnetacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/144-Fougeres" -table fougeres |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/145-tablephioglossees" -table ophioglossees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/146-Marsiliacees" -table marsiliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/147-Equisetacees" -table equisetacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/148-Isoetees" -table isoetees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a charger -dossier "menus/149-Lycopodiacees" -table lycopodiacees |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/bonnier/shell/generer_html.sh |
---|
New file |
0,0 → 1,149 |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/001-Renonculacees" -table renonculacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/002-Berberidees" -table berberidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/003-Nympheacees" -table nympheacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/004-Papaveracees" -table papaveracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/005-Fumariacees" -table fumariacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/006-Cruciferes" -table cruciferes |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/007-Capparidees" -table capparidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/008-Cistinees" -table cistinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/009-Violariees" -table violariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/010-Resedacees" -table resedacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/011-Droseracees" -table droseracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/012-Polygalees" -table polygalees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/013-Frankeniacees" -table frankeniacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/014-Caryophyllees" -table caryophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/015-Elatinees" -table elatinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/016-Linees" -table linees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/017-Tiliacees" -table tiliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/018-Malvacees" -table malvacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/019-Geraniees" -table geraniees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/020-Hypericinees" -table hypericinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/021-Acerinees" -table acerinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/022-Ampelidees" -table ampelidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/023-Hippocastanees" -table hippocastanees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/024-Meliacees" -table meliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/025-Balsaminees" -table balsaminees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/026-tablexalidees" -table oxalidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/027-Zygophyllees" -table zygophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/028-Hesperidees" -table hesperidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/029-Rutacees" -table rutacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/030-Coriariees" -table coriariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/031-Celastrinees" -table celastrinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/032-Staphyleacees" -table staphyleacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/033-dossierlicinees" -table ilicinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/034-Rhamnees" -table rhamnees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/035-Terebinthacees" -table terebinthacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/036-Papilionacees" -table papilionacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/037-Cesalpiniees" -table cesalpiniees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/038-Rosacees" -table rosacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/039-Granatees" -table granatees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/040-tablenagrariees" -table onagrariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/041-Myriophyllees" -table myriophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/042-Hippuridees" -table hippuridees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/043-Callitrichinees" -table callitrichinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/044-Ceratophyllees" -table ceratophyllees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/045-Lythrariees" -table lythrariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/046-Philadelphees" -table philadelphees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/047-Tamariscinees" -table tamariscinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/048-Myrtacees" -table myrtacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/049-Cucurbitacees" -table cucurbitacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/050-Portulacees" -table portulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/051-Paronychiees" -table paronychiees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/052-Crassulacees" -table crassulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/053-Cactees" -table cactees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/054-Ficoïdees" -table ficoïdees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/055-Grossulariees" -table grossulariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/056-Saxifragees" -table saxifragees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/057-tablembelliferes" -table ombelliferes |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/058-Araliacees" -table araliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/059-Cornees" -table cornees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/060-Loranthacees" -table loranthacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/061-Caprifoliacees" -table caprifoliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/062-Rubiacees" -table rubiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/063-Valerianees" -table valerianees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/064-Dipsacees" -table dipsacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/065-Composees" -table composees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/066-Ambrosiacees" -table ambrosiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/067-Lobeliacees" -table lobeliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/068-Campanulacees" -table campanulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/069-Vacciniees" -table vacciniees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/070-Ericinees" -table ericinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/071-Pyrolacees" -table pyrolacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/072-Monotropees" -table monotropees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/073-Lentibulariees" -table lentibulariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/074-Primulacees" -table primulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/075-Ebenacees" -table ebenacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/076-Styracees" -table styracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/077-tableleinees" -table oleinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/078-Jasminees" -table jasminees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/079-Apocynees" -table apocynees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/080-Asclepiadees" -table asclepiadees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/081-Gentianees" -table gentianees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/082-Polemoniacees" -table polemoniacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/083-Convolvulacees" -table convolvulacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/084-Cuscutacees" -table cuscutacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/085-Ramondiacees" -table ramondiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/086-Borraginees" -table borraginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/087-Solanees" -table solanees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/088-Verbascees" -table verbascees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/089-Scrofularinees" -table scrofularinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/090-tablerobanchees" -table orobanchees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/091-Labiees" -table labiees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/092-Acanthacees" -table acanthacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/093-Verbenacees" -table verbenacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/094-Plantaginees" -table plantaginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/095-Plombaginees" -table plombaginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/096-Globulariees" -table globulariees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/097-Phytolaccees" -table phytolaccees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/098-Amarantacees" -table amarantacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/099-Salsolacees" -table salsolacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/100-Polygonees" -table polygonees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/101-Daphnoidees" -table daphnoidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/102-Laurinees" -table laurinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/103-Santalacees" -table santalacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/104-Eleagnees" -table eleagnees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/105-Cytinees" -table cytinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/106-Aristolochiees" -table aristolochiees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/107-Empetrees" -table empetrees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/108-Euphorbiacees" -table euphorbiacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/109-Morees" -table morees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/110-Ficacees" -table ficacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/111-Celtidees" -table celtidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/112-Ulmacees" -table ulmacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/113-Urticees" -table urticees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/114-Cannabinees" -table cannabinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/115-Juglandees" -table juglandees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/116-Cupuliferes" -table cupuliferes |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/117-Salicinees" -table salicinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/118-Platanees" -table platanees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/119-Betulinees" -table betulinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/120-Myricees" -table myricees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/121-Alismacees" -table alismacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/122-Butomees" -table butomees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/123-Colchicacees" -table colchicacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/124-Liliacees" -table liliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/125-Dioscorees" -table dioscorees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/126-dossierridees" -table iridees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/127-Amaryllidees" -table amaryllidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/128-tablerchidees" -table orchidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/129-Hydrocharidees" -table hydrocharidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/130-Joncaginees" -table joncaginees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/131-Potamees" -table potamees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/132-Naiadees" -table naiadees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/133-Zosteracees" -table zosteracees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/134-Lemnacees" -table lemnacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/135-Aroidees" -table aroidees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/136-Typhacees" -table typhacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/137-Joncees" -table joncees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/138-Cyperacees" -table cyperacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/139-Graminees" -table graminees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/140-Abietinees" -table abietinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/141-Cupressinees" -table cupressinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/142-Taxinees" -table taxinees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/143-Gnetacees" -table gnetacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/144-Fougeres" -table fougeres |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/145-tablephioglossees" -table ophioglossees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/146-Marsiliacees" -table marsiliacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/147-Equisetacees" -table equisetacees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/148-dossiersoetees" -table isoetees |
/opt/lampp/bin/php ../../../script.php bonnier -p bonnier -a html -dossier "menus/149-Lycopodiacees" -table lycopodiacees |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/bonnier/bonnier.ini |
---|
New file |
0,0 → 1,20 |
; Encodage : UTF-8 |
; Exemple de fichier de configuration d'un projet |
; Les commentaires commencent par ';', comme dans php.ini |
; Indique le nom du projet |
projet_nom = bonnier |
; Indique le nombre sur un chiffre de la version du projet |
version = 0 |
; Indique le nombre sur deux chiffres de la sous version du projet |
sous_version = 00 |
; Indique la date de début de cette version du projet |
date_debut = "2009-12-11 00:00:00" |
; Indique la date de fin de cette version du projet |
date_fin = NULL |
; Indique le chemin où les fichier html vont être générés |
chemin_fichier_sortie = "php:'/home/'.'david'.'/Bureau/bonnierhtml/'" |
; Indique le chemin où trouver le fichier du projet contenant les données à charger puis standardiser |
chemin_fichier_tab = "php:'/home/'.'david'.'/Bureau/bonnierhtml/'" |
; Indique le chemin où stocker le fichier de log |
log_chemin = "php:'/home/'.'david'.'/Bureau/bonnierhtml/'" |
/tags/v5.8-aspergeraie/scripts/modules/osm/config.ini |
---|
New file |
0,0 → 1,12 |
; Base de données contenant les infos provenant d'OSM |
bdd_osm_nom = "tb_osm" |
; Ajouter les nouvelles version à la suite dans versions et versionsDonnees. |
version = "2.0" |
dossierSql = "{ref:dossierDonneesEflore}osm/" |
[fichiers] |
structureSql = "osm_v{ref:version}.sql" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:version}/{ref:fichiers.structureSql}" |
/tags/v5.8-aspergeraie/scripts/modules/osm/Osm.php |
---|
New file |
0,0 → 1,65 |
<?php |
//declare(encoding='UTF-8'); |
/** |
* Exemple de lancement du script : : |
* 1. Création de la base de données : |
* /opt/lampp/bin/php cli.php osm -a communes -m manuel -v 3 |
* |
* @category php 5.4 |
* @package DEL |
* @subpackage Scripts |
* @author Aurélien PERONNET <aurelien@tela-botanica.org> |
* @copyright Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org) |
* @license CeCILL v2 http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt |
* @license GNU-GPL http://www.gnu.org/licenses/gpl.html |
*/ |
class Osm extends EfloreScript { |
const PROJET_NOM = 'osm'; |
protected $parametres_autorises = array( |
'-m' => array(false, 'auto', 'Mode «auto» ou «manuel». En manuel, les compteurs dans les boucles sont affichés.')); |
public function executer() { |
try { |
$this->initialiserProjet(self::PROJET_NOM); |
// Lancement de l'action demandée |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerStructureSql' : |
$this->chargerStructureSql(); |
break; |
case 'cm' : |
case 'cmCreer' : |
case 'cmSupprimer' : |
$script = $this->chargerClasse('FranceCommunes'); |
$script->executer(); |
break; |
case 'za' : |
case 'zaCreer' : |
case 'zaCorriger' : |
case 'zaMajIdZG' : |
case 'zaSupprimer' : |
$script = $this->chargerClasse('ZonesAdmin'); |
$script->executer(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
print "\n";// Pour ramener à la ligne en fin de script |
} |
protected function initialiserProjet($projetNom) { |
$this->projetNom = $projetNom; |
} |
private function chargerClasse($classe) { |
require_once $classe.'.php'; |
$conteneur = new Conteneur($this->parametres); |
return new $classe($conteneur); |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/shell/carto-osm-service.sh |
---|
New file |
0,0 → 1,41 |
#!/bin/sh |
#/etc/rc.d/init.d/ |
# |
# Jean-Pascal MILCENT & Mohcen BENMOUNAH [19 juillet 2011] |
# Service de lancement des scripts d'integration des donnees OSM pour le service de Geocadage Inverse |
# |
case "$1" in |
start) |
echo "Demarrage de carto-osm-cron :" |
nohup /usr/local/sbin/carto-osm-cron 1>/dev/null 2>/dev/null & |
;; |
stop) |
echo "Arret de carto-osm-cron" |
PID=`ps -eaf | grep carto-osm-cron | grep -v grep | tr -s ' ' | cut -d' ' -f2 | head -n1` |
kill -9 ${PID} |
;; |
status) |
echo -n "Voici les PID du processus carto-osm-cron :" |
PID=`ps -eaf | grep carto-osm-cron | grep -v grep | tr -s ' ' | cut -d' ' -f2 | head -n1` |
echo ${PID} |
;; |
*) |
echo "Usage: {start|stop|status}" |
exit 1 |
;; |
esac |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/shell/carto-osm-cron.sh |
---|
New file |
0,0 → 1,30 |
#!/bin/bash |
# |
# Mohcen BENMOUNAH & Jean-Pascal MILCENT [19 juillet 2011] |
# /etc/init.d/carto-osm : demarage/arrete/etat du cron de l'integration des donnees OSM pour le Geocodage Inverse (carto-osm) |
# Lancement toutes les semaines le samedi matin après 3h00 |
while true |
do |
JOUR=$(date "+%u") |
# Si nous sommes samedi (=6) |
if [ $JOUR -eq 6 ] ; then |
HEURE=$(date "+%H") |
# Si nous sommes à 3 heures du matin |
if [ $HEURE -eq 3 ] ; then |
logger "carto-osm-maj : lancement script" |
sudo -u telabotap /usr/local/sbin/carto-osm-maj |
logger "carto-osm-maj : arret script" |
# Nous retenterons de vérifier jour et heure dans 6 jours |
sleep 6d |
else |
# Tentative toutes les heures |
logger "carto-osm-maj : tentative heure $HEURE" |
sleep 1h |
fi |
else |
# Tentative tous les jours |
logger "carto-osm-maj : tentative jour $JOUR" |
sleep 1d |
fi |
done |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/shell/carto-osm-maj.sh |
---|
New file |
0,0 → 1,91 |
#!/bin/bash |
# |
# Script de lancement de l'integration des donnees OSM pour le geocodage inverse |
# Mohcen BENMOUNAH & Jean-Pascal MILCENT [19 juillet 2011] |
# |
ageEnSeconde(){ expr `date +%s` - `stat -c %Y $1`; }; |
if [ -f config.cfg ] ; then |
source config.cfg |
echo $DATE; |
else |
echo "Veuillez paramétrer le script en renommant le fichier 'config.defaut.cfg' en 'config.cfg'." |
exit; |
fi |
echo "Export de l'emplacement du binaire Java dans la variable d'environnement JAVACMD"; |
export JAVACMD="$CHEMIN_JAVA" |
echo "Export de l'emplacement du dossier tmp pour Osmosis" |
export JAVACMD_OPTIONS="-Djava.io.tmpdir=$OSMOSIS_DOSSIER_TMP -Xmx4G" |
if [ ! -f "$DOSSIER_OSM/$FICHIER_OSM" ] || [ `ageEnSeconde "$DOSSIER_OSM/$FICHIER_OSM"` -gt 86000 ] ; then |
echo "Téléchargement du nouveau fichier PBF ..."; |
wget $URL_FICHIER_OSM -O "$DOSSIER_OSM/$FICHIER_OSM" |
else |
echo "Fichier $FICHIER_OSM existant à moins d'un jour."; |
fi |
if [ ! -f "$DOSSIER_OSM/$FICHIER_ZG_NEW" ] || [ `ageEnSeconde "$DOSSIER_OSM/$FICHIER_ZG_NEW"` -gt 86000 ] ; then |
echo "Filtrage du fichier en cours ..."; |
$CHEMIN_OSMOSIS \ |
-v \ |
--read-pbf-fast "$DOSSIER_OSM/$FICHIER_OSM" workers=6 \ |
--tf accept-relations admin_level=8 \ |
--tf accept-relations type=boundary \ |
--tf accept-relations ref:INSEE=* \ |
--used-way \ |
--used-node \ |
--wx "$DOSSIER_OSM/$FICHIER_ZG_NEW" |
fi |
HEURE_DEBUT=`date +"%F %X"`; |
echo "Début éxecution scripts php : $HEURE_DEBUT"; |
if [ ! -f "$DOSSIER_OSM/$FICHIER_ZG_OLD" ] ; then |
echo "Création des tables osm en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a chargerStructureSql -v $VERBOSITE > $FICHIER_LOG |
echo "Analyse du fichier osm en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a analyser -v $VERBOSITE -f "$DOSSIER_OSM/$FICHIER_ZG_NEW" >> $FICHIER_LOG |
else |
echo "Suppression du fichier DIFF existant en cours ..."; |
rm -f "$DOSSIER_OSM/$FICHIER_ZG_DIFF" |
echo "Déduction de la différence en cours ..."; |
$CHEMIN_OSMOSIS\ |
--read-xml file="$DOSSIER_OSM/$FICHIER_ZG_NEW" \ |
--read-xml file="$DOSSIER_OSM/$FICHIER_ZG_OLD" \ |
--derive-change \ |
--write-xml-change file="$DOSSIER_OSM/$FICHIER_ZG_DIFF" |
echo "Début de la mise à jour de base ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php mise_a_jour -a MAJ -f "$DOSSIER_OSM/$FICHIER_ZG_DIFF" > $FICHIER_LOG |
fi |
echo "Renommage du fichier NEW en OLD en cours ..."; |
mv "$DOSSIER_OSM/$FICHIER_ZG_NEW" "$DOSSIER_OSM/$FICHIER_ZG_OLD" >> $FICHIER_LOG |
echo "Traitement de l'ordre en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a ordre -v $VERBOSITE >> $FICHIER_LOG |
echo "Remplissage des polygones en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a polygone -v $VERBOSITE >> $FICHIER_LOG |
echo "Remise de l'ordre à zéro en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a zero -v $VERBOSITE >> $FICHIER_LOG |
echo "Traitement de l'ordre des polygones incomplets en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a ordonnerPolygoneInc -v $VERBOSITE >> $FICHIER_LOG |
echo "Remplissage des polygones incomplets en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a remplirPolygoneInc -v $VERBOSITE >> $FICHIER_LOG |
echo "Renommage des polygones incomplets en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a renommer -v $VERBOSITE >> $FICHIER_LOG |
echo "Definition des centroïdes en cours ..."; |
$CHEMIN_PHP -d memory_limit=$MEMORY_LIMIT_PHP $CHEMIN_SCRIPT/cli.php osm -a centre -v $VERBOSITE >> $FICHIER_LOG |
HEURE_FIN=`date +"%F %X"`; |
echo "Fin éxecution scripts php : $HEURE_FIN"; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/shell/config.defaut.cfg |
---|
New file |
0,0 → 1,26 |
# Binaires |
CHEMIN_JAVA="/usr/local/jre/bin/java" |
CHEMIN_PHP="/usr/local/php/5.5/bin/php" |
CHEMIN_SCRIPT="/home/apitela/www/scripts/eflore" |
# Dossiers, fichiers & urls |
# Pour tester : http://download.geofabrik.de/europe/france/languedoc-roussillon-latest.osm.pbf |
URL_FICHIER_OSM="http://download.geofabrik.de/europe/france-latest.osm.pbf" |
DOSSIER_OSM="/home/jpm/web/eflore/eflore-projets/donnees/osm" |
FICHIER_OSM="fr.osm.pbf" |
FICHIER_ZG_NEW="fr_communes_new.osm" |
FICHIER_ZG_OLD="fr_communes_old.osm" |
FICHIER_ZG_DIFF="fr_communes_diff.osm" |
# Osmosis |
CHEMIN_OSMOSIS="/usr/local/sbin/osmosis-0.43.1/bin" |
OSMOSIS_DOSSIER_TMP="$DOSSIER_OSM/tmp" |
# Logs |
VERBOSITE=3 |
DATE=`date +"%F"` |
CHEMIN_LOG="$DOSSIER_OSM/logs" |
FICHIER_LOG="$CHEMIN_LOG/analyse_${DATE}.log" |
# Paramètres PHP |
MEMORY_LIMIT_PHP="8000M" |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/shell |
---|
New file |
Property changes: |
Added: svn:ignore |
+config.cfg |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/PolygoneCreateur.php |
---|
New file |
0,0 → 1,143 |
<?php |
/** |
* Traitement de l'ordre : |
* |
* Fonction qui rajoute l'ordre et le sens de chaque way d'une relation dans la table `osm_relation_a_chemins` |
* |
* Exemple de lancement du script : |
* /opt/lampp/bin/php -d memory_limit=8000M cli.php osm -a ordre -m manuel |
* |
*/ |
class PolygoneCreateur { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
/** |
* Fonction qui parcourt tous les ways les noeuds de chaque relation en prenant en considération l'ordre et |
* le sens de chaque ways concaténés ensemble (séparés par des virgules). Update du champ polygone de chaque |
* relation dans la table `osm_relations` |
*/ |
public function executer() { |
// Lancement de l'action demandée |
$cmd = $this->conteneur->getParametre('a'); |
switch ($cmd) { |
case 'polygone' : |
$this->genererPolygones(); |
break; |
case 'centre' : |
$this->mettreAJourCentroide(); |
break; |
case 'zero' : |
$this->remettreOrdreAZero(); |
break; |
default : |
$msgTpl = "Erreur : la commande '%s' n'est pas prise en compte par la classe %s !"; |
$msg = sprintf($msgTpl, $cmd, get_class($this)); |
throw new Exception($msg); |
} |
print "\n";// Pour ramener à la ligne en fin de script |
} |
private function genererPolygones() { |
$relations = $this->getRelations(); |
foreach ($relations as $relation) { |
$chemins = $this->getChemins($relation['id_relation']); |
$noeuds = array(); |
foreach ($chemins as $chemin) { |
$noeuds = array_merge($noeuds, $this->getNoeuds($chemin['id_chemin'], $chemin['sens'])); |
} |
$this->creerPolygone($relation, $noeuds); |
if ($this->mode == 'manuel') { |
$this->messages->afficherAvancement("Création du polygone pour la relation : ", 1); |
} |
} |
} |
private function getRelations() { |
$requete = 'SELECT id_relation, nom, code_insee '. |
'FROM osm_relations '. |
' -- '.__FILE__.' : '.__LINE__; |
$relations = $this->bdd->recupererTous($requete); |
return $relations; |
} |
private function getChemins($idRelation) { |
$requete = 'SELECT id_chemin, sens '. |
'FROM osm_relation_a_chemins '. |
"WHERE id_relation = $idRelation ". |
'ORDER BY ordre '. |
' -- '.__FILE__.' : '.__LINE__; |
$chemins = $this->bdd->recupererTous($requete); |
return $chemins; |
} |
private function getNoeuds($idChemin, $sens) { |
$tri = ($sens == 'directe') ? 'ASC' : 'DESC'; |
$requete = 'SELECT NLL.id_noeud, NLL.lat, NLL.`long` '. |
'FROM osm_chemin_a_noeuds AS WN '. |
' INNER JOIN osm_noeuds AS NLL ON (WN.id_noeud = NLL.id_noeud) '. |
"WHERE WN.id_chemin = $idChemin ". |
"ORDER BY WN.ordre $tri ". |
' -- '.__FILE__.' : '.__LINE__; |
$noeuds = $this->bdd->recupererTous($requete); |
$latLng = array(); |
foreach ($noeuds as $noeud) { |
$latLng[] = $noeud['lat'].' '.$noeud['long']; |
} |
return $latLng; |
} |
private function creerPolygone($relation, $noeuds) { |
$polygone = implode(', ', $noeuds); |
$idRelation = $relation['id_relation']; |
$nomCommuneP = $this->bdd->proteger($relation['nom']); |
$InseeP = $this->bdd->proteger($relation['code_insee']); |
$note = ($noeuds[0] == $noeuds[count($noeuds) - 1]) ? 'Polygone complet' : 'Polygone incomplet'; |
$requete = 'REPLACE INTO osm_communes (id_relation, nom, code_insee, polygone, notes ) '. |
"VALUES ($idRelation, $nomCommuneP, $InseeP, ". |
"POLYFROMTEXT('MULTIPOLYGON ((($polygone)))'), '$note') ". |
' -- '.__FILE__.' : '.__LINE__; |
unset($polygone); |
$this->bdd->requeter($requete); |
} |
/** |
* Pour chaque commune, renseigne le champe "centre" avec un point centroïde du polygone (si non null). |
*/ |
private function mettreAJourCentroide() { |
$requete = 'UPDATE osm_communes '. |
'SET centre = CENTROID(polygone) '. |
"WHERE polygone IS NOT NULL ". |
' -- '.__FILE__.' : '.__LINE__; |
$retour = $this->bdd->requeter($requete); |
$this->messages->traiterInfo("Nombre de centroïde mis à jour : ".$retour->rowCount()); |
} |
/** |
* Pour chaque commune, remet à zéro l'ordre des chemins si le polygone est incomplet. |
*/ |
private function remettreOrdreAZero() { |
$sousRequeteRelations = 'SELECT DISTINCT id_relation '. |
'FROM osm_communes '. |
"WHERE notes = 'Polygone incomplet' "; |
$requete = 'UPDATE osm_relation_a_chemins '. |
'SET ordre = NULL '. |
"WHERE id_relation IN ($sousRequeteRelations) ". |
' -- '.__FILE__.' : '.__LINE__; |
$retour = $this->bdd->requeter($requete); |
$this->messages->traiterInfo("Nombre de chemins remis à zéro : ".$retour->rowCount()); |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/PolygoneReparateur.php |
---|
New file |
0,0 → 1,300 |
<?php |
/** |
* Réparation des polygones incomplets : |
* |
* Exemple de lancement du script : |
* /opt/lampp/bin/php -d memory_limit=8000M cli.php osm -a ordonnerPolygoneInc -m manuel -v 3 |
* |
* /opt/lampp/bin/php -d memory_limit=8000M cli.php osm -a remplirPolygoneInc -m manuel -v 3 |
* |
* /opt/lampp/bin/php -d memory_limit=8000M cli.php osm -a renommer -m manuel -v 3 |
* |
*/ |
class PolygoneReparateur { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
/** |
* Fonction qui parcourt tous les ways les noeuds de chaque relation en prenant en considération l'ordre et |
* le sens de chaque ways concaténés ensemble (séparés par des virgules). Update du champ polygone de chaque |
* relation dans la table `osm_relations` |
*/ |
public function executer() { |
// Lancement de l'action demandée |
$cmd = $this->conteneur->getParametre('a'); |
switch ($cmd) { |
case 'ordonnerPolygoneInc' : |
$this->ordonnerRelationsAuPolygoneIncomplet(); |
break; |
case 'remplirPolygoneInc' : |
$this->remplirRelationsAuPolygoneIncomplet(); |
break; |
case 'renommer' : |
$this->renommerEnPolygoneIncomplet(); |
break; |
default : |
$msgTpl = "Erreur : la commande '%s' n'est pas prise en compte par la classe %s !"; |
$msg = sprintf($msgTpl, $cmd, get_class($this)); |
throw new Exception($msg); |
} |
print "\n";// Pour ramener à la ligne en fin de script |
} |
/** |
* Fonction qui récupère les relations des polygones incomplets et appelle pour chaque relation la fonction |
* ordonnerPolygoneIncomplet($ordre,$tour,$idRelation,$nombrePolygone) |
*/ |
private function ordonnerRelationsAuPolygoneIncomplet() { |
$relations = $this->getRelationsAuPolygoneIncomplet(); |
foreach ($relations as $relation) { |
$idRelation = $relation['id_relation']; |
$this->ordonnerCheminsMultiPolygone($idRelation); |
if ($this->mode == 'manuel') { |
$this->messages->afficherAvancement("Réparation du polygone incomplet : ", 1); |
} |
} |
} |
/** |
* Fonction récursive qui exécute la même tâche que la fonction ordonnerWays() pour chaque polygone d'un |
* multipolygone et remplie le champ NbPoly dans la table `osm_relation_a_chemins` qui correspond au nombre de polygone fermé |
* dans le multipolygone |
*/ |
private function ordonnerCheminsMultiPolygone($idRelation, $numPolygone = 1, $ordre = 1, $tour = 1) { |
$chemins = $this->getChemins($idRelation); |
$nbreCheminsTotal = count($chemins); |
// premier élément du tableau |
$idPremierChemin = $chemins[0]['id_chemin']; |
$idChemin = $idPremierChemin; |
$this->mettreAJourChemin($idRelation, $idPremierChemin, $ordre, 'directe', $numPolygone); |
//selection dernier noeud |
$nodes = $this->getNoeuds($idPremierChemin); |
$nombreNodes = count($nodes); |
$premierNoeud = $nodes[0]['id_noeud']; |
$dernierNoeud = $nodes[$nombreNodes - 1]['id_noeud']; |
$noeudActuel = $dernierNoeud; |
//Condition pour laquelle la boucle while continue à tourner; tant que le premier noeud du polygone n'est |
//égale au dernier et tant qu'il reste des ways à gérer |
while (($premierNoeud != $noeudActuel) && (($ordre % 1000) < $nbreCheminsTotal)) { |
//select le way qui possède le dernier noeud du précédent way et écarter l'actuel |
$ordre++; |
$chemins = $this->getCheminsAOrdonner($idRelation, $idChemin, $noeudActuel); |
if (isset($chemins[0])) { |
$idChemin = $chemins[0]['id_chemin']; |
$nodes = $this->getNoeuds($idChemin); |
$nombreNodes = count($nodes); |
if (strcmp($nodes[0]['id_noeud'], $noeudActuel ) == 0) { |
$sens = 'directe'; |
$noeudActuel = $nodes[$nombreNodes-1]['id_noeud']; |
} else { |
$sens = 'indirecte'; |
$noeudActuel = $nodes[0]['id_noeud']; |
} |
$this->mettreAJourChemin($idRelation, $idChemin, $ordre, $sens, $numPolygone); |
} |
} |
$ordre = 1000 * $tour; //différencier chaque polygone: pour chaque polygone on a un multiple de mille |
if ($this->getNombreChemins($idRelation) != 0) { |
//appelle de la méthode récursivement |
$this->ordonnerCheminsMultiPolygone($idRelation, ++$numPolygone, $ordre, ++$tour); |
} |
} |
private function getRelationsAuPolygoneIncomplet() { |
$requete = 'SELECT id_relation '. |
'FROM osm_communes '. |
"WHERE notes = 'Polygone incomplet' ". |
' -- '.__FILE__.' : '.__LINE__; |
$relations = $this->bdd->recupererTous($requete); |
return $relations; |
} |
private function getChemins($idRelation) { |
$requete = 'SELECT id_chemin '. |
'FROM osm_relation_a_chemins '. |
"WHERE id_relation = $idRelation ". |
"AND ordre IS NULL ". |
' -- '.__FILE__.' : '.__LINE__; |
$chemins = $this->bdd->recupererTous($requete); |
return $chemins; |
} |
/** |
* Select des ways qui n'ont pas été ordonnés: on obtient à chaque itération les ways qui restent à ordonner |
*/ |
private function getCheminsAOrdonner($idRelation, $idChemin, $idNoeud) { |
$requete = 'SELECT cn.id_chemin '. |
'FROM osm_relation_a_chemins AS rc '. |
' INNER JOIN osm_chemin_a_noeuds AS cn ON (rc.id_chemin = cn.id_chemin) '. |
"WHERE cn.id_noeud = $idNoeud ". |
"AND cn.id_chemin != $idChemin ". |
"AND rc.id_relation = $idRelation ". |
"AND rc.ordre IS NULL ". |
' -- '.__FILE__.' : '.__LINE__; |
$chemins = $this->bdd->recupererTous($requete); |
return $chemins; |
} |
private function getNoeuds($idChemin) { |
$requete = 'SELECT id_noeud '. |
'FROM osm_chemin_a_noeuds '. |
"WHERE id_chemin = $idChemin ". |
'ORDER BY ordre '. |
' -- '.__FILE__.' : '.__LINE__; |
$noeuds = $this->bdd->recupererTous($requete); |
return $noeuds; |
} |
private function getNombreChemins($idRelation) { |
$requete = 'SELECT COUNT(id_chemin) AS nbre '. |
'FROM osm_relation_a_chemins '. |
"WHERE id_relation = $idRelation ". |
'AND ordre = 0 '. |
' -- '.__FILE__.' : '.__LINE__; |
$infos = $this->bdd->recuperer($requete); |
return $infos['nbre']; |
} |
private function mettreAJourChemin($idRelation, $idChemin, $ordre, $sens, $nbrePoly) { |
$requete = 'UPDATE osm_relation_a_chemins '. |
"SET ordre = '$ordre', sens = '$sens', num_poly = $nbrePoly ". |
"WHERE id_relation = $idRelation ". |
"AND id_chemin = $idChemin ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
/** |
* Fonction qui récupère les relations des polygones incomplets et appelle pour chaque relation la fonction |
* remplirPolygoneIncomplet($idRelation); |
*/ |
private function remplirRelationsAuPolygoneIncomplet() { |
$relations = $this->getRelationsAuPolygoneIncomplet(); |
foreach ($relations as $relation) { |
$this->remplirPolygoneIncomplet($relation['id_relation']); |
if ($this->mode == 'manuel') { |
$this->messages->afficherAvancement("Création du polygone incomplet : ", 1); |
} |
} |
} |
/** |
* Fonction qui exécute la même tâche que la fonction remplirPolygone() pour chaque polygone d'un multipolygone |
* et renvoie un tableau MultiPolygone[] où chaque case contient un polygone fermé. Puis met à jour le polygone |
* de la commune. |
*/ |
private function remplirPolygoneIncomplet($idRelation) { |
// Tableau multipolygone qui contient tous les polygones d'un multipolygone |
$multiPolygone = array(); |
// Tableau roles qui contient les différents roles des chemins de la relation |
$roles = array(); |
// Sélectionner le nombre de polygones qui existe dans un multipolygone |
$nbPoly = $this->getNombrePoly($idRelation); |
//boucle for qui parcourt chaque polygone du multipolygone |
for ($numPoly = 1; $numPoly <= $nbPoly; $numPoly++) { |
$polygone = array(); |
$chemins = $this->getCheminsParPolygone($idRelation, $numPoly); |
foreach ($chemins as $chemin) { |
$role = $chemin['role']; |
$roles[$role] = (isset($roles[$role])) ? $roles[$role]++ : 1; |
$noeuds = $this->getNoeudsPourCheminEtSens($chemin['id_chemin'], $chemin['sens']); |
$polygone = array_merge($polygone, $noeuds); |
} |
$multiPolygone[] = implode(', ', $polygone); |
} |
$this->mettreAJourMultiPolygone($multiPolygone, $roles, $idRelation, $nbPoly); |
} |
private function getNombrePoly($idRelation) { |
$requete = 'SELECT MAX(num_poly) AS num_poly '. |
'FROM osm_relation_a_chemins '. |
"WHERE id_relation = $idRelation ". |
' -- '.__FILE__.' : '.__LINE__; |
$resultat = $this->bdd->recuperer($requete); |
return $resultat['num_poly']; |
} |
private function getCheminsParPolygone($idRelation, $numPoly) { |
$requete = 'SELECT id_chemin, sens, role '. |
'FROM osm_relation_a_chemins '. |
"WHERE id_relation = $idRelation ". |
"AND num_poly = $numPoly ". |
'ORDER BY ordre '. |
' -- '.__FILE__.' : '.__LINE__; |
$chemins = $this->bdd->recupererTous($requete); |
return $chemins; |
} |
private function getNoeudsPourCheminEtSens($idChemin, $sens) { |
$tri = ($sens == 'directe') ? 'ASC' : 'DESC'; |
$requete = 'SELECT NLL.id_noeud, NLL.lat, NLL.`long` '. |
'FROM osm_chemin_a_noeuds AS WN '. |
' INNER JOIN osm_noeuds AS NLL ON (WN.id_noeud = NLL.id_noeud) '. |
"WHERE WN.id_chemin = $idChemin ". |
"ORDER BY WN.ordre $tri ". |
' -- '.__FILE__.' : '.__LINE__; |
$noeuds = $this->bdd->recupererTous($requete); |
$latLng = array(); |
foreach ($noeuds as $noeud) { |
$latLng[] = $noeud['lat'].' '.$noeud['long']; |
} |
return $latLng; |
} |
/** |
* Remplie le champ polygone à partir du tableau MultiPolygone |
*/ |
private function mettreAJourMultiPolygone($multiPolygone, $roles, $idRelation, $nbPoly) { |
// Présence d'une enclave contenue dans cette entité administrative mais qui appartient à une autre entité administrative |
if ((isset($roles['inner']) || isset($roles['enclave']))) { |
if ($nbPoly == 2) { |
$multiPoly = implode('),(', $multiPolygone); |
} else { |
$multiPoly = null; |
$msgTpl = "La relation '%s' possède plus de 2 polygones de type enclaves."; |
$this->messages->traiterErreur($msgTpl, array($idRelation)); |
} |
} else { |
// Tous les autres cas |
$multiPoly = implode(')),((', $multiPolygone); |
} |
if (isset($multiPoly)) { |
$this->mettreAJourCommune($idRelation, $multiPoly); |
} |
} |
private function mettreAJourCommune($idRelation, $multiPoly) { |
$requete = 'UPDATE osm_communes '. |
"SET polygone = MPOLYFROMTEXT('MULTIPOLYGON((($multiPoly)))'), ". |
"notes = 'Polygone complet' ". |
"WHERE id_relation = $idRelation ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
/** |
* Renomme la note des polygones vides d'un polygone complet en polygone incomplet |
*/ |
private function renommerEnPolygoneIncomplet() { |
$requete = 'UPDATE osm_communes '. |
"SET notes = 'Polygone incomplet' ". |
"WHERE ASTEXT(polygone) IS NULL ". |
' -- '.__FILE__.' : '.__LINE__; |
$retour = $this->bdd->requeter($requete); |
$this->messages->traiterInfo("Nombre de polygones définis à incomplet : ".$retour->rowCount()); |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/OrdonneurDeChemins.php |
---|
New file |
0,0 → 1,226 |
<?php |
/** |
* Traitement de l'ordre : |
* |
* Fonction qui rajoute l'ordre et le sens de chaque way d'une relation dans la table `osm_relation_a_chemins` |
* |
* Exemple de lancement du script : |
* /opt/lampp/bin/php -d memory_limit=8000M cli.php osm -a ordre -m manuel |
* |
*/ |
class OrdonneurDeChemins { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
private $premierNoeudPolygon = null; |
private $infosRel = array(); |
private $infosNoeuds = array(); |
private $idRelation = null; |
private $idChemin = null; |
private $idNoeud = null; |
private $ordre = 0; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
public function executer() { |
$relations = $this->getToutesRelationsAChemins(); |
if ($this->mode == 'manuel') { |
$this->messages->traiterInfo("Nombre de relations : %s", array(count($relations))); |
} |
foreach ($relations as $relation) { |
// Traitement de la relation courante |
$this->idRelation = $relation['id_relation']; |
$this->chargerDonneesRelationActuelle(); |
$numPolygon = 1; |
while(count($this->chemins) > 0) { |
reset($this->chemins); |
$idChemin = key($this->chemins); |
echo "--------------POLY : $numPolygon : $idChemin\n"; |
$this->ordonnerCheminsRelation($numPolygon, $idChemin); |
$this->mettreAJourRelationAChemin(); |
$numPolygon++; |
} |
// Affichage de l'avancement |
if ($this->mode == 'manuel') { |
$this->messages->afficherAvancement("Ordone les chemins de la relation : ", 1); |
} |
} |
} |
private function getToutesRelationsAChemins() { |
$requete = 'SELECT DISTINCT id_relation '. |
'FROM osm_relation_a_chemins '. |
'WHERE id_relation = 403823 '. |
' -- '.__FILE__.' : '.__LINE__; |
$relations = $this->bdd->recupererTous($requete); |
return $relations; |
} |
private function chargerDonneesRelationActuelle() { |
$requete = 'SELECT cn.id_chemin, cn.id_noeud, cn.ordre '. |
'FROM osm_relation_a_chemins AS rc '. |
' INNER JOIN osm_chemin_a_noeuds AS cn ON (rc.id_chemin = cn.id_chemin) '. |
"WHERE rc.id_relation = {$this->idRelation} ". |
"ORDER BY rc.ordre ASC, cn.ordre ASC ". |
' -- '.__FILE__.' : '.__LINE__; |
$infos = $this->bdd->recupererTous($requete); |
$noeuds = array(); |
foreach ($infos as $info) { |
$noeuds[$info['id_noeud']][$info['id_chemin']] = $info['ordre']; |
if (! isset($this->chemins[$info['id_chemin']]) ) { |
$this->chemins[$info['id_chemin']]['max'] == info['ordre']; |
if ($info['ordre'] == 1) { |
$this->chemins[$info['id_chemin']][0] == $info['id_noeud']; |
} |
} else { |
} |
if (count($noeuds[$info['id_noeud']]) == 2) { |
list($premierChemin, $dernierChemin) = array_keys($noeuds[$info['id_noeud']]); |
$this->chemins[$premierChemin][] = $info['id_noeud']; |
$this->chemins[$dernierChemin][] = $info['id_noeud']; |
$this->noeuds[$info['id_noeud']][$premierChemin] = $dernierChemin; |
$this->noeuds[$info['id_noeud']][$dernierChemin] = $premierChemin; |
} |
} |
//print_r($this->chemins);exit(); |
} |
private function ordonnerCheminsRelation($numPolygon, $idChemin, $idCheminPrecedent = null, $ordre = 1) { |
$this->infosRel[$idChemin] = array($ordre, $numPolygon); |
list($premierNoeud, $dernierNoeud) = $this->chemins[$idChemin]; |
if ($idCheminPrecedent == null) {// Premier chemin à tester |
$this->premierNoeudPolygon = $premierNoeud; |
$noeudSuivant = ($dernierNoeud == $premierNoeud) ? $premierNoeud : $dernierNoeud; |
echo "Chemin $idChemin :: premierNoeud: $premierNoeud, dernierNoeud: $dernierNoeud \n"; |
} else { |
list($premierNoeudPrec, $dernierNoeudPrec) = $this->chemins[$idCheminPrecedent]; |
unset($this->chemins[$idCheminPrecedent]); |
$noeudSuivant = ($dernierNoeudPrec == $dernierNoeud || $premierNoeudPrec == $dernierNoeud) ? $premierNoeud : $dernierNoeud; |
echo "Chemin $idChemin :: premierNoeudPrec: $premierNoeudPrec, dernierNoeudPrec: $dernierNoeudPrec, premierNoeud: $premierNoeud, dernierNoeud: $dernierNoeud \n"; |
} |
if ($this->premierNoeudPolygon != $noeudSuivant) { |
if (isset($this->noeuds[$noeudSuivant][$idChemin])) { |
$idCheminSuivant = $this->noeuds[$noeudSuivant][$idChemin]; |
if (! isset($this->infosRel[$idCheminSuivant])) { |
$this->ordonnerCheminsRelation($numPolygon, $idCheminSuivant, $idChemin, ++$ordre); |
} else { |
$this->messages->traiterAvertissement("Chemins %s déjà pris en comtpe", array($idCheminSuivant)); |
} |
} else { |
$this->messages->traiterAvertissement("Relation %s a un polygone incomplet", array($this->idRelation)); |
} |
} else { |
unset($this->chemins[$idChemin]); |
} |
return null; |
} |
private function mettreAJourRelationAChemin() { |
if (count($this->infosRel) > 0) { |
foreach ($this->infosRel as $idC => $donnees) { |
list($ordre, $numPolygon) = $this->bdd->proteger($donnees); |
$requete = 'UPDATE osm_relation_a_chemins '. |
"SET sens = $ordre, num_poly = $numPolygon ". |
"WHERE id_relation = {$this->idRelation} ". |
"AND id_chemin = $idC ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->infosRel = array(); |
} |
} |
private function creerSet($donnees) { |
$values = array(); |
foreach ($donnees as $infos) { |
$infosP = $this->bdd->proteger($infos); |
$values[] = implode(',', $infosP); |
} |
$valuesClause = '('.implode('),(', $values).')'; |
return $valuesClause; |
} |
private function getIdPremierChemin() { |
$idChemin = null; |
if (count($this->infosRel) > 0) { |
reset($this->infosRel); |
$idChemin = key($this->infosRel); |
} |
return $idChemin; |
} |
private function mettreAJourChemin($sens, $ligne, $fichier = __FILE__) { |
$ordre = $this->ordre++; |
$requete = 'UPDATE osm_relation_a_chemins '. |
"SET ordre = '$ordre', sens = '$sens' ". |
"WHERE id_relation = {$this->idRelation} ". |
"AND id_chemin = {$this->idChemin} ". |
" -- $fichier : $ligne"; |
$retour = $this->bdd->requeter($requete); |
return $retour; |
} |
private function getIdDernierNoeud() { |
$idNoeud = false; |
if (count($this->infosRel[$this->idChemin]) > 0) { |
end($this->infosRel[$this->idChemin]); |
$idNoeud = current($this->infosRel[$this->idChemin]); |
} |
return $idNoeud; |
} |
private function ordonnerChemins() { |
foreach ($this->infosRel as $chemin) { |
// Selection du chemin qui possède le dernier noeud du précédent chemin et écarter l'actuel |
$idCheminSuivant = $this->getIdCheminSuivant(); |
if ($idCheminSuivant) { |
$this->idChemin = $idCheminSuivant; |
$idPremierNoeud = $this->getIdPremierNoeud(); |
$idDernierNoeud = $this->getIdDernierNoeud(); |
$sens = $this->getSens($idPremierNoeud); |
$this->mettreAJourChemin($sens, __LINE__); |
$this->idNoeud = ($sens == 'directe') ? $idDernierNoeud : $idPremierNoeud; |
} |
} |
} |
private function getIdCheminSuivant() { |
$idCheminSuivant = false; |
if (isset($this->infosNoeuds[$this->idNoeud])) { |
$idCheminSuivant = next($this->infosNoeuds[$this->idNoeud]); |
//echo $this->idChemin.'-'.$idCheminSuivant."\n".print_r($this->infosNoeuds[$this->idNoeud]); exit(); |
} else { |
$msg = "Impossible de trouver le chemin suivant pour la relation : %s, le chemin %s et le noeud %s"; |
$this->messages->traiterAvertissement($msg, array($this->idRelation, $this->idChemin, $this->idNoeud)); |
} |
return $idCheminSuivant; |
} |
private function getSens($idPremierNoeud) { |
$sens = ( strcmp($idPremierNoeud, $this->idNoeud ) == 0 ) ? 'directe' : 'indirecte'; |
return $sens; |
} |
private function getIdPremierNoeud() { |
$idNoeud = false; |
if (count($this->infosRel[$this->idChemin]) > 0) { |
reset($this->infosRel[$this->idChemin]); |
$idNoeud = current($this->infosRel[$this->idChemin]); |
} |
return $idNoeud; |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/config.ini |
---|
New file |
0,0 → 1,9 |
; Ajouter les nouvelles version à la suite dans versions et versionsDonnees. |
version = "1.0" |
dossierSql = "{ref:dossierDonneesEflore}osm/" |
[fichiers] |
structureSql = "osm_v{ref:version}.sql" |
[chemins] |
structureSql = "{ref:dossierSql}{ref:version}/{ref:fichiers.structureSql}" |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/MiseAJour.php |
---|
New file |
0,0 → 1,417 |
<?php |
/** |
* Permet de mettre à jour les contours à partir d'un fichier de diff. |
* |
* Exemple de lancement du script : |
* /opt/lampp/bin/php -d memory_limit=3500M cli.php osm -a maj -f fichier_osm_change -e fichier_osm_nouveau |
*/ |
class MiseAJour { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
private $communes = array(); |
private $relations_communes = array(); |
private $relation_a_chemins = array(); |
private $chemin_a_noeuds = array(); |
private $noeuds = array(); |
private $pas = 10000; |
private $pas_commune = 1000; |
private $elementType = ''; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
/** |
* Fonction qui parcourt tous les ways les noeuds de chaque relation en prenant en considération l'ordre et |
* le sens de chaque ways concaténés ensemble (séparés par des virgules). Update du champ polygone de chaque |
* relation dans la table `osm_relations` |
*/ |
public function executer() { |
// Lancement de l'action demandée |
$cmd = $this->conteneur->getParametre('a'); |
switch ($cmd) { |
case 'maj' : |
$this->mettreAjour(); |
break; |
default : |
$msgTpl = "Erreur : la commande '%s' n'est pas prise en compte par la classe %s !"; |
$msg = sprintf($msgTpl, $cmd, get_class($this)); |
throw new Exception($msg); |
} |
print "\n";// Pour ramener à la ligne en fin de script |
} |
/** |
* Fonction permettant de traiter et d'analyser le fichier de différence et de mettre à jour la base de données |
* en tenant compte des trois cas:Suppression, Création ,modification |
*/ |
private function mettreAjour() { |
$lecteur = $this->getLecteurXml(); |
while ($lecteur->read()) { |
if ($lecteur->nodeType == XMLREADER::ELEMENT) { |
$this->elementType = $lecteur->localName; |
$this->analyserElementXml($lecteur->localName, $lecteur->expand()); |
} |
if ($this->mode == 'manuel') { |
$this->messages->afficherAvancement("Analyse de la ligne du fichier de diff OSM : ", 1); |
} |
} |
} |
private function getLecteurXml() { |
$fichierOsm = $this->conteneur->getParametre('f'); |
$lecteur = new XMLReader(); |
$ouvertureXmlOk = $lecteur->open($fichierOsm); |
if ($ouvertureXmlOk === false) { |
$msgTpl = "Impossible d'ouvrir le fichier osm : %s"; |
$msg = sprintf($msgTpl, $this->conteneur->getParametre('f')); |
new Exception($msg); |
} |
return $lecteur; |
} |
private function analyserElementXml($noeudDom) { |
$relations = $noeudDom->getElementsByTagName('relation'); |
if ($relations->length > 0) { |
foreach ($relations as $relation) { |
$this->analyserRelation($relation); |
$this->traiterRelations(); |
} |
} |
$ways = $creations->getElementsByTagName('way'); |
if ($ways->length > 0) { |
foreach ($ways as $way) { |
$this->analyserWay($way); |
$this->traiterCheminANoeuds(); |
} |
} |
$noeuds = $creations->getElementsByTagName('node'); |
if ($noeuds->length > 0) { |
foreach ($noeuds as $noeud) { |
$this->analyserNode($noeud); |
$this->traiterNoeuds(); |
} |
} |
$this->traiterElementsOrphelins(); |
} |
private function traiterRelations() { |
if (count($this->relation_a_chemins) > $this->pas) { |
switch ($this->elementType) { |
case 'create' : |
$this->insererRelationAChemins(); |
break; |
case 'modify' : |
$this->modifierRelationAChemins(); |
break; |
case 'delete' : |
$this->supprimerRelationAChemins(); |
break; |
} |
} |
if (count($this->relations_communes) > $this->pas_commune) { |
switch ($this->elementType) { |
case 'create' : |
$this->insererRelationsCommunes(); |
break; |
case 'modify' : |
$this->modifierRelationsCommunes(); |
break; |
case 'delete' : |
$this->supprimerRelationsCommunes(); |
break; |
} |
} |
} |
private function traiterChemins() { |
if (count($this->chemin_a_noeuds) > $this->pas) { |
switch ($this->elementType) { |
case 'create' : |
$this->insererCheminANoeuds(); |
break; |
case 'modify' : |
$this->modifierCheminANoeuds(); |
break; |
case 'delete' : |
$this->supprimerCheminANoeuds(); |
break; |
} |
} |
} |
private function traiterNoeuds() { |
if (count($this->noeuds) > $this->pas) { |
switch ($this->elementType) { |
case 'create' : |
$this->insererNoeuds(); |
break; |
case 'modify' : |
$this->modifierNoeuds(); |
break; |
case 'delete' : |
$this->supprimerNoeuds(); |
break; |
} |
} |
} |
private function traiterElementsOrphelins() { |
switch ($this->elementType) { |
case 'create' : |
$this->insererRelationsCommunes(); |
$this->insererRelationAChemins(); |
$this->insererCheminANoeuds(); |
$this->insererNoeuds(); |
break; |
case 'modify' : |
$this->modifierRelationsCommunes(); |
$this->modifierRelationAChemins(); |
$this->modifierCheminANoeuds(); |
$this->modifierNoeuds(); |
break; |
case 'delete' : |
$this->supprimerRelationsCommunes(); |
$this->supprimerRelationAChemins(); |
$this->supprimerCheminANoeuds(); |
$this->supprimerNoeuds(); |
break; |
} |
} |
/** |
* Récupère l'id commune, nom commune et le code INSEE et remplie la table `osm_relations` |
*/ |
private function analyserRelation($relation) { |
$relation_id = $relation->getAttribute('id'); |
$chemins = $relation->getElementsByTagName('member'); |
foreach ($chemins as $chemin) { |
if ($chemin->getAttribute('type') == 'way') { //écarter le noeud centrale |
$chemin_id = $chemin->getAttribute('ref'); |
$role = $chemin->getAttribute('role');//role: null, inner, outer, exclave et enclave. |
$this->relation_a_chemins[] = array($relation_id, $chemin_id, $role); |
} |
} |
$tags = $relation->getElementsByTagName('tag'); |
if ($tags->length > 0) { |
$this->analyserTags($relation_id, $tags); |
} |
} |
private function analyserTags($relation_id, $tags) { |
$commune_nom = null; |
$commune_insee = null; |
foreach ($tags as $tag) { |
$tag_cle = $tag->getAttribute('k'); |
$tag_val = $tag->getAttribute('v'); |
switch ($tag_cle) { |
case 'name' : |
$commune_nom = $tag_val; |
break; |
case 'ref:INSEE' : |
$commune_insee = $tag_val; |
break; |
} |
if (!is_null($commune_nom) && !is_null($commune_insee)) { |
$this->relations_communes[] = array($relation_id, $commune_nom, $commune_insee); |
if (!isset($this->communes[$commune_insee])) { |
$this->communes[$commune_insee] = $relation_id; |
} else { |
$e = "La relation #%s contient déjà le tag ref:INSEE avec la valeur %s.". |
"Veuillez corriger la carte OSM."; |
$this->traiterErreur($e, array($this->communes[$commune_insee], $commune_insee, $relation_id)); |
} |
break; |
} |
} |
} |
/** |
* Récupère l'id_way et tous les id_node de chaque way et remplie la table `osm_chemin_a_noeuds` |
*/ |
private function analyserWay($way) { |
$chemin_id = $way->getAttribute('id'); |
$noeuds = $way->getElementsByTagName('nd'); |
$ordre = 0; |
foreach ($noeuds as $noeud) { |
$noeud_id = $noeud->getAttribute('ref'); |
$this->chemin_a_noeuds[] = array($chemin_id, $noeud_id, ++$ordre); |
} |
} |
/** |
* Fonction qui récupère tous les l'id_node et les valeurs(Lat/Lon) correspondantes et remplie la table `osm_noeuds` |
*/ |
private function analyserNode($node) { |
$this->noeuds[] = array( |
$node->getAttribute('id'), |
$node->getAttribute('lat'), |
$node->getAttribute('lon') |
); |
} |
//Insertion des relations |
private function insererRelationsCommunes() { |
$requete = 'INSERT INTO osm_relations (id_relation, nom, code_insee) '. |
'VALUES '.$this->creerValuesMultiple($this->relations_communes). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
$this->relations_communes = array(); |
} |
//Insertion des relations à chemins |
private function insererRelationAChemins() { |
$requete = 'INSERT INTO osm_relation_a_chemins (id_relation, id_chemin, role) '. |
'VALUES '.$this->creerValuesMultiple($this->relation_a_chemins). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
$this->relation_a_chemins = array(); |
} |
//Insertion des chemins à noeuds |
private function insererCheminANoeuds() { |
$requete = 'INSERT INTO osm_chemin_a_noeuds (id_chemin, id_noeud, ordre) '. |
'VALUES '.$this->creerValuesMultiple($this->chemin_a_noeuds). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
$this->chemin_a_noeuds = array(); |
} |
//Insertion des noeuds |
private function insererNoeuds() { |
$requete = 'INSERT INTO osm_noeuds (id_noeud, lat, `long`) '. |
'VALUES '.$this->creerValuesMultiple($this->noeuds). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
$this->noeuds = array(); |
} |
//Update des relations |
private function modifierRelationsCommunes() { |
foreach ($this->relations_communes as $donnee) { |
$infosP = $this->bdd->proteger($donnee); |
$requete = 'UPDATE osm_relations '. |
"SET id_relation = $infosP[0], nom = $infosP[1], code_insee = $infosP[2] ". |
"WHERE id_relation = $infosP[0] ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->relations_communes = array(); |
} |
/* |
*Update des relations à chemins en supprimant l'ancienne relation et tous ses chemins |
*de la table osm_relation_a_chemins et insérer la nouvelle |
*/ |
private function modifierRelationAChemins() { |
$this->supprimerRelationAChemins(); |
foreach ($this->relation_a_chemins as $donnee) { |
$infosP = $this->bdd->proteger($donnee); |
$requete = 'INSERT INTO osm_relation_a_chemins (id_relation, id_chemin, role) '. |
"VALUES ($infosP[0], $infosP[1], $infosP[2]) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->relation_a_chemins = array(); |
} |
/* |
*Update des chemins à noeuds en supprimant l'ancien chemin et tous ses noeuds |
*de la table osm_chemins_a_noeuds et insérer le nouveau |
*/ |
private function modifierCheminANoeuds() { |
$this->supprimerCheminANoeuds(); |
foreach ($this->chemin_a_noeuds as $donnee) { |
$infosP = $this->bdd->proteger($donnee); |
$requete = 'INSERT INTO osm_chemin_a_noeuds (id_chemin, id_noeud, ordre) '. |
"VALUES ($infosP[0], $infosP[1], $infosP[2]) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->chemin_a_noeuds = array(); |
} |
//Update des noeuds |
private function modifierNoeuds() { |
foreach ($this->noeuds as $donnee) { |
$infosP = $this->bdd->proteger($donnee); |
$requete = 'UPDATE osm_noeuds '. |
"SET id_noeud = $infosP[0], lat = $infosP[1], `long` = $infosP[2] ". |
"WHERE id_noeud = $infosP[0] ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->noeuds = array(); |
} |
//Suppressions des relations |
private function supprimerRelationsCommunes() { |
$idsIn = $this->getIds($this->relations_communes); |
$this->relations_communes = array(); |
$requete = 'DELETE FROM osm_relations '. |
"WHERE id_relation IN ($idsIn) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
//Suppressions des relations à chemins |
private function supprimerRelationAChemins() { |
$idsIn = $this->getIds($this->relation_a_chemins); |
$this->relation_a_chemins = array(); |
$requete = 'DELETE FROM osm_relation_a_chemins '. |
"WHERE id_relation IN ($idsIn) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
//Suppressions des chemins à noeuds |
private function supprimerCheminANoeuds() { |
$idsIn = $this->getIds($this->chemin_a_noeuds); |
$this->chemin_a_noeuds = array(); |
$requete = 'DELETE FROM osm_chemin_a_noeuds '. |
"WHERE id_chemin IN ($idsIn) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
//Suppressions des chemins à noeuds |
private function supprimerNoeuds() { |
$idsIn = $this->getIds($this->noeuds); |
$this->noeuds = array(); |
$requete = 'DELETE FROM osm_noeuds '. |
"WHERE id_noeud IN ($idsIn) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
private function getIds(&$tableau) { |
$ids = array(); |
foreach ($tableau as $info) { |
$ids[] = $this->bdd->proteger($info[0]); |
} |
$idsSansDoublon = array_unique($ids); |
$idsIn = implode(',', $idsSansDoublon); |
return $idsIn; |
} |
private function creerValuesMultiple($donnees) { |
$values = array(); |
foreach ($donnees as $infos) { |
$infosP = $this->bdd->proteger($infos); |
$values[] = implode(',', $infosP); |
} |
$valuesClause = '('.implode('),(', $values).')'; |
return $valuesClause; |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/Osm.php |
---|
New file |
0,0 → 1,104 |
<?php |
//declare(encoding='UTF-8'); |
/** |
* Exemple de lancement du script : : |
* 1. Création de la base de données : |
* /opt/lampp/bin/php cli.php osm -a chargerStructureSql -m manuel -v 3 |
* |
* 2. Analyse du fichir OSM : |
* /opt/lampp/bin/php cli.php osm -a analyser -f "../donnees/osm/fr_communes_new.osm" -m manuel -v 3 |
* |
* 3. Traitement de l'ordre : |
* /opt/lampp/bin/php cli.php osm -a ordre -m manuel -v 3 |
* |
* 4. Remplissage des polygones : |
* /opt/lampp/bin/php cli.php osm -a polygone -m manuel -v 3 |
* |
* Définition des centroïdes pour les polygones déjà complets: |
* /opt/lampp/bin/php cli.php osm -a centre -m manuel -v 3 |
* |
* 5. Remise de l'ordre à zéro : |
* /opt/lampp/bin/php cli.php osm -a zero -m manuel -v 3 |
* |
* 6. Traitement de l'ordre des polygones incomplets : |
* /opt/lampp/bin/php cli.php osm -a ordonnerPolygoneInc -m manuel -v 3 |
* |
* 7. Remplissage des polygones incomplets : |
* /opt/lampp/bin/php cli.php osm -a remplirPolygoneInc -m manuel -v 3 |
* |
* 8. Renommage des polygones incomplets : |
* /opt/lampp/bin/php cli.php osm -a renommer -m manuel -v 3 |
* |
* 9. Définition des centroïdes : |
* /opt/lampp/bin/php cli.php osm -a centre -m manuel -v 3 |
* |
* @category php 5.4 |
* @package DEL |
* @subpackage Scripts |
* @author Aurélien PERONNET <aurelien@tela-botanica.org> |
* @copyright Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org) |
* @license CeCILL v2 http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt |
* @license GNU-GPL http://www.gnu.org/licenses/gpl.html |
*/ |
// TODO : Améliorer la gestion de l'ordre des chemins pour éviter de prendre en compte des chemins inexistants |
class Osm extends EfloreScript { |
const PROJET_NOM = 'osm'; |
protected $parametres_autorises = array( |
'-f' => array(true, null, 'Chemin du fichier osm à analyser'), |
'-m' => array(false, 'auto', 'Mode «auto» ou «manuel». En manuel, les compteurs dans les boucles sont affichés.')); |
public function executer() { |
try { |
$this->initialiserProjet(self::PROJET_NOM); |
// Lancement de l'action demandée |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'chargerStructureSql' : |
$this->chargerStructureSql(); |
break; |
case 'analyser' : |
$script = $this->chargerClasse('ParseurOsm'); |
$script->executer(); |
break; |
case 'ordre' : |
$script = $this->chargerClasse('OrdonneurDeChemins'); |
$script->executer(); |
break; |
case 'polygone' : |
case 'centre' : |
case 'zero' : |
$script = $this->chargerClasse('PolygoneCreateur'); |
$script->executer(); |
break; |
case 'ordonnerPolygoneInc' : |
case 'remplirPolygoneInc' : |
case 'renommer' : |
$script = $this->chargerClasse('PolygoneReparateur'); |
$script->executer(); |
break; |
case 'maj' : |
$script = $this->chargerClasse('MiseAJour'); |
$script->executer(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
print "\n";// Pour ramener à la ligne en fin de script |
} |
protected function initialiserProjet($projetNom) { |
$this->projetNom = $projetNom; |
} |
private function chargerClasse($classe) { |
require_once $classe.'.php'; |
$conteneur = new Conteneur($this->parametres); |
return new $classe($conteneur); |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/archives/ParseurOsm.php |
---|
New file |
0,0 → 1,245 |
<?php |
/** |
* Exemple de lancement du script : |
* |
* Analyse du fichir OSM : |
* /opt/lampp/bin/php cli.php osm -a analyser -f "../donnees/osm/france_communes_new.osm" -m manuel |
* |
*/ |
class ParseurOsm { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
private $communes = array(); |
private $relations_communes = array(); |
private $relation_a_chemins = array(); |
private $chemin_a_noeuds = array(); |
private $noeuds = array(); |
private $pas = 10000; |
private $pas_commune = 1000; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
public function executer() { |
// Lancement de l'action demandée |
$cmd = $this->conteneur->getParametre('a'); |
switch ($cmd) { |
case 'analyser' : |
$this->lireFichierOsm(); |
break; |
case 'polygone' : |
$this->remplirPolygone(); |
break; |
case 'zero' : |
$this->remettreOrdreAZero(); |
break; |
default : |
$this->messages->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd)); |
} |
} |
/** |
* Lit le fichier OSM et lance l'analyse des noeuds xml en fonction de leur type. |
*/ |
private function lireFichierOsm() { |
$lecteur = $this->getLecteurXml(); |
while ($lecteur->read()) { |
if ($lecteur->nodeType == XMLREADER::ELEMENT) { |
$this->analyserElementXml($lecteur->localName, $lecteur->expand()); |
} |
if ($this->mode == 'manuel') { |
$this->messages->afficherAvancement("Analyse de la ligne du fichier OSM : ", 1); |
} |
} |
$this->insererElementsOrphelins(); |
} |
private function analyserElementXml($elementNom, $noeudDom) { |
switch ($elementNom) { |
case 'relation' : |
$this->analyserRelation($noeudDom); |
break; |
case 'way' : |
$this->analyserWay($noeudDom); |
break; |
case 'node' : |
$this->analyserNode($noeudDom); |
break; |
} |
} |
private function insererElementsOrphelins() { |
$this->insererRelationsCommunes(); |
$this->insererRelationAChemins(); |
$this->insererCheminANoeuds(); |
$this->insererNoeuds(); |
} |
private function getLecteurXml() { |
$fichierOsm = $this->conteneur->getParametre('f'); |
$lecteur = new XMLReader(); |
$ouvertureXmlOk = $lecteur->open($fichierOsm); |
if ($ouvertureXmlOk === false) { |
$msgTpl = "Impossible d'ouvrir le fichier osm : %s"; |
$msg = sprintf($msgTpl, $this->conteneur->getParametre('f')); |
new Exception($msg); |
} |
return $lecteur; |
} |
/** |
* Récupère l'id commune, nom commune et le code INSEE et remplie la table `CommuneOSM` |
*/ |
private function analyserRelation($relation) { |
$idRelation = $relation->getAttribute('id'); |
$chemins = $relation->getElementsByTagName('member'); |
$this->analyserChemins($idRelation, $chemins); |
if (count($this->relation_a_chemins) > $this->pas) { |
$this->insererRelationAChemins(); |
} |
$tags = $relation->getElementsByTagName('tag'); |
$this->analyserTags($idRelation, $tags); |
if (count($this->relations_communes) > $this->pas_commune) { |
$this->insererRelationsCommunes(); |
} |
} |
private function analyserChemins($relation_id, $chemins) { |
$ordreChemin = 1; |
foreach ($chemins as $chemin) { |
if ($chemin->getAttribute('type') == 'way') { //écarter le noeud centrale |
$chemin_id = $chemin->getAttribute('ref'); |
$role = $chemin->getAttribute('role');//role: null, inner, outer, exclave et enclave. |
$this->relation_a_chemins[] = array($relation_id, $chemin_id, $role, $ordreChemin++); |
} |
} |
} |
private function analyserTags($relation_id, $tags) { |
$commune_nom = null; |
$commune_insee = null; |
foreach ($tags as $tag) { |
$tag_cle = $tag->getAttribute('k'); |
$tag_val = $tag->getAttribute('v'); |
switch ($tag_cle) { |
case 'name' : |
$commune_nom = $tag_val; |
break; |
case 'ref:INSEE' : |
$commune_insee = $tag_val; |
break; |
} |
if (!is_null($commune_nom) && !is_null($commune_insee)) { |
if (!isset($this->relations_communes[$relation_id])) { |
$this->relations_communes[$relation_id] = array($relation_id, $commune_nom, $commune_insee); |
} else { |
$e = "La relation #%s possédant le tag ref:INSEE «%s» est déjà prise en compte."; |
$this->messages->traiterErreur($e, array($relation_id, $commune_insee)); |
} |
if (!isset($this->communes[$commune_insee])) { |
$this->communes[$commune_insee] = $relation_id; |
} else { |
$e = "La relation #%s contient déjà le tag ref:INSEE avec la valeur %s.". |
"Veuillez corriger la carte OSM."; |
$this->messages->traiterErreur($e, array($this->communes[$commune_insee], $commune_insee, $relation_id)); |
} |
break;// Stoppe le foreach car nous avons les infos nécessaires |
} |
} |
} |
/** |
* Récupère l'id_way et tous les id_node de chaque way et remplie la table `osm_chemin_a_noeuds` |
*/ |
private function analyserWay($way) { |
$chemin_id = $way->getAttribute('id'); |
$ordre = 1; |
$noeuds = $way->getElementsByTagName('nd'); |
foreach ($noeuds as $noeud) { |
$noeud_id = $noeud->getAttribute('ref'); |
$this->chemin_a_noeuds[] = array($chemin_id, $noeud_id, $ordre++); |
} |
if (count($this->chemin_a_noeuds) > $this->pas) { |
$this->insererCheminANoeuds(); |
} |
} |
/** |
* Fonction qui récupère tous les l'id_node et les valeurs(Lat/Lon) correspondantes et remplie la table `osm_noeuds` |
*/ |
private function analyserNode($node) { |
$noeud_id = $node->getAttribute('id'); |
$lat = $node->getAttribute('lat'); |
$lon = $node->getAttribute('lon'); |
$this->noeuds[] = array($noeud_id, $lat, $lon); |
if (count($this->noeuds) > $this->pas) { |
$this->insererNoeuds(); |
} |
} |
private function insererRelationsCommunes() { |
if (count($this->relations_communes) > 0) { |
$requete = 'INSERT INTO osm_relations (id_relation, nom, code_insee) '. |
'VALUES '.$this->creerValuesMultiple($this->relations_communes). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->relations_communes = array(); |
} |
private function insererRelationAChemins() { |
if (count($this->relation_a_chemins) > 0) { |
$requete = 'INSERT INTO osm_relation_a_chemins (id_relation, id_chemin, role, ordre) '. |
'VALUES '.$this->creerValuesMultiple($this->relation_a_chemins). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->relation_a_chemins = array(); |
} |
private function insererCheminANoeuds() { |
if (count($this->chemin_a_noeuds) > 0) { |
$requete = 'INSERT INTO osm_chemin_a_noeuds (id_chemin, id_noeud, ordre) '. |
'VALUES '.$this->creerValuesMultiple($this->chemin_a_noeuds). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->chemin_a_noeuds = array(); |
} |
private function insererNoeuds() { |
if (count($this->noeuds) > 0) { |
$requete = 'INSERT INTO osm_noeuds (id_noeud, lat, `long`) '. |
'VALUES '.$this->creerValuesMultiple($this->noeuds). |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->noeuds = array(); |
} |
private function creerValuesMultiple($donnees) { |
$values = array(); |
foreach ($donnees as $infos) { |
$infosP = $this->bdd->proteger($infos); |
$values[] = implode(',', $infosP); |
} |
$valuesClause = '('.implode('),(', $values).')'; |
return $valuesClause; |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/FranceCommunes.php |
---|
New file |
0,0 → 1,61 |
<?php |
/** |
* Création de la table osm_communes. |
* /opt/lampp/bin/php cli.php osm -a communes -m manuel |
* |
*/ |
class FranceCommunes { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
private $bddOsmNom; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->bddOsmNom = $this->conteneur->getParametre('bdd_osm_nom'); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
public function executer() { |
// Lancement de l'action demandée |
$cmd = $this->conteneur->getParametre('a'); |
switch ($cmd) { |
case 'cm' : |
$this->supprimerTableOsmCommunes(); |
$this->conteneur->getEfloreCommun()->chargerStructureSql(); |
$this->creerTableOsmCommunes(); |
break; |
case 'cmCreer' : |
$this->creerTableOsmCommunes(); |
break; |
case 'cmSupprimer' : |
$this->supprimerTableOsmCommunes(); |
break; |
default : |
$this->messages->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd)); |
} |
} |
private function supprimerTableOsmCommunes() { |
$requete = 'DROP TABLE IF EXISTS osm_communes '. |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
private function creerTableOsmCommunes() { |
$requete = 'INSERT INTO osm_communes '. |
"SELECT osm_id, osm_version, osm_timestamp, name, ref_insee, shape, shape_centroid, wikipedia ". |
"FROM {$this->bddOsmNom}.multipolygons_ref ". |
"WHERE admin_level = 8 ". |
"AND (ref_insee IS NOT NULL OR ref_insee != '') ". |
"AND CHAR_LENGTH(ref_insee) = 5 ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm/ZonesAdmin.php |
---|
New file |
0,0 → 1,119 |
<?php |
/** |
* Création de la table osm_communes. |
* /opt/lampp/bin/php cli.php osm -a communes -m manuel |
* |
*/ |
class ZonesAdmin { |
private $conteneur; |
private $bdd; |
private $messages; |
private $mode; |
private $bddOsmNom; |
public function __construct($conteneur) { |
$this->conteneur = $conteneur; |
$this->bdd = $this->conteneur->getBdd(); |
$this->bddOsmNom = $this->conteneur->getParametre('bdd_osm_nom'); |
$this->messages = $this->conteneur->getMessages(); |
$this->mode = $this->conteneur->getParametre('m'); |
} |
public function executer() { |
// Lancement de l'action demandée |
$cmd = $this->conteneur->getParametre('a'); |
switch ($cmd) { |
case 'za' : |
$this->supprimerTableOsmZonesAdmin(); |
$this->conteneur->getEfloreCommun()->chargerStructureSql(); |
$this->creerTableOsmZonesAdmin(); |
$this->corrigerTableOsmZonesAdmin(); |
$this->mettreAJourIdZoneGeo(); |
break; |
case 'zaCreer' : |
$this->creerTableOsmZonesAdmin(); |
break; |
case 'zaCorriger' : |
$this->corrigerTableOsmZonesAdmin(); |
break; |
case 'zaMajIdZG' : |
$this->mettreAJourIdZoneGeo(); |
break; |
case 'zaSupprimer' : |
$this->supprimerTableOsmZonesAdmin(); |
break; |
default : |
$this->messages->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd)); |
} |
} |
private function supprimerTableOsmZonesAdmin() { |
$requete = 'DROP TABLE IF EXISTS osm_zones_admin '. |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
private function creerTableOsmZonesAdmin() { |
$requete = 'INSERT INTO osm_zones_admin '. |
"SELECT if(ref_insee != '' AND admin_level = 8, CONCAT('INSEE-C:',ref_insee), ". |
"if(ref_insee != '' AND admin_level = 6, CONCAT('INSEE-D:',ref_insee), ". |
"if(ref_insee != '' AND admin_level = 4, CONCAT('INSEE-R:',ref_insee), ". |
"if(iso3166_2 != '', CONCAT('ISO-3166-2:',iso3166_2), ". |
"if(iso3166_1 != '', CONCAT('ISO-3166-1:',iso3166_1), ". |
"CONCAT('OSM-ID:',osm_id)))))), ". |
'osm_id, osm_version, osm_timestamp, '. |
"if(name_fr != '', name_fr, name), ". |
'shape, shape_centroid, Y(shape_centroid), X(shape_centroid), zone, '. |
'admin_level, iso3166_1, iso3166_2, ref_insee, ref_nuts, '. |
'name, name_fr, name_en, name_es, wikipedia '. |
"FROM {$this->bddOsmNom}.multipolygons_ref ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
private function corrigerTableOsmZonesAdmin() { |
$requete = 'SELECT osm_id, other_tags '. |
"FROM {$this->bddOsmNom}.multipolygons_ref ". |
"WHERE iso3166_2 IS NULL AND other_tags LIKE '%\"iso3166-2\"%' ". |
' -- '.__FILE__.' : '.__LINE__; |
$resultat = $this->bdd->recupererTous($requete); |
if ($resultat) { |
foreach ($resultat as $infos) { |
$tags = $this->getTags($infos['other_tags']); |
$iso_3166_2 = $this->bdd->proteger($tags['iso3166-2']); |
$osm_id = $this->bdd->proteger($infos['osm_id']); |
$requete = 'UPDATE osm_zones_admin '. |
"SET code_iso_3166_2 = $iso_3166_2 ". |
"WHERE osm_id = $osm_id ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
} |
} |
private function getTags($tagsInfos) { |
$tags = array(); |
$clesValeurs = explode(',', $tagsInfos); |
foreach ($clesValeurs as $cleValeur) { |
list($cle, $val) = explode('=>', $cleValeur); |
$tags[trim($cle, '"')] = trim($val, '"'); |
} |
return $tags; |
} |
private function mettreAJourIdZoneGeo() { |
$requete = 'UPDATE osm_zones_admin '. |
"SET id_zone_geo = if(code_insee != '' AND niveau = 8, CONCAT('INSEE-C:',code_insee), ". |
"if(code_insee != '' AND niveau = 6, CONCAT('INSEE-D:',code_insee), ". |
"if(code_insee != '' AND niveau = 4, CONCAT('INSEE-R:',code_insee), ". |
"if(code_iso_3166_2 != '', CONCAT('ISO-3166-2:',code_iso_3166_2), ". |
"if(code_iso_3166_1 != '', CONCAT('ISO-3166-1:',code_iso_3166_1), ". |
"CONCAT('OSM-ID:',osm_id)))))) ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
} |
/tags/v5.8-aspergeraie/scripts/modules/osm |
---|
New file |
Property changes: |
Added: svn:ignore |
+.config.ini.swp |
Added: svn:mergeinfo |
Merged /branches/v5.2-alpage/scripts/modules/osm:r976,978 |
Merged /branches/v5.7-arrayanal/scripts/modules/osm:r1050,1052 |
Merged /branches/v5.1-acheb/scripts/modules/osm:r927 |
Merged /branches/v5.7-arrayanal:r1066-1070 |
/tags/v5.8-aspergeraie/scripts/modules/apd/apd.ini |
---|
New file |
0,0 → 1,18 |
version="3_4_0" |
dossierapd = "{ref:dossierDonneesEflore}apd/{ref:version}/" |
[tables] |
apdMeta = "apd_meta" |
apd = "apd_v{ref:version}" |
[fichiers] |
structureSql = "apd_v{ref:version}.sql" |
csvCjbg = "apd_v{ref:version}.csv" |
csvRtax = "apd_v{ref:version}_rtax.csv" |
csvRtaxModifie = "apd_v{ref:version}_rtax_modifie.csv" |
[chemins] |
structureSql = "{ref:dossierapd}{ref:fichiers.structureSql}" |
csvCjbg = "{ref:dossierapd}{ref:fichiers.csvCjbg}" |
csvRtax = "{ref:dossierapd}{ref:fichiers.csvRtax}" |
csvRtaxModifie = "{ref:dossierapd}{ref:fichiers.csvRtaxModifie}" |
/tags/v5.8-aspergeraie/scripts/modules/apd/Apd.php |
---|
New file |
0,0 → 1,719 |
<?php |
//declare(encoding='UTF-8'); |
/** |
* Exemple de lancement du script : : |
* /opt/lampp/bin/php cli.php apd -a chargerTous |
* |
* Base de données des Trachéophytes (trachéo...quoi ?? C'est le truc avec le stylo Bic ?) |
* d'Afrique de l'Ouest (et Centrale mais faut pas le dire) |
* |
* @category php 5.2 |
* @package eFlore/Scripts |
* @author Mathias CHOUET <mathias@tela-botanica.org> |
* @copyright Copyright (c) 2014, Tela Botanica (accueil@tela-botanica.org) |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
*/ |
class Apd extends EfloreScript { |
private $table = null; |
private $tableMeta = null; |
private $pasInsertion = 1000; |
private $departInsertion = 0; |
protected $parametres_autorises = array(); |
// Entêtes du nouveau fichier Rtax à produire |
protected $entetesRtax = array("num_nom","num_nom_retenu","num_tax_sup","rang","nom_sci", |
"nom_supra_generique","genre","epithete_infra_generique","epithete_sp", |
"type_epithete","epithete_infra_sp","cultivar_groupe","cultivar","nom_commercial", |
"auteur","annee","biblio_origine","notes","nom_addendum","homonyme","num_type", |
"num_basionyme","synonyme_proparte","synonyme_douteux","synonyme_mal_applique", |
"synonyme_orthographique","orthographe_originelle","hybride_parent_01", |
"hybride_parent_01_notes","hybride_parent_02","hybride_parent_02_notes", |
"nom_francais","presence","statut_origine ","statut_introduction","statut_culture","exclure_taxref"); |
public function initialiserProjet($projetNom) { |
parent::initialiserProjet($projetNom); |
$this->table = Config::get("apd"); |
$this->tableMeta = Config::get("apdMeta"); |
} |
public function executer() { |
try { |
$this->initialiserProjet('apd'); |
// Lancement de l'action demandée |
$cmd = $this->getParametre('a'); |
switch ($cmd) { |
case 'tout' : |
$ok = $this->productionCsvPourReferentiels(); |
if ($ok === true) { |
$this->integrationEFlore(); |
} |
break; |
case 'ref' : // partie 1 : "referentiels" |
$this->productionCsvPourReferentiels(); |
break; |
case 'eflore' : // partie 2 : "eFlore" |
$this->integrationEFlore(); |
break; |
case 'nettoyage' : |
$this->nettoyage(); |
break; |
case 'chargerStructureSql' : |
//$this->creerStructure(); |
$this->chargerStructureSql(); |
break; |
case 'verifierEtGenererCsvRtax' : |
$this->verifierEtGenererCsvRtax(); |
break; |
case 'chargerCsvRtax' : |
$this->chargerCsvRtax(); |
break; |
case 'changerRangs' : |
$this->changerRangs(); |
break; |
case 'completerNumNomRetenu' : |
$this->completerNumNomRetenu(); |
break; |
case 'supprimerNumTaxSupPourSynonymes' : |
$this->supprimerNumTaxSupPourSynonymes(); |
break; |
case 'subspAutonymes' : |
$this->subspAutonymes(); |
break; |
case 'genererNomSupraGenerique' : |
$this->genererNomSupraGenerique(); |
break; |
case 'genererEpitheteInfraGenerique' : |
$this->genererEpitheteInfraGenerique(); |
break; |
case 'exporterCSVModifie' : |
$this->exporterCSVModifie(); |
break; |
case 'genererChpNumTax' : |
$this->genererChpNumTax(); |
break; |
case 'genererNomSciHtml' : |
$this->genererChpNomSciHtml(); |
break; |
case 'genererChpNomComplet' : |
$this->genererChpNomComplet(); |
break; |
case 'genererChpFamille' : |
$this->genererChpFamille(); |
break; |
case 'genererChpHierarchie' : |
$this->genererChpHierarchie(); |
break; |
default : |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!"); |
} |
} catch (Exception $e) { |
$this->traiterErreur($e->getMessage()); |
} |
} |
// Lance la première moitié du boulot, et s'arrête lorsque le fichier CSV |
// au format Rtax est rempli avec les données amendées - il est prêt à rentrer dans Rtxß. |
// Retourne true si tout s'est bien passé, false sinon |
protected function productionCsvPourReferentiels() { |
$retour = false; |
$this->nettoyage(); |
$this->chargerStructureSql(); |
$verifOk = $this->verifierEtGenererCsvRtax(); |
if ($verifOk === true) { |
$chgtOk = $this->chargerCsvRtax(); |
if ($chgtOk) { |
$this->changerRangs(); |
$this->completerNumNomRetenu(); |
$this->supprimerNumTaxSupPourSynonymes(); |
$this->subspAutonymes(); |
$this->genererNomSupraGenerique(); |
$this->genererEpitheteInfraGenerique(); |
$this->exporterCSVModifie(); |
$retour = true; |
} |
} |
return $retour; |
} |