示例#1
0
    // walk the array and construct URLs
    // The encoded URL value is actually "artist name|album title". The artist
    // name is included to ensure that albums with the same name are not
    // conflated and the pipe character is a delimiter
    array_walk($list, function (&$v, $k) {
        $v = array('name' => $v, 'url' => '/genre/' . Music::encode($v) . '/artist');
    });
    return ListPage::render('Genres', null, false, false, $list);
});
//		genre/1/artist 	- list of artists for genre=1
//
$klein->respond('GET', '/genre/[:genre]/artist', function ($request, $response) {
    // get the parameter
    $genre = Music::decode($request->param('genre'));
    // get the list
    $list = Genre::getArtists($genre);
    // walk the array and construct URLs
    // The encoded URL value is actually "artist name|album title". The artist
    // name is included to ensure that albums with the same name are not
    // conflated and the pipe character is a delimiter
    array_walk($list, function (&$v, $k) use($genre) {
        $v = array('name' => $v['artist'], 'url' => '/genre/' . Music::encode($genre) . '/artist/' . Music::encode($v['artist']) . '/album');
    });
    // build the "previous" link data
    $previous = array('path' => '/genre', 'text' => 'Genres');
    return ListPage::render($genre, $previous, false, false, $list);
});
//		genre/1/artist/2/album 	- list of albums for genre=1, artist=2
//
$klein->respond('GET', '/genre/[:genre]/artist/[:artist]/album', function ($request, $response) {
    // get the parameter