if ($z3950_debug) { $fp = fopen("../../temp/raw" . rand() . ".marc", "wb"); fwrite($fp, $rec); fclose($fp); } if (strpos($rec, chr(0x1d)) !== false) { $rec = substr($rec, 0, strpos($rec, chr(0x1d)) + 1); } $monEnr = new iso2709_record($rec); if ($monEnr->valid()) { $messageframe = " {$p} " . $msg['z3950_lu_bin']; $pb = 0; } else { $rec = yaz_record($id, $p, "string"); $monEnr2 = new iso2709_record($rec); if ($monEnr2->valid()) { $messageframe = "{$p} " . $msg['z3950_lu_cok']; $pb = 0; } else { // DEBUG //$fp = fopen ("../../temp/raw".rand().".sutrs","wb"); //fwrite ($fp, $rec); //fclose ($fp); $rec = sutrs_record($rec, $sutrs_lang); $messageframe = " {$p} " . $msg['z3950_lu_chs']; //$pb = 1; //$rec=""; } } if ($pb) { $messageframe = $msg["z3950_reception_notice"] . $messageframe;
function recup_noticeunimarc($notice) { global $id_unimarc; global $doc_type; global $hierarchic_level; global $bibliographic_level; global $bibliographic_level_origine; global $hierarchic_level_origine; global $isbn; global $issn_011; global $prix; global $prix_cd; global $cb; global $lang_code; global $org_lang_code; global $tit_200a; global $tit_200c; global $tit_200d; global $tit_200e; global $tit_200v; global $serie_200; global $editeur_lieu; global $editeur_adr; global $editeur_nom; global $editeur_date; global $editeur_pays; global $editeur_pmbfields; global $no_edition; global $npages; global $ill; global $size; global $accomp; global $collection_225; global $n_contenu; global $n_resume; global $n_gen; global $EAN; global $collection_410; global $collection_411; global $serie; global $index_sujets; global $dewey; global $dewey_l; global $tu_500; global $tu_500_r; global $tu_500_s; global $tu_500_j; global $aut_700; global $aut_701; global $aut_702; global $aut_710; global $aut_711; global $aut_712; global $origine_notice; global $lien, $eformat; global $info_995; global $info_996; global $info_852; global $analytique; global $info_600_a, $info_600_j, $info_600_x, $info_600_y, $info_600_z; global $info_601_a, $info_601_j, $info_601_x, $info_601_y, $info_601_z; global $info_602_a, $info_602_j, $info_602_x, $info_602_y, $info_602_z; global $info_605_a, $info_605_j, $info_605_x, $info_605_y, $info_605_z; global $info_606_a, $info_606_j, $info_606_x, $info_606_y, $info_606_z; global $info_607_a, $info_607_j, $info_607_x, $info_607_y, $info_607_z; global $info_686; global $indicateur; global $link_generate; $id_import = array(); $id_unimarc = 0; $indicateur = array(); $doc_type = ""; $hierarchic_level = '0'; $bibliographic_level = 'm'; $isbn = array(); $issn_011 = array(); $prix = array(); $prix_cd = array(); $cb = ""; $lang_code = array(); $org_lang_code = array(); $tit_200a = array(); $tit_200c = array(); $tit_200d = array(); $tit_200e = array(); $tit_200v = array(); $serie_200 = array(); $editeur_lieu = array(); $editeur_adr = array(); $editeur_nom = array(); $editeur_date = array(); $editeur_pays = array(); $editeur_pmbfields = array(); $npages = array(); $no_edition = array(); $ill = array(); $size = array(); $accomp = array(); $collection_225 = array(); $collection_410 = array(); $collection_411 = array(); $n_contenu = array(); $n_resume = array(); $n_gen = array(); $EAN = array(); $serie = array(); $index_sujets = array(); $dewey = array(); $dewey_l = array(); $tu_500 = array(); $tu_500_r = array(); $tu_500_s = array(); $tu_500_j = array(); $aut_700 = array(); $aut_701 = array(); $aut_702 = array(); $aut_710 = array(); $aut_711 = array(); $aut_712 = array(); $origine_notice = array(); $lien = array(); $eformat = array(); $info_995 = array(); $info_852 = array(); $analytique = array(); $info_600_a = array(); $info_600_j = array(); $info_600_x = array(); $info_600_y = array(); $info_600_z = array(); $info_601_a = array(); $info_601_j = array(); $info_601_x = array(); $info_601_y = array(); $info_601_z = array(); $info_602_a = array(); $info_602_j = array(); $info_602_x = array(); $info_602_y = array(); $info_602_z = array(); $info_605_a = array(); $info_605_j = array(); $info_605_x = array(); $info_605_y = array(); $info_605_z = array(); $info_606_a = array(); $info_606_j = array(); $info_606_x = array(); $info_606_y = array(); $info_606_z = array(); $info_607_a = array(); $info_607_j = array(); $info_607_x = array(); $info_607_y = array(); $info_607_z = array(); $info_686 = array(); $info_996 = array(); $record = new iso2709_record($notice, AUTO_UPDATE); if (!$record->valid("import_notice")) { // On ne traite pas les notices invalides /*echo "<pre>"; print_r($record->inner_data); echo "</pre>"; die();*/ $num_notice = $record->get_subfield("001"); $titr = $record->get_subfield_array("200", 'a'); $requete = "insert into error_log(error_origin,error_text) values('import_func_" . addslashes(SESSid) . ".inc.php','" . addslashes("La notice (numéro : " . $num_notice[0] . ", titre : " . $titr[0] . ") n'a pas été reprise. <BR/><span style='color:#FF0000'>Erreur(s):" . implode("<BR/>", $record->errors) . "</span>") . "')"; mysql_query($requete); return false; } $doc_type = $record->inner_guide['dt']; $bibliographic_level_origine = $record->inner_guide['bl']; $hierarchic_level_origine = $record->inner_guide['hl']; // traitements particuliers, solution d'urgence pour les pério et autres. if ($link_generate) { //Si on choisit d'importer les liens on reprend le niveau switch ($bibliographic_level_origine) { case 'a': $hierarchic_level = '2'; $bibliographic_level = 'a'; break; case 's': if ($hierarchic_level_origine <= '1') { $hierarchic_level = '1'; $bibliographic_level = 's'; } else { $hierarchic_level = '2'; $bibliographic_level = 'b'; } break; case 'm': case 'c': default: // suite à pb d'export Orphée : si inconnu, non conforme, on force à 0 et m $hierarchic_level = '0'; $bibliographic_level = 'm'; break; } } else { //Sinon on reprend tous en temps que monographie $hierarchic_level = '0'; $bibliographic_level = 'm'; } for ($i = 0; $i < count($record->inner_directory); $i++) { $cle = $record->inner_directory[$i]['label']; //$length=$record->inner_directory[$i]['length']; //$adress=$record->inner_directory[$i]['adress']; $flag_cle = 0; if (!array_key_exists($cle, $indicateur)) { $flag_cle = 1; } // memo indicateur de champ $indicateur[$cle][] = substr($record->inner_data[$i]['content'], 0, 2); if ($flag_cle) { switch ($cle) { case "001": $id_import = $record->get_subfield($cle); $id_unimarc = $id_import[0]; break; case "010": /* isbn */ $isbn = $record->get_subfield($cle, 'a'); $prix = $record->get_subfield($cle, 'd'); break; case "011": /* issn_011 */ $issn_011 = $record->get_subfield($cle, 'a'); break; case "071": /* barcode */ $cb = $record->get_subfield($cle, "a"); break; case "101": /* language */ $lang_code = $record->get_subfield_array($cle, "a"); $org_lang_code = $record->get_subfield_array($cle, "c"); break; case "200": /* titles */ $tit_200a = $record->get_subfield_array($cle, 'a'); $tit_200c = $record->get_subfield_array($cle, 'c'); $tit_200d = $record->get_subfield_array($cle, 'd'); $tit_200e = $record->get_subfield_array($cle, 'e'); $tit_200v = $record->get_subfield_array($cle, 'v'); $serie_200 = $record->get_subfield($cle, "h", "i"); break; case "205": /* no_edition */ $no_edition = $record->get_subfield_array($cle, "a"); break; case "210": /* publisher */ // b: adr $editeur_lieu = $record->get_subfield_array_array($cle, "a"); $editeur_adr = $record->get_subfield_array_array($cle, "b"); $editeur_nom = $record->get_subfield_array_array($cle, "c"); $editeur_date = $record->get_subfield_array($cle, "d"); $editeur_pays = $record->get_subfield_array_array($cle, "z"); $editeur_pmbfields = $record->get_subfield_array_array($cle, "9"); break; case "215": /* description */ $npages = $record->get_subfield_array($cle, "a"); $ill = $record->get_subfield_array($cle, "c"); $size = $record->get_subfield_array($cle, "d"); $accomp = $record->get_subfield_array($cle, "e"); break; case "225": /* collection */ $collection_225 = $record->get_subfield($cle, "a", "i", "v", "x"); break; case "300": /* inside */ $n_gen = $record->get_subfield_array($cle, "a"); break; case "327": /* inside */ $n_contenu = $record->get_subfield_array($cle, "a"); break; case "330": /* abstract */ $n_resume = $record->get_subfield_array($cle, "a"); break; case "345": /* EAN */ $EAN = $record->get_subfield($cle, "b"); $prix_cd = $record->get_subfield($cle, "d"); break; case "410": /* collection */ $collection_410 = $record->get_subfield($cle, "v", "t", "x", "3"); break; case "411": /* sub-collection */ $collection_411 = $record->get_subfield($cle, "v", "t", "x", "3"); break; case "461": /* series */ $serie = $record->get_subfield($cle, "t", "v"); break; case "464": /* analytique */ // $a pour le tout-venant le reste pour les périodiques bretons ! C'est un periodique donc un depouillement ou une notice objet $analytique = $record->get_subfield_array_array($cle); $info_464 = $record->get_subfield($cle, "t", "v", "p", "d", "z", "e"); break; case "500": // titres uniformes $tu_500 = $record->get_subfield($cle, "a", "i", "k", "l", "m", "n", "q", "u", "w", "3"); $tu_500_r = $record->get_subfield_array_array($cle, "r"); $tu_500_s = $record->get_subfield_array_array($cle, "s"); $tu_500_j = $record->get_subfield_array_array($cle, "j"); break; case "600": // 600 PERSONAL NAME USED AS SUBJECT $info_600_a = $record->get_subfield_array_array($cle, "a"); $info_600_j = $record->get_subfield_array_array($cle, "j"); $info_600_x = $record->get_subfield_array_array($cle, "x"); $info_600_y = $record->get_subfield_array_array($cle, "y"); $info_600_z = $record->get_subfield_array_array($cle, "z"); break; case "601": // 601 CORPORATE BODY NAME USED AS SUBJECT $info_601_a = $record->get_subfield_array_array($cle, "a"); $info_601_j = $record->get_subfield_array_array($cle, "j"); $info_601_x = $record->get_subfield_array_array($cle, "x"); $info_601_y = $record->get_subfield_array_array($cle, "y"); $info_601_z = $record->get_subfield_array_array($cle, "z"); break; case "602": // 602 FAMILY NAME USED AS SUBJECT $info_602_a = $record->get_subfield_array_array($cle, "a"); $info_602_j = $record->get_subfield_array_array($cle, "j"); $info_602_x = $record->get_subfield_array_array($cle, "x"); $info_602_y = $record->get_subfield_array_array($cle, "y"); $info_602_z = $record->get_subfield_array_array($cle, "z"); break; case "605": // 605 TITLE USED AS SUBJECT $info_605_a = $record->get_subfield_array_array($cle, "a"); $info_605_j = $record->get_subfield_array_array($cle, "j"); $info_605_x = $record->get_subfield_array_array($cle, "x"); $info_605_y = $record->get_subfield_array_array($cle, "y"); $info_605_z = $record->get_subfield_array_array($cle, "z"); break; case "606": // RAMEAU / TOPICAL NAME USED AS SUBJECT $info_606_a = $record->get_subfield_array_array($cle, "a"); $info_606_j = $record->get_subfield_array_array($cle, "j"); $info_606_x = $record->get_subfield_array_array($cle, "x"); $info_606_y = $record->get_subfield_array_array($cle, "y"); $info_606_z = $record->get_subfield_array_array($cle, "z"); break; case "607": // 607 GEOGRAPHICAL NAME USED AS SUBJECT $info_607_a = $record->get_subfield_array_array($cle, "a"); $info_607_j = $record->get_subfield_array_array($cle, "j"); $info_607_x = $record->get_subfield_array_array($cle, "x"); $info_607_y = $record->get_subfield_array_array($cle, "y"); $info_607_z = $record->get_subfield_array_array($cle, "z"); break; case "610": /* mots clé */ $index_sujets = $record->get_subfield_array($cle, "a"); break; case "676": /* Dewey */ $dewey = $record->get_subfield_array($cle, "a"); $dewey_l = $record->get_subfield_array($cle, "l"); $dewey_num = $record->get_subfield_array($cle, "l", "3"); break; case "686": /* pcdm3 */ $info_686 = $record->get_subfield($cle, "a", "l", "3"); break; case "700": $aut_700 = $record->get_subfield($cle, "a", "b", "c", "d", "4", "f", "N", "3"); break; case "701": $aut_701 = $record->get_subfield($cle, "a", "b", "c", "d", "4", "f", "N", "3"); break; case "702": $aut_702 = $record->get_subfield($cle, "a", "b", "c", "d", "4", "f", "N", "3"); break; case "710": $aut_710 = $record->get_subfield($cle, "a", "b", "c", "g", "d", "4", "f", "e", "k", "l", "m", "n", "3"); break; case "711": $aut_711 = $record->get_subfield($cle, "a", "b", "c", "g", "d", "4", "f", "e", "k", "l", "m", "n", "3"); break; case "712": $aut_712 = $record->get_subfield($cle, "a", "b", "c", "g", "d", "4", "f", "e", "k", "l", "m", "n", "3"); break; case "801": /* origine du catalogage */ $origine_notice = $record->get_subfield($cle, "a", "b"); break; case "852": /* infos du SCD de Lyon 3 */ $info_852 = $record->get_subfield($cle, "b", "h", "p", "y"); break; case "856": /* url */ $lien = $record->get_subfield($cle, "u"); $eformat = $record->get_subfield($cle, "q"); break; case "995": /* infos de la BDP */ $info_995 = $record->get_subfield($cle, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "M", "N", "O", "P", "R", "S", "T", "U", "V", "W", "Z"); break; case "996": /* infos supplémentaires... ? */ $info_996 = $record->get_subfield($cle, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "M", "N", "O", "P", "R", "S", "T", "U", "V", "W", "Z"); break; default: break; } /* end of switch */ } } /* end of for */ //Récupération des catégories en lien avec le fichier xml category_auto::get_info_categ($record); return true; }
function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array()) { global $charset; $enrichment = array(); $this->noticeToEnrich = $notice_id; // récupération du code sudoc (PPN) de la notice stocké dans le champ perso de type "resolve" avec pour label "SUDOC" $mes_pp = new parametres_perso("notices"); $mes_pp->get_values($notice_id); $values = $mes_pp->values; foreach ($values as $field_id => $vals) { if ($mes_pp->t_fields[$field_id]['TYPE'] == "resolve") { $field_options = _parser_text_no_function_("<?xml version='1.0' encoding='" . $charset . "'?>\n" . $mes_pp->t_fields[$field_id]['OPTIONS'], "OPTIONS"); foreach ($field_options['RESOLVE'] as $resolve) { if (strtoupper($resolve['LABEL']) == "SUDOC") { $infos = explode('|', $vals[0]); $ppn = $infos[0]; } } } } if ($ppn == "") { return $this->build_error(); } $url = "carmin.sudoc.abes.fr"; $port = "210"; $base = "abes-z39-public"; $format = "unimarc"; $term = "@attr 1=12 @attr 2=3 \"{$ppn}\" "; $id = yaz_connect("{$url}:{$port}/{$base}", array("piggyback" => false)); yaz_range($id, 1, 1); yaz_syntax($id, strtolower($format)); yaz_search($id, "rpn", $term); $options = array("timeout" => 45); //Override le timeout du serveur mysql, pour être sûr que le socket dure assez longtemps pour aller jusqu'aux ajouts des résultats dans la base. $sql = "set wait_timeout = 120"; mysql_query($sql); yaz_wait($options); $error = yaz_error($id); $error_info = yaz_addinfo($id); if (!empty($error)) { yaz_close($id); return $this->build_error(); } else { $hits = yaz_hits($id); $hits += 0; if ($hits) { $rec = yaz_record($id, 1, "raw"); $record = new iso2709_record($rec); if (!$record->valid()) { yaz_close($id); return $this->build_error(); } $lines = ""; $document->document_type = $record->inner_guide[dt]; $document->bibliographic_level = $record->inner_guide[bl]; $document->hierarchic_level = $record->inner_guide[hl]; if ($document->hierarchic_level == "") { if ($document->bibliographic_level == "s") { $document->hierarchic_level = "1"; } if ($document->bibliographic_level == "m") { $document->hierarchic_level = "0"; } } $indicateur = array(); $cle_list = array(); for ($i = 0; $i < count($record->inner_directory); $i++) { $cle = $record->inner_directory[$i]['label']; $indicateur[$cle][] = substr($record->inner_data[$i]['content'], 0, 2); $field_array = $record->get_subfield_array_array($cle); $line = ""; if (!$cle_list[$cle]) { foreach ($field_array as $field) { $line .= $cle . " "; foreach ($field as $ss_field) { $line .= "\$" . $ss_field["label"] . $ss_field["content"]; } $line .= "<br>"; } } $cle_list[$cle] = 1; $lines .= $line; } if ($lines == "") { yaz_close($id); return $this->build_error(); } } else { yaz_close($id); return $this->build_error(); } } yaz_close($id); $enrichment['sudoc']['content'] = $lines; $enrichment['source_label'] = $this->msg['sudoc_enrichment_source']; return $enrichment; }
function iso2709toXML_notice($contents, $format = "unimarc") { global $output_params, $charset; $n_notices = 0; $n_valid = 0; $n_invalid = 0; $this->n_traitees = 0; $this->n_valid = 0; $this->n_invalid = 0; $this->error_msg = array(); $this->warning_msg = array(); $this->notices_xml_ = array(); while ($contents != "") { $e_notice = strpos($contents, chr(0x1d)); $notice = substr($contents, 0, $e_notice + 1); $contents = substr($contents, $e_notice + 1); $n = new iso2709_record($notice, AUTO_UPDATE, $format); if ($n->is_utf8) { $this->is_utf8 = true; } else { if ($output_params['CHARSET'] == "utf-8") { $n->inner_guide['pos9'] = "a"; } } if ($n->valid()) { //Récupération des infos //Taille code sous-champ $sl = $n->inner_guide["sl"]; //Taille des inticateurs $il = $n->inner_guide["il"]; $data .= " <notice>\n"; //Etat de la notice $values = array("rs", "dt", "bl", "hl", "el", "ru"); for ($i = 0; $i < count($values); $i++) { $v = $n->inner_guide[$values[$i]]; if (ord($v) == 32) { $v = "*"; } $data .= " <" . $values[$i] . ">" . $v . "</" . $values[$i] . ">\n"; } for ($i = 0; $i < count($n->inner_data); $i++) { $data .= " <f c=\"" . $n->inner_data[$i]["label"] . "\""; $content = substr($n->inner_data[$i]["content"], 0, strlen($n->inner_data[$i]["content"]) - 1); $sub_fields = explode(chr(31), $content); if (count($sub_fields) == 1) { $data .= ">" . htmlspecialchars($this->is_utf8 ? $sub_fields[0] : $n->ISO_decode($sub_fields[0]), ENT_QUOTES, $charset) . "</f>\n"; } else { if (strlen($sub_fields[0]) > 2) { $sub_fields[0] = substr($sub_fields[0], strlen($sub_fields[0]) - 2); } $data .= " ind=\"" . $sub_fields[0] . "\">\n"; for ($j = 1; $j < count($sub_fields); $j++) { $data .= " <s c=\"" . substr($sub_fields[$j], 0, 1) . "\">" . htmlspecialchars($this->is_utf8 ? substr($sub_fields[$j], 1) : $n->ISO_decode(substr($sub_fields[$j], 1)), ENT_QUOTES, $charset) . "</s>\n"; } $data .= " </f>\n"; } } $data .= " </notice>\n"; $this->notices_xml_[] = $data; $n_valid++; } else { $this->error_msg[] = @implode(" / ", $n->errors); $n_invalid++; } $n_notices++; } $this->n_traitees = $n_notices; $this->n_valid = $n_valid; $this->n_invalid = $n_invalid; return $n_notices; }