affiche_jsscript($msg['z3950_echec_no_valid_attr'], "z3950_failed", $bib_id);
        }
    } else {
        //////////////////////////////////////////////////////////////////////////////////
        // the query is ok we prepare the Z 3950 process for this biblio and
        // save the $id to be able later to retrieve the records from the servers
        //////////////////////////////////////////////////////////////////////////////////
        //$stato[$bib_id] = 1;
        $auth = $auth_user . $auth_pass;
        if ($auth != "") {
            $id = yaz_connect("{$url}:{$port}/{$base}", array("user" => $auth_user, "password" => $auth_pass, "piggyback" => false)) or affiche_jsscript($msg['z3950_echec_cnx'], "z3950_failed", $bib_id);
        } else {
            $id = yaz_connect("{$url}:{$port}/{$base}", array("piggyback" => false)) or affiche_jsscript($msg['z3950_echec_cnx'], "z3950_failed", $bib_id);
        }
        $map[$bib_id] = $id;
        yaz_element($id, "F");
        $etrange_limite = $limite_notices;
        yaz_range($id, 1, $etrange_limite);
        yaz_syntax($id, strtolower($format));
        echo $term;
        yaz_search($id, "rpn", $term);
    }
}
///////////////////////////////////////////////////////////////////////////
// Fase 2: all the possible connections are ready now start the researches
//////////////////////////////////////////////////////////////////////////
//Correction mystérieuse : visiblement la fonction yaz_search impacte la variable global $limite... modifié en $limite_notices
affiche_jsscript($msg['z3950_zmsg_wait'], "", $mioframe);
$options = array("timeout" => 45);
$t1 = time();
//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.
 function search($source_id, $query, $search_id)
 {
     global $base_path, $charset, $include_path;
     //global $url,$z3950_base,$z3950_login,$z3950_password,$z3950_max_notices,$z3950_format,$z3950_port,$z3950_convert,$z3950_profil;
     $this->error = false;
     $this->error_message = "";
     $params = $this->get_source_params($source_id);
     $this->fetch_global_properties();
     if ($params["PARAMETERS"]) {
         //Affichage du formulaire avec $params["PARAMETERS"]
         $vars = unserialize($params["PARAMETERS"]);
         foreach ($vars as $key => $val) {
             global ${$key};
             ${$key} = $val;
         }
     }
     if (!($z3950_max_notices * 1)) {
         $z3950_max_notices = 100;
     }
     //Tranformation de la recherche en requete rpn bib1
     $rpn = $this->parse_query($query);
     $zurl = $url . ($z3950_port ? ":" . $z3950_port : "") . ($z3950_base ? "/" . $z3950_base : "");
     $opts = array();
     if ($z3950_login) {
         $opts["user"] = $z3950_login;
     }
     if ($z3950_password) {
         $opts["password"] = $z3950_password;
     }
     $opts["piggyback"] = false;
     $yaz_id = yaz_connect($zurl, $opts);
     yaz_element($yaz_id, "F");
     yaz_range($yaz_id, 1, $z3950_max_notices);
     yaz_syntax($yaz_id, strtolower($z3950_format));
     yaz_search($yaz_id, "rpn", $rpn . " ");
     $opts_wait = array("timeout" => $params["TIMEOUT"]);
     yaz_wait($opts_wait);
     if (yaz_error($yaz_id)) {
         $this->error = true;
         $this->error_message = yaz_error($yaz_id);
     } else {
         $n_results = yaz_hits($yaz_id);
         if ($n_results > $z3950_max_notices) {
             $n_results = $z3950_max_notices;
         }
         $convert_order = $this->get_convert_order($z3950_convert);
         for ($k = 1; $k <= $n_results; $k++) {
             $notice = yaz_record($yaz_id, $k, "raw");
             //Conversion de la notice
             if ($z3950_convert) {
                 $export = new convert($notice, $convert_order);
                 if (!$export->error) {
                     $cnotice = $export->output_notice;
                 } else {
                     $cnotice = "";
                 }
             } else {
                 $cnotice = $notice;
             }
             if ($cnotice) {
                 //Conversion de la notice en XML
                 $xmlunimarc = new xml_unimarc();
                 $nxml = $xmlunimarc->iso2709toXML_notice($cnotice);
                 if ($xmlunimarc->is_utf8) {
                     $rcharset = "utf-8";
                 } else {
                     $rcharset = $charset;
                 }
                 $xmlunimarc->notices_xml_[0] = '<?xml version="1.0" encoding="' . $rcharset . '"?>' . $xmlunimarc->notices_xml_[0];
                 if ($xslt_exemplaire) {
                     $xmlunimarc->notices_xml_[0] = $this->apply_xsl_to_xml($xmlunimarc->notices_xml_[0], $xslt_exemplaire["content"]);
                 }
                 //					print_r($xmlunimarc->notices_xml_[0]);
                 if ($nxml >= 1) {
                     $params = _parser_text_no_function_($xmlunimarc->notices_xml_[0], "NOTICE");
                     $this->rec_record($params, $source_id, $search_id);
                 }
             }
         }
     }
 }
