02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

private $_daysInMonth;<br />

private $_startDay;<br />

public function __construct($dbo=NULL, $useDate=NULL) {...}<br />

public function buildCalendar() {...}<br />

/**<br />

* Displays a given event's information<br />

*<br />

* @param int $id the event ID<br />

* @return string basic markup to display the event info<br />

*/<br />

public function displayEvent($id)<br />

{<br />

/*<br />

* Make sure an ID was passed<br />

*/<br />

if ( empty($id) ) { return NULL; }<br />

}<br />

/*<br />

* Make sure the ID is an integer<br />

*/<br />

$id = preg_replace('/[^0-9]/', '', $id);<br />

/*<br />

* Load the event data from the DB<br />

*/<br />

$event = $this->_loadEventById($id);<br />

/*<br />

* Generate strings for the date, start, <strong>and</strong> end time<br />

*/<br />

$ts = strtotime($event->start);<br />

$date = date('F d, Y', $ts);<br />

$start = date('g:ia', $ts);<br />

$end = date('g:ia', strtotime($event->end));<br />

/*<br />

* Generate <strong>and</strong> return the markup<br />

*/<br />

return "$event->title"<br />

. "\n\t$date, $start&mdash;$end"<br />

. "\n\t$event->description";<br />

private function _loadEventData($id=NULL) {...}<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

163

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!