Ejemplo n.º 1
0
                //if ($total % 10 == 0) {
                //   affiche_jsscript ($msg["z3950_reception_notice"]." $total / $lim_recherche", "#99FF99", $bib_id);
                //}
                $notice = new z3950_notice($formato[$bib_id], $rec);
                $isbd_affichage = $notice->get_isbd_display();
                $lu_isbn = $isbd_affichage[0];
                $lu_titre = $isbd_affichage[1];
                $lu_auteur = $isbd_affichage[2];
                $lu_isbd = $isbd_affichage[3];
                $sql2 = "insert into z_notices (znotices_id, znotices_query_id, znotices_bib_id, isbn, titre, auteur, isbd, z_marc) ";
                $sql2 .= "values(0,'{$last_query_id}', '{$bib_id}', '{$lu_isbn}', '" . addslashes($lu_titre) . "', '" . addslashes($lu_auteur) . "', '" . addslashes($lu_isbd) . "','" . addslashes($rec) . "') ";
                pmb_mysql_query($sql2);
                $ID_notice = pmb_mysql_insert_id();
            }
            // fin du if qui vérifie que la notice n'est pas vide
        }
        // fin for
        yaz_close($id);
        $msg1 = str_replace("!!total!!", $total, $msg[z3950_recup_fini]);
        $msg1 = str_replace("!!hits!!", $hits, $msg1);
        affiche_jsscript($msg1, "z3950_succeed", $bib_id);
    }
    // fin if else error
}
$dt = time() - $t1;
$msg1 = str_replace('!!time!!', $dt, $msg['z3950_zmsg_show']);
affiche_jsscript($msg1, "", $mioframe);
//showButRes();
?>
</body>
</html>
 function fetchYazInfos($book)
 {
     global $booklibrary_configuration;
     if (!extension_loaded('yaz')) {
         echo "<script> alert('Sorry, \\'yaz.so\\' isn\\'t loaded....'); window.history.go(-1);</script>\n";
         exit;
     }
     $param_ws = mosBooklibraryWS::getWsParamById($book->informationFrom) - 1;
     $hosts = mosBooklibraryWS::getWSArray();
     $str_conect = trim($hosts[$param_ws][3]) . ":" . trim($hosts[$param_ws][4]) . "/" . trim($hosts[$param_ws][5]);
     //$str_conect ="z3950.bibsys.no:2100";// "140.147.249.38:7090/voyager";
     //$str_conect = "troy.lib.sfu.ca:210/innopac";
     //echo $str_conect;
     $id = yaz_connect($str_conect);
     yaz_syntax($id, $hosts[$param_ws][6]);
     $query = '@attr 1=7  ' . $book->isbn;
     yaz_search($id, 'rpn', $query);
     yaz_wait();
     $error = yaz_error($id);
     if (!empty($error)) {
         echo "<script> alert('ERROR:" . addslashes($error) . "'); window.history.go(-1);</script>\n";
         exit;
     }
     $rec = yaz_record($id, 1, "array");
     $error = yaz_error($id);
     if (yaz_hits($id) == 0) {
         echo "<script> alert('On this ISBN(" . addslashes($book->isbn) . ") of the not found records'); window.history.go(-1);</script>\n";
         yaz_close($id);
         exit;
     } elseif (!empty($error)) {
         echo "<script> alert('ERROR:" . addslashes($error) . "'); window.history.go(-1);</script>\n";
         yaz_close($id);
         exit;
     }
     yaz_close($id);
     $book->comment = "";
     $book->title = "";
     $book->authors = "";
     $book->manufacturer = "";
     $book->release_Date = "";
     $book->URL = "";
     foreach ($rec as $i => $value) {
         $s = explode(")(", $rec[$i][0]);
         if (isset($s[2])) {
             switch (substr($s[0], 3, strlen($s[0]))) {
                 case '245':
                     $book->comment .= $rec[$i][1];
                     if (substr($s[2], 2, strlen($s[2]) - 3) == 'a') {
                         $book->title .= $rec[$i][1];
                     }
                     break;
                 case '100':
                     $book->authors .= $rec[$i][1];
                     break;
                 case '260':
                     $book->manufacturer .= $rec[$i][1];
                     if (substr($s[2], 2, strlen($s[2]) - 3) == 'c') {
                         $book->release_Date .= $rec[$i][1];
                     }
                     break;
                 case '856':
                     $book->URL .= $rec[$i][1];
                     break;
             }
         }
     }
     return $book;
 }
