コード例 #1
0
 /**
  * @inherited
  */
 public function hasTranslation($language = null)
 {
     if ($language === null) {
         $language = Lang::getCurrent()->id;
     }
     return parent::hasTranslation($language);
 }
コード例 #2
0
ファイル: LangUrlManager.php プロジェクト: dmdropkick/shop
 /**
  * [createUrl description]
  * @param  [type] $params [description]
  * @return [type]         [description]
  */
 public function createUrl($params)
 {
     $defaultLang = Lang::getDefaultLang();
     if (isset($params[1]) && isset($params[1]['lang_id'])) {
         // Если указан идентификатор языка, то делаем попытку найти язык в БД, иначе работаем с языком по умолчанию.
         $lang = Lang::findOne(['url' => $params[1]['lang_id']]);
         if ($lang === null) {
             $lang = $defaultLang;
         }
         unset($params[1]['lang_id']);
     } else {
         // Если не указан параметр языка, то работаем с текущим языком.
         $lang = Lang::getCurrent();
     }
     // Получаем сформированный URL(без префикса идентификатора языка).
     $url = parent::createUrl($params);
     if ($lang->url == $defaultLang->url) {
         return $url;
     }
     // Добавляем к URL префикс - буквенный идентификатор языка.
     if ($url == '/') {
         return '/' . $lang->url;
     } else {
         return '/' . $lang->url . $url;
     }
 }
コード例 #3
0
ファイル: PageSearch.php プロジェクト: aldegtyarev/fantasy
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchNews($params)
 {
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case Lang::LANG_EN:
             $category_id = self::NEWS_CATEGORY_EN;
             break;
         case Lang::LANG_RU:
         default:
             $category_id = self::NEWS_CATEGORY;
             break;
     }
     $query = Page::find()->joinWith('user');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => Yii::$app->params['items-per-page'], 'pageSizeParam' => false]]);
     $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, 'category_id' => $category_id, 'published' => 1, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     /*
             $query->andFilterWhere(['like', 'name', $this->name])
                 ->andFilterWhere(['like', 'intro', $this->intro])
                 ->andFilterWhere(['like', 'text', $this->text])
                 ->andFilterWhere(['like', 'meta_title', $this->meta_title])
                 ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])
                 ->andFilterWhere(['like', 'meta_descr', $this->meta_descr]);
     */
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Updates an existing Post model.
  * If update is successful, the browser will be redirected to the current page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(Url::current());
     } else {
         return $this->render('update', ['model' => $model, 'langList' => Lang::getList()]);
     }
 }
コード例 #5
0
ファイル: Lang.php プロジェクト: aldegtyarev/fantasy
 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;
         }
     }
 }
コード例 #6
0
ファイル: Lang.php プロジェクト: dench/resistor
 public static function getLangByUrl($code = null)
 {
     if ($code === null) {
         return null;
     } else {
         $language = Lang::find()->where('code = :code', [':code' => $code])->one();
         if ($language === null) {
             return null;
         } else {
             return $language;
         }
     }
 }
コード例 #7
0
 public function actionIndex($_lang = null)
 {
     $request = Yii::$app->request;
     $cookies = $request->cookies;
     $locales = Lang::getLocaleList(false);
     if ($_lang !== null && isset($locales[$_lang])) {
         Yii::$app->response->cookies->add(new Cookie(['name' => 'language', 'value' => $_lang]));
         return $this->goHome();
     } elseif (isset($cookies['language'])) {
         Yii::$app->language = ArrayHelper::getValue($locales, $cookies['language']->value);
     }
     return $this->actionView('readme');
 }
コード例 #8
0
ファイル: LangRequest.php プロジェクト: dench/resistor
 public function getLangUrl()
 {
     if ($this->_lang_url === null) {
         $this->_lang_url = $this->getUrl();
         $url_list = explode('/', $this->_lang_url);
         $lang_url = isset($url_list[1]) ? $url_list[1] : null;
         Lang::setCurrent($lang_url);
         if ($lang_url !== null && $lang_url === Lang::getCurrent()->code && strpos($this->_lang_url, Lang::getCurrent()->code) === 1) {
             $this->_lang_url = substr($this->_lang_url, strlen(Lang::getCurrent()->code) + 1);
         }
     }
     return $this->_lang_url;
 }
