Egorka
6 years ago
23 changed files with 975 additions and 699 deletions
@ -0,0 +1,16 @@
|
||||
<?php |
||||
/** |
||||
* Created by Error202 |
||||
* Date: 24.08.2018 |
||||
*/ |
||||
|
||||
/** |
||||
* @var $this \yii\web\View |
||||
* @var $form \yii\widgets\ActiveForm |
||||
* @var $model \core\forms\SettingsForm |
||||
* @var $language string |
||||
*/ |
||||
|
||||
$postfix = $language == Yii::$app->params['defaultLanguage'] ? '' : '_' . $language; |
||||
|
||||
echo $form->field($model, 'value' . $postfix)->textarea(['rows' => 6]); |
@ -0,0 +1,26 @@
|
||||
<?php |
||||
/** |
||||
* Created by Error202 |
||||
* Date: 25.08.2018 |
||||
*/ |
||||
|
||||
use yii\widgets\DetailView; |
||||
use core\entities\Settings; |
||||
|
||||
/** |
||||
* @var $this \yii\web\View |
||||
* @var $setting Settings |
||||
* @var $language string |
||||
*/ |
||||
|
||||
echo DetailView::widget([ |
||||
'model' => $setting, |
||||
'attributes' => [ |
||||
[ |
||||
'label' => Yii::t('main', 'Value'), |
||||
'value' => function (Settings $entity) use ($language) { |
||||
return $entity->findTranslation($language)->value; |
||||
} |
||||
], |
||||
], |
||||
]); |
@ -0,0 +1,50 @@
|
||||
<?php |
||||
|
||||
use yii\db\Migration; |
||||
|
||||
/** |
||||
* Handles the creation of table `settings_lng`. |
||||
*/ |
||||
class m180910_182109_create_settings_lng_table extends Migration |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeUp() |
||||
{ |
||||
$tableOptions = null; |
||||
if ($this->db->driverName === 'mysql') { |
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||||
} |
||||
|
||||
$this->createTable('{{%settings_lng}}', [ |
||||
'id' => $this->primaryKey(), |
||||
'language' => $this->string(6)->notNull(), |
||||
'section' => $this->string(255)->notNull(), |
||||
'key' => $this->string(255)->notNull(), |
||||
'value' => $this->text(), |
||||
], $tableOptions); |
||||
|
||||
$this->createIndex('key', '{{%settings_lng}}', ['section', 'key']); |
||||
$this->createIndex('idx_settings_lng_language', '{{%settings_lng}}', 'language'); |
||||
$this->addForeignKey('frg_settings_lng_settings_setting_id_id', '{{%settings_lng}}', ['section', 'key'], '{{%settings}}', ['section', 'key'], 'CASCADE', 'CASCADE'); |
||||
|
||||
$this->dropColumn('{{%settings}}', 'id'); |
||||
$this->addPrimaryKey('key', '{{%settings}}', ['section', 'key']); |
||||
$this->dropColumn('{{%settings}}', 'value'); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeDown() |
||||
{ |
||||
$this->addColumn('{{%settings}}', 'value', $this->text()); |
||||
$this->dropPrimaryKey('key', '{{%settings}}'); |
||||
$this->addColumn('{{%settings}}', 'id', $this->primaryKey()); |
||||
|
||||
$this->dropForeignKey('frg_settings_lng_settings_setting_id_id', '{{%settings_lng}}'); |
||||
$this->dropIndex('idx_settings_lng_language', '{{%settings_lng}}'); |
||||
$this->dropTable('{{%settings_lng}}'); |
||||
} |
||||
} |
Loading…
Reference in new issue