Example #1
0
 public function run()
 {
     $model = new Comment();
     $model->scenario = Yii::$app->user->isGuest ? Comment::SCENARIO_GUEST : Comment::SCENARIO_USER;
     $model->load(Yii::$app->getRequest()->post());
     if ($model->save()) {
         if (Yii::$app->user->isGuest) {
             $cookie = new Cookie(['name' => "username", 'value' => $model->username, 'expire' => time() + 86400 * 365]);
             Yii::$app->getResponse()->getCookies()->add($cookie);
             $cookie = new Cookie(['name' => "email", 'value' => $model->email, 'expire' => time() + 86400 * 365]);
             Yii::$app->getResponse()->getCookies()->add($cookie);
         }
         $content = CommentsList::widget(["entity" => $model->entity, "entity_id" => $model->entity_id, "dataProvider" => new ActiveDataProvider(['query' => Comment::find()->where(['comment_id' => $model->comment_id])]), "nestedLevel" => Yii::$app->getRequest()->post("nestedLevel") + 1]);
         return $this->controller->renderJsonMessage(true, $content);
     }
     return $this->controller->renderJsonMessage(false, $model->formatErrors());
 }
Example #2
0
        echo $model->entity;
        ?>
" data-entity-id="<?php 
        echo $model->entity_id;
        ?>
" href="#">回复</a>
    </div>
     <div class="reply-form" data-nestedLevel="<?php 
        echo $nestedLevel;
        ?>
">

     </div>
     <?php 
        if ($model->isReplied()) {
            echo CommentsList::widget(['entity' => $entity, "entity_id" => $entity_id, "parent_id" => $model->comment_id, "nestedLevel" => $nestedLevel + 1]);
        }
        ?>
    <?php 
    }
    ?>
  </div>
</div>
<?php 
}
?>

<?php 
if ($nestedLevel == 1) {
    ?>
</div>
Example #3
0
<?php

use hass\comment\widgets\CommentsForm;
use hass\comment\widgets\CommentsList;
/* @var $this yii\web\View */
/* @var $model hass\comment\models\Comment */
?>

<div class="panel">
	<div class="panel-body">
       <?php 
echo CommentsForm::widget(['entity' => $entity, "entity_id" => $entity_id, "commentUrl" => $commentUrl]);
?>
    </div>
</div>
<?php 
echo CommentsList::widget(['entity' => $entity, "entity_id" => $entity_id, "replyFormUrl" => $replyFormUrl]);