diff --git a/common/components/ImageManager.php b/common/components/ImageManager.php new file mode 100644 index 0000000..eb93139 --- /dev/null +++ b/common/components/ImageManager.php @@ -0,0 +1,52 @@ +mediaPath !== null) { + $sMediaPath = $this->mediaPath; + } + + $sFileExtension = pathinfo($mImageManager->fileName, PATHINFO_EXTENSION); + //get image file path + $sImageFilePath = $sMediaPath . '/' . $mImageManager->id . '_' . $mImageManager->fileHash . '.' . $sFileExtension; + //check file exists + if (file_exists($sImageFilePath)) { + $return = \Yii::$app->imageresize->getUrl( + $sImageFilePath, + $width, + $height, + $mode, + 100, + $mImageManager->fileName + ); + } else { + $return = null; //isset(\Yii::$app->controller->module->assetPublishedUrl) ? \Yii::$app->controller->module->assetPublishedUrl. "/img/img_no-image.png" : null; + } + } + return $return; + } +} \ No newline at end of file diff --git a/common/models/Order.php b/common/models/Order.php index a6d00c7..32e58ad 100644 --- a/common/models/Order.php +++ b/common/models/Order.php @@ -1,11 +1,9 @@ [ - 'product', - 'name', - 'email', - 'message', - ], - self::SCENARIO_CALLBACK => [ - 'product', - 'name', - 'phone', - 'message', - 'returnUrl', - ], - ] - ); - 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 [ + return array_merge(parent::rules(), [ [ - [ - 'product', - 'phone', - 'name', - 'email', - ], - 'required', - ], - [ - [ 'email' ], - 'email', - ], - // [ - // [ 'phone' ], - // 'match', - // 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', - // ], - [ - [ - 'product', - 'name', - 'phone', - 'email', - ], - 'string', - 'max' => 255, - ], - [ - [ - 'message', - 'returnUrl,', - ], - 'string', - ], - [ - [ - 'status', - ], - 'boolean', - ], - ]; + ['subject'], + 'string' + ] + ]); } - /** - * @inheritdoc - */ - public function attributeLabels() + public function scenarios() { - return [ - 'product' => Yii::t('core', 'product'), - 'id' => Yii::t('core', 'id'), - 'name' => Yii::t('core', 'name'), - 'phone' => Yii::t('core', 'phone'), - 'created_at' => Yii::t('core', 'created_at'), - 'ip' => Yii::t('core', 'ip'), - 'url' => Yii::t('core', 'url'), - 'status' => Yii::t('core', 'status'), - 'message' => Yii::t('core', 'message'), - 'email' => Yii::t('core', 'email'), - ]; + return []; } } diff --git a/composer.json b/composer.json index 32764c0..5ed9553 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "minimum-stability": "stable", "require": { "php": ">=7.0", - "artweb/artbox-core": "~0.0.1", + "artweb/artbox-core": "@dev", "yiisoft/yii2": "~2.0", "yiisoft/yii2-bootstrap": "~2.0", "yiisoft/yii2-swiftmailer": "~2.0", diff --git a/composer.lock b/composer.lock index 4702236..b62cdc2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "1ad205bd41e4dfbc52bad09c7e6c1677", + "content-hash": "497cd4fa2109f53680f63a074ef3c552", "packages": [ { "name": "2amigos/yii2-tinymce-widget", @@ -68,11 +68,11 @@ }, { "name": "artweb/artbox-core", - "version": "v0.0.8-stable", + "version": "dev-master", "source": { "type": "git", "url": "git@gitlab.artweb.com.ua:yarik.nechyporuk/artbox-core.git", - "reference": "becbaf610b959abbe6693a4b62b6933c3574cb1a" + "reference": "d80f6a3ae32b635fdeb8850f68867a494f59f5d8" }, "require": { "2amigos/yii2-tinymce-widget": "~1.0", @@ -95,7 +95,7 @@ "BSD-3-Clause" ], "description": "Artbox core extension", - "time": "2017-06-23T12:25:08+00:00" + "time": "2017-07-07 12:33:25" }, { "name": "bower-asset/amcharts", @@ -154,7 +154,7 @@ "shasum": "" }, "require": { - "bower-asset/jquery": ">=1.9.1,<=3" + "bower-asset/jquery": ">=1.9.1,<4.0" }, "type": "bower-asset-library", "extra": { @@ -2422,16 +2422,16 @@ }, { "name": "yiister/yii2-gentelella", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/yiister/yii2-gentelella.git", - "reference": "646ae0053c4a485d6b3d42c4ef67cbee26d74ef7" + "reference": "ec02c7e89363ee2f2c074588f3f13d3751fea1b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiister/yii2-gentelella/zipball/646ae0053c4a485d6b3d42c4ef67cbee26d74ef7", - "reference": "646ae0053c4a485d6b3d42c4ef67cbee26d74ef7", + "url": "https://api.github.com/repos/yiister/yii2-gentelella/zipball/ec02c7e89363ee2f2c074588f3f13d3751fea1b5", + "reference": "ec02c7e89363ee2f2c074588f3f13d3751fea1b5", "shasum": "" }, "require": { @@ -2476,7 +2476,7 @@ "theme", "yii2" ], - "time": "2017-05-22T11:24:30+00:00" + "time": "2017-07-04T05:05:27+00:00" } ], "packages-dev": [ @@ -3439,16 +3439,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.2.2", + "version": "6.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e" + "reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f2786490399836d2a544a34785c4a8d3ab32cf0e", - "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fa5711d0559fc4b64deba0702be52d41434cbcb7", + "reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7", "shasum": "" }, "require": { @@ -3519,20 +3519,20 @@ "testing", "xunit" ], - "time": "2017-06-13T14:07:07+00:00" + "time": "2017-07-03T15:54:24+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "4.0.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "eabce450df194817a7d7e27e19013569a903a2bf" + "reference": "d8833b396dce9162bb2eb5d59aee5a3ab3cfa5b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/eabce450df194817a7d7e27e19013569a903a2bf", - "reference": "eabce450df194817a7d7e27e19013569a903a2bf", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/d8833b396dce9162bb2eb5d59aee5a3ab3cfa5b4", + "reference": "d8833b396dce9162bb2eb5d59aee5a3ab3cfa5b4", "shasum": "" }, "require": { @@ -3578,7 +3578,7 @@ "mock", "xunit" ], - "time": "2017-03-03T06:30:20+00:00" + "time": "2017-06-30T08:15:21+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -3743,16 +3743,16 @@ }, { "name": "sebastian/environment", - "version": "3.0.4", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "74776f8dbc081cab9287c2a601c0c1d842568744" + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/74776f8dbc081cab9287c2a601c0c1d842568744", - "reference": "74776f8dbc081cab9287c2a601c0c1d842568744", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { @@ -3764,7 +3764,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -3789,7 +3789,7 @@ "environment", "hhvm" ], - "time": "2017-06-20T16:25:05+00:00" + "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", @@ -4186,16 +4186,16 @@ }, { "name": "symfony/browser-kit", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "c2c8ceb1aa9dab9eae54e9150e6a588ce3e53be1" + "reference": "3a4435e79a8401746e8525e98039199d0924b4e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/c2c8ceb1aa9dab9eae54e9150e6a588ce3e53be1", - "reference": "c2c8ceb1aa9dab9eae54e9150e6a588ce3e53be1", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/3a4435e79a8401746e8525e98039199d0924b4e5", + "reference": "3a4435e79a8401746e8525e98039199d0924b4e5", "shasum": "" }, "require": { @@ -4239,20 +4239,20 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2017-04-12T14:14:56+00:00" + "time": "2017-06-24T09:29:48+00:00" }, { "name": "symfony/console", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e" + "reference": "a97e45d98c59510f085fa05225a1acb74dfe0546" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/70d2a29b2911cbdc91a7e268046c395278238b2e", - "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e", + "url": "https://api.github.com/repos/symfony/console/zipball/a97e45d98c59510f085fa05225a1acb74dfe0546", + "reference": "a97e45d98c59510f085fa05225a1acb74dfe0546", "shasum": "" }, "require": { @@ -4308,11 +4308,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-06-02T19:24:58+00:00" + "time": "2017-07-03T13:19:36+00:00" }, { "name": "symfony/css-selector", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -4365,16 +4365,16 @@ }, { "name": "symfony/debug", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d" + "reference": "63b85a968486d95ff9542228dc2e4247f16f9743" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/e9c50482841ef696e8fa1470d950a79c8921f45d", - "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d", + "url": "https://api.github.com/repos/symfony/debug/zipball/63b85a968486d95ff9542228dc2e4247f16f9743", + "reference": "63b85a968486d95ff9542228dc2e4247f16f9743", "shasum": "" }, "require": { @@ -4417,11 +4417,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-06-01T21:01:25+00:00" + "time": "2017-07-05T13:02:37+00:00" }, { "name": "symfony/dom-crawler", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -4477,16 +4477,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4054a102470665451108f9b59305c79176ef98f0" + "reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4054a102470665451108f9b59305c79176ef98f0", - "reference": "4054a102470665451108f9b59305c79176ef98f0", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/67535f1e3fd662bdc68d7ba317c93eecd973617e", + "reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e", "shasum": "" }, "require": { @@ -4536,11 +4536,11 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-06-04T18:15:29+00:00" + "time": "2017-06-09T14:53:08+00:00" }, { "name": "symfony/finder", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -4648,16 +4648,16 @@ }, { "name": "symfony/yaml", - "version": "v3.3.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063" + "reference": "1f93a8d19b8241617f5074a123e282575b821df8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/9752a30000a8ca9f4b34b5227d15d0101b96b063", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063", + "url": "https://api.github.com/repos/symfony/yaml/zipball/1f93a8d19b8241617f5074a123e282575b821df8", + "reference": "1f93a8d19b8241617f5074a123e282575b821df8", "shasum": "" }, "require": { @@ -4699,7 +4699,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-06-02T22:05:06+00:00" + "time": "2017-06-15T12:58:50+00:00" }, { "name": "theseer/tokenizer", @@ -4942,6 +4942,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "artweb/artbox-core": 20, "bower-asset/amcharts-stock": 20, "kartik-v/yii2-widget-select2": 20 }, diff --git a/console/migrations/m170707_104149_add_subject_column_to_feedback_table.php b/console/migrations/m170707_104149_add_subject_column_to_feedback_table.php new file mode 100644 index 0000000..bcdaf61 --- /dev/null +++ b/console/migrations/m170707_104149_add_subject_column_to_feedback_table.php @@ -0,0 +1,25 @@ +addColumn('feedback', 'subject', $this->string()); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('feedback'); + } +} diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 3d07af4..9842a9c 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -2,6 +2,7 @@ namespace frontend\controllers; use artbox\core\models\Feedback; + use common\models\Order; use common\models\Settings; use Yii; use yii\web\BadRequestHttpException; @@ -104,33 +105,6 @@ if (empty( Yii::$app->request->post() )) { throw new BadRequestHttpException(); } else { - $model = new Feedback(); - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return [ - 'success' => true, - 'message' => 'Success message', - 'alert' => '
- Success text -
-