コード例 #1
0
 /**
  * Lists all Notecomment models.
  * @return mixed
  */
 public function actionIndex()
 {
     $list = '';
     $post = Yii::$app->request->post();
     if ($post['id']) {
         $mod = new Query();
         $comment = $mod->select(['a.id', 'a.parentId', 'a.noteId', 'a.content', 'a.createTime', 'b.username'])->from('notecomment as a')->leftJoin('user as b', 'a.userId = b.id')->where(['commentId' => $post['id']])->orderBy(['createTime' => 'DESC', 'id' => 'DESC'])->createCommand()->queryAll();
         if ($comment) {
             foreach ($comment as $v) {
                 $content = '回复@' . Notecomment::getCommentByParId($v['parentId']) . ':' . $v['content'];
                 $ahtml = html::a(html::tag("i", "", ["class" => "fa fa-thumbs-o-up"]) . html::tag("span", "回复"), ["/main/viewart", "id" => $v["articleId"], "parId" => $v['id']]);
                 $list .= '<div class="infos small-comment' . $post['id'] . '" style="border:1px solid;">
                         	<div class="media-body markdown-reply content-body">
                         		<p>' . $content . '</p>
                         		<span class="opts pull-right">
                         			<a class="author" >' . $v["username"] . '</a>
                         			•
                         			<addr title="' . $v["createTime"] . '">' . Html::tag("span", Yii::$app->formatter->asRelativeTime($v["createTime"])) . '</addr>
                         			' . $ahtml . '
                                 </span>
                         	</div>
                         </div>';
             }
         }
     }
     $result = array('success' => true, 'message' => $list);
     echo json_encode($result);
     die;
     return $this->renderAjax('index', ['success' => true, 'message' => '']);
 }
コード例 #2
0
ファイル: _form.php プロジェクト: kennygp/yii-myweb
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\Notecomment;
use common\models\User;
use yii\console\Markdown;
/* @var $this yii\web\View */
/* @var $model app\models\Notecomment */
/* @var $form yii\widgets\ActiveForm */
if ($parId) {
    $username = Notecomment::getCommentByParId($parId);
    $huifu = '回复' . $username;
} else {
    $huifu = '';
    $parId = 0;
    $username = '';
}
?>

<div class="notecomment-form">

    <?php 
$form = ActiveForm::begin(['action' => ['/notecomment/create']]);
?>

    <?php 
echo $form->field($model, 'content')->textarea(['rows' => 6, 'placeholder' => $huifu]);
?>
    
    <?php 
コード例 #3
0
ファイル: MainController.php プロジェクト: kennygp/yii-myweb
 /**
  * 根据主表Id显示笔记详情
  *
  * @param
  *            $id
  * @return Ambigous <string, string>
  */
 public function actionViewnote($id)
 {
     $user = Notecomment::getCommentByParId(1);
     $get = Yii::$app->request->get();
     if ($this->addScanNum($id)) {
         $mod = new Query();
         $comment = $mod->select(['a.id', 'a.content', 'a.createTime', 'b.username'])->from('notecomment as a')->leftJoin('user as b', 'a.userId = b.id')->where(['noteId' => $id, 'parentId' => 0])->createCommand();
         $renArr = ['model' => $this->findModel($id), 'comment' => $comment->queryAll(), 'tags' => $this->getHotTag(), 'hotnote' => $this->getHotAsk(3), 'commentMod' => new Notecomment(), 'parId' => isset($get['parId']) ? $get['parId'] : ''];
         return $this->render('viewnote', $renArr);
     }
 }