Commit 8b3dc47b1047a9e1bb7131527049c4462b8b9041

Authored by Yarik
1 parent 4cad42b8

XPanel removed

backend/views/settings/_main_tab.php
... ... @@ -10,13 +10,13 @@
10 10 */
11 11 echo $form->field($model, 'name')
12 12 ->textInput();
13   - // echo $form->field($model, 'logo')
14   - // ->widget(
15   - // \noam148\imagemanager\components\ImageManagerInputWidget::className(),
16   - // [
17   - // 'showPreview' => true,
18   - // 'showDeletePickedImageConfirm' => false,
19   - // ]
20   - // );
  13 + echo $form->field($model, 'logo')
  14 + ->widget(
  15 + \noam148\imagemanager\components\ImageManagerInputWidget::className(),
  16 + [
  17 + 'showPreview' => true,
  18 + 'showDeletePickedImageConfirm' => false,
  19 + ]
  20 + );
21 21 echo $form->field($model, 'about')
22 22 ->textarea();
23 23 \ No newline at end of file
... ...
backend/views/settings/codes.php
... ... @@ -5,20 +5,19 @@
5 5 */
6 6  
7 7 use common\models\Settings;
8   - use artbox\gentelella\widgets\XPanel;
9 8 use yii\bootstrap\ActiveForm;
10 9 use yii\bootstrap\Html;
11 10 use yii\web\View;
  11 + use yiister\gentelella\widgets\Panel;
