Attempt to inform user if session has really terminated.
[egate.git] / www / mquery.egw
index 755b77a..b694786 100644 (file)
 <html>
-<head>
-<title> WWW/Z39.50 Gateway Query Form</title>
-</head>
-<body>
 {
-# $Id: mquery.egw,v 1.3 1995/11/08 18:07:22 adam Exp $
+# $Id: mquery.egw,v 1.16 1996/03/14 11:50:45 adam Exp $
 
     if {[info commands saveState] == ""} {
         source z39util.tcl
+        if {![info exists debug]} {
+            session-lost
+            egw_abort
+        }
     }
 
     global setNo
     global nextSetNo
     global hist
-
-    html {<form action="http:} $env(SCRIPT_NAME)
-    html / $sessionId {/msearch.egw/} $setNo {" method=post>} \n
+    global targets
 
     if {[catch {set setNo $nextSetNo}]} {
         set nextSetNo 1
         set setNo 1
     }
-    if {1} {
-    set i 1
-    foreach host [array names targets] {
-        set databases [wform target$host]
-        if {$databases == ""} continue
-        html "host=$host, $databases <br>\n"
-        set hist($setNo,$i,host) $host
-        set hist($setNo,$i,database) $databases
-        incr i
+
+    html {<head><title> WWW/Z39.50 Gateway Query Form</title></head><body>}
+
+    set useIcons 1
+    button-main
+    button-new-target
+
+    html {<form action="http:} $env(SCRIPT_NAME)
+    html / $sessionId {/msearch.egw/} $setNo {" method=get>} \n
+
+    set phost {}
+    set i 0
+    foreach t [lsort [egw_form target]] {
+        set host [lindex $t 0]
+        set base [lindex $t 1]
+        if {$host != $phost} {
+            set phost $host
+            incr i
+            set hist($setNo,$i,host) $host
+            set hist($setNo,$i,idAuthentication) [lindex $targets($host) 3]
+        }
+        lappend hist($setNo,$i,database) $base
     }
-    } else {
-    set hosts [wform target]
-    html "hosts=$hosts <br>\n"
-    set i 1
-    foreach host $hosts {
-        set hist($setNo,$i,host) $host
-        set hist($setNo,$i,database) [lindex [lindex $targets($host) 1] 0]
-        incr i
+    set oSetNo [lindex $sessionParms 0]
+    if {$oSetNo < 0} {
+        set oSetNo 0
     }
-    set host [lindex $hosts 0]
+    if {$i == 0 && $oSetNo && [info exists hist($oSetNo,0,host)]} {
+        for {set i 1} {$i <= $hist($oSetNo,0,host)} {incr i} {
+            set hist($setNo,$i,host) $hist($oSetNo,$i,host)
+            set hist($setNo,$i,idAuthentication) \
+                $hist($oSetNo,$i,idAuthentication)
+            set hist($setNo,$i,database) $hist($oSetNo,$i,database)
+        }
+        incr i -1
     }
-    set hist($setNo,0,host) [expr $i - 1]
-}
-<hr>
-<h3>Input your search criteria: </h3> <br>
-{
+    if {$i == 0} {
+        html "<h2>No targets specified</h2></body></html>"
+        egw_abort 1
+    }
+
+    set curSort server
+    set curFormat brief    
+    if {$oSetNo} {
+        set curSort $hist($oSetNo,sort)
+        set curFormat $hist($oSetNo,format)
+    }
+
+    set hist($setNo,0,host) $i
+
+    html "<b>Fill-in this search form:</b><br>\n"
     set fields [lindex $targets($host) 2]
     for {set no 1} {$no < 4} {incr no} {
+
         html {<select name="menu} $no {">} \n
+        set template {}
+        if {$oSetNo} {
+            set template [join $hist($oSetNo,form,menu$no)]
+        }
+        if {[string length $template] > 0} {
+            html {<option> } $template "\n"
+        }
         foreach f $fields {
-            html {<option> } [lindex $f 0] \n
+            set name [lindex $f 0]
+            if {$template == $name} continue
+            html {<option> } $name \n
         }
         html "</select>\n"
-        html {<input type="text" name="entry} $no {" size=30>} \n
+
+        html {<input type="text" name="entry} $no {" size=35 value="}
+
+        if {$oSetNo} {
+            if {[info exists hist($oSetNo,form,entry$no)]} {
+                html [join $hist($oSetNo,form,entry$no) " "]
+            }
+        }
+        html {">} \n
         if {$no < 3} {
             html {<select name="logic} $no {">} \n
-            html "<option> And\n"
-            html "<option> Or\n"
-            html "<option> And not\n"
+            set template {}
+            if {$oSetNo} {
+                set template [join $hist($oSetNo,form,logic$no) " "]
+            }
+            if {[string length $template] > 0} {
+                html "<option> " $template \n
+            }
+            foreach op {And Or {And not}} {
+                if {$template == $op} continue
+                html "<option> " [join $op " "] \n
+            }
             html "</select>\n"
         }
         html "<br>\n"
     }
-}
-<h3> Various technical parameters: </h3> <br>
-Max hits: <input type="text" name="hits" value="10" size=3>
-Records are shown in:
-<select name="format">
-<option> Long format
-<option> Medium format
-<option> Short format
-<option> Raw MARC
-</select>
-<br>
-<p>
-<input type=submit value="Search"><input type=reset value="Reset">
-</form>
-<hr>
-This page is maintained by <a href="mailto:pwh@dtv.dk"> Peter Wad Hansen </a>.
-Last modified 29. september 1995. <br>
-<em> This and the following pages are under construction
-and will continue to be so until the end of December 1995.</em>
-<hr>
 
-{
-    html {<a href="http:} $env(SCRIPT_NAME)
-    html / $sessionId {/mtargets.egw"> New target </a>}
+    html {<input type=submit value="Search"><input type=reset value="Reset">}
+    html "<br>\n"
+
+    html {<b>Display each record in <select name="format">}
+    if {![string compare $curFormat brief]} {
+        html "<option>brief\n"
+        html "<option>medium\n"
+    } else {
+        html "<option>medium\n"
+        html "<option>brief\n"
+    }
+    html "</select> notation"
+    html { and sort by <select name="sort">}
+    if {![string compare $curSort score]} {
+        html "<option>score\n"
+        html "<option>server\n"
+    } else {
+        html "<option>server\n"
+        html "<option>score\n"
+    }
+    html "</select></b><br>\n"
+
+    set useIcons 0
+    button-main
+    button-new-target
 }
 {
+    catch maintenance
+    if {!$debug} return
     html "<hr>\n"
     html "<h3>Debug information</h3>\n"
     html "sessionId: $sessionId <br>\n"
@@ -97,7 +150,12 @@ and will continue to be so until the end of December 1995.</em>
     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
         html $e {: } $env($e) {<br>} \n
     }
-    html "form: " [wform] " <br>\n"
+    set j $hist($setNo,0,host)
+    for {set i 1} {$i <= $j} {incr i} {
+        html "host=" $hist($setNo,$i,host) " " $hist($setNo,$i,database) 
+        html "<br>\n"
+    }
+    html "form: " [egw_form] " <br>\n"
     html "target: " $host " <br>\n"
     html "setNo: " $setNo " <br>\n"
     html "nextSetNo: " $nextSetNo " <br>\n"