More work on target definitons.
[egate.git] / www / z39util.tcl
index ca41b99..7903fd4 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.24 1996/01/24 14:14:20 adam Exp $
+# $Id: z39util.tcl,v 1.25 1996/01/24 16:59:29 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -130,7 +130,8 @@ proc display-brief {zset no tno} {
         if {$p} {
             html ": "
         }
-       html {<em>}
+        html { <a href="http:} $env(SCRIPT_NAME) /
+        html $sessionId {/showfull.egw/} $setNo + $tno + $no + full {">}
        set nope 1
         foreach v $title {
             html $v
@@ -139,23 +140,22 @@ proc display-brief {zset no tno} {
         if {$nope} {
             html {No title} 
         }
-        html {</em> }
+        html {</a> }
        foreach v $cover {
            html $v
        }
-        html {<br>}
-       foreach v $location {
-           html " $v"
-        }
-       foreach v $publisher {
-           html " $v"
-        }
-       foreach v $year {
-           html " $v"
+        if {0} {
+            html {<br>}
+            foreach v $location {
+                html " $v"
+            }
+            foreach v $publisher {
+                html " $v"
+            }
+            foreach v $year {
+                html " $v"
+            }
         }
-        html { -- <a href="http:} $env(SCRIPT_NAME) /
-        html $sessionId {/showfull.egw/} $setNo + $tno + $no + full {">}
-       html "<em>view full</em></a>"
     }
     html "<br>\n"
 }
@@ -462,13 +462,13 @@ proc build-query {t ilines} {
             }
             switch $op {
             And
-                { set q "@and $q ${attr} ${term}" }
+                { set q "@and $q ${attr} \"${term}\"" }
             Or
-                { set q "@or $q ${attr} ${term}" }
+                { set q "@or $q ${attr} \"${term}\"" }
             {And not}
-                { set q "@not $q ${attr} ${term}" }
+                { set q "@not $q ${attr} \"${term}\"" }
             {}
-                { set q "${attr} ${term}" }
+                { set q "${attr} \"${term}\"" }
             }
             set op [egw_form logic$i]
         }
@@ -505,45 +505,46 @@ proc z39scan {setNo scanNo tno scanLines scanPos cache} {
     set zs $zz.s$scanNo.$setNo
     $zz callback ok-response
     $zz failback fail-response
-    if {$oldHost != $host} {
+    set thisHost [splitHostSpec $host]
+    if {$oldHost != $thisHost} {
         catch [list $zz disconnect]
 
         set sessionWait 0
-        if {[catch [list $zz connect $host]]} {
-            displayError "Cannot connect to target" $host
+        if {[catch [list $zz connect $thisHost]]} {
+            displayError "Cannot connect to target" $thisHost
             return 0
         } elseif {$sessionWait == 0} {
             if {[catch {egw_wait sessionWait 300}]} {
                $zz disconnect
-                displayError "Cannot connect to target" $host
+                displayError "Cannot connect to target" $thisHost
                 return 0
             }
             if {$sessionWait != 1} {
-                displayError "Cannot connect to target" $host
+                displayError "Cannot connect to target" $thisHost
                 return 0
             }
         }
         $zz idAuthentication $idAuth
         set sessionWait 0
         if {[catch {$zz init}]} {
-            displayError "Cannot initialize target" $host
+            displayError "Cannot initialize target" $thisHost
            $zz disconnect
             return 0
         }
         if {[catch {egw_wait sessionWait 60}]} {
-            displayError "Cannot initialize target" $host
+            displayError "Cannot initialize target" $thisHost
            $zz disconnect
             return 0
         }
         if {$sessionWait != "1"} {
-            displayError "Cannot initialize target" $host
+            displayError "Cannot initialize target" $thisHost
            $zz disconnect
             return 0
         }
         if {![$zz initResult]} {
             set u [$zz userInformationField]
             $zz disconnect
-            displayError "Cannot initialize target $host" $u
+            displayError "Cannot initialize target $thisHost" $u
             return 0
         }
     } else {
@@ -647,45 +648,46 @@ proc z39search {setNo piggy tno elements} {
     }
     $zz callback ok-response
     $zz failback fail-response
-    if {$oldHost != $host} {
+    set thisHost [splitHostSpec $host]
+    if {$oldHost != $thisHost} {
         catch [list $zz disconnect]
 
         set sessionWait 0
-        if {[catch [list $zz connect $host]]} {
-            displayError "Cannot connect to target" $host
+        if {[catch [list $zz connect $thisHost]]} {
+            displayError "Cannot connect to target" $thisHost
             return 0
         } elseif {$sessionWait == 0} {
             if {[catch {egw_wait sessionWait 300}]} {
                $zz disconnect
-                displayError "Cannot connect to target" $host
+                displayError "Cannot connect to target" $thisHost
                 return 0
             }
             if {$sessionWait != 1} {
-                displayError "Cannot connect to target" $host
+                displayError "Cannot connect to target" $thisHost
                 return 0
             }
         }
         $zz idAuthentication $idAuth
         set sessionWait 0
         if {[catch {$zz init}]} {
-            displayError "Cannot initialize target" $host
+            displayError "Cannot initialize target" $thisHost
            $zz disconnect
             return 0
         }
         if {[catch {egw_wait sessionWait 60}]} {
-            displayError "Cannot initialize target" $host
+            displayError "Cannot initialize target" $thisHost
            $zz disconnect
             return 0
         }
         if {$sessionWait != "1"} {
-            displayError "Cannot initialize target" $host
+            displayError "Cannot initialize target" $thisHost
            $zz disconnect
             return 0
         }
         if {![$zz initResult]} {
             set u [$zz userInformationField]
             $zz disconnect
-            displayError "Cannot initialize target $host" $u
+            displayError "Cannot initialize target $thisHost" $u
             return 0
         }
     } else {
@@ -720,6 +722,7 @@ proc z39search {setNo piggy tno elements} {
         $zz.$setNo mediumSetPresentNumber 0
     }
     set sessionWait 0
+    egw_log debug "search: $query"
     $zz.$setNo search $query
 
     if {[catch {egw_wait sessionWait 600}]} {
@@ -797,7 +800,8 @@ proc z39msearch {setNo piggy elements} {
         if {[catch {set oldHost [z39$i connect]}]} {
             set oldHost ""
         }
-        if {$oldHost != $host} {
+        set thisHost [splitHostSpec $host]
+        if {$oldHost != $thisHost} {
             catch {z39$i disconnect}
         }
         z39$i callback [list connect-m-response $i]
@@ -807,14 +811,15 @@ proc z39msearch {setNo piggy elements} {
     for {set i 1} {$i <= $not} {incr i} {
         set oldHost [z39$i connect]
         set host $hist($setNo,$i,host)
-        if {$oldHost == $host} {
+        set thisHost [splitHostSpec $host]
+        if {$oldHost == $thisHost} {
             set zstatus($i) 1
             continue
         }
         z39$i idAuthentication $hist($setNo,$i,idAuthentication)
-        html "Connecting to target " $host " <br>\n"
+        html "Connecting to target " $thisHost " <br>\n"
         set zstatus($i) -1
-        if {![catch {z39$i connect $host}]} {
+        if {![catch {z39$i connect $thisHost}]} {
             incr zleft
         } 
     }
@@ -826,7 +831,7 @@ proc z39msearch {setNo piggy elements} {
     }
     set zleft 0
     for {set i 1} {$i <= $not} {incr i} {
-        html "host " $hist($setNo,$i,host) ": "
+        html "host " [splitHostSpec $hist($setNo,$i,host)] ": "
         if {$zstatus($i) >= 1} {
             html "ok <br>\n"
             ir-set z39$i.$setNo z39$i
@@ -1109,3 +1114,16 @@ proc maintenance {} {
     html {<em> This and the following pages are under construction and }
     html {will continue to be so until the end of January 1996.</em>}
 }
+
+proc splitHostSpec {host} {
+    set i [string last . $host]
+    if {$i > 1} {
+        incr i -1
+        return [string range $host 0 $i]
+    }
+    return $host
+}
+
+proc mergeHostSpec {host databases} {
+    return ${host}.[join $databases -]
+}