예제 #1
0
<?php

use yeesoft\comments\Comments;
use yii\helpers\ArrayHelper;
use yii\widgets\ListView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $model yeesoft\comments\models\Comment */
?>

<?php 
$containerClass = ArrayHelper::getValue($dataProvider->query->where, 'parent_id') ? 'sub-comments' : 'comments';
?>

<?php 
if ($comment) {
    Pjax::begin();
    echo ListView::widget(['dataProvider' => $dataProvider, 'emptyText' => Comments::t('comments', 'No Comments'), 'itemView' => function ($model, $key, $index, $widget) use($comment, $nested_level) {
        return $this->render('item', compact('model', 'widget', 'comment', 'nested_level'));
    }, 'options' => ['class' => $containerClass], 'itemOptions' => ['class' => 'comment'], 'layout' => '{items}<div class="text-center">{pager}</div>', 'pager' => ['class' => yii\widgets\LinkPager::className(), 'options' => ['class' => 'pagination pagination-sm']]]);
    Pjax::end();
}
예제 #2
0
 /**
  * getStatusOptionsList
  * @return array
  */
 public static function getStatusOptionsList()
 {
     return [[self::STATUS_PENDING, Comments::t('comments', 'Pending'), 'default'], [self::STATUS_APPROVED, Comments::t('comments', 'Approved'), 'primary'], [self::STATUS_SPAM, Comments::t('comments', 'Spam'), 'default'], [self::STATUS_TRASH, Comments::t('comments', 'Trash'), 'default']];
 }
예제 #3
0
use yeesoft\comments\widgets\CommentsForm;
use yeesoft\comments\widgets\CommentsList;
use yii\timeago\TimeAgo;
/* @var $this yii\web\View */
/* @var $model yeesoft\comments\models\Comment */
$commentsPage = Yii::$app->getRequest()->get("comment-page", 1);
$cacheKey = 'comment' . $model . $model_id . $commentsPage . substr(\Yii::$app->language, 0, 2);
//SIMONE forse non indispensabile, ma logico
$cacheProperties = CommentsHelper::getCacheProperties($model, $model_id);
?>
<div class="comments">
    <?php 
if ($this->beginCache($cacheKey . '-count', $cacheProperties)) {
    ?>
        <h5><?php 
    echo Comments::t('comments', 'All Comments');
    ?>
 (<?php 
    echo Comment::activeCount($model, $model_id);
    ?>
)</h5>
        <?php 
    $this->endCache();
    ?>
    <?php 
}
?>

    <?php 
if (!Comments::getInstance()->onlyRegistered || !Yii::$app->user->isGuest) {
    ?>
예제 #4
0
    ?>
        <div class="comments-main-form">
            <?php 
    echo CommentsForm::widget();
    ?>
        </div>
    <?php 
}
?>

    <?php 
if ($this->beginCache($cacheKey, $cacheProperties)) {
    ?>
        <?php 
    Pjax::begin();
    echo ListView::widget(['dataProvider' => $dataProvider, 'emptyText' => CommentsModule::t('comments', 'No Comments'), 'itemView' => function ($model, $key, $index, $widget) {
        $nested_level = 1;
        return $this->render('comment', compact('model', 'widget', 'nested_level'));
    }, 'options' => ['class' => 'comments'], 'itemOptions' => ['class' => 'comment'], 'layout' => '{items}<div class="text-center">{pager}</div>', 'pager' => ['class' => yii\widgets\LinkPager::className(), 'options' => ['class' => 'pagination pagination-sm']]]);
    Pjax::end();
    $this->endCache();
    ?>
    <?php 
} else {
    ?>
        <?php 
    TimeAgo::widget();
    ?>
    <?php 
}
?>
예제 #5
0
                        <div class="col-lg-6">
                            <?php 
    echo $form->field($comment, 'username', ['enableAjaxValidation' => true])->textInput(['maxlength' => true, 'class' => 'form-control input-sm', 'placeholder' => Comments::t('comments', 'Your name')])->label(false);
    ?>
                        </div>
                        <div class="col-lg-6">
                            <?php 
    echo $form->field($comment, 'email')->textInput(['maxlength' => true, 'email' => true, 'class' => 'form-control input-sm', 'placeholder' => Comments::t('comments', 'Your email')])->label(false);
    ?>
                        </div>
                    <?php 
} else {
    ?>
                        <div class="col-lg-6">
                            <?php 
    echo ($comment->parent_id ? Comments::t('comments', 'Reply as') : Comments::t('comments', 'Post as')) . ' <b>' . Yii::$app->user->identity->username . '</b>';
    ?>
                        </div>
                    <?php 
}
?>
                </div>
            </div>
        </div>

    </div>

    <?php 
