function getItem($itemId) { /* $items = array( array(name => "Learning jQuery Mobile - Exercise 4", number => "0_7cprzfhg", qty => "1", taxamt => "0", amt => "1.00", desc => "Learn how to set the viewport on your mobile app", category => "Digital"), array(name => "Laser Cannon", number => "456", qty => "1", taxamt => "0", amt => "1.25", desc => "Lock and load!", category => "Digital")); */ $items = getPlayList(); $returnObj = array(); for ($i = 0; $i < count($items); $i++) { if ($items[$i]['number'] == $itemId) { $returnObj = $items[$i]; } } return $returnObj; }
Flight::redirect($request->referrer); } else { Flight::redirect('http://localhost/php/App/'); } }); Flight::route('GET /album/@id/destroy', function ($id) { $response = json_decode(deleteAlbum($id)); if ($response->stat) { Flight::redirect('http://localhost/php/App/albums'); } else { Flight::redirect('http://localhost/php/App/'); } }); Flight::route('GET /playlist/@id/edit', function ($id) { $request = Flight::request(); $playlist = json_decode(getPlayList($id)); if (!isset($playlist->error)) { Flight::render('editPlayList', array('playlist' => $playlist), 'body_content'); Flight::render('layout', array('Titre' => 'Modifier un track à ' . $playlist[0]->titre)); } else { Flight::redirect($request->referrer); } }); Flight::route('GET /track/@id/edit', function ($id) { $request = Flight::request(); $track = json_decode(getTrack($id)); if (!isset($track->error)) { Flight::render('editTRack', array('track' => $track), 'body_content'); Flight::render('layout', array('Titre' => 'Modifier le track ' . $track[0]->title)); } else { Flight::redirect($request->referrer);
function playList($vid = 0, $plid = 0) { $callback = $_GET["callback"]; $result = array("playList" => getPlayList($vid, $plid)); return $callback . "(" . json_encode($result) . ")"; }