Exemplo n.º 1
0
 /**
  * @inherited
  */
 public function hasTranslation($language = null)
 {
     if ($language === null) {
         $language = Lang::getCurrent()->id;
     }
     return parent::hasTranslation($language);
 }
Exemplo n.º 2
0
 /**
  * [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;
     }
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
 /**
  * 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()]);
     }
 }
Exemplo n.º 5
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;
         }
     }
 }
Exemplo n.º 6
0
 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;
         }
     }
 }
 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');
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 /**
  * 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;
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 /**
  * @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;
 }
Exemplo n.º 13
0
 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]);
 }
Exemplo n.º 14
0
 /**
  * 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]);
     }
 }
Exemplo n.º 15
0
 /**
  * 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]);
     }
 }
Exemplo n.º 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]);
 }
Exemplo n.º 17
0
 /**
  * [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;
 }
Exemplo n.º 18
0
 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;
     }
 }
Exemplo n.º 19
0
 /**
  * @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']]];
 }
Exemplo n.º 20
0
<?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>
Exemplo n.º 21
0
 /**
  * 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.');
     }
 }
Exemplo n.º 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">
Exemplo n.º 23
0
 /**
  * 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]);
 }
Exemplo n.º 24
0
 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]);
 }
Exemplo n.º 25
0


        <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');
    ?>
Exemplo n.º 26
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()]);
 }
Exemplo n.º 27
0
 public function getContent($language = null)
 {
     $language = $language === null ? Lang::getCurrent()->code : $language;
     return $this->hasOne(Message::className(), ['id' => 'id'])->where('language = :language', [':language' => $language]);
 }
Exemplo n.º 28
0
 /**
  * возвращает последние новости в зависимости от языка на сайте
  *
  * @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();
 }
Exemplo n.º 29
0
 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]);
     }
 }
Exemplo n.º 30
0
 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;
     }
 }