Пример #1
0
 public function actionComment()
 {
     $model = new CommentForm();
     if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('commentFormSubmitted');
         StoreUtils::sendPendingEmails();
         return $this->refresh();
     }
     return $this->render('comment', ['model' => $model]);
 }
Пример #2
0
 public function actionProduct($id = null)
 {
     $product = Products::find()->where(['id' => $id])->one();
     $sec = Sections::find(['title'])->where(['id' => $product->section_id])->one();
     $others = Products::find()->orderBy(['date' => SORT_DESC])->where(['section_id' => $product->section_id])->andWhere(['not in', 'id', [$id]])->limit(4)->all();
     $comments = Comments::find()->where(['product_id' => $id])->orderBy(['id' => SORT_DESC])->all();
     $model = new CommentForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $com = new Comments();
         $com->product_id = $id;
         $com->login = Yii::$app->session->get('login');
         $com->comment = $model->comment;
         $com->save();
         return $this->redirect(Yii::$app->request->referrer);
     }
     return $this->render('product', ['product' => $product, 'section_title' => $sec, 'others' => $others, 'model' => $model, 'comments' => $comments]);
 }
Пример #3
0
 public function actionMore($id)
 {
     $model = new CommentForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $comment = $model->addComment($id);
         if (!$comment) {
             Yii::$app->session->setFlash('error', 'Ошибка при валидации');
             Yii::error('Ошибка при валидации');
             return $this->refresh();
         }
     }
     $tour = Tour::findOne($id);
     //->all();
     $gallery = Gallery::find()->where(['id_tour' => $id])->all();
     $comments = $model->getComments($id);
     return $this->render('more', ['tour' => $tour, 'gallery' => $gallery, 'model' => $model, 'comments' => $comments]);
 }
Пример #4
0
 public function actionView($id, $page = null, $pageSize = null)
 {
     $pageSize = $pageSize ?: Yii::$app->params['pageSize'];
     $page = $page ?: 1;
     $offset = ($page - 1) * $pageSize;
     /** @var iLinkoScope $api */
     $api = Yii::$app->linko->getApi();
     $form = new CommentForm();
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $comment = new Comment(['postId' => $id, 'content' => $form->comment, 'authorId' => Yii::$app->user->id, 'authorName' => Yii::$app->user->getIdentity()->username]);
         $api->addComment($comment);
         Yii::$app->session->setFlash('info', 'Your comment was added.');
         $this->redirect(['view', 'id' => $id]);
     }
     if ($form->hasErrors()) {
         Yii::$app->session->setFlash('error', implode('<br />', $form->getFirstErrors()));
     }
     $linkObject = $api->getLink($id);
     $req = new GetCommentsRequest();
     $req->maxResults = $pageSize;
     $req->offset = $offset;
     $req->linkId = $id;
     $comments = $api->getComments($req);
     $data = new ArrayDataProvider(['totalCount' => $comments->totalResults, 'models' => $comments->comments, 'pagination' => ['totalCount' => $comments->totalResults, 'defaultPageSize' => $pageSize]]);
     return $this->render('view', ['link' => $linkObject, 'comments' => $data, 'commentForm' => $form]);
 }
Пример #5
0
 public function actionMessages($id)
 {
     $model = new CommentForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->postMessage()) {
             $this->refresh();
         }
     }
     $messages = QueryModel::messages($id);
     return $this->render('messages', ['messages' => $messages, 'model' => $model]);
 }