"_item_"), "CATALOG");
//Lecture des paramètres
_parser_("imports/".$param_path."/params.xml", array("IMPORTNAME" => "_import_name_", "NPERPASS" => "_n_per_pass_", "INPUT" => "_input_", "STEP" => "_step_", "OUTPUT" => "_output_"), "PARAMS");
//Inclusion des librairies éventuelles
for ($i = 0; $i < count($step); $i ++) {
if ($step[$i]['TYPE'] == "custom") {
//echo "imports/".$param_path."/".$step[$i][SCRIPT][0][value];
require_once ("imports/".$param_path."/".$step[$i]['SCRIPT'][0]['value']);
}
}
require_once ("xmltransform.php");
//En fonction du type de fichier d'entrée, inclusion du script de gestion des entrées
switch ($input_type) {
case "xml" :
require_once ("imports/input_xml.inc.php");
break;
case "iso_2709" :
require_once ("imports/input_iso_2709.inc.php");
break;
case "text" :
require_once("imports/input_text.inc.php");
break;
case "custom" :
require_once ("imports/$param_path/".$input_params['SCRIPT']);
break;
default :
die($msg["ie_import_entry_not_valid"]);
}
//En fonction du type de fichier de sortie, inclusion du script de gestion des sorties
switch ($output_type) {
case "xml" :
require_once ("imports/output_xml.inc.php");
break;
case "txt" :
require_once ("imports/output_txt.inc.php");
break;
case "iso_2709" :
require_once("imports/output_iso_2709.inc.php");
break;
case "custom" :
require_once ("imports/$param_path/".$output_params['SCRIPT']);
break;
default :
die($msg["ie_output_type_not_valid"]);
}
//Si premier accès
if (!$first) {
$origine=str_replace(" ","",microtime());
$origine=str_replace("0.","",$origine);
//Copie du fichier dans le répertoire temporaire
if ($_FILES['import_file']['name']) {
if (!@ copy($_FILES['import_file']['tmp_name'], "$base_path/temp/".$origine.$_FILES['import_file']['name'])) {
error_message_history($msg["ie_tranfert_error"], $msg["ie_transfert_error_detail"], 1);
exit;
} else $file_in = $origine.$_FILES['import_file']['name'];
} else if ($file_in && file_exists($base_path."/temp/".$file_in)){
} else {
if (!$file_in) $file_in = "convert".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic";
if (!file_exists($base_path."/temp/convert".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic")) {
error_message_history($msg["ie_file_not_found"], sprintf($msg["ie_file_not_found_detail"],$file_in), 1);
exit;
}
}
//Première notice = 0
$n_current = 0;
//Nombre d'erreurs = 0;
$n_errors = 0;
//Création du fichier de sortie
$f = explode(".", $file_in);
if (count($f) > 1) {
unset($f[count($f) - 1]);
}
$file_out = implode(".", $f).".".$output_params['SUFFIX']."~";
$fo = fopen("$base_path/temp/".$file_out, "w+");
//Ouverture du fichier d'origine
$fi = fopen("$base_path/temp/".$file_in, "r");
//Récupération du nombre de notices et enregistrement dans la base de données des notices
$index = _get_n_notices_($fi, "$base_path/temp/".$file_in, $input_params,$origine);
if (count($index) == 0) {
error_message_history($msg["ie_empty_file"], sprintf($msg["ie_empty_file_detail"],$import_type_l), 1);
exit;
}
//Entête
@ fwrite($fo, _get_header_($output_params));
fclose($fo);
//Vidage de la table de log
//mysql_query("delete from error_log where error_origin='convert.log'");
}
function convert_notice($notice,$encoding) {
global $step;
global $param_path;
global $n_errors;
global $message_convert;
global $n_current;
global $z;
for ($i = 0; $i < count($step); $i ++) {
$s = $step[$i];
//si on a un encodage sur la notice, on le rajoute aux parametres
if($encoding) $s['ENCODING'] = $encoding;
$islast=($i==count($step)-1);
$isfirst=($i==0);
switch ($s[TYPE]) {
case "xmltransform" :
$r = perform_xslt($notice, $s, $islast, $isfirst, $param_path);
break;
case "toiso" :
$r = toiso($notice, $s, $islast, $isfirst, $param_path);
break;
case "isotoxml" :
$r = isotoxml($notice, $s, $islast, $isfirst, $param_path);
break;
case "texttoxml":
$r = texttoxml($notice, $s, $islast, $isfirst, $param_path);
break;
case "custom" :
eval("\$r=".$s['CALLBACK'][0][value]."(\$notice, \$s, \$islast, \$isfirst, \$param_path);");
break;
}
if (!$r['VALID']) {
$n_errors ++;
$message_convert.= "Notice ". ($n_current + $z)." : ".$r['ERROR']."
\n";
$notice = "";
break;
} else {
$notice = $r['DATA'];
if($r['WARNING']){
$n_errors ++;
$message_convert.= "Notice ". ($n_current + $z)." : ".$r['WARNING']."
\n";
}
}
}
return $notice;
}
$requete="select count(1) from import_marc where origine='$origine'";
$resultat=mysql_query($requete);
$n_notices=mysql_result($resultat,0,0);
$percent = @ round(($n_current / $n_notices) * 100);
if ($percent == 0)
$percent = 1;
echo "