/ Published in: PHP

Expand |
Embed | Plain Text
/** * Event Calendar Class * * This class enables the creation of event calendar * * @author Alex Glover <[email protected]> */ class EventCalendar { var $CI; var $show_next_prev = TRUE; var $next_prev_url = ''; var $day_url = ''; var $events_url = ''; /** * Constructor * * @access public */ $this->initialize($config); } } /** * Initializes the configuration * * @access public * @param array config array * @return void */ { foreach ($config as $key => $val) { { $this->$key = $val; } } } /** * Generates the event calendar * * @access public * @param array config array * @param array events data array * @return void */ function generate($config = NULL, $events = NULL) { $date = $config['month'] . ' ' . $config['year']; //Tests if the offset is set, which is how many months away from current month the calendar is displaying $offset = $config['offset']; $prev = $offset - 1; $next = $offset + 1; } else { $prev = -1; $next = 1; } //prints the calendar name and navigation arrows echo '<span id="calendar-month">'; echo anchor($this->next_prev_url . $prev . "#calendar-month", '<img src="'.base_url().'assets/images/calendar-left.png" id="calendar-left" class="calendar-nav"/>', 'rel="nofollow"') . date('F Y', strtotime($date)) . anchor($this->next_prev_url . $next . '#calendar-month', '<img src="'.base_url().'assets/images/calendar-right.png" id="calendar-right" class="calendar-nav"/>', 'rel="nofollow"') . '</span>'; echo ' <table cellpadding="0" cellspacing="0" border="1" class="volunteer-calendar"> <thead> <tr> <th>Sunday</th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> </tr> </thead> <tbody>'; $first = $this->getFirstWeekDay($config['month'] . $config['year']); $total_days = $this->getTotalDaysinMonth($date); $count = 0; echo '<tr>'; //displays empty days while($count < $first) { $count++; } //count used to display the date $day_count = 1; //loops through as long as day_countis less than the last day of the month while($day_count <= $total_days) { $class = ''; //if there are events on the specific day $print_events = '<ul class="events">' . $daily_events . '</ul>'; } $class .= 'today'; } //displays the day's number on the calendar $print_events . '</td>'; if($count == 6) { $count = -1; echo '<tr>'; } $day_count++; $count++; } while($count <= 6) { $count++; } echo '</tr>'; echo '</tbody>'; echo '</table>'; } /** * Gets the first day of the month in week number format (0-7 returned) * * @access public * @param date */ function getFirstWeekDay($date) { } /** * Gets the total number of days in the given month * * @access public * @param date */ function getTotalDaysinMonth($date) { } /** * Gets the events from the events array that match the given date * * @access public * @param String date * @param array events * @return String */ function getDailyEvents($date, $events) { $theevents = ''; foreach($events as $event) { $theevents .= '<li>' . anchor($this->events_url . $event->id, $event->title , 'rel="nofollow"') . '</li>'; } } } return $theevents; } } ?>
You need to login to post a comment.