Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 581 → Rev 582

/trunk/jrest/services/InventoryImportExcel.php
306,7 → 306,9
$info_milieu="000null";
break;
case DEPARTEMENT:
$info_commune['code']="000null";
/*if (!isset ($info_commune['code']) || $info_commune['code']=='') {
$info_commune['code']="000null";
}*/
break;
case LATITUDE:
$info_latitude="000null";
324,7 → 326,6
 
list($jour,$mois,$annee)=split("/",$info_dateobs);
$info_dateobs=$annee."-".$mois."-".$jour." 0:0:0";
 
$query = "INSERT INTO cel_inventory (identifiant,ordre,nom_sel,num_nom_sel,nom_ret,num_nom_ret,num_taxon,famille,location,id_location,date_observation,lieudit,station, milieu, commentaire, date_creation,date_modification,coord_x,coord_y) " .
" VALUES('".$DB->escapeSimple($utilisateur)."','".
$DB->escapeSimple($this->dernier_ordre)."','".
346,7 → 347,6
$DB->escapeSimple($info_longitude)."')";
// print "\n";
 
 
$res =& $DB->query($query);
 
if (PEAR::isError($res)) {
421,7 → 421,6
}
}
 
$res =& $DB->query($query);
 
if (DB::isError($res)) {
438,18 → 437,20
function traiterLieudit($lieudit) { // texte libre
 
//echo "traitement lieudit";
 
return utf8_encode(trim($lieudit));
$lieudit=fix_latin($lieudit);
return trim($lieudit);
}
 
function traiterStation($station) { // texte libre
// echo "traitement station";
return utf8_encode(trim($station));
$station=fix_latin($station);
return trim($station);
}
 
function traiterMilieu($milieu) { // texte libre
// echo "traitement milieu";
return utf8_encode(trim($milieu));
$milieu=fix_latin($milieu);
return trim($milieu);
}
 
function traiterDepartement($departement) { // texte libre
469,6 → 470,7
 
function traiterNotes($notes) { // texte libre
// echo "traitement notes";
$notes=remove_accent($notes);
return utf8_encode(trim($notes));
}
 
841,7 → 843,67
 
}
 
function init_byte_map(){
global $byte_map;
for($x=128;$x<256;++$x){
$byte_map[chr($x)]=utf8_encode(chr($x));
}
$cp1252_map=array(
"\x80"=>"\xE2\x82\xAC", // EURO SIGN
"\x82" => "\xE2\x80\x9A", // SINGLE LOW-9 QUOTATION MARK
"\x83" => "\xC6\x92", // LATIN SMALL LETTER F WITH HOOK
"\x84" => "\xE2\x80\x9E", // DOUBLE LOW-9 QUOTATION MARK
"\x85" => "\xE2\x80\xA6", // HORIZONTAL ELLIPSIS
"\x86" => "\xE2\x80\xA0", // DAGGER
"\x87" => "\xE2\x80\xA1", // DOUBLE DAGGER
"\x88" => "\xCB\x86", // MODIFIER LETTER CIRCUMFLEX ACCENT
"\x89" => "\xE2\x80\xB0", // PER MILLE SIGN
"\x8A" => "\xC5\xA0", // LATIN CAPITAL LETTER S WITH CARON
"\x8B" => "\xE2\x80\xB9", // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
"\x8C" => "\xC5\x92", // LATIN CAPITAL LIGATURE OE
"\x8E" => "\xC5\xBD", // LATIN CAPITAL LETTER Z WITH CARON
"\x91" => "\xE2\x80\x98", // LEFT SINGLE QUOTATION MARK
"\x92" => "\xE2\x80\x99", // RIGHT SINGLE QUOTATION MARK
"\x93" => "\xE2\x80\x9C", // LEFT DOUBLE QUOTATION MARK
"\x94" => "\xE2\x80\x9D", // RIGHT DOUBLE QUOTATION MARK
"\x95" => "\xE2\x80\xA2", // BULLET
"\x96" => "\xE2\x80\x93", // EN DASH
"\x97" => "\xE2\x80\x94", // EM DASH
"\x98" => "\xCB\x9C", // SMALL TILDE
"\x99" => "\xE2\x84\xA2", // TRADE MARK SIGN
"\x9A" => "\xC5\xA1", // LATIN SMALL LETTER S WITH CARON
"\x9B" => "\xE2\x80\xBA", // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
"\x9C" => "\xC5\x93", // LATIN SMALL LIGATURE OE
"\x9E" => "\xC5\xBE", // LATIN SMALL LETTER Z WITH CARON
"\x9F" => "\xC5\xB8" // LATIN CAPITAL LETTER Y WITH DIAERESIS
);
foreach($cp1252_map as $k=>$v){
$byte_map[$k]=$v;
}
}
 
function fix_latin($instr){
if(mb_check_encoding($instr,'UTF-8'))return $instr; // no need for the rest if it's all valid UTF-8 already
global $nibble_good_chars,$byte_map;
$outstr='';
$char='';
$rest='';
while((strlen($instr))>0){
if(1==@preg_match($nibble_good_chars,$input,$match)){
$char=$match[1];
$rest=$match[2];
$outstr.=$char;
}elseif(1==@preg_match('@^(.)(.*)$@s',$input,$match)){
$char=$match[1];
$rest=$match[2];
$outstr.=$byte_map[$char];
}
$instr=$rest;
}
return $outstr;
}
 
 
function remove_accent($str)
{
$a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î',