Exemple #1
0
 public function save()
 {
     $group = new PatternGroup();
     $group->project_id = \Yii::$app->request->get('project_id');
     $group->name = $this->name;
     if (!$group->save()) {
         return false;
     }
     $patterns = Pattern::find()->where(['group_id' => $this->id])->all();
     foreach ($patterns as $pattern) {
         $patternNew = new Pattern();
         $patternNew->attributes = $pattern->attributes;
         $patternNew->group_id = $group->id;
         if (!$patternNew->save()) {
             return false;
         }
         $translations = PatternTranslation::find()->where(['pattern_id' => $pattern->id])->all();
         foreach ($translations as $translation) {
             $translationNew = new PatternTranslation();
             $translationNew->attributes = $translation->attributes;
             $translationNew->pattern_id = $patternNew->id;
             if (!$translationNew->save()) {
                 return false;
             }
         }
     }
     return true;
 }
Exemple #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pattern::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'group_id' => Yii::$app->request->get('group_id'), 'type_id' => $this->type_id, 'priority' => $this->priority]);
     $query->andFilterWhere(['like', 'module', $this->module])->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Exemple #3
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @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]]);
?>