12 12  
13 13 $this->title = Yii::t('core', 'Codes');
14 14  
15 15 $this->params[ 'breadcrumbs' ][] = $this->title;
16 16 ?>
17 17  
18   -<?php $panel = XPanel::begin(
  18 +<?php $panel = Panel::begin(
19 19 [
20   - 'title' => $this->title,
21   - 'toolbar' => false,
  20 + 'header' => $this->title,
22 21 ]
23 22 ); ?>
24 23  
... ...
backend/views/settings/robots.php
... ... @@ -5,20 +5,19 @@
5 5 */
6 6  
7 7 use common\models\Settings;
8   - use artbox\gentelella\widgets\XPanel;
9 8 use yii\bootstrap\ActiveForm;
10 9 use yii\bootstrap\Html;
11 10 use yii\web\View;
  11 + use yiister\gentelella\widgets\Panel;
12 12  
13 13 $this->title = $model->getAttributeLabel('robots');
14 14  
15 15 $this->params[ 'breadcrumbs' ][] = $this->title;
16 16 ?>
17 17  
18   -<?php $panel = XPanel::begin(
  18 +<?php $panel = Panel::begin(
19 19 [
20   - 'title' => $this->title,
21   - 'toolbar' => false,
  20 + 'header' => $this->title,
22 21 ]
23 22 ); ?>
24 23  
... ...
backend/views/settings/settings.php
... ... @@ -5,21 +5,20 @@
5 5 */
6 6  
7 7 use common\models\Settings;
8   - use artbox\gentelella\widgets\XPanel;
9 8 use yii\bootstrap\ActiveForm;
10 9 use yii\bootstrap\Html;
11 10 use yii\bootstrap\Tabs;
12 11 use yii\web\View;
  12 + use yiister\gentelella\widgets\Panel;
13 13  
14 14 $this->title = 'Settings';
15 15  
16 16 $this->params[ 'breadcrumbs' ][] = $this->title;
17 17 ?>
18 18  
19   -<?php $panel = XPanel::begin(
  19 +<?php $panel = Panel::begin(
20 20 [
21   - 'title' => $this->title,
22   - 'toolbar' => false,
  21 + 'header' => $this->title,
23 22 ]
24 23 ); ?>
25 24  
... ...
backend/views/site/analytics.php
... ... @@ -7,233 +7,230 @@
7 7 * @var array $countries
8 8 */
9 9  
10   - use artbox\gentelella\widgets\XPanel;
11 10 use speixoto\amcharts\Widget;
12 11 use yii\bootstrap\Tabs;
13 12 use yii\web\View;
  13 + use yiister\gentelella\widgets\Panel;
14 14  
15 15 ?>
16 16  
17 17 <div class="row">
18   - <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
19   - <div class="tile-stats">
20   - <div class="icon"><i class="fa fa-clock-o"></i>
21   - </div>
22   - <div class="count"><?= $data[ 'sessions' ] ?></div>
23   -
24   - <h3>Sessions</h3>
25   - <p>Lorem ipsum psdea itgum rixt.</p>
  18 + <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
  19 + <div class="tile-stats">
  20 + <div class="icon"><i class="fa fa-clock-o"></i>
  21 + </div>
  22 + <div class="count"><?= $data[ 'sessions' ] ?></div>
  23 +
  24 + <h3>Sessions</h3>
  25 + <p>Lorem ipsum psdea itgum rixt.</p>
  26 + </div>
26 27 </div>
27   - </div>
28   - <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
29   - <div class="tile-stats">
30   - <div class="icon"><i class="fa fa-user"></i>
31   - </div>
32   - <div class="count"><?= $data[ 'users' ] ?></div>
33   -
34   - <h3>Users</h3>
35   - <p>Lorem ipsum psdea itgum rixt.</p>
  28 + <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
  29 + <div class="tile-stats">
  30 + <div class="icon"><i class="fa fa-user"></i>
  31 + </div>
  32 + <div class="count"><?= $data[ 'users' ] ?></div>
  33 +
  34 + <h3>Users</h3>
  35 + <p>Lorem ipsum psdea itgum rixt.</p>
  36 + </div>
36 37 </div>
37   - </div>
38   - <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
39   - <div class="tile-stats">
40   - <div class="icon"><i class="fa fa-eye"></i>
41   - </div>
42   - <div class="count"><?= $data[ 'views' ] ?></div>
43   -
44   - <h3>Page views</h3>
45   - <p>Lorem ipsum psdea itgum rixt.</p>
  38 + <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
  39 + <div class="tile-stats">
  40 + <div class="icon"><i class="fa fa-eye"></i>
  41 + </div>
  42 + <div class="count"><?= $data[ 'views' ] ?></div>
  43 +
  44 + <h3>Page views</h3>
  45 + <p>Lorem ipsum psdea itgum rixt.</p>
  46 + </div>
46 47 </div>
47   - </div>
48   - <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
49   - <div class="tile-stats">
50   - <div class="icon"><i class="fa fa-plus"></i>
51   - </div>
52   - <div class="count"><?= round(intval($data[ 'new' ]), 2) ?> %</div>
53   -
54   - <h3>New sessions</h3>
55   - <p>Lorem ipsum psdea itgum rixt.</p>
  48 + <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
  49 + <div class="tile-stats">
  50 + <div class="icon"><i class="fa fa-plus"></i>
  51 + </div>
  52 + <div class="count"><?= round(intval($data[ 'new' ]), 2) ?> %</div>
  53 +
  54 + <h3>New sessions</h3>
  55 + <p>Lorem ipsum psdea itgum rixt.</p>
  56 + </div>
56 57 </div>
57   - </div>
58 58 </div>
59 59  
60 60 <div class="row">
61   - <div class="col-md-12">
62   - <?php $panel = XPanel::begin(
63   - [
64   - 'title' => 'Analytics',
65   - 'toolbarLayout' => false,
66   - ]
67   - ); ?>
68   -
69   - <?php
70   - $chartConfiguration = [
71   - 'type' => 'serial',
72   - 'dataProvider' => $data[ 'plot' ],
73   - 'categoryField' => 'day',
74   - 'categoryAxis' => [
75   - 'labelFrequency' => 5,
76   - ],
77   - 'graphs' => [
78   - [
79   - "balloon" => [
80   - "drop" => true,
81   - "adjustBorderColor" => false,
82   - "color" => "#ffffff",
83   - ],
84   - "bullet" => "round",
85   - "bulletBorderAlpha" => 1,
86   - "bulletColor" => "#FFFFFF",
87   - "bulletSize" => 5,
88   - "hideBulletsCount" => 50,
89   - "lineThickness" => 2,
90   - "title" => "red line",
91   - "useLineColorForBulletBorder" => true,
92   - "valueField" => "users",
93   - "balloonText" => "<span style='font-size:18px;'>Users: [[users]]</span>",
94   - "lineColor" => '#9ABCC3',
95   - ],
96   - [
97   - "balloon" => [
98   - "drop" => true,
99   - "adjustBorderColor" => false,
100   - "color" => "#ffffff",
101   - ],
102   - "bullet" => "round",
103   - "bulletBorderAlpha" => 1,
104   - "bulletColor" => "#FFFFFF",
105   - "bulletSize" => 5,
106   - "hideBulletsCount" => 50,
107   - "lineThickness" => 2,
108   - "title" => "red line",
109   - "useLineColorForBulletBorder" => true,
110   - "valueField" => "sessions",
111   - "balloonText" => "<span style='font-size:18px;'>Sessions: [[sessions]]</span>",
112   - "lineColor" => '#A8E3D6',
113   - ],
114   - ],
115   - 'chartCursor' => [
116   - "pan" => true,
117   - "valueLineEnabled" => true,
118   - "valueLineBalloonEnabled" => true,
119   - "cursorAlpha" => 1,
120   - "cursorColor" => "#1ABB9C",
121   - "limitToGraph" => "g1",
122   - "valueLineAlpha" => 0.2,
123   - "valueZoomable" => true,
124   - ],
125   - ];
  61 + <div class="col-md-12">
  62 + <?php $panel = Panel::begin(
  63 + [
  64 + 'header' => 'Analytics',
  65 + ]
  66 + ); ?>
  67 +
  68 + <?php
  69 + $chartConfiguration = [
  70 + 'type' => 'serial',
  71 + 'dataProvider' => $data[ 'plot' ],
  72 + 'categoryField' => 'day',
  73 + 'categoryAxis' => [
  74 + 'labelFrequency' => 5,
  75 + ],
  76 + 'graphs' => [
  77 + [
  78 + "balloon" => [
  79 + "drop" => true,
  80 + "adjustBorderColor" => false,
  81 + "color" => "#ffffff",
  82 + ],
  83 + "bullet" => "round",
  84 + "bulletBorderAlpha" => 1,
  85 + "bulletColor" => "#FFFFFF",
  86 + "bulletSize" => 5,
  87 + "hideBulletsCount" => 50,
  88 + "lineThickness" => 2,
  89 + "title" => "red line",
  90 + "useLineColorForBulletBorder" => true,
  91 + "valueField" => "users",
  92 + "balloonText" => "<span style='font-size:18px;'>Users: [[users]]</span>",
  93 + "lineColor" => '#9ABCC3',
  94 + ],
  95 + [
  96 + "balloon" => [
  97 + "drop" => true,
  98 + "adjustBorderColor" => false,
  99 + "color" => "#ffffff",
  100 + ],
  101 + "bullet" => "round",
  102 + "bulletBorderAlpha" => 1,
  103 + "bulletColor" => "#FFFFFF",
  104 + "bulletSize" => 5,
  105 + "hideBulletsCount" => 50,
  106 + "lineThickness" => 2,
  107 + "title" => "red line",
  108 + "useLineColorForBulletBorder" => true,
  109 + "valueField" => "sessions",
  110 + "balloonText" => "<span style='font-size:18px;'>Sessions: [[sessions]]</span>",
  111 + "lineColor" => '#A8E3D6',
  112 + ],
  113 + ],
  114 + 'chartCursor' => [
  115 + "pan" => true,
  116 + "valueLineEnabled" => true,
  117 + "valueLineBalloonEnabled" => true,
  118 + "cursorAlpha" => 1,
  119 + "cursorColor" => "#1ABB9C",
  120 + "limitToGraph" => "g1",
  121 + "valueLineAlpha" => 0.2,
  122 + "valueZoomable" => true,
  123 + ],
  124 + ];
  125 +
  126 + echo Widget::widget(
  127 + [
  128 + 'chartConfiguration' => $chartConfiguration,
  129 + 'width' => '100%',
  130 + ]
  131 + );
  132 + ?>
  133 +
  134 + <?php $panel::end(); ?>
126 135  
127   - echo Widget::widget(
128   - [
129   - 'chartConfiguration' => $chartConfiguration,
130   - 'width' => '100%',
131   - ]
132   - );
133   - ?>
134   -
135   - <?php $panel::end(); ?>
136   -
137   - </div>
  136 + </div>
138 137 </div>
139 138  
140 139 <div class="row">
141   - <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
142   - <?php $panel = XPanel::begin(
143   - [
144   - 'title' => 'Analytics',
145   - 'toolbarLayout' => false,
146   - ]
147   - ); ?>
148   -
149   - <?php
150   - $chartConfiguration = [
151   - "type" => "pie",
152   - "titleField" => "category",
153   - "valueField" => "column-1",
154   - "dataProvider" => [
155   - [
156   - "category" => "New Visitor",
157   - "column-1" => round(intval($data[ 'new' ]), 2),
158   - ],
159   - [
160   - "category" => "Returning Visitor",
161   - "column-1" => 100 - round(intval($data[ 'new' ]), 2),
162   - ],
163   - ],
164   - "colors" => [
165   - "#A8E3D6",
166   - "#9ABCC3",
167   - ],
168   - ];
  140 + <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
  141 + <?php $panel = Panel::begin(
  142 + [
  143 + 'header' => 'Analytics',
  144 + ]
  145 + ); ?>
  146 +
  147 + <?php
  148 + $chartConfiguration = [
  149 + "type" => "pie",
  150 + "titleField" => "category",
  151 + "valueField" => "column-1",
  152 + "dataProvider" => [
  153 + [
  154 + "category" => "New Visitor",
  155 + "column-1" => round(intval($data[ 'new' ]), 2),
  156 + ],
  157 + [
  158 + "category" => "Returning Visitor",
  159 + "column-1" => 100 - round(intval($data[ 'new' ]), 2),
  160 + ],
  161 + ],
  162 + "colors" => [
  163 + "#A8E3D6",
  164 + "#9ABCC3",
  165 + ],
  166 + ];
  167 +
  168 + echo Widget::widget(
  169 + [
  170 + 'chartConfiguration' => $chartConfiguration,
  171 + 'width' => '100%',
  172 + ]
  173 + );
  174 + ?>
  175 +
  176 + <?php $panel::end(); ?>
  177 + </div>
169 178  
170   - echo Widget::widget(
171   - [
172   - 'chartConfiguration' => $chartConfiguration,
173   - 'width' => '100%',
174   - ]
175   - );
176   - ?>
177   -
178   - <?php $panel::end(); ?>
179   - </div>
180   -
181   - <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
182   -
183   - <?php $panel = XPanel::begin(
184   - [
185   - 'title' => 'Analytics',
186   - 'toolbarLayout' => false,
187   - ]
188   - ); ?>
189   -
190   - <?php
191   - echo Tabs::widget(
192   - [
193   - 'options' => [
194   - 'class' => 'bar_tabs',
195   - ],
196   - 'items' => [
197   - [
198   - 'label' => 'Browsers',
199   - 'content' => $this->render(
200   - '_table',
201   - [
202   - 'data' => $browsers,
203   - 'name' => 'Browser',
204   - ]
205   - ),
206   - 'active' => true,
207   - ],
208   - [
209   - 'label' => 'Cities',
210   - 'content' => $this->render(
211   - '_table',
212   - [
213   - 'data' => $cityes,
214   - 'name' => 'City',
215   - ]
216   - ),
217   - ],
218   - [
219   - 'label' => 'Countries',
220   - 'content' => $this->render(
221   - '_table',
222   - [
223   - 'data' => $countries,
224   - 'name' => 'Country',
225   - ]
226   - ),
227   - ],
228   - ],
229   - ]
230   - );
231   -
232   - ?>
233   -
234   - <?php $panel::end(); ?>
235   -
236   - </div>
  179 + <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
  180 +
  181 + <?php $panel = Panel::begin(
  182 + [
  183 + 'header' => 'Analytics',
  184 + ]
  185 + ); ?>
  186 +
  187 + <?php
  188 + echo Tabs::widget(
  189 + [
  190 + 'options' => [
  191 + 'class' => 'bar_tabs',
  192 + ],
  193 + 'items' => [
  194 + [
  195 + 'label' => 'Browsers',
  196 + 'content' => $this->render(
  197 + '_table',
  198 + [
  199 + 'data' => $browsers,
  200 + 'name' => 'Browser',
  201 + ]
  202 + ),
  203 + 'active' => true,
  204 + ],
  205 + [
  206 + 'label' => 'Cities',
  207 + 'content' => $this->render(
  208 + '_table',
  209 + [
  210 + 'data' => $cityes,
  211 + 'name' => 'City',
  212 + ]
  213 + ),
  214 + ],
  215 + [
  216 + 'label' => 'Countries',
  217 + 'content' => $this->render(
  218 + '_table',
  219 + [
  220 + 'data' => $countries,
  221 + 'name' => 'Country',
  222 + ]
  223 + ),
  224 + ],
  225 + ],
  226 + ]
  227 + );
  228 +
  229 + ?>
  230 +
  231 + <?php $panel::end(); ?>
  232 +
  233 + </div>
237 234  
238 235 </div>
239 236  
... ...
backend/views/site/index.php
... ... @@ -4,19 +4,18 @@
4 4 * @var View $this
5 5 */
6 6  
7   - use artbox\gentelella\widgets\XPanel;
8 7 use backend\assets\AnalyticsAsset;
9 8 use yii\web\View;
  9 + use yiister\gentelella\widgets\Panel;
10 10  
11 11 $this->title = 'Artbox !';
12 12  
13 13 AnalyticsAsset::register($this);
14 14 ?>
15 15  
16   -<?php $panel = XPanel::begin(
  16 +<?php $panel = Panel::begin(
17 17 [
18   - 'title' => 'Hello!',
19   - 'toolbar' => false,
  18 + 'header' => 'Hello!',
20 19 ]
21 20 ); ?>
22 21  
... ...
backend/views/sitemap/index.php
1 1 <?php
2   - use artbox\gentelella\widgets\XPanel;
3 2 use common\components\Sitemap;
4 3 use yii\bootstrap\Html;
5 4 use yii\web\View;
  5 + use yiister\gentelella\widgets\Panel;
6 6  
7 7 /**
8 8 * @var View $this
... ... @@ -16,12 +16,11 @@
16 16 ?>
17 17 <div class="sitemap-main">
18 18 <?php
19   - $xPanel = XPanel::begin(
  19 + $xPanel = Panel::begin(
20 20 [
21   - 'toolbar' => false,
22   - 'title' => $this->title,
  21 + 'header' => $this->title,
23 22 'options' => [
24   - 'class' => 'sitemap-buttons',
  23 + 'class' => 'x_panel sitemap-buttons',
25 24 ],
26 25 ]
27 26 );
... ...
backend/views/sitemap/update.php
1 1 <?php
2 2 use common\models\SitemapDynamic;
3 3 use common\models\SitemapStatic;
4   - use artbox\gentelella\widgets\XPanel;
5 4 use yii\bootstrap\ActiveForm;
6 5 use yii\bootstrap\Html;
7 6 use yii\helpers\Url;
8 7 use yii\web\View;
  8 + use yiister\gentelella\widgets\Panel;
9 9  
10 10 /**
11 11 * @var View $this
... ... @@ -19,12 +19,12 @@
19 19 $this->title = \Yii::t('core', 'Update sitemap');
20 20 $this->params[ 'breadcrumbs' ][] = $this->title;
21 21 $form = ActiveForm::begin();
22   - $xPanel = XPanel::begin(
  22 + $xPanel = Panel::begin(
23 23 [
24   - 'title' => \Yii::t('core', 'Static pages'),
25   - 'toolbarLayout' => '{collapse}',
26   - 'options' => [
27   - 'class' => 'dynamic_fields',
  24 + 'header' => \Yii::t('core', 'Static pages'),
  25 + 'collapsable' => true,
  26 + 'options' => [
  27 + 'class' => 'x_panel dynamic_fields',
28 28 ],
29 29 ]
30 30 );
... ... @@ -91,10 +91,10 @@
91 91 ]
92 92 );
93 93 $xPanel::end();
94   - $xPanel2 = XPanel::begin(
  94 + $xPanel2 = Panel::begin(
95 95 [
96   - 'title' => \Yii::t('core', 'Dynamic pages'),
97   - 'toolbarLayout' => '{collapse}',
  96 + 'header' => \Yii::t('core', 'Dynamic pages'),
  97 + 'collapsable' => true,
98 98 ]
99 99 );
100 100 ?>
... ...
common/config/bootstrap.php
... ... @@ -3,4 +3,7 @@
3 3 Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
4 4 Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
5 5 Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
6   - Yii::setAlias('@storage', dirname(dirname(__DIR__)) . '/storage');
7 6 \ No newline at end of file
  7 + Yii::setAlias('@storage', dirname(dirname(__DIR__)) . '/storage');
  8 + if (!Yii::getAlias('@artbox/core', false)) {
  9 + Yii::setAlias('@artbox/core', dirname(dirname(__DIR__)) . '/artweb/artbox-core');
  10 + }
8 11 \ No newline at end of file
... ...
common/config/settings.php
... ... @@ -19,7 +19,7 @@
19 19 'google' => '',
20 20 'twitter' => '',
21 21 'name' => '',
22   - 'logo' => '',
  22 + 'logo' => null,
23 23 'about' => '',
24 24 'analytics_key' => '',
25 25 'robots' => '',
... ...
composer.json
... ... @@ -18,8 +18,6 @@
18 18 "minimum-stability": "stable",
19 19 "require": {
20 20 "php": ">=7.0",
21   - "artweb/artbox-core": "~0.0.1",
22   - "artweb/artbox-gentelella": "~0.0.1",
23 21 "yiisoft/yii2": "~2.0",
24 22 "yiisoft/yii2-bootstrap": "~2.0",
25 23 "yiisoft/yii2-swiftmailer": "~2.0",
... ... @@ -58,5 +56,11 @@
58 56 "type": "vcs",
59 57 "url": "git@gitlab.artweb.com.ua:yarik.nechyporuk/artbox-gentelella.git"
60 58 }
61   - ]
  59 + ],
  60 + "autoload": {
  61 + "psr-4": {
  62 + "artbox\\core\\": "artweb/artbox-core/",
  63 + "artbox\\gentelella\\": "artweb/artbox-gentelella/"
  64 + }
  65 + }
62 66 }
... ...
frontend/models/ContactForm.php deleted
1   -<?php
2   -
3   - namespace frontend\models;
4   -
5   - use Yii;
6   - use yii\base\Model;
7   -
8   - /**
9   - * ContactForm is the model behind the contact form.
10   - */
11   - class ContactForm extends Model
12   - {
13   - public $name;
14   - public $email;
15   - public $subject;
16   - public $body;
17   - public $verifyCode;
18   -
19   - /**
20   - * @inheritdoc
21   - */
22   - public function rules()
23   - {
24   - return [
25   - // name, email, subject and body are required
26   - [
27   - [
28   - 'name',
29   - 'email',
30   - 'subject',
31   - 'body',
32   - ],
33   - 'required',
34   - ],
35   - // email has to be a valid email address
36   - [
37   - 'email',
38   - 'email',
39   - ],
40   - // verifyCode needs to be entered correctly
41   - [
42   - 'verifyCode',
43   - 'captcha',
44   - ],
45   - ];
46   - }
47   -
48   - /**
49   - * @inheritdoc
50   - */
51   - public function attributeLabels()
52   - {
53   - return [
54   - 'verifyCode' => 'Verification Code',
55   - ];
56   - }
57   -
58   - /**
59   - * Sends an email to the specified email address using the information collected by this model.
60   - *
61   - * @param string $email the target email address
62   - *
63   - * @return bool whether the email was sent
64   - */
65   - public function sendEmail($email)
66   - {
67   - return Yii::$app->mailer->compose()
68   - ->setTo($email)
69   - ->setFrom([ $this->email => $this->name ])
70   - ->setSubject($this->subject)
71   - ->setTextBody($this->body)
72   - ->send();
73   - }
74   - }
frontend/models/PasswordResetRequestForm.php deleted
1   -<?php
2   - namespace frontend\models;
3   -
4   - use Yii;
5   - use yii\base\Model;
6   - use common\models\User;
7   -
8   - /**
9   - * Password reset request form
10   - */
11   - class PasswordResetRequestForm extends Model
12   - {
13   - public $email;
14   -
15   - /**
16   - * @inheritdoc
17   - */
18   - public function rules()
19   - {
20   - return [
21   - [
22   - 'email',
23   - 'trim',
24   - ],
25   - [
26   - 'email',
27   - 'required',
28   - ],
29   - [
30   - 'email',
31   - 'email',
32   - ],
33   - [
34   - 'email',
35   - 'exist',
36   - 'targetClass' => '\common\models\User',
37   - 'filter' => [ 'status' => User::STATUS_ACTIVE ],
38   - 'message' => 'There is no user with this email address.',
39   - ],
40   - ];
41   - }
42   -
43   - /**
44   - * Sends an email with a link, for resetting the password.
45   - *
46   - * @return bool whether the email was send
47   - */
48   - public function sendEmail()
49   - {
50   - /* @var $user User */
51   - $user = User::findOne(
52   - [
53   - 'status' => User::STATUS_ACTIVE,
54   - 'email' => $this->email,
55   - ]
56   - );
57   -
58   - if (!$user) {
59   - return false;
60   - }
61   -
62   - if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
63   - $user->generatePasswordResetToken();
64   - if (!$user->save()) {
65   - return false;
66   - }
67   - }
68   -
69   - return Yii::$app->mailer->compose(
70   - [
71   - 'html' => 'passwordResetToken-html',
72   - 'text' => 'passwordResetToken-text',
73   - ],
74   - [ 'user' => $user ]
75   - )
76   - ->setFrom([ Yii::$app->params[ 'supportEmail' ] => Yii::$app->name . ' robot' ])
77   - ->setTo($this->email)
78   - ->setSubject('Password reset for ' . Yii::$app->name)
79   - ->send();
80   - }
81   - }
frontend/models/ResetPasswordForm.php deleted
1   -<?php
2   - namespace frontend\models;
3   -
4   - use yii\base\Model;
5   - use yii\base\InvalidParamException;
6   - use common\models\User;
7   -
8   - /**
9   - * Password reset form
10   - */
11   - class ResetPasswordForm extends Model
12   - {
13   - public $password;
14   -
15   - /**
16   - * @var \common\models\User
17   - */
18   - private $_user;
19   -
20   - /**
21   - * Creates a form model given a token.
22   - *
23   - * @param string $token
24   - * @param array $config name-value pairs that will be used to initialize the object properties
25   - *
26   - * @throws \yii\base\InvalidParamException if token is empty or not valid
27   - */
28   - public function __construct($token, $config = [])
29   - {
30   - if (empty( $token ) || !is_string($token)) {
31   - throw new InvalidParamException('Password reset token cannot be blank.');
32   - }
33   - $this->_user = User::findByPasswordResetToken($token);
34   - if (!$this->_user) {
35   - throw new InvalidParamException('Wrong password reset token.');
36   - }
37   - parent::__construct($config);
38   - }
39   -
40   - /**
41   - * @inheritdoc
42   - */
43   - public function rules()
44   - {
45   - return [
46   - [
47   - 'password',
48   - 'required',
49   - ],
50   - [
51   - 'password',
52   - 'string',
53   - 'min' => 6,
54   - ],
55   - ];
56   - }
57   -
58   - /**
59   - * Resets password.
60   - *
61   - * @return bool if password was reset.
62   - */
63   - public function resetPassword()
64   - {
65   - $user = $this->_user;
66   - $user->setPassword($this->password);
67   - $user->removePasswordResetToken();
68   -
69   - return $user->save(false);
70   - }
71   - }
frontend/models/SignupForm.php deleted
1   -<?php
2   - namespace frontend\models;
3   -
4   - use yii\base\Model;
5   - use common\models\User;
6   -
7   - /**
8   - * Signup form
9   - */
10   - class SignupForm extends Model
11   - {
12   - public $username;
13   - public $email;
14   - public $password;
15   -
16   - /**
17   - * @inheritdoc
18   - */
19   - public function rules()
20   - {
21   - return [
22   - [
23   - 'username',
24   - 'trim',
25   - ],
26   - [
27   - 'username',
28   - 'required',
29   - ],
30   - [
31   - 'username',
32   - 'unique',
33   - 'targetClass' => '\common\models\User',
34   - 'message' => 'This username has already been taken.',
35   - ],
36   - [
37   - 'username',
38   - 'string',
39   - 'min' => 2,
40   - 'max' => 255,
41   - ],
42   -
43   - [
44   - 'email',
45   - 'trim',
46   - ],
47   - [
48   - 'email',
49   - 'required',
50   - ],
51   - [
52   - 'email',
53   - 'email',
54   - ],
55   - [
56   - 'email',
57   - 'string',
58   - 'max' => 255,
59   - ],
60   - [
61   - 'email',
62   - 'unique',
63   - 'targetClass' => '\common\models\User',
64   - 'message' => 'This email address has already been taken.',
65   - ],
66   -
67   - [
68   - 'password',
69   - 'required',
70   - ],
71   - [
72   - 'password',
73   - 'string',
74   - 'min' => 6,
75   - ],
76   - ];
77   - }
78   -
79   - /**
80   - * Signs user up.
81   - *
82   - * @return User|null the saved model or null if saving fails
83   - */
84   - public function signup()
85   - {
86   - if (!$this->validate()) {
87   - return null;
88   - }
89   -
90   - $user = new User();
91   - $user->username = $this->username;
92   - $user->email = $this->email;
93   - $user->setPassword($this->password);
94   - $user->generateAuthKey();
95   -
96   - return $user->save() ? $user : null;
97   - }
98   - }