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; $error = yaz_error($id[$ptr]); if (!empty($error)) { ## NO //trigger_error("Z39.50 error <br />", E_USER_ERROR); echo $lookLoc->getText("lookup_YAZerror") . $error . " ("; echo yaz_errno($id[$ptr]) . ') ' . yaz_addinfo($id[$ptr]); echo "<br />"; } else { ## YES, we got a response!! $hits[$ptr] = yaz_hits($id[$ptr]); $ttlHits += $hits[$ptr]; //echo "Host #$ptr {$postVars[hosts][$ptr][name]} result Count: $hits[$ptr] <br />"; } } //echo "Total Hits=$ttlHits <br />";
yaz_wait(); $error = yaz_error($id); if (!empty($error)) { echo "Error Number: " . yaz_errno($id); echo "Error Description: " . $error; echo "Additional Error Information: " . yaz_addinfo($id); } $outputString = "<?xml version=\"1.0\"?>\n"; $outputString .= "<datei>\n"; $outputArray = []; for ($p = 1; $p <= yaz_hits($id); $p++) { $record = yaz_record($id, $p, "render;charset=iso5426,utf8"); //render;charset=iso5426,utf8 $error = yaz_error($id); if (!empty($error)) { echo "Error Number: " . yaz_errno($id); echo "Error Description: " . $error; echo "Additional Error Information: " . yaz_addinfo($id); } $recordArray = explode("", $record); $header = substr($recordArray[0], 0, 24); $recordContent = '<datensatz id="" typ="' . substr($header, 23, 1) . '" status="' . substr($header, 5, 1) . '" mabVersion="' . substr($header, 6, 4) . '">' . "\n"; $recordContent .= printLine(substr($recordArray[0], 24)); for ($j = 1; $j < count($recordArray); $j++) { $recordContent .= printLine($recordArray[$j]); } $recordContent .= '</datensatz>' . "\n"; $outputString .= $recordContent; array_push($outputArray, $recordContent); } $outputString .= "</datei>";
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 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); } }
yaz_element($id, $element); } else { yaz_element($id, "F"); } yaz_syntax($id, $syntax); yaz_range($id, $start, $number); } yaz_wait(); $host_url = "term=" . urlencode($term) . "&field="; $host_url .= urlencode($field) . "&"; $host_url .= "element={$element}&syntax={$syntax}"; for ($i = 0; $i < $num_hosts; $i++) { $id = $ids[$i]; if ($id <= 0) { continue; } $error = yaz_error($id); $errno = yaz_errno($id); $addinfo = yaz_addinfo($id); echo '<tr>'; $attempt = $reintentar + 1; if ($errno) { echo '<td align="center">'; echo '<table cellspacing="0" cellpadding="2" width="97%" border="0"><tr><td>'; echo $msgstr["attempt"] . ": {$attempt} "; // echo "$host[$i] "; echo "Error: {$error} (code {$errno}) {$addinfo}"; echo "</td></tr></table>\n"; echo "</td></tr>"; } else { echo '<td align="center">';
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; }