X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=www%2Fz39util.tcl;h=9efda0b3fc2c7011e13cf6958e2bb39c291bd288;hb=02d3e042a063e539acce998f74b00a09df000cd0;hp=bfa560845c37b69475f5c6238558e0bec46a798c;hpb=e406f6fe976eeae769f193a9d48938d903c02543;p=egate.git diff --git a/www/z39util.tcl b/www/z39util.tcl index bfa5608..9efda0b 100644 --- a/www/z39util.tcl +++ b/www/z39util.tcl @@ -1,5 +1,5 @@ # -# $Id: z39util.tcl,v 1.37 1996/03/08 16:47:08 adam Exp $ +# $Id: z39util.tcl,v 1.38 1996/03/11 17:40:49 adam Exp $ # proc saveState {} { uplevel #0 { @@ -65,7 +65,7 @@ proc fail-response {} { set sessionWait -1 } -proc display-brief {zset no setNo targetNo} { +proc display-medium {zset no setNo targetNo} { global env global sessionId @@ -84,21 +84,131 @@ proc display-brief {zset no setNo targetNo} { return } set rtype [$zset recordType $no] - if {$rtype == "SUTRS"} { + switch $rtype { + SUTRS { + html { } + html [join [$zset getSutrs $no]] + html "
\n" + return + } + WAIS { + html { } + html [join [$zset getWAIS $no headline]] + html {} + html "
\n" + html {Score: } [$zset getWAIS $no score] + set lines [$zset getWAIS $no lines] + if {$lines > 0} { + html {, } $lines { lines} + } + html "
\n" + return + } + } + if {![catch { + set author [$zset getMarc $no field 100 * a] + set corp [$zset getMarc $no field 110 * a] + set meet [$zset getMarc $no field 111 * a] + set title [$zset getMarc $no field 245 * a] + if {[llength $author] == 0} { + set cover [$zset getMarc $no field 245 * {[bc]}] + } else { + set cover [$zset getMarc $no field 245 * b] + } + set location [$zset getMarc $no field 260 * a] + set publisher [$zset getMarc $no field 260 * b] + set year [$zset getMarc $no field 260 * c] + } dispError ] } { html { } - html [join [$zset getSutrs $no]] - html "
\n" - return - } - if {$rtype == "WAIS"} { + set p 0 + foreach a $author { + if {$p} { + html ", " + } + html $a + set p 1 + } + foreach a $corp { + if {$p} { + html ", " + } + html $a + set p 1 + } + foreach a $meet { + if {$p} { + html ", " + } + html $a + set p 1 + } + if {$p} { + html ": " + } + set nope 1 + foreach v $title { + html $v + set nope 0 + } + set v [join $cover ""] + if {[string length $v] > 0} { + set nope 0 + html $v + } elseif {$nope} { + html "No Title" + } + html { } + } else { html { } - html [join [$zset getWAIS $no headline]] - html {} - html "
\n" + html {No Title} + html { } + html "Error: " $dispError "\n" + } + html "
\n" +} + +proc display-brief {zset no setNo targetNo} { + global env + global sessionId + + set type [$zset type $no] + if {$type == "SD"} { + set err [lindex [$zset diag $no] 1] + set add [lindex [$zset diag $no] 2] + if {$add != {}} { + set add " :${add}" + } + html "${no} Error ${err}${add}
\n" + return + } + if {$type != "DB"} { return } + set rtype [$zset recordType $no] + switch $rtype { + SUTRS { + html { } + html [string range [join [$zset getSutrs $no]] 0 70] + html "
\n" + return + } + WAIS { + html { } + html [string range [join [$zset getWAIS $no headline]] 0 70] + + html {} + set score [$zset getWAIS $no score] + html { Score } $score + html "
\n" + return + } + } if {![catch { set author [$zset getMarc $no field 100 * a] set corp [$zset getMarc $no field 110 * a] @@ -140,11 +250,13 @@ proc display-brief {zset no setNo targetNo} { if {$p} { html ": " } + html {} set nope 1 foreach v $title { html $v set nope 0 } + html {} if {$nope} { set v [join $cover ""] if {[string length $v] > 40} { @@ -168,26 +280,36 @@ proc display-brief {zset no setNo targetNo} { html "
\n" } -proc display-raw {zset no tno} { +proc display-raw {zset no setNo targetNo} { set type [$zset type $no] - if {$type == "SD"} { - set err [lindex [$zset diag $no] 1] - set add [lindex [$zset diag $no] 2] - if {$add != {}} { - set add " :${add}" + switch $type { + SD { + set err [lindex [$zset diag $no] 1] + set add [lindex [$zset diag $no] 2] + if {$add != {}} { + set add " :${add}" + } + html "

${no}

\n" + html "Error ${err}${add}
\n" + return + } + DB { + } + default { + return } - html "

${no}

