当前位置: 首页>>代码示例>>PHP>>正文


PHP Playlist::all方法代码示例

本文整理汇总了PHP中Playlist::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Playlist::all方法的具体用法?PHP Playlist::all怎么用?PHP Playlist::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Playlist的用法示例。


在下文中一共展示了Playlist::all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index($request)
 {
     if (Session::isActive()) {
         $data = array();
         $data['currentPageTitle'] = 'Playlists';
         $data['playlists'] = array();
         $data['channels'] = Session::get()->getOwnedChannels();
         foreach ($data['channels'] as $chan) {
             $data['playlists'][$chan->id] = Playlist::all(array('conditions' => array('channel_id = ?', $chan->id), 'order' => 'timestamp desc'));
         }
         return new ViewResponse('playlists/playlists', $data);
     } else {
         return new RedirectResponse(WEBROOT);
     }
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:15,代码来源:playlist_controller.php

示例2: get

 public function get($id, $request, $playlist = false)
 {
     if (!Video::exists($id)) {
         return Utils::getNotFoundResponse();
     }
     $video = Video::find($id);
     $author = UserChannel::find($video->poster_id);
     if ($request->acceptsJson()) {
         $videoData = array('id' => $video->id, 'title' => $video->title, 'author' => $video->poster_id, 'description' => $video->description, 'views' => $video->views, 'likes' => $video->likes, 'dislikes' => $video->dislikes);
         return new JsonResponse($videoData);
     }
     $data = array();
     $data['currentPageTitle'] = $video->title;
     if ($video->isSuspended()) {
         $data['author'] = $author;
         $data['video'] = $video;
         return new ViewResponse('video/suspended', $data);
     } elseif ($video->isPrivate() && (!Session::isActive() || $video->poster_id != Session::get()->getMainChannel()->id)) {
         $data['author'] = $author;
         $data['video'] = $video;
         return new ViewResponse('video/private', $data);
     }
     if ($playlist != false) {
         $videos_ids = json_decode($playlist->videos_ids);
         foreach ($videos_ids as $key => $value) {
             if ($value == $video->id) {
                 $nextKey = isset($videos_ids[$key + 1]) ? $key + 1 : 0;
                 break;
             }
         }
         $data['nextVideo'] = WEBROOT . 'playlists/' . $playlist->id . '/watch/' . $videos_ids[$nextKey];
     }
     $ext = explode('.', $video->url);
     $ext = $ext[count($ext) - 1];
     $data['playlist'] = $playlist;
     $data['video'] = $video;
     $data['ext'] = $ext;
     $data['playlists'] = array();
     $data['channels'] = Session::isActive() ? Session::get()->getOwnedChannels() : array();
     foreach ($data['channels'] as $chan) {
         $data['playlists'][$chan->id] = Playlist::all(array('conditions' => array('channel_id = ?', $chan->id), 'order' => 'timestamp desc'));
     }
     $data['title'] = $video->title;
     $data['tags'] = array();
     $tags = explode(' ', $video->tags);
     foreach ($tags as $tag) {
         $tag = trim($tag);
         $tag = str_replace(',', '', $tag);
         $tag = str_replace(';', '', $tag);
         $tag = str_replace(':', '', $tag);
         $tag = str_replace('.', '', $tag);
         $data['tags'][] = $tag;
     }
     $data['poster_id'] = $video->poster_id;
     $data['author'] = $author;
     $data['description'] = $video->description;
     $data['views'] = $video->views;
     $data['likes'] = $video->likes;
     $data['dislikes'] = $video->dislikes;
     $data['thumbnail'] = $video->getThumbnail();
     $data['subscribers'] = $author->getSubscribersNumber();
     $data['subscribed'] = Session::isActive() ? Session::get()->hasSubscribedToChannel($author->id) : false;
     $data['likedByUser'] = Session::isActive() ? $video->isLikedByUser(Session::get()->id) : false;
     $data['dislikedByUser'] = Session::isActive() ? $video->isDislikedByUser(Session::get()->id) : false;
     $data['recommendations'] = $video->getAssociatedVideos(4);
     $data['channels'] = Session::isActive() ? Session::get()->getOwnedChannels() : array();
     $data['flagged'] = $video->isFlagged();
     $data['discover'] = $video->discover;
     $data['currentPage'] = "watch";
     $video->addView();
     return new ViewResponse('video/video', $data);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:72,代码来源:video_controller.php

示例3: playlists

 public function playlists($id, $request)
 {
     $channel = UserChannel::exists($id) ? UserChannel::find_by_id($id) : UserChannel::find_by_name($id);
     if (is_object($channel)) {
         $data = array();
         $data['currentPage'] = 'channel';
         $data['currentPageTitle'] = $channel->name . ' - Playlists';
         $data['current'] = 'playlists';
         $data['id'] = $channel->id;
         $data['name'] = $channel->name;
         $data['avatar'] = $channel->getAvatar();
         $data['background'] = $channel->getBackground();
         $data['description'] = $channel->description;
         $data['subscribers'] = $channel->getSubscribedUsersAsList();
         $data['subscribed'] = Session::isActive() ? Session::get()->hasSubscribedToChannel($channel->id) : false;
         $data['playlists'] = Playlist::all(array('conditions' => array('channel_id = ?', $channel->id)));
         $data['channelBelongsToUser'] = Session::isActive() ? $channel->belongToUser(Session::get()->id) : false;
         $data['total_views'] = $channel->getAllViews();
         $data['videos'] = $channel->getPostedVideos();
         $data['owner_id'] = $channel->owner_id;
         $data['verified'] = $channel->verified;
         $data['sub'] = count($data['subscribers']);
         return new ViewResponse('channel/playlists', $data);
     } else {
         return Utils::getNotFoundResponse();
     }
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:27,代码来源:channel_controller.php


注:本文中的Playlist::all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。