Exemplo n.º 1
0
 public function actionError()
 {
     $frontend = \Yii::getAlias('@frontend');
     $page404FileName = $frontend . '/web/404.shtml';
     if (!file_exists($page404FileName)) {
         CacheHelper::getCache('frontend_404_page', []);
     }
     return $this->renderFile($page404FileName);
 }
 /**
  * 首页
  * @author gaoqing
  * @date 2016-03-21
  * @return string 视图
  */
 public function actionIndex()
 {
     $view = "index";
     $obj_diseaseService = new DiseaseService();
     //1、疾病的信息(根据疾病的 dname, 获取疾病信息)
     $disease = $obj_diseaseService->getDiseasesByPinyin($this->params['dname'], false, true, true, true);
     $disease['alias_arr'] = [];
     if (!empty($disease['alias'])) {
         $disease['alias_arr'] = $this->explodeStr($disease['alias']);
     }
     //2、获取 4 条症状信息
     //        $symptoms = [];
     //        if ($this->isNotNull($disease['tsymptom'])){
     //            $symptoms = array_slice($disease['tsymptom'], 0, 4);
     //        }
     //3、获取全面解读部分数据
     $allReads = CacheHelper::getCache('frontend_disease_index_wzjd', ['id' => $disease['id']]);
     //4、关注问题
     $asks = CacheHelper::getCache('frontend_disease_index_gzwt', ['id' => $disease['id'], 'keywords' => $disease['keywords']]);
     //得到当前病 对应到 9939_com_v2sns wd_keshi 表中的 id 值
     //        $v2snsKeshiID = $obj_diseaseService->getKeshiIDByName($disease['name']);
     //医生信息
     $doctors = $this->getDoctors();
     //得到热词部分
     //        $hotWords = $this->letterHotWordsBatch($disease['name']);
     //        $model['randWords'] = $hotWords;
     $disease['thumb'] = empty($disease['thumb']) ? '/images/dise_02.jpg' : \librarys\helpers\utils\Url::getuploadfileUrl(1, $disease['thumb']);
     $params = ['disease' => $disease, 'allReads' => $allReads, 'asks' => $asks, 'doctors' => $doctors];
     return $this->render($view, $params);
 }
 /**
  * 文章页
  * @author gaoqing
  * @date 2016-03-25
  * @return string 视图
  */
 public function actionDetail()
 {
     $view = "detail";
     $aid = $this->helpGparam("aid", "-1");
     //获取文章的信息
     $condition = ['id' => $aid];
     $article = Article::search($condition, 0, 1);
     $article = $article['list'];
     if (!isset($article) || empty($article)) {
         throw new NotFoundHttpException('当前访问的页面不存在!');
     }
     if ($this->isNotNull($article)) {
         $article = $article[0];
         $article['inputtime'] = date('Y-m-d H:i:s', $article['inputtime']);
         $article['keywords_init'] = $article['keywords'];
         $article['keywords'] = explode(' ', $article['keywords']);
     }
     //文章内容添加疾病、症状词的链接
     //lc@2016-5-24
     $cache_all = Article::getAllDiseaseSymptom2Redis();
     $content = $article['content'];
     $link_num = 5;
     //每页内链个数
     $single_link_num = 1;
     //单个词链接个数
     $i = 1;
     $str = '';
     $count = 0;
     foreach ($cache_all as $k => $v) {
         $searchArr = '(' . $k . ')';
         $replaceArr = '<a href="' . $v . '" title="' . $k . '" target="_blank">' . $k . '</a>';
         if ($i > $link_num) {
             break;
         }
         if (stripos($str, $k) === false) {
             $content = preg_replace($searchArr, $replaceArr, $content, $single_link_num, $count);
             if ($count > 0) {
                 $str .= $k;
                 $i++;
             }
         }
     }
     $article['content'] = $content;
     //获取当前文章对应的疾病信息
     $isSymptom = 0;
     if ($article['diseaseid'] > 0) {
         $disease_obj = new Disease();
         $res = $disease_obj->getDiseaseById($article['diseaseid']);
         $disease = $res['disease'];
         $disease['inspect'] = $res['diseaseContent']['inspect'];
     } elseif ($article['symptomid'] > 0) {
         $symptom = Symptom::getSymptomByid($article['symptomid'], true);
         $disease = $symptom;
         $disease['inspect'] = $symptom['examine'];
         $isSymptom = 1;
     }
     //上一篇
     $preCondition = ['<', 'id', $aid];
     $preArticle = Article::search($preCondition, 0, 1, 'id DESC');
     $preArticle = $preArticle['list'];
     if ($this->isNotNull($preArticle)) {
         $preArticle = $preArticle[0];
     }
     //下一篇
     $nextCondition = ['>', 'id', $aid];
     $nextArticle = Article::search($nextCondition, 0, 1, 'id ASC');
     $nextArticle = $nextArticle['list'];
     if ($this->isNotNull($nextArticle)) {
         $nextArticle = $nextArticle[0];
     }
     $relArtsAndAsks = CacheHelper::getCache('frontend_article_detail_xgwz', ['title' => $article['title'], 'id' => $aid, 'diseaseid' => $article['diseaseid'], 'symptomid' => $article['symptomid']]);
     $relArticles = $relArtsAndAsks['relArticles'];
     //相关问答
     $asks = $relArtsAndAsks['relAsks'];
     //hot words part
     $letter_list = range('A', 'Z');
     $randwords = $this->rand_words();
     $hotWords = ['letter' => $letter_list, 'words' => $randwords];
     //common diseases and hot departments part
     $commonDisDep = CacheHelper::getCache('frontend_article_detail_rmksbw', []);
     //大家还在找部分
     $stillFind = $this->getStillFindDatas($disease['name']);
     //右侧:最新文章
     $lastestArticles = $this->getLatestArticles();
     $params = ['article' => $article, 'preArticle' => $preArticle, 'nextArticle' => $nextArticle, 'relArticles' => $relArticles, 'asks' => $asks, 'isSymptom' => $isSymptom, 'disease' => $disease, 'hotWords' => $hotWords, 'commonDisDep' => $commonDisDep, 'stillFind' => $stillFind, 'lastestArticles' => $lastestArticles];
     return $this->render($view, $params);
 }
 /**
  * 文章页
  * @author gaoqing
  * @date 2016-03-25
  * @return string 视图
  */
 public function actionDetail()
 {
     $view = "detail";
     $aid = $this->helpGparam("aid", "-1");
     //获取文章的信息
     $condition = ['id' => $aid];
     $article = Article::search($condition, 0, 1);
     $article = $article['list'];
     if (!isset($article) || empty($article)) {
         throw new NotFoundHttpException('当前访问的页面不存在!');
     }
     if ($this->isNotNull($article)) {
         $article = $article[0];
         $article['keywords_init'] = $article['keywords'];
         $article['keywords'] = explode(' ', $article['keywords']);
     }
     //获取当前文章对应的疾病信息
     $disease = $this->diseaseService->getDiseaseByArtid($aid);
     //上一篇
     $preCondition = ['<', 'id', $aid];
     $preArticle = Article::search($preCondition, 0, 1, 'id DESC');
     $preArticle = $preArticle['list'];
     if ($this->isNotNull($preArticle)) {
         $preArticle = $preArticle[0];
     }
     //下一篇
     $nextCondition = ['>', 'id', $aid];
     $nextArticle = Article::search($nextCondition, 0, 1, 'id ASC');
     $nextArticle = $nextArticle['list'];
     if ($this->isNotNull($nextArticle)) {
         $nextArticle = $nextArticle[0];
     }
     //获取相关疾病文章
     $relArtsAndAsks = CacheHelper::getCache('frontend_article_detail_xgwz', ['title' => $article['title'], 'id' => $aid, 'diseaseid' => $article['diseaseid'], 'iswapjb' => true]);
     $relArticles = isset($relArtsAndAsks['relArticles']['list']) ? $relArtsAndAsks['relArticles']['list'] : array();
     //相关问答
     $asks = isset($relArtsAndAsks['relAsks']['list']) ? $relArtsAndAsks['relAsks']['list'] : array();
     //推荐专家
     $doctors = $this->getDoctors();
     $params = ['article' => $article, 'preArticle' => $preArticle, 'nextArticle' => $nextArticle, 'relArticles' => $relArticles, 'asks' => $asks, 'disease' => $disease, 'doctors' => $doctors];
     return $this->renderPartial($view, $params);
 }
