From: <Dav...@nt...> - 2005-11-04 18:53:17
|
Author: DavidBright Date: 2005-11-04 10:51:52 -0800 (Fri, 04 Nov 2005) New Revision: 7311 Modified: twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/data/TWiki/CalendarPlugin.txt twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/lib/TWiki/Plugins/CalendarPlugin.pm Log: Item830: CalendarPlugin: Change default aslist format to be something reasonable. Modified: twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/data/TWiki/CalendarPlugin.txt =================================================================== --- twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/data/TWiki/CalendarPlugin.txt 2005-11-04 18:41:49 UTC (rev 7310) +++ twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/data/TWiki/CalendarPlugin.txt 2005-11-04 18:51:52 UTC (rev 7311) @@ -174,13 +174,13 @@ | ==daynames="Mon¦Tue¦..."== | Custom day names | "Monday¦Tuesday¦Wednesday¦Thursday¦<br />Friday¦Saturday¦Sunday" | | ==header="..."== | Text at the top of the calendar; use ==$m== for current month, ==$y== for year | Current month and year | | ==weekstartsonmonday="1"== or =="0"== | Flag to start week on Monday | "0" (Sunday) | -| ==showdatenumbers="0"== | Show day numbers 1...31 in date cells. Note that ==showdatenumbers=1== means that ==HTML::CalendarMonthSimple== will add the date numbers to the cells. If ==showdatenumbers=0==, then the plugin adds the date numbers. The result of this is that a calendar will *always* show the date numbers. | "0" | +| ==showdatenumbers="0"== | Show day numbers 1...31 in date cells. Note that ==showdatenumbers=1== means that ==HTML::CalendarMonthSimple== will add the date numbers to the cells. If ==showdatenumbers=0==, then the plugin adds the date numbers. The result of this is that a calendar will *always* show the date numbers. | "0" (except with aslist="1", see below) | | ==showweekdayheaders="1"== | Show the weekday headers | "0" | | ==weekdayheadersbig="0"== | If enabled, show weekday headers in bold cell headings | "1" | | ==cellalignment="left"== | Horizontal cell alignment of day cells: "left", "center", "right", "justify", "char" | "center" | | ==vcellalignment="middle"== | Vertical cell alignment of day cells: "top", "middle", "bottom", "baseline" | "top" | | ==cellheight="n"== | Height in pixels of each cell in the calendar | Minimum height needed | -| ==format="..."== | How to highlight a date | See above | +| ==format="..."== | How to highlight a date | See [[%TOPIC%#EventFormatting][Event Formatting]] below | | ==width="n"== or =="n%"== | Width of calendar table in pixels or percent | Minimum width needed | | ==border="n"== | Border width of calendar table | "1" | | ==nowrap="1"== or =="0"== | Prevent cell content from wrapping | "0" | @@ -199,10 +199,10 @@ | ==todaycolor="#nnnn"== | Background of today's cell | The web bgcolor | | ==todaycontentcolor="#nnnn"== | Content color of today's cell | contentcolor setting | | and other attributes of HTML::CalendarMonthSimple ||| -| ==aslist== | Controls whether events displayed in calendar style (=aslist=0=) or list style (=aslist=1=). | 0 | +| ==aslist== | Controls whether events displayed in calendar style (=aslist=0=) or list style (=aslist=1=). Note that specifying =aslist=1= forces =showdatenumbers=1=. This is done to ensure that the date number is formatted according to =datenumberformat= and that only the days that have an event are listed. | 0 | | ==days== | Specifies how many days of calendar data to list. Only valid if =aslist=1=. | 1 | | ==months== | Specifies how many months of calendars to display. Only valid if =aslist=0=. | 1 | -| ==datenumberformat== | Specifies formatting for the date number in each cell. The formatting codes accepted are the same as those for the ==%<nop>GMTIME%== variable. | $day | +| ==datenumberformat== | Specifies formatting for the date number in each cell. The formatting codes accepted are the same as those for the ==%<nop>GMTIME%== variable. | '$day' (if =aslist=0=)%BR%' * $day $mon $year' (if =aslist=1=) | | ==todaydatenumberformat== | Specifies formatting for the date number for the current day (today) in the calendar. The formatting codes accepted are the same as those for the ==%<nop>GMTIME%== variable. | ==datenumberformat== | | ==multidayformat== | Specifies formatting of the description for multi-day events. See [[%TOPIC%#MultiDayFormatting][Multi-Day Event Formatting]] for details. | ==$description== | @@ -226,16 +226,35 @@ | ^ | <nobr> == * En dd MMM yyyy - dd MMM yyyy - description== </nobr> | E3 12 Apr 2005 - 31 Dec 2005 - Every three days from 12 Apr 2005 through 31 Dec 2005 (inclusive) | | *Exception*: | Insert the following between the above syntax and the description:<br /> ==X { dd MMM yyyy, dd MMM yyyy - dd MMM yyyy }== | 1 Fri X { 01 Dec 2002, 06 Dec 2002 - 14 Dec 2002 } - Every first Friday except on the 01 Dec 2002 and between 06 Dec 2002 and 14 Dec 2002 | -If an event falls in the selected month then the corresponding day is (by default): +#EventFormatting +---+++ Event formatting + +For a table-style calendar, if an event falls in the selected month then the corresponding day is (by default): * highlighted (font size +2) * linked to the topic containing the event list * marked with an icon whose ALT string is the event's description I.e. ==format== is: <verbatim> -<a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/$web/$topic"><font size="+2">$old</font> -<img alt="$description" SRC="%PUBURLPATH%/$installWeb/CalendarPlugin/exclam.gif" /></a> +$old<font size="+2"><a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/$web/$topic"> +<img alt="$description" SRC="%PUBURLPATH%/$installWeb/CalendarPlugin/exclam.gif" /></a></font> </verbatim> +For a list-style calendar, if an event falls in the selected time period, then it is displayed (by default): + * As a bullet item + * With the date as dd Mmm yyyy + * Linked to the topic containing the event list +In other words, ==datenumberformat== is: +<verbatim> + * $day $mon $year +</verbatim> +and ==format== is: +<verbatim> +$old - <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/$web/$topic"> +$description</a> +</verbatim> + +This displays the events in a form very similar to that in which they are specified (although specific to a particular date). + #MultiDayFormatting ---+++ Multi-Day Event Formatting Modified: twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/lib/TWiki/Plugins/CalendarPlugin.pm =================================================================== --- twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/lib/TWiki/Plugins/CalendarPlugin.pm 2005-11-04 18:41:49 UTC (rev 7310) +++ twiki/branches/DEVELOP/twikiplugins/CalendarPlugin/lib/TWiki/Plugins/CalendarPlugin.pm 2005-11-04 18:51:52 UTC (rev 7311) @@ -120,9 +120,8 @@ lang => 'English', topic => $topic, web => $web, - format => '<a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/$web/$topic"><font size="+2">' - . '$old</font><img alt="$description" src="%PUBURLPATH%/$installWeb/CalendarPlugin/exclam.gif" border="0" /></a>', - datenumberformat => '$day', + format => undef, + datenumberformat => undef, todaydatenumberformat => undef, multidayformat => undef, # Default: display description unchanged ); @@ -289,10 +288,6 @@ $options{$option} = $v if defined($v); } - # Default todaydatenumberformat to datenumberformat if not otherwise set - - $options{todaydatenumberformat} = $options{datenumberformat} if (! $options{todaydatenumberformat}); - # get GMT offset my ($currentYear, $currentMonth, $currentDay, $currentHour, $currentMinute, $currentSecond) = Today_and_Now(1); my $gmtoff = scalar &TWiki::Func::extractNameValuePair( $attributes, 'gmtoffset' ); @@ -369,6 +364,29 @@ my $asList = scalar &TWiki::Func::extractNameValuePair( $attributes, 'aslist' ); + if ($asList) { + + # If displaying as a list, force showdatenumbers to 1 so that the Plugin can format them later. + # This logic seems backwards, but if showdatenumber is 0, the calendar initialization code below will put date numbers into the contents of each day. Then, when displaying the list, every day will be included in the list because the contents is not "empty." This would produce an ugly list. In contrast, if HTML::CalendarSimple is told to put the date numbers on the calendar, this will be done outside of the content. Therefore, we can later display only those days that actually have events, at the cost of formatting the date numbers again. + + + $options{showdatenumbers} = 1; + if (!$options{format}) { + $options{format} = '$old - <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/$web/$topic">$description</a>$n'; + } + if (!$options{datenumberformat}) { + $options{datenumberformat} = ' * $day $mon $year'; + } + } else { + if (!$options{datenumberformat}) { + $options{datenumberformat} = '$day'; + } + } + + # Default todaydatenumberformat to datenumberformat if not otherwise set + + $options{todaydatenumberformat} = $options{datenumberformat} if (! $options{todaydatenumberformat}); + # Process "days" parameter (goes with aslist=1; specifies the # number of days of calendar data to list). Default is 1. @@ -957,8 +975,8 @@ # Set a value for seconds since the epoch my $epochSeconds = timegm($sec, $min, $hour, $day, $mon-1, $year); - # use default TWiki format "31 Dec 1999 - 23:59" unless specified - $formatString ||= '$day $month $year - $hour:$min'; + # Set to format to empty string if undefined to avoid possible warnings + $formatString ||= ''; # Unfortunately, there is a disconnect between the TWiki # formatTime() function and Date::Calc when it comes to the day of |