| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Craft Contact Form Extensions plugin for Craft CMS 3.x. |
||
| 4 | * |
||
| 5 | * Adds extensions to the Craft CMS contact form plugin. |
||
| 6 | * |
||
| 7 | * @link https://rias.be |
||
| 8 | * |
||
| 9 | * @copyright Copyright (c) 2018 Rias |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace rias\contactformextensions\models; |
||
| 13 | |||
| 14 | use Craft; |
||
| 15 | use craft\base\Model; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * CraftContactFormExtensions Settings Model. |
||
| 19 | * |
||
| 20 | * This is a model used to define the plugin's settings. |
||
| 21 | * |
||
| 22 | * Models are containers for data. Just about every time information is passed |
||
| 23 | * between services, controllers, and templates in Craft, it’s passed via a model. |
||
| 24 | * |
||
| 25 | * https://craftcms.com/docs/plugins/models |
||
| 26 | * |
||
| 27 | * @author Rias |
||
| 28 | * |
||
| 29 | * @since 1.0.0 |
||
| 30 | */ |
||
| 31 | class Settings extends Model |
||
| 32 | { |
||
| 33 | // Public Properties |
||
| 34 | // ========================================================================= |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var bool |
||
| 38 | */ |
||
| 39 | public $enableDatabase = true; |
||
| 40 | |||
| 41 | public $enableTemplateOverwrite = true; |
||
| 42 | public $enableConfirmationEmail = true; |
||
| 43 | public $notificationTemplate = ''; |
||
| 44 | public $confirmationTemplate = ''; |
||
| 45 | public $confirmationSubject = ''; |
||
| 46 | |||
| 47 | public $recaptcha = false; |
||
| 48 | public $recaptchaVersion = ''; |
||
| 49 | public $recaptchaSiteKey = ''; |
||
| 50 | public $recaptchaSecretKey = ''; |
||
| 51 | public $recaptchaHideBadge = false; |
||
| 52 | public $recaptchaDataBadge = 'bottomright'; |
||
| 53 | public $recaptchaTimeout = 5; |
||
| 54 | public $recaptchaDebug = false; |
||
| 55 | public $recaptchaThreshold = 0.5; |
||
| 56 | |||
| 57 | // Public Methods |
||
| 58 | // ========================================================================= |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | public function getConfirmationSubject(): string |
||
| 64 | { |
||
| 65 | if (is_array($this->confirmationSubject)) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 66 | return $this->confirmationSubject[Craft::$app->sites->currentSite->handle]; |
||
| 67 | } |
||
| 68 | |||
| 69 | return $this->confirmationSubject; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Returns the validation rules for attributes. |
||
| 74 | * |
||
| 75 | * Validation rules are used by [[validate()]] to check if attribute values are valid. |
||
| 76 | * Child classes may override this method to declare different validation rules. |
||
| 77 | * |
||
| 78 | * More info: http://www.yiiframework.com/doc-2.0/guide-input-validation.html |
||
| 79 | * |
||
| 80 | * @return array |
||
| 81 | */ |
||
| 82 | public function rules() |
||
| 83 | { |
||
| 84 | return [ |
||
| 85 | ['enableDatabase', 'boolean'], |
||
| 86 | ['enableTemplateOverwrite', 'boolean'], |
||
| 87 | ['enableConfirmationEmail', 'boolean'], |
||
| 88 | ['notificationTemplate', 'string'], |
||
| 89 | ['confirmationTemplate', 'string'], |
||
| 90 | ['confirmationSubject', 'string'], |
||
| 91 | ['recaptcha', 'boolean'], |
||
| 92 | ['recaptchaSiteKey', 'string'], |
||
| 93 | ['recaptchaSecretKey', 'string'], |
||
| 94 | ['recaptchaHideBadge', 'boolean'], |
||
| 95 | ['recaptchaDataBadge', 'string'], |
||
| 96 | ['recaptchaTimeout', 'integer'], |
||
| 97 | ['recaptchaThreshold', 'double', 'max' => 1, 'min' => 0], |
||
| 98 | ['recaptchaDebug', 'boolean'], |
||
| 99 | ]; |
||
| 100 | } |
||
| 101 | } |
||
| 102 |