Exemple #1
0
 /**
  * Finds the Comment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Comment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Comment::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #2
0
 /** @inheritdoc */
 public function run()
 {
     $model = new Comment();
     /*if ($this->validate && $model->load(\Yii::$app->request->post()) && $model->login()) {
                 return \Yii::$app->response->redirect(\Yii::$app->user->returnUrl);
             }
     */
     if (!$model->setThread($this->module, $this->itemid)) {
         throw new InvalidConfigException("Module or ItemID unexpected (" . $this->module . '/' . $this->itemid . "). Allows only [0-9a-zA-Z_].");
     }
     $comments = Comment::find()->comments($this->module, $this->itemid)->count();
     $this->registerClientScript();
     $view = $this->getView();
     $view->registerJs("jQuery('#threads-comments-{$model->thread}').threads();");
     $coms = [['time' => '123', 'text' => '234'], ['time' => '1asdasd23', 'text' => 'qweqweqw']];
     //$view->registerJs("$('#commentTemplate').tmpl(".json_encode($coms).").appendTo('#commentList');");
     //$this->action['thread']=$model->getThread();
     return $this->render('comments', ['model' => $model, 'comments' => $comments, 'action' => \yii\helpers\Url::to($this->action)]);
 }