Esempio n. 1
0
 static function getLangByUrl($url = null)
 {
     if ($url === null) {
         return null;
     } else {
         $language = Lang::find()->where('url = :url', [':url' => $url])->one();
         if ($language === null) {
             return null;
         } else {
             return $language;
         }
     }
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Lang::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, 'default' => $this->default, 'date_update' => $this->date_update, 'date_create' => $this->date_create]);
     $query->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'local', $this->local])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function run()
 {
     return $this->render('lang/view', ['current' => Lang::getCurrent(), 'langs' => Lang::find()->where('id != :current_id', [':current_id' => Lang::getCurrent()->id])->all()]);
 }
Esempio n. 4
0
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\MessageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Messages');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="message-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Message'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'language', 'value' => 'language', 'filter' => \yii\helpers\ArrayHelper::map(\app\models\Lang::find()->all(), 'url', 'url')], ['attribute' => 'id', 'value' => 'id0.message'], 'translation:ntext', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>