defaults to current group; set specific default blog group name, i.e. 'BlogPages' SDV($BlogCal['pastonly'], 0); //show link to future months; set to 1 for showing only link to past month. //daynames are set automatically according to locale, but could be set manually with this array #SDVA($BlogCal['daynames'], array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")); //daynames array //Added by XES SDV($BlogCal['multimessage'], 'posts found:'); //message appended to number if multiple entries are found on a given date SDV($BlogCal['multimessagefmt'], 'titlespaced'); // which pagelist format to use for the results //search path for blogcal.css file, if any if (!isset($FarmPubDirUrl)) $FarmPubDirUrl = $PubDirUrl; SDV($BlogCalendarPubListFmt, array ( "pub/blogcal/blogcal.css" => "$PubDirUrl/blogcal/blogcal.css", "$FarmD/pub/blogcal/blogcal.css" => "$FarmPubDirUrl/blogcal/blogcal.css" )); // load table styles for blog calendar foreach((array)$BlogCalendarPubListFmt as $k=>$v) { if (file_exists(FmtPageName($k,$pagename))) { $HTMLHeaderFmt['blogcal'][] = "\n"; break; } else //in HTML head css styling of blogcal table, used if no stylesheet is found SDV($HTMLStylesFmt['blogcal'], " table.bcal { margin:0 0.5em; padding:0; font-size:90%; } table.bcal caption { text-align:center; font-weight:bold; padding:5px 0 2px 0; } table.bcal caption a { text-decoration:none; } table.bcal th { width:2em; border-top:1px dotted #999; border-bottom:1px dotted #999; font-weight:normal; font-size:.75em; } table.bcal td { margin:0; padding:1px 1px 1px 0; text-align:center; font-size:0.85em; line-height:1.2em; } td.bcal-daynames { text-align:center; color:#333; font-size:.75em; } td.bcal-blank {} td.bcal-today { background-color:#ffff00; color: #000000; } td.bcal-day { color: #333; } a.bcal-link { text-decoration:none; font-weight:bold; } td.bcal-link {background-color:#bbddff; color: #000000; } td.bcal-linktoday { background-color: #ffcc00; color: #000000; } "); } //set abbreviated day names if (!is_array($BlogCal['daynames'])) for ($i=1; $i<=7; $i++) $BlogCal['daynames'][$i-1] = strftime("%a",mktime(0,0,0,6,$i,2008)); //2008-06-01 was a Sunday //markup and function Markup('bcal','directives','/\\(:blogcal\\s*(.*?):\\)/e', "BlogCalendarFmt(\$pagename, PSS('$1'))"); function BlogCalendarFmt($pagename, $args) { global $ScriptUrl, $EnablePathInfo, $BlogCal; $req = RequestArgs(); $args = ParseArgs($args); $args = array_merge($req, $args); #echo "
\$args "; print_r($args); echo "
"; // Determine this Group $group = PageVar($pagename, '$Group'); $name = PageVar($pagename, '$Name'); $PageUrl = ($EnablePathInfo) ? $ScriptUrl.'/'.$group.'/'.$name : $ScriptUrl.'?n='.$group.'.'.$name; if (isset($args['group'])) $defaultgroup = $args['group']; elseif ($BlogCal['defaultgroup']!='0') $defaultgroup = $BlogCal['defaultgroup']; else $defaultgroup = $group; // What is today? $tyear = date("Y"); $tmonth = date("m"); $tday = date("d"); $year = isset($args['year']) ? $args['year'] : $tyear; $month = isset($args['month']) ? $args['month'] : $tmonth; $day = isset($args['day']) ? $args['day'] : $tday; $month = isset($args['shift']) ? $month + $args['shift'] : $month; $prev_month = ($month>1) ? sprintf("%02.0f",$month-1) : 12; $prev_year = ($month>1) ? $year : $year - '01'; $next_month = ($month<12) ? sprintf("%02.0f",$month+1) : '01'; $next_year = ($month<12) ? $year : $year + 1; $itime = mktime(0,0,0,$month,16,$year); // day 16, i.e. in the middle; $iyear = strftime("%Y",$itime); $imonth = strftime("%m",$itime); $monthname = strftime("%B %Y",$itime); // Monthname YYYY static $cnt=0; $cnt++; //output blogcal table $out = "\n"; $prev = "«"; $next = "»"; $pastonly = (isset($args['pastonly'])) ? 1 : $BlogCal['pastonly']; if ($pastonly==1 && $next_month>$tmonth) $next = ''; if(isset($args['shift'])) $out.= ""; else $out.= ""; $maxdays = date("t",mktime(0,0,0,$month,1,$year)); $weekdaystart = date('w',mktime(0,0,0,$month,1,$year)); // weekstart should be from 0 to 6. // also from PmCal $BlogCal['weekstart'] = abs($BlogCal['weekstart']) % 7; if ($BlogCal['weekstart']>=1 && $weekdaystart==0) $weekdaystart = 7; //make table header cells (weekday names) $out.="\n "; for ($i=0; $i<7; $i++) { $d = ($i + $BlogCal['weekstart']) % 7; $out.= ""; } $out .= " "; $base = (isset($args['base'])) ? $args['base'] : $BlogCal['basename']; $sep = '-'; if (isset($args['isobasic']) || $BlogCal['isobasic']==1) $sep = ''; for ($index =($BlogCal['weekstart'] - $weekdaystart); $index < $maxdays; ) { $out.="\n "; //make table cells (day numbers) for ($i=0; $i<7; $i++, $index++) { $daynum = $index+1; $tooltip = ""; $pages = array(); $class = 'bcal-day'; //set default class //empty cells: the day doesn't exist if ($index<0 || $index >= $maxdays) $out.=""; //normal cal cell else { $paddeddaynum = ($daynum<10) ? "0".$daynum : $daynum; $pname = $base.$iyear.$sep.$imonth.$sep.$paddeddaynum; $pname = MakePageName($pagename, $defaultgroup.".".$pname); // -- Added by Criss -- Determine whether there are any subpages with that date $pages = ListPages('/^' . preg_quote($pname,'/') . '.*/'); $count = count($pages); if ($count > 0) { //log page link cell $class = 'bcal-link'; // Test for today, change class if ($tyear==$year && $tmonth==$month && $tday==$daynum) $class = 'bcal-linktoday'; // Build tooltips to list each page foreach ($pages as $thispage) { if (isset($args['tooltip'])) { if ($args['tooltip']=='description' || $args['tooltip']=='Description') $tooltip .= PageVar($thispage,'$Description') . "\n"; else $tooltip .= PageTextVar($thispage,$args['tooltip']) . "\n"; } else $tooltip .= PageVar($thispage,'$Titlespaced') . "\n"; } // If there's more than one, prepend different format, and have different output... if ($count > 1 ) { $tooltip = "$count " . $BlogCal['multimessage'] . "\n" . substr($tooltip, 0, -1) ; //strip the last newline // ?action=search&q=name%3DBlog%2F20140102*+fmt%3D%23titlespaced $out .= ""; } else { if (isset($args['tooltip'])) { if ($args['tooltip']=='description' || $args['tooltip']=='Description') $tooltip = PageVar($pages[0],'$Description'); else $tooltip = PageTextVar($pages[0],$args['tooltip']); } else $tooltip = PageVar($pages[0],'$Titlespaced'); $out .= ""; } } else { //today cell if ($tyear==$year && $tmonth==$month && $tday==$daynum) $class = 'bcal-today'; $out.=""; } } } $out .= " "; } $out.= "\n

$monthname

$prev $monthname $next
{$BlogCal['daynames'][$d]}
 $daynum$daynum$daynum
\n"; return Keep($out); } // }}}