public function actionSearchart()
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $article = [];
     $articleid = $this->helpGquery('articleid', '0');
     $type = $this->helpGquery('type', '1');
     if (!empty($articleid)) {
         if ($type == 2) {
             $articleObj = new \common\models\Article();
             $temp = $articleObj->List_ArticleByIds([$articleid]);
             if (!empty($temp)) {
                 $article = $temp[0];
             }
         } elseif ($type == 1) {
             $temp = Article::find()->where(['id' => $articleid])->asArray()->one();
             if (!empty($temp)) {
                 $temp['url'] = \Yii::getAlias("@domain") . '/article/' . date('Y/md', $temp['inputtime']) . '/' . $temp['id'] . '.shtml';
                 $article = $temp;
             }
         }
     }
     return $article;
 }
示例#2
0
 public static function search_article_data($sphinx_data)
 {
     $total = 0;
     $ret_list = array();
     if (!empty($sphinx_data['matches'])) {
         $art_obj = new \common\models\Article();
         $zx_art_ids = array();
         $jb_art_ids = array();
         foreach ($sphinx_data['matches'] as $k => $v) {
             $attr = $v['attrs'];
             if ($attr['tmp_source_id'] == 1) {
                 $zx_art_ids[] = $k;
             } else {
                 $jb_art_ids[] = $k;
             }
         }
         if (count($zx_art_ids) > 0) {
             $disease_list = $art_obj->List_ArticleByIds($zx_art_ids);
             if ($disease_list) {
                 foreach ($disease_list as $k => $v) {
                     $v['tmp_source_id'] = 1;
                     $v['url'] = $v['url'];
                     $article_path = sprintf("%s/%d.shtml", 'article', $v['id']);
                     $v['wap_url'] = sprintf('%s/%s', Yii::getAlias('@wap'), $article_path);
                     $ret_list[] = $v;
                 }
             }
         }
         if (count($jb_art_ids) > 0) {
             $diseaseArticle = new DArticle();
             $disease_list = $diseaseArticle->List_DiseaseArticleByIds($jb_art_ids);
             if ($disease_list) {
                 foreach ($disease_list as $k => $v) {
                     $v['tmp_source_id'] = 2;
                     $date_path = date('Y/md', $v['inputtime']);
                     $article_path = sprintf("%s/%s/%d.shtml", 'article', $date_path, $v['id']);
                     $v['url'] = sprintf('%s/%s', Yii::getAlias('@jb_domain'), $article_path);
                     $v['wap_url'] = sprintf('%s/%s', Yii::getAlias('@mjb_domain'), $article_path);
                     $ret_list[] = $v;
                 }
             }
         }
         $total = $sphinx_data['total'];
     }
     $explain_words = $sphinx_data['explain_words'];
     return array('list' => $ret_list, 'total' => $total, 'explain_words' => $explain_words);
 }