From a6275a602bb8b881bb264aff83e4d7adeadf92cc Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 4 Jul 2003 15:28:29 +0000 Subject: [PATCH] Implemented attribute formats SVN revision: 572 --- doc/ChangeLog | 3 + doc/config.html | 26 ++++ src/elogd.c | 235 +++++++++++++++++++++++++++---------- themes/default/default.css | 10 ++ 4 files changed, 210 insertions(+), 64 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 6f24d6d0..f8eb3a6b 100755 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -11,6 +11,9 @@ Version 2.3.9, released June xxth, 2003 - Replace 'Email message body' by 'Email format' - Send attachments as email attachments - Don't display more than 10 email recipients +- Made default for "Filteres browsing" zero +- Added "Format = width, size, flags, css1, css2" +- Display error if email notification fails Version 2.3.8, released June 4th, 2003 ====================================== diff --git a/doc/config.html b/doc/config.html index 9e8fa190..64a47610 100755 --- a/doc/config.html +++ b/doc/config.html @@ -817,6 +817,32 @@ listed here to display a date filter. Using that filter, the last day, week, mon on can be displayed.

+

  • Format <attribute> = <width>,<size>,<flags>,<css_class_name>,<css_class_value> +
    +Optional formatting parameters for attributes. Following items can be defined in the +comma-separated list:

    + +Values used for new message entry form: +

      +
    • <width> Width of the text entry field in characters +
    • <size> Maximum number of characters allowed. +
    +

    + +Values used for single message display page: +

      +
    • <flags> Sum of following flags: +
        +
      • 1: Display attribute in same line as previous attribute +
      • 2: Display radio buttons or check boxes in separate lines (if applicable) +
      +
    • <css_class_name>,<css_class_value> Cascading Style Sheet class + names used for cells containing attribute name or value, respectively. The classes must + be defined in the style sheet file (usually themes/default/default.css). +
    +

    +Default is "80, 500, 0, attribname, attribvalue". +


    diff --git a/src/elogd.c b/src/elogd.c index bec252d0..aa4ce6b7 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.126 2003/07/04 15:28:29 midas + Implemented attribute formats + Revision 1.125 2003/07/03 15:04:11 midas Fixed bug with attachment redirection @@ -1074,6 +1077,12 @@ char author_list[MAX_N_LIST][NAME_LENGTH] = { #define AF_ICON (1<<5) #define AF_RADIO (1<<6) +/* attribute format flags */ +#define AFF_SAME_LINE 1 +#define AFF_MULTI_LINE 2 +#define AFF_DATE 4 +#define AFF_EXTENDABLE 8 + char attr_list[MAX_N_ATTR][NAME_LENGTH]; char attr_options[MAX_N_ATTR][MAX_N_LIST][NAME_LENGTH]; int attr_flags[MAX_N_ATTR]; @@ -5439,14 +5448,16 @@ int i; void show_edit_form(LOGBOOK *lbs, int message_id, BOOL breply, BOOL bedit, BOOL bupload) { -int i, j, n, index, size, width, height, fh, length, first; +int i, j, n, index, size, width, height, fh, length, first, input_size, input_maxlen, + format_flags; char str[1000], preset[1000], *p, *pend, star[80], comment[10000], reply_string[256]; char list[MAX_N_ATTR][NAME_LENGTH], file_name[256], *buffer, format[256]; char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], orig_tag[80], reply_tag[80], att[MAX_ATTACHMENTS][256], encoding[80], slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH], - owner[256], locked_by[256]; + owner[256], locked_by[256], class_value[80], class_name[80]; time_t now; +char fl[8][NAME_LENGTH]; for (i=0 ; in_attr ; index++) { + strcpy(class_name, "attribname"); + strcpy(class_value, "attribvalue"); + input_size = 80; + input_maxlen = NAME_LENGTH; + + sprintf(str, "Format %s", attr_list[index]); + if (getcfg(lbs->name, str, format)) + { + n = strbreak(format, fl, 8); + if (n > 0 && atoi(fl[0]) > 0) + input_size = atoi(fl[0]); + if (n > 1 && atoi(fl[1]) > 0) + input_maxlen = atoi(fl[1]); + if (n > 2) + format_flags = atoi(fl[2]); + if (n > 3) + strlcpy(class_name, fl[3], sizeof(class_name)); + if (n > 4) + strlcpy(class_value, fl[4], sizeof(class_value)); + } + strcpy(star, (attr_flags[index] & AF_REQUIRED) ? "*" : ""); /* check for preset string */ @@ -5772,8 +5804,8 @@ time_t now; { if (attr_options[index][0][0] == 0) { - rsprintf("\n", - NAME_LENGTH, attr_list[index], attrib[index]); + rsprintf("\n", + class_value, input_size, input_maxlen, attr_list[index], attrib[index]); } else { @@ -5800,6 +5832,9 @@ time_t now; else rsprintf("%s\n", str, attr_options[index][i], attr_options[index][i]); + + if (format_flags & AFF_MULTI_LINE) + rsprintf("
    "); } rsprintf("\n"); @@ -5817,6 +5852,9 @@ time_t now; else rsprintf("%s\n", attr_list[index], attr_options[index][i], attr_options[index][i]); + + if (format_flags & AFF_MULTI_LINE) + rsprintf("
    "); } rsprintf("\n"); @@ -5840,6 +5878,9 @@ time_t now; rsprintf("\"%s\"\n", attr_options[index][i], comment); else rsprintf("\n", attr_options[index][i]); + + if (format_flags & AFF_MULTI_LINE) + rsprintf("
    "); } rsprintf("\n"); @@ -9784,7 +9825,7 @@ LOGBOOK *lbs_cur; int compose_email(LOGBOOK *lbs, char *mail_to, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH], char *mail_param, int old_mail, char att_file[MAX_ATTACHMENTS][256]) { -int i, j, n, flags; +int i, j, n, flags, status; char str[NAME_LENGTH+100], str2[256], mail_from[256], *mail_text, smtp_host[256], subject[256]; char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH]; char list[MAX_PARAM][NAME_LENGTH], url[256], comment[256]; @@ -9897,50 +9938,60 @@ char list[MAX_PARAM][NAME_LENGTH], url[256], comment[256]; getparam("text")); } + status = 0; if (flags & 16) { if (getcfg(lbs->name, "Omit Email to", str) && atoi(str) == 1) - sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, FALSE, url, att_file); + status = sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, FALSE, url, att_file); else - sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, TRUE, url, att_file); + status = sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, TRUE, url, att_file); } else { if (getcfg(lbs->name, "Omit Email to", str) && atoi(str) == 1) - sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, FALSE, url, NULL); + status = sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, FALSE, url, NULL); else - sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, TRUE, url, NULL); + status = sendmail(lbs, smtp_host, mail_from, mail_to, subject, mail_text, TRUE, url, NULL); } - if (!getcfg(lbs->name, "Display email recipients", str) || - atoi(str) == 1) + if (status < 0) { - if (mail_param[0] == 0) - strcpy(mail_param, "?"); - else - strcat(mail_param, "&"); - - n = strbreak(mail_to, list, MAX_PARAM); - - if (n < 10) + sprintf(str, loc("Error sending Email via \"%s\""), smtp_host); + url_encode(str, sizeof(str)); + sprintf(mail_param, "?error=%s", str); + } + else + { + if (!getcfg(lbs->name, "Display email recipients", str) || + atoi(str) == 1) { - for (i=0 ; i%s\n", loc("Email notification suppressed")); - i = 1; + } + else if (isparam("error")) + { + rsprintf("%s\n", getparam("error")); } else { @@ -10882,11 +10937,10 @@ BOOL first; else break; } + if (i>0) + rsprintf("\n"); } - if (i>0) - rsprintf("\n"); - /*---- display message ID ----*/ if (locked_by && locked_by[0]) @@ -10896,8 +10950,15 @@ BOOL first; rsprintf("%s\n", str); } - rsprintf("%s:%d\n\n", - loc("Message ID"), message_id); + rsprintf("\n"); + + for (i=0 ; in_attr ; i++) + rsprintf("\n", attr_list[i], attrib[i]); + + /* browsing flag to distinguish "/../=" from browsing */ + rsprintf("\n"); + + rsprintf("%s: %d\n", loc("Message ID"), message_id); /*---- display date ----*/ @@ -10922,21 +10983,13 @@ BOOL first; mktime(&ts); strftime(str, sizeof(str), format, &ts); - rsprintf("%s:%s\n\n", + rsprintf("    %s: %s\n", loc("Entry date"), str); } else - rsprintf("%s:%s\n\n", + rsprintf("    %s: %s\n", loc("Entry date"), date); - for (i=0 ; in_attr ; i++) - rsprintf("\n", attr_list[i], attrib[i]); - - /* browsing flag to distinguish "/../=" from browsing */ - rsprintf("\n"); - - rsprintf("\n\n"); - /*---- link to original message or reply ----*/ if (message_error != EL_FILE_ERROR && (reply_tag[0] || orig_tag[0])) @@ -10944,15 +10997,13 @@ BOOL first; if (orig_tag[0]) { - rsprintf(""); sprintf(ref, "%s", orig_tag); - rsprintf("%s:", loc("In reply to")); - rsprintf("
    %s\n", ref, orig_tag); + rsprintf("    %s: ", loc("In reply to")); + rsprintf("%s\n", ref, orig_tag); } if (reply_tag[0]) { - rsprintf(""); - rsprintf("%s:", loc("Reply to this")); + rsprintf("    %s: ", loc("Reply to this")); p = strtok(reply_tag, ","); do @@ -10966,18 +11017,49 @@ BOOL first; } while (p); - rsprintf("\n"); + rsprintf("\n"); } } + rsprintf("\n"); + /*---- display attributes ----*/ + /* retrieve attribute flags */ + for (i=0 ; in_attr ; i++) + { + format_flags[i] = 0; + sprintf(str, "Format %s", attr_list[i]); + if (getcfg(lbs->name, str, format)) + { + n = strbreak(format, fl, 8); + if (n > 2) + format_flags[i] = atoi(fl[2]); + } + } + for (i=0 ; in_attr ; i++) { - sprintf(lattr, "l%s", attr_list[i]); - rsprintf(""); + strcpy(class_name, "attribname"); + strcpy(class_value, "attribvalue"); - if (!getcfg(lbs->name, "Filtered browsing", str) || + sprintf(str, "Format %s", attr_list[i]); + if (getcfg(lbs->name, str, format)) + { + n = strbreak(format, fl, 8); + if (n > 3) + strlcpy(class_name, fl[3], sizeof(class_name)); + if (n > 4) + strlcpy(class_value, fl[4], sizeof(class_value)); + } + + if ((format_flags[i] & AFF_SAME_LINE) == 0) + rsprintf(""); + + sprintf(lattr, "l%s", attr_list[i]); + rsprintf("\n", - attr_list[i]); + rsprintf("%s:\n", + class_value, attr_list[i]); else - rsprintf("%s:\n", - attr_list[i]); + rsprintf("%s:\n", + class_value, attr_list[i]); } /* display image for icon */ else if (attr_flags[i] & AF_ICON) { - rsprintf("%s:\n"); + rsprintf(" \n"); + } + else if ((attr_flags[i] & AF_MULTI) && (format_flags[i] & AFF_MULTI_LINE)) + { + rsprintf("%s:\n"); } else { - rsprintf("%s:\n"); + rsprintf(" \n"); } + + if (i == lbs->n_attr-1 || (format_flags[i+1] & AFF_SAME_LINE) == 0) + rsprintf("
    ", class_name); + + if (getcfg(lbs->name, "Filtered browsing", str) && atoi(str) == 1) { if (*getparam(lattr) == '1') @@ -10990,16 +11072,16 @@ BOOL first; if (equal_ustring(attr_options[i][0], "boolean")) { if (atoi(attrib[i]) == 1) - rsprintf("%s:
    \n", attr_list[i]); + rsprintf("%s:\n", attr_list[i], class_value); if (attrib[i][0]) { sprintf(str, "Icon comment %s", attrib[i]); @@ -11010,14 +11092,39 @@ BOOL first; else rsprintf("", attrib[i]); } - rsprintf(" 
    \n", attr_list[i], class_value); + + /* separate options into individual lines */ + strlcpy(str, attrib[i], sizeof(str)); + p = strtok(str, "|"); + while (p) + { + while (*p == ' ') + p++; + + rsputs2(p); + + p = strtok(NULL, "|"); + + if (p) + rsprintf("
    "); + } + + rsprintf("
    \n", attr_list[i]); + rsprintf("%s:\n", attr_list[i], class_value); rsputs2(attrib[i]); - rsprintf(" 
    \n"); } rsputs("\n"); diff --git a/themes/default/default.css b/themes/default/default.css index feac173f..2401dbe2 100755 --- a/themes/default/default.css +++ b/themes/default/default.css @@ -223,6 +223,16 @@ td { } /* attribute names and values on single message page */ +.attribhead { + background-color:#E0E0A0; + border:1px solid #0000FF; + border-top:1px solid white; + border-left:1px solid white; + padding:2px; + font-size:10pt; + font-family:sans-serif; +} + .attribname { background-color:#CCCCFF; border:1px solid #0000FF;