本文整理汇总了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;
//.........这里部分代码省略.........