/** * @return bool */ public function save($validate = true) { if ($validate && !$this->validate()) { return false; } return ParamsManager::getInstance()->manager->staticParams('change', Module::getInstance()->settingsKey, $this->getAttributes()); }
/** * @return bool */ public function save() { if (!isset(Yii::$app->params[Module::getInstance()->settingsKey])) { $path = Yii::getAlias('@webroot/files/common') . '/'; if (!is_file($path . 'underconstruction.jpg')) { FileHelper::createDirectory($path); copy(Yii::getAlias('@webroot/modules/admunderconst/assets/images/underconstruction.jpg'), $path . 'underconstruction.jpg'); } } return ParamsManager::getInstance()->manager->staticParams('change', Module::getInstance()->settingsKey, $this->getAttributes()); }
/** * Finds the Params model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Params the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Module::getInstance()->manager->createParamsQuery('find')->where(['id' => $id])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return bool */ public function save() { return ParamsManager::getInstance()->manager->staticParams('change', Module::getInstance()->settingsKey, $this->getAttributes()); }
use pavlinter\admparams\Module; use pavlinter\buttons\InputButton; use yii\bootstrap\Alert; use yii\helpers\Url; use yii\widgets\ActiveForm; use pavlinter\adm\Adm; /* @var $this yii\web\View */ /* @var $model app\models\Params */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="params-form"> <?php if (!$model->isNewRecord) { echo Alert::widget(['body' => Module::t('description', $model->name, ['dot' => true]), 'closeButton' => false, 'options' => ['class' => 'alert-info']]); } ?> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 250]); ?> <?php echo $form->field($model, 'value')->textarea(['rows' => 6]); ?>
<div class="params-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a(Adm::t('admparams', 'Create Params'), ['create'], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Adm::t('admparams', 'Add Default Params'), [''], ['class' => 'btn btn-success pull-right', 'data' => ['method' => 'post', 'params' => ['admparams-load-params' => '1']]]); ?> </p> <?php echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'vAlign' => 'middle'], ['attribute' => 'value', 'vAlign' => 'middle', 'value' => function ($model) { return \yii\helpers\StringHelper::truncate($model->value, 70); }], ['attribute' => 'description', 'vAlign' => 'middle', 'format' => 'raw', 'value' => function ($model) { return Module::t('description', $model->name, ['dot' => true]); }], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}', 'options' => ['style' => 'width:70px;'], 'buttons' => ['update' => function ($url, $model, $key) { if ($model->isSerialized()) { return null; } return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']); }]]]]); ?> </div>