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


PHP SearchHelper::getInstance方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:giangnh264,项目名称:mobileplus,代码行数:101,代码来源:SearchController.php


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