コード例 #9
0
ファイル: Country.php プロジェクト: aldegtyarev/fantasy
 public function getName()
 {
     $currentLang = Lang::getCurrent();
     switch ($currentLang->name) {
         case 'EN':
             $res = $this->name_GB;
             break;
         case 'RU':
         default:
             $res = $this->name_RU;
             break;
     }
     return $res;
 }
コード例 #10
0
ファイル: LangSearch.php プロジェクト: vetal2409/example
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Lang::find()->notDeleted();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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, 'default' => $this->default, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'deleted' => $this->deleted]);
     $query->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'local', $this->local])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #11
0
ファイル: Fantasy.php プロジェクト: aldegtyarev/fantasy
 public function getDescrField()
 {
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case 'en-EN':
             $field = 'descr_en';
             break;
         case 'ru-RU':
         default:
             $field = 'descr_ru';
             break;
     }
     return $field;
 }
コード例 #12
0
ファイル: LangRequest.php プロジェクト: vetal2409/example
 /**
  * @return mixed|string
  */
 public function getLangUrl()
 {
     if ($this->_lang_url === null) {
         $this->_lang_url = $this->getUrl();
         preg_match('#^' . $this->baseUrl . '\\/([^\\/]*).*#', $this->_lang_url, $lang_list);
         $lang_url = array_key_exists(1, $lang_list) ? $lang_list[1] : null;
         Lang::setCurrent($lang_url);
         if ($lang_url !== null && $lang_url === Lang::getCurrent()->url) {
             $search = $lang_list[0] === $this->baseUrl . '/' . $lang_url ? '/' . $lang_url : '/' . $lang_url . '/';
             $this->_lang_url = str_replace($search, '/', $this->_lang_url);
         }
     }
     return $this->_lang_url;
 }
コード例 #13
0
ファイル: About.php プロジェクト: aldegtyarev/fantasy
 public function run()
 {
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case 'en-EN':
             $info_block_id = 6;
             break;
         case 'ru-RU':
         default:
             $info_block_id = 5;
             break;
     }
     $info_block = InfoBlock::getInfo($info_block_id);
     return $this->render('about', ['info_block' => $info_block]);
 }
コード例 #14
0
ファイル: ViewController.php プロジェクト: dench/resistor
 /**
  * Updates an existing View model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     for ($i = 1; $i <= Lang::find()->count(); $i++) {
         $model_content[$i] = ViewLang::findOne(['id' => $id, 'lang_id' => $i]);
     }
     if (Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content)) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/view']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
コード例 #15
0
ファイル: MessageController.php プロジェクト: dench/resistor
 /**
  * Updates an existing SourceMessage model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $lang = Lang::find()->all();
     foreach ($lang as $i) {
         $model_content[$i->code] = Message::findOne(['id' => $id, 'language' => $i->code]);
     }
     if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->save()) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/message']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
コード例 #16
0
 /**
  * Lists all Page models.
  * @return mixed
  */
 public function actionIndex()
 {
     //		/echo 'index';die;
     $searchModel = new PageSearch();
     //$dataProvider = $searchModel->searchNews(Yii::$app->request->queryParams);
     $dataProvider = $searchModel->searchNews(Yii::$app->request->queryParams);
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case Lang::LANG_EN:
             $meta_key = 'news-list-en';
             break;
         case Lang::LANG_RU:
         default:
             $meta_key = 'news-list-ru';
             break;
     }
     $meta_info = MetaInfo::getMetaInfo($meta_key);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'meta_info' => $meta_info]);
 }
コード例 #17
0
ファイル: LangRequest.php プロジェクト: dmdropkick/shop
 /**
  * [getLangUrl description]
  * @return [type] [description]
  */
 public function getLangUrl()
 {
     if ($this->_lang_url === null) {
         $defaultLang = Lang::getDefaultLang();
         $this->_lang_url = $this->getUrl();
         $url_list = explode('/', $this->_lang_url);
         $lang_url = isset($url_list[1]) ? $url_list[1] : null;
         Lang::setCurrent($lang_url);
         if ($lang_url !== null && $lang_url === Lang::getCurrent()->url && strpos($this->_lang_url, Lang::getCurrent()->url) === 1) {
             $this->_lang_url = substr($this->_lang_url, strlen(Lang::getCurrent()->url) + 1);
         }
         // Если язык в адресе соотвествует дефолтному то редиректим на урл без языка.
         if ($defaultLang->url == $lang_url) {
             if ($this->_lang_url) {
                 $url = $this->_lang_url;
             } else {
                 $url = '/';
             }
             return Yii::$app->getResponse()->redirect($url, 301);
         }
     }
     return $this->_lang_url;
 }
