示例#1
0
 public function run($id)
 {
     /** @var PostBase $model */
     $model = $this->findModel((int) $id);
     if ($this->checkAccess) {
         call_user_func($this->checkAccess, $this->id, $model);
     }
     $model->scenario = $this->scenario;
     /* @var $modelClass PostBase */
     $modelClass = $this->modelClass;
     $statusArray = $modelClass::statusLabels();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->save(false)) {
                 return $this->controller->refresh();
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('admin', 'BACKEND_FLASH_FAIL_ADMIN_UPDATE'));
                 return $this->controller->refresh();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     return $this->controller->render('update', ['model' => $model, 'statusArray' => $statusArray]);
 }
示例#2
0
 public function run()
 {
     $modelClass = $this->modelClass;
     $model = new $modelClass(['scenario' => $this->scenario]);
     $statusArray = $modelClass::statusLabels();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->save(false)) {
                 return $this->controller->redirect(['update', 'id' => $model->id]);
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('page', 'BACKEND_FLASH_FAIL_ADMIN_CREATE'));
                 return $this->controller->refresh();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     return $this->controller->render('create', ['model' => $model, 'statusArray' => $statusArray]);
 }
 /**
  * Update model page.
  *
  * @param integer $id Post ID
  *
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model->setScenario('admin-update');
     $statusArray = PageModel::statusLabels();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->save(false)) {
                 return $this->refresh();
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('comments-models', 'BACKEND_FLASH_FAIL_ADMIN_UPDATE'));
                 return $this->refresh();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     return $this->render('update', ['model' => $model, 'statusArray' => $statusArray]);
 }
示例#4
0
<?php

/**
 * Blog create view.
 *
 * @var \yii\base\View $this View
 * @var \app\themes\admin\widgets\Box $box Box widget instance
 * @var array $statusArray Statuses array
 */
use app\themes\admin\widgets\Box;
use app\modules\page\Module;
$this->title = Module::t('page', 'Pages');
$this->params['subtitle'] = Module::t('page', 'Create post');
$this->params['breadcrumbs'] = [['label' => $this->title, 'url' => ['index']], $this->params['subtitle']];
?>
<div class="row">
    <div class="col-sm-12">
        <?php 
$box = Box::begin(['title' => $this->params['subtitle'], 'renderBody' => false, 'options' => ['class' => 'box-primary'], 'bodyOptions' => ['class' => 'table-responsive'], 'buttonsTemplate' => '{cancel}']);
echo $this->render('_form', ['model' => $model, 'statusArray' => $statusArray, 'box' => $box]);
Box::end();
?>
    </div>
</div>
示例#5
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('page', 'Id'), 'title' => Module::t('page', 'Title'), 'alias' => Module::t('page', 'Alias'), 'teaser' => Module::t('page', 'Teaser'), 'content' => Module::t('page', 'Content'), 'views' => Module::t('page', 'Views'), 'status_id' => Module::t('page', 'Status Id'), 'data' => Module::t('page', 'Data'), 'created_at' => Module::t('page', 'Created at'), 'updated_at' => Module::t('page', 'Updated at')];
 }
示例#6
0
use app\themes\admin\widgets\GridView;
use app\modules\page\Module;
use yii\grid\ActionColumn;
use yii\grid\CheckboxColumn;
use yii\helpers\Html;
use yii\jui\DatePicker;
$this->title = Module::t('page', 'Pages');
$this->params['subtitle'] = Module::t('page', 'List');
$this->params['breadcrumbs'] = [$this->title];
$gridId = 'pages-grid';
$gridConfig = ['id' => $gridId, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => CheckboxColumn::classname()], 'id', 'alias', ['attribute' => 'title', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model['title'], ['update', 'id' => $model['id']]);
}], 'views', ['attribute' => 'status_id', 'format' => 'html', 'value' => function ($model) {
    $class = $model->status_id === $model::STATUS_PUBLISHED ? 'label-success' : 'label-danger';
    return '<span class="label ' . $class . '">' . $model->status . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status_id', $statusArray, ['class' => 'form-control', 'prompt' => Module::t('page', 'BACKEND_PROMPT_STATUS')])], ['attribute' => 'created_at', 'format' => 'date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'created_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])], ['attribute' => 'updated_at', 'format' => 'date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'updated_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])]]];
$boxButtons = $actions = [];
$showActions = false;
if (Yii::$app->user->can('BCreateBlogs')) {
    $boxButtons[] = '{create}';
}
if (Yii::$app->user->can('BUpdateBlogs')) {
    $actions[] = '{update}';
    $showActions = $showActions || true;
}
if (Yii::$app->user->can('BDeleteBlogs')) {
    $boxButtons[] = '{batch-delete}';
    $actions[] = '{delete}';
    $showActions = $showActions || true;
}
if ($showActions === true) {
示例#7
0
<?php

/**
 * Comment model create view.
 *
 * @var \yii\base\View $this View
 * @var array $statusArray Statuses array
 */
use app\modules\page\Module;
use app\themes\admin\widgets\Box;
$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']];
?>
<div class="row">
    <div class="col-sm-12">
        <?php 
$box = Box::begin(['title' => $this->params['subtitle'], 'renderBody' => false, 'options' => ['class' => 'box-primary'], 'bodyOptions' => ['class' => 'table-responsive'], 'buttonsTemplate' => '{cancel}']);
echo $this->render('_form', ['model' => $model, 'statusArray' => $statusArray, 'box' => $box]);
Box::end();
?>
    </div>
</div>
示例#8
0
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">

        </div>
        <div class="col-sm-6">

        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <?php 
echo $form->field($model, 'snippet')->widget(ImperaviWidget::className(), ['settings' => ['minHeight' => 200, 'imageGetJson' => Url::to(['/blogs/default/imperavi-get']), 'imageUpload' => Url::to(['/blogs/default/imperavi-image-upload']), 'fileUpload' => Url::to(['/blogs/default/imperavi-file-upload'])]]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <?php 
echo $form->field($model, 'content')->widget(ImperaviWidget::className(), ['settings' => ['minHeight' => 300, 'imageGetJson' => Url::to(['/blogs/default/imperavi-get']), 'imageUpload' => Url::to(['/blogs/default/imperavi-image-upload']), 'fileUpload' => Url::to(['/blogs/default/imperavi-file-upload'])]]);
?>
        </div>
    </div>
<?php 
$box->endBody();
$box->beginFooter();
echo Html::submitButton($model->isNewRecord ? Module::t('page', 'BACKEND_CREATE_SUBMIT') : Module::t('page', 'BACKEND_UPDATE_SUBMIT'), ['class' => $model->isNewRecord ? 'btn btn-primary btn-large' : 'btn btn-success btn-large']);
$box->endFooter();
ActiveForm::end();
示例#9
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['post_id' => Module::t('page', 'Post ID'), 'vocab_id' => Module::t('page', 'Vocab ID'), 'term_id' => Module::t('page', 'Term ID')];
 }