/** * Load available languages. * @return SSystemLanguage collection */ private function loadLanguages() { $model = SSystemLanguage::model()->findAll(); foreach ($model as $lang) { $this->_languages[$lang->code] = $lang; if ($lang->default === '1') { $this->_default = $lang->code; } } return $this->_languages; }
/** * Delete language */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { $model = SSystemLanguage::model()->findAllByPk($_REQUEST['id']); if (!empty($model)) { foreach ($model as $page) { $page->delete(); } } if (!Yii::app()->request->isAjaxRequest) { $this->redirect('index'); } } }
<?php /** * Create/update language form */ return array('id' => 'languageUpdateForm', 'elements' => array('name' => array('type' => 'text'), 'code' => array('type' => 'text', 'hint' => Yii::t('CoreModule.core', 'Например: en')), 'locale' => array('type' => 'text', 'hint' => Yii::t('CoreModule.core', 'Например: en, en_us')), 'flag_name' => array('type' => 'dropdownlist', 'items' => SSystemLanguage::getFlagImagesList(), 'empty' => '---'), 'default' => array('type' => 'checkbox')));