X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=www%2Fz39util.tcl;h=36a28a1588133b7fc54bf8ff06cc06e48cb382a5;hb=8bafbc608e1ffba9ee87f4856e586dffa57901b8;hp=8740be44742c7b7eab30d3ea135425806e25fca6;hpb=4938d0c2e8f4e1eec397c2bfbbc7e23fd150c369;p=egate.git
diff --git a/www/z39util.tcl b/www/z39util.tcl
index 8740be4..36a28a1 100644
--- a/www/z39util.tcl
+++ b/www/z39util.tcl
@@ -1,5 +1,5 @@
#
-# $Id: z39util.tcl,v 1.36 1996/03/07 12:46:09 adam Exp $
+# $Id: z39util.tcl,v 1.41 1996/03/14 11:50:51 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,19 +84,136 @@ proc display-brief {zset no setNo targetNo} {
return
}
set rtype [$zset recordType $no]
- if {$rtype == "SUTRS"} {
- html [join [$zset getSutrs $no]]
- html "
\n"
- return
+ 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 {$rtype == "WAIS"} {
+ 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]
+ set score [$zset getMarc $no field 999 * r]
+ } dispError ] } {
html { }
- html [join [$zset getWAIS $no headline]]
- html {}
- html "
\n"
+ 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 { }
+ if {[scan $score %d nscore]} {
+ html "; Score " $nscore
+ }
+ } else {
+ html { }
+ html {No Title}
+ html { }
+ html "Error: " $dispError "\n"
+ }
+ html "
\n"
+}
+
+proc display-brief {zset no setNo targetNo} {
+ global env
+ global sessionId
+
+ html {
\n" [join [$zset getWAIS $no text]] "\n\n" + return + } + if {[info exists data(bytes)]} { + html {
" [join [$zset getSutrs $no]] "
\n" - button-europagate + button-main if {$setMax > 0 && $setMax < [$zz.$setNo resultCount]} { + if {!$useIcons} { + html "\n | " + } html {} + html {">
} } else { - html {">Next Records} " | \n" + html {">Next Records} } } if {$setMax > 0 && $startPos != "" && $startPos != "1"} { + if {!$useIcons} { + html "\n | " + } html {} } else { - html {">Previous Records} " | \n" + html {">Previous Records} } } - button-new-query 1 $setNo - button-new-target 1 - button-view-history 0 + if {$targetNo > 0} { + button-result-set $setNo $targetNo + } + button-new-query $setNo + button-new-target + button-view-history 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
+ global zstatus
+ global targets
+
+ set not $hist($setNo,0,host)
+ for {set i 1} {$i <= $not} {incr i} {
+ if {$zstatus($i) != 2} continue
+ set status [z39$i.$setNo responseStatus]
+ if {[lindex $status 0] != "DBOSD"} continue
+ set nor $hist($setNo,$i,offset)
+ 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]
+ } elseif {![string compare [z39$i.$setNo recordType $j] USmarc]} {
+ set score [z39$i.$setNo getMarc $j field 999 * r]
+ if {[scan $score %d score] != 1} {
+ set score 10
+ }
+ } else {
+ set score 10
+ }
+ if {$score > 0} {
+ lappend scoreArray [list $score $i $j]
+ }
+ }
+ }
+ if {![info exists scoreArray]} {
+ html "
\n" } -proc button-europagate {} { +proc button-main {} { global useIcons html {} if {$useIcons} { html {} } else { - html {Europagate | } + html {Europagate} } } -proc button-define-target {more} { +proc button-define-target {} { global useIcons global env global sessionId + if {!$useIcons} { + html "\n | " + } html {} } else { html {">Define Target} - if {$more} { - html " | \n" - } else { - html "\n" - } } } -proc button-new-target {more} { +proc button-new-target {} { global useIcons global env global sessionId - global mMode + global scriptTarget - html {} } else { html {">New Target} - if {$more} { - html " | \n" - } else { - html "\n" - } } } -proc button-view-history {more} { +proc button-view-history {} { global useIcons global env global sessionId global nextSetNo + if {!$useIcons} { + html "\n | " + } html {} } else { html {">View History} - if {$more} { - html " | \n" - } else { - html "\n" - } } } -proc button-new-query {more setNo} { +proc button-new-query {setNo} { global useIcons global env global sessionId global hist - global mMode + global scriptQuery - html {} + html {} + if {$useIcons} { html {} } else { html {New Query} - if {$more} { - html " | \n" - } else { - html "\n" - } } } -proc button-scan-window {more setNo} { +proc button-result-set {setNo tno} { + global useIcons + global env + global sessionId + global hist + + if {!$useIcons} { + html "\n | " + } + html {} + } else { + html {">Result Set} + } +} + +proc button-scan-window {setNo} { global useIcons global env global sessionId global hist + if {!$useIcons} { + html "\n | " + } set targetNo 0 html {} @@ -1451,11 +1778,6 @@ proc button-scan-window {more setNo} { html {alt="Scan" border=0>} } else { html {Scan} - if {$more} { - html " | \n" - } else { - html "\n" - } } } @@ -1468,7 +1790,7 @@ proc maintenance {} { } proc splitHostSpec {host} { - set i [string last . $host] + set i [string first / $host] if {$i > 1} { incr i -1 return [string range $host 0 $i] @@ -1476,21 +1798,32 @@ proc splitHostSpec {host} { return $host } +proc splitDatabaseSpec {host} { + set i [string first / $host] + if {$i > 1} { + incr i + regsub -all -- - [string range $host $i end] { } res + return $res + } + regsub -all -- - $host {} res + return $res +} + proc mergeHostSpec {host databases} { - return ${host}.[join $databases -] + return ${host}/[join $databases -] } proc mkAssoc {assoc host} { global targets if {[catch {$assoc failback fail-response}]} { - if {[lindex $targets($host) 6] == "1"} { + if {![string compare [lindex $targets($host) 1] WAIS]} { wais $assoc } else { ir $assoc } } else { - if {[lindex $targets($host) 6] == "1"} { + if {![string compare [lindex $targets($host) 1] WAIS]} { if {[$assoc comstack] == "wais"} return wais $assoc } else { @@ -1498,4 +1831,63 @@ proc mkAssoc {assoc host} { ir $assoc } } -} \ No newline at end of file +} + +proc serverList {headlineProc targetProc} { + global targets + global groupsDescription + + proc targetsCmp {l r} { + global targets + return [string compare [string tolower [lindex $targets($l) 0]] \ + [string tolower [lindex $targets($r) 0]]] + } + proc groupCmp {l r} { + global groupsOrder + if {[catch {set lo $groupsOrder($l)}]} { + set lo 10 + } + if {[catch {set ro $groupsOrder($r)}]} { + set ro 10 + } + return [expr $lo - $ro] + } + + foreach tt [array names targets] { + lappend groupsTmp([lindex $targets($tt) 6]) $tt + } + set gts [lsort -command groupCmp [array names groupsTmp]] + foreach gt $gts { + if {[info exists groupsDescription($gt)]} { + eval $headlineProc [list $groupsDescription($gt)] + } else { + eval $headlineProc $gt + } + set tn [lsort -command targetsCmp $groupsTmp($gt)] + foreach t $tn { + eval $targetProc $t + } + } + + rename targetsCmp {} +} + +proc session-lost {} { + global useIcons + + html {