From f1a1680e12cac265fa384eb5e2005a327b9aa780 Mon Sep 17 00:00:00 2001 From: Eugeny Galkovskiy Date: Thu, 27 Jul 2017 12:57:51 +0300 Subject: [PATCH] Форма сообщений --- common/config/settings.php | 10 +++++----- common/messages/ua/app.php | 12 +++++++++++- common/models/Feedback.php | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/layouts/main.php | 36 ++++++++++++------------------------ frontend/views/site/index.php | 1 + 5 files changed, 192 insertions(+), 30 deletions(-) create mode 100644 common/models/Feedback.php diff --git a/common/config/settings.php b/common/config/settings.php index 6cd934e..79a91ba 100644 --- a/common/config/settings.php +++ b/common/config/settings.php @@ -2,10 +2,10 @@ return [ 1 => [ - 'phone' => '+38 (044) 593-73-76', - 'phone2' => '+38 (098) 468-07-64', - 'skype' => 'artwebstudio', - 'email' => 'artweb.ua@gmail.com', + 'phone' => '+38 (068) 380-39-82', + 'phone2' => '', + 'skype' => '', + 'email' => 'zhegal@gmail.com', 'house' => '1-М', 'street' => 'пр. М. Бажана', 'office' => '25', @@ -20,7 +20,7 @@ return [ 'twitter' => '', 'name' => 'KB Energy', 'logo' => '1', - 'about' => '', + 'about' => 'Комплексний підхід до енергозбереження та енергонезалежності', 'analytics_key' => '119240817', 'robots' => 'User-agent: Google Disallow: diff --git a/common/messages/ua/app.php b/common/messages/ua/app.php index e3b6834..e32611a 100644 --- a/common/messages/ua/app.php +++ b/common/messages/ua/app.php @@ -1,2 +1,12 @@ 'ID', + 'name' => 'Ім\'я', + 'phone' => 'Телефон', + 'created_at' => 'Створено', + 'ip' => 'IP', + 'url' => 'URL', + 'status' => 'Статус', + 'message' => 'Повідомлення', + 'email' => 'Email', + ]; \ No newline at end of file diff --git a/common/models/Feedback.php b/common/models/Feedback.php new file mode 100644 index 0000000..6be03a2 --- /dev/null +++ b/common/models/Feedback.php @@ -0,0 +1,163 @@ + [ + 'title', + 'name', + 'email', + 'message', + ], + self::SCENARIO_CALLBACK => [ + 'title', + 'name', + 'phone', + 'message', + ], + ] + ); + return $scenarios; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::className(), + 'updatedAtAttribute' => false, + ], + [ + 'class' => AttributeBehavior::className(), + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => 'ip', + ], + 'value' => function ($event) { + return \Yii::$app->request->userIP; + }, + ], + [ + 'class' => AttributeBehavior::className(), + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => 'url', + ], + 'value' => function ($event) { + return \Yii::$app->request->referrer; + }, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'title', + 'phone', + 'name', + 'email', + ], + 'required', + ], + [ + [ 'email' ], + 'email', + ], + // [ + // [ 'phone' ], + // 'match', + // 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', + // ], + [ + [ + 'title', + 'name', + 'phone', + 'email', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'message', + ], + 'string', + ], + [ + [ + 'status', + ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'id'), + 'name' => Yii::t('app', 'name'), + 'phone' => Yii::t('app', 'phone'), + 'created_at' => Yii::t('app', 'created_at'), + 'ip' => Yii::t('app', 'ip'), + 'url' => Yii::t('app', 'url'), + 'status' => Yii::t('app', 'status'), + 'message' => Yii::t('app', 'message'), + 'email' => Yii::t('app', 'email'), + 'title' => Yii::t('app', 'title'), + ]; + } +} diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 4a7681b..c1a11fa 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -7,7 +7,7 @@ */ use artbox\core\components\SeoComponent; use artbox\core\helpers\ImageHelper; - use artbox\core\models\Feedback; + use common\models\Feedback; use artbox\core\models\Page; use artbox\core\models\User; use common\models\Settings; @@ -305,24 +305,20 @@ _________________________________________________________ --> [ 'items' => [ [ - 'label' => \Yii::t('app', 'Наші проекти'), - 'url' => [ '#' ], + 'label' => \Yii::t('app', 'Чому ми'), + 'url' => [ '#section1' ], ], [ - 'label' => \Yii::t('app', '10 кроків до енергонезалежності'), - 'url' => [ '#' ], - ], - [ - 'label' => \Yii::t('app', 'Чому обирають нас'), - 'url' => [ '#' ], + 'label' => \Yii::t('app', 'Наші проекти'), + 'url' => [ '#section2' ], ], [ - 'label' => \Yii::t('app', 'ЗМІ про нас'), - 'url' => [ '#' ], + 'label' => \Yii::t('app', '10 кроків до енергонезалежності'), + 'url' => [ '#section3' ], ], [ 'label' => \Yii::t('app', 'Контакти'), - 'url' => [ '#' ], + 'url' => [ '#section4' ], ], ], 'options' => [ @@ -371,7 +367,7 @@ _________________________________________________________ -->