Exemplo n.º 5
0
 /**
  * 生成 404 静态页面
  * @author gaoqing
  * @date 2016-04-20
  * @param string $cacheKey 缓存的唯一标识
  * @return boolean$generateFlag是否生成成功
  */
 public static function cache404Page($cacheKey, $param = [], $forceCache = false)
 {
     $generateFlag = false;
     $frontend = \Yii::getAlias('@frontend');
     $page404FileName = $frontend . '/web/404.shtml';
     if (!file_exists($page404FileName)) {
         $forceCache = true;
     }
     if ($forceCache) {
         $view = "404";
         //获取最新的资讯文章
         $article = new Article();
         $where = ' status=20';
         $order = ' articleid DESC';
         $lastestNews = $article->List_Articles($where, $order, 5, 0);
         //获取 疾病健康 文章
         $darticle = new \common\models\disease\Article();
         $lastestJibingArticle = $darticle->getLatestArticle(5, 0);
         //精彩问答
         $ask = new Ask();
         $where1 = ' 1';
         $order1 = ' id DESC';
         $lastestAsk = $ask->getList($where1, $order1, 5, 0);
         //字母部分
         $letters = range('A', 'Z');
         $condition = array('typeid' => array(0, 2, 3, 4, 5, 6, 7, 8, 9));
         $rand_words = KeyWords::getCacheRandWords(100, $condition);
         //热门疾病、热门部位
         $commonDisDep = CacheHelper::getCache('frontend_article_detail_rmksbw_404', []);
         $params = ['lastestNews' => $lastestNews, 'lastestJibingArticle' => $lastestJibingArticle, 'lastestAsk' => $lastestAsk, 'letters' => $letters, 'rand_words' => $rand_words, 'commonDisDep' => $commonDisDep, 'searchurl' => 'http://www.9939.com/zhuanti/'];
         $controller = new BaseController('base404', null);
         $controller->id = "base404";
         $page404FilePath = $frontend . '/views/site';
         $controller->viewPath = $page404FilePath;
         $page404 = $controller->renderPartial($view, $params);
         if (isset($page404) && !empty($page404)) {
             if (file_put_contents($page404FileName, $page404)) {
                 $generateFlag = true;
             }
         }
     }
     return $generateFlag;
 }
