Ejemplo n.º 1
0
 /**
  * Executes the widget.
  */
 public function run()
 {
     $modelName = $this->object->content->object_model;
     $modelId = $this->object->content->object_id;
     // Count all Comments
     $commentCount = \humhub\modules\comment\models\Comment::GetCommentCount($modelName, $modelId);
     $comments = \humhub\modules\comment\models\Comment::GetCommentsLimited($modelName, $modelId, 2);
     $isLimited = $commentCount > 2;
     return $this->render('comments', array('object' => $this->object, 'comments' => $comments, 'modelName' => $modelName, 'modelId' => $modelId, 'id' => $this->object->getUniqueId(), 'isLimited' => $isLimited, 'total' => $commentCount));
 }
Ejemplo n.º 2
0
 /**
  * Returns a List of all Comments belong to this Model
  */
 public function actionShow()
 {
     $content = $this->parentContent;
     $pagination = new \yii\data\Pagination(['totalCount' => Comment::GetCommentCount($content->className(), $content->getPrimaryKey()), 'pageSize' => $this->module->commentsBlockLoadSize]);
     $query = Comment::find();
     $query->orderBy('created_at DESC');
     $query->where(['object_model' => $content->className(), 'object_id' => $content->getPrimaryKey()]);
     $query->offset($pagination->offset)->limit($pagination->limit);
     $comments = array_reverse($query->all());
     $output = \humhub\modules\comment\widgets\ShowMore::widget(['pagination' => $pagination, 'object' => $content]);
     foreach ($comments as $comment) {
         $output .= \humhub\modules\comment\widgets\Comment::widget(['comment' => $comment]);
     }
     if (Yii::$app->request->get('mode') == 'popup') {
         return $this->renderAjax('showPopup', array('object' => $content, 'output' => $output, 'id' => $content->getUniqueId()));
     } else {
         return $this->renderAjaxContent($output);
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns count of existing comments
  *
  * @return Int Comment Count
  */
 public function getCommentsCount()
 {
     return \humhub\modules\comment\models\Comment::GetCommentCount(get_class($this->object), $this->object->getPrimaryKey());
 }
Ejemplo n.º 4
0
                    <div class="task-controls pull-right">

                        <a data-toggle="collapse"
                           href="#task-comment-<?php 
        echo $task->id;
        ?>
"
                           onclick="$('#comment_humhubmodulestasksmodelsTask_<?php 
        echo $task->id;
        ?>
').show();return false;"
                           aria-expanded="false"
                           aria-controls="collapseTaskComments"><i
                                class="fa fa-comment-o"></i> <?php 
        echo $count = Comment::GetCommentCount($task->className(), $task->id);
        ?>
                        </a>

                    </div>


                    <div class="task-controls pull-right assigned-users task-completed-controls"
                         style="display: inline;">
                        <!-- Show assigned user -->
                        <?php 
        foreach ($task->assignedUsers as $user) {
            ?>
                            <a href="<?php 
            echo $user->getUrl();
            ?>