Exemple #1
0
//Ouverture du fichier final
$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, "r+");
//Positionnement a la fin du fichier
fseek($fo, filesize("{$base_path}/temp/" . $file_out));
for ($i = $n_current; $i < $n_current + $n_per_pass; $i++) {
    $requete = "select notice, encoding from import_marc where no_notice=" . ($i + 1) . " and origine='{$origine}'";
    $resultat = mysql_query($requete);
    if (mysql_num_rows($resultat) != 0) {
        //Si la notice existe début de conversion
        $obj = mysql_fetch_object($resultat);
        $notice_ = convert_notice($obj->notice, $obj->encoding);
        @fwrite($fo, $notice_);
        $z++;
    } else {
        break;
    }
}
//Y-a-t-il eu des erreurs ?
if ($message_convert != "") {
    $requete = "insert into error_log (error_date,error_origin, error_text) values(now(),'convert.log " . $origine . "','" . addslashes($message_convert) . "')";
    mysql_query($requete);
    echo mysql_error();
}
//Fin du fichier de notice ?
if ($z < $n_per_pass) {
    $n_current = $n_current + $z;
Exemple #2
0
function from_sutrs($ss, $campo)
{
    $base_path = "../..";
    global $class_path;
    global $lang;
    global $include_path;
    global $charset;
    global $campi, $sep;
    global $fun;
    $campi = array();
    // strip \r\n and spaces
    $pattern = "/\r/";
    $ss = preg_replace($pattern, "", $ss);
    $pattern = "/\n /";
    $ss = preg_replace($pattern, " ", $ss);
    $pattern = "/\n/";
    $ss = preg_replace($pattern, " ", $ss);
    $pattern = "/\\s+/";
    $ss = preg_replace($pattern, " ", $ss);
    // put tag sutrs in sutrs record
    foreach ($campo as $dummykey => $v) {
        $dato[$v] = "";
        $ss = preg_replace("/{$v}:/", "|{$v}::", $ss);
    }
    // 	explode fields sutrs in $dato (array)
    $aX = preg_split("/\\|/", $ss);
    foreach ($aX as $dummykey => $vv) {
        $v = preg_split("/::/", $vv);
        if ($dato[$v[0]] == '') {
            $sep = '';
        } else {
            $sep = '|';
        }
        $dato[$v[0]] .= $sep . $v[1];
    }
    // copy $dato values to associative array $campi which keys are standard and in english
    reset($campo);
    while (list($k, $v) = each($campo)) {
        $campi[$k] = $dato[$v];
    }
    //* DEBUG
    // 			$fp = fopen ("../../temp/raw".rand().".unimarc","wb");
    // 			fwrite ($fp,$lista[3]);
    // 			fclose ($fp);
    // text record construction in $notice
    $sep = '|';
    $notice = "";
    //isbn
    $notice .= sut_numbers();
    // col. 1
    $notice .= del_more_garbage(sut_authors());
    // col. 2..28  (1 author = 3 col)
    $notice .= del_more_garbage(sut_title());
    // col.29..32
    $notice .= sut_edition();
    // col.33
    $notice .= del_more_garbage(sut_editor());
    // col.34..36
    $notice .= del_more_garbage(sut_collection());
    // col.37..40
    // serie
    $notice .= sut_dummy(2);
    // col.41..42
    $notice .= sut_decimalindex();
    // col.43
    $notice .= sut_freeindex();
    // col.44
    $notice .= sut_lang();
    // col.45
    // orig.lang
    $notice .= sut_dummy(1);
    // col.46
    $notice .= sut_collation();
    // col.47..50
    $notice .= sut_notes();
    // col.51..53
    //DEBUG: in z_progression_main expand size frame3 to 50%
    //print "<hr /><br />";
    //printr($campo,'','CAMPO');
    //printr($campi,'','CAMPI');
    //print "$ss<br /><hr />$notice";
    //Lecture des paramètres d'import
    $param_path = "sutrs2unimarciso";
    //Lecture des paramètres
    _parser_("{$base_path}/admin/convert/imports/" . $param_path . "/params.xml", array("IMPORTNAME" => "_import_name_", "NPERPASS" => "_n_per_pass_", "INPUT" => "_input_", "STEP" => "_step_", "OUTPUT" => "_output_"), "PARAMS");
    require_once "{$base_path}/admin/convert/xmltransform.php";
    //En fonction du type de fichier d'entrée, inclusion du script de gestion des entrées
    require_once "{$base_path}/admin/convert/imports/input_text.inc.php";
    //En fonction du type de fichier de sortie, inclusion du script de gestion des sorties
    require_once "{$base_path}/admin/convert/imports/output_iso_2709.inc.php";
    $n_current = 0;
    $n_errors = 0;
    $n_per_pass = 1;
    $notice_ = convert_notice($notice);
    return $notice_;
}