Exemplo n.º 6
0
 /**
  * app 端 【疾病模块】首页接口数据
  * @author gaoqing
  * @date 2016-09-08
  * @return string json 格式的数据
  */
 public static function index($condition)
 {
     //1、疾病的信息(根据疾病的 dname, 获取疾病信息)
     $disease = self::getDiseasesByPinyin($condition['dname'], false, true, true, true);
     array_walk($disease, function (&$value, $key) {
         if (empty($value)) {
             $value = '';
         }
     });
     $disease['inspect_short'] = String::cutString($disease['inspect'], 20);
     $disease['alias_arr'] = [];
     if (!empty($disease['alias'])) {
         $disease['alias_arr'] = self::explodeStr($disease['alias']);
     }
     //2、获取 4 条症状信息
     $symptoms = [];
     if (self::isNotNull($disease['tsymptom'])) {
         $symptoms = array_slice($disease['tsymptom'], 0, 4);
     }
     //3、获取全面解读部分数据
     $allReads = CacheHelper::getCache('frontend_disease_index_wzjd', ['id' => $disease['id'], 'name' => $disease['name']]);
     if (!empty($allReads)) {
         foreach ($allReads as $module => $allRead) {
             $subRead = [];
             foreach ($allRead as $index => $val) {
                 if ($index < 2) {
                     $val['app_url'] = \Yii::getAlias('@app_domain') . '/article/' . date('Y/md', $val['inputtime']) . '/' . $val['id'] . '.shtml';
                     $subRead[] = $val;
                 }
             }
             $allReads[$module] = $subRead;
         }
     }
     $disease['thumb'] = empty($disease['thumb']) ? '/images/dise_02.jpg' : \librarys\helpers\utils\Url::getuploadfileUrl(1, $disease['thumb']);
     $params = ['disease' => $disease, 'symptoms' => $symptoms, 'allReads' => $allReads];
     return ['code' => 200, 'message' => '数据响应成功', 'data' => $params];
 }
