public function actionView() { $radioId = Yii::app()->request->getParam("id", 0); $radioName = WapRadioModel::model()->findByPk($radioId)->name; $albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id"); $radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1'); $album = WapAlbumModel::model()->published()->findByPk($albumId); if (!$album) { $this->forward("/site/error", true); } $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId); $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId); $phone = yii::app()->user->getState('msisdn'); $errorCode = 'success'; $errorDescription = ''; $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT'); ///meta tag $AlbumDetail = AlbumModel::model()->findByPk($albumId); $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id; $ArtistInfo = ArtistModel::model()->findByPk($artistId); $this->itemName = $AlbumDetail->name; $this->artist = $ArtistInfo->name; $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1'); $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name)); $this->description = strip_tags($AlbumDetail->description); //get other radio $parent_id = Yii::app()->params['horoscope']['parent_id']; $radioListOther = WapRadioModel::model()->getHoroscopes($parent_id); $this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar)); }
public function actionViewType() { $artistId = Yii::app()->request->getParam('id'); $artist = ArtistModel::model()->findByPk($artistId); $this->artist = $artist->name; $this->thumb = ArtistModel::model()->getAvatarUrl($artist->id, 150); $this->url = URLHelper::buildFriendlyURL("artist", $artist->id, $artist->url_key); if (!$artist) { $this->forward("/site/error", true); } $listType = Yii::app()->request->getParam('list', 'song'); $countSongsOfArtist = $artist->song_count; $countClipsOfArtist = $artist->video_count; $countAlbumsOfArtist = $artist->album_count; $pageSize = Yii::app()->params['numberSongsPerPage']; if ($listType == 'song') { // in case that list songs of artist $songPages = new CPagination($countSongsOfArtist); $songPages->setPageSize($pageSize); $currentPage = $songPages->getCurrentPage(); $songsOfArtist = WapSongModel::model()->getSongsSameSinger(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'songsOfArtist' => $songsOfArtist, 'songPages' => $songPages)); } elseif ($listType == 'clip') { // in case that list clips of artist $clipPages = new CPagination($countClipsOfArtist); $clipPages->setPageSize($pageSize); $currentPage = $clipPages->getCurrentPage(); $clipsOfArtist = WapVideoModel::model()->getVideosSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'clipsOfArtist' => $clipsOfArtist, 'clipPages' => $clipPages)); } else { // in case that list albums of artist $albumPages = new CPagination($countAlbumsOfArtist); $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); $albumsOfArtist = WapAlbumModel::model()->getAlbumsSameArtist(0, $artist->id, $currentPage * $pageSize, $pageSize); $this->render('viewtype', array('artist' => $artist, 'listType' => $listType, 'countSongsOfArtist' => $countSongsOfArtist, 'countClipsOfArtist' => $countClipsOfArtist, 'countAlbumsOfArtist' => $countAlbumsOfArtist, 'albumsOfArtist' => $albumsOfArtist, 'albumPages' => $albumPages)); } }
public function actionIndex() { $keyword = trim(yii::app()->request->getParam('q', '')); $keyword = strip_tags($keyword); $search_type = trim(yii::app()->request->getParam('type', '')); $page = intval(yii::app()->request->getParam('page', 1)); $is_search = Yii::app()->request->getParam('is_search', 1); $paging = array('page' => $page, 'recordsPerPage' => !$search_type ? Yii::app()->params['numberPerPage'] : Yii::app()->params['pageSize']); $limit = 5; $searchType = !$search_type ? $this->type_infos : array($search_type => ''); $total_results = array(); foreach ($searchType as $type => $info) { switch ($type) { case 'song': $response = SearchHelper::getInstance()->search($keyword, 'song', $limit, $page - 1); $results = $this->copyAndCast($response->docs, array('name' => 'name', 'artist_name' => 'artist_name')); $results = $this->getStatistic($results, $type); $countSong = $response->numFound; $pages = new CPagination($countSong); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'pages' => $pages); break; case 'clip': $response = SearchHelper::getInstance()->search($keyword, 'video', $limit, $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); $results = $this->getStatistic($results, $type); $countClip = $response->numFound; $pages = new CPagination($countClip); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'pages' => $pages); break; case 'album': $response = SearchHelper::getInstance()->search($keyword, 'album', $limit, $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); $results = $this->getStatistic($results, $type); $countAlbum = $response->numFound; $pages = new CPagination($countAlbum); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'pages' => $pages); break; case 'artist': $response = SearchHelper::getInstance()->search($keyword, 'artist', $limit, $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); $results = $this->getStatistic($results, $type, 'song_count'); $countArtist = $response->numFound; $pages = new CPagination($countArtist); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'pages' => $pages); $listArtist = ArtistModel::updateResultFromSearch($this->copyAndCast($response->docs, array())); $artistSeach = trim($listArtist[0]['name']); if ($artistSeach == $keyword || Common::makeFriendlyUrl($artistSeach) == Common::makeFriendlyUrl($keyword)) { $urlKey = Common::makeFriendlyUrl(trim($listArtist[0]['name'])); $link = Yii::app()->createUrl("artist/view", array("id" => $listArtist[0]['id'], "title" => $urlKey)); $this->redirect($link); } break; case 'videoplaylist': $response = SearchHelper::getInstance()->search($keyword, 'videoplaylist', $limit, $page - 1); $results = $this->copyAndCast($response->docs, array('artist' => 'artist_name')); $results = $this->getStatistic($results, $type); $countVideoPlaylist = $response->numFound; $pages = new CPagination($countVideoPlaylist); $pageSize = Yii::app()->params['pageSize']; $pages->params = array('q' => $keyword, 'type' => $type); $pages->setPageSize($pageSize); $total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'pages' => $pages); break; } } if ($is_search == '0') { $this->render('list_rbt', array('keyword' => $keyword, 'search_type' => $search_type, 'total_results' => $total_results, 'type_infos' => $this->type_infos)); } // echo '<pre>';print_r($total_results); $this->render('result', array('keyword' => $keyword, 'search_type' => $search_type, 'total_results' => $total_results, 'type_infos' => $this->type_infos)); }
public function actionArtistList() { $callBack = (int) Yii::app()->request->getParam('call_back', 0); $page = (int) Yii::app()->request->getParam('page', 1); $limit = Yii::app()->params['numberPerPage']; $offset = ($page - 1) * $limit; $artistId = (int) Yii::app()->request->getParam('artist_id'); $artist = ArtistModel::model()->findByPk($artistId); $songId = 0; $count = WapSongModel::model()->countSongsSameSinger($songId, $artistId); $songs = WapSongModel::model()->getSongsSameSinger($songId, $artistId, $offset, $limit); $pager = new CPagination($count); $pager->setPageSize($limit); $offset = $pager->getOffset(); $callBackLink = Yii::app()->createUrl("song/artistList", array('artist_id' => $artistId)); if ($callBack) { $this->layout = false; $this->render("_ajaxList", compact('songs', 'pager', 'callBackLink', 'artist')); } else { $this->render("artist", compact('songs', 'pager', 'callBackLink', 'artist')); } }
/** * function actionView * call to render detail album page */ public function actionView() { $albumId = (int) Yii::app()->request->getParam('id'); $album = WapAlbumModel::model()->available()->findByPk($albumId); if (!$album) { $this->forward("/site/error", true); } else { if ($album->status == 0) { $deactive = true; } } $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId); //samge artist $countAlbumsSameArtist = WapAlbumModel::model()->countAlbumsSameArtist($album->id, $album->artist_id); $albumPages = new CPagination($countAlbumsSameArtist); $pageSize = Yii::app()->params['pageSize']; $albumPages->setPageSize($pageSize); $currentPage = $albumPages->getCurrentPage(); /* NEW */ $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId); $artistIds = ''; if ($artists) { foreach ($artists as $artist) { $artistIds .= ',' . $artist->artist_id; } } $artistIds = $artistIds != '' ? substr($artistIds, 1) : ''; $albumsSameArtist = WapAlbumModel::model()->getAlbumbyArtists($artistIds, $pageSize, $currentPage * $pageSize); /* END */ $phone = yii::app()->user->getState('msisdn'); $errorCode = 'success'; $errorDescription = ''; //for show price $favourite = Yii::app()->request->getParam('favourite', null); $phone = yii::app()->user->getState('msisdn'); $user_id = Yii::app()->user->id; if (isset($favourite) && $favourite == 0) { if (!empty($user_id)) { $res = WapFavouriteAlbumModel::model()->deleteAllByAttributes(array('msisdn' => $phone, 'album_id' => $albumId)); } else { $this->redirect($this->createUrl("/account/login")); } } if (isset($favourite) && $favourite == 1) { if (!empty($phone)) { $res = WapFavouriteAlbumModel::model()->favouriteAlbum($phone, $albumId); } else { $this->redirect($this->createUrl("/account/login")); } } $like = null; if ($phone) { $like = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $albumId, 'msisdn' => $phone)); } $userType = "GUEST"; $phone = Yii::app()->user->getState('phone'); if ($phone) { $userType = "MEMBER"; } $userSub = Yii::app()->user->getState('userSub'); $packageCode = Yii::app()->user->getState('packageCode'); if ($userSub) { $userType = "SUB_" . $packageCode; } $perLimit = ContentLimitModel::getPermision($albumId, "album", $userType, "WAP"); ///meta tag $AlbumDetail = AlbumModel::model()->findByPk($albumId); $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id; $ArtistInfo = ArtistModel::model()->findByPk($artistId); $this->itemName = $AlbumDetail->name; $this->artist = $ArtistInfo->name; $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1'); $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name)); $this->description = strip_tags($AlbumDetail->description); $this->render('view', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'albumsSameArtist' => $albumsSameArtist, 'albumPages' => $albumPages, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'userSub' => $userSub, 'like' => $like, 'perLimit' => $perLimit, 'deactive' => $deactive)); }