Commit 2ff006627f547fb5a5ccf7febfaa7ebae0a8418b

Authored by Administrator
1 parent 8e7a541c

firs page

backend/web/js/option.js
... ... @@ -58,55 +58,55 @@ $(function() {
58 58 }
59 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 110 $(document).on('click', '.remove-lang', function() {
111 111 var lang = $(this).parent().data('lang');
112 112 var flag = $(this).parent().find('span.flag').first().clone();
... ...
common/widgets/FieldEditor.php 0 → 100644
  1 +<?php
  2 +namespace backend\components;
  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 43 \ No newline at end of file
... ...
common/widgets/MultiLangForm.php 0 → 100644
  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 27 \ No newline at end of file
... ...
common/widgets/views/multi-lang-form.php 0 → 100644
  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 33 \ No newline at end of file
... ...
frontend/assets/AdminAsset.php
... ... @@ -19,6 +19,7 @@ class AdminAsset extends AssetBundle
19 19 public $baseUrl = '@web';
20 20 public $css = [
21 21 'css/style.css',
  22 + 'css/art_box.css',
22 23 '/admin/css/flags32.css',
23 24 'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin',
24 25 ];
... ...
frontend/controllers/AccountsController.php
1 1 <?php
2 2 namespace frontend\controllers;
3 3  
  4 +use common\models\Language;
4 5 use Yii;
5 6 use common\models\User;
6 7 use common\models\UserInfo;
... ... @@ -44,11 +45,14 @@ class AccountsController extends Controller
44 45  
45 46 $user_info = $this->findUserInfo(Yii::$app->user->identity->id);
46 47  
  48 + $langs = Language::getActiveLanguages();
  49 +
47 50  
48 51  
49 52 return $this->render('cabinet', [
50 53 'user' => $user,
51 54 'user_info' => $user_info,
  55 + 'langs' => $langs,
52 56 ]);
53 57  
54 58  
... ...
frontend/controllers/SiteController.php
... ... @@ -93,71 +93,71 @@ class SiteController extends Controller
93 93 ]);
94 94 }
95 95  
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   -// }
  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 + }
161 161 }
162 162  
163 163 /**
... ...
frontend/views/accounts/_form.php 0 → 100644
  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(['item_id'=> $model->id, 'model'=>'Gallery']); ?>
  53 +
  54 +
  55 +<div class="form-group">
  56 + <?= Html::submitButton('Create', ['class' => 'btn btn-success']) ?>
  57 +</div>
  58 +
  59 +<?php ActiveForm::end(); ?>
0 60 \ No newline at end of file
... ...
frontend/views/accounts/cabinet.php
... ... @@ -2,58 +2,25 @@
2 2 use common\models\Option;
3 3 use yii\helpers\Html;
4 4 use yii\widgets\ActiveForm;
  5 +use \common\widgets\MultiLangForm;
  6 +
5 7 $this->title = 'Мой профиль';
6   -$this->params['breadcrumbs'][] = $this->title;
  8 + $this->params['breadcrumbs'][] = $this->title;
7 9 ?>
8 10  
9 11 <h1><?= $this->title ?></h1>
10 12  
11   -<?php $form = ActiveForm::begin(); ?>
12   -
13   - <?= $form->field($user, 'username')->textInput() ?>
14   -
15   - <?= $form->field($user, 'lastname')->textInput() ?>
16   -
17   - <?= $form->field($user, 'firstname')->textInput() ?>
18   -
19   - <?= $form->field($user, 'email')->textInput() ?>
20   -
21   - <?= $form->field($user_info, 'user_id')->textInput() ?>
22   -
23   - <?= $form->field($user_info, 'view_count')->textInput() ?>
24   -
25   - <?= $form->field($user_info, 'busy')->textInput(['maxlength' => true]) ?>
26   -
27   - <?= $form->field($user_info, 'date_visit')->textInput() ?>
28   -
29   - <?= $form->field($user_info, 'experience')->textInput() ?>
30 13  
31   - <?= $form->field($user_info, 'rank')->textInput(['maxlength' => true]) ?>
32 14  
33   - <?= $form->field($user_info, 'salary')->textInput(['maxlength' => true]) ?>
34   -
35   - <?= $form->field($user_info, 'job')->textInput(['maxlength' => true]) ?>
36   -
37   - <?= $form->field($user_info, 'location')->textInput(['maxlength' => true]) ?>
38   -
39   - <?= $form->field($user_info, 'soft')->textInput() ?>
40   -
41   - <?= $form->field($user_info, 'guarantee')->textInput() ?>
42   -
43   - <?= $form->field($user_info, 'contract')->textInput() ?>
44   -
45   - <?= $form->field($user_info, 'estimate')->textInput() ?>
46   -
47   - <?= $form->field($user_info, 'purchase')->textInput() ?>
  15 +<?php
48 16  
49   - <?= $form->field($user_info, 'delivery')->textInput() ?>
  17 +$form = $this->render('_form', [
  18 + 'user' => $user,
  19 + 'user_info' => $user_info,
  20 +]);
50 21  
51   - <?= $form->field($user_info, 'prepayment')->textInput() ?>
  22 +echo MultiLangForm::widget(['form'=>$form]);
52 23  
53   - <?= $form->field($user_info, 'about')->textarea(['rows' => 6]) ?>
  24 +?>
54 25  
55   - <div class="form-group">
56   - <?= Html::submitButton('Create', ['class' => 'btn btn-success']) ?>
57   - </div>
58 26  
59   -<?php ActiveForm::end(); ?>
60 27 \ No newline at end of file
... ...
frontend/web/css/art_box.css 0 → 100644
  1 +.glyphicon_right{
  2 + top: -55px;
  3 + left: 50px;
  4 +}
0 5 \ No newline at end of file
... ...