|
Cookbook /
WikiCalendarSummary: Add support for a simple calendar. Each date becomes a wiki page.
Version: 0.3.43
Status: Stable
Prerequisites: pmwiki 2.0 and above; 2.1 recommended
Maintainer: jr
Solutionwikilog.phpΔ -- this PmWiki 2 version is an update of the version for PmWiki 1, simplified to reduce the number of script files. The latest version is tested with PmWiki 2.1.5.
Internationalisation:
wikilog.cssΔ -- stylesheet to control the calendar display.
DiscussionPlease note. The Publish PDF library includes the WikiCalendar recipe. First you need to install the calendar. Installation
include_once("This won't work when MultiLanguage is used. To make it work replace the above two lines with:
SDV($language,$_COOKIE['userlang']);
include_once("$FarmD/cookbook/wikilog.php");
//DON'T include_once("$FarmD/cookbook/wikilog-i18n-XX.php");
and make sure to load multilanguage.php before wikilog.php - SteP February 14, 2007, at 04:34 PM
Using the calendarIn the following discussion, assume calendar entries are in a group called Calendar, with a home page called Calendar.Calendar:
To make a form for posting a story to (by default) "today's page" or another selected date, add the To show a list of the latest entries from a page in another group, enter:
Calendar is the name of the calendar group and the home link points to Calendar.Calendar. If you want the calendar home page to be something other than Calendar.Calendar, such as Calendar.HomePage, put the following into the Calendar.GroupHeader To show a list of the latest entries on this page from a page in another group, enter:
To generate a list of "go to month" links suitable for a sidebar (including links to the first and last days' entries, if any, for those months), enter: To display all the entries for the current week in a single page, enter: To provide a form to post a story to a specified date, add this to the home page: There is a range of configuration variables which an administrator can override in the local/config.php file. Place these settings before the
This configures how weekdays are presented.
0 - american style, Sun to Sat
1 - european style, Mon to Sun
SDV($calendar_weekstyle,1);
This configures how dates are presented.
0 - american style, 11/17/2002
1 - european style, 17.11.2002
2 - international style, 2002-11-17
SDV($calendar_datestyle,1);
SDV($space_date_titles,1);
SDV($SpaceDateString,'-');
How many months relative to the current one to start the calendar.
Can be a negative (going back) or a positive (going ahead) number.
The value zero (0) starts the calendar with the current month.
SDV($calendar_months_start,0);
How many months altogether to show on the calendar.
SDV($calendar_months_number,2);
How many months after we should wrap and start a new row.
SDV($calendar_month_wrap,3);
Whether or not to display current entries at the bottom of the calendar.
Enter 'false' to omit the current period's entries.
SDV($display_log_entries,true);
Whether to display current entries in ascending or descending order.
Enter 'false' to show the oldest first.
SDV($newest_first,true);
Whether to display a summary or full calendar on individual entry pages.
Enter 'false' to include the calendar on every page.
SDV($summary_only,true);
This is the default home of each collection (Group) of date pages.
SDV($wikilog_home_page,FmtPageName('$Group',$pagename));
Translate date markup yyyy-mm-dd into long dates
SDV($DateSeparatorPattern,'[-.\/]');
Whether to display non-existent date entries in the calendar as day or day?
Enter 'true' to use the wiki '?' convention for non-existent entries
SDV($day_as_wiki,false);
Whether to display a list or list and Publish button on wikilog news pages
Enter 'true' to include a Publish button after the news list
SDV($enable_publish,false);
Whether to display warm and friendly week day names for (:thisweek:)
Enter 'false' to use normal day names
SDV($yesterday_today_tomorrow,true);
Whether to display fully-defined week day names for (:thisweek:).
0 - day number only
1 - long date (day name, day number, month name, year)
2 - day and month number only (dd.mm or mm/dd or mm-dd)
SDV($long_weekday,0);
Whether to make an edit link on week day names
Enter 'false' to suppress edit link
SDV($edit_weekday,true);
Month and day names in chosen language
SDV($language,'en');
By default, the calendar publish function is disabled. To use the publish function, you will need the PublishWikiTrail recipe. The wikilog-i18n-xx.php files from PmWiki 1 work with the PmWiki 2 calendar. To set local configuration values, either add Finally, wikilog adds date markup: it turns yyyy-mm-dd text into long dates. History08 Jun 2006 -- set $calendar_box_access_code to false to disable the access code field on (:wikilogbox:) 01 Jun 2006 -- add nofollow to nonexistent dates 26 May 2006 -- add group and page option to (:wikilognav:) 24 May 2006 -- avoid mis-handling of dates in url text; improve (:wikilogbox:) handling 08 Mar 2006 upload correct i18n-en file 31 Oct 2005 -- update wikilog.phpΔ. wikilog-i18n-en.phpΔ, wikilog.cssΔ to tidy (:thisweek:) display 27 Oct 2005 fixed bug in function "calendar_nav_bar($pagename,$startingtime)" causing the previous month not to be displayed (Thierry Vanderschueren) line : $lasttime =$startingtime-$calendar_months_number*2592000;
changed into
$lasttime =$startingtime-($calendar_months_number - 1) * 2592000;
Really? If I display 2 months ($calendar_months_number = 2), say October and November, the previous link is to August, which will then display August and September. If, however, I make the above change, the previous link is to September, which will then display September and (repeating itself) October. If I display 1 month, the previous link goes to the current month, not the previous month. So I don't understand why the above change is required or desirable. Perhaps you could help me see what I am missing.
20 Oct 2005 add configuration options for (:thisweek:) 18 Oct 2005 add (:thisweek:) to display entries for the current week -- updates wikilog.phpΔ, wikilog-i18n-en.phpΔ and wikilog.cssΔ 22 May 2005 add (:wikilognav:) to list a series of months (default 15) in a style suitable for a sidebar (requires a new wikilog.css file) 15 May 2005 enhance (:wikilogbox:) so authors can select the date for the story (also requires new wikilog-i18n file) 11 May 2005 add support for 14 Mar 2005 merge the 27 Feb 2005 fixed bug if $calendar_datestyle = 2; and allow trailing spaces after (:wikilog:) directives 10 Feb 2005 changed $CalendarBoxFmt and include
to language files; move files to cookbook directory instead of local directory. (DanielScheibler) 25 Jan 2005 fix incompatibility with pmwiki beta 19, which led to invalid html being generated 17 Jan 2005 pick up the author from the PmWiki cookie (thanks to RobinS) and add support for yyyy-mm-dd markup (renders as a long date). 2 Dec 2004 try again: $url_connector should no longer be needed; but Paul could perhaps retest with beta 4. 15 Nov 2004 put back $url_connector from the PmWiki 1 version -- it's still needed. However, if $url_connector='&'; the WikiCalendar currently doesn't work correctly without a small change to pmwiki itself. See PITS.00165. Thanks to Paul Lewis for reporting the problem and testing a solution. OriginsChristian asked: >A general comment: >* It's slightly confusing with the script called 'wikilog' when the > example is so extremely calendar-oriented. Is the functionality of a > log and a calendar so similar? >* Same goes for the directive (:wikilog:)... to which John answered: <boringHistory> When I were a lad, I was taught that experimental scientists always kept a lab book with a daily log of activities. Like a ship's log. James Cook's log book from the Endeavour voyages makes grim reading. He had some unrelentingly bad hair days. You can tell from the names he gave to places: Cape Tribulation, Cape Foulwind, Murderers' Bay... (I have since learnt that Abel Tasman named Murderers' Bay -- one of his crew got eaten.) Lab books were invariably stained, burnt, torn and dog-eared. Like their authors. So the original idea behind the wikilog was just for a web-based project log book. But what people see is a calendar and it just became easier to explain it in those terms. But it's not really a calendar; it has no pictures of snow-capped mountains, tumbling brooks, happy smiling children, or cute cats. Or ruddy hobbits. We could of course add such features (as long as there are no hobbits). And it was just too hard to come up with a new name and markup. The name 'wikilog' creates no pre-conceived notions about what it "should" do. All the others I could think of were freighted with too much cultural baggage. </boringHistory> See alsoContributor(:wikilog Calendar:) Screen Shot![]() Comments
global $monthnames, $pagename;
$month = substr($title, 4, 2);
$day = substr($title, 6, 2);
if ($day[0] == "0") { $day = $day[1]; } // no leading '0' on days
$monthname = $monthnames[$month - 1];
$monthday = $monthname.$day;
$monthday_include =
MarkupToHTML($pagename, "(:included $monthday:)").
"<br />";
return $monthday_include;
}
function view_calendar($pagename,$homepage) {
global $calendar_months_start,
...
...
// check to see whether to display a summary only
if (IsDate($title) && ($summary_only==true)) {
$r = "<p class='datetrail'>".adjacent_entries($group,$title)."</p>\n";
// new link to the general month-day page
$general_day = month_day_link($title);
return $general_day.$r.set_page_title($title)."<h3>".longdate($title)."</h3>";
}
...
...
}
New FeaturesI have downloaded the Calendar component of PmWiki and have got it up and running on my local test wiki. It adds valuable functionality to PmWiki, but I have some suggestions that I believe would make it simpler to use, more versatile, and applicable in more situations. Here goes:
Sorry about just making requests, without any solutions. To my defence, I tried to do the mentioned modifications myself, but I found that changing the markup was a bit more complicated than I first thought. I am putting up these requests in the hope that this is a problem with me, and not with the markup funktionality of PmWiki :-). If this is the wrong place to make such a request, I'm also sorry about that. --Magnus It looks as if it's time to review the markup and try to simplify it. jr
That would of course be great, and increase the value of PmWiki. I already took a stab at packaging WikiCalendar into a zip file (with all files in correct directories), and could also add a bit to the documentation.Magnus
Added 18 Oct 2005 version jr
Date FormatsBecause I have been struggling a bit to work out how Wikilog formats dates and which of its various formats it uses when, I thought I'd write up what (I think) I've discovered. Correct me if I'm wrong. There are four (4) separate date formats. Actually five if you count what wdate markup matches.
Quick patch to the calender_month() function -- eliminates leading 0 in calendar days under the 10th of the month, replaces with ($dayn = "day name") & non-breaking space, to keep right (numeric) alignment:
if ($i<10) { $day="0".$i; $dayn = " " . $i; } else { $day=$dayn=$i; }
$entryname= $prefix . $day;
$r.="<td class='calendar-";
if (abs($todays_time - mktime(0,0,0,$month,$i,$year)) < 86400) {
$r.="today-";
}
if (PageExists($entryname)) {
$r.="entry'><b>[[". $entryname . "|" . $dayn . "]]</b>";
} else {
$r.="noentry'>[[". $entryname . "|" . $dayn . "]]";
}
XES December 09, 2006, at 07:41 PM I have created a Dutch translation for the WikiCalendar. Should I just attach it? DJ 2007-aug-02 Recipe author's error!The following removed comments arose because jr must have inadvertently uploaded the i18n file from WikiForms instead of WikiCalendar. He sends his profuse apologies. The latest wikilog-i18n-en.phpΔ file should be correct. Thanks to Conrad Edwards for drawing this to my attention. The new i18n file should fix all these problems. jr March 08 2006, at 02:39 PM Is there a way to move the date under the calendar above it, or totally remove it? Is there a way to edit navigation links above the calendar - to get the year showed with two numbers like 08 or showing thew year not at all? Is there possibility to get a variable like $PmCalDName in PmCalendar - I'd like to use something like $PmCalDName: %Y%m%d%W%a to save the information I need. And is it possible to get the pages opened from calendar not to open in editpage? |