Browse Source

Passer en stable

Lors de l'import CSV, si on utilise un en-tete, et si plusieurs colonnes ont le meme en-tete, il faut les mettre dans un tableau que l'on ne peuple que des valeurs non vides
svn/attic/spip-bonux-3/118152
cedric@yterium.com 11 years ago
parent
commit
6d066a3ac1
  1. 17
      inc/importer_csv.php
  2. 4
      paquet.xml

17
inc/importer_csv.php

@ -74,20 +74,33 @@ function inc_importer_csv_dist($file, $head = false, $delim = ",", $enclos = '"'
if ($header){
$header = array_map('importer_csv_importcharset',$header);
$header = array_map('importer_csv_nettoie_key',$header);
$header_type = array();
foreach ($header as $heading) {
if (!isset($header_type[$heading]))
$header_type[$heading] = "scalar";
else
$header_type[$heading] = "array";
}
}
}
while (($data = fgetcsv($handle, $len, $delim, $enclos)) !== FALSE) {
$data = array_map('importer_csv_importcharset',$data);
if ($head AND isset($header)) {
foreach ($header as $key=>$heading) {
$row[$heading]=(isset($data[$key])) ? $data[$key] : '';
if ($header_type[$heading]=="array"){
if (!isset($row[$heading]))
$row[$heading] = array();
if (isset($data[$key]) AND strlen($data[$key]))
$row[$heading][]= $data[$key];
}
else
$row[$heading]=(isset($data[$key])) ? $data[$key] : '';
}
$return[]=$row;
} else {
$return[]=$data;
}
}
fclose($handle);
}
return $return;
}

4
paquet.xml

@ -1,8 +1,8 @@
<paquet
prefix="spip_bonux"
categorie="outil"
version="3.0.0-dev"
etat="dev"
version="3.0.1"
etat="stable"
compatibilite="[3.0.0-dev;3.1.*]"
logo="img_pack/spip-bonux.png"
documentation="http://www.spip-contrib.net/SPIP-Bonux"

Loading…
Cancel
Save