Attempt to inform user if session has really terminated.
[egate.git] / www / tdefine.egw
1 <html>
2 {
3 # $Id: tdefine.egw,v 1.6 1996/03/14 11:50:49 adam Exp $
4
5     if {[info commands saveState] == ""} {
6         source z39util.tcl
7         if {![info exists debug]} {
8             session-lost
9             egw_abort
10         }
11     }
12
13     html {<head><title> WWW/Z39.50 Gateway Target Definition Response</title>}
14     html {</head><body>}
15
16     set useIcons 1
17     button-main
18     button-define-target
19     button-new-target
20
21     html "<h2>Target definition response</h2><br>\n"
22
23     set name [lindex [egw_form name] 0]
24     set description [lindex [egw_form description] 0]
25     set host [lindex [egw_form host] 0]
26     set databases [lindex [egw_form databases] 0]
27     set authentication [egw_form authentication]
28     set fields [lindex [egw_form fields] 0]
29     set recordType [lindex [egw_form recordtype] 0]
30
31     set ok 1
32     if {[string length $name] == 0} {
33         html "You didn't specify a target name. A target name <em>must</em> "
34         html "be specified.<br>\n"
35         set ok 0
36     }
37     if {[string length $host] == 0} {
38         html "You didn't specify a target name. A host <em>must</em> "
39         html "be specified.<br>\n"
40         set ok 0
41     }
42     if {[string length $databases] == 0} {
43         html "You didn't specify any database(s). At least one database "
44         html "<em>must</em> be specified.<br>\n"
45         set ok 0
46     }
47     if {[string length $recordType] == 0} {
48         html "You didn't specify any record type. One record type "
49         html "<em>must</em> be specified.<br>\n"
50         set ok 0
51     }
52     catch {unset item}
53     catch {unset attrList}
54     set fname {}
55     foreach e $fields {
56         set eqn [string first = $e]
57         if {$eqn > 0} {
58             lappend item {@attr} $e
59         } else {
60             if {[info exists item]} {
61                 lappend attrList [list $fname $item]
62                 set fname {}
63                 unset item
64             }
65             if {[string length $fname] > 0} {
66                 set fname "${fname} $e"
67             } else {
68                 set fname $e
69             }
70         }
71     }
72     if {[info exists item]} {
73         lappend attrList [list $fname $item]
74     }
75     if {![info exists attrList]} {
76         html "You didn't specify proper search fields. At least one"
77         html " search fields must be present<br>\n"
78         set ok 0
79     }
80     if {![string compare recordType WAIS]} {
81         set attrList { {Free-text} {} }
82     }
83     set hostSpec [mergeHostSpec $host $databases]
84     if {$ok} {
85         global targets
86         set targets($hostSpec) [list \
87             [join $name] \
88             $recordType \
89             $attrList \
90             $authentication \
91             $description \
92             1 \
93             user ]
94         html "Target successfully defined<br>\n"
95     }
96     html "<p>\n"
97     set useIcons 0
98     button-main
99     button-define-target
100     button-new-target
101 }
102 {
103     global debug
104
105     if {!$debug} return
106
107     html "\n<br>name=" $name "<br>\n"
108     html "description=" $description "<br>\n"
109     html "host=" $host "<br>\n"
110     html "databases=" $databases "<br>\n"
111     html "fields=" $fields "<br>\n"
112     html "attrList=$attrList<br>\n"
113 }
114
115 </body></html>