# START ---- Variables You Should Change ----- # # $resourceparent = 44; # ID of Folder for processing () $day_heading_length = 2; # Size of weekday abbr in calendar (0-4) 4=full day name # # END ---- Variables You Should Change ----- # # START ---- CSS elements which can optionally be customized ----- # # Element names are pretty much self-explanatory # $calendar_css = "background:#e4f2ff; /*background-color: #ffffdd;*/ width:100%;"; $month_css = "background-image: url(assets/templates/light/images/header.gif); background-repeat: repeat-x; text-align:center; font-weight:bold"; $day_heading_css = "background-image: url(assets/templates/light/images/header.gif); background-repeat: repeat-x; text-align:center; width:14%"; $day_css = "text-align:center; border:1px solid #F0F8FF; height=55px;"; $today_css = "color: red; background-color:#EAEAEA; text-align:center; font-weight:bold; border:1px solid red;"; $blogday_css = "color:#003799; background-color:#EAEAEA; text-align:center; font-weight:bold; border:1px solid #003799;"; $empty_day_css = ""; # # END ---- CSS elements which can optionally be customized ----- # # ----- You should not need to modify code below this point ----- # # # Calculate required time & date related variables # $time = time(); # Grab the current timestamp $blogdate=$_GET['blogdate']; # Assign $blogdate variable if sent if($blogdate != "") $Ym=$blogdate; # If $blogdate sent, use it for $Ym else $Ym=$_GET['Ym']; # Else extract $Ym variable if sent if($Ym != "") { # If $Ym exists, get $year and $month $year=substr($Ym, 0, 4); # Get year part $month=substr($Ym, 4, 2); # Get month part } else { # If $Ym is empty, assign variables from current date $year=date('Y', $time); $month=date('m', $time); $today=date('j', $time); } if(($month == date('m', $time)) && ($year == date('Y', $time))) { $today=date('j', $time); # If this month and this year, assign $today } $first_of_month = mktime(0,0,0,$month,1,$year); # Always start with current month $lastmonth = strftime("%Y%m%d",mktime(0,0,0,$month-1,1,$year)); # Previous month $nextmonth = strftime("%Y%m%d",mktime(0,0,0,$month+1,1,$year)); # Next month # Query for dates of documents which were published this month $tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix']; $site_content = $tbl."site_content"; # DB.Prefix_Table Variable $resource = $etomite->getAllChildren($resourceparent, 'alias', 'ASC', $fields='id, longtitle, alias, createdby'); $limit=count($resource); $datelist = array(); for ($y = 0; $y < $limit; $y++) { $value = $resource[$y]['alias']; $othervalue = $resource[$y]['longtitle']; $datelist[]= $value; $aliaslist[$value]= $othervalue; $idlist[$value]= $resource[$y]['id']; } # Generate all the day headings according to the current locale $day_headings = array(); for($n=0,$t=3*86400; $n<7; $n++,$t+=86400) # January 4, 1970 was a Sunday $day_headings[$n] = gmstrftime('%A',$t); # %A means full textual day name $day_headings = array_map('ucfirst',$day_headings); # Some locales don't capitalize day names list($month, $year, $month_name, $weekday) = explode(',',strftime('%m,%Y,%B,%w',$first_of_month)); # $weekday %= 7; # strftime gives Monday as 1, Sunday as 7. Adjust so Sunday is 0 $month_name = ucfirst($month_name); # Some locales don't capitalize month names $maxdays = date('t', $first_of_month); # Number of days in the month $day = 1; # starting day of the month $BC_Calendar = "\n"; # Begin actual calendar generation $BC_Calendar .= "\n"; $BC_Calendar .= "\n"; $BC_Calendar .= "\n"; $BC_Calendar .= "\n"; # Display weekday heading abbreviations if($day_heading_length > 0 and $day_heading_length <= 4){ # if day_heading_length is allowed value # if day_heading_length is 4, the full name of the day will be printed # otherwise, just the first n characters foreach($day_headings as $day_heading){ $d = ($day_heading_length != 4) ? substr($day_heading,0,$day_heading_length) : $day_heading; $BC_Calendar .= "\n"; } $BC_Calendar .= "\n\n"; # Close weekday heading and prepare to print days } # Take care of the first "empty" days of the month if($weekday > 0) $BC_Calendar .= "\n"; # Print all days of the month while($day <= $maxdays){ if($weekday == 7){ # Start a new week - end table row and start a new one $BC_Calendar .= "\n\n"; $weekday = 0; } # Create the $Ymd variable to compare against the list of days with content $Ymd = $year.$month.str_pad($day,2,"0", STR_PAD_LEFT); $this_day = ""; $this_css = $day_css; # If a day has content documents associated with it, create a link to the appropriate blog if(in_array($Ymd,$datelist)){ $this_css .= " ".$blogday_css; } # If the day is today, give it special CSS formatting if ($day==$today){ $this_day .= $day; $this_day .=""; $this_day .=""; $this_css .= " ".$today_css; } else {$this_day .= "$day"; $this_day .=""; $this_day .="";} # Otherwise just display the day $BC_Calendar .="\n"; $day++; $weekday++; # Goto the next day and weekday } # Take care of the remaining "empty" days of the month if($weekday != 7) $BC_Calendar .= "\n"; # Close the calendar and finish $BC_Calendar .="\n
\n"; # Create previous month link $BC_Calendar .= "&laq"."uo;\n"; # Use << for link $BC_Calendar .= "\n"; # Display calendar month and year $BC_Calendar .= "$month_name, $year"; $BC_Calendar .= "\n"; # Create next month link $BC_Calendar .= "&raq"."uo;\n"; # Use >> for link $BC_Calendar .= "
$d
".$this_day; # Use CSS formatting of days # Close up the hyperlink to the blog if(in_array($Ymd,$datelist)) $BC_Calendar .= "\n".$aliaslist[$Ymd]."";# # Close up the CSS formatting of days $BC_Calendar .="
\n"; return $BC_Calendar; # # END of Code #