Esempio n. 1
0
 public function init()
 {
     parent::init();
     $this->module = \Yii::$app->getModule(Module::$name);
     // Текущий модуль
     $model = new PostComment();
     $this->comments = $model->getRecentPostComments($this->limit);
 }
Esempio n. 2
0
<p><?php 
echo Markdown::convert($model->anons);
?>
</p>


<p>
    <?php 
if (PostComment::getCountComments($model->id) > 0) {
    ?>
        <span class="glyphicon glyphicon-comment"></span>&nbsp; <a href="<?php 
    echo Url::to(['default/view', 'id' => $model->id, '#' => 'comments']);
    ?>
"><?php 
    echo Module::t('module', 'COMMENTS:{count}', ['count' => PostComment::getCountComments($model->id)]);
    ?>
</a> |
    <?php 
}
?>
    <?php 
if ($model->tagLinks) {
    ?>
        <span class="glyphicon glyphicon-tags"></span>&nbsp; <?php 
    echo Tags::array2string($model->tagLinks);
    ?>
    <?php 
}
?>
</p>
Esempio n. 3
0
 /**
  * @param $id
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function getComments($id)
 {
     return PostComment::find()->where(['moder' => PostComment::COMMENT_MODER_ALLOWED])->andWhere(['material_id' => $id])->andWhere(['type' => PostComment::TYPE_OF_COMMENT])->all();
 }
Esempio n. 4
0
 /**
  * Возвращает все комментарии к посту
  * и осуществляет связь hasMany с PostComment
  * @return ActiveQuery
  */
 public function getComments()
 {
     return $this->hasMany(PostComment::className(), ['material_id' => 'id'])->where(['namespace' => PostComment::MATERIAL_MODEL_OF_NAMESPACE])->orderBy(['parent_id' => SORT_ASC, 'id' => SORT_ASC]);
 }