Esempio n. 1
0
 /**
  * Displays a single Items model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $searchModelComments = new CommentsSearch();
     $dataProviderComments = $searchModelComments->searchItemComments($id);
     //        var_dump($dataProviderComments);
     //        exit();
     return $this->render('view', ['model' => $this->findModel($id), 'dataProviderComments' => $dataProviderComments]);
 }
Esempio n. 2
0
 /**
  * Displays a grid containing all Objects of this API.
  * @param integer $id
  * @param boolean $propose
  * @param boolean $followed
  * @param boolean $followersNotified
  * @return mixed
  */
 public function actionView($id, $propose = false, $followed = null, $followersNotified = null)
 {
     $searchModel = new ObjectsSearch();
     $dataProvider = $searchModel->search(['ObjectsSearch' => ['api' => $id]]);
     $commentSearchModel = new CommentsSearch();
     $commentsProvider = $commentSearchModel->findCommentsNotReplies(['CommentsSearch' => ['api' => $id]]);
     $repliesProvider = $commentSearchModel->findReplies(['CommentsSearch' => ['api' => $id]]);
     $repliesProvider->setPagination(false);
     $commentsModel = new Comments();
     $commentsModel->api = $id;
     if ($commentsModel->load(Yii::$app->request->post())) {
         $commentsModel->save();
     }
     $myId = \Yii::$app->user->id;
     $followUserAPI = FollowUserApi::findOne(['follower' => $myId, 'api' => $id]);
     $doIFollow = false;
     if ($followUserAPI) {
         $doIFollow = true;
         $followUserAPI->last_seen = date('Y-m-d H:i:s');
         $followUserAPI->changed_name = false;
         $followUserAPI->changed_descr = false;
         $followUserAPI->changed_version = false;
         $followUserAPI->changed_proposed = false;
         $followUserAPI->changed_published = false;
         $followUserAPI->changed_privacy = false;
         $followUserAPI->changed_upvotes = 0;
         $followUserAPI->changed_downvotes = 0;
         $followUserAPI->changed_objects_number = 0;
         $followUserAPI->save();
     }
     $followers = FollowUserApi::find()->where(['api' => $id])->count();
     $this->view->params['followers_notified'] = $followersNotified;
     $this->view->params['propose'] = $propose;
     $this->view->params['followed'] = $followed;
     // Elastic Search Query for Recommendations
     $esq = new ElasticSearchQuery();
     $api = $this->findModel($id);
     $esq->setApi($api);
     $esq->MakeJSON();
     $recommend = $esq->Build();
     return $this->render('view', ['model' => $this->findModel($id), 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'doIFollow' => $doIFollow, 'followers' => $followers, 'commentsProvider' => $commentsProvider, 'repliesProvider' => $repliesProvider, 'commentsModel' => $commentsModel, 'recommend' => $recommend]);
 }
 /**
  * Lists all Comments models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new CommentsSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }