當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ListPage::render方法代碼示例

本文整理匯總了PHP中ListPage::render方法的典型用法代碼示例。如果您正苦於以下問題:PHP ListPage::render方法的具體用法?PHP ListPage::render怎麽用?PHP ListPage::render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ListPage的用法示例。


在下文中一共展示了ListPage::render方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array_walk

    // get the params
    $playlist = Music::decode($request->param('playlist'));
    // get the list of songs
    $list = Playlist::getSongs($playlist);
    // 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($playlist) {
        $v = array('name' => $v['Title'], 'url' => '/playlist/' . Music::encode($playlist) . '/song/' . Music::encode($v['file']));
    });
    // build the "previous" link data
    $previous = array('path' => '/playlist', 'text' => 'Playlists');
    // build the shuffle link
    $shuffle = '/playlist/' . Music::encode($playlist) . '/song/shuffle';
    return ListPage::render($playlist, $previous, $shuffle, false, $list);
});
//		playlist/1/song/2 	- load all songs for playlist=1, start playing song=2, go to nowplaying
//
$klein->respond('GET', '/playlist/[:playlist]/song/[:song]', function ($request, $response) {
    // get the params
    $playlist = Music::decode($request->param('playlist'));
    $song = $request->param('song');
    $song = $song == 'shuffle' ? 'shuffle' : Music::decode($song);
    // clear the playlist
    Music::send('clear');
    // get the list of songs
    $songs = Playlist::getSongs($playlist);
    // load the playlist with the requested songs (and figure out the current
    // song position)
    $pos = 0;
開發者ID:monstergfx,項目名稱:pi-music,代碼行數:31,代碼來源:playlist.php

示例2: list

    // get the artist & album values
    list($artist, $album) = explode('|', Music::decode($request->param('album')));
    // get the list of songs
    $list = Album::getSongs($artist, $album);
    // 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($artist, $album) {
        $v = array('name' => $v['Title'], 'url' => '/album/' . Music::encode($artist . '|' . $album) . '/song/' . Music::encode($v['file']));
    });
    // build the "previous" link data
    $previous = array('path' => '/album', 'text' => 'Albums');
    // build the shuffle link
    $shuffle = '/album/' . Music::encode($artist . '|' . $album) . '/song/shuffle';
    return ListPage::render($album, $previous, $shuffle, false, $list);
});
//		album/1/song/2	- load all songs for album=1, play song=2, go to nowplaying
//
$klein->respond('GET', '/album/[:album]/song/[:song]', function ($request, $response) {
    // get the parameters
    // get the artist & album values
    list($artist, $album) = explode('|', Music::decode($request->param('album')));
    $song = $request->param('song');
    $song = $song == 'shuffle' ? 'shuffle' : Music::decode($song);
    // clear the playlist
    Music::send('clear');
    // get the list of songs
    $songs = Album::getSongs($artist, $album);
    // load the playlist with the requested songs (and figure out the current
    // song position)
開發者ID:monstergfx,項目名稱:pi-music,代碼行數:31,代碼來源:album.php

示例3: array_walk

    // conflated and the pipe character is a delimiter
    array_walk($list, function (&$v, $k) {
        $v = array('name' => $v['Title'], 'url' => '/song/' . Music::encode($v['file']));
    });
    $list = array_filter($list, function ($v) {
        return $v['name'] ? true : false;
    });
    usort($list, function ($a, $b) {
        if (array_key_exists('name', $a) && array_key_exists('name', $b)) {
            return $a['name'] < $b['name'] ? -1 : 1;
        }
        return 0;
    });
    // build the shuffle link
    $shuffle = '/song/shuffle';
    return ListPage::render('Songs', null, $shuffle, false, $list);
});
//		song/1 	- load ALL songs, play song=1, go to nowplaying
//
$klein->respond('GET', '/song/[:song]', function ($request, $response) {
    // get parameter
    $song = $request->param('song');
    $song = $song == 'shuffle' ? 'shuffle' : Music::decode($song);
    // clear the playlist
    Music::send('clear');
    // get the list of songs
    $songs = Song::getList();
    // load the playlist with the requested songs (and figure out the current
    // song position)
    $pos = 0;
    for ($i = 0; $i < count($songs); $i++) {
開發者ID:monstergfx,項目名稱:pi-music,代碼行數:31,代碼來源:song.php


注:本文中的ListPage::render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。