Exemplo n.º 7
0
 /**
  * 右侧公共信息,跟疾病有关的
  * lc 2016-4-6
  * @param type $symptomid
  * @param array $filter  ['disease','relSymptom'] 筛选需要的数据 
  * @return type
  */
 public function getRightInfo($symptomid, $filter = [])
 {
     $cacheHelper = new CacheHelper();
     $filter = !empty($filter) ? $filter : ['disease', 'articles', 'doctorInfos', 'leftDoctor', 'medicalDepartment', 'relSymptom'];
     $model = [];
     $diseaseList = [];
     $parms = ['id' => $symptomid];
     $diseaseCache = $cacheHelper->getCache('frontend_symptom_index_knjb', $parms);
     if (in_array('medicalDepartment', $filter) || in_array('disease', $filter)) {
         if (!empty($diseaseCache)) {
             $model['disid'] = $diseaseCache['diseaseId'];
             //症状首页左侧可能疾病及伴随症状
             $model['disease'] = $diseaseCache['diseaseTmp'];
         }
     }
     //右侧就诊科室
     //        if (in_array('medicalDepartment', $filter)) {
     //            if (!empty($diseaseCache)) {
     //                //在取到的所有科室数据合并去重
     //                $medicalDepartment = [];
     //                foreach ($diseaseCache['departmentMap'] as $vv) {
     //                    $Tmp['medicalDepartmentTmp'][] = $vv['id'];
     //                    $Tmp['medicalDepartmentTmpName'][] = $vv['name'];
     //                    $Tmp['medicalDepartmentTmpPinyin'][] = $vv['pinyin'];
     //                }
     //                $medicalDepartment['id'] = array_unique($Tmp['medicalDepartmentTmp']);
     //                $medicalDepartment['name'] = array_unique($Tmp['medicalDepartmentTmpName']);
     //                $medicalDepartment['pinyin'] = array_unique($Tmp['medicalDepartmentTmpPinyin']);
     ////                print_r($medicalDepartment);exit;
     //                $model['medicalDepartment'] = $medicalDepartment;
     //                //科室拼音
     //                $model['departPinyin'] = $this->department->getDepartmentPinyin();
     //            }
     //        }
     //右侧相关症状
     if (in_array('relSymptom', $filter)) {
         $relateObj = new Relate();
         $model['relSymptom'] = $relateObj->getRelateSymptoms($symptomid);
     }
     //症状相关文章
     if (in_array('articles', $filter)) {
         $articleObj = new Article();
         $model['articles'] = [];
         $articles = $articleObj->listByCondition([['status' => '99'], ['symptomid' => $symptomid]], 7, 0, 'id DESC');
         if (!empty($articles)) {
             $model['articles'] = $articles;
         } else {
             if (!empty($diseaseCache)) {
                 $diseaseId = $diseaseCache['diseaseId'];
                 $disease_ids = implode(',', $diseaseId);
                 $articles = $articleObj->listBySqlCondition($disease_ids, 7, 0);
                 $arts = [];
                 foreach ($articles as $k => $v) {
                     $date_path = date('Y/md', $v['inputtime']);
                     $article_path = sprintf("%s/%s/%d.shtml", 'article', $date_path, $v['id']);
                     $articleUrl = sprintf('%s/%s', Yii::getAlias('@jb_domain'), $article_path);
                     foreach ($v as $kk => $vv) {
                         $arts[$k][$kk] = $vv;
                         $arts[$k]['url'] = $articleUrl;
                     }
                 }
                 $model['articles'] = $arts;
             }
         }
     }
     //专家(左侧)
     if (in_array('doctorInfos', $filter)) {
         if (!empty($diseaseCache)) {
             //取所有相关疾病里第一个疾病id来查专家
             $diseaserandid = $diseaseCache['diseaseId']['0'];
             $doctors = $this->getDoctor($diseaserandid, 0, 6);
             //专家(右侧)
             $rightDoctor = array_slice($doctors, 3, 3);
             $model['doctorInfos'] = $rightDoctor;
             //在线咨询 左侧
             $leftDoctor = [['uid' => 1440561, 'nickname' => '陶丽萍', 'zhicheng' => '', 'best_dis' => '保健综合', 'pic' => '201601/1440561_avatar_middle.jpg'], ['uid' => 221102, 'nickname' => '王庆松', 'zhicheng' => '', 'best_dis' => '上呼吸道综合', 'pic' => '201601/221102_avatar_middle.jpg'], ['uid' => 831181, 'nickname' => '刘业生', 'zhicheng' => '', 'best_dis' => '常见病综合,呼吸道系统诊疗', 'pic' => '201604/831181_avatar_middle.jpg']];
             $model['leftDoctor'] = $leftDoctor;
         }
     }
     return $model;
 }