当前位置: 首页>>代码示例>>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;未经允许,请勿转载。