34 static char rcsid[] not_used =
53 #include <mime_util.h>
56 #include "WWWOutput.h"
61 #define getpid _getpid
62 #define access _access
63 #define X_OK 00 // Simple existence
67 : d_strm(&strm), d_attr_rows(rows), d_attr_cols(cols)
76 set_mime_html(*d_strm, unknown_type, dap_version(), x_plain);
87 <td align=\"right\">\n\
89 <a href=\"opendap_form_help.html#disposition\" target=\"help\">Action:</a></h3>\n\
91 <input type=\"button\" value=\"Get ASCII\" onclick=\"ascii_button()\">\n\
92 <input type=\"button\" value=\"Get as CoverageJSON\" onclick=\"binary_button('covjson')\">\n";
95 if (netcdf3_file_response)
96 *d_strm <<
"<input type=\"button\" value=\"Get as NetCDF 3\" onclick=\"binary_button('nc')\">\n";
98 if (netcdf4_file_response)
99 *d_strm <<
"<input type=\"button\" value=\"Get as NetCDF 4\" onclick=\"binary_button('nc4')\">\n";
102 "<input type=\"button\" value=\"Binary (DAP2) Object\" onclick=\"binary_button('dods')\">\n\
103 <input type=\"button\" value=\"Show Help\" onclick=\"help_button()\">\n\
106 <td align=\"right\"><h3><a href=\"opendap_form_help.html#data_url\" target=\"help\">Data URL:</a>\n\
108 <td><input name=\"url\" type=\"text\" size=\"" << d_attr_cols <<
"\" value=\"" << url <<
"\">\n" ;
111 void WWWOutput::write_attributes(AttrTable *attr,
const string prefix)
114 for (AttrTable::Attr_iter a = attr->attr_begin(); a
115 != attr->attr_end(); ++a) {
116 if (attr->is_container(a))
117 write_attributes(attr->get_attr_table(a),
118 (prefix ==
"") ? attr->get_name(a) : prefix +
string(
119 ".") + attr->get_name(a));
122 *d_strm << prefix <<
"." << attr->get_name(a) <<
": ";
124 *d_strm << attr->get_name(a) <<
": ";
126 int num_attr = attr->get_attr_num(a) - 1;
127 for (
int i = 0; i < num_attr; ++i)
129 *d_strm << attr->get_attr(a, i) <<
", ";
131 *d_strm << attr->get_attr(a, num_attr) <<
"\n";
145 <td align=\"right\" valign=\"top\"><h3>\n\
146 <a href=\"opendap_form_help.html#global_attr\" target=\"help\">Global Attributes:</a></h3>\n\
147 <td><textarea name=\"global_attr\" rows=\"" << d_attr_rows <<
"\" cols=\"" << d_attr_cols <<
"\">\n" ;
149 write_attributes(&attr);
151 *d_strm <<
"</textarea><p>\n\n";
154 void WWWOutput::write_variable_entries(DDS &dds)
159 <td align=\"right\" valign=\"top\">\n\
160 <h3><a href=\"opendap_form_help.html#dataset_variables\" target=\"help\">Variables:</a></h3>\n\
163 for (DDS::Vars_iter p = dds.var_begin(); p != dds.var_end(); ++p) {
164 (*p)->print_val(*d_strm);
168 (*p)->print_attributes(*d_strm, d_attr_rows, d_attr_cols);
170 *d_strm <<
"\n<p><p>\n\n";
171 *d_strm <<
"<tr><td><td>\n\n";
183 switch (btp->type()) {
194 AttrTable &attr = btp->get_attr_table();
197 if (attr.get_size() == 0) {
198 DBG(cerr <<
"No Attributes for " << btp->name() << endl);
202 *d_strm <<
"<textarea name=\"" << btp->name() <<
"_attr\" rows=\"" << d_attr_rows <<
"\" cols=\""
203 << d_attr_cols <<
"\">\n";
204 write_attributes(&attr);
205 *d_strm <<
"</textarea>\n\n";
209 case dods_structure_c:
210 case dods_sequence_c: {
211 AttrTable &attr = btp->get_attr_table();
214 if (attr.get_size() == 0) {
215 DBG(cerr <<
"No Attributes for " << btp->name() << endl);
219 *d_strm <<
"<textarea name=\"" << btp->name() <<
"_attr\" rows=\"" << d_attr_rows <<
"\" cols=\""
220 << d_attr_cols <<
"\">\n";
221 write_attributes(&attr);
222 *d_strm <<
"</textarea>\n\n";
227 Grid &g =
dynamic_cast<Grid&
>(*btp);
230 if (attr.get_size() == 0 && array_attr.get_size() == 0) {
231 DBG(cerr <<
"No Attributes for " << btp->name() << endl);
235 *d_strm <<
"<textarea name=\"" << btp->name() <<
"_attr\" rows=\"" << d_attr_rows <<
"\" cols=\""
236 << d_attr_cols <<
"\">\n";
237 write_attributes(&g.get_attr_table());
238 write_attributes(&g.get_array()->get_attr_table(), g.name());
239 for (Grid::Map_iter m = g.map_begin(); m != g.map_end(); ++m) {
240 Array &map =
dynamic_cast<Array&
>(**m);
241 write_attributes(&map.get_attr_table(), map.name());
243 *d_strm <<
"</textarea>\n\n";