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