*
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// =========================================================================
// Configuration
// =========================================================================
// 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,'-');
SDV($day_separator, (($calendar_datestyle==0) ? ',' : ''));
// 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));
// 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, (($action=='print' || $action=='publish') ? false : true));
// Allow page names to be all numerics.
$CalendarPattern = "[0-9]{8}";
$WikiDateCreateFmt = "\$LinkText";
## process date links
Markup('datelink','>inline',
"/\[\[($GroupPattern(?:[\/.])$CalendarPattern)\|(.*?)\]\]/", "datelink_e");
function datelink_e($m) {
extract($GLOBALS['MarkupToHTML']);
return Keep(MakeDateLink($pagename,$m[1],$m[2]),'L');
}
Markup('daylink','>inline',
"/\[\[((?:$GroupPattern\/)?($CalendarPattern))\]\]/", "daylink_e");
function daylink_e($m) {
return Keep(MakeDateLink($pagename,$m[1],(IsDate($m[2]) ? longdate($m[2]) : $m[2])),'L');
}
## process date markup
SDV($DateSeparatorPattern,'[-.\/]');
Markup('wdate','inline',
"/([^_\/\)=]|^)(\d\d\d\d)($DateSeparatorPattern)(\d\d)\\3(\d\d)/",
"wdateHelper");
function wdateHelper($m) {
return IsDate($m[2].$m[4].$m[5]) ? $m[1].longdate($m[2].$m[4].$m[5]) : $m[0];
}
// 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);
// Set depending on whether you need [[Page?logdate= or [[Page&logdate=
SDV($url_connector,"?");
// Month and day names in chosen language
SDV($language,'en');
SDV($scriptlocation,'scripts');
if (file_exists("$FarmD/cookbook/wikilog-i18n-$language.php"))
include_once("$FarmD/cookbook/wikilog-i18n-$language.php");
elseif (file_exists("$FarmD/cookbook/$scriptlocation/wikilog-i18n-$language.php"))
include_once("$FarmD/cookbook/$scriptlocation/wikilog-i18n-$language.php");
elseif (file_exists("$FarmD/local/wikilog-i18n-$language.php"))
include_once("$FarmD/local/wikilog-i18n-$language.php");
elseif (file_exists("$FarmD/local/$scriptlocation/wikilog-i18n-$language.php"))
include_once("$FarmD/local/$scriptlocation/wikilog-i18n-$language.php");
elseif (file_exists("$FarmD/local/$scriptlocation/wikilog-i18n-en.php"))
include_once("$FarmD/local/$scriptlocation/wikilog-i18n-en.php");
else include_once("$FarmD/cookbook/$scriptlocation/wikilog-i18n-en.php");
// Publish button format
if ($EnablePDF) SDV($PublishCalendarOptionsFmt,
" (\$[PDF options])");
SDV($PublishCalendarFmt,
"
");
// (:wikilognav:) to jump to a particular month
// How many months altogether to show in the navigation list.
SDV($calendar_months_listed,15);
// How many months into the future to show in the list.
SDV($calendar_months_future,3);
Markup('wnav','
".list_calendar_months($pagename,$m[1],$m[2])."
";
}
// (:wikilogbox:) to post short stories to today's page
SDV($calendar_box_access_code,true);
SDV($calendar_subpages,false);
SDV($CalendarBoxFmt,"
\$CalendarTitle
");
if ($action == 'wikilog') {
if (auditWikilog()) SDV($HandleActions['wikilog'],'HandleWikilogPost');
else Redirect($pagename);
} else if ($action=='print' || $action=='publish') {
Markup('wbox','>links','/\(:wikilogbox(chrono)?\s*(.*?):\)/','');
Markup('pubcal','>title','/\(:publishcalendar:\)/','');
} else
Markup('wbox','>links','/\(:wikilogbox(chrono)?\s*(.*?):\)/', "wbox_e");
function wbox_e($m) {
extract($GLOBALS['MarkupToHTML']);
return "<:block>".Keep(str_replace(
array("$CalendarTitle","$StoryDate","$Chrono","$AccessCode"),
array(SetCalendarTitle($m[2]),select_calendar_date($pagename),$m[1],
rand(100,999)), FmtPageName($GLOBALS['CalendarBoxFmt'],$pagename)));
}
# load the wikilog stylesheet
$HTMLHeaderFmt[] =
"";
/*
You can define different colours for the dates with or without an entry in the
wikilog stylesheet. The class attributes for the TD tag are:
calendar-today-entry : current date and there is an entry
calendar-today-noentry : current date but there is no entry
calendar-entry : any other date with an entry
calendar-noentry : any other date without an entry
calendar-blank : empty cells at the start and end of month
The class attribute for date links is:
nonexistent-date : wikilink without an entry
*/
// ======================================================================
if (isset($_GET['logdate'])) {
$logdate = $_GET['logdate'];
$FmtV['$Logdate'] = $logdate;
} else $logdate = '';
Markup('wikilog',''.view_calendar_list($pagename,$m[1],$m[2]);
}
Markup('wikidate','>wikilogn','/\(:\wikilogtitle:\)/', "wikidate_e");
function wikidate_e($m) {
extract($GLOBALS['MarkupToHTML']);
return show_date($pagename);
}
Markup('pubcal','>title','/\(:publishcalendar:\)/', "pubcal_e");
function pubcal_e($m) {
extract($GLOBALS['MarkupToHTML']);
return Keep(FmtPageName($GLOBALS['PublishCalendarFmt'],$pagename));
}
Markup('week','>nl1',"/^\(:thisweek(?:\s+([-+]?\d+))?:\)\s*$/", "week_e");
function week_e($m) {
extract($GLOBALS['MarkupToHTML']);
return calendar_week($pagename,$m[1]);
}
$Name = FmtPageName('$Name',$pagename);
if (IsDate($Name)) $SpacedName = preg_replace('/(..)(..)$/',
"$SpaceDateString$1$SpaceDateString$2",$Name);
function view_calendar_choice($pagename,$name) {
global $DefaultName;
if (PageExists(FmtPageName("\$Group.$name",$pagename)))
return view_calendar($pagename,$name);
foreach(array($name,$DefaultName) as $pg) {
if (PageExists("$name.$pg"))
return view_calendar_list($pagename,$name,$pg);
}
return view_calendar($pagename,$name);
}
function view_calendar($pagename,$homepage) {
global $calendar_months_start, $calendar_months_number,$calendar_month_wrap;
global $wikilog_home_page, $summary_only, $logdate, $PublishCalendarFmt;
global $newest_first, $display_log_entries, $enable_publish,$AsSpacedFunction;
$group = FmtPageName('$Group',$pagename);
$title = FmtPageName('$Name',$pagename);
if ($homepage != '') $wikilog_home_page = $homepage;
if (preg_match('/^(\\d{8})-(.*)/',$title,$event)) {
$title = $event[1]; $subtitle = $event[2];
}
// check to see whether to display a summary only
if (@$subtitle)
return '(:title '.$AsSpacedFunction($subtitle).':)'.
(IsDate($title) ? "
";
if ($display_log_entries==true) {
$l=list_entries(strftime("%m",$itime),
strftime("%Y",$itime),$group);
if ($newest_first) $d = $l.$d; else $d .= $l;
}
// +1 month
// It's actually 30 days which could break if displaying a lot of months
// but it should be ok when displaying only one or two years at a time
$itime=$itime+2592000;
$i++;
if (($i%$calendar_month_wrap==0) && ($i!=12)) $r.="
";
}
$r.="
";
// generate the chrono list
if ($display_log_entries==true) {
$r.= home_link($wikilog_home_page) . "
$d
";
if ($enable_publish) {
$r.= '(:publishcalendar:)'."\n";
$PublishCalendarFmt = str_replace(array('$Month','$Year'),
array($month,$year), $PublishCalendarFmt);
}
}
// translate the page title
if (IsDate($title)) {
$r.= set_page_title($title) . "
" . longdate($title) . "
";
}
return "$r";
}
function set_page_title($title) {
global $SpaceDateString;
return '(:title '.
preg_replace('/(..)(..)$/',"$SpaceDateString$1$SpaceDateString$2",$title).':)';
}
function view_calendar_list($pagename,$homegroup,$hometitle) {
global $calendar_months_start, $calendar_months_number, $enable_publish;
global $wikilog_home_page, $logdate, $PublishCalendarFmt, $newest_first;
if ($hometitle=='') $hometitle = $homegroup;
$hometitle = "$homegroup/$hometitle";
// start configured number of months before/ahead
$startingdate = $logdate."16";
if (IsDate($startingdate)) {
$year = substr($startingdate,0,4);
$month= substr($startingdate,4,2);
} else {
$year = date("Y");
$month= date("m");
}
$startingtime = mktime(0,0,0,$month,16,$year);
// generate the calendar navigation bar
$r = calendar_nav_bar($pagename,$startingtime);
// generate the calendar
$itime=$startingtime+$calendar_months_start*2592000;
$i=0;
$d="";
while ($i<$calendar_months_number) {
$l=list_entries(strftime("%m",$itime),strftime("%Y",$itime),
$homegroup);
if ($newest_first) $d = $l.$d; else $d .= $l;
// +1 month
// It's actually 30 days which could break if displaying a lot of months
// but it should be ok when displaying only one or two years at a time
$itime=$itime+2592000;
$i++;
}
// generate the chrono list
$r.= home_link($hometitle) . "