本文整理匯總了PHP中SearchHelper::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP SearchHelper::getInstance方法的具體用法?PHP SearchHelper::getInstance怎麽用?PHP SearchHelper::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SearchHelper
的用法示例。
在下文中一共展示了SearchHelper::getInstance方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionLoadAjax
public function actionLoadAjax()
{
$keyword = trim(yii::app()->request->getParam('q', ''));
$search_type = $type = trim(yii::app()->request->getParam('type', 'song'));
$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']);
switch ($search_type) {
case 'song':
$response = SearchHelper::getInstance()->search($keyword, 'song', $paging['recordsPerPage'], $page - 1);
$results = $this->copyAndCast($response->docs, array('name' => 'name', 'artist_name' => 'artist_name'));
if ($response->numFound > 0) {
$countSong = $response->numFound;
$pages = new CPagination($countSong);
$pageSize = Yii::app()->params['pageSize'];
$pages->params = array('q' => $keyword, 'type' => $type);
$pages->setPageSize($pageSize);
$topItems = array();
$topItemPages = new CPagination(0);
$results = $this->getStatistic($results, $type);
} else {
$pages = new CPagination(0);
$pageSize = Yii::app()->params['numberPerPage'];
$topItemPages = new CPagination($pageSize);
$topItemPages->setPageSize($pageSize);
$currentPage = $topItemPages->getCurrentPage();
$topItems = null;
// WapSongModel::model()->getTopSongsWeek($currentPage * $pageSize, $pageSize);;//WapSongModel::getListHot(1,$pageSize,'filter_sync_status');
}
$total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages);
break;
case 'clip':
$response = SearchHelper::getInstance()->search($keyword, 'video', $paging['recordsPerPage'], $page - 1);
$results = $this->copyAndCast($response->docs, array('artist' => 'artist_name'));
if ($response->numFound > 0) {
$countClip = $response->numFound;
$pages = new CPagination($countClip);
$pageSize = Yii::app()->params['pageSize'];
$pages->params = array('q' => $keyword, 'type' => $type);
$pages->setPageSize($pageSize);
$topItems = array();
$topItemPages = new CPagination(0);
$results = $this->getStatistic($results, $type);
} else {
$pages = new CPagination(0);
$pageSize = Yii::app()->params['numberPerPage'];
$topItemPages = new CPagination($pageSize);
$currentPage = $topItemPages->getCurrentPage();
$topItemPages->setPageSize($pageSize);
$topItems = null;
//WapVideoModel::model()->getTopVideosWeek($currentPage * $pageSize, $pageSize);//WapVideoModel::getListHot(1,$pageSize,'filter_sync_status');
}
$total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages);
break;
case 'album':
$response = SearchHelper::getInstance()->search($keyword, 'album', $paging['recordsPerPage'], $page - 1);
$results = $this->copyAndCast($response->docs, array('artist' => 'artist_name'));
if ($response->numFound > 0) {
$countAlbum = $response->numFound;
$pages = new CPagination($countAlbum);
$pageSize = Yii::app()->params['pageSize'];
$pages->params = array('q' => $keyword, 'type' => $type);
$pages->setPageSize($pageSize);
$topItems = array();
$topItemPages = new CPagination(0);
$results = $this->getStatistic($results, $type);
} else {
$pages = new CPagination(0);
$pageSize = Yii::app()->params['numberPerPage'];
$topItemPages = new CPagination($pageSize);
$topItemPages->setPageSize($pageSize);
$currentPage = $topItemPages->getCurrentPage();
$topItems = null;
//WapAlbumModel::model()->getTopAlbumsWeek($currentPage * $pageSize, $pageSize);//WapAlbumModel::getListHot(1,$pageSize);
}
$total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages);
break;
case 'artist':
$response = SearchHelper::getInstance()->search($keyword, 'artist', $paging['recordsPerPage'], $page - 1);
$results = $this->copyAndCast($response->docs, array('artist' => 'artist_name'));
if ($response->numFound > 0) {
$countArtist = $response->numFound;
$pages = new CPagination($countArtist);
$pageSize = Yii::app()->params['pageSize'];
$pages->params = array('q' => $keyword, 'type' => $type);
$pages->setPageSize($pageSize);
$topItems = array();
$topItemPages = new CPagination(0);
$results = $this->getStatistic($results, $type, 'song_count');
} else {
$pages = new CPagination(0);
$pageSize = Yii::app()->params['numberPerPage'];
$topItemPages = new CPagination($pageSize);
$currentPage = $topItemPages->getCurrentPage();
$topItemPages->setPageSize($pageSize);
$topItems = null;
//WapArtistModel::model()->getTopArtists($currentPage * $pageSize, $pageSize);
}
$total_results[$type] = array('numFound' => $response->numFound, 'results' => $results, 'topItems' => $topItems, 'pages' => $pages, 'topItemPages' => $topItemPages);
break;
//.........這裏部分代碼省略.........