コード例 #18
0
ファイル: LangUrlManager.php プロジェクト: vetal2409/example
 public function createUrl($params)
 {
     if (is_array($params) && array_key_exists('lang_id', $params)) {
         //isset($params['lang_id'])
         $lang = Lang::findOne($params['lang_id']);
         if ($lang === null) {
             $lang = Lang::getDefaultLang();
         }
         unset($params['lang_id']);
     } else {
         $lang = Lang::getCurrent();
     }
     $url = parent::createUrl($params);
     $baseUrl = $this->showScriptName || !$this->enablePrettyUrl ? $this->getScriptUrl() : $this->getBaseUrl();
     if ($url !== '/') {
         if ($baseUrl === '') {
             return '/' . $lang->url . $url;
         } else {
             return str_replace($baseUrl, "{$baseUrl}/{$lang->url}", $url);
         }
     } else {
         return '/' . $lang->url;
     }
 }
コード例 #19
0
ファイル: StageLang.php プロジェクト: dench/resistor
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['id', 'lang_id', 'name'], 'required'], [['id', 'lang_id'], 'integer'], [['name'], 'string', 'max' => 32], [['id', 'lang_id'], 'unique', 'targetAttribute' => ['id', 'lang_id'], 'message' => 'The combination of ID and Lang ID has already been taken.'], [['id'], 'exist', 'skipOnError' => true, 'targetClass' => Stage::className(), 'targetAttribute' => ['id' => 'id']], [['lang_id'], 'exist', 'skipOnError' => true, 'targetClass' => Lang::className(), 'targetAttribute' => ['lang_id' => 'id']]];
 }
コード例 #20
0
ファイル: index.php プロジェクト: dench/resistor
<?php

use backend\components\SetColumn;
use common\models\District;
use common\models\Lang;
use common\models\Region;
use common\models\Sale;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel common\models\SaleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Sales');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box">
    <div class="box-body table-responsive">
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'code', 'headerOptions' => ['width' => '100']], ['class' => SetColumn::className(), 'attribute' => 'name', 'name' => 'name', 'value' => 'content.name'], ['class' => SetColumn::className(), 'attribute' => 'region_id', 'filter' => Region::getList(), 'name' => 'region.content.name'], ['class' => SetColumn::className(), 'attribute' => 'district_id', 'filter' => District::getListAll(), 'name' => 'district.content.name'], 'address', ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.Y'], 'options' => ['width' => '80']], ['class' => SetColumn::className(), 'attribute' => 'top', 'filter' => Sale::getTopList(), 'name' => 'topName', 'cssClasses' => [Sale::TOP_DISABLED => 'default', Sale::TOP_ENABLED => 'success']], ['class' => SetColumn::className(), 'attribute' => 'status', 'filter' => Sale::getStatusList(), 'name' => 'statusName', 'cssClasses' => [Sale::STATUS_HIDE => 'default', Sale::STATUS_ACTIVE => 'success', Sale::STATUS_AWAITING => 'warning']], ['class' => SetColumn::className(), 'attribute' => 'sold', 'filter' => Sale::getSoldList(), 'name' => 'soldName', 'cssClasses' => [Sale::SOLD_ACTUAL => 'success', Sale::SOLD_US => 'default', Sale::SOLD_OTHER => 'default']], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => ['width' => '70'], 'template' => '{link} {update} {delete}', 'buttons' => ['link' => function ($url, $model, $key) {
    return Html::a('<span class="fa fa-eye"></span>', Url::to(Yii::$app->params['http'] . '/' . Lang::getCurrent()->code . '/sale/' . $model->id), ['target' => '_blank']);
}]]]]);
?>
    </div>
    <div class="box-footer">
        <?php 
echo Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']);
?>
    </div>
