Commit c3ab6536b4e45ad39390b8f05a284703c2db2268
Merge remote-tracking branch 'origin/master'
Showing
12 changed files
with
392 additions
and
119 deletions
Show diff stats
backend/web/js/option.js
| @@ -58,55 +58,55 @@ $(function() { | @@ -58,55 +58,55 @@ $(function() { | ||
| 58 | } | 58 | } |
| 59 | return false; | 59 | return false; |
| 60 | }); | 60 | }); |
| 61 | - $.each($('.nav-tabs.f32'), function(key, value) { | ||
| 62 | - if($(value).find('li').length > 1) { | ||
| 63 | - $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>'); | ||
| 64 | - } | ||
| 65 | - }); | ||
| 66 | - $(document).on('click', '.dropdown-menu.f32:not(.old) li a[data-lang]', function() { | ||
| 67 | - var lang = $(this).data('lang'); | ||
| 68 | - var flag = $(this).find('span').first().clone(); | ||
| 69 | - var el = $(this); | ||
| 70 | - var id = $(this).attr('href').substr(1); | ||
| 71 | - var path = form[id].handler; | ||
| 72 | - var view = form[id].view; | ||
| 73 | - var model = form[id].model; | ||
| 74 | - $.get(path, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) { | ||
| 75 | - $('#'+id+'-tabs li').removeClass('active'); | ||
| 76 | - $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | ||
| 77 | - $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | ||
| 78 | - $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); | ||
| 79 | - $('body').append($(data).filter('script')); | ||
| 80 | - $(el).parent().remove(); | ||
| 81 | - if(!$('#lang-'+id+' li').length) { | ||
| 82 | - $('#'+id+'Lang').addClass('disabled'); | ||
| 83 | - } | ||
| 84 | - if($('#'+id+'-tabs li').length > 1) { | ||
| 85 | - $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>') | ||
| 86 | - } | ||
| 87 | - }); | ||
| 88 | - }); | ||
| 89 | - $(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function(e) { | ||
| 90 | - e.preventDefault(); | ||
| 91 | - var lang = $(this).data('lang'); | ||
| 92 | - var flag = $(this).find('span').first().clone(); | ||
| 93 | - var el = $(this); | ||
| 94 | - var id = $(this).attr('href').substr(1); | ||
| 95 | - $.get(form[id], { language_id: lang, widget_id: id }, function(data) { | ||
| 96 | - $('#'+id+'-tabs li').removeClass('active'); | ||
| 97 | - $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | ||
| 98 | - $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | ||
| 99 | - $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); | ||
| 100 | - $('body').append($(data).filter('script')); | ||
| 101 | - $(el).parent().remove(); | ||
| 102 | - if(!$('#lang-'+id+' li').length) { | ||
| 103 | - $('#'+id+'Lang').addClass('disabled'); | ||
| 104 | - } | ||
| 105 | - if($('#'+id+'-tabs li').length > 1) { | ||
| 106 | - $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>') | ||
| 107 | - } | ||
| 108 | - }); | ||
| 109 | - }); | 61 | + //$.each($('.nav-tabs.f32'), function(key, value) { |
| 62 | + // if($(value).find('li').length > 1) { | ||
| 63 | + // $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>'); | ||
| 64 | + // } | ||
| 65 | + //}); | ||
| 66 | + //$(document).on('click', '.dropdown-menu.f32:not(.old) li a[data-lang]', function() { | ||
| 67 | + // var lang = $(this).data('lang'); | ||
| 68 | + // var flag = $(this).find('span').first().clone(); | ||
| 69 | + // var el = $(this); | ||
| 70 | + // var id = $(this).attr('href').substr(1); | ||
| 71 | + // var path = form[id].handler; | ||
| 72 | + // var view = form[id].view; | ||
| 73 | + // var model = form[id].model; | ||
| 74 | + // $.get(path, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) { | ||
| 75 | + // $('#'+id+'-tabs li').removeClass('active'); | ||
| 76 | + // $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | ||
| 77 | + // $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | ||
| 78 | + // $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); | ||
| 79 | + // $('body').append($(data).filter('script')); | ||
| 80 | + // $(el).parent().remove(); | ||
| 81 | + // if(!$('#lang-'+id+' li').length) { | ||
| 82 | + // $('#'+id+'Lang').addClass('disabled'); | ||
| 83 | + // } | ||
| 84 | + // if($('#'+id+'-tabs li').length > 1) { | ||
| 85 | + // $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>') | ||
| 86 | + // } | ||
| 87 | + // }); | ||
| 88 | + //}); | ||
| 89 | + //$(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function(e) { | ||
| 90 | + // e.preventDefault(); | ||
| 91 | + // var lang = $(this).data('lang'); | ||
| 92 | + // var flag = $(this).find('span').first().clone(); | ||
| 93 | + // var el = $(this); | ||
| 94 | + // var id = $(this).attr('href').substr(1); | ||
| 95 | + // $.get(form[id], { language_id: lang, widget_id: id }, function(data) { | ||
| 96 | + // $('#'+id+'-tabs li').removeClass('active'); | ||
| 97 | + // $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | ||
| 98 | + // $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | ||
| 99 | + // $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); | ||
| 100 | + // $('body').append($(data).filter('script')); | ||
| 101 | + // $(el).parent().remove(); | ||
| 102 | + // if(!$('#lang-'+id+' li').length) { | ||
| 103 | + // $('#'+id+'Lang').addClass('disabled'); | ||
| 104 | + // } | ||
| 105 | + // if($('#'+id+'-tabs li').length > 1) { | ||
| 106 | + // $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>') | ||
| 107 | + // } | ||
| 108 | + // }); | ||
| 109 | + //}); | ||
| 110 | $(document).on('click', '.remove-lang', function() { | 110 | $(document).on('click', '.remove-lang', function() { |
| 111 | var lang = $(this).parent().data('lang'); | 111 | var lang = $(this).parent().data('lang'); |
| 112 | var flag = $(this).parent().find('span.flag').first().clone(); | 112 | var flag = $(this).parent().find('span.flag').first().clone(); |
common/config/main-local.php
| @@ -3,9 +3,9 @@ return [ | @@ -3,9 +3,9 @@ return [ | ||
| 3 | 'components' => [ | 3 | 'components' => [ |
| 4 | 'db' => [ | 4 | 'db' => [ |
| 5 | 'class' => 'yii\db\Connection', | 5 | 'class' => 'yii\db\Connection', |
| 6 | - 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local', | ||
| 7 | - 'username' => 'postgres', | ||
| 8 | - 'password' => '', | 6 | + 'dsn' => 'pgsql:host=195.248.225.149;port=5432;dbname=mfp', |
| 7 | + 'username' => 'test33', | ||
| 8 | + 'password' => 'E4q2N7i9', | ||
| 9 | 'schemaMap' => [ | 9 | 'schemaMap' => [ |
| 10 | 'pgsql'=> [ | 10 | 'pgsql'=> [ |
| 11 | 'class'=>'yii\db\pgsql\Schema', | 11 | 'class'=>'yii\db\pgsql\Schema', |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "{{%fields}}". | ||
| 9 | + * | ||
| 10 | + * @property integer $id | ||
| 11 | + * @property string $table_name | ||
| 12 | + * @property integer $table_id | ||
| 13 | + * @property string $value | ||
| 14 | + * @property string $field_name | ||
| 15 | + * @property string $field_type | ||
| 16 | + */ | ||
| 17 | +class Fields extends \yii\db\ActiveRecord | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public static function tableName() | ||
| 23 | + { | ||
| 24 | + return '{{%fields}}'; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @inheritdoc | ||
| 29 | + */ | ||
| 30 | + public function rules() | ||
| 31 | + { | ||
| 32 | + return [ | ||
| 33 | + [['table_name', 'table_id',], 'required'], | ||
| 34 | + [['table_id','language'], 'integer'], | ||
| 35 | + [['table_name', 'value', 'field_name','field_type'], 'string', 'max' => 255] | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public function attributeLabels() | ||
| 43 | + { | ||
| 44 | + return [ | ||
| 45 | + 'id' => 'ID', | ||
| 46 | + 'table_name' => 'Model Name', | ||
| 47 | + 'table_id' => 'Model ID', | ||
| 48 | + 'value' => 'Value', | ||
| 49 | + 'field_name' => 'Field Name', | ||
| 50 | + 'language' => 'Language', | ||
| 51 | + ]; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public static function getData($id, $model, $type){ | ||
| 55 | + return self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all(); | ||
| 56 | + } | ||
| 57 | +} |
| 1 | +<?php | ||
| 2 | +namespace common\widgets; | ||
| 3 | +use common\models\Fields; | ||
| 4 | +use yii\base\Widget; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +class FieldEditor extends Widget | ||
| 8 | +{ | ||
| 9 | + public $item_id; | ||
| 10 | + public $model; | ||
| 11 | + public $template; | ||
| 12 | + | ||
| 13 | + public function init(){ | ||
| 14 | + | ||
| 15 | + parent::init(); | ||
| 16 | + | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + public function run() | ||
| 21 | + { | ||
| 22 | + if($this->item_id && $this->model){ | ||
| 23 | + $widgetData = $this->findModel(); | ||
| 24 | + } else { | ||
| 25 | + $widgetData= [new Fields()]; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + return $this->render($this->template.'_field',['model'=>$widgetData]); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + protected function findModel() | ||
| 33 | + { | ||
| 34 | + if (($model = Fields::find()->where(['table_id'=>$this->item_id, 'table_name'=>$this->model, 'field_type'=>$this->template])->all()) !== null) { | ||
| 35 | + | ||
| 36 | + return $model; | ||
| 37 | + | ||
| 38 | + } else { | ||
| 39 | + return [new Fields()]; | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | +} | ||
| 0 | \ No newline at end of file | 43 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | +namespace common\widgets; | ||
| 3 | +use common\models\Language; | ||
| 4 | +use common\modules\blog\controllers\AjaxController; | ||
| 5 | +use yii\base\InvalidParamException; | ||
| 6 | +use yii\base\Widget; | ||
| 7 | +use yii\bootstrap\ActiveForm; | ||
| 8 | + | ||
| 9 | +class MultiLangForm extends Widget | ||
| 10 | +{ | ||
| 11 | + public $form; | ||
| 12 | + | ||
| 13 | + public function init() | ||
| 14 | + { | ||
| 15 | + parent::init(); | ||
| 16 | + | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public function run() | ||
| 20 | + { | ||
| 21 | + return $this->render('multi-lang-form', | ||
| 22 | + [ | ||
| 23 | + 'form' => $this->form | ||
| 24 | + ]); | ||
| 25 | + } | ||
| 26 | +} | ||
| 0 | \ No newline at end of file | 27 | \ No newline at end of file |
| 1 | +<!----> | ||
| 2 | +<!--<div class="dropdown pull-right">--> | ||
| 3 | +<!-- <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">--> | ||
| 4 | +<!-- --><?//= Yii::t('app', 'Add language') ?> | ||
| 5 | +<!-- <span class="caret"></span>--> | ||
| 6 | +<!-- </button>--> | ||
| 7 | +<!-- <ul class="dropdown-menu f32" >--> | ||
| 8 | +<!-- <li><a href="#" data-lang="0"><span class="flag ru"></span></a></li>--> | ||
| 9 | +<!-- <li><a href="#" data-lang="1"><span class="flag ua"></span></a></li>--> | ||
| 10 | +<!-- </ul>--> | ||
| 11 | +<!--</div>--> | ||
| 12 | +<ul class="nav nav-tabs f32" role="tablist"> | ||
| 13 | + | ||
| 14 | + <li data-lang="0" class="active"> | ||
| 15 | + | ||
| 16 | + <a href="#ru_form" role="tab" data-toggle="tab"><span class="flag ru"></span></a> | ||
| 17 | + | ||
| 18 | + </li> | ||
| 19 | + <!-- <li data-lang="1">--> | ||
| 20 | + <!----> | ||
| 21 | + <!-- <a href="#ua_form" role="tab" data-toggle="tab"><span class="flag ua"></span></a>--> | ||
| 22 | + <!-- <span class="glyphicon glyphicon-remove-circle remove-lang glyphicon_right"></span>--> | ||
| 23 | + <!-- </li>--> | ||
| 24 | +</ul> | ||
| 25 | +<div class="tab-content lang-tab-content"> | ||
| 26 | + <div class="tab-pane active" id="ru_form"> | ||
| 27 | + | ||
| 28 | + <?= $form ?> | ||
| 29 | + | ||
| 30 | + </div> | ||
| 31 | + | ||
| 32 | +</div> | ||
| 0 | \ No newline at end of file | 33 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +class m160128_101543_fields extends Migration | ||
| 6 | +{ | ||
| 7 | + public function up() | ||
| 8 | + { | ||
| 9 | + $tableOptions = null; | ||
| 10 | + | ||
| 11 | + $this->createTable('{{%fields}}', [ | ||
| 12 | + 'id' => $this->primaryKey(), | ||
| 13 | + 'table_name' => $this->string(255)->notNull(), | ||
| 14 | + 'table_id' => $this->integer(), | ||
| 15 | + 'value' => $this->string(255), | ||
| 16 | + 'field_name' => $this->string(), | ||
| 17 | + 'field_type' => $this->string(32)->notNull(), | ||
| 18 | + 'language' => $this->integer() | ||
| 19 | + ], $tableOptions); | ||
| 20 | + | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public function down() | ||
| 24 | + { | ||
| 25 | + $this->dropTable('{{%fields}}'); | ||
| 26 | + } | ||
| 27 | +} |
frontend/assets/AdminAsset.php
| @@ -19,6 +19,7 @@ class AdminAsset extends AssetBundle | @@ -19,6 +19,7 @@ class AdminAsset extends AssetBundle | ||
| 19 | public $baseUrl = '@web'; | 19 | public $baseUrl = '@web'; |
| 20 | public $css = [ | 20 | public $css = [ |
| 21 | 'css/style.css', | 21 | 'css/style.css', |
| 22 | + 'css/art_box.css', | ||
| 22 | '/admin/css/flags32.css', | 23 | '/admin/css/flags32.css', |
| 23 | //'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', | 24 | //'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', |
| 24 | ]; | 25 | ]; |
frontend/controllers/SiteController.php
| 1 | <?php | 1 | <?php |
| 2 | namespace frontend\controllers; | 2 | namespace frontend\controllers; |
| 3 | 3 | ||
| 4 | +use common\models\UserInfo; | ||
| 4 | use Yii; | 5 | use Yii; |
| 5 | use common\models\LoginForm; | 6 | use common\models\LoginForm; |
| 6 | use frontend\models\PasswordResetRequestForm; | 7 | use frontend\models\PasswordResetRequestForm; |
| @@ -92,71 +93,71 @@ class SiteController extends Controller | @@ -92,71 +93,71 @@ class SiteController extends Controller | ||
| 92 | ]); | 93 | ]); |
| 93 | } | 94 | } |
| 94 | 95 | ||
| 95 | -// // creat new model table Social and new model User | ||
| 96 | -// $social = new Social(); | ||
| 97 | -// $user = new User(); | ||
| 98 | -// | ||
| 99 | -// $serviceName = Yii::$app->getRequest()->getQueryParam('service'); | ||
| 100 | -// | ||
| 101 | -// if (isset($serviceName)) { | ||
| 102 | -// /** @var $eauth \nodge\eauth\ServiceBase */ | ||
| 103 | -// $eauth = Yii::$app->get('eauth')->getIdentity($serviceName); | ||
| 104 | -// $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl()); | ||
| 105 | -// $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login')); | ||
| 106 | -// | ||
| 107 | -// try { | ||
| 108 | -// if ($eauth->authenticate()) { | ||
| 109 | -// $identity = User::findByEAuth($eauth); | ||
| 110 | -// Yii::$app->getUser()->login($identity); | ||
| 111 | -// | ||
| 112 | -// //Save date get social network in database | ||
| 113 | -// if (! $social::find()->where(['social_user_id' => $identity[profile][id], 'social_name' => $identity[profile][service]])->exists()) { | ||
| 114 | -// $name = explode(' ',$identity[profile][name]); | ||
| 115 | -// $user->firstname = $name[0]; | ||
| 116 | -// $user->lastname = $name[1]; | ||
| 117 | -// $user->id_system_date = date("d.m.y.H:i:s"); | ||
| 118 | -// $user->save(); | ||
| 119 | -// $social->social_name = $identity[profile][service]; | ||
| 120 | -// $social->social_user_id = $identity[profile][id]; | ||
| 121 | -// $social->user_id = $user->id; | ||
| 122 | -// $social->validate(); | ||
| 123 | -// $social->errors; | ||
| 124 | -// $social->save(); | ||
| 125 | -// } | ||
| 126 | -// | ||
| 127 | -// // special redirect with closing popup window | ||
| 128 | -// $eauth->redirect(); | ||
| 129 | -// } | ||
| 130 | -// else { | ||
| 131 | -// // close popup window and redirect to cancelUrl | ||
| 132 | -// $eauth->cancel(); | ||
| 133 | -// } | ||
| 134 | -// } | ||
| 135 | -// catch (\nodge\eauth\ErrorException $e) { | ||
| 136 | -// // save error to show it later | ||
| 137 | -// Yii::$app->getSession()->setFlash('error', 'EAuthException: '.$e->getMessage()); | ||
| 138 | -// | ||
| 139 | -// // close popup window and redirect to cancelUrl | ||
| 140 | -// // $eauth->cancel(); | ||
| 141 | -// $eauth->redirect($eauth->getCancelUrl()); | ||
| 142 | -// } | ||
| 143 | -// } | ||
| 144 | -// | ||
| 145 | -// | ||
| 146 | -// | ||
| 147 | -// | ||
| 148 | -// if (!\Yii::$app->user->isGuest) { | ||
| 149 | -// return $this->goHome(); | ||
| 150 | -// } | ||
| 151 | -// | ||
| 152 | -// $model = new LoginForm(); | ||
| 153 | -// if ($model->load(Yii::$app->request->post()) && $model->login()) { | ||
| 154 | -// return $this->goBack(); | ||
| 155 | -// } else { | ||
| 156 | -// return $this->render('login', [ | ||
| 157 | -// 'model' => $model, | ||
| 158 | -// ]); | ||
| 159 | -// } | 96 | + // creat new model table Social and new model User |
| 97 | + $social = new Social(); | ||
| 98 | + $user = new User(); | ||
| 99 | + | ||
| 100 | + $serviceName = Yii::$app->getRequest()->getQueryParam('service'); | ||
| 101 | + | ||
| 102 | + if (isset($serviceName)) { | ||
| 103 | + /** @var $eauth \nodge\eauth\ServiceBase */ | ||
| 104 | + $eauth = Yii::$app->get('eauth')->getIdentity($serviceName); | ||
| 105 | + $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl()); | ||
| 106 | + $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login')); | ||
| 107 | + | ||
| 108 | + try { | ||
| 109 | + if ($eauth->authenticate()) { | ||
| 110 | + $identity = User::findByEAuth($eauth); | ||
| 111 | + Yii::$app->getUser()->login($identity); | ||
| 112 | + | ||
| 113 | + //Save date get social network in database | ||
| 114 | + if (! $social::find()->where(['social_user_id' => $identity[profile][id], 'social_name' => $identity[profile][service]])->exists()) { | ||
| 115 | + $name = explode(' ',$identity[profile][name]); | ||
| 116 | + $user->firstname = $name[0]; | ||
| 117 | + $user->lastname = $name[1]; | ||
| 118 | + $user->id_system_date = date("d.m.y.H:i:s"); | ||
| 119 | + $user->save(); | ||
| 120 | + $social->social_name = $identity[profile][service]; | ||
| 121 | + $social->social_user_id = $identity[profile][id]; | ||
| 122 | + $social->user_id = $user->id; | ||
| 123 | + $social->validate(); | ||
| 124 | + $social->errors; | ||
| 125 | + $social->save(); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + // special redirect with closing popup window | ||
| 129 | + $eauth->redirect(); | ||
| 130 | + } | ||
| 131 | + else { | ||
| 132 | + // close popup window and redirect to cancelUrl | ||
| 133 | + $eauth->cancel(); | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + catch (\nodge\eauth\ErrorException $e) { | ||
| 137 | + // save error to show it later | ||
| 138 | + Yii::$app->getSession()->setFlash('error', 'EAuthException: '.$e->getMessage()); | ||
| 139 | + | ||
| 140 | + // close popup window and redirect to cancelUrl | ||
| 141 | + // $eauth->cancel(); | ||
| 142 | + $eauth->redirect($eauth->getCancelUrl()); | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + | ||
| 149 | + if (!\Yii::$app->user->isGuest) { | ||
| 150 | + return $this->goHome(); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + $model = new LoginForm(); | ||
| 154 | + if ($model->load(Yii::$app->request->post()) && $model->login()) { | ||
| 155 | + return $this->goBack(); | ||
| 156 | + } else { | ||
| 157 | + return $this->render('login', [ | ||
| 158 | + 'model' => $model, | ||
| 159 | + ]); | ||
| 160 | + } | ||
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | /** | 163 | /** |
| @@ -212,6 +213,13 @@ class SiteController extends Controller | @@ -212,6 +213,13 @@ class SiteController extends Controller | ||
| 212 | $model = new SignupForm(); | 213 | $model = new SignupForm(); |
| 213 | if ($model->load(Yii::$app->request->post())) { | 214 | if ($model->load(Yii::$app->request->post())) { |
| 214 | if ($user = $model->signup()) { | 215 | if ($user = $model->signup()) { |
| 216 | + | ||
| 217 | + $user_info = new UserInfo(); | ||
| 218 | + | ||
| 219 | + $user_info->user_id = $user->id; | ||
| 220 | + | ||
| 221 | + $user_info->save(); | ||
| 222 | + | ||
| 215 | if (Yii::$app->getUser()->login($user)) { | 223 | if (Yii::$app->getUser()->login($user)) { |
| 216 | return $this->goHome(); | 224 | return $this->goHome(); |
| 217 | } | 225 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +?> | ||
| 7 | + | ||
| 8 | +<?php $form = ActiveForm::begin(); ?> | ||
| 9 | + | ||
| 10 | +<?= $form->field($user, 'username')->textInput() ?> | ||
| 11 | + | ||
| 12 | +<?= $form->field($user, 'lastname')->textInput() ?> | ||
| 13 | + | ||
| 14 | +<?= $form->field($user, 'firstname')->textInput() ?> | ||
| 15 | + | ||
| 16 | +<?= $form->field($user, 'email')->textInput() ?> | ||
| 17 | + | ||
| 18 | +<?= $form->field($user_info, 'user_id')->textInput() ?> | ||
| 19 | + | ||
| 20 | +<?= $form->field($user_info, 'view_count')->textInput() ?> | ||
| 21 | + | ||
| 22 | +<?= $form->field($user_info, 'busy')->textInput(['maxlength' => true]) ?> | ||
| 23 | + | ||
| 24 | +<?= $form->field($user_info, 'date_visit')->textInput() ?> | ||
| 25 | + | ||
| 26 | +<?= $form->field($user_info, 'experience')->textInput() ?> | ||
| 27 | + | ||
| 28 | +<?= $form->field($user_info, 'rank')->textInput(['maxlength' => true]) ?> | ||
| 29 | + | ||
| 30 | +<?= $form->field($user_info, 'salary')->textInput(['maxlength' => true]) ?> | ||
| 31 | + | ||
| 32 | +<?= $form->field($user_info, 'job')->textInput(['maxlength' => true]) ?> | ||
| 33 | + | ||
| 34 | +<?= $form->field($user_info, 'location')->textInput(['maxlength' => true]) ?> | ||
| 35 | + | ||
| 36 | +<?= $form->field($user_info, 'soft')->textInput() ?> | ||
| 37 | + | ||
| 38 | +<?= $form->field($user_info, 'guarantee')->textInput() ?> | ||
| 39 | + | ||
| 40 | +<?= $form->field($user_info, 'contract')->textInput() ?> | ||
| 41 | + | ||
| 42 | +<?= $form->field($user_info, 'estimate')->textInput() ?> | ||
| 43 | + | ||
| 44 | +<?= $form->field($user_info, 'purchase')->textInput() ?> | ||
| 45 | + | ||
| 46 | +<?= $form->field($user_info, 'delivery')->textInput() ?> | ||
| 47 | + | ||
| 48 | +<?= $form->field($user_info, 'prepayment')->textInput() ?> | ||
| 49 | + | ||
| 50 | +<?= $form->field($user_info, 'about')->textarea(['rows' => 6]) ?> | ||
| 51 | + | ||
| 52 | +<?= \common\widgets\FieldEditor::widget(['template'=>'', 'item_id'=> $user->id, 'model'=>'User']); ?> | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +<div class="form-group"> | ||
| 56 | + <?= Html::submitButton('Create', ['class' => 'btn btn-success']) ?> | ||
| 57 | +</div> | ||
| 58 | + | ||
| 59 | +<?php ActiveForm::end(); ?> | ||
| 0 | \ No newline at end of file | 60 | \ No newline at end of file |
frontend/views/accounts/cabinet.php
| 1 | <?php | 1 | <?php |
| 2 | - use common\models\Option; | 2 | +use common\models\Option; |
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | +use \common\widgets\MultiLangForm; | ||
| 3 | 6 | ||
| 4 | $this->title = 'Мой профиль'; | 7 | $this->title = 'Мой профиль'; |
| 5 | -$this->params['breadcrumbs'][] = $this->title; | 8 | + $this->params['breadcrumbs'][] = $this->title; |
| 6 | ?> | 9 | ?> |
| 7 | 10 | ||
| 8 | <h1><?= $this->title ?></h1> | 11 | <h1><?= $this->title ?></h1> |
| 9 | 12 | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +<?php | ||
| 16 | + | ||
| 17 | +$form = $this->render('_form', [ | ||
| 18 | + 'user' => $user, | ||
| 19 | + 'user_info' => $user_info, | ||
| 20 | +]); | ||
| 21 | + | ||
| 22 | +echo MultiLangForm::widget(['form'=>$form]); | ||
| 23 | + | ||
| 24 | +?> | ||
| 25 | + | ||
| 26 | + |