/**
  * @return array
  */
 public function addTranslation()
 {
     $langs = Language::getAllActive();
     $data = [];
     foreach ($langs as $lang) {
         $data[$lang->varCode] = $this->translations[$lang->varCode];
     }
     return $data;
 }
 /**
  * @param $category
  * @return bool
  */
 protected static function checkNeeded($category)
 {
     $allLanguage = ArrayHelper::map(Language::getAllActive(), 'varCode', 'varName');
     if ($category === 'admin' && array_key_exists(Setting::getValue('languageAdminPanel'), $allLanguage)) {
         return true;
     } elseif ($category === 'app' && array_key_exists(Yii::$app->language, $allLanguage)) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Language::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['intLanguageID' => $this->intLanguageID, 'isDefault' => $this->isDefault, 'isActive' => $this->isActive]);
     $query->andFilterWhere(['like', 'varCode', $this->varCode])->andFilterWhere(['like', 'varName', $this->varName]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SourceMessage::find()->groupBy('source_message.id');
     $query->joinWith('messages');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 15]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category' => 'app']);
     $query->andFilterWhere(['like', 'message', $this->message]);
     $langs = Language::getAllActive();
     foreach ($langs as $lang) {
         $query->andFilterWhere(['like', 'translation', $this->translations[$lang->varCode]]);
     }
     return $dataProvider;
 }
 /**
  * Finds the Language model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Language the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Language::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #6
0
<?php

use yii\helpers\Url;
use yii\grid\GridView;
use mistim\theme\adminlte\widgets\Box;
use mistim\theme\adminlte\widgets\grid\ActionColumn;
use mistim\models\Language;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $searchModel mistim\models\Search\MessageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
Url::remember(Url::current());
$this->title = Yii::t('admin', 'Translations');
$this->params['breadcrumbs'][] = $this->title;
$langs = Language::getAllActive();
$columnLangs = [];
foreach ($langs as $lang) {
    $columnLangs[] = ['attribute' => 'translation', 'label' => Yii::t('admin', strtoupper($lang->varCode)), 'value' => function ($data) use($lang) {
        foreach ($data->messages as $item) {
            if ($item->language === $lang->varCode) {
                return $item->translation;
            }
        }
    }];
}
$gridId = 'translate-grid';
$gridConfig = ['id' => $gridId, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ArrayHelper::merge([['class' => 'yii\\grid\\SerialColumn'], 'message'], $columnLangs)];
$showActions = false;
if (Yii::$app->user->can('/admin/translation-public/view')) {
    $actions[] = '{view}';
    $showActions = $showActions || true;
Beispiel #7
0
        <div class="form-group field-setting-varvalue required">
            <label class="control-label col-sm-3" for="setting-varkey"><?php 
    echo Yii::t('app', 'Value');
    ?>
</label>
            <div class="col-md-6">
                <?php 
    echo Html::tag('div', $model->varValue ? Yii::t('app', 'yes') : Yii::t('app', 'no'), ['class' => 'text-as-input']);
    ?>
            </div>
        </div>
    <?php 
} elseif ($model->varKey === 'languageAdminPanel') {
    ?>
        <?php 
    echo $form->field($model, 'varValue')->dropDownList(ArrayHelper::map(Language::getAllActive(), 'varCode', 'varCode'));
    ?>
    <?php 
} elseif ($model->varKey === 'extensionUploadFile') {
    ?>
        <?php 
    echo $form->field($model, 'varValue', ['template' => "{label}<div class='col-sm-6'>\n{input}\n{error}\n{hint}</div>"])->textInput(['maxlength' => true])->hint(Yii::t('app', 'enter the necessary extensions, separated by commas', ['class' => 'help-block col-sm-6 col-sm-offset-3']));
    ?>
    <?php 
} else {
    ?>
        <?php 
    echo $form->field($model, 'varValue')->textInput(['maxlength' => true]);
    ?>
    <?php 
}