Commit b6b226d0eec8763f920ce089a6cdba3c1eca45f7
1 parent
2e9ea16e
01.06.16
Showing
5 changed files
with
61 additions
and
65 deletions
Show diff stats
.htaccess
| @@ -81,21 +81,21 @@ AddDefaultCharset utf-8 | @@ -81,21 +81,21 @@ AddDefaultCharset utf-8 | ||
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | # кеширование в браузере на стороне пользователя | 83 | # кеширование в браузере на стороне пользователя |
| 84 | -#<IfModule mod_expires.c> | ||
| 85 | -#ExpiresActive On | ||
| 86 | -#ExpiresDefault "access 7 days" | ||
| 87 | -#ExpiresByType application/javascript "access plus 1 year" | ||
| 88 | -#ExpiresByType text/javascript "access plus 1 year" | ||
| 89 | -#ExpiresByType text/css "access plus 1 year" | ||
| 90 | -#ExpiresByType text/html "access plus 7 day" | ||
| 91 | -#ExpiresByType text/x-javascript "access 1 year" | ||
| 92 | -#ExpiresByType image/gif "access plus 1 year" | ||
| 93 | -#ExpiresByType image/jpeg "access plus 1 year" | ||
| 94 | -#ExpiresByType image/png "access plus 1 year" | ||
| 95 | -#ExpiresByType image/jpg "access plus 1 year" | ||
| 96 | -#ExpiresByType image/x-icon "access 1 year" | ||
| 97 | -#ExpiresByType application/x-shockwave-flash "access 1 year" | ||
| 98 | -#</IfModule> | 84 | +<IfModule mod_expires.c> |
| 85 | +ExpiresActive On | ||
| 86 | +ExpiresDefault "access 7 days" | ||
| 87 | +ExpiresByType application/javascript "access plus 1 year" | ||
| 88 | +ExpiresByType text/javascript "access plus 1 year" | ||
| 89 | +ExpiresByType text/css "access plus 1 year" | ||
| 90 | +ExpiresByType text/html "access plus 7 day" | ||
| 91 | +ExpiresByType text/x-javascript "access 1 year" | ||
| 92 | +ExpiresByType image/gif "access plus 1 year" | ||
| 93 | +ExpiresByType image/jpeg "access plus 1 year" | ||
| 94 | +ExpiresByType image/png "access plus 1 year" | ||
| 95 | +ExpiresByType image/jpg "access plus 1 year" | ||
| 96 | +ExpiresByType image/x-icon "access 1 year" | ||
| 97 | +ExpiresByType application/x-shockwave-flash "access 1 year" | ||
| 98 | +</IfModule> | ||
| 99 | 99 | ||
| 100 | <IfModule mod_deflate.c> | 100 | <IfModule mod_deflate.c> |
| 101 | AddOutputFilterByType DEFLATE text/plain | 101 | AddOutputFilterByType DEFLATE text/plain |
| @@ -117,25 +117,25 @@ RewriteCond %{HTTP:Accept-encoding} gzip | @@ -117,25 +117,25 @@ RewriteCond %{HTTP:Accept-encoding} gzip | ||
| 117 | RewriteCond %{REQUEST_FILENAME}.gz -f | 117 | RewriteCond %{REQUEST_FILENAME}.gz -f |
| 118 | RewriteRule ^(.*)$ $1.gz [QSA,L] | 118 | RewriteRule ^(.*)$ $1.gz [QSA,L] |
| 119 | </IfModule> | 119 | </IfModule> |
| 120 | -## Cache-Control | ||
| 121 | -#<ifModule mod_headers.c> | ||
| 122 | -## 30 дней | ||
| 123 | -#<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> | ||
| 124 | -#Header set Cache-Control "max-age=2592000, public" | ||
| 125 | -#</filesMatch> | ||
| 126 | -## 30 дней | ||
| 127 | -#<filesMatch "\.(css|js)$"> | ||
| 128 | -#Header set Cache-Control "max-age=2592000, public" | ||
| 129 | -#</filesMatch> | ||
| 130 | -## 2 дня | ||
| 131 | -#<filesMatch "\.(xml|txt)$"> | ||
| 132 | -#Header set Cache-Control "max-age=172800, public, must-revalidate" | ||
| 133 | -#</filesMatch> | ||
| 134 | -## 1 день | ||
| 135 | -#<filesMatch "\.(html|htm|php)$"> | ||
| 136 | -#Header set Cache-Control "max-age=172800, private, must-revalidate" | ||
| 137 | -#</filesMatch> | ||
| 138 | -#</ifModule> | 120 | +# Cache-Control |
| 121 | +<ifModule mod_headers.c> | ||
| 122 | +# 30 дней | ||
| 123 | +<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> | ||
| 124 | +Header set Cache-Control "max-age=2592000, public" | ||
| 125 | +</filesMatch> | ||
| 126 | +# 30 дней | ||
| 127 | +<filesMatch "\.(css|js)$"> | ||
| 128 | +Header set Cache-Control "max-age=2592000, public" | ||
| 129 | +</filesMatch> | ||
| 130 | +# 2 дня | ||
| 131 | +<filesMatch "\.(xml|txt)$"> | ||
| 132 | +Header set Cache-Control "max-age=172800, public, must-revalidate" | ||
| 133 | +</filesMatch> | ||
| 134 | +# 1 день | ||
| 135 | +<filesMatch "\.(html|htm|php)$"> | ||
| 136 | +Header set Cache-Control "max-age=172800, private, must-revalidate" | ||
| 137 | +</filesMatch> | ||
| 138 | +</ifModule> | ||
| 139 | 139 | ||
| 140 | #Запрет отдачи HTTP-заголовков Vary браузерам семейства MSIE | 140 | #Запрет отдачи HTTP-заголовков Vary браузерам семейства MSIE |
| 141 | <IfModule mod_setenvif.c> | 141 | <IfModule mod_setenvif.c> |
backend/controllers/UserController.php
| @@ -114,16 +114,22 @@ class UserController extends Controller | @@ -114,16 +114,22 @@ class UserController extends Controller | ||
| 114 | public function actionUpdate($id) | 114 | public function actionUpdate($id) |
| 115 | { | 115 | { |
| 116 | $model = $this->findModel($id); | 116 | $model = $this->findModel($id); |
| 117 | + if (Yii::$app->request->isAjax) { | ||
| 118 | + Yii::$app->response->format = Response::FORMAT_JSON; | ||
| 119 | + $model->load(Yii::$app->request->post()); | ||
| 120 | + return ActiveForm::validate($model); | ||
| 121 | + }else if ($model->load(Yii::$app->request->post()) && $model->validate()) { | ||
| 122 | + $model->save(); | ||
| 117 | 123 | ||
| 118 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 119 | - | ||
| 120 | - $auth = Yii::$app->authManager; | ||
| 121 | - $authorRole = $auth->getRole('author'); | ||
| 122 | - $auth->assign($authorRole, $model->id); | 124 | + foreach($model->role as $k => $role){ |
| 125 | + $auth = Yii::$app->authManager; | ||
| 126 | + $authorRole = $auth->getRole($role); | ||
| 127 | + $auth->assign($authorRole, $model->id); | ||
| 128 | + } | ||
| 123 | 129 | ||
| 124 | return $this->redirect(['view', 'id' => $model->id]); | 130 | return $this->redirect(['view', 'id' => $model->id]); |
| 125 | } else { | 131 | } else { |
| 126 | - return $this->render('update', [ | 132 | + return $this->render('create', [ |
| 127 | 'model' => $model, | 133 | 'model' => $model, |
| 128 | ]); | 134 | ]); |
| 129 | } | 135 | } |
common/widgets/Mailer.php
| @@ -19,18 +19,18 @@ class Mailer extends Widget{ | @@ -19,18 +19,18 @@ class Mailer extends Widget{ | ||
| 19 | 19 | ||
| 20 | public function run(){ | 20 | public function run(){ |
| 21 | 21 | ||
| 22 | -// $mail = new \PHPMailer(); | ||
| 23 | -// | ||
| 24 | -// $mail->IsSMTP(); | ||
| 25 | -// | ||
| 26 | -// $mail->CharSet = 'UTF-8'; | ||
| 27 | -// $mail->Username = "dockdep@gmail.com"; | ||
| 28 | -// $mail->Password = "k0l0b04eg@"; | ||
| 29 | -// $mail->SetFrom('dockdep@gmail.com'); | ||
| 30 | -// $mail->Subject = $this->subject; | ||
| 31 | -// $mail->MsgHTML('test'); | ||
| 32 | -// $address = "dockdep@gmail.com"; | ||
| 33 | -// $mail->AddAddress($address); | 22 | + $mail = new \PHPMailer(); |
| 23 | + | ||
| 24 | + $mail->IsSMTP(); | ||
| 25 | + | ||
| 26 | + $mail->CharSet = 'UTF-8'; | ||
| 27 | + $mail->Username = "dockdep@gmail.com"; | ||
| 28 | + $mail->Password = "k0l0b04eg@"; | ||
| 29 | + $mail->SetFrom('dockdep@gmail.com'); | ||
| 30 | + $mail->Subject = $this->subject; | ||
| 31 | + $mail->MsgHTML($this->render('test')); | ||
| 32 | + $address = "dockdep@gmail.com"; | ||
| 33 | + $mail->AddAddress($address); | ||
| 34 | // $mail->AddAddress($this->email); | 34 | // $mail->AddAddress($this->email); |
| 35 | // if(!$mail->send()) { | 35 | // if(!$mail->send()) { |
| 36 | // | 36 | // |
frontend/controllers/SiteController.php
| @@ -28,22 +28,11 @@ class SiteController extends Controller | @@ -28,22 +28,11 @@ class SiteController extends Controller | ||
| 28 | public function actionIndex() | 28 | public function actionIndex() |
| 29 | { | 29 | { |
| 30 | 30 | ||
| 31 | -// $catalogs = Catalog::find()->where(['parent_id'=>'0'])->all(); | ||
| 32 | $modelText = Page::find()->where(['translit'=>'home'])->one(); | 31 | $modelText = Page::find()->where(['translit'=>'home'])->one(); |
| 33 | -// $news = News::find()->orderBy('id DESC')->limit(4)->all(); | ||
| 34 | -// $products_new = Products::find()->where(['new'=>'1'])->orderBy('id DESC')->innerJoinWith(['cost'])->groupBy('id')->limit(4)->all(); | ||
| 35 | -// //print_r($products_new); | ||
| 36 | -// $products_top = Products::find()->where(['top'=>'1'])->orderBy('id DESC')->innerJoinWith(['cost'])->groupBy('id')->limit(4)->all(); | ||
| 37 | -// //print_r($products_top); | ||
| 38 | -// //$products_sale = Products::find()->where(['sale'=>'1'])->innerJoinWith(['cost'])->orderBy('id DESC')->limit(4)->all(); | ||
| 39 | -// $products_akciya = Products::find()->where(['akciya'=>'1'])->innerJoinWith(['cost'])->orderBy('id DESC')->limit(4)->all(); | 32 | + |
| 40 | return $this->render('index', [ | 33 | return $this->render('index', [ |
| 41 | 'text'=>$modelText, | 34 | 'text'=>$modelText, |
| 42 | -// 'catalogs'=>$catalogs, | ||
| 43 | -// 'news'=>$news, | ||
| 44 | -// 'products_new'=>$products_new, | ||
| 45 | -// 'products_top'=>$products_top, | ||
| 46 | -// 'products_akciya'=>$products_akciya, | 35 | + |
| 47 | ]); | 36 | ]); |
| 48 | } | 37 | } |
| 49 | 38 |