</div>
コード例 #21
0
ファイル: LangController.php プロジェクト: vetal2409/example
 /**
  * Finds the Lang model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Lang the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Lang::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #22
0
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => Yii::t('app', 'Yii2 Documentation'), 'brandUrl' => ['/site/index'], 'options' => ['class' => 'navbar-default', 'style' => 'margin-bottom: 0;']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-left'], 'items' => [['label' => Yii::t('app', 'Backend'), 'url' => '/admin']]]);
$langHelper = new LangHelper(['langs' => Lang::getList(true)]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => $langHelper->langs[$langHelper->currentLang], 'items' => $langHelper->getList()], ['label' => $gitHubLogo . 'GitHub', 'url' => 'https://github.com/LAV45/yii2-translated-behavior', 'linkOptions' => ['target' => '_blank'], 'encode' => false]]]);
NavBar::end();
?>
    <main class="jumbotron" role="main" style="margin-bottom: 0;">
        <div class="container text-center">
            <h1>Yii2 translated behavior</h1>
            <p class="lead">
                <?php 
echo Yii::t('app', 'This extension helps you to quickly add the ability to translate your website.');
?>
            </p>
            <p>
                <img alt="Latest Stable Version" src="https://poser.pugx.org/lav45/yii2-translated-behavior/v/stable">
                <img alt="Total Downloads" src="https://poser.pugx.org/lav45/yii2-translated-behavior/downloads">
                <img alt="Code Coverage" src="https://scrutinizer-ci.com/g/lav45/yii2-translated-behavior/badges/coverage.png?b=master">
コード例 #23
0
ファイル: HotelController.php プロジェクト: vetal2409/example
 /**
  * Updates an existing Hotel model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     //$this->allowAccess(Hotel::checkAccess($id));
     $model = $this->findModel($id);
     $languages = Lang::getAll();
     $roomTypes = RoomType::getRoomTypes();
     $department = Department::getAll();
     $modelHotelDepartmentMapping = new HotelDepartmentMapping();
     $modelHotelData = HotelData::getByHotelId($id);
     if (!$modelHotelData) {
         $modelHotelData = new HotelData();
     }
     $availableRooms = HotelRoomTypeMapping::getRoomTypesIdByHotelId($id);
     $hotelDepartments = HotelDepartmentMapping::getByHotelId($id);
     $modelHotelRoomTypeMapping = new HotelRoomTypeMapping();
     $countries = Country::getAllCountries();
     $savePath = Yii::getAlias($model::FILE_PATH);
     $imageDataProvider = new ArrayDataProvider(['models' => Image::getImagesByHotelId($id)]);
     if ($model->load(Yii::$app->request->post())) {
         //            $modelCity = City::getOrCreateByNameAndCountryId($_POST['Hotel']['cityName'], $model->country_id);
         //            $model->city_id = $modelCity->id;
         if ($model->save()) {
             foreach ($_POST['HotelRoomTypeMapping']['room_type_id'] as $roomTypeId) {
                 $hotelRoomTypeMappings = HotelRoomTypeMapping::getRoomTypeByHotelIdAndRoomTypeId($id, $roomTypeId);
                 if (!$hotelRoomTypeMappings) {
                     $modelHotelRoomTypeMapping = new HotelRoomTypeMapping();
                     $modelHotelRoomTypeMapping->setAttribute('hotel_id', $model->getAttribute('id'));
                     $modelHotelRoomTypeMapping->setAttribute('room_type_id', $roomTypeId);
                     $modelHotelRoomTypeMapping->save();
                 } elseif ($hotelRoomTypeMappings->getAttribute('deleted') === ActiveRecord::STATUS_DELETED) {
                     $hotelRoomTypeMappings->setAttribute('deleted', ActiveRecord::STATUS_NOT_DELETED);
                     $hotelRoomTypeMappings->save();
                 }
             }
             foreach ($languages as $key => $language) {
                 $modelHotelData = HotelData::getByLanguageIdAndHotelId($language->local, $id);
                 if ($modelHotelData) {
                     $modelHotelData->setAttribute('lang_id', Yii::$app->request->post('HotelData')['lang_id'][$key]);
                     $modelHotelData->setAttribute('description', Yii::$app->request->post('HotelData')['description'][$key]);
                     $modelHotelData->setAttribute('location', Yii::$app->request->post('HotelData')['location'][$key]);
                     $modelHotelData->setAttribute('price_information', Yii::$app->request->post('HotelData')['price_information'][$key]);
                     $modelHotelData->setAttribute('other', Yii::$app->request->post('HotelData')['other'][$key]);
                     $modelHotelData->save();
                 } else {
                     $modelHotelData = new HotelData();
                     $modelHotelData->setAttribute('hotel_id', $id);
                     $modelHotelData->setAttribute('lang_id', Yii::$app->request->post('HotelData')['lang_id'][$key]);
                     $modelHotelData->setAttribute('description', Yii::$app->request->post('HotelData')['description'][$key]);
                     $modelHotelData->setAttribute('location', Yii::$app->request->post('HotelData')['location'][$key]);
                     $modelHotelData->setAttribute('price_information', Yii::$app->request->post('HotelData')['price_information'][$key]);
                     $modelHotelData->setAttribute('other', Yii::$app->request->post('HotelData')['other'][$key]);
                     $modelHotelData->save();
                 }
             }
             foreach ($availableRooms as $room) {
                 if (!in_array($room, $_POST['HotelRoomTypeMapping']['room_type_id'])) {
                     $hotelRoomTypeMapping = HotelRoomTypeMapping::getRoomTypeByHotelIdAndRoomTypeId($id, $room);
                     $hotelRoomTypeMapping->setAttribute('deleted', ActiveRecord::STATUS_DELETED);
                     $hotelRoomTypeMapping->save();
                 }
             }
             foreach ($_POST['HotelDepartmentMapping']['department_id'] as $departmentId) {
                 $hotelDepartmentMapping = HotelDepartmentMapping::getByHotelIdAndDepartmentId($id, $departmentId);
                 if (!$hotelDepartmentMapping) {
                     $modelHotelDepartmentMapping = new HotelDepartmentMapping();
                     $modelHotelDepartmentMapping->setAttribute('hotel_id', $model->getAttribute('id'));
                     $modelHotelDepartmentMapping->setAttribute('department_id', $departmentId);
                     $modelHotelDepartmentMapping->save();
                 } elseif ($hotelDepartmentMapping->getAttribute('deleted') === ActiveRecord::STATUS_DELETED) {
                     $hotelDepartmentMapping->setAttribute('deleted', ActiveRecord::STATUS_NOT_DELETED);
                     $hotelDepartmentMapping->save();
                 }
             }
             foreach ($hotelDepartments as $department) {
                 if (!in_array($department, $_POST['HotelDepartmentMapping']['department_id'])) {
                     $modelHotelDepartmentMapping = HotelDepartmentMapping::getByHotelIdAndDepartmentId($id, $department);
                     $modelHotelDepartmentMapping->setAttribute('deleted', ActiveRecord::STATUS_DELETED);
                     $modelHotelDepartmentMapping->save();
                 }
             }
             $files = $model->loadFiles($model->fileAttribute);
             if ($files !== false) {
                 foreach ($files as $file) {
                     if ($file->saveAs($savePath . $file->name)) {
                         $image = new Image();
                         $image->setAttribute('name', $file->name);
                         $image->setAttribute('hotel_id', $id);
                         $image->setAttribute('path', $model::FILE_PATH . $file->name);
                         $image->save();
                     }
                 }
             }
             if ($model->preview_image_id === 0 || $model->preview_image_id === null) {
                 $model->setAttribute('preview_image_id', !empty($image) ? $image->id : $model::IMAGE_NOT_SET);
                 $model->save();
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('update', ['model' => $model, 'modelHotelData' => $modelHotelData, 'modelHotelRoomTypeMapping' => $modelHotelRoomTypeMapping, 'roomTypes' => $roomTypes, 'countries' => $countries, 'availableRooms' => $availableRooms, 'hotelDepartments' => $hotelDepartments, 'imageDataProvider' => $imageDataProvider, 'department' => $department, 'modelHotelDepartmentMapping' => $modelHotelDepartmentMapping, 'languages' => $languages]);
 }
コード例 #24
0
ファイル: Sale.php プロジェクト: dench/resistor
 public function getContent($lang_id = null)
 {
     $lang_id = $lang_id === null ? Lang::getCurrent()->id : $lang_id;
     return $this->hasOne(SaleLang::className(), ['id' => 'id'])->where('lang_id = :lang_id', [':lang_id' => $lang_id]);
 }
コード例 #25
0
ファイル: _header.php プロジェクト: aldegtyarev/fantasy


        <div class="sub-menu">
			<div class="main-mob-menu"></div> 
			<div class="clr"></div>                           
		</div><!--sub-menu-->

		<?php 
//echo Banners::widget(['position'=>1])
?>

		<div class="mid-line">
			<div class="col logo">
				<a href="<?php 
echo Url::to(['site/index', 'lang_id' => Lang::getCurrent()->id]);
?>
">
					<img src="/images/logo-n.png" alt="Название организации" />
				</a>
			</div>
			<div class="col registration">
				<?php 
if (\Yii::$app->user->isGuest) {
    ?>
					<a href="<?php 
    echo Url::to(['site/signup']);
    ?>
" title="<?php 
    echo Yii::t('app', 'LoginForm_reg_and_win');
    ?>
コード例 #26
0
ファイル: WLang.php プロジェクト: aldegtyarev/fantasy
 public function run()
 {
     return $this->render('lang/view', ['current' => Lang::getCurrent(), 'langs' => Lang::find()->where('id != :current_id', [':current_id' => Lang::getCurrent()->id])->all()]);
 }
コード例 #27
0
ファイル: SourceMessage.php プロジェクト: dench/resistor
 public function getContent($language = null)
 {
     $language = $language === null ? Lang::getCurrent()->code : $language;
     return $this->hasOne(Message::className(), ['id' => 'id'])->where('language = :language', [':language' => $language]);
 }
コード例 #28
0
ファイル: Page.php プロジェクト: aldegtyarev/fantasy
 /**
  * возвращает последние новости в зависимости от языка на сайте
  *
  * @return array
  */
 public static function getLastNews()
 {
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case 'en-EN':
             $category_id = self::NEWS_CATEGORY_EN;
             break;
         case 'ru-RU':
         default:
             $category_id = self::NEWS_CATEGORY;
             break;
     }
     $sql = 'SELECT p.`id`, p.`name`, p.`alias`, p.`intro`, p.`image`, p.`created_by`, p.`created_at`, u.`nickname` FROM ' . self::tableName() . ' AS p INNER JOIN {{%user}} AS u ON p.`created_by` = u.`id` WHERE `category_id` = :category_id AND `published` = 1 ORDER BY `id` DESC LIMIT 0,3';
     $params = [':category_id' => $category_id];
     return Yii::$app->db->createCommand($sql)->bindValues($params)->queryAll();
 }
