Added CSV (;) export

SVN revision: 846
This commit is contained in:
Stefan Ritt 2004-03-22 10:30:37 +00:00
parent f3ddd1a0ab
commit 473311b020

View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 1.308 2004/03/22 10:30:37 midas
Added CSV (;) export
Revision 1.307 2004/03/21 20:01:48 midas Revision 1.307 2004/03/21 20:01:48 midas
Version 2.5.2 beta Version 2.5.2 beta
@ -4753,7 +4756,8 @@ int setparam(char *param, char *value)
strlcpy(_value[i], value, NAME_LENGTH); strlcpy(_value[i], value, NAME_LENGTH);
} else { } else {
sprintf(str, "Error: Too many parameters (> %d). Cannot perform operation.\n", MAX_PARAM); sprintf(str, "Error: Too many parameters (> %d). Cannot perform operation.\n",
MAX_PARAM);
show_error(str); show_error(str);
return 0; return 0;
} }
@ -7521,12 +7525,19 @@ void show_find_form(LOGBOOK * lbs)
rsprintf("<input type=radio id=\"threaded\" name=\"mode\" value=\"threaded\">"); rsprintf("<input type=radio id=\"threaded\" name=\"mode\" value=\"threaded\">");
rsprintf("<label for=\"threaded\">%s&nbsp;&nbsp;</label>\n", loc("Display threads")); rsprintf("<label for=\"threaded\">%s&nbsp;&nbsp;</label>\n", loc("Display threads"));
if (strieq(mode, "CSV")) if (strieq(mode, "CSV1"))
rsprintf("<input type=radio id=\"CSV\" name=\"mode\" value=\"CSV\" checked>"); rsprintf("<input type=radio id=\"CSV1\" name=\"mode\" value=\"CSV1\" checked>");
else else
rsprintf("<input type=radio id=\"CSV\" name=\"mode\" value=\"CSV\">"); rsprintf("<input type=radio id=\"CSV1\" name=\"mode\" value=\"CSV1\">");
rsprintf("<label for=\"CSV\">%s&nbsp;&nbsp;</label>\n", rsprintf("<label for=\"CSV1\">%s&nbsp;&nbsp;</label>\n",
loc("Display comma-separated values (CSV)")); loc("CSV (\",\" separated)"));
if (strieq(mode, "CSV2"))
rsprintf("<input type=radio id=\"CSV2\" name=\"mode\" value=\"CSV2\" checked>");
else
rsprintf("<input type=radio id=\"CSV2\" name=\"mode\" value=\"CSV2\">");
rsprintf("<label for=\"CSV2\">%s&nbsp;&nbsp;</label>\n",
loc("CSV (\";\" separated)"));
if (strieq(mode, "XML")) if (strieq(mode, "XML"))
rsprintf("<input type=radio id=\"XML\" name=\"mode\" value=\"XML\" checked>"); rsprintf("<input type=radio id=\"XML\" name=\"mode\" value=\"XML\" checked>");
@ -9014,7 +9025,8 @@ void show_import_page(LOGBOOK * lbs)
rsprintf("<label for=\"head\">%s</label>\n", loc("Derive attributes from CSV file")); rsprintf("<label for=\"head\">%s</label>\n", loc("Derive attributes from CSV file"));
if (isparam("ignore")) if (isparam("ignore"))
rsprintf("<input type=checkbox checked id=\"ignore\" name=\"ignore\" value=\"1\">\n"); rsprintf
("<input type=checkbox checked id=\"ignore\" name=\"ignore\" value=\"1\">\n");
else else
rsprintf("<input type=checkbox id=\"ignore\" name=\"ignore\" value=\"1\">\n"); rsprintf("<input type=checkbox id=\"ignore\" name=\"ignore\" value=\"1\">\n");
rsprintf("<label for=\"ignore\">%s</label>\n", loc("Ignore first line")); rsprintf("<label for=\"ignore\">%s</label>\n", loc("Ignore first line"));
@ -9070,7 +9082,7 @@ void csv_import(LOGBOOK * lbs, char *csv, char *csvfile)
if (isparam("preview")) { if (isparam("preview")) {
/* title row */ /* title row */
sprintf(str, loc("CVS import preview of %s"), csvfile); sprintf(str, loc("CSV import preview of %s"), csvfile);
show_standard_header(lbs, TRUE, str, "./"); show_standard_header(lbs, TRUE, str, "./");
rsprintf("<table class=\"frame\" cellpadding=0 cellspacing=0>\n"); rsprintf("<table class=\"frame\" cellpadding=0 cellspacing=0>\n");
rsprintf("<tr><td class=\"title1\">%s</td></tr>\n", str, str); rsprintf("<tr><td class=\"title1\">%s</td></tr>\n", str, str);
@ -11213,8 +11225,8 @@ void display_reply(LOGBOOK * lbs, int message_id, int printable,
display_line(lbs, message_id, 0, "threaded", expand, level, printable, display_line(lbs, message_id, 0, "threaded", expand, level, printable,
n_line, FALSE, date, in_reply_to, reply_to, n_attr_disp, n_line, FALSE, date, in_reply_to, reply_to, n_attr_disp,
disp_attr, (void *) attrib, lbs->n_attr, text, show_text, NULL, encoding, 0, NULL, disp_attr, (void *) attrib, lbs->n_attr, text, show_text, NULL, encoding,
locked_by); 0, NULL, locked_by);
if (reply_to[0]) { if (reply_to[0]) {
p = reply_to; p = reply_to;
@ -12021,8 +12033,8 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
str[NAME_LENGTH], ref[256], img[80], comment[NAME_LENGTH], mode[80], mid[80], str[NAME_LENGTH], ref[256], img[80], comment[NAME_LENGTH], mode[80], mid[80],
menu_str[1000], menu_item[MAX_N_LIST][NAME_LENGTH], param[NAME_LENGTH], format[80]; menu_str[1000], menu_item[MAX_N_LIST][NAME_LENGTH], param[NAME_LENGTH], format[80];
char *p, *pt, *pt1, *pt2, *slist, *svalue, *gattr; char *p, *pt, *pt1, *pt2, *slist, *svalue, *gattr;
BOOL show_attachments, threaded, csv, xml, mode_commands, expand, filtering, disp_filter, BOOL show_attachments, threaded, csv, xml, mode_commands, expand, filtering,
show_text; disp_filter, show_text;
time_t ltime, ltime_start, ltime_end, now, ltime1, ltime2; time_t ltime, ltime_start, ltime_end, now, ltime1, ltime2;
struct tm tms, *ptms; struct tm tms, *ptms;
MSG_LIST *msg_list; MSG_LIST *msg_list;
@ -12135,7 +12147,7 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
} }
threaded = strieq(mode, "threaded"); threaded = strieq(mode, "threaded");
csv = strieq(mode, "CSV"); csv = strieq(mode, "CSV1") || strieq(mode, "CSV2");
xml = strieq(mode, "XML"); xml = strieq(mode, "XML");
if (csv || xml) { if (csv || xml) {
@ -12621,9 +12633,12 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
rsputs(pt1); rsputs(pt1);
rsputs("\""); rsputs("\"");
} }
if (i < lbs->n_attr - 1) if (i < lbs->n_attr - 1) {
if (strieq(mode, "CSV1"))
rsprintf(","); rsprintf(",");
else else
rsprintf(";");
} else
rsprintf("\r\n"); rsprintf("\r\n");
} }
} else if (xml) { } else if (xml) {
@ -12955,8 +12970,7 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
/* evaluate Guest display list */ /* evaluate Guest display list */
if (getcfg(lbs->name, "Password file", str) && if (getcfg(lbs->name, "Password file", str) &&
getcfg(lbs->name, "Guest list display", str) && getcfg(lbs->name, "Guest list display", str) && !isparam("unm")) {
!isparam("unm")) {
strcpy(list, str); strcpy(list, str);
@ -13086,9 +13100,12 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
rsputs(pt1); rsputs(pt1);
rsputs("\""); rsputs("\"");
} }
if (i < lbs->n_attr - 1) if (i < lbs->n_attr - 1) {
if (strieq(mode, "CSV1"))
rsprintf(","); rsprintf(",");
else else
rsprintf(";");
} else
rsprintf("\r\n"); rsprintf("\r\n");
} }
@ -14857,8 +14874,7 @@ void show_elog_message(LOGBOOK * lbs, char *dec_path, char *command)
for (i = 0; i < lbs->n_attr; i++) { for (i = 0; i < lbs->n_attr; i++) {
if (getcfg(lbs->name, "Password file", str) && if (getcfg(lbs->name, "Password file", str) &&
getcfg(lbs->name, "Guest display", str) && getcfg(lbs->name, "Guest display", str) && !isparam("unm")) {
!isparam("unm")) {
n = strbreak(str, gattr, MAX_N_ATTR, ","); n = strbreak(str, gattr, MAX_N_ATTR, ",");
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
@ -14978,8 +14994,7 @@ void show_elog_message(LOGBOOK * lbs, char *dec_path, char *command)
show_text = !getcfg(lbs->name, "Show text", str) || atoi(str) == 1; show_text = !getcfg(lbs->name, "Show text", str) || atoi(str) == 1;
if (getcfg(lbs->name, "Password file", str) && if (getcfg(lbs->name, "Password file", str) &&
getcfg(lbs->name, "Guest display", str) && getcfg(lbs->name, "Guest display", str) && !isparam("unm")) {
!isparam("unm")) {
n = strbreak(str, gattr, MAX_N_ATTR, ","); n = strbreak(str, gattr, MAX_N_ATTR, ",");
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
@ -15029,7 +15044,8 @@ void show_elog_message(LOGBOOK * lbs, char *dec_path, char *command)
rsprintf rsprintf
("<tr><td><table class=\"listframe\" width=\"100%%\" cellspacing=0>\n"); ("<tr><td><table class=\"listframe\" width=\"100%%\" cellspacing=0>\n");
rsprintf("<tr><td nowrap width=\"10%%\" class=\"attribname\">%s %d:</td>\n", rsprintf
("<tr><td nowrap width=\"10%%\" class=\"attribname\">%s %d:</td>\n",
loc("Attachment"), index + 1); loc("Attachment"), index + 1);
rsprintf("<td class=\"attribvalue\"><a href=\"%s\">%s</a>\n", ref, rsprintf("<td class=\"attribvalue\"><a href=\"%s\">%s</a>\n", ref,