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