request->post(); $model = new NewKnowledgelabel(); $model->pid =0; $result =$model->getList([],'id,pid,name',2); $result = ArrayHelper::toArray($result); foreach($result as $k=>$v){ $model->pid =$v['id']; $arr =$model->getList([],'id,pid,name',1); $arr = ArrayHelper::toArray($arr); $result[$k]['child']=$arr; } return $this->render('index',['result'=>$result]); } public function actionList() { $model = new NewKnowledgelabel(); $model->pid =0; $result =$model->getList([],'id,pid,name',2); $result = ArrayHelper::toArray($result); foreach($result as $k=>$v){ $model->pid =$v['id']; $arr =$model->getList([],'id,pid,name',1); $arr = ArrayHelper::toArray($arr); $result[$k]['child']=$arr; } $query = $model::find(); $query->select('name'); $query->andWhere(['del'=>1]); $query->andFilterWhere(['id'=>Yii::$app->request->get('cid')]); $row = $query->asArray()->one();//单个栏目 $models = new NewsKnowledge(); if(Yii::$app->request->get('cid') != 0) { $models->label_id = Yii::$app->request->get('cid'); } $knowData=$models->getTitle(Yii::$app->request->get(),'id,subject,thumb,abstract,source,clicks,create_at',1); foreach($knowData['data'] as $k=>$v){ $knowData['data'][$k]['thumb']=json_decode($v['thumb'],true); $knowData['data'][$k]['create_at']=date("Y-m-d H:i:s",$v['create_at']); } $newsModel= new News(); $newsClick = $newsModel->Clicks(10); return $this->render('list',['result'=>$result,'newsClick'=>$newsClick,'knowData'=>$knowData['data'],'page'=>$knowData['page'],'row'=>$row,]); } public function actionGetlist() { $model = new NewsKnowledge(); if(Yii::$app->request->get('id') != 0) { $model->label_id = Yii::$app->request->get('id'); } $knowData=$model->getTitle([],'id,subject,thumb,abstract,source,clicks,create_at',1); foreach($knowData as $k=>$v){ $knowData[$k]['thumb']=json_decode($v['thumb'],true); $knowData[$k]['create_at']=date("Y-m-d H:i:s",$v['create_at']); } if(!empty($knowData)){ return Help::JsonCode(Help::SUCCESS,'成功',$knowData); } return Help::JsonCode(Help::ERROR,'失败'); } public function actionDetails() { $input = Yii::$app->request->get(); $model= new NewsKnowledge(); $row = $model->NewsKnowledgeDetails($input); if(empty($row)) return $this->goBack(); $row['create_at']=date("Y-m-d H:i",$row['create_at']); $newsModel= new News(); // $newsClick = $newsModel->Clicks(10); $newsClick = $model->RelevantArticle(['id','subject'],10); $hotHouse = $this->HotHouse(); //热度关键词 $participle=$this->Participle(); $prev=$this->prev($input); $next=$this->next($input); return $this->render('details',['row'=>$row,'newsClick'=>$newsClick,'hotHouse'=>$hotHouse,'participle'=>$participle,'prev'=>$prev,'next'=>$next]); } /*上一篇*/ public function prev($input) { $model= new NewsKnowledge(); $input['mark']='>'; return $model->getPage($input); } /*下一篇*/ public function next($input) { $model= new NewsKnowledge(); $input['mark']='<'; return $model->getPage($input); } /*分词*/ private function Participle() { $model = new NewKnowledgelabel(); $model->pid !=0; return $model->getList([],'id,pid,name',3); } private function HotHouse() { $model = new PushHousesale(); $model->type = 1; if(Yii::$app->hostserver->hostId != 0) { $model->city = Yii::$app->hostserver->hostId; } $rows = $model->Homegetlist(4); if($rows != null) { $zhuti = new \frontend\server\HouseServer(); foreach ($rows as &$val) { $val['characteristic'] = $zhuti->Subject( json_decode($val['characteristic']),2); $val['thumb'] = Yii::$app->params['httpImg']['hosts'].Yii::$app->params['httpImg']['houses']. $val['thumb']; } return $rows; } } public function actionTools() { return $this->render('tools'); } }