Login   Register  
PHP Classes
elePHPant
Icontem

File: test_calendar.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Manuel Lemos  >  Calendar generation class  >  test_calendar.php  >  Download  
File: test_calendar.php
Role: Example script
Content type: text/plain
Description: Example script that demonstrates how to use and customize the calendar output
Class: Calendar generation class
Calendar month HTML table generator.
Author: By
Last change: Set the file role.
Date: 11 years ago
Size: 2,580 bytes
 

Contents

Class file image Download
<?
/*
 * test_calendar.html
 *
 * @(#) $Header: /cvsroot/PHPlibrary/test_calendar.html,v 1.2 2000/12/03 23:01:53 mlemos Exp $
 *
 */

?><html>
<head>
<title>Test for Manuel Lemos' PHP calendar class</title>
</head>
<body>
<h1><center>Test for Manuel Lemos' PHP calendar class</center></h1>
<hr />
<?

/*
 * Include table and calendar class code.
 */
 
require("tableclass.php");
 require(
"calendarclass.php");

/*
 * Define a subclass of the calendar class to customise any output aspects.
 */
class my_calendar_class extends calendar_class
{
 var 
$this_year=0;
 var 
$this_month=0;
 var 
$this_day=0;
 var 
$days_highlight="#DDDD00";
 var 
$today_highlight="#00DDDD";

 Function 
fetchcustomcolumn(&$columndata)
 {
  if(
$this->day>0)
   
$columndata["backgroundcolor"]=($this->year==$this->this_year && $this->month==$this->this_month && $this->day==$this->this_day $this->today_highlight $this->days_highlight);
  return 
1;
 }
};

/*
 * Create a calendar object.
 */
 
$calendar=new my_calendar_class;

/*
 * Set the year and the month to display.
 */
 
$calendar->this_year=intval(Date("Y"));
 
$calendar->this_month=intval(Date("n"));
 
$calendar->this_day=intval(Date("j"));
 
$calendar->year=((IsSet($year) && !strcmp(intval($year),$year) && $year>0) ? $year $calendar->this_year);
 
$calendar->month=((IsSet($month) && !strcmp(intval($month),$month) && $month>=&& $month<=12) ? $month $calendar->this_month);

 
$months=array(
  
"January",
  
"February",
  
"March",
  
"April",
  
"May",
  
"June",
  
"July",
  
"August",
  
"September",
  
"October",
  
"November",
  
"December"
 
);

 echo 
"<h1><center>".$months[$calendar->month-1]." ".$calendar->year."</center></h1>\n";

/*
 * Output the calendar display using the function named Output.
 */
 
echo $calendar->outputcalendar();

 echo 
"<p><center>";
 if(
$calendar->month>1)
  echo 
"<a href=\"".$PHP_SELF."?year=".$calendar->year."&month=".($calendar->month-1)."\">&lt;&lt; ".$months[$calendar->month-2]."</a> ";
 if(
$calendar->month<12)
  echo 
"<a href=\"".$PHP_SELF."?year=".$calendar->year."&month=".($calendar->month+1)."\">".$months[$calendar->month]." &gt;&gt;</a> ";
 echo 
"</center></p>\n<p><center>";
 if(
$calendar->year>=1)
  echo 
"<a href=\"".$PHP_SELF."?year=".($calendar->year-1)."&month=".$calendar->month."\">&lt;&lt; ".($calendar->year-1)."</a> ";
 echo 
"<a href=\"".$PHP_SELF."?year=".($calendar->year+1)."&month=".$calendar->month."\">".($calendar->year+1)." &gt;&gt;</a>";
 echo 
"</center></p>\n";
?>
<hr />
</body>
</html>