Exemplo n.º 1
0
 /**
  * Render the settings form.
  */
 public function run()
 {
     /* @var $model \yii\db\ActiveRecord */
     $model = new $this->modelClass();
     if ($this->scenario) {
         $model->setScenario($this->scenario);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         foreach ($model->toArray() as $key => $value) {
             Yii::$app->settings->set($key, $value, $model->formName());
         }
         Yii::$app->getSession()->addFlash('success', Module::t('settings', 'Successfully saved settings on {section}', ['section' => $model->formName()]));
     }
     foreach ($model->attributes() as $key) {
         $model->{$key} = Yii::$app->settings->get($key, $model->formName());
     }
     return $this->controller->render($this->viewName, ['model' => $model]);
 }
Exemplo n.º 2
0
 * @var yii\data\ActiveDataProvider $dataProvider
 */
$this->title = Module::t('settings', 'Settings');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="setting-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
//echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Module::t('settings', 'Create {modelClass}', ['modelClass' => Module::t('settings', 'Setting')]), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
Pjax::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'section', 'filter' => ArrayHelper::map(Setting::find()->select('section')->distinct()->where(['<>', 'section', ''])->all(), 'section', 'section')], 'key', 'value:ntext', ['class' => '\\rsol\\grid\\ToggleColumn', 'attribute' => 'active', 'filter' => [1 => Yii::t('yii', 'Yes'), 0 => Yii::t('yii', 'No')]], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
    <?php 
Pjax::end();
?>
</div>
Exemplo n.º 3
0
    <?php 
echo $form->field($model, 'section');
?>

    <?php 
echo $form->field($model, 'key');
?>

    <?php 
echo $form->field($model, 'value');
?>

    <?php 
echo $form->field($model, 'active')->checkbox();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton(Module::t('settings', 'Search'), ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::resetButton(Module::t('settings', 'Reset'), ['class' => 'btn btn-default']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 4
0
echo $form->field($model, 'section')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'key')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'value')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'active')->checkbox(['value' => 1]);
?>

    <?php 
echo $form->field($model, 'type')->dropDownList($model->getTypes())->hint(Module::t('settings', 'Change at your own risk'));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('settings', 'Create') : Module::t('settings', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 5
0
    <div class="setting-form">

        <?php 
$form = ActiveForm::begin();
?>

        <?php 
foreach ($config as $field) {
    ?>
            <?php 
    echo $form->field($model, $field['name'])->textInput(['maxlength' => 255]);
    ?>
        <?php 
}
?>

        <div class="form-group">
            <?php 
echo Html::submitButton(Module::t('settings', 'Save'), ['class' => 'btn btn-success']);
?>
        </div>

        <?php 
ActiveForm::end();
?>

    </div>

</div>
Exemplo n.º 6
0
<?php

/**
 * @link http://phe.me
 * @copyright Copyright (c) 2014 Pheme
 * @license MIT http://opensource.org/licenses/MIT
 */
use yii\helpers\Html;
use rsol\settings\Module;
/**
 * @var yii\web\View $this
 * @var rsol\settings\models\Setting $model
 */
$this->title = Module::t('settings', 'Create {modelClass}', ['modelClass' => Module::t('settings', 'Setting')]);
$this->params['breadcrumbs'][] = ['label' => Module::t('settings', 'Settings'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="setting-create">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Exemplo n.º 7
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('settings', 'ID'), 'type' => Module::t('settings', 'Type'), 'section' => Module::t('settings', 'Section'), 'key' => Module::t('settings', 'Key'), 'value' => Module::t('settings', 'Value'), 'active' => Module::t('settings', 'Active'), 'created' => Module::t('settings', 'Created'), 'modified' => Module::t('settings', 'Modified')];
 }
Exemplo n.º 8
0
<?php

/**
 * @link http://phe.me
 * @copyright Copyright (c) 2014 Pheme
 * @license MIT http://opensource.org/licenses/MIT
 */
use yii\helpers\Html;
use rsol\settings\Module;
/**
 * @var yii\web\View $this
 * @var rsol\settings\models\Setting $model
 */
$this->title = Module::t('settings', 'Update {modelClass}: ', ['modelClass' => Module::t('settings', 'Setting')]) . ' ' . $model->section . '.' . $model->key;
$this->params['breadcrumbs'][] = ['label' => Module::t('settings', 'Settings'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Module::t('settings', 'Update');
?>
<div class="setting-update">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Exemplo n.º 9
0
 /**
  * @return string
  */
 public function run()
 {
     $model = $this->loadDynamicModel();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $model->save();
         $message = $this->successMessage ?: Module::t('settings', 'Settings saved');
         \Yii::$app->session->setFlash('success', $message);
     }
     return $this->controller->render($this->viewName, ['model' => $model, 'config' => $this->config['attributes']]);
 }
Exemplo n.º 10
0
use rsol\settings\Module;
/**
 * @var yii\web\View $this
 * @var rsol\settings\models\Setting $model
 */
$this->title = $model->section . '.' . $model->key;
$this->params['breadcrumbs'][] = ['label' => Module::t('settings', 'Settings'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="setting-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Module::t('settings', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Module::t('settings', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Module::t('settings', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'type', 'section', 'active:boolean', 'key', 'value:ntext', 'created:datetime', 'modified:datetime']]);
?>

</div>