toto je original z http://www.etomite.org/browsesnippets.h ... category=8
ja ho mam na http://www.spzke-mesto.sk
Kód: Vybrať všetko
# Calendar - Calendar for Etomite 0.6 - 2005-01-17
# Created By: Ralph A. Dahlgren - Email: rad14701@yahoo.com
# Usage: Simply customize the Variables & style settings below
# Use [!Calendar!] to call this snippet
# START ---- Variables which can optionally be customized ----- #
# Style Element names are pretty much self-explanatory
#
$day_heading_length = 2; # Size of weekday abbr in calendar (0-4) 4=full day name
$output_style = "background-color:#F0F8FF; border:1px solid black; width:100%";
$month_style = "background-color:#FFDDBB; text-align:center; font-weight:bold";
$day_heading_style = "background-color:#BBF0F0; text-align:center; width:14%";
$day_style = "text-align:right; border:1px solid #F0F8FF";
$today_style = "color:red; background-color:#EAEAEA; text-align:right;";
$blogday_style = "color:green; background-color:#EAEAEA; text-align:right; font-weight:bold; border:1px solid red";
$empty_day_style = "";
#
# END ---- Variables 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
$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
# 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
# Generate Calendar
$output = "<table style='$output_style'>\n"; # Begin actual calendar generation
$output .= "<tr><th colspan='1' style='$month_style'>\n"; # Create previous month link
$output .= "<a href='[~".$etomite->documentObject[id]."~]&Ym=$lastmonth'>&laq"."uo;</a>\n"; # Use << for link
$output .= "</th>\n";
$output .= "<th colspan='5' style='$month_style'>\n"; # Display calendar month and year
$output .= "$month_name, $year";
$output .= "</th>\n";
$output .= "<th colspan='1' style='$month_style'>\n"; # Create next month link
$output .= "<a href='[~".$etomite->documentObject[id]."~]&Ym=$nextmonth'>&raq"."uo;</a>\n"; # Use >> for link
$output .= "</th></tr>\n";
$output .= "<tr>\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;
$output .= "<th style='$day_heading_style' abbr='$day_heading'>$d</th>\n";
}
$output .= "</tr>\n<tr>\n"; # Close weekday heading and prepare to print days
}
# Take care of the first "empty" days of the month
if($weekday > 0) $output .= "<td style='$empty_day_style' colspan='$weekday'> </td>\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
$output .= "</tr>\n<tr>\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);
$output .="<td><div style='$day_style'>\n"; # Use style formatting of days
# If the day is today, give it special style formatting
if ($day==$today) $output .= "<b style='$today_style'>$day</b>\n";
else $output .= "$day"; # Otherwise just display the day
# Close up the style formatting of days
$output .="</div></td>\n";
$day++; $weekday++; # Goto the next day and weekday
}
# Take care of the remaining "empty" days of the month
if($weekday != 7) $output .= "<td style='$empty_day_style' colspan='".(7-$weekday)."'> </td>\n";
# Close the calendar and finish
$output .="</tr>\n</table>\n";
return $output;