PHP Classes

File: calendar_sample.php

Recommend this page to a friend!
  Classes of Marc Antony Vose   SSCalendar   calendar_sample.php   Download  
File: calendar_sample.php
Role: Example script
Content type: text/plain
Description: a sample implementation
Class: SSCalendar
Dynamic Calendar Generator
Author: By
Last change:
Date: 22 years ago
Size: 3,694 bytes
 

Contents

Class file image Download
<?php

if( !class_exists(SScalendar) ){
    include(
"ss_calendar.php");
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Calendar Test</title>
    <meta name="generator" content="BBEdit 6.5.2" />


<style type="text/css">

p {
    font-family: verdana,sans-serif;
    font-size: 10px;
}


}

<?php include("calendar_styles.php"); ?>

</style>



</head>
<body>

<?php

if( !isset($ss_date) ){
   
$ss_date = "2002-05-14";
}

?>

<p>
<b>SSCalendar() sample page</b>
<br />
Refer to the PHP source to see a complete explanation of what's going on here.
</p>

<p>
Here's the default calendar. As you can see, two lines of code allows you to spit out a reference calendar, with today selected. Here, if you step from one month to the next, it doesn't handle the data passed, so the date doesn't change.
</p>


<?php

// spit out the default calendar.

$this_cal = new SScalendar();
$this_cal->spewSmallMonthView();
?>

<p>
This next calendar does handle the date, and I've specified a number of dates which are "hot". (<b>Note</b>: the dates are only hot in May 2002. If your script was also set to select data out of a database with each load, you'd be able to set up different dates in different months.)
</p>

<p>
(From here down, I have hard-coded the default date as May 14, 2002, so I can illustrate some things. Bit the SScalendar class will select the current date by default normally if you don't select a date.)
</p>


<?php


// this is an array of the dates that will be hot in the calendar

$cal_data = array();
$cal_data[] = "2002-05-24";
$cal_data[] = "2002-05-06";
$cal_data[] = "2002-05-5";
$cal_data[] = "2002-05-14";
$cal_data[] = "2002-05-13";
$cal_data[] = "2002-05-29";
$cal_data[] = "2002-05-01";
$cal_data[] = "2002-05-3";
$cal_data[] = "2002-05-19";


$this_cal->specifySmallMonthHotDates($cal_data);
if( isset(
$ss_date) ){
   
$this_cal->specifyCurrentDate($ss_date);
}
$this_cal->spewSmallMonthView();

?>

<p>
Let's now spit out that exact same calendar in German.
</p>

<?php


$this_cal
->specifyLanguage("de");
$this_cal->spewSmallMonthView();

?>




<p>
Here's the default large calendar, in Spanish. Note the special accent characters; they should be specified in your day_names string as the HTML entity, like "&amp;#233;". The class will automatically take that into account when it abbreviates the string.
</p>

<?php

$this_cal
->specifyLanguage("es");
$this_cal->spewLargeMonthView();
?>

<p>
Finally, we present the calendar in French. Maybe the inline data for the month of May 2002 are your travel plans.
</p>


<?php


// test array for populating calendar

$cal_data = array();

$cal_data["2002-05-04"] = array();
array_push($cal_data["2002-05-04"],
    array(
"item_text"=>"New York City",
       
"item_url"=>"http://www.nyc.ny.us/")
);
array_push($cal_data["2002-05-04"],
    array(
"item_text"=>"Brooklyn",
       
"item_url"=>"")
);

$cal_data["2002-05-11"] = array();
array_push($cal_data["2002-05-11"],
    array(
"item_text"=>"Paris",
       
"item_url"=>"http://www.paris.fr/")
);

$cal_data["2002-05-19"] = array();
array_push($cal_data["2002-05-19"],
    array(
"item_text"=>"Anchorage, Alaska",
       
"item_url"=>"http://www.anchorage.ak.us/")
);

$this_cal->specifyLargeMonthHotDates($cal_data);
if( isset(
$ss_date) ){
   
$this_cal->specifyCurrentDate($ss_date);
}
$this_cal->specifyLanguage("fr");
$this_cal->spewLargeMonthView();

?>



</body>
</html>