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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

168<br />

CHAPTER 5 ■ ADD CONTROLS TO CREATE, EDIT, AND DELETE EVENTS<br />

private $_y;<br />

private $_daysInMonth;<br />

private $_startDay;<br />

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

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

public function displayEvent($id) {...}<br />

/**<br />

* Generates a form to edit or create events<br />

*<br />

* @return string the HTML markup for the editing form<br />

*/<br />

public function displayForm()<br />

{<br />

/*<br />

* Check if an ID was passed<br />

*/<br />

if ( isset($_POST['event_id']) )<br />

{<br />

$id = (int) $_POST['event_id'];<br />

// Force integer type to sanitize data<br />

}<br />

else<br />

{<br />

$id = NULL;<br />

}<br />

/*<br />

* Instantiate the headline/submit button text<br />

*/<br />

$submit = "Create a New Event";<br />

/*<br />

* If an ID is passed, loads the associated event<br />

*/<br />

if ( !empty($id) )<br />

{<br />

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

/*<br />

* If no object is returned, return NULL<br />

*/<br />

if ( !is_object($event) ) { return NULL; }<br />

$submit = "Edit This Event";

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

Saved successfully!

Ooh no, something went wrong!