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.

);<br />

)<br />

'object' => 'Calendar',<br />

'method' => 'confirmDelete'<br />

/*<br />

* Make sure the anti-CSRF token was passed <strong>and</strong> that the<br />

* requested action exists in the lookup array<br />

*/<br />

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

{<br />

$use_array = $actions[$_POST['action']];<br />

$obj = new $use_array['object']($dbo);<br />

}<br />

/*<br />

* Check for an ID <strong>and</strong> sanitize it if found<br />

*/<br />

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

{<br />

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

}<br />

else { $id = NULL; }<br />

echo $obj->$use_array['method']($id);<br />

function __autoload($class_name)<br />

{<br />

$filename = '../../../sys/class/class.'<br />

. strtolower($class_name) . '.inc.php';<br />

if ( file_exists($filename) )<br />

{<br />

include_once $filename;<br />

}<br />

}<br />

?><br />

CHAPTER 8 ■ EDITING THE CALENDAR WITH AJAX AND JQUERY<br />

You can test the preceding code <strong>by</strong> deleting the ID Test event from the calendar. After the modal<br />

window fades out, the event title is still present <strong>and</strong> clickable; however, if you try to view the event’s<br />

details, its information is unavailable, <strong>and</strong> it doesn’t make sense (see Figure 8-8).<br />

303

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

Saved successfully!

Ooh no, something went wrong!