Work on WAIS protocol.
[egate.git] / www / z39util.tcl
index 9efda0b..e50db2b 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.38 1996/03/11 17:40:49 adam Exp $
+# $Id: z39util.tcl,v 1.39 1996/03/12 16:30:30 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -175,6 +175,7 @@ proc display-brief {zset no setNo targetNo} {
     global env
     global sessionId
 
+    html {<li>}
     set type [$zset type $no]
     if {$type == "SD"} {
         set err [lindex [$zset diag $no] 1]
@@ -581,41 +582,45 @@ proc display-full-wais {zset no setNo targetNo} {
     } else {
         set nwi 1
     }
+    html "<dl>\n"
+    html {<dt><b>Title</b>}
     if {$nwi} {
-        html {Title: <a href="} $data(linkage) {">} $data(title) "</a><br>\n"
-        html {URL: } $data(linkage) "<br>\n"
+        html {<dd><a href="} $data(linkage) {">} $data(title) "</a>"
+        html {<dt><b>URL</b>}
+        html {<dd>} $data(linkage) "<br>\n"
     } else {
-        html {Title: } [join [$zset getWAIS $no headline]] "<br>\n"
+        html {<dd>} [join [$zset getWAIS $no headline]]
     }
-    html {Score: } [$zset getWAIS $no score] "<br>\n"
+    html {<dt><b>Score</b><dd>} [$zset getWAIS $no score]
     set lines [$zset getWAIS $no lines]
     if {$lines > 0} {
-        html {Lines: } $lines "<br>\n"
+        html {<dt><b>Lines</b><dd>} $lines "<br>\n"
     }
     if {!$nwi} {
-        html "<pre>\n" [join [$zset getWAIS $no text]] "\n</pre>\n"
+        html "</dl><pre>\n" [join [$zset getWAIS $no text]] "\n</pre>\n"
         return
     }
     if {[info exists data(bytes)]} {
-        html {Bytes: } $data(bytes) "<br>\n"
+        html {<dt><b>Bytes</b><dd>} $data(bytes)
     }
     if {[info exists data(dateOfLastModification)]} {
-        html {Last modified: } $data(dateOfLastModification) "<br>\n"
+        html {<dt><b>Last modified</b><dd>} $data(dateOfLastModification)
     }
     if {[info exists data(lastChecked)]} {
-        html {Last checked: } $data(lastChecked) "<br>\n"
+        html {<dt><b>Last checked</b><dd>} $data(lastChecked) "<br>\n"
     }
     if {[info exists data(ip)]} {
-        html {<dl><dt>Initial text<dd>} $data(ip) "</dl><br>\n"
+        html {<dt><b>Initial text</b><dd>} $data(ip) "</dl><br>\n"
     }
-
-    html {<a href="} $env(SCRIPT_NAME) / $sessionId {/sameas.egw/}
-    html $setNo + $targetNo + 1 + $hist($setNo,maxPresent) +
-    html [egw_enc [$zset getWAIS $no documentID]] {">}
-    html {Similar WAIS record</a><br>}
-    html "<dl><dt>References\n<dd>\n"
+    if {0} {
+        html {<a href="} $env(SCRIPT_NAME) / $sessionId {/sameas.egw/}
+        html $setNo + $targetNo + 1 + $hist($setNo,maxPresent) +
+        html [egw_enc [$zset getWAIS $no documentID]] {">}
+        html {Similar WAIS record</a><br>}
+    }
+    html "<dt><b>References</b>\n"
     for {set i 1} {[info exists data($i,linkage)]} {incr i} {
-        html {<a href="} $data($i,linkage) {">}
+        html {<dd><a href="} $data($i,linkage) {">}
         if {[info exists data($i,title)]} {
             html $data($i,title)
         } else {
@@ -694,16 +699,16 @@ proc build-query {t ilines} {
     set q {}
     for {set i 1} {$i <= $ilines} {incr i} {
         set term [join [egw_form entry$i]]
+        if {[string length $term] == 0} continue
         if {![string compare [lindex $targets($t) 1] WAIS]} {
-            if {[string length $op] == 0} {
+            if {[string length $q] == 0} {
                 set q $term
             } else {
                 set q "$term $q"
             }
             set op [egw_form logic$i]
             continue
-        }                
-        if {[string length $term] > 0} {
+        } else {
             set field [join [egw_form menu$i]]
             catch {unset attr}
             foreach x [lindex $targets($t) 2] {
@@ -716,13 +721,13 @@ proc build-query {t ilines} {
                 set attr [lindex [lindex [lindex $targets($t) 2] 0] 1]
             }
             switch $op {
-            And
+                And
                 { set q "@and $q ${attr} \"${term}\"" }
-            Or
+                Or
                 { set q "@or $q ${attr} \"${term}\"" }
-            {And not}
+                {And not}
                 { set q "@not $q ${attr} \"${term}\"" }
-            {}
+                {}
                 { set q "${attr} \"${term}\"" }
             }
             set op [egw_form logic$i]
@@ -833,6 +838,7 @@ proc display-scan {setNo scanNo tno} {
     global targets
     global env
     global sessionId
+    global scriptQuery
 
     set zz z39$tno
     set zs $zz.s$scanNo.$setNo
@@ -862,7 +868,7 @@ proc display-scan {setNo scanNo tno} {
         if {0} {
             regsub -all {\ } [lindex [$zs scanLine $i] 1] + tterm
             html {<a href="http:} $env(SCRIPT_NAME)
-            html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo +
+            html / $sessionId / $scriptQuery / $setNo + $hist($setNo,host) +
             html $hist($setNo,scan) +  $tterm {">}
         } else {
             regsub -all {\ } [lindex [$zs scanLine $i] 1] + tterm
@@ -1307,19 +1313,25 @@ proc buttons-result-set-s {setNo targetNo setMax startPos after} {
 
     set zz z39$targetNo
     html "<p>\n"
-    button-europagate
+    button-main
     if {$setMax > 0 && $setMax < [$zz.$setNo resultCount]} {
+        if {!$useIcons} {
+            html "\n | "
+        }
         html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo + $targetNo + 
         html [expr $setMax + 1] + [expr $setMax + $hist($setNo,maxPresent)]
         if {$useIcons} {
-            html {"><img src="/egwgif/button-next-records.gif" alt="Next Records"}
-           html { border=0></a>}
+            html {"><img src="/egwgif/button-next-records.gif" }
+            html {alt="Next Records" border=0></a>}
         } else {
-            html {">Next Records</a>} " | \n"
+            html {">Next Records</a>}
         }
     }
     if {$setMax > 0 && $startPos != "" && $startPos != "1"} {
+        if {!$useIcons} {
+            html "\n | "
+        }
         html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo + $targetNo
         html + [expr $startPos - $hist($setNo,maxPresent)]
@@ -1328,7 +1340,7 @@ proc buttons-result-set-s {setNo targetNo setMax startPos after} {
             html {"><img src="/egwgif/button-previous-records.gif" }
            html {alt="Previous Records" border=0></a>}
         } else {
-            html {">Previous Records</a>} " | \n"
+            html {">Previous Records</a>} 
         }
     }
     button-new-query 1 $setNo
@@ -1504,6 +1516,7 @@ proc z39history {} {
     global sessionId
     global targets
     global html3
+    global scriptQuery
 
     set targetNo 0
     if {![info exists nextSetNo]} {
@@ -1565,7 +1578,7 @@ proc z39history {} {
             html "<dd>\n"
         }
         html { <a href="http:} $env(SCRIPT_NAME)
-        html / $sessionId {/query.egw/} $host + $setNo
+        html / $sessionId / $scriptQuery / $setNo + $host
         if {$html3} {
             html {">}
         } else {
@@ -1596,19 +1609,19 @@ proc displayError {msga msgb} {
     html "<p><center>\n"
     html {<img src="/egwgif/noway.gif" alt="Error">}
     html "<h2>" $msga "</h2>\n"
-    if {$msgb != ""} {
+    if {[string length $msgb] > 0} {
         html "<h3>" $msgb "</h3>\n"
     }
     html "</center><p>\n"
 }
 
-proc button-europagate {} {
+proc button-main {} {
     global useIcons
     html {<a href="http://europagate.dtv.dk/">}
     if {$useIcons} {
         html {<img src="/egwgif/button-egw.gif" alt="Europagate" border=0></a>}
     } else {
-        html {Europagate</a> | }
+        html {Europagate</a>}
     }
 }
 
@@ -1617,6 +1630,9 @@ proc button-define-target {more} {
     global env
     global sessionId
 
+    if {!$useIcons} {
+        html "\n | "
+    }
     html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/tform.egw}
     if {$useIcons} {
@@ -1624,11 +1640,6 @@ proc button-define-target {more} {
        html {alt="Define Target" border=0></a>}
     } else {
         html {">Define Target</a>}
-        if {$more} {
-            html " | \n"
-        } else {
-            html "\n"
-        }
     }
 }
 
@@ -1637,24 +1648,20 @@ proc button-new-target {more} {
     global env
     global sessionId
     global mMode
+    global scriptTarget
 
-    html {<a href="http:} $env(SCRIPT_NAME)
-    html / $sessionId 
-    if {$mMode} {
-        html {/mtargets.egw}
-    } else {
-        html {/targets.egw}
+    if {[string length $scriptTarget] == 0} return
+
+    if {!$useIcons} {
+        html "\n | "
     }
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId / $scriptTarget
     if {$useIcons} {
         html {"><img src="/egwgif/button-new-target.gif" }
        html {alt="New Target" border=0></a>}
     } else {
         html {">New Target</a>}
-        if {$more} {
-            html " | \n"
-        } else {
-            html "\n"
-        }
     }
 }
 
@@ -1664,6 +1671,9 @@ proc button-view-history {more} {
     global sessionId
     global nextSetNo
 
+    if {!$useIcons} {
+        html "\n | "
+    }
     html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/history.egw;}
     catch { html "/" $nextSetNo}
@@ -1672,11 +1682,6 @@ proc button-view-history {more} {
         html {border=0></a>}
     } else {
         html {">View History</a>}
-        if {$more} {
-            html " | \n"
-        } else {
-            html "\n"
-        }
     }
 }
 
@@ -1686,25 +1691,19 @@ proc button-new-query {more setNo} {
     global sessionId
     global hist
     global mMode
+    global scriptQuery
 
-    html {<a href="http:} $env(SCRIPT_NAME)
-    html / $sessionId 
-    if {$mMode} {
-        html {/mquery.egw/} $setNo
-    } else {
-        html {/query.egw/} $hist($setNo,0,host) + $setNo
+    if {!$useIcons} {
+        html "\n | "
     }
-    html {">}
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId / $scriptQuery / $setNo + $hist($setNo,0,host) {">}
+
     if {$useIcons} {
         html {<img src="/egwgif/button-new-query.gif" }
        html {alt="New Query" border=0></a>}
     } else {
         html {New Query</a>}
-        if {$more} {
-            html " | \n"
-        } else {
-            html "\n"
-        }
     }
 }
 
@@ -1714,6 +1713,9 @@ proc button-scan-window {more setNo} {
     global sessionId
     global hist
 
+    if {!$useIcons} {
+        html "\n | "
+    }
     set targetNo 0
     html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/search.egw/} $setNo + $targetNo + {scan} {">}
@@ -1722,11 +1724,6 @@ proc button-scan-window {more setNo} {
        html {alt="Scan" border=0></a>}
     } else {
         html {Scan</a>}
-        if {$more} {
-            html " | \n"
-        } else {
-            html "\n"
-        }
     }
 }
 
@@ -1759,7 +1756,7 @@ proc splitDatabaseSpec {host} {
 }
 
 proc mergeHostSpec {host databases} {
-    return ${host}.[join $databases -]
+    return ${host}/[join $databases -]
 }
 
 proc mkAssoc {assoc host} {
@@ -1780,4 +1777,8 @@ proc mkAssoc {assoc host} {
             ir $assoc
         }
     }
+}
+
+if {[info exists utilExtension]} {
+    source $utilExtension
 }
\ No newline at end of file