Ejemplo n.º 3
0
        //echo json_encode($postVars);
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'getCutter':
        echo "{'cutter':'" . getCutter($_REQUEST[author]) . "'}";
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'getOpts':
        echo json_encode($postVars);
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'search':
        include 'lookupSrchPrep.php';
        ## will respond directly, depending on what is received
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    case 'abandon':
        for ($n = 0; $n < $postVars[numHosts]; $n++) {
            yaz_close($id[$n]);
        }
        break;
        #-.-.-.-.-.-.-.-.-.-.-.-.-
    #-.-.-.-.-.-.-.-.-.-.-.-.-
    default:
        echo "invalid mode: {$_POST['mode']} <br />";
        break;
}
Ejemplo n.º 4
0
 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 do_search_and_show_hits()
{
    output_header("Search Results");
    echo "<br>";
    if (empty($_GET['start'])) {
        $start = 1;
    } else {
        $start = $_GET['start'];
    }
    if (!empty($_GET['fq'])) {
        $fullquery = unserialize(base64_decode($_GET['fq']));
    } else {
        $fullquery = query_format();
    }
    global $external_catalog_locator;
    $id = yaz_connect($external_catalog_locator);
    yaz_syntax($id, "usmarc");
    yaz_element($id, "F");
    yaz_search($id, "rpn", trim($fullquery));
    $extra_options = array("timeout" => 60);
    yaz_wait($extra_options);
    $errorMsg = yaz_error($id);
    if (!empty($errorMsg)) {
        echo "<center>";
        echo _("The following error has occurred:");
        echo "<br><br>";
        echo "<b><i>{$errorMsg}</i></b>";
        echo "<p>";
        $url = "editproject.php?action=createnew";
        echo sprintf(_("Please try again. If the problem recurs, please create your project manually by following this <a href='%s'>link</a>."), $url);
        echo "</center>";
        exit;
    }
    echo "<center>";
    if (yaz_hits($id) == 0) {
        echo "<b>";
        echo _("There were no results returned.");
        echo "</b>";
        echo "<br>";
        echo _("Please search again or click 'No Matches' to create the project manually.");
        echo "<br>";
    } else {
        echo "<b>";
        echo sprintf(_("%d results returned. Note that some non-book results may not be displayed."), yaz_hits($id));
        echo "<br>";
        echo _("Please pick a result from below:");
        echo "</b>";
    }
    echo "</center>";
    echo "<br><form method='post' action='editproject.php'>";
    echo "<input type='hidden' name='action' value='create_from_marc_record'>";
    echo "<table border='0 width='100%' cellpadding='0' cellspacing='0'>";
    // -----------------------------------------------------
    $hits_per_page = 20;
    // Perhaps later this can be a PM preference or an option on the form.
    $i = 1;
    while ($start <= yaz_hits($id) && $i <= $hits_per_page) {
        $rec = yaz_record($id, $start, "array");
        //if it's not a book don't display it.  we might want to uncomment in the future if there are too many records being returned - if (substr(yaz_record($id, $start, "raw"), 6, 1) != "a") { $start++; continue; }
        $marc_record = new MARCRecord();
        $marc_record->load_yaz_array($rec);
        if ($i % 2 == 1) {
            echo "<tr>";
        }
        echo "<td width='5%' align='center' valign='top'>";
        echo "<input type='radio' name='rec' value='" . base64_encode(serialize($rec)) . "'>";
        echo "</td>";
        echo "<td width='45%' align='left' valign='top'>";
        echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
        foreach (array(array('label' => _("Title"), 'value' => $marc_record->title), array('label' => _("Author"), 'value' => $marc_record->author), array('label' => _("Publisher"), 'value' => $marc_record->publisher), array('label' => _("Language"), 'value' => $marc_record->language), array('label' => _("LCCN"), 'value' => $marc_record->lccn), array('label' => _("ISBN"), 'value' => $marc_record->isbn)) as $couple) {
            $label = $couple['label'];
            $value = $couple['value'];
            echo "<tr>";
            echo "<td width='20%' align='left' valign='top'><b>{$label}</b>:</td>";
            echo "<td align='left' valign='top'>{$value}</td>";
            echo "</tr>\n";
        }
        echo "</table><p></td>";
        if ($i % 2 != 1) {
            echo "</tr>\n";
        }
        $i++;
        $start++;
    }
    if ($i % 2 != 1) {
        echo "</tr>\n";
    }
    // -----------------------------------------------------
    $encoded_fullquery = base64_encode(serialize($fullquery));
    echo "<tr>";
    echo "<td colspan='2' width='50%' align='left' valign='top'>";
    if (isset($_GET['start']) && $_GET['start'] - $hits_per_page > 0) {
        $url = "external_catalog_search.php?action=do_search_and_show_hits&start=" . ($_GET['start'] - $hits_per_page) . "&fq={$encoded_fullquery}";
        echo "<a href='{$url}'>Previous</a>";
    } else {
        echo "&nbsp;";
    }
    echo "</td>";
    echo "<td colspan='2' width='50%' align='right' valign='top'>";
    if ($start + $hits_per_page <= yaz_hits($id)) {
        $url = "external_catalog_search.php?action=do_search_and_show_hits&start={$start}&fq={$encoded_fullquery}";
        echo "<a href='{$url}'>Next</a>";
    } else {
        echo "&nbsp;";
    }
    echo "</td>";
    echo "</tr>\n";
    // -----------------------------------------------------
    echo "</table><br><center>";
    if (yaz_hits($id) != 0) {
        echo "<input type='submit' value='", attr_safe(_("Create the Project")), "'>&nbsp;";
    }
    $label = attr_safe(_('Search Again'));
    $url = "external_catalog_search.php?action=show_query_form";
    echo "<input type='button' value='{$label}' onclick='javascript:location.href=\"{$url}\";'>";
    echo "&nbsp;";
    $label = attr_safe(_('No Matches'));
    $url = "editproject.php?action=createnew";
    echo "<input type='button' value='{$label}' onclick='javascript:location.href=\"{$url}\";'>";
    echo "&nbsp;";
    $label = attr_safe(_('Quit'));
    $url = "projectmgr.php";
    echo "<input type='button' value='{$label}' onclick='javascript:location.href=\"{$url}\";'>";
    echo "</form>";
    echo "</center>";
    yaz_close($id);
}
 function getSearchResult($num_hit)
 {
     if (!isset($this->search_result[$num_hit]) && $num_hit <= $this->z_hits) {
         $this->z_start_range = (int) floor($num_hit / 5) * 5 + 1;
         $this->doSearch();
     }
     $catalog_id = $this->search_result[$num_hit]['catalog_id'][0] != "_" ? $this->search_result[$num_hit]['catalog_id'] : false;
     $cat_element = new StudipLitCatElement($catalog_id);
     if ($cat_element->isNewEntry()) {
         $cat_element->setValues($this->search_result[$num_hit]);
         $cat_element->setValue("catalog_id", $this->sess_var_name . "__" . $num_hit);
     }
     if ($this->z_id != NULL) {
         yaz_close($this->z_id);
         $this->z_id = NULL;
     }
     return $cat_element;
 }