From 0ae6f10931b5cc2eeb2303fa4e6a4cc66eb5567e Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2016 13:55:19 +0200 Subject: [PATCH] firs page --- common/config/main-local.php | 6 +++--- frontend/controllers/AccountsController.php | 61 ++----------------------------------------------------------- frontend/controllers/LandingController.php | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 62 deletions(-) create mode 100644 frontend/controllers/LandingController.php diff --git a/common/config/main-local.php b/common/config/main-local.php index fc2943b..f47e800 100644 --- a/common/config/main-local.php +++ b/common/config/main-local.php @@ -3,9 +3,9 @@ return [ 'components' => [ 'db' => [ 'class' => 'yii\db\Connection', - 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local', - 'username' => 'postgres', - 'password' => '', + 'dsn' => 'pgsql:host=195.248.225.149;port=5432;dbname=mfp', + 'username' => 'test33', + 'password' => 'E4q2N7i9', 'schemaMap' => [ 'pgsql'=> [ 'class'=>'yii\db\pgsql\Schema', diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 31949f4..6969f24 100644 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -2,9 +2,7 @@ namespace frontend\controllers; use Yii; -use common\models\Accounts; -use frontend\models\ChangePasswordForm; -use common\models\News; +use common\models\User; use yii\data\ActiveDataProvider; use yii\filters\AccessControl; use yii\web\Controller; @@ -17,9 +15,6 @@ use yii\web\NotFoundHttpException; class AccountsController extends Controller { - public $layout = '/internal'; - - public function behaviors() { return [ @@ -58,38 +53,13 @@ class AccountsController extends Controller } - public function actionIndex() - { - $dataProvider = new ActiveDataProvider([ - 'query' => News::find()->where(['is_active'=>1]), - 'pagination' => [ - 'pageSize' => 16, - ], - ]); - return $this->render('index',[ - 'dataProvider' => $dataProvider - ]); - } - public function actionView($translit) - { - - $activeNews = $this->findModel($translit); - $next_news = News::find()->where(['is_active'=>1])->andWhere('id > :id',[':id' => $activeNews->id])->one(); - $prev_news = News::find()->where(['is_active'=>1])->andWhere('id < :id',[':id' => $activeNews->id])->one(); - - return $this->render('view', [ - 'model' => $activeNews, - 'next_news' => $next_news instanceof News ? $next_news : '', - 'prev_news' => $prev_news instanceof News ? $prev_news : '' - ]); - } protected function findModel($id) { - if (($model = Accounts::findOne(["id"=>$id])) !== null) { + if (($model = User::findOne(["id"=>$id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); @@ -97,32 +67,5 @@ class AccountsController extends Controller } - public function actionChangePassword(){ - - - $form = new ChangePasswordForm(); - - - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - - $model = Accounts::findOne(Yii::$app->user->identity->id); - - $model->load(Yii::$app->request->post(), 'ChangePasswordForm'); - - $model->save(); - - return $this->redirect(['cabinet']); - - } else { - - return $this->render('change-password', [ - 'model' => $form - ]); - - } - } - - - } diff --git a/frontend/controllers/LandingController.php b/frontend/controllers/LandingController.php new file mode 100644 index 0000000..65cddb2 --- /dev/null +++ b/frontend/controllers/LandingController.php @@ -0,0 +1,19 @@ +render(); + } + +} \ No newline at end of file -- libgit2 0.21.4