Example #1
0
 public function actionAirportAlias()
 {
     $this->stdout('Generate alias: Airport.' . PHP_EOL, Console::FG_GREEN);
     $language = ReceivedLanguage::find()->indexBy('id')->asArray()->all();
     $airport = ReceivedAirport::find()->indexBy('code')->all();
     $translations = ReceivedAirportTranslation::find()->asArray()->all();
     $translation = [];
     foreach ($translations as $value) {
         $alias = $this->translit($value['name']);
         if ($value['language_id'] == 3 || $value['language_id'] == 9) {
             $translation[$value['airport_code']][$value['language_id']] = $alias;
         } else {
             $translation[$value['airport_code']][$value['language_id']] = preg_replace('~[^a-z0-9_-]~i', '*', $alias);
         }
     }
     $count = count($airport);
     Console::startProgress(0, $count);
     $count_ = 0;
     foreach ($airport as $value) {
         $value->alias_de = $value->alias;
         $value->alias_en = $value->alias;
         $value['alias_zh-CN'] = $value->alias;
         $value->alias_tr = $value->alias;
         $value->alias_ru = $value->alias;
         $value->alias_fr = $value->alias;
         $value->alias_es = $value->alias;
         $value->alias_it = $value->alias;
         $value->alias_th = $value->alias;
         foreach ($translation[$value->code] as $key => $_value) {
             if ($_value != '') {
                 switch ($language[$key]['code']) {
                     case 'de':
                         $value->alias_de = $_value;
                         break;
                     case 'en':
                         $value->alias_en = $_value;
                         break;
                         //                        case 'zh-CN':
                         //                            $value['alias_zh-CN'] = $_value;
                         //                            break;
                     //                        case 'zh-CN':
                     //                            $value['alias_zh-CN'] = $_value;
                     //                            break;
                     case 'tr':
                         $value->alias_tr = $_value;
                         break;
                     case 'ru':
                         $value->alias_ru = $_value;
                         break;
                     case 'fr':
                         $value->alias_fr = $_value;
                         break;
                     case 'es':
                         $value->alias_es = $_value;
                         break;
                     case 'it':
                         $value->alias_it = $_value;
                         break;
                         //                        case 'th':
                         //                            $value->alias_th = $_value;
                         //                            break;
                 }
             }
         }
         if (!$value->save()) {
             print_r($value->attributes);
             print_r($value->errors);
             return Controller::EXIT_CODE_ERROR;
         }
         Console::updateProgress(++$count_, $count);
     }
     Console::endProgress();
     return Controller::EXIT_CODE_NORMAL;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLanguage()
 {
     return $this->hasOne(ReceivedLanguage::className(), ['id' => 'language_id']);
 }
Example #3
0
/* @var $this yii\web\View */
/* @var $model common\models\PatternTranslation */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="pattern-translation-form">
    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'pattern_id')->dropdownList(\common\models\Pattern::find()->select(['id', 'module'])->indexBy('id')->column(), ['prompt' => 'Pattern:'])->label('Pattern ID');
?>

    <?php 
echo $form->field($model, 'language_id')->dropdownList(\common\models\ReceivedLanguage::find()->select(['code', 'id'])->indexBy('id')->column(), ['prompt' => 'Language:'])->label('Language Code');
?>

    <?php 
//= $form->field($model, 'value')->textarea(['rows' => 6])
?>
    <?php 
//*/
?>
    <?php 
echo $form->field($model, 'value')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 200, 'plugins' => ['clips', 'fullscreen'], 'pastePlainText' => false, 'paragraphize' => false]]);
?>
    <?php 
//*/
?>
    <div class="form-group">