ActiveForm::end();
?>
예제 #6
0
echo Html::encode($model->content);
?>
    </div>
    <?php 
if ($nested_level < Comments::getInstance()->maxNestedLevel) {
    ?>
        <div class="comment-footer">
            <?php 
    if (!Comments::getInstance()->onlyRegistered || !Yii::$app->user->isGuest) {
        ?>
                <a class="reply-button" data-reply-to="<?php 
        echo $model->id;
        ?>
"
                   href="#"><?php 
        echo Comments::t('comments', 'Reply');
        ?>
</a>
                <!--<span class="dot-left"></span>
                <a class="glyphicon glyphicon-thumbs-up"></a> <span>0</span> &nbsp;
                <a class="glyphicon glyphicon-thumbs-down"></a> <span>0</span><span class="dot-left"></span>
                -->
            <?php 
    }
    ?>
        </div>
    <?php 
}
?>
</div>
예제 #7
0
<?php

use yeesoft\comments\Comments;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model yeesoft\comments\models\Comment */
$this->title = Yii::t('yee', 'Update "{item}"', ['item' => Comments::t('comments', 'Comment')]);
$this->params['breadcrumbs'][] = ['label' => Comments::t('comments', 'Comments'), 'url' => ['index']];
$this->params['breadcrumbs'][] = Yii::t('yee', 'Update');
?>
<div class="comment-update">
    <h3 class="lte-hide-title"><?php 
echo Html::encode($this->title);
?>
</h3>
    <?php 
echo $this->render('_form', compact('model'));
?>
</div>
예제 #8
0
?>
                </div>

                <div class="col-sm-6 text-right">
                    <?php 
echo GridPageSize::widget(['pjaxId' => 'comment-grid-pjax']);
?>
                </div>
            </div>

            <?php 
Pjax::begin(['id' => 'comment-grid-pjax']);
?>

            <?php 
echo GridView::widget(['id' => 'comment-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'bulkActionOptions' => ['gridId' => 'comment-grid', 'actions' => [Url::to(['bulk-activate']) => Comments::t('comments', 'Approve'), Url::to(['bulk-deactivate']) => Comments::t('comments', 'Unapprove'), Url::to(['bulk-spam']) => Comments::t('comments', 'Mark as Spam'), Url::to(['bulk-trash']) => Comments::t('comments', 'Move to Trash'), Url::to(['bulk-delete']) => Yii::t('yee', 'Delete')]], 'columns' => [['class' => 'yeesoft\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['class' => 'yeesoft\\grid\\columns\\TitleActionColumn', 'controller' => '/comment/default', 'attribute' => 'content', 'title' => function (Comment $model) {
    return Html::a(mb_substr($model->content, 0, 32) . '...', ['/comment/default/update', 'id' => $model->id], ['data-pjax' => 0]);
}, 'buttonsTemplate' => '{update} {delete}'], ['label' => Yii::t('yee', 'User'), 'value' => function (Comment $model) {
    return $model->getAuthor();
}, 'options' => ['style' => 'width:150px']], ['attribute' => 'model', 'value' => function (Comment $model) {
    return $model->model . ($model->model_id ? ' [' . $model->model_id . ']' : '');
}, 'options' => ['style' => 'width:120px']], ['class' => 'yeesoft\\grid\\columns\\StatusColumn', 'attribute' => 'status', 'optionsArray' => Comment::getStatusOptionsList(), 'options' => ['style' => 'width:60px']], ['class' => 'yeesoft\\grid\\columns\\DateFilterColumn', 'attribute' => 'created_at', 'value' => function (Comment $model) {
    return '<span style="font-size:85%;" class="label label-' . (time() >= $model->created_at ? 'primary' : 'default') . '">' . $model->createdDate . ' ' . $model->createdTime . '</span>';
}, 'format' => 'raw', 'options' => ['style' => 'width:150px']], ['attribute' => 'user_ip', 'options' => ['style' => 'width:100px']]]]);
?>

            <?php 
Pjax::end();
?>
        </div>
    </div>