예제 #1
0
 /**
  * @return Response
  */
 public function actionTagSuggest()
 {
     $response = ['data' => ['status' => false], 'format' => 'json'];
     if (isset($_GET['q']) && ($keyword = trim($_GET['q'])) !== '') {
         $response['data']['items'] = Tag::suggest($keyword);
     }
     return new Response($response);
 }
예제 #2
0
 /**
  * @param $tags
  * @return string
  */
 public function run($tags)
 {
     $tags = Tag::string2Array($tags);
     /** @var QuestionSearch $searchModel */
     $searchModel = $this->getModel();
     $dataProvider = $searchModel->search(['tags' => $tags]);
     $models = $dataProvider->getModels();
     return $this->render(compact('searchModel', 'models', 'dataProvider', 'tags'));
 }
예제 #3
0
파일: TagSearch.php 프로젝트: faninv/gtqa
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tag::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'frequency' => $this->frequency]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
예제 #4
0
 /**
  * Finds the Tag model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tag the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Tag::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #5
0
파일: Question.php 프로젝트: faninv/gtqa
 /**
  * @return array a list of links that point to the post list filtered by every tag of this post
  */
 public function getTagsList()
 {
     return Tag::string2Array($this->tags);
 }
 public function down()
 {
     $this->dropTable(Tag::tableName());
 }
예제 #7
0
파일: Tags.php 프로젝트: faninv/gtqa
 /**
  * @inheritdoc
  */
 public function run()
 {
     $models = Tag::find()->orderBy('frequency')->limit($this->limit)->all();
     return $this->render('tags', ['models' => $models]);
 }