<?php
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
require_once( dirname(__FILE__).'/class.Calendar.php' );
/**
* Displays events in a given month.
*
* @author Oscar Merida <oscarAtoscarm.org>
* @created Jan 18 2004
*/
class Calendar_Events extends Calendar
{
    
/**
     * Display links to events for the given day
     */
    
function dspDayCell($day)
    {
        if (
$events $this->getDaysEvents($day))
        {
?>
    <p class="dayNum"><?= $day ?></p>
    <ul>
<?php
        
foreach ($events as $i => $e)
        {
?>      <li><a href="<?= $e['link'?>"><?= $e['title'?></a></li>
<?
        
}
?>  </ul>
<?php
    
}
    else
    {
?>
    <p class="dayNumNoEvents"><?= $day ?></p>
<?php
    
// end if
}

    
/**
    * Adds an event on a day
    *
    * @param string $day
    * @param string $title
    * @param string $url
    * @return null
    * @access public
    */
    
function addEvent($day$title$link '')
    {
        
$this->events[(int) $day][] = array('title' => $title'link' => $link);
    }

    
/**
    * Returns an array of the events on a day.
    *
    * @param integer $day
    * @return array
    * @access private
    */
    
function getDaysEvents($day)
    {
        if (
count($this->events$day ]))
        {
            return 
$this->events[$day];
        }
        else
        {
            return 
FALSE;
        }
    }
// end class
?>