@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | public function attributeLabels() |
63 | 63 | { |
64 | 64 | return [ |
65 | - 'address'=>Yii::t('app','E-mail address'), |
|
66 | - 'isValid'=>Yii::t('app','Is valid?'), |
|
67 | - 'isValidRFC'=>Yii::t('app','In line with RFC standard?'), |
|
68 | - 'isNoRFCWarnings'=>Yii::t('app','No RFC warnings?'), |
|
69 | - 'isValidDNS'=>Yii::t('app','DNS check passed?'), |
|
70 | - 'needsTrimming'=>Yii::t('app','Has spaces to be trimmed?'), |
|
71 | - 'isValidSpoofCheck'=>Yii::t('app','Spoof check OK?'), |
|
65 | + 'address'=>Yii::t('app', 'E-mail address'), |
|
66 | + 'isValid'=>Yii::t('app', 'Is valid?'), |
|
67 | + 'isValidRFC'=>Yii::t('app', 'In line with RFC standard?'), |
|
68 | + 'isNoRFCWarnings'=>Yii::t('app', 'No RFC warnings?'), |
|
69 | + 'isValidDNS'=>Yii::t('app', 'DNS check passed?'), |
|
70 | + 'needsTrimming'=>Yii::t('app', 'Has spaces to be trimmed?'), |
|
71 | + 'isValidSpoofCheck'=>Yii::t('app', 'Spoof check OK?'), |
|
72 | 72 | |
73 | 73 | ]; |
74 | 74 | } |
@@ -78,23 +78,23 @@ discard block |
||
78 | 78 | * run the different validators |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - private function runValidator(){ |
|
81 | + private function runValidator() { |
|
82 | 82 | $this->isValidRFC = $this->validator->isValid($this->address, new RFCValidation()); |
83 | 83 | $this->isNoRFCWarnings = $this->validator->isValid($this->address, new NoRFCWarningsValidation()); |
84 | 84 | |
85 | - if($this->checkDNS){ |
|
85 | + if ($this->checkDNS) { |
|
86 | 86 | $this->isValidDNS = $this->validator->isValid($this->address, new DNSCheckValidation()); |
87 | 87 | } |
88 | 88 | |
89 | - if($this->checkSpoof) { |
|
89 | + if ($this->checkSpoof) { |
|
90 | 90 | $this->isValidSpoofCheck = $this->validator->isValid($this->address, new SpoofCheckValidation()); |
91 | 91 | } |
92 | 92 | |
93 | 93 | $this->setNeedsTrimming(); |
94 | - $this->isValid = ($this->isValidRFC && $this->isNoRFCWarnings && $this->isValidDNS && $this->isValidSpoofCheck ); |
|
94 | + $this->isValid = ($this->isValidRFC && $this->isNoRFCWarnings && $this->isValidDNS && $this->isValidSpoofCheck); |
|
95 | 95 | } |
96 | 96 | |
97 | - private function setNeedsTrimming(){ |
|
97 | + private function setNeedsTrimming() { |
|
98 | 98 | $this->needsTrimming = ($this->address !== trim($this->address)); |
99 | 99 | } |
100 | 100 |
@@ -44,40 +44,40 @@ discard block |
||
44 | 44 | return [ |
45 | 45 | [['textInput'], 'required'], |
46 | 46 | [['textInput'], 'string', 'max' => 1024 * $this->module->maxInputKB], |
47 | - [['checkDNS','checkSpoof','displayOnlyProblems'],'boolean'], |
|
47 | + [['checkDNS', 'checkSpoof', 'displayOnlyProblems'], 'boolean'], |
|
48 | 48 | ]; |
49 | 49 | } |
50 | 50 | |
51 | 51 | public function attributeLabels() |
52 | 52 | { |
53 | 53 | return [ |
54 | - 'textInput'=>Yii::t('app','E-mail addresses'), |
|
55 | - 'checkDNS'=>Yii::t('app','Perform DNS check'), |
|
56 | - 'checkSpoof'=>Yii::t('app','Perform spoofing check'), |
|
57 | - 'displayOnlyProblems'=>Yii::t('app','Display only e-mails with problems in results'), |
|
54 | + 'textInput'=>Yii::t('app', 'E-mail addresses'), |
|
55 | + 'checkDNS'=>Yii::t('app', 'Perform DNS check'), |
|
56 | + 'checkSpoof'=>Yii::t('app', 'Perform spoofing check'), |
|
57 | + 'displayOnlyProblems'=>Yii::t('app', 'Display only e-mails with problems in results'), |
|
58 | 58 | ]; |
59 | 59 | } |
60 | 60 | |
61 | 61 | public function attributeHints() |
62 | 62 | { |
63 | 63 | return [ |
64 | - 'textInput'=>Yii::t('app','One e-mail address per line'), |
|
65 | - 'checkDNS'=>Yii::t('app','Checking DNS will increase processing time'), |
|
64 | + 'textInput'=>Yii::t('app', 'One e-mail address per line'), |
|
65 | + 'checkDNS'=>Yii::t('app', 'Checking DNS will increase processing time'), |
|
66 | 66 | ]; |
67 | 67 | } |
68 | 68 | |
69 | - public function process(){ |
|
69 | + public function process() { |
|
70 | 70 | $this->loadEmailAddresses(); |
71 | 71 | return true; |
72 | 72 | } |
73 | 73 | |
74 | - private function loadEmailAddresses(){ |
|
75 | - if($this->textInput){ |
|
74 | + private function loadEmailAddresses() { |
|
75 | + if ($this->textInput) { |
|
76 | 76 | $pattern = '/\r\n|[\r\n]/'; |
77 | - $array = preg_split( $pattern, $this->textInput ); |
|
78 | - if(!empty($array)){ |
|
79 | - foreach ($array as $address){ |
|
80 | - if($address){ |
|
77 | + $array = preg_split($pattern, $this->textInput); |
|
78 | + if (!empty($array)) { |
|
79 | + foreach ($array as $address) { |
|
80 | + if ($address) { |
|
81 | 81 | $model = new EmailAddress([ |
82 | 82 | 'address'=>$address, |
83 | 83 | 'checkDNS'=>$this->checkDNS, |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | ]); |
86 | 86 | |
87 | 87 | $this->emailAddresses[] = $model; |
88 | - if(!$model->isValid){ |
|
88 | + if (!$model->isValid) { |
|
89 | 89 | $this->failingEmailAddresses[] = $model; |
90 | 90 | } |
91 | 91 |
@@ -48,21 +48,21 @@ |
||
48 | 48 | $model = new EmailsValidationForm(); |
49 | 49 | $dataProvider = null; |
50 | 50 | |
51 | - if($model->load(Yii::$app->request->post()) && $model->process()){ |
|
51 | + if ($model->load(Yii::$app->request->post()) && $model->process()) { |
|
52 | 52 | $dataProvider = new ArrayDataProvider([ |
53 | - 'allModels'=>($model->displayOnlyProblems ? $model->failingEmailAddresses:$model->emailAddresses), |
|
53 | + 'allModels'=>($model->displayOnlyProblems ? $model->failingEmailAddresses : $model->emailAddresses), |
|
54 | 54 | 'pagination' => [ |
55 | 55 | 'pageSize' => count($model->emailAddresses), |
56 | 56 | ], |
57 | 57 | ]); |
58 | 58 | $formatter = new Formatter(); |
59 | 59 | |
60 | - if(!empty($model->failingEmailAddresses)){ |
|
61 | - Yii::$app->session->addFlash('danger',Yii::t('app','There were {count} e-mail addresses that failed validation!',[ |
|
60 | + if (!empty($model->failingEmailAddresses)) { |
|
61 | + Yii::$app->session->addFlash('danger', Yii::t('app', 'There were {count} e-mail addresses that failed validation!', [ |
|
62 | 62 | 'count'=>count($model->failingEmailAddresses) |
63 | 63 | ])); |
64 | 64 | } |
65 | - Yii::$app->session->addFlash('success',Yii::t('app','Checked {count} e-mails in {duration}!',[ |
|
65 | + Yii::$app->session->addFlash('success', Yii::t('app', 'Checked {count} e-mails in {duration}!', [ |
|
66 | 66 | 'count'=>count($model->emailAddresses), |
67 | 67 | 'duration'=>$formatter->asDuration(Yii::getLogger()->getElapsedTime()) |
68 | 68 | ])); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $this->params['breadcrumbs'][] = Yii::t('app', 'E-mail validation'); |
14 | 14 | ?> |
15 | 15 | <div id="bulk-email-validation"> |
16 | - <?php if($model->module->displayFlashMessages):?> |
|
16 | + <?php if ($model->module->displayFlashMessages):?> |
|
17 | 17 | <div class="row"> |
18 | 18 | <div class="col-xs-12"> |
19 | 19 | <?php foreach (Yii::$app->session->allFlashes as $type => $message): ?> |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | <?php endforeach ?> |
27 | 27 | </div> |
28 | 28 | </div> |
29 | - <?php endif;?> |
|
29 | + <?php endif; ?> |
|
30 | 30 | |
31 | 31 | |
32 | 32 | <div class="panel panel-default email-validation-results" id="email-validation-results"> |
33 | 33 | <div class="panel-heading"> |
34 | - <?= Yii::t('app','Input')?> |
|
35 | - <a class="pull-right btn btn-default btn-xs" data-toggle="collapse" href="#emails-validation-input"><?=Yii::t('app','Show/hide')?></a> |
|
34 | + <?= Yii::t('app', 'Input')?> |
|
35 | + <a class="pull-right btn btn-default btn-xs" data-toggle="collapse" href="#emails-validation-input"><?=Yii::t('app', 'Show/hide')?></a> |
|
36 | 36 | </div> |
37 | 37 | |
38 | 38 | <div id="emails-validation-input" class="panel-collapse collapse <?=(count($model->emailAddresses)>0 ? null:'in')?>"> |
@@ -63,5 +63,5 @@ discard block |
||
63 | 63 | |
64 | 64 | <?php $form = ActiveForm::end() ?> |
65 | 65 | |
66 | - <?= $this->render('_validation-list',['model'=>$model,'dataProvider'=>$dataProvider])?> |
|
66 | + <?= $this->render('_validation-list', ['model'=>$model, 'dataProvider'=>$dataProvider])?> |
|
67 | 67 | </div> |
68 | 68 | \ No newline at end of file |
@@ -74,14 +74,14 @@ |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | if($model->checkSpoof){ |
77 | - $columns[] =[ |
|
78 | - 'attribute'=> 'isValidSpoofCheck', |
|
79 | - 'format'=>'boolean', |
|
80 | - 'contentOptions' => function ($model) { |
|
81 | - /** @var EmailAddress $model */ |
|
82 | - return ['class' => (!$model->isValidSpoofCheck ? 'danger text-danger': 'text-success')]; |
|
83 | - }, |
|
84 | - ]; |
|
77 | + $columns[] =[ |
|
78 | + 'attribute'=> 'isValidSpoofCheck', |
|
79 | + 'format'=>'boolean', |
|
80 | + 'contentOptions' => function ($model) { |
|
81 | + /** @var EmailAddress $model */ |
|
82 | + return ['class' => (!$model->isValidSpoofCheck ? 'danger text-danger': 'text-success')]; |
|
83 | + }, |
|
84 | + ]; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | ?> |
@@ -13,81 +13,81 @@ discard block |
||
13 | 13 | [ |
14 | 14 | 'attribute'=> 'address', |
15 | 15 | 'format'=>'raw', |
16 | - 'value'=>function($model){ |
|
16 | + 'value'=>function($model) { |
|
17 | 17 | /** @var EmailAddress $model */ |
18 | 18 | // hilight spaces |
19 | 19 | $word = " "; |
20 | - $text = preg_replace ("/" . preg_quote($word, '/') . "/", |
|
20 | + $text = preg_replace("/" . preg_quote($word, '/') . "/", |
|
21 | 21 | "<span class='bg-primary'> </span>", |
22 | 22 | $model->address); |
23 | 23 | return $text; |
24 | 24 | |
25 | 25 | }, |
26 | - 'contentOptions' => function ($model) { |
|
26 | + 'contentOptions' => function($model) { |
|
27 | 27 | /** @var EmailAddress $model */ |
28 | - return ['class' => (!$model->isValid ? 'danger text-danger': 'text-success')]; |
|
28 | + return ['class' => (!$model->isValid ? 'danger text-danger' : 'text-success')]; |
|
29 | 29 | }, |
30 | 30 | ], |
31 | 31 | [ |
32 | 32 | 'attribute'=> 'needsTrimming', |
33 | 33 | 'format'=>'boolean', |
34 | - 'contentOptions' => function ($model) { |
|
34 | + 'contentOptions' => function($model) { |
|
35 | 35 | /** @var EmailAddress $model */ |
36 | - return ['class' => ($model->needsTrimming ? 'warning text-warning': 'text-success')]; |
|
36 | + return ['class' => ($model->needsTrimming ? 'warning text-warning' : 'text-success')]; |
|
37 | 37 | }, |
38 | 38 | ], |
39 | 39 | [ |
40 | 40 | 'attribute'=> 'isValid', |
41 | 41 | 'format'=>'boolean', |
42 | - 'contentOptions' => function ($model) { |
|
42 | + 'contentOptions' => function($model) { |
|
43 | 43 | /** @var EmailAddress $model */ |
44 | - return ['class' => (!$model->isValid ? 'danger text-danger': 'text-success')]; |
|
44 | + return ['class' => (!$model->isValid ? 'danger text-danger' : 'text-success')]; |
|
45 | 45 | }, |
46 | 46 | ], |
47 | 47 | [ |
48 | 48 | 'attribute'=> 'isValidRFC', |
49 | 49 | 'format'=>'boolean', |
50 | - 'contentOptions' => function ($model) { |
|
50 | + 'contentOptions' => function($model) { |
|
51 | 51 | /** @var EmailAddress $model */ |
52 | - return ['class' => (!$model->isValidRFC ? 'danger text-danger': 'text-success')]; |
|
52 | + return ['class' => (!$model->isValidRFC ? 'danger text-danger' : 'text-success')]; |
|
53 | 53 | }, |
54 | 54 | ], |
55 | 55 | [ |
56 | 56 | 'attribute'=> 'isNoRFCWarnings', |
57 | 57 | 'format'=>'boolean', |
58 | - 'contentOptions' => function ($model) { |
|
58 | + 'contentOptions' => function($model) { |
|
59 | 59 | /** @var EmailAddress $model */ |
60 | - return ['class' => (!$model->isNoRFCWarnings ? 'danger text-danger': 'text-success')]; |
|
60 | + return ['class' => (!$model->isNoRFCWarnings ? 'danger text-danger' : 'text-success')]; |
|
61 | 61 | }, |
62 | 62 | ], |
63 | 63 | ]; |
64 | 64 | |
65 | -if($model->checkDNS){ |
|
66 | - $columns[] =[ |
|
65 | +if ($model->checkDNS) { |
|
66 | + $columns[] = [ |
|
67 | 67 | 'attribute'=> 'isValidDNS', |
68 | 68 | 'format'=>'boolean', |
69 | - 'contentOptions' => function ($model) { |
|
69 | + 'contentOptions' => function($model) { |
|
70 | 70 | /** @var EmailAddress $model */ |
71 | - return ['class' => (!$model->isValidDNS ? 'danger text-danger': 'text-success')]; |
|
71 | + return ['class' => (!$model->isValidDNS ? 'danger text-danger' : 'text-success')]; |
|
72 | 72 | }, |
73 | 73 | ]; |
74 | 74 | } |
75 | 75 | |
76 | -if($model->checkSpoof){ |
|
77 | - $columns[] =[ |
|
76 | +if ($model->checkSpoof) { |
|
77 | + $columns[] = [ |
|
78 | 78 | 'attribute'=> 'isValidSpoofCheck', |
79 | 79 | 'format'=>'boolean', |
80 | - 'contentOptions' => function ($model) { |
|
80 | + 'contentOptions' => function($model) { |
|
81 | 81 | /** @var EmailAddress $model */ |
82 | - return ['class' => (!$model->isValidSpoofCheck ? 'danger text-danger': 'text-success')]; |
|
82 | + return ['class' => (!$model->isValidSpoofCheck ? 'danger text-danger' : 'text-success')]; |
|
83 | 83 | }, |
84 | 84 | ]; |
85 | 85 | } |
86 | 86 | |
87 | 87 | ?> |
88 | -<?php if($model->emailAddresses):?> |
|
88 | +<?php if ($model->emailAddresses):?> |
|
89 | 89 | <div class="panel panel-primary email-validation-results" id="email-validation-results"> |
90 | - <div class="panel-heading"><?= Yii::t('app','Results')?></div> |
|
90 | + <div class="panel-heading"><?= Yii::t('app', 'Results')?></div> |
|
91 | 91 | |
92 | 92 | <div class="panel-body"> |
93 | 93 | <?= \yii\grid\GridView::widget([ |
@@ -97,4 +97,4 @@ discard block |
||
97 | 97 | |
98 | 98 | </div> |
99 | 99 | </div> |
100 | -<?php endif;?> |
|
100 | +<?php endif; ?> |