/** * 根据部位获取症状 * @author gaoqing * @date 2016-04-13 * @param int $columns 在页面中,显示的列数 * @return array 部位及症状集 */ private static function getPartSymptom($columns) { $partSymptom = []; $part = new Part(); $symptom = new Symptom(); $firstLevel = $part->getPartLevel1(1); if (self::isNotNull($firstLevel)) { foreach ($firstLevel as $level1) { $inner = array(); $inner['part'] = $level1; $size = count($firstLevel) * $columns; $inner['symptom'] = $symptom->getSymptomsByPartid($level1['id'], 'part_level1', 0, $size); $partSymptom[] = $inner; } } return $partSymptom; }
public function actionPromo() { $this->layout = 'parts'; $ids = []; foreach (Part::find()->where('file_foto != ""')->all() as $part) { $ids[$part->id] = null; } $parts = Part::find()->where(['in', 'id', array_rand($ids, 8)])->all(); return $this->render('promo', ['parts' => $parts]); }
public function actionIndex() { Yii::$app->opengraph->title = Seo::Settings()->title; Yii::$app->opengraph->description = Seo::Settings()->description; Yii::$app->opengraph->image = 'http://xn--90agaunhfc3b5f.xn--p1ai/images/regularSprites/logoIQ174.png'; Yii::$app->opengraph->twitter->card = 'summary'; Yii::$app->opengraph->twitter->site = '@Webtest74'; Yii::$app->opengraph->twitter->creator = '@Webtest74'; $ids = []; foreach (Part::find()->where('file_foto != ""')->all() as $part) { $ids[$part->id] = null; } $parts = Part::find()->where(['in', 'id', array_rand($ids, 12)])->all(); return $this->render('index', ['parts' => $parts]); }
/** * 疾病 sitemap * @author gaoqing * @date 2016-04-25 * @return array 响应信息 */ private function diseaseSitemap() { /** * <urlset> * <url> * <loc>http://jb.9939.com/article/2009/0327/1.shtml</loc> * <lastmod>2009-03-27</lastmod> * <changefreq>always</changefreq> * <priority>0.6</priority> * </url> * </urlset> */ $where = $this->_ownership; $sitemap = '<?xml version="1.0" encoding="UTF-8"?>'; $sitemap .= $this->_baidu ? '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">' : '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; //判断jb还是wapjb $prefix = $where == 'pc' ? '' : 'wap_'; //1、生成 疾病 部分的 sitemap $diseases = Disease::find()->asArray()->all(); $sitemap .= $this->setSitemapURL($diseases, $prefix . 'disease'); //2、生成 症状 部分的 sitemap $symptoms = Symptom::find()->asArray()->all(); $sitemap .= $this->setSitemapURL($symptoms, $prefix . 'symptom'); //3、生成 科室 部分的 sitemap $departments = Department::find()->asArray()->all(); $sitemap .= $this->setSitemapURL($departments, $prefix . 'department'); //4、生成 部位 部分的 sitemap $parts = Part::find()->asArray()->all(); $sitemap .= $this->setSitemapURL($parts, $prefix . 'part'); $sitemap .= '</urlset>'; //5、生成 sitemap 文件 if ($where == 'pc') { $frontend = \Yii::getAlias("@frontend"); $frontDomain = \Yii::getAlias("@frontdomain"); } elseif ($where == 'wap') { $frontend = \Yii::getAlias("@wapjb"); $frontDomain = \Yii::getAlias("@mjb_domain"); } // $frontend = \Yii::getAlias("@frontend"); $sitemapFolder = 'sitemap'; $fileFolder = $frontend . '/web/' . $sitemapFolder; if (!file_exists($fileFolder) || !is_dir($fileFolder)) { mkdir($fileFolder, 0755); } $fileName = $this->_baidu ? 'diseasebaidusitemap.xml' : 'diseasesitemap.xml'; if (file_put_contents($fileFolder . '/' . $fileName, $sitemap)) { // $frontDomain = \Yii::getAlias("@frontdomain"); return ['flag' => 1, 'url' => $frontDomain . '/' . $sitemapFolder . '/' . $fileName, 'name' => $fileName]; } return []; }
/** * Finds the Product model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Product the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Part::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * 一级部位下的子部位的数目 * @param type $id * @return array 返回该一级部位下的子部位的数目 */ public function getLevel1ChildNum($id) { return Part::find()->select("count(id) as count")->where('pid=:pid', [':pid' => $id])->asArray()->one(); }
/** * @return \yii\db\ActiveQuery */ public function getParts() { return $this->hasMany(Part::className(), ['category_id' => 'id']); }
/** * 根据疾病id, 获取所属的部位信息 * @author gaoqing * @date 2016-03-23 * @param int $diseaseid 疾病id * @return array 所属的部位信息 */ public static function getPartsByDisid($diseaseid) { $parts = []; //得到 9939_part_disease_rel 的 part id $partDiseases = []; $db = \Yii::$app->db_jbv2; $sql = " SELECT DISTINCT partid FROM 9939_part_disease_rel WHERE diseaseid = '" . $diseaseid . "' ORDER BY partid DESC "; $partDiseases['list'] = $db->createCommand($sql)->queryAll(PDO::FETCH_ASSOC); //根据 part id 得到所有的部位信息 $partids = self::getPartIDsFromPDR($partDiseases); if (!empty($partids)) { $parts = Part::find()->where(['id' => $partids])->orderBy('id DESC')->asArray()->all(); } self::$_sftablename = ""; return $parts; }