"_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
if (is_array($step)) {
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
$input_instance = start_import::get_instance_from_input_type($input_type);
//En fonction du type de fichier de sortie, inclusion du script de gestion des sorties
$output_instance = start_export::get_instance_from_output_type($output_type);
//Si premier accès
if(!isset($first)) $first = '';
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
if(is_object($input_instance)) {
$index = $input_instance->_get_n_notices_($fi, "$base_path/temp/".$file_in, $input_params,$origine);
} else {
$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
if(isset($output_params['SCRIPT'])) {
$class_name = str_replace('.class.php', '', $output_params['SCRIPT']);
}
if(is_object($output_instance)) {
fwrite($fo, $output_instance->_get_header_($output_params));
} elseif (isset($class_name) && class_exists($class_name)) {
$import_instance = new $class_name();
fwrite($fo, $import_instance->_get_header_($output_params));
} else {
fwrite($fo, _get_header_($output_params));
}
fclose($fo);
//Vidage de la table de log
//pmb_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;
if (is_array($step)) {
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" :
$static = explode('.', $s['SCRIPT'][0]['value']);
if (class_exists($static[0])) {
eval("\$r=".$static[0]."::".$s['CALLBACK'][0]['value']."(\$notice, \$s, \$islast, \$isfirst, \$param_path);");
} else {
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(isset($r['WARNING']) && $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=pmb_mysql_query($requete);
$n_notices=pmb_mysql_result($resultat,0,0);
$percent = @ round(($n_current / $n_notices) * 100);
if ($percent == 0)
$percent = 1;
echo "
".round($percent)."% |