示例#1
0
" ><?php 
echo CHtml::encode($album->artist_name);
?>
</a></p>
    </div>
</div>


<ul class="bxh_album_list song_detail_list mart20">
    <?php 
foreach ($songs as $song) {
    $urlKey = Common::makeFriendlyUrl(trim($song->song->name));
    $artist_name = Common::makeFriendlyUrl($song->artist_name);
    $link = Yii::app()->createUrl("song/view", array("id" => $song->song_id, "title" => $urlKey, 'artist' => $artist_name));
    $artistLink = Yii::app()->createUrl("/search") . "?" . http_build_query(array("q" => CHtml::encode($song->song->artist_name)));
    $artistId = SongArtistModel::model()->findByAttributes(array('song_id' => $song->song->id))->artist_id;
    $image = AvatarHelper::getAvatar("artist", $artistId, 640);
    ?>
        <li>
            <a href="<?php 
    echo $link;
    ?>
">
                <img src="<?php 
    echo $image;
    ?>
" alt="<?php 
    echo CHtml::encode($song->song->artist_name);
    ?>
">
            </a>
示例#2
0
 public function actionView()
 {
     $id = (int) Yii::app()->request->getParam('id', 0);
     $playUrl = Yii::app()->request->getParam('url', null);
     $lyric = (int) Yii::app()->request->getParam('lyric', 0);
     $song = WapSongModel::model()->available()->findByPk($id);
     $isDeactive = false;
     if (!$song || $song->status == SongModel::DELETED) {
         $this->forward("/site/error", true);
     } elseif ($song->status == SongModel::DEACTIVE) {
         $isDeactive = true;
     }
     $artistId = SongArtistModel::model()->getArtistBySong($id, 'id');
     if ($artistId) {
         $artistId = $artistId[0];
     } else {
         $artistId = 0;
     }
     $genreId = SongGenreModel::model()->getCatBySong($song->id, false, true);
     if ($genreId) {
         $genreId = $genreId[0];
     } else {
         $genreId = 0;
     }
     //--- Check quyền nghe bài hát này
     $userType = "GUEST";
     if (Yii::app()->user->getState('msisdn')) {
         $userType = "MEMBER";
     }
     if (!empty($this->userSub)) {
         if (isset($this->userSub->package) && !empty($this->userSub->package)) {
             $package = $this->userSub->package->code;
         }
         $package = strtoupper($package);
         $userType = "SUB_" . $package;
     }
     $per = ContentLimitModel::getPermision($song->id, "song", $userType, "WAP");
     //---End check quyền nghe bài hát này
     $count = WapSongModel::model()->countSongsSameSinger($song->id, $artistId);
     $pager = new CPagination($count);
     $limit = Yii::app()->params['numberPerPage'];
     if ($this->layout == 'application.views.wap.layouts.main') {
         $limit = Yii::app()->params['numberSongPerPageWap'];
     }
     $pager->setPageSize($limit);
     $songArtist = WapSongModel::model()->getSongsSameSinger($song->id, $artistId, $pager->getOffset(), $pager->getLimit());
     $callBackLink = Yii::app()->createUrl("song/artist", array('song_id' => $song->id, 'artist_id' => $artistId));
     // check like
     $like = null;
     $favourite = Yii::app()->request->getParam('favourite', null);
     $user_id = Yii::app()->user->id;
     $phone = yii::app()->user->getState('msisdn');
     $artist_name = Common::makeFriendlyUrl($song->artist_name);
     $back_url = Yii::app()->params['base_url'] . Yii::app()->createUrl('song/view', array('id' => $song->id, 'url_key' => Common::makeFriendlyUrl($song->name), 'artist' => $artist_name));
     if (isset($favourite) && $favourite == 1) {
         //yeu thich video
         if (!empty($phone)) {
             $fav = WapFavouriteSongModel::model()->favouriteSong($id, $phone, $phone);
         } else {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
         }
     } elseif (isset($favourite) && $favourite == 0) {
         if (!empty($user_id)) {
             $res = WapFavouriteSongModel::model()->deleteAll("song_id={$id} AND msisdn={$phone}");
         } else {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
         }
     }
     if ($phone) {
         $like = WapFavouriteSongModel::model()->findByAttributes(array('song_id' => $song->id, 'msisdn' => $phone));
     }
     // Get Song Meta Data
     $Artist = ArtistModel::model()->findByPk($song->song_artist[0]->artist_id);
     $this->url = URLHelper::buildFriendlyURL("song", $song->id, $song->url_key);
     $this->itemName = $song->name;
     $this->artist = $Artist ? $Artist->name : 'Music';
     $this->thumb = ArtistModel::model()->getAvatarUrl($song->song_artist[0]->artist_id, 's1');
     $userSub = $this->userSub;
     $this->render('view', compact('song', 'songArtist', 'pager', 'callBackLink', 'artistId', 'genreId', 'like', 'per', 'lyric', 'playUrl', 'isDeactive'));
 }