/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('comments-models', 'ATTR_ID'), 'name' => Module::t('comments-models', 'ATTR_NAME'), 'status_id' => Module::t('comments-models', 'ATTR_STATUS'), 'created_at' => Module::t('comments-models', 'ATTR_CREATED'), 'updated_at' => Module::t('comments-models', 'ATTR_UPDATED')]; }
<?php /** * Comment update view. * * @var \yii\base\View $this View * @var \stepancher\comments\models\backend\Comment $model Model * @var array $statusArray Status array */ use stepancher\comments\Module; $this->title = Module::t('comments', 'BACKEND_UPDATE_TITLE'); $this->params['subtitle'] = Module::t('comments', 'BACKEND_UPDATE_SUBTITLE'); $this->params['breadcrumbs'] = [['label' => $this->title, 'url' => ['index']], $this->params['subtitle']]; echo $this->render('_form', ['model' => $model, 'statusArray' => $statusArray]);
/** * Disable comments for indicated extension * * @param string $name Extension name * * @return mixed */ public function actionDisable($name) { if (!Model::disableExtension($name)) { Yii::$app->session->setFlash('danger', Module::t('comments-models', 'BACKEND_FLASH_FAIL_ADMIN_DISABLE')); } return $this->redirect(['index']); }
echo Module::t('comments', 'FRONTEND_WIDGET_COMMENTS_DELETE'); ?> </a> <?php } ?> </div> <?php } ?> </div> <?php if ($comment->isDeleted) { ?> <?php echo Module::t('comments', 'FRONTEND_WIDGET_COMMENTS_DELETED_COMMENT_TEXT'); ?> <?php } else { ?> <div class="content" data-comment="content"><?php echo $comment->content; ?> </div> <?php } ?> </div> <?php if ($comment->children) { ?>
<?php /** * Comment model create view. * * @var \yii\base\View $this View * @var \stepancher\comments\models\backend\Model $model Model * @var array $statusArray Statuses array */ use stepancher\comments\Module; $this->title = Module::t('comments-models', 'BACKEND_CREATE_TITLE'); $this->params['subtitle'] = Module::t('comments-models', 'BACKEND_CREATE_SUBTITLE'); $this->params['breadcrumbs'] = [['label' => $this->title, 'url' => ['index']], $this->params['subtitle']]; echo $this->render('_form', ['model' => $model, 'statusArray' => $statusArray]);
* @var \yii\widgets\ActiveForm $form Form * @var \stepancher\comments\models\backend\Model $model Model * @var array $statusArray Statuses array */ use stepancher\comments\Module; use yii\helpers\Html; use yii\widgets\ActiveForm; $form = ActiveForm::begin(); ?> <div class="box"> <div class="box-body"> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'name')->textInput(['placeholder' => Module::t('comments-models', 'BACKEND_CREATE_PLACEHOLDER_NAME')]); ?> </div> <div class="col-sm-6"></div> </div> </div> <div class="box-footer text-left"> <?php echo Html::submitButton($model->isNewRecord ? Module::t('comments-models', 'BACKEND_CREATE_SUBMIT') : Module::t('comments-models', 'BACKEND_UPDATE_SUBMIT'), ['class' => 'btn btn-primary']); ?> </div> </div> <?php ActiveForm::end();
/** * Find model by ID. * * @param integer|array $id Comment ID * * @return Comment Model * * @throws HttpException 404 error if comment not found */ protected function findModel($id) { /** @var Comment $model */ $model = Comment::findOne($id); if ($model !== null) { return $model; } else { throw new HttpException(404, Module::t('comments', 'FRONTEND_FLASH_RECORD_NOT_FOUND')); } }
/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('comments', 'ATTR_ID'), 'parent_id' => Module::t('comments', 'ATTR_PARENT'), 'model_class' => Module::t('comments', 'ATTR_MODEL_CLASS'), 'model_id' => Module::t('comments', 'ATTR_MODEL'), 'author_id' => Module::t('comments', 'ATTR_AUTHOR'), 'content' => Module::t('comments', 'ATTR_CONTENT'), 'status_id' => Module::t('comments', 'ATTR_STATUS'), 'created_at' => Module::t('comments', 'ATTR_CREATED'), 'updated_at' => Module::t('comments', 'ATTR_UPDATED')]; }
<?php /** * Comments widget form view. * @var \yii\web\View $this View * @var \yii\widgets\ActiveForm $form Form * @var \stepancher\comments\models\frontend\Comment $model New comment model */ use stepancher\comments\Module; use yii\helpers\Html; echo Html::beginForm(['/comments/default/create'], 'POST', ['class' => 'form-horizontal', 'data-comment' => 'form', 'data-comment-action' => 'create']); ?> <div class="form-group" data-comment="form-group"> <div class="col-sm-12"> <?php echo Html::activeTextarea($model, 'content', ['class' => 'form-control']); ?> <?php echo Html::error($model, 'content', ['data-comment' => 'form-summary', 'class' => 'help-block hidden']); ?> </div> </div> <?php echo Html::activeHiddenInput($model, 'parent_id', ['data-comment' => 'parent-id']); echo Html::activeHiddenInput($model, 'model_class'); echo Html::activeHiddenInput($model, 'model_id'); echo Html::submitButton(Module::t('comments', 'FRONTEND_WIDGET_COMMENTS_FORM_SUBMIT'), ['class' => 'btn btn-danger btn-lg']); echo Html::endForm();
<?php /** * @var \yii\base\View $this View * @var \yii\data\ActiveDataProvider $dataProvider Data provider * @var \stepancher\comments\models\backend\CommentSearch $searchModel Search model * @var array $statusArray Statuses array */ use stepancher\comments\Module; use kartik\grid\GridView; use kartik\dynagrid\DynaGrid; use yii\grid\ActionColumn; use yii\helpers\Html; $this->title = Module::t('comments-models', 'BACKEND_INDEX_TITLE'); $this->params['subtitle'] = Module::t('comments-models', 'BACKEND_INDEX_SUBTITLE'); $this->params['breadcrumbs'] = [$this->title]; $columns = [['class' => 'kartik\\grid\\SerialColumn', 'order' => DynaGrid::ORDER_FIX_LEFT], 'id', 'name', ['attribute' => 'status_id', 'format' => 'html', 'value' => function ($model) { $class = $model->status_id === $model::STATUS_ENABLED ? 'label-success' : 'label-danger'; return '<span class="label ' . $class . '">' . $model->status . '</span>'; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $statusArray, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '---']], ['attribute' => 'created_at', 'format' => 'date'], ['attribute' => 'updated_at', 'format' => 'date'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '<nobr>{update}{delete}</nobr>', 'buttons' => ['update' => function ($url, $model) { return Html::a('<span class="icon fa fa-edit"></span>', $url, ['class' => 'btn btn-sm btn-primary']); }, 'delete' => function ($url, $model) { return Html::a('<span class="icon fa fa-trash"></span>', $url, ['class' => 'btn btn-sm btn-danger isDel']); }]]]; $dynaGridOptions = ['columns' => $columns, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['before' => Html::a('<i class="btn-label glyphicon fa fa-plus"></i>   ' . Module::t('comments-models', 'BACKEND_CREATE_SUBTITLE'), ['create'], ['class' => 'btn btn-labeled btn-success no-margin-t']), 'after' => '<div class="pull-right">{pager}</div>']], 'options' => ['id' => 'dynagrid-comments-models']]; if (class_exists('\\stepancher\\adminlteTheme\\config\\AnminLteThemeConfig')) { DynaGrid::begin(\yii\helpers\ArrayHelper::merge(\stepancher\adminlteTheme\config\AnminLteThemeConfig::getDefaultConfigDynagrid(), $dynaGridOptions)); } else { DynaGrid::begin(['columns' => $columns, 'toggleButtonGrid' => ['label' => '<i class="glyphicon glyphicon-wrench"></i>   Настройки'], 'toggleButtonFilter' => ['label' => '<i class="glyphicon glyphicon-filter"></i>    Фильтры'], 'toggleButtonSort' => ['label' => '<i class="glyphicon glyphicon-sort"></i>    Сортировка'], 'storage' => DynaGrid::TYPE_DB, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Сбросить', [''], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Обновить'])], ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}{toggleData}'], '{export}'], 'export' => ['label' => 'Экспорт'], 'panel' => ['before' => Html::a('<i class="btn-label glyphicon fa fa-plus"></i>   ' . Module::t('comments-models', 'BACKEND_CREATE_SUBTITLE'), ['create'], ['class' => 'btn btn-labeled btn-success no-margin-t']), 'after' => false]], 'options' => ['id' => 'dynagrid-comments-models']]); } DynaGrid::end();
* Comments list view. * * @var \yii\web\View $this View * @var \stepancher\comments\models\frontend\Comment[] $models Comments models * @var \stepancher\comments\models\frontend\Comment $model New comment model */ use stepancher\comments\Module; ?> <div id="comments"> <div id="comments-list" data-comment="list"> <?php echo $this->render('_index_item', ['models' => $models]); ?> </div> <!--/ #comments-list --> <?php if (Yii::$app->user->can('createComments')) { ?> <h3><?php echo Module::t('comments', 'FRONTEND_WIDGET_COMMENTS_FORM_TITLE'); ?> </h3> <?php echo $this->render('_form', ['model' => $model]); ?> <?php } ?> </div>