\n" - html "Error ${err}${add}
\n" - return - } - if {$type != "DB"} { - return } set rtype [$zset recordType $no] - if {$rtype == "SUTRS"} { - html [join [$zset getSutrs $no]] "
\n" - return - } + switch $rtype { + SUTRS { + html "\n" [join [$zset getSutrs $no]] "\n\n" + return + } + WAIS { + html "\n" [join [$zset getWAIS $no text]] "\n\n" + return + } + } if {[catch {set r [$zset getMarc $no line * * *]}]} { html "Unknown record type: $rtype
\n" return @@ -305,110 +427,11 @@ proc dl-marc-field-rec {zset no tag lead start stop startid sep} { } } -proc display-full-wais {zset no setNo targetNo} { +proc display-full-marc {zset no setNo targetNo} { global env global hist global sessionId - set i 0 - set element junk - htmlToken l [join [$zset getWAIS $no text]] { - if {[string compare [string index $l 0] {<}]} { - set data($element) $l - continue - } - switch -exact $l { - { - set element title - } - { - set element dateOfLastModification - } - { - set element controlIdentifier - } - { - set element lastChecked - } - { - set element bytes - } - { - set element linkage - } - { - incr i - } -
  • { - set element "$i,linkage" - } - { - set element "$i,title" - } - default { - set element junk - } - } - } - if {![info exists data(title)] || ![info exists data(linkage)]} { - html "
    " [join [$zset getWAIS $no text]] "\n
    \n" - return - } - html {Title: } {} $data(title) "
    \n" - html {URL: } $data(linkage) "
    \n" - html {Score: } [$zset getWAIS $no score] "
    \n" - html {Lines: } [$zset getWAIS $no lines] "
    \n" - if {[info exists data(bytes)]} { - html {Bytes: } $data(bytes) "
    \n" - } - if {[info exists data(dateOfLastModification)]} { - html {Last modified: } $data(dateOfLastModification) "
    \n" - } - if {[info exists data(lastChecked)]} { - html {Last checked: } $data(lastChecked) "
    \n" - } - html {} - html {Similar WAIS record
    } - html "
      \n" - for {set i 1} {[info exists data($i,linkage)]} {incr i} { - html {
    • } - html $data($i,title) "
      \n" - html "URL: " $data($i,linkage) - } - html "
    \n" -} - -proc display-full {zset no setNo targetNo} { - set type [$zset type $no] - if {$type == "SD"} { - set err [lindex [$zset diag $no] 1] - set add [lindex [$zset diag $no] 2] - if {$add != {}} { - set add " :${add}" - } - html "Error ${err}${add}
    \n" - return - } - if {$type != "DB"} { - return - } - set rtype [$zset recordType $no] - if {$rtype == "SUTRS"} { - html "
    "
    -        html [join [$zset getSutrs $no]]
    -        html "

    \n" - return - } - if {$rtype == "WAIS"} { - display-full-wais $zset $no $setNo $targetNo - return - } - if {[catch {set r [$zset getMarc $no line * * *]}]} { - html "Unknown record type: $rtype
    \n" - return - } html "
    \n" set n [dl-marc-field $zset $no 700 a "Author" "Authors" "
    \n"] if {$n == 0} { @@ -501,6 +524,144 @@ proc display-full {zset no setNo targetNo} { html "
    \n" } +proc display-full-wais {zset no setNo targetNo} { + global env + global hist + global sessionId + + set i 0 + set element junk + htmlToken l [join [$zset getWAIS $no text]] { + if {[string compare [string index $l 0] {<}]} { + if {[info exist data($element)]} { + set data($element) $data($element)$l + } else { + set data($element) $l + } + continue + } + switch -- $l { + { + set element title + } + { + set element dateOfLastModification + } + { + set element controlIdentifier + } + { + set element lastChecked + } + { + set element bytes + } + { + set element linkage + } + { + incr i + } +
  • { + set element "$i,linkage" + } + { + set element "$i,title" + } + { + set element ip + } + default { + set element junk + } + } + } + if {![info exists data(title)] || ![info exists data(linkage)]} { + set nwi 0 + } else { + set nwi 1 + } + if {$nwi} { + html {Title: } $data(title) "
    \n" + html {URL: } $data(linkage) "
    \n" + } else { + html {Title: } [join [$zset getWAIS $no headline]] "
    \n" + } + html {Score: } [$zset getWAIS $no score] "
    \n" + set lines [$zset getWAIS $no lines] + if {$lines > 0} { + html {Lines: } $lines "
    \n" + } + if {!$nwi} { + html "
    \n" [join [$zset getWAIS $no text]] "\n
    \n" + return + } + if {[info exists data(bytes)]} { + html {Bytes: } $data(bytes) "
    \n" + } + if {[info exists data(dateOfLastModification)]} { + html {Last modified: } $data(dateOfLastModification) "
    \n" + } + if {[info exists data(lastChecked)]} { + html {Last checked: } $data(lastChecked) "
    \n" + } + if {[info exists data(ip)]} { + html {
    Initial text
    } $data(ip) "

    \n" + } + + html {} + html {Similar WAIS record
    } + html "
    References\n
    \n" + for {set i 1} {[info exists data($i,linkage)]} {incr i} { + html {} + if {[info exists data($i,title)]} { + html $data($i,title) + } else { + html Untitled + } + html "
    \n" + } + html "
    \n" +} + +proc display-full {zset no setNo targetNo} { + set type [$zset type $no] + switch $type { + SD { + set err [lindex [$zset diag $no] 1] + set add [lindex [$zset diag $no] 2] + if {$add != {}} { + set add " :${add}" + } + html "Error ${err}${add}
    \n" + return + } + DB { + } + default { + return + } + } + set rtype [$zset recordType $no] + switch $rtype { + SUTRS { + html "
    " [join [$zset getSutrs $no]] "

    \n" + return + } + WAIS { + display-full-wais $zset $no $setNo $targetNo + return + } + } + if {[catch {set r [$zset getMarc $no line * * *]}]} { + html "Unknown record type: $rtype
    \n" + return + } + display-full-marc $zset $no $setNo $targetNo +} + proc display-rec {from to dfunc setNo targetNo} { while {$from <= $to} { @@ -1021,8 +1182,12 @@ proc z39msearch {setNo elements start number cache} { } set zstatus($i) 1 incr zleft - egw_log debug "setNo=$setNo msearch " $hist($setNo,$i,query) - z39$i.$setNo search $hist($setNo,$i,query) + egw_log debug "msearch host=" $hist($setNo,$i,host) + egw_log debug "setNo=$setNo query=" $hist($setNo,$i,query) "=" + if {[catch {z39$i.$setNo search $hist($setNo,$i,query)}]} { + set zstatus($i) -1 + incr zleft -1 + } } elseif {[z39$i.$setNo resultCount] >= $start} { if {[expr $start + $number - 1] > [z39$i.$setNo resultCount]} { set tnumber [expr [z39$i.$setNo resultCount] - $start + 1] @@ -1173,6 +1338,10 @@ proc buttons-result-set-s {setNo targetNo setMax startPos after} { html "

    \n" } +proc score-sort {l r} { + return [expr [lindex $r 0] - [lindex $l 0]] +} + proc display-result-set-m-score {setNo} { global hist global useIcons @@ -1181,23 +1350,38 @@ proc display-result-set-m-score {setNo} { set not $hist($setNo,0,host) for {set i 1} {$i <= $not} {incr i} { - if {[lindex $status 0] != "DBOSD"} continue - + if {$zstatus($i) != 2} continue + set status [z39$i.$setNo responseStatus] + if {[lindex $status 0] != "DBOSD"} continue if {$hist($setNo,$i,offset) > $hist($setNo,maxPresent)} { - set nor $hist($setNo,$i,maxPresent) + set nor $hist($setNo,maxPresent) } else { set nor $hist($setNo,$i,offset) } - for {set j 1} {$j < $not} {incr j} { - if {![string compare [z39$i.$setNo recordType] WAIS]} { - lappend scoreArray [list \ - [z39$i.$setNo getWAIS $j score] $i $setNo $j] + for {set j 1} {$j <= $nor} {incr j} { + if {![string compare [z39$i.$setNo recordType $j] WAIS]} { + set score [z39$i.$setNo getWAIS $j score] + if {$score > 0} { + lappend scoreArray [list $score $i $j] + } } else { - lappend scoreArray [list 0 $i $setNo $j] + lappend scoreArray [list 10 $i $j] } } } - html "score merge
    " + if {![info exists scoreArray]} { + html "

    Search produced no result


    \n" + return + } + set scoreSorted [lsort -command score-sort $scoreArray] + + html "
      \n" + foreach r $scoreSorted { + set i [lindex $r 1] + set j [lindex $r 2] + display-$hist($setNo,format) z39$i.$setNo $j $setNo $i + } + html "

    \n" } proc display-result-set-m-server {setNo} { @@ -1220,16 +1404,14 @@ proc display-result-set-m-server {setNo} { html "Error\n
    NSD$code: $msg: $addinfo" } else { set r [z39$i.$setNo resultCount] - html "$r hits\n
    \n
      \n" + html "$r hits\n
      \n" if {$hist($setNo,$i,offset) > $hist($setNo,maxPresent)} { - display-rec 1 $hist($setNo,maxPresent) \ - display-brief $setNo $i + set nor $hist($setNo,maxPresent) } else { - display-rec 1 $hist($setNo,$i,offset) \ - display-brief $setNo $i + set nor $hist($setNo,$i,offset) } - html "
    " + display-rec 1 $nor display-$hist($setNo,format) $setNo $i } html "\n" }