From 31e7b19370976739b44a02436be37752a0f6b916 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 22 Mar 2004 14:14:57 +0000 Subject: [PATCH] Implemented 'display ' SVN revision: 850 --- doc/config.html | 26 +++++++++++++++++++++ src/elogd.c | 62 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 7 deletions(-) diff --git a/doc/config.html b/doc/config.html index bd93d971..5384ef8e 100755 --- a/doc/config.html +++ b/doc/config.html @@ -1016,6 +1016,32 @@ dates can be searched for via a start and end date. If date attributes are used (see above), a drop-down quick filter box is displayed which lets the user select "last day", "last week", "next week", and so on.

+

  • Display <attribute> = <string> +
    +Instead of subsituting an attribute, the original attribute can be kept and just the +output formatting can be changed. This can be very handy for constructing HTML links +out of attributes. Presume that a company has a telephone book reachable under
    +
    +
    +http://any.company.com/telbook.cgi?search=<name>
    +
    + +where <name> has to be replaced by a search string. +Now one can construct an automatic telephonebook lookup with following options: +
    +
    +Attributes = Name, Telephone, ...
    +Display Telephone = <a href="http://any.company.com/telbook.cgi?search=$Name">$Name's telephone number</a>
    +
    + +The attribute Telephone is now automatically constructed from +the attribute Name and consists of a link to the company's +telephonebook. The advantage of this system is if the URL of the telephonebook +changes one day, only one statement in the config file has to be changed, while +otherways (like with the Subst Telephone = ... option) all +entries would have to be changed manually.

    + +

  • Execute new | edit | delete = <command>
    It is possible to execute a shell command on the server side after a new message diff --git a/src/elogd.c b/src/elogd.c index a649620c..5e2d7750 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.309 2004/03/22 14:14:57 midas + Implemented 'display ' + Revision 1.308 2004/03/22 10:30:37 midas Added CSV (;) export @@ -8996,10 +8999,16 @@ void show_import_page(LOGBOOK * lbs) loc("Field separator")); rsprintf(""); - strcpy(str, ","); + str[0] = 0; if (isparam("sep")) strcpy(str, getparam("sep")); + if (str[0] == 0) + rsprintf(""); + else + rsprintf(""); + rsprintf("\n", loc("Auto detect")); + if (str[0] == ',') rsprintf(""); else @@ -9007,9 +9016,9 @@ void show_import_page(LOGBOOK * lbs) rsprintf("\n", loc("Comma")); if (str[0] == ';') - rsprintf(""); + rsprintf(""); else - rsprintf(""); + rsprintf(""); rsprintf("\n", loc("Semicolon")); rsprintf("\n"); @@ -9067,7 +9076,6 @@ void csv_import(LOGBOOK * lbs, char *csv, char *csvfile) return; } - p = csv; first = TRUE; in_quotes = FALSE; iline = n_imported = 0; @@ -9077,6 +9085,26 @@ void csv_import(LOGBOOK * lbs, char *csv, char *csvfile) strcpy(sep, getparam("sep")); if (sep[0] == 0) strcpy(sep, ","); + if (strieq(sep, "auto")) { + + /* count commas */ + for (i=0,p=csv ; p ; i++) { + p = strchr(p, ','); + if (p) + p++; + } + n = i; + + /* count semicolon */ + for (i=0,p=csv ; p ; i++) { + p = strchr(p, ';'); + if (p) + p++; + } + + strcpy(sep, i > n ? ";" : ","); + } + n_attr = lbs->n_attr; if (isparam("preview")) { @@ -9105,6 +9133,8 @@ void csv_import(LOGBOOK * lbs, char *csv, char *csvfile) rsprintf(""); } + p = csv; + do { for (i = 0; i < 10000 && *p; i++) { if (!in_quotes && (*p == '\r' || *p == '\n')) @@ -11014,10 +11044,28 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, rsputs(attrib[i]); else { rsprintf("", ref); - if (is_html(attrib[i])) - rsputs(attrib[i]); + + sprintf(str, "Display %s", attr_list[i]); + if (getcfg(lbs->name, str, display)) { + j = build_subst_list(lbs, (char (*)[NAME_LENGTH]) slist, + (char (*)[NAME_LENGTH]) svalue, attrib, TRUE); + sprintf(str, "%d", message_id); + add_subst_list((char (*)[NAME_LENGTH]) slist, + (char (*)[NAME_LENGTH]) svalue, "message id", str, &j); + add_subst_time(lbs, (char (*)[NAME_LENGTH]) slist, + (char (*)[NAME_LENGTH]) svalue, "entry time", date, &j); + + strsubst(display, (char (*)[NAME_LENGTH]) slist, + (char (*)[NAME_LENGTH]) svalue, j); + + } else + strcpy(display, attrib[i]); + + if (is_html(display)) + rsputs(display); else - rsputs2(attrib[i]); + rsputs2(display); + rsprintf(""); }