diff --git a/backend/web/js/option.js b/backend/web/js/option.js index 1786a9a..384a1dd 100755 --- a/backend/web/js/option.js +++ b/backend/web/js/option.js @@ -58,55 +58,55 @@ $(function() { } return false; }); - $.each($('.nav-tabs.f32'), function(key, value) { - if($(value).find('li').length > 1) { - $(value).find('li').append(''); - } - }); - $(document).on('click', '.dropdown-menu.f32:not(.old) li a[data-lang]', function() { - var lang = $(this).data('lang'); - var flag = $(this).find('span').first().clone(); - var el = $(this); - var id = $(this).attr('href').substr(1); - var path = form[id].handler; - var view = form[id].view; - var model = form[id].model; - $.get(path, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) { - $('#'+id+'-tabs li').removeClass('active'); - $('#'+id+'-tabs').append('
  • '+$('

    ').append($(flag)).html()+'

  • '); - $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); - $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); - $('body').append($(data).filter('script')); - $(el).parent().remove(); - if(!$('#lang-'+id+' li').length) { - $('#'+id+'Lang').addClass('disabled'); - } - if($('#'+id+'-tabs li').length > 1) { - $('#'+id+'-tabs li').append('') - } - }); - }); - $(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function(e) { - e.preventDefault(); - var lang = $(this).data('lang'); - var flag = $(this).find('span').first().clone(); - var el = $(this); - var id = $(this).attr('href').substr(1); - $.get(form[id], { language_id: lang, widget_id: id }, function(data) { - $('#'+id+'-tabs li').removeClass('active'); - $('#'+id+'-tabs').append('
  • '+$('

    ').append($(flag)).html()+'

  • '); - $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); - $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); - $('body').append($(data).filter('script')); - $(el).parent().remove(); - if(!$('#lang-'+id+' li').length) { - $('#'+id+'Lang').addClass('disabled'); - } - if($('#'+id+'-tabs li').length > 1) { - $('#'+id+'-tabs li').append('') - } - }); - }); + //$.each($('.nav-tabs.f32'), function(key, value) { + // if($(value).find('li').length > 1) { + // $(value).find('li').append(''); + // } + //}); + //$(document).on('click', '.dropdown-menu.f32:not(.old) li a[data-lang]', function() { + // var lang = $(this).data('lang'); + // var flag = $(this).find('span').first().clone(); + // var el = $(this); + // var id = $(this).attr('href').substr(1); + // var path = form[id].handler; + // var view = form[id].view; + // var model = form[id].model; + // $.get(path, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) { + // $('#'+id+'-tabs li').removeClass('active'); + // $('#'+id+'-tabs').append('
  • '+$('

    ').append($(flag)).html()+'

  • '); + // $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); + // $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); + // $('body').append($(data).filter('script')); + // $(el).parent().remove(); + // if(!$('#lang-'+id+' li').length) { + // $('#'+id+'Lang').addClass('disabled'); + // } + // if($('#'+id+'-tabs li').length > 1) { + // $('#'+id+'-tabs li').append('') + // } + // }); + //}); + //$(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function(e) { + // e.preventDefault(); + // var lang = $(this).data('lang'); + // var flag = $(this).find('span').first().clone(); + // var el = $(this); + // var id = $(this).attr('href').substr(1); + // $.get(form[id], { language_id: lang, widget_id: id }, function(data) { + // $('#'+id+'-tabs li').removeClass('active'); + // $('#'+id+'-tabs').append('
  • '+$('

    ').append($(flag)).html()+'

  • '); + // $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); + // $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); + // $('body').append($(data).filter('script')); + // $(el).parent().remove(); + // if(!$('#lang-'+id+' li').length) { + // $('#'+id+'Lang').addClass('disabled'); + // } + // if($('#'+id+'-tabs li').length > 1) { + // $('#'+id+'-tabs li').append('') + // } + // }); + //}); $(document).on('click', '.remove-lang', function() { var lang = $(this).parent().data('lang'); var flag = $(this).parent().find('span.flag').first().clone(); diff --git a/common/widgets/FieldEditor.php b/common/widgets/FieldEditor.php new file mode 100644 index 0000000..82a0b41 --- /dev/null +++ b/common/widgets/FieldEditor.php @@ -0,0 +1,42 @@ +item_id && $this->model){ + $widgetData = $this->findModel(); + } else { + $widgetData= [new Fields()]; + } + + + return $this->render($this->template.'_field',['model'=>$widgetData]); + } + + protected function findModel() + { + if (($model = Fields::find()->where(['table_id'=>$this->item_id, 'table_name'=>$this->model, 'field_type'=>$this->template])->all()) !== null) { + + return $model; + + } else { + return [new Fields()]; + } + } +} \ No newline at end of file diff --git a/common/widgets/MultiLangForm.php b/common/widgets/MultiLangForm.php new file mode 100644 index 0000000..ef284ce --- /dev/null +++ b/common/widgets/MultiLangForm.php @@ -0,0 +1,26 @@ +render('multi-lang-form', + [ + 'form' => $this->form + ]); + } +} \ No newline at end of file diff --git a/common/widgets/views/multi-lang-form.php b/common/widgets/views/multi-lang-form.php new file mode 100644 index 0000000..4bcf422 --- /dev/null +++ b/common/widgets/views/multi-lang-form.php @@ -0,0 +1,32 @@ + + + + + + + + + + + + +
    +
    + + + +
    + +
    \ No newline at end of file diff --git a/frontend/assets/AdminAsset.php b/frontend/assets/AdminAsset.php index 2173f44..59ecdc1 100755 --- a/frontend/assets/AdminAsset.php +++ b/frontend/assets/AdminAsset.php @@ -19,6 +19,7 @@ class AdminAsset extends AssetBundle public $baseUrl = '@web'; public $css = [ 'css/style.css', + 'css/art_box.css', '/admin/css/flags32.css', 'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', ]; diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index ddba771..5d9c5c7 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -1,6 +1,7 @@ findUserInfo(Yii::$app->user->identity->id); + $langs = Language::getActiveLanguages(); + return $this->render('cabinet', [ 'user' => $user, 'user_info' => $user_info, + 'langs' => $langs, ]); diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 197d72f..ff76c66 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -93,71 +93,71 @@ class SiteController extends Controller ]); } -// // creat new model table Social and new model User -// $social = new Social(); -// $user = new User(); -// -// $serviceName = Yii::$app->getRequest()->getQueryParam('service'); -// -// if (isset($serviceName)) { -// /** @var $eauth \nodge\eauth\ServiceBase */ -// $eauth = Yii::$app->get('eauth')->getIdentity($serviceName); -// $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl()); -// $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login')); -// -// try { -// if ($eauth->authenticate()) { -// $identity = User::findByEAuth($eauth); -// Yii::$app->getUser()->login($identity); -// -// //Save date get social network in database -// if (! $social::find()->where(['social_user_id' => $identity[profile][id], 'social_name' => $identity[profile][service]])->exists()) { -// $name = explode(' ',$identity[profile][name]); -// $user->firstname = $name[0]; -// $user->lastname = $name[1]; -// $user->id_system_date = date("d.m.y.H:i:s"); -// $user->save(); -// $social->social_name = $identity[profile][service]; -// $social->social_user_id = $identity[profile][id]; -// $social->user_id = $user->id; -// $social->validate(); -// $social->errors; -// $social->save(); -// } -// -// // special redirect with closing popup window -// $eauth->redirect(); -// } -// else { -// // close popup window and redirect to cancelUrl -// $eauth->cancel(); -// } -// } -// catch (\nodge\eauth\ErrorException $e) { -// // save error to show it later -// Yii::$app->getSession()->setFlash('error', 'EAuthException: '.$e->getMessage()); -// -// // close popup window and redirect to cancelUrl -// // $eauth->cancel(); -// $eauth->redirect($eauth->getCancelUrl()); -// } -// } -// -// -// -// -// if (!\Yii::$app->user->isGuest) { -// return $this->goHome(); -// } -// -// $model = new LoginForm(); -// if ($model->load(Yii::$app->request->post()) && $model->login()) { -// return $this->goBack(); -// } else { -// return $this->render('login', [ -// 'model' => $model, -// ]); -// } + // creat new model table Social and new model User + $social = new Social(); + $user = new User(); + + $serviceName = Yii::$app->getRequest()->getQueryParam('service'); + + if (isset($serviceName)) { + /** @var $eauth \nodge\eauth\ServiceBase */ + $eauth = Yii::$app->get('eauth')->getIdentity($serviceName); + $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl()); + $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login')); + + try { + if ($eauth->authenticate()) { + $identity = User::findByEAuth($eauth); + Yii::$app->getUser()->login($identity); + + //Save date get social network in database + if (! $social::find()->where(['social_user_id' => $identity[profile][id], 'social_name' => $identity[profile][service]])->exists()) { + $name = explode(' ',$identity[profile][name]); + $user->firstname = $name[0]; + $user->lastname = $name[1]; + $user->id_system_date = date("d.m.y.H:i:s"); + $user->save(); + $social->social_name = $identity[profile][service]; + $social->social_user_id = $identity[profile][id]; + $social->user_id = $user->id; + $social->validate(); + $social->errors; + $social->save(); + } + + // special redirect with closing popup window + $eauth->redirect(); + } + else { + // close popup window and redirect to cancelUrl + $eauth->cancel(); + } + } + catch (\nodge\eauth\ErrorException $e) { + // save error to show it later + Yii::$app->getSession()->setFlash('error', 'EAuthException: '.$e->getMessage()); + + // close popup window and redirect to cancelUrl + // $eauth->cancel(); + $eauth->redirect($eauth->getCancelUrl()); + } + } + + + + + if (!\Yii::$app->user->isGuest) { + return $this->goHome(); + } + + $model = new LoginForm(); + if ($model->load(Yii::$app->request->post()) && $model->login()) { + return $this->goBack(); + } else { + return $this->render('login', [ + 'model' => $model, + ]); + } } /** diff --git a/frontend/views/accounts/_form.php b/frontend/views/accounts/_form.php new file mode 100644 index 0000000..2778d4f --- /dev/null +++ b/frontend/views/accounts/_form.php @@ -0,0 +1,59 @@ + + + + +field($user, 'username')->textInput() ?> + +field($user, 'lastname')->textInput() ?> + +field($user, 'firstname')->textInput() ?> + +field($user, 'email')->textInput() ?> + +field($user_info, 'user_id')->textInput() ?> + +field($user_info, 'view_count')->textInput() ?> + +field($user_info, 'busy')->textInput(['maxlength' => true]) ?> + +field($user_info, 'date_visit')->textInput() ?> + +field($user_info, 'experience')->textInput() ?> + +field($user_info, 'rank')->textInput(['maxlength' => true]) ?> + +field($user_info, 'salary')->textInput(['maxlength' => true]) ?> + +field($user_info, 'job')->textInput(['maxlength' => true]) ?> + +field($user_info, 'location')->textInput(['maxlength' => true]) ?> + +field($user_info, 'soft')->textInput() ?> + +field($user_info, 'guarantee')->textInput() ?> + +field($user_info, 'contract')->textInput() ?> + +field($user_info, 'estimate')->textInput() ?> + +field($user_info, 'purchase')->textInput() ?> + +field($user_info, 'delivery')->textInput() ?> + +field($user_info, 'prepayment')->textInput() ?> + +field($user_info, 'about')->textarea(['rows' => 6]) ?> + + $model->id, 'model'=>'Gallery']); ?> + + +
    + 'btn btn-success']) ?> +
    + + \ No newline at end of file diff --git a/frontend/views/accounts/cabinet.php b/frontend/views/accounts/cabinet.php index d674151..162a954 100755 --- a/frontend/views/accounts/cabinet.php +++ b/frontend/views/accounts/cabinet.php @@ -2,58 +2,25 @@ use common\models\Option; use yii\helpers\Html; use yii\widgets\ActiveForm; +use \common\widgets\MultiLangForm; + $this->title = 'Мой профиль'; -$this->params['breadcrumbs'][] = $this->title; + $this->params['breadcrumbs'][] = $this->title; ?>

    title ?>

    - - - field($user, 'username')->textInput() ?> - - field($user, 'lastname')->textInput() ?> - - field($user, 'firstname')->textInput() ?> - - field($user, 'email')->textInput() ?> - - field($user_info, 'user_id')->textInput() ?> - - field($user_info, 'view_count')->textInput() ?> - - field($user_info, 'busy')->textInput(['maxlength' => true]) ?> - - field($user_info, 'date_visit')->textInput() ?> - - field($user_info, 'experience')->textInput() ?> - field($user_info, 'rank')->textInput(['maxlength' => true]) ?> - field($user_info, 'salary')->textInput(['maxlength' => true]) ?> - - field($user_info, 'job')->textInput(['maxlength' => true]) ?> - - field($user_info, 'location')->textInput(['maxlength' => true]) ?> - - field($user_info, 'soft')->textInput() ?> - - field($user_info, 'guarantee')->textInput() ?> - - field($user_info, 'contract')->textInput() ?> - - field($user_info, 'estimate')->textInput() ?> - - field($user_info, 'purchase')->textInput() ?> +field($user_info, 'delivery')->textInput() ?> +$form = $this->render('_form', [ + 'user' => $user, + 'user_info' => $user_info, +]); - field($user_info, 'prepayment')->textInput() ?> +echo MultiLangForm::widget(['form'=>$form]); - field($user_info, 'about')->textarea(['rows' => 6]) ?> +?> -
    - 'btn btn-success']) ?> -
    - \ No newline at end of file diff --git a/frontend/web/css/art_box.css b/frontend/web/css/art_box.css new file mode 100644 index 0000000..5dcf7f6 --- /dev/null +++ b/frontend/web/css/art_box.css @@ -0,0 +1,4 @@ +.glyphicon_right{ + top: -55px; + left: 50px; +} \ No newline at end of file -- libgit2 0.21.4