public function run() { if (!TsTranslation::model()->isAccessEnabled()) { echo 'Error 403. You have no permission to use this widget!'; } else { $this->registerClientScript(); $languageModel = new ExtLanguages(); $languageModel->unsetAttributes(); $allLanguages = AllLanguages::model()->findAll(); $allLanguagesList = CHtml::listData($allLanguages, 'id', 'name'); $sourceTableName = SourceMessages::model()->tableName(); $sql = 'SELECT `category` FROM ' . $sourceTableName . ' GROUP BY `category`'; $categoryArray = Yii::app()->db->createCommand($sql)->queryColumn(); $this->render('_translation_list', array('id' => $this->_id, 'model' => $languageModel, 'type' => $this->type, 'allLanguagesList' => $allLanguagesList, 'listOptions' => $this->listOptions, 'htmlOptions' => $this->htmlOptions, 'categoryArray' => $categoryArray, 'showDynamicContent' => $this->showDynamicContent)); } }
public static function addTranslation($event) { if ($event->category === null) { $event->category = ''; if (Yii::app()->controller->module !== null) { $event->category .= Yii::app()->controller->module->id . '.'; } else { $event->category .= 'root.'; } $event->category .= Yii::app()->controller->id . '.' . Yii::app()->controller->action->id; } $source = SourceMessages::model()->findByAttributes(array('message' => $event->message, 'category' => $event->category)); //var_dump($event->message, $event->category);die; if ($source === NULL) { $source = new SourceMessages(); $source->category = $event->category; $source->message = $event->message; $source->save(); } $translation = TranslatedMessages::model()->findByPk(array('id' => $source->id, 'language' => $event->language)); if ($translation === NULL) { $translation = new TranslatedMessages(); $translation->id = $source->id; $translation->language = $event->language; $translation->translation = $event->message; $translation->save(); } }
public function actionGetTranslationsByCategory() { if (Yii::app()->request->isAjaxRequest && isset($_POST['language']) && isset($_POST['category']) && isset($_POST['listId'])) { $sourceModel = new SourceMessages(); $sourceModel->unsetAttributes(); $sourceModel->category = $_POST['category']; $sourceModel->language = $_POST['language']; $languageModel = ExtLanguages::model()->findByAttributes(array('code2' => $_POST['language'])); $this->renderPartial('_translations_by_category', array('sourceModel' => $sourceModel, 'languageModel' => $languageModel, 'listId' => $_POST['listId'])); } }