Exemple #3
0
 * bl?ppn=PPN
 *   PPN ist die eine ID-Nummer des BL
 * bl?isbn=ISBN&format=json
 * bl?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im BL-Katalog
 * und gibt maximal 10 Ergebnisse als MARCXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(BL_URL, array("user" => BL_USER, "password" => BL_PASSWORD));
yaz_syntax($id, BL_SYNTAX);
//utf-8 Kodierung
yaz_range($id, 1, 10);
yaz_element($id, BL_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=12 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
    }
Exemple #4
0
 *   ISBN kann ebenfalls eine Komma-separierte Liste von ISBNs sein
 * hbz?ppn=PPN
 *   PPN ist die eine ID-Nummer des HBZ
 * hbz?isbn=ISBN&format=json
 * hbz?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im HBZ-Katalog
 * und gibt maximal 10 Ergebnisse als MABXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(HBZ_URL);
yaz_syntax($id, HBZ_SYNTAX);
yaz_range($id, 1, 10);
yaz_element($id, HBZ_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=12 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
    }
Exemple #5
0
 *   ISBN kann ebenfalls eine Komma-separierte Liste von ISBNs sein
 * gbv?ppn=PPN
 *   PPN ist die eine ID-Nummer des GBV
 * gbv?isbn=ISBN&format=json
 * gbv?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im GBV-Katalog
 * und gibt maximal 10 Ergebnisse als MARCXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(GBV_URL);
yaz_syntax($id, GBV_SYNTAX);
yaz_range($id, 1, 10);
yaz_element($id, GBV_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=12 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
    }
Exemple #6
0
 *   ISBN kann ebenfalls eine Komma-separierte Liste von ISBNs sein
 * nebis?ppn=PPN
 *   PPN ist die eine ID-Nummer des NEBIS
 * nebis?isbn=ISBN&format=json
 * nebis?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im NEBIS-Katalog
 * und gibt maximal 10 Ergebnisse als MARCXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(NEBIS_URL);
yaz_syntax($id, NEBIS_SYNTAX);
yaz_range($id, 1, 10);
yaz_element($id, NEBIS_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=12 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
    }
Exemple #7
0
 * b3kat?ppn=PPN
 *   PPN ist die eine ID-Nummer des B3KAT
 * b3kat?isbn=ISBN&format=json
 * b3kat?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im B3KAT-Katalog
 * und gibt maximal 10 Ergebnisse als MABXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(B3KAT_URL, array("user" => B3KAT_USER, "password" => B3KAT_PASSWORD));
