/** * 生成 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; }
/** * 疾病库 首页 */ public function actionIndex() { $data = []; //季发性疾病 $seasonalDiseaseMap = $this->seasonalDiseaseMap; $seasonal_disease = $this->getCategoryData($seasonalDiseaseMap, 8); //分类疾病和文章 //10疾病和4篇不同文章 $midPeopleOptionMap = $this->midPeopleMap; $common_disease_population = $this->getCategoryData($midPeopleOptionMap, 10, true); //科室 以及相关疾病 $midDepartmentMap = $this->midDepartmentMap; $department_classification = $this->getCategoryData($midDepartmentMap, 8); $model['department_classification'] = $department_classification; //问答 最新有专家回答的四个(ask+answer) $obj_ask = new Ask(); $latest_disease_answer = $obj_ask->getLatestAsk(0, 4); //最新疾病文章 调取最新疾病文章时间倒序,前面为疾病词 $obj_article = new Article(); $latest_disease_article = $obj_article->getLatestDiseaseArticle(0, 8); //疾病热词 $diseaseHotWordsMap = $this->diseaseHotWordsMap; $disease_hot_words = $this->getCategoryData($diseaseHotWordsMap, 10); $data['seasonal_disease'] = $seasonal_disease; //季发性疾病 $data['common_disease_population'] = $common_disease_population; //人类常见疾病 $data['department_classification'] = $department_classification; //科室分类 $data['midDepartmentMap'] = $midDepartmentMap; //科室 $data['latest_disease_answer'] = $latest_disease_answer; //最新疾病问答 $data['latest_disease_article'] = $latest_disease_article; //最新疾病文章 $data['disease_hot_words'] = $disease_hot_words; //最新疾病文章 $data['diseaseZone'] = $this->diseaseZone; //疾病专区 return $this->render('index', $data); }
public static function search_ask_data($sphinx_data) { $total = 0; $ask_res_list = array(); if (!empty($sphinx_data['matches'])) { $ret_list = array(); $ask_obj = new Ask(); $answer_obj = new Answer(); foreach ($sphinx_data['matches'] as $k => $v) { $r = $ask_obj->list_one($k); if (count($r) > 0) { $ret_list[] = $r; } } if (!empty($ret_list)) { foreach ($ret_list as $key => $value) { $ask_res_list[$key]['ask'] = $value; $answer_list = $answer_obj->getbyaskid($value['id']); $len = count($answer_list); if ($len > 0) { $ask_res_list[$key]['answer'] = $answer_list[0]; } } } $total = $sphinx_data['total']; } $explain_words = $sphinx_data['explain_words']; return array('list' => $ask_res_list, 'total' => $total, 'explain_words' => $explain_words); }