-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar.php
108 lines (96 loc) · 3.17 KB
/
calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<html>
<head>
<title>Calendar</title>
<style type="text/css">
a { text-decoration: none; }
table { font-family: verdana, sans-serif; border: 1px solid #ccc; border-collapse: collapse; font-size: 9px; color: #666; width: 600px; }
th { border: 1px solid #ccc; font-size: 9px; color: #666; }
tr { border: 1px solid #ccc; font-size: 9px; color: #666; }
td { border: 1px solid #ccc; font-size: 9px; color: #666; height: 65px; vertical-align: top; width: 14.28%; }
.spacerdays { background-color: #ccc; }
.dayHeading { background-color: #00f; color: #fff; }
.headerTitle { font-size: 14px; color: #99f; background-color: #fff; }
.headerString { font-size: 11px; color: #fff; background-color: #333; }
.dayContent { color: #00f; font-size: 9px; background-color: #ddd; margin: 2px; }
.currentDay { background-color: #fdd; }
.weekendDay { background-color: #eee; }
</style>
</head>
<body>
<?php
require_once('calendar.class.inc.php');
/**
* Ideally this information would come from a DB, but the $content array below is laid
* out in a fashion that should be very similar to what a query result would be like.
*/
$content = array(
array(
'id' => '1',
'date' => '2006-02-11',
'text' => 'This is a nice item on Jan 11, 2006',
'desc' => 'This is a really long description that gets used to describe the item we\'re showing here blah blah blah blah',
'cat' => 'Announcement',
'catcolor' => '#ccf'
),
array(
'id' => '2',
'date' => '2006-05-15',
'text' => 'Hurray for birds on Jan 22, 2006!',
'desc' => 'This is a really long description that gets used to describe the item we\'re showing here blah blah blah blah'
),
array(
'id' => '3',
'date' => '2006-02-21',
'text' => 'Another entry to fill up space.',
'desc' => 'This is a really long description that gets used to describe the item we\'re showing here blah blah blah blah',
'cat' => 'Event',
'catcolor' => '#fcc'
)
);
/**
* Set year and/or month to display calendar for. If either are set from the URL
* use the custom date, otherwise default to the current year and/or month.
*/
$year = (isset($_GET['y']) ? $_GET['y'] : null);
$month = (isset($_GET['m']) ? $_GET['m'] : null);
/**
* Instantiate the PHP Calendar Class
*/
$cal = new Calendar($year,$month);
/**
* Set the Calendar title bar contents
*/
$cal->setTitle('This is my Calendar!');
/**
* Loop through the records contained in the DB results or array contents. Events
* can also be added manually by running this method for each event to be added.
*/
foreach($content as $k => $v) {
$cal->setEvents($v['id'],$v['date'],$v['text'],$v['desc'],$v['cat'],$v['catcolor'],false,'destination.php');
}
/**
* Toggle showing the weekday numbers on
*/
$cal->setShowWeekDayNum(true);
/**
* Toggle adding an "Add Event" link to each day
*/
$cal->setAddEvt('addevent.php');
/**
* Output the HTML to draw the calendar.
*/
$cal->drawHTML();
/**
* Output the calendar as an array
*/
//echo "<hr />\n<pre>\n";
//print_r($cal->drawArray());
//echo "</pre>\n";
?>
<!-- The following block simply displays the source code for review purposes -->
<hr />
<h1>Source Code</h1>
<?php highlight_file(__FILE__); ?>
<!-- END show source code block -->
</body>
</html>