コード例 #1
0
ファイル: Lang.php プロジェクト: skamnev/members
 public function afterSave($insert, $changedAttributes)
 {
     if ($this->default) {
         Lang::updateAll(['`default`' => 0], '`default` = :default AND id <> :lang_id', [':default' => 1, ':lang_id' => $this->id]);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
コード例 #2
0
ファイル: LangController.php プロジェクト: skamnev/members
 /**
  * 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.');
     }
 }
コード例 #3
0
 public function init()
 {
     $lang = Lang::getCurrent()->url;
     $model['am'] = new ProductsAm();
     $model['ru'] = new ProductsRu();
     $model['en'] = new ProductsEn();
     $this->lang = $lang;
     $this->model = $model[$lang];
 }
コード例 #4
0
 public function behaviors()
 {
     $languagesModel = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     $languages = [];
     foreach ($languagesModel as $model) {
         $languages[$model->url] = $model->name;
     }
     return ['ml' => ['class' => MultilingualBehavior::className(), 'languages' => $languages, 'defaultLanguage' => $languageDefault->url, 'langForeignKey' => 'code_id', 'tableName' => "{{%mapping_questions_codes_lang}}", 'attributes' => ['description']]];
 }
コード例 #5
0
ファイル: WLang.php プロジェクト: skamnev/members
 public static function label($code)
 {
     $languages = Lang::find()->all();
     if (self::$_labels === null) {
         self::$_labels = array();
         foreach ($languages as $language) {
             self::$_labels[$language->getAttribute('url')] = Yii::t('backend', $language->getAttribute('name'));
         }
     }
     return isset(self::$_labels[$code]) ? self::$_labels[$code] : null;
 }
コード例 #6
0
 /**
  * Updates an existing FieldsTypes 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'id' => $model->id]);
     } else {
         $languages = Lang::find()->all();
         $languageDefault = Lang::findOne(['default' => 1]);
         return $this->render('update', ['model' => $model, 'languages' => $languages, 'languageDefault' => $languageDefault]);
     }
 }
コード例 #7
0
ファイル: CmsFaqController.php プロジェクト: skamnev/members
 /**
  * Updates an existing CmsFaq model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id, $category_id)
 {
     $model = $this->findModel($id);
     $categoryModel = CmsFaqCategories::findOne($category_id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', 'Successfully updated.');
         return $this->redirect(['cms-faq/update', 'id' => $model->id, 'category_id' => $category_id]);
     }
     $languages = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     return $this->render('update', ['model' => $model, 'languages' => $languages, 'languageDefault' => $languageDefault, 'categoryModel' => $categoryModel]);
 }
コード例 #8
0
ファイル: LangRequest.php プロジェクト: skamnev/members
 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()->url && strpos($this->_lang_url, Lang::getCurrent()->url) === 1) {
             $this->_lang_url = substr($this->_lang_url, strlen(Lang::getCurrent()->url) + 1);
         }
     }
     return $this->_lang_url;
 }
コード例 #9
0
 /**
  * Updates an existing CmsMealPlan 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', 'Successfully updated.');
     }
     /*    return $this->redirect(['index']);
           } else {*/
     $languages = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     return $this->render('update', ['model' => $model, 'languages' => $languages, 'languageDefault' => $languageDefault]);
     //}
 }
コード例 #10
0
ファイル: PdfsController.php プロジェクト: skamnev/members
 /**
  * Updates an existing Pdfs 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', 'Successfully updated.');
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         $languages = Lang::find()->all();
         $languageDefault = Lang::findOne(['default' => 1]);
         $rulesModel = new PdfsRules();
         $rules = $model->getPdfsRules()->joinWith('pdfQuestions');
         $rulesDataProvider = new ActiveDataProvider(['query' => $rules]);
         $mappingCategories = new MappingCategories();
         return $this->render('update', ['model' => $model, 'languages' => $languages, 'languageDefault' => $languageDefault, 'rulesDataProvider' => $rulesDataProvider, 'rulesModel' => $rulesModel, 'mappingCategories' => $mappingCategories]);
     }
 }
コード例 #11
0
ファイル: CmsPages.php プロジェクト: skamnev/members
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $languagesModel = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     $language_rules = [];
     foreach ($languagesModel as $language) {
         $message = Yii::t('backend', 'Please specify {name} category name', ['name' => $language->name]);
         if ($languageDefault->url == $language->url) {
             array_push($language_rules, [['title'], 'required', 'message' => $message]);
         } else {
             array_push($language_rules, [['title_' . $language->url], 'required', 'message' => $message]);
         }
     }
     $rules_general = [[['content', 'meta_keywords', 'meta_description'], 'string'], [['code_id', 'no_code_id', 'category_id', 'created_at', 'updated_at'], 'safe'], [['is_active', 'author', 'sort_order'], 'integer'], [['category_id'], 'required', 'message' => Yii::t('backend', 'Please select at least one Category')], [['publish_date'], 'date', 'format' => 'dd.mm.yyyy'], ['main_img', 'file', 'extensions' => 'jpeg, jpg, gif, png'], [['title', 'content_heading'], 'string', 'max' => 255], [['identifier'], 'string', 'max' => 128]];
     return array_merge($language_rules, $rules_general);
 }
コード例 #12
0
ファイル: CmsFaqCategories.php プロジェクト: skamnev/members
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $languagesModel = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     $language_rules = [];
     foreach ($languagesModel as $language) {
         $message = Yii::t('backend', 'Please specify {name} category name', ['name' => $language->name]);
         if ($languageDefault->url == $language->url) {
             array_push($language_rules, [['title'], 'required', 'message' => $message]);
         } else {
             array_push($language_rules, [['title_' . $language->url], 'required', 'message' => $message]);
         }
     }
     $rules_general = [[['status', 'sort_order'], 'integer'], [['created_at', 'updated_at'], 'safe'], [['title'], 'string', 'max' => 255]];
     return array_merge($language_rules, $rules_general);
 }
コード例 #13
0
ファイル: Videos.php プロジェクト: skamnev/members
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $languagesModel = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     $language_rules = [];
     foreach ($languagesModel as $language) {
         $message = Yii::t('backend', 'Please specify {name} name', ['name' => $language->name]);
         if ($languageDefault->url == $language->url) {
             array_push($language_rules, [['title'], 'required', 'message' => $message]);
         } else {
             array_push($language_rules, [['title_' . $language->url], 'required', 'message' => $message]);
         }
     }
     $rules_general = [[['id', 'status'], 'integer'], [['description'], 'string'], [['created_at', 'updated_at', 'file'], 'safe'], [['title'], 'string', 'max' => 255], ['external_url', 'unique', 'attributes' => 'url'], ['external_url', 'string'], ['external_url', 'match', 'pattern' => '/[a-zA-Z0-9-_.]+$/']];
     return array_merge($language_rules, $rules_general);
 }
コード例 #14
0
ファイル: FieldsTypes.php プロジェクト: skamnev/members
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $languagesModel = Lang::find()->all();
     $languageDefault = Lang::findOne(['default' => 1]);
     $language_rules = [];
     foreach ($languagesModel as $language) {
         $message = Yii::t('backend', 'Please specify {field} field', ['field' => $language->name]);
         if ($languageDefault->url == $language->url) {
             array_push($language_rules, [['title'], 'required', 'message' => $message]);
         } else {
             array_push($language_rules, [['title_' . $language->url], 'required', 'message' => $message]);
         }
     }
     $rules_general = [[['title'], 'string', 'max' => 128], [['has_options', 'has_other_field'], 'integer']];
     return array_merge($language_rules, $rules_general);
 }
コード例 #15
0
 /**
  * Updates an existing MembersAttributesToOptions 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (Yii::$app->request->isAjax) {
             $response = ['status' => 'success', 'message' => 'Data was successfully saved'];
             \Yii::$app->response->format = 'json';
             return $response;
         } else {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         $languages = Lang::find()->all();
         $languageDefault = Lang::findOne(['default' => 1]);
         return $this->renderAjax('update', ['model' => $model, 'languages' => $languages, 'languageDefault' => $languageDefault]);
     }
 }
コード例 #16
0
 /**
  * Updates an existing MembersAttributes 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', 'Successfully updated.');
         return $this->redirect(['members-attributes/update', 'id' => $model->id]);
     } else {
         $languages = Lang::find()->all();
         $languageDefault = Lang::findOne(['default' => 1]);
         $typeModel = FieldsTypes::findOne($model->type_id);
         $optionsDataProvider = null;
         if ($typeModel->has_options) {
             $optionsDataProvider = $this->_getAttributesOptions($id);
         }
         $optionsModel = new MembersAttributesToOptions();
         return $this->render('update', ['model' => $model, 'optionsDataProvider' => $optionsDataProvider, 'optionsModel' => $optionsModel, 'languages' => $languages, 'languageDefault' => $languageDefault]);
     }
 }
コード例 #17
0
ファイル: PlaceController.php プロジェクト: Git1111/portfolio
 public function actionIndex($id)
 {
     $lang = Lang::getCurrent()->url;
     $rating = new Rating();
     $model = $this->getModel();
     $product = $model->findOne($id);
     $reviews = $this->getReviews($id);
     $menu = Menu::getItemMenu($id);
     if ($rating->load(Yii::$app->request->post()) && $rating->validate()) {
         //User::d($_POST);
         $rating->product_id = $id;
         $rating->rating = $_POST['score_score'];
         $rating->save();
         $rating->reloadRating($id);
         return $this->refresh();
     } else {
         return $this->render('index', ['model' => $product, 'lang' => $lang, 'rating' => $rating, 'reviews' => $reviews, 'menu' => $menu]);
     }
 }
コード例 #18
0
ファイル: main.php プロジェクト: skamnev/members
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => 'Improving LIVES', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$menuItems = [['label' => 'Home', 'url' => ['/site/index']], ['label' => Yii::t('backend', 'Users'), 'url' => ['/user-management/user/index']], ['label' => Yii::t('backend', 'Members'), 'url' => ['/members/index']], ['label' => Yii::t('backend', 'PDFs'), 'url' => ['/pdfs']], ['label' => Yii::t('backend', 'Videos'), 'url' => ['/videos']], ['label' => Yii::t('backend', 'Mapping'), 'items' => [['label' => Yii::t('backend', 'Categories'), 'url' => ['/mapping-categories/index']], ['label' => Yii::t('backend', 'Question Codes'), 'url' => ['/mapping-questions-codes/index']]]], ['label' => Yii::t('backend', 'CMS'), 'items' => [['label' => Yii::t('backend', 'Pages'), 'url' => ['/cms-pages-categories/index']], ['label' => Yii::t('backend', 'Recipes'), 'url' => ['/cms-recipes-categories/index']], ['label' => Yii::t('backend', 'Meal Plans'), 'url' => ['/meal-plan/index']], ['label' => Yii::t('backend', 'FAQ'), 'url' => ['/cms-faq-categories/index']]]], ['label' => Yii::t('backend', 'Settings'), 'items' => [['label' => Yii::t('backend', 'General'), 'url' => ['/general-settings/index']], ['label' => Yii::t('backend', 'Languages'), 'url' => ['/lang/index']], ['label' => Yii::t('backend', 'Fields Types'), 'url' => ['/fields-types/index']], ['label' => Yii::t('backend', 'Weight Tracker'), 'url' => ['/general-settings/weight-tracker']], ['label' => Yii::t('backend', 'Meal Plan'), 'url' => ['/general-settings/meal-plan']]]]];
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
    $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
}
$menuItems[] = ['label' => Yii::t('backend', Lang::getLangByUrl(Yii::$app->language)->name), 'items' => WLang::getItems()];
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>
    <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo Alert::widget();
?>

        <?php 
echo $content;
?>
    </div>
コード例 #19
0
ファイル: UrlManager.php プロジェクト: skamnev/members
 /**
  * @inheritdoc
  */
 public function init()
 {
     $languages = Lang::find()->all();
     foreach ($languages as $language) {
         $this->languages[] = $language->getAttribute('url');
     }
     if ($this->enableLocaleUrls && $this->languages) {
         if (!$this->enablePrettyUrl) {
             throw new InvalidConfigException('Locale URL support requires enablePrettyUrl to be set to true.');
         }
     }
     $this->_defaultLanguage = Lang::getDefaultLang()->getAttribute('url');
     return parent::init();
 }