<html>
<body>
<?php
function mkCalendar($month, $year, $events)
{
$darr = array("Monday"=>"1","Tuesday"=>"2","Wednesday"=>"3","Thursday"=>"4","Friday"=>"5","Saturday"=>"6","Sunday"=>"7");
$marr = array("January"=>"Januar","February"=>"Februar","March"=>"März","April"=>"April","May"=>"Mai","June"=>"Juni","July"=>"Juli","August"=>"August","September"=>"September","October"=>"Oktober","November"=>"November","December"=>"Dezember");
$foo = $darr[date("l", mktime(date("H"), date("i"), date("s"), $month, 01, $year))];
$ts = mktime(0, 0, 0, $month, 01, $year);
for($x = 1;$x < $foo;$x++)
{
$leer .= "<td></td>";
}
$Cal .= "<table cellspacing='1' cellpadding='0' width='150px' height='110px' style='font-family: verdana; font-size:9px;'>";
$Cal .= "<tr><th bgColor='#DFE4EF' colspan='7' align='center'><b>".$marr[date("F", $ts)]." ".date('Y', $ts)."</b></th></tr>";
$Cal .= "<tr>";
$Cal .= "<td><b>Mo</b></td>";
$Cal .= "<td><b>Di</b></td>";
$Cal .= "<td><b>Mi</b></td>";
$Cal .= "<td><b>Do</b></td>";
$Cal .= "<td><b>Fr</b></td>";
$Cal .= "<td><b>Sa</b></td>";
$Cal .= "<td><b>So</b></td>";
$Cal .= "</tr>";
$Cal .= "<tr>";
$y = 0; $y = $y + $foo;
$Cal .= $leer;
$br = 0;
for($x = 1; $x <= date("t", $ts);$x++)
{
if($y % 7 == 1)
{
$Cal .= "</tr><tr>";
$br++;
}
//DEFAULT, KEIN EINTRAG
//Hier werden Samstage und Sonntage mit einem anderen background versehen
if(strftime("%A",mktime(date("H"), date("i"), date("s"), $month, $x, $year)) == "Saturday" OR strftime("%A",mktime(0, 0, 0, $month, $x, $year)) == "Sunday"
OR strftime("%A",mktime(date("H"), date("i"), date("s"), $month, $x, $year)) == "Samstag" OR strftime("%A",mktime(0, 0, 0, $month, $x, $year)) == "Sonntag")
{
$bgCol = "bgColor='#cdd8eb'";
}else{
$bgCol = "bgColor='#DFE4EF'";
}
$border = "style='border:0px;'";
if($events[date("Y-m-d", mktime(0, 0, 0, $month, $x, $year))]!= "")
{
$bgCol = "bgColor='#a2a8c7'";
$border = "style='border:0px;'";
$event_hide_ddrivetip = "hideddrivetip()";
$event_show_ddrivetip = "ddrivetip('".$events[date("Y-m-d", mktime(0, 0, 0, $month, $x, $year))]."')";
}else{
$event_hide_ddrivetip = "";
$event_show_ddrivetip = "";
}
if(date("Ymd") == date("Ymd",mktime(0, 0, 0, $month, $x, $year)))
{
$border = "style='border:1px solid #FF0000;'";
}
#$Cal .= "<td ".$bgCol." onMouseOut=\"this.".$bgCol.";hideddrivetip()\" onMouseOver=\"this.bgColor='#769bba';ddrivetip('".$events."')\"; ".$border.">". sprintf("%02d",$x) ."</td>";
$Cal .= "<td ".$bgCol." onMouseOut=\"this.".$bgCol.";".$event_hide_ddrivetip."\" onMouseOver=\"this.bgColor='#769bba';".$event_show_ddrivetip."\"; ".$border.">". sprintf("%02d",$x) ."</td>";
$y++;
}
if($br <= 4) { $Cal .= "<tr><td colspan='7' align='center'> </td></tr>"; }
$Cal .= "</tr></table>";
return $Cal;
}
?>
<style type="text/css">
#dhtmltooltip{
position: absolute;
width: 250px;
border: 1px solid #a1a1a1;
padding: 5px;
background: #006699;
color: white;
visibility: hidden;
z-index: 100;
}
</style>
<div id="dhtmltooltip"></div>
<script type="text/javascript">
/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}
function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
/if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"
//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}
function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
document.onmousemove=positiontip
var clockid=new Array()
var clockidoutside=new Array()
var i_clock=-1
var thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
var thistime = hours+":"+minutes+":"+seconds
function writeclock() {
i_clock++
if (document.all || document.getElementById || document.layers) {
clockid[i_clock]="clock"+i_clock
document.write("<span id='"+clockid[i_clock]+"' style='display:inline;'>"+thistime+"</span>")
}
}
function clockon() {
thistime= new Date()
hours=thistime.getHours()
minutes=thistime.getMinutes()
seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = hours+":"+minutes+":"+seconds
if (document.all) {
for (i=0;i<=clockid.length-1;i++) {
var thisclock=eval(clockid[i])
thisclock.innerHTML=thistime
}
}
if (document.getElementById) {
for (i=0;i<=clockid.length-1;i++) {
document.getElementById(clockid[i]).innerHTML=thistime
}
}
var timer=setTimeout("clockon()",1000)
}
window.onload=clockon
</script>
<?php
//Hier werden einfach alle 13 Tage ein Beispiel Termin erzeugt
for($x = 0; $x <= 62; $x++ ){
if(($x % 13) == 1){
$events[date("Y-m-d", mktime(0,0,0,date("m"),$x,date("Y")))] = "<strong>Dynamisch erzeugter Beispiel Termin für diesen ".strftime("%A", strtotime(date("Y-m-d", mktime(0,0,0,date("m"),$x,date("Y")))))."</strong>";
}
}
// mit Aufruf der funktion mkCalendar wird ein Monatskalender ausgeben
echo mkCalendar(date("m"),date("Y"),$events);
echo "<br>";
// mit Aufruf der funktion mkCalendar wird ein Monatskalender ausgeben, hier jedoch durch date("m")+1 der folgende Monat
echo mkCalendar(date("m",mktime(0, 0, 0, date("m")+1, 01, date("Y"))),date("Y",mktime(0, 0, 0, date("m")+1, 01, date("Y"))),$events);
?>
</body>
</html>