コード例 #29
0
ファイル: PersonalController.php プロジェクト: dench/resistor
 function actionSaleCreate()
 {
     $model = new Sale();
     for ($i = 1; $i <= Lang::find()->count(); $i++) {
         $model_content[$i] = new SaleLang();
         $model_content[$i]['lang_id'] = $i;
         $model_content[$i]['id'] = 0;
     }
     $model->status = Sale::STATUS_AWAITING;
     $model->sold = 1;
     $model->code = rand(100000000, 999999999);
     if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->validate() && $model->district_id > 0) {
         $model->save();
         foreach ($model_content as $key => $content) {
             $content->id = $model->id;
             $content->lang_id = $key;
             $content->save(false);
         }
         return $this->redirect(['sale-update', 'id' => $model->id]);
     } else {
         return $this->render('sale/create', ['model' => $model, 'model_content' => $model_content]);
     }
 }
コード例 #30
0
ファイル: ParserController.php プロジェクト: dench/resistor
 public function actionSend()
 {
     $data = Yii::$app->request->post();
     if (!empty($data['Parse']['id'])) {
         $parse = Parse::findOne($data['Parse']['id']);
     } else {
         return false;
     }
     if (!empty($data['Sale']['id'])) {
         $sale = Sale::findOne($data['Sale']['id']);
         $content = $sale->content;
     }
     if (empty($sale)) {
         $sale = new Sale();
         $sale->user_id = @$data['Sale']['user_id'];
     }
     if (empty($content)) {
         $content = new SaleLang();
         $content->lang_id = Lang::getCurrent()->id;
         $content->id = 0;
     }
     if ($sale->load($data) && $content->load($data) && $sale->validate() && $content->validate()) {
         $sale->save(false);
         if (!$content->id) {
             for ($i = 1; $i <= Lang::find()->count(); $i++) {
                 $model_content[$i] = new SaleLang();
                 $model_content[$i]['lang_id'] = $i;
                 $model_content[$i]['id'] = $sale->id;
                 $model_content[$i]['description'] = $content->description;
                 $model_content[$i]['name'] = $content->name;
                 $model_content[$i]->save(false);
             }
             $parse->sale_id = $sale->id;
             $parse->save();
         } else {
             $content->save(false);
         }
         return true;
     } else {
         Yii::trace(print_r($sale->errors, true));
         Yii::trace(print_r($content->errors, true));
         return false;
     }
 }