A lot of work on scan. Tables used to display scan terms and hits.
[egate.git] / www / search.egw
index 588f13a..eed24c0 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: search.egw,v 1.30 1996/01/24 08:27:29 adam Exp $
+# $Id: search.egw,v 1.31 1996/01/26 15:50:08 adam Exp $
 
 proc start-scan {scanNo cache dir initSet} {
     global sessionId
@@ -16,9 +16,50 @@ proc start-scan {scanNo cache dir initSet} {
 
     set host $hist($setNo,host)
 
-    html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
+    html "<head><title> WWW/Z39.50 Gateway Scan " [splitHostSpec $host]
+    html " </title>\n"
     html "</head><body>\n"
 
+    set useIcons 1
+    button-europagate
+
+    if {$dir == "b"} {
+        set lines 20
+        set pos 20
+    } elseif {$dir == "f"} {
+        set lines 20
+        set pos 1
+    } else {
+        set lines 20
+        set pos 10
+    }
+    if {$hist($setNo,$scanNo,scanTerm) != ""} {
+        if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
+            button-new-query 0 $setNo
+            egw_log debug "z39_scan failed"
+            return
+        }
+        html {<a href="http:} $env(SCRIPT_NAME)
+        html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
+        if {$useIcons} {
+            html {<img src="/egwgif/button-previous-terms.gif" }
+            html {alt="Next Terms" border=0></a>}
+        } else {
+            html {Previous Terms</a> | }
+        }
+
+        html {<a href="http:} $env(SCRIPT_NAME)
+        html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
+        if {$useIcons} {
+            html {<img src="/egwgif/button-next-terms.gif" }
+            html {alt="Next Terms" border=0></a>}
+        } else {
+            html {Next Terms</a> | }
+        }
+        html {</a>}
+    }
+    button-new-query 0 $setNo
+
     set databases [lindex $targets($host) 1]
 
     if {$initSet == ""} {
@@ -50,14 +91,15 @@ proc start-scan {scanNo cache dir initSet} {
             html {<input type="checkbox" name="baseall" value="} 
             html [concat $databases] {"> All <br>} \n
         }
-        html "Input your search criteria:<br>\n"
     }
+    html "Input your scan criteria:<br>\n"
     set fields [lindex $targets($host) 2]
     set no 1
     html {<select name="menu} $no {">} \n
     set template {}
     if {$oSetNo > 0} {
         set template [join $hist($oSetNo,form,menu$no)]
+        egw_log debug "template=$template"
     }
     if {[string length $template] > 0} {
         html {<option> } $template \n
@@ -74,47 +116,13 @@ proc start-scan {scanNo cache dir initSet} {
     html "\n"
     html {</form><br>}
 
-    button-europagate
-
+    set useIcons 0
     if {$hist($setNo,$scanNo,scanTerm) == ""} {
-        button-new-query 0 $setNo
-        egw_abort
-        return
-    }
-    if {$dir == "b"} {
-        set lines 20
-        set pos 20
-    } elseif {$dir == "f"} {
-        set lines 20
-        set pos 1
-    } else {
-        set lines 20
-        set pos 10
-    }
-    if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
+        button-europagate
+        button-new-query 0 $setNo        
         return
     }
 
-    html {<a href="http:} $env(SCRIPT_NAME)
-    html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b {">}
-    if {$useIcons} {
-        html {<img src="/egwgif/button-previous-terms.gif" }
-        html {alt="Next Terms" border=0></a>}
-    } else {
-        html {Previous Terms</a> | }
-    }
-
-    html {<a href="http:} $env(SCRIPT_NAME)
-    html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f {">}
-    if {$useIcons} {
-        html {<img src="/egwgif/button-next-terms.gif" }
-        html {alt="Next Terms" border=0></a>}
-    } else {
-        html {Next Terms</a> | }
-    }
-    html {</a>}
-    button-new-query 0 $setNo
-
     html "<p>\n"
     display-scan $setNo $scanNo 0
     html "<p>\n"
@@ -165,7 +173,7 @@ proc buttons {setNo setMax startPos after} {
 
     html "<p>\n"
     button-europagate
-    if {$setMax < [z39.$setNo resultCount]} {
+    if {$setMax > 0 && $setMax < [z39.$setNo resultCount]} {
         html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
         html + [expr $setMax + $hist($setNo,maxPresent)]
@@ -176,7 +184,7 @@ proc buttons {setNo setMax startPos after} {
             html {">Next Records</a>} " | \n"
         }
     }
-    if {$startPos != "" && $startPos != "1"} {
+    if {$setMax > 0 && $startPos != "" && $startPos != "1"} {
         html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo 
         html + [expr $startPos - $hist($setNo,maxPresent)]
@@ -204,6 +212,8 @@ proc buttons {setNo setMax startPos after} {
     global hist
 
     set setNo [lindex $sessionParms 0]
+    set startPos [lindex $sessionParms 1]
+    set endPos [lindex $sessionParms 2]
 
     if {[egw_form] != ""} {
         set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
@@ -259,7 +269,7 @@ proc buttons {setNo setMax startPos after} {
             set termPlusAttr [build-scan $hist($setNo,host) $i]
             set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
             set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
-            start-scan $scanNo 0 {} {}
+            start-scan $scanNo 0 {} $setNo
             html "</body></html>\n"
             egw_abort
             return
@@ -273,14 +283,32 @@ proc buttons {setNo setMax startPos after} {
             egw_abort
         }
         set hist($setNo,query) $query
-    } else {
-        if {[lindex $sessionParms 1] == "scan"} {
-            set scanNo 1000
-            set hist($setNo,$scanNo,scanTerm) {}
-            start-scan $scanNo 0 {} {}
-            html "</body></html>\n"
-            egw_abort
+    } elseif {[lindex $sessionParms 1] == "hyper"} {
+        egw_log debug "hyper search"
+        set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
+        set hist($nextSetNo,host) $hist($setNo,host)
+        set hist($nextSetNo,database) $hist($setNo,database)
+
+        if {$nextSetNo == $setNo} {
+            set setNo $nextSetNo
+            incr nextSetNo
+        } else {
+            catch {unset hist($setNo,hits)}
         }
+        set hist($setNo,scan) 0
+        set hist($setNo,query) \
+            "$hist($setNo,scanAttr) \"[lindex $sessionParms 2]\""
+        egw_log debug "hyper databases: $hist($setNo,database)"
+        set hist($setNo,form,entry1) [lindex $sessionParms 2]
+        set startPos ""
+    } elseif {[lindex $sessionParms 1] == "scan"} {
+        egw_log debug "star scan"
+        set scanNo 1000
+        set hist($setNo,$scanNo,scanTerm) {}
+        start-scan $scanNo 0 {} {}
+        html "</body></html>\n"
+        egw_abort
+    } else {
         if {![info exists hist($setNo,scan)]} return
         if {$hist($setNo,scan) > 0} {
             set scanNo [lindex $sessionParms 1]
@@ -295,18 +323,25 @@ proc buttons {setNo setMax startPos after} {
     }
     set host $hist($setNo,host)
 
-    html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
+    html "<head><title> WWW/Z39.50 Gateway Search " [splitHostSpec $host] 
+    html " </title>\n"
     html "</head><body>\n"
 
-    set startPos [lindex $sessionParms 1]
-    set endPos [lindex $sessionParms 2]
     set setMax 0
     set setOffset 0
+    set useIcons 1
     if {$startPos == ""} {
         if {[z39search $setNo 1 0 B] != "1"} {
             return
         }
         set r [z39.$setNo resultCount]
+
+        set setMax [z39.$setNo resultCount]
+        if {$setMax > $hist($setNo,maxPresent)} {
+            set setMax $hist($setNo,maxPresent)
+        }
+        buttons $setNo $setMax $startPos 0
+
         set setOffset [z39.$setNo numberOfRecordsReturned]
         if {$setOffset > 0} {
             html {<h3> Records 1-} $setOffset " out of $r</h3>\n"
@@ -317,10 +352,7 @@ proc buttons {setNo setMax startPos after} {
         html "<ul>\n"
         display-rec 1 $setOffset display-brief 0
         incr setOffset
-        set setMax [z39.$setNo resultCount]
-        if {$setMax > $hist($setNo,maxPresent)} {
-            set setMax $hist($setNo,maxPresent)
-        }
+
     } else {
         if {[z39search $setNo 0 0 B] != "1"} {
             return 
@@ -331,9 +363,7 @@ proc buttons {setNo setMax startPos after} {
         if {$setMax > $endPos} {
             set setMax $endPos
         }
-        if {$setMax > 0} {
-            buttons $setNo $setMax $startPos 0
-        }
+        buttons $setNo $setMax $startPos 0
         if {$setMax > 0} {
             html {<h3> Records } $startPos {-} $setMax " out of $r</h3>\n"
         } else {
@@ -346,6 +376,7 @@ proc buttons {setNo setMax startPos after} {
         z39present $setNo 0 $setOffset $setMax display-brief B
     }
     html "</ul>\n"
+    set useIcons 0
     buttons $setNo $setMax $startPos 1
 }