//"mab2; charset=iso5426,utf8"
yaz_syntax($id, B3KAT_SYNTAX);
yaz_range($id, 1, 10);
yaz_element($id, B3KAT_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    //aus der Doku: 53 Number local call (BV-Nr.)
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=53 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
Exemple #8
0
function antall_treff($q)
{
    global $config;
    $bib = $_GET['bib'];
    $debug = 0;
    if ($config['libraries'][$bib]['sru']) {
        // SRU
        $qu = urlencode($q);
        $query = '(dc.author=' . $qu . '+or+dc.title=' . $qu . ')+and+dc.title=lydopptak';
        $sruurl = $config['libraries'][$bib]['sru'] . '?version=1.1&operation=searchRetrieve&query=' . $query;
        if ($xml = file_get_contents($sruurl)) {
            preg_match("/numberOfRecords>(.*?)</", $xml, $matches);
            return $matches[1];
        } else {
            echo 'error';
        }
    } else {
        //Z39.50
        $ccl = "(fo={$q} or in={$q} or ti={$q}) and ti=lydopptak";
        $host = $config['libraries'][$bib]['z3950'];
        $zconfig = get_zconfig();
        $type = 'xml';
        $syntax = 'NORMARC';
        $id = yaz_connect($host);
        yaz_element($id, "F");
        yaz_syntax($id, $syntax);
        yaz_range($id, 1, 1);
        yaz_ccl_conf($id, $zconfig);
        $cclresult = array();
        if (!yaz_ccl_parse($id, $ccl, $cclresult)) {
            echo $debug ? 'Error: ' . $cclresult["errorstring"] : 'error';
        } else {
            $rpn = $cclresult["rpn"];
            yaz_search($id, "rpn", utf8_decode($rpn));
        }
        yaz_wait();
        $error = yaz_error($id);
        if (!empty($error)) {
            echo $debug ? "Error yazCclArray: {$error}" : 'error';
        } else {
            return yaz_hits($id);
        }
    }
}
Exemple #9
0
 * swb?ppn=PPN
 *   PPN ist die eine ID-Nummer des SWB
 * swb?isbn=ISBN&format=json
 * swb?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im SWB-Katalog
 * und gibt maximal 10 Ergebnisse als MARCXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(SWB_URL);
yaz_syntax($id, SWB_SYNTAX);
//utf-8 Kodierung
yaz_range($id, 1, 10);
yaz_element($id, SWB_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=12 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
    }
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 doZSearch($zid, $rpn, $start, $number)
 {
     yaz_range($zid, (int) $start, (int) $number);
     yaz_syntax($zid, $this->z_syntax);
     if ($this->z_sort) {
         yaz_sort($zid, $this->z_sort);
     }
     yaz_element($zid, 'F');
     yaz_search($zid, "rpn", $rpn);
     yaz_wait($options = array('timeout' => $this->z_timeout));
     if (yaz_errno($zid)) {
         $error_msg = yaz_error($zid);
         if ($error_info = yaz_addinfo($zid)) {
             $error_msg .= ' - ' . $error_info;
         }
         $this->addError("error", sprintf(_("Fehler bei der Suche: %s"), $error_msg));
         return false;
     } else {
         return yaz_hits($zid);
     }
 }
Exemple #12
0
function yazCclArray($ccl, $syntax = 'marc21', $host = 'default')
{
    global $config;
    if ($host == 'default') {
        $host = $config['libraries'][$_GET['bib']]['z3950'];
    }
    $zconfig = get_zconfig();
    $hits = 0;
    $type = 'xml';
    $id = yaz_connect($host);
    yaz_element($id, "F");
    yaz_syntax($id, $syntax);
    yaz_range($id, 1, 1);
    yaz_ccl_conf($id, $zconfig);
    $cclresult = array();
    if (!yaz_ccl_parse($id, $ccl, $cclresult)) {
        echo 'Error: ' . $cclresult["errorstring"];
    } else {
        // NB! Ser ikke ut som Z39.50 fra Bibliofil støtter "sort"
        // Se nederst her: http://www.bibsyst.no/produkter/bibliofil/z3950.php
        // PHP/YAZ-funksjonen yaz-sort ville kunne dratt nytte av dette:
        // http://no.php.net/manual/en/function.yaz-sort.php
        // Sort Flags
        // a Sort ascending
        // d Sort descending
        // i Case insensitive sorting
        // s Case sensitive sorting
        // Bib1-attributter man kunne sortert på:
        // http://www.bibsyst.no/produkter/bibliofil/z/carl.xml
        // yaz_sort($id, "1=31 di");
        $rpn = $cclresult["rpn"];
        yaz_search($id, "rpn", utf8_decode($rpn));
    }
    yaz_wait();
    $error = yaz_error($id);
    if (!empty($error)) {
        echo "Error yazCclArray: {$error}";
    } else {
        $hits = yaz_hits($id);
    }
    $data = array();
    for ($p = 1; $p <= $hits; $p++) {
        $rec = yaz_record($id, $p, $type);
        if (empty($rec)) {
            continue;
        }
        $data[] = $rec;
        if ($p == $config['maks_poster']) {
            break;
        }
    }
    $ret = array("hits" => $hits, "result" => $data);
    return $ret;
}
Exemple #13
0
function yazCclArray($ccl)
{
    global $config;
    $system = $config['lib']['system'];
    // Create an array to hold settings for the different systems
    $zopts = array();
    $zopts['aleph'] = array('syntax' => '', 'yaz_con_opts' => array('piggyback' => true));
    $zopts['bibliofil'] = array('syntax' => 'normarc', 'yaz_con_opts' => array('piggyback' => true));
    $zopts['bibsys'] = array('syntax' => '', 'yaz_con_opts' => array('piggyback' => false));
    $zopts['koha'] = array('syntax' => '', 'yaz_con_opts' => array('piggyback' => true));
    $zopts['mikromarc'] = array('syntax' => 'normarc', 'yaz_con_opts' => array('piggyback' => true));
    /*
    The Glitre project has not been able to find sample servers fot these
    systems, even after asking the vendors if any exist:
    
    $zopts['reindex'] = array(
      'syntax' => '', 
      'yaz_con_opts' => array(
    	'piggyback' => false,
      ),
    );
    $zopts['tidemann'] = array(
      'syntax' => '', 
      'yaz_con_opts' => array(
    	'piggyback' => false,
      ),	
    );
    */
    $hits = 0;
    $type = 'xml';
    $id = yaz_connect($config['lib']['z3950'], $zopts[$system]['yaz_con_opts']);
    yaz_element($id, "F");
    yaz_syntax($id, $zopts[$system]['syntax']);
    yaz_range($id, 1, 1);
    yaz_ccl_conf($id, get_zconfig());
    $cclresult = array();
    if (!yaz_ccl_parse($id, $ccl, $cclresult)) {
        echo 'Error yaz_ccl_parse: ' . $cclresult["errorstring"];
    } else {
        // Norwegian Z39.50 have no or limited support for yaz_sort
        // See http://wiki.biblab.no/index.php/Z39.50%2C_SRU_og_sortering for details
        // yaz_sort($id, "1=31 di");
        $rpn = $cclresult["rpn"];
        yaz_search($id, "rpn", utf8_decode($rpn));
    }
    yaz_wait();
    $error = yaz_error($id);
    if (!empty($error)) {
        $yaz_errno = yaz_errno($id);
        // echo "<p>Error yaz_wait: $error ($yaz_errno)</p>";
        $error = array('error' => true, 'stage' => 'yaz_wait', 'desc' => $error, 'num' => $yaz_errno);
        return $error;
    } else {
        $hits = yaz_hits($id);
    }
    $data = array();
    for ($p = 1; $p <= $hits; $p++) {
        $rec = yaz_record($id, $p, $type);
        if (empty($rec)) {
            continue;
        }
        $data[] = $rec;
        // If a max number of records is set for this library, respect it - otherwise use the default.
        $records_max = $config['lib']['records_max'] ? $config['lib']['records_max'] : $config['records_max'];
        if ($p == $records_max) {
            break;
        }
    }
    $ret = array("hits" => $hits, "result" => $data);
    return $ret;
}
    //showMeComplex("using host #$ptr",$postVars[hosts]);
    $aHost = $postVars[hosts][$ptr][host];
    $aUser = $postVars[hosts][$ptr][user];
    $aPw = $postVars[hosts][$ptr][pw];
    $connOK = yaz_connect($aHost, array("user" => $aUser, "password" => $aPw));
    if (!$connOK) {
        echo 'yaz setup not successful! <br />';
        trigger_error($lookLoc->getText("lookup_yaz_setup_failed") . $postVars[hosts][$ptr][name] . "<br />", E_USER_ERROR);
    } else {
        //echo 'yaz setup successful! <br />';
        $id[$ptr] = $connOK;
        $db = $postVars[hosts][$ptr][db];
        //echo "specifying db: $db<br />";
        yaz_database($id[$ptr], $db);
        yaz_syntax($id[$ptr], $syntax);
        yaz_element($id[$ptr], "F");
        //echo "sending: $qry <br />";
        if (!yaz_search($id[$ptr], $srchType, $qry)) {
            trigger_error($lookLoc->getText("lookup_badQuery") . "<br />", E_USER_NOTICE);
        }
    }
}
$waitOpts = array("timeout" => $postVars[timeout]);
//echo "<br /> waiting $waitOpts[timeout] seconds for responses. <br />";
//yaz_wait($waitOpts);
yaz_wait();
$ttlHits = 0;
for ($i = 0; $i < $numHosts; $i++) {
    ## did we make it?
    //			$ptr = ($useHost == -1)?$i:$useHost;
    $ptr = $i;
 function _getLookupResult($server, $isbn)
 {
     // Now support YAZ only.
     $query = '@attr 1=7 ' . $isbn;
     $conn = yaz_connect($server['host'], array('user' => $server['user'], 'password' => $server['pw']));
     if (!$conn) {
         return array('error' => 'could not connect lookup');
     }
     yaz_database($conn, $server['db']);
     yaz_syntax($conn, "usmarc");
     yaz_element($conn, "F");
     //echo "sending: $qry <br />";
     if (!yaz_search($conn, 'rpn', $query)) {
         return array('error' => 'bad query');
     }
     $param = array('timeout' => 5);
     yaz_wait($param);
     $error = yaz_error($conn);
     if (!empty($error)) {
         return array('error' => 'lookup response error (' . yaz_errno($conn) . ') : ' . yaz_addinfo($conn));
     }
     if (yaz_hits($conn) < 1) {
         return array('error' => 'no result');
     }
     // For bulk actions, auto select first record
     require_once "../lookup2/lookupYazFunc.php";
     $data = extract_marc_fields(yaz_record($conn, 1, 'array'), true, 1, 1, $server['charset']);
     if (empty($data['callNmbr1']) && empty($data['050a']) || empty($data['100a'])) {
         // Require callNmbr1, continue search
         return array('error' => 'no result');
     }
     return $data;
 }
 function _getLookupResult($server, $isbn)
 {
     // Now support YAZ only
     $query = '@attr 1=7 ' . $isbn;
     $conn = yaz_connect($server['host'], array('user' => $server['user'], 'password' => $server['pw']));
     if (!$conn) {
         return false;
     }
     yaz_database($conn, $server['db']);
     yaz_syntax($conn, "usmarc");
     yaz_element($conn, "F");
     if (!yaz_search($conn, 'rpn', $query)) {
         return false;
     }
     yaz_wait();
     $error = yaz_error($conn);
     if (!empty($error)) {
         return false;
     }
     if (yaz_hits($conn) < 1) {
         return false;
     }
     // For bulk actions, auto select first record
     require_once "../lookup2/lookupYazFunc.php";
     $data = extract_marc_fields(yaz_record($conn, 1, 'array'), true, 1, 1);
     return $data['856u'];
 }
Exemple #17
0
 * obvsg.php?ppn=PPN
 *   PPN ist die eine ID-Nummer des B3KAT
 * obvsg.php?isbn=ISBN&format=json
 * obvsg.php?ppn=PPN&format=json
 *   Ausgabe erfolgt als JSON
 *
 * Sucht übergebene ISBN bzw. PPN im OBVSG-Katalog
 * und gibt maximal 10 Ergebnisse als MABXML zurück
 * bzw. als JSON.
 */
include 'lib.php';
$id = yaz_connect(OBVSG_URL, array("user" => OBVSG_USER, "password" => OBVSG_PASSWORD));
//"mab2; charset=iso5426,utf8"
yaz_syntax($id, OBVSG_SYNTAX);
yaz_range($id, 1, 10);
yaz_element($id, OBVSG_ELEMENTSET);
if (isset($_GET['ppn'])) {
    $ppn = trim($_GET['ppn']);
    yaz_search($id, "rpn", '@attr 5=100 @attr 1=1016 "' . $ppn . '"');
}
if (isset($_GET['isbn'])) {
    $n = trim($_GET['isbn']);
    $nArray = explode(",", $n);
    if (count($nArray) > 1) {
        //mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
        //Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
        $suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \\"' . implode('\\" @attr 1=7 \\"', $nArray) . '\\"';
        yaz_search($id, "rpn", $suchString);
    } else {
        yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
    }