Completed
Branch Gutenberg/use-new-wordpress-pa... (9fa7a4)
by
unknown
63:25 queued 48:18
created
strategies/validation/EE_Full_HTML_Validation_Strategy.strategy.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@
 block discarded – undo
13 13
 class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base
14 14
 {
15 15
 
16
-    /**
17
-     * @param null $validation_error_message
18
-     */
19
-    public function __construct($validation_error_message = null)
20
-    {
21
-        if (! $validation_error_message) {
22
-            $validation_error_message = sprintf(
23
-                __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
24
-                '<br />',
25
-                $this->get_list_of_allowed_tags()
26
-            );
27
-        }
28
-        parent::__construct($validation_error_message);
29
-    }
16
+	/**
17
+	 * @param null $validation_error_message
18
+	 */
19
+	public function __construct($validation_error_message = null)
20
+	{
21
+		if (! $validation_error_message) {
22
+			$validation_error_message = sprintf(
23
+				__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
24
+				'<br />',
25
+				$this->get_list_of_allowed_tags()
26
+			);
27
+		}
28
+		parent::__construct($validation_error_message);
29
+	}
30 30
 
31 31
 
32 32
 
33
-    /**
34
-     * get_list_of_allowed_tags
35
-     *
36
-     * generates and returns a string that lists the top-level HTML tags that are allowable for this input
37
-     *
38
-     * @return string
39
-     */
40
-    public function get_list_of_allowed_tags()
41
-    {
42
-        global $allowedposttags;
43
-        ksort($allowedposttags);
44
-        return implode(', ', array_keys($allowedposttags));
45
-    }
33
+	/**
34
+	 * get_list_of_allowed_tags
35
+	 *
36
+	 * generates and returns a string that lists the top-level HTML tags that are allowable for this input
37
+	 *
38
+	 * @return string
39
+	 */
40
+	public function get_list_of_allowed_tags()
41
+	{
42
+		global $allowedposttags;
43
+		ksort($allowedposttags);
44
+		return implode(', ', array_keys($allowedposttags));
45
+	}
46 46
 
47 47
 
48 48
 
49
-    /**
50
-     * @param $normalized_value
51
-     * @throws \EE_Validation_Error
52
-     */
53
-    public function validate($normalized_value)
54
-    {
55
-        global $allowedposttags;
56
-        parent::validate($normalized_value);
57
-        $normalized_value_sans_tags =  wp_kses("$normalized_value", $allowedposttags);
58
-        if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
59
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
60
-        }
61
-    }
49
+	/**
50
+	 * @param $normalized_value
51
+	 * @throws \EE_Validation_Error
52
+	 */
53
+	public function validate($normalized_value)
54
+	{
55
+		global $allowedposttags;
56
+		parent::validate($normalized_value);
57
+		$normalized_value_sans_tags =  wp_kses("$normalized_value", $allowedposttags);
58
+		if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
59
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
60
+		}
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      */
19 19
     public function __construct($validation_error_message = null)
20 20
     {
21
-        if (! $validation_error_message) {
21
+        if ( ! $validation_error_message) {
22 22
             $validation_error_message = sprintf(
23 23
                 __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
24 24
                 '<br />',
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         global $allowedposttags;
56 56
         parent::validate($normalized_value);
57
-        $normalized_value_sans_tags =  wp_kses("$normalized_value", $allowedposttags);
57
+        $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedposttags);
58 58
         if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
59 59
             throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
60 60
         }
Please login to merge, or discard this patch.
strategies/validation/EE_Max_Length_Validation_Strategy.strategy.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@
 block discarded – undo
11 11
 class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base
12 12
 {
13 13
 
14
-    protected $_max_length;
14
+	protected $_max_length;
15 15
 
16
-    public function __construct($validation_error_message = null, $max_length = EE_INF)
17
-    {
18
-        $this->_max_length = $max_length;
19
-        if ($validation_error_message === null) {
20
-            $validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
21
-        }
22
-        parent::__construct($validation_error_message);
23
-    }
16
+	public function __construct($validation_error_message = null, $max_length = EE_INF)
17
+	{
18
+		$this->_max_length = $max_length;
19
+		if ($validation_error_message === null) {
20
+			$validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
21
+		}
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25
-    /**
26
-     * @param $normalized_value
27
-     */
28
-    public function validate($normalized_value)
29
-    {
30
-        if ($this->_max_length !== EE_INF &&
31
-                $normalized_value &&
32
-                is_string($normalized_value) &&
33
-                 strlen($normalized_value) > $this->_max_length) {
34
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
35
-        }
36
-    }
25
+	/**
26
+	 * @param $normalized_value
27
+	 */
28
+	public function validate($normalized_value)
29
+	{
30
+		if ($this->_max_length !== EE_INF &&
31
+				$normalized_value &&
32
+				is_string($normalized_value) &&
33
+				 strlen($normalized_value) > $this->_max_length) {
34
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @return array
40
-     */
41
-    public function get_jquery_validation_rule_array()
42
-    {
43
-        if ($this->_max_length !== EE_INF) {
44
-            return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
45
-        } else {
46
-            return array();
47
-        }
48
-    }
38
+	/**
39
+	 * @return array
40
+	 */
41
+	public function get_jquery_validation_rule_array()
42
+	{
43
+		if ($this->_max_length !== EE_INF) {
44
+			return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
45
+		} else {
46
+			return array();
47
+		}
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     public function get_jquery_validation_rule_array()
42 42
     {
43 43
         if ($this->_max_length !== EE_INF) {
44
-            return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
44
+            return array('maxlength'=> $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message()));
45 45
         } else {
46 46
             return array();
47 47
         }
Please login to merge, or discard this patch.
strategies/validation/EE_Enum_Validation_Strategy.strategy.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
 class EE_Enum_Validation_Strategy extends EE_Validation_Strategy_Base
12 12
 {
13 13
 
14
-    /**
15
-     * Check that the value is in the allowed list
16
-     * @param $normalized_value
17
-     * @throws EE_Error
18
-     * @throws EE_Validation_Error
19
-     * @return boolean
20
-     */
21
-    public function validate($normalized_value)
22
-    {
23
-        parent::validate($normalized_value);
24
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
-            throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26
-        }
27
-        $enum_options = $this->_input->flat_options();
28
-        if ($normalized_value === true) {
29
-            $normalized_value = 1;
30
-        } elseif ($normalized_value === false) {
31
-            $normalized_value = 0;
32
-        }
33
-        if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
34
-            throw new EE_Validation_Error(
35
-                $this->get_validation_error_message(),
36
-                'invalid_enum_value'
37
-            );
38
-        } else {
39
-            return true;
40
-        }
41
-    }
14
+	/**
15
+	 * Check that the value is in the allowed list
16
+	 * @param $normalized_value
17
+	 * @throws EE_Error
18
+	 * @throws EE_Validation_Error
19
+	 * @return boolean
20
+	 */
21
+	public function validate($normalized_value)
22
+	{
23
+		parent::validate($normalized_value);
24
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+			throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26
+		}
27
+		$enum_options = $this->_input->flat_options();
28
+		if ($normalized_value === true) {
29
+			$normalized_value = 1;
30
+		} elseif ($normalized_value === false) {
31
+			$normalized_value = 0;
32
+		}
33
+		if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
34
+			throw new EE_Validation_Error(
35
+				$this->get_validation_error_message(),
36
+				'invalid_enum_value'
37
+			);
38
+		} else {
39
+			return true;
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * If we are using the default validation error message, make it dynamic based
45
-     * on the allowed options.
46
-     * @return string
47
-     */
48
-    public function get_validation_error_message()
49
-    {
50
-        $parent_validation_error_message = parent::get_validation_error_message();
51
-        if (! $parent_validation_error_message) {
52
-            $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53
-            return sprintf(
54
-                __("This is not allowed option. Allowed options are %s.", "event_espresso"),
55
-                implode(', ', $enum_options)
56
-            );
57
-        } else {
58
-            return $parent_validation_error_message;
59
-        }
60
-    }
43
+	/**
44
+	 * If we are using the default validation error message, make it dynamic based
45
+	 * on the allowed options.
46
+	 * @return string
47
+	 */
48
+	public function get_validation_error_message()
49
+	{
50
+		$parent_validation_error_message = parent::get_validation_error_message();
51
+		if (! $parent_validation_error_message) {
52
+			$enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53
+			return sprintf(
54
+				__("This is not allowed option. Allowed options are %s.", "event_espresso"),
55
+				implode(', ', $enum_options)
56
+			);
57
+		} else {
58
+			return $parent_validation_error_message;
59
+		}
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function validate($normalized_value)
22 22
     {
23 23
         parent::validate($normalized_value);
24
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
24
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25 25
             throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26 26
         }
27 27
         $enum_options = $this->_input->flat_options();
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public function get_validation_error_message()
49 49
     {
50 50
         $parent_validation_error_message = parent::get_validation_error_message();
51
-        if (! $parent_validation_error_message) {
51
+        if ( ! $parent_validation_error_message) {
52 52
             $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53 53
             return sprintf(
54 54
                 __("This is not allowed option. Allowed options are %s.", "event_espresso"),
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_URL_Validation_Strategy.strategy.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,52 +11,52 @@
 block discarded – undo
11 11
 class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @param null $validation_error_message
16
-     */
17
-    public function __construct($validation_error_message = null)
18
-    {
19
-        if (! $validation_error_message) {
20
-            $validation_error_message = __("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
21
-        }
22
-        parent::__construct($validation_error_message);
23
-    }
14
+	/**
15
+	 * @param null $validation_error_message
16
+	 */
17
+	public function __construct($validation_error_message = null)
18
+	{
19
+		if (! $validation_error_message) {
20
+			$validation_error_message = __("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
21
+		}
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * just checks the field isn't blank
29
-     *
30
-     * @param $normalized_value
31
-     * @return bool
32
-     * @throws \EE_Validation_Error
33
-     */
34
-    public function validate($normalized_value)
35
-    {
36
-        if ($normalized_value) {
37
-            if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
38
-                throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
39
-            } else {
40
-                if (! EEH_URL::remote_file_exists(
41
-                    $normalized_value,
42
-                    array(
43
-                            'sslverify' => false,
44
-                            'limit_response_size' => 4095,// we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
45
-                        )
46
-                )) {
47
-                    throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
48
-                }
49
-            }
50
-        }
51
-    }
27
+	/**
28
+	 * just checks the field isn't blank
29
+	 *
30
+	 * @param $normalized_value
31
+	 * @return bool
32
+	 * @throws \EE_Validation_Error
33
+	 */
34
+	public function validate($normalized_value)
35
+	{
36
+		if ($normalized_value) {
37
+			if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
38
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
39
+			} else {
40
+				if (! EEH_URL::remote_file_exists(
41
+					$normalized_value,
42
+					array(
43
+							'sslverify' => false,
44
+							'limit_response_size' => 4095,// we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
45
+						)
46
+				)) {
47
+					throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
48
+				}
49
+			}
50
+		}
51
+	}
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function get_jquery_validation_rule_array()
59
-    {
60
-        return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
61
-    }
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function get_jquery_validation_rule_array()
59
+	{
60
+		return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function __construct($validation_error_message = null)
18 18
     {
19
-        if (! $validation_error_message) {
19
+        if ( ! $validation_error_message) {
20 20
             $validation_error_message = __("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
21 21
         }
22 22
         parent::__construct($validation_error_message);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
             if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
38 38
                 throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
39 39
             } else {
40
-                if (! EEH_URL::remote_file_exists(
40
+                if ( ! EEH_URL::remote_file_exists(
41 41
                     $normalized_value,
42 42
                     array(
43 43
                             'sslverify' => false,
44
-                            'limit_response_size' => 4095,// we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
44
+                            'limit_response_size' => 4095, // we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
45 45
                         )
46 46
                 )) {
47 47
                     throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
@@ -57,6 +57,6 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function get_jquery_validation_rule_array()
59 59
     {
60
-        return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
60
+        return array('validUrl'=>true, 'messages' => array('validUrl' => $this->get_validation_error_message()));
61 61
     }
62 62
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Credit_Card_Validation_Strategy.strategy.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,55 +13,55 @@
 block discarded – undo
13 13
 class EE_Credit_Card_Validation_Strategy extends EE_Text_Validation_Strategy
14 14
 {
15 15
 
16
-    /**
17
-     * @param null $validation_error_message
18
-     */
19
-    public function __construct($validation_error_message = null)
20
-    {
21
-        if (! $validation_error_message) {
22
-            $validation_error_message = __("Please enter a valid credit card number", "event_espresso");
23
-        }
24
-        parent::__construct($validation_error_message);
25
-    }
16
+	/**
17
+	 * @param null $validation_error_message
18
+	 */
19
+	public function __construct($validation_error_message = null)
20
+	{
21
+		if (! $validation_error_message) {
22
+			$validation_error_message = __("Please enter a valid credit card number", "event_espresso");
23
+		}
24
+		parent::__construct($validation_error_message);
25
+	}
26 26
 
27
-    /**
28
-     * just checks the field isn't blank
29
-     * @param $normalized_value
30
-     * @throws EE_Validation_Error
31
-     * @return void
32
-     */
33
-    public function validate($normalized_value)
34
-    {
35
-        if ($normalized_value && ! $this->verify_is_credit_card($normalized_value)) {
36
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
37
-        }
38
-    }
27
+	/**
28
+	 * just checks the field isn't blank
29
+	 * @param $normalized_value
30
+	 * @throws EE_Validation_Error
31
+	 * @return void
32
+	 */
33
+	public function validate($normalized_value)
34
+	{
35
+		if ($normalized_value && ! $this->verify_is_credit_card($normalized_value)) {
36
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
37
+		}
38
+	}
39 39
 
40 40
 
41 41
 
42
-    /**
43
-     * gets additional validation rules for use in the jQuery validation JS corresponding to this field when displaying.
44
-     *
45
-     * @return array
46
-     */
47
-    public function get_jquery_validation_rule_array()
48
-    {
49
-        return array('creditcard'=>true, 'messages' => array( 'creditcard' => $this->get_validation_error_message() ) );
50
-    }
42
+	/**
43
+	 * gets additional validation rules for use in the jQuery validation JS corresponding to this field when displaying.
44
+	 *
45
+	 * @return array
46
+	 */
47
+	public function get_jquery_validation_rule_array()
48
+	{
49
+		return array('creditcard'=>true, 'messages' => array( 'creditcard' => $this->get_validation_error_message() ) );
50
+	}
51 51
 
52
-    /**
53
-     * Uses regular expressions to verify $card_number is actually a credit card number
54
-     * @param string $card_number
55
-     * @return boolean
56
-     */
57
-    private function verify_is_credit_card($card_number)
58
-    {
59
-        // Credit card: All major cards
60
-        $regex = '~^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$~';
61
-        if (preg_match($regex, $card_number) || empty($card_number)) {
62
-            return true;
63
-        } else {
64
-            return false;
65
-        }
66
-    }
52
+	/**
53
+	 * Uses regular expressions to verify $card_number is actually a credit card number
54
+	 * @param string $card_number
55
+	 * @return boolean
56
+	 */
57
+	private function verify_is_credit_card($card_number)
58
+	{
59
+		// Credit card: All major cards
60
+		$regex = '~^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$~';
61
+		if (preg_match($regex, $card_number) || empty($card_number)) {
62
+			return true;
63
+		} else {
64
+			return false;
65
+		}
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      */
19 19
     public function __construct($validation_error_message = null)
20 20
     {
21
-        if (! $validation_error_message) {
21
+        if ( ! $validation_error_message) {
22 22
             $validation_error_message = __("Please enter a valid credit card number", "event_espresso");
23 23
         }
24 24
         parent::__construct($validation_error_message);
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function get_jquery_validation_rule_array()
48 48
     {
49
-        return array('creditcard'=>true, 'messages' => array( 'creditcard' => $this->get_validation_error_message() ) );
49
+        return array('creditcard'=>true, 'messages' => array('creditcard' => $this->get_validation_error_message()));
50 50
     }
51 51
 
52 52
     /**
Please login to merge, or discard this patch.
strategies/validation/EE_Validation_Strategy_Base.strategy.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -11,97 +11,97 @@
 block discarded – undo
11 11
 {
12 12
 
13 13
 
14
-    protected $_validation_error_message = '';
15
-
16
-
17
-
18
-    /**
19
-     * @param null $validation_error_message
20
-     */
21
-    public function __construct($validation_error_message = null)
22
-    {
23
-        $this->_validation_error_message = $validation_error_message === null
24
-            ? __('Input invalid', 'event_espresso')
25
-            : $validation_error_message;
26
-        parent::__construct();
27
-    }
28
-
29
-
30
-
31
-    /**
32
-     * Performs validation on the request data that corresponds to this field.
33
-     * If validation fails, should throw an EE_Validation_Error.
34
-     * Note: most validate() functions should allow $normalized_value to be empty,
35
-     * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty.
36
-     *
37
-     * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
38
-     *                                this validation strategy is the 'required' validation strategy,
39
-     *                                most should be OK with a null, empty string, etc)
40
-     */
41
-    public function validate($normalized_value)
42
-    {
43
-        // by default, the validation strategy does no validation. this should be implemented
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying.
50
-     * For documentation, see http://jqueryvalidation.org/
51
-     * Eg to generate the following js for validation, <br><code>
52
-     *  $( "#myform" ).validate({
53
-     *      rules: {
54
-     *          field_name: {
55
-     *              required: true,
56
-     *              minlength: 3,
57
-     *              equalTo: "#password"
58
-     *          }
59
-     *      }
60
-     *  });
61
-     * </code>
62
-     * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ).
63
-     * This is done so that if we are applying multiple sanitization strategies to a field,
64
-     * we can easily combine them.
65
-     *
66
-     * @return array
67
-     */
68
-    public function get_jquery_validation_rule_array()
69
-    {
70
-        return array();
71
-    }
72
-
73
-
74
-
75
-    /**
76
-     * Gets the i18n validation error message for when this validation strategy finds
77
-     * the input is invalid. Used for both frontend and backend validation.
78
-     *
79
-     * @return string
80
-     */
81
-    public function get_validation_error_message()
82
-    {
83
-        return $this->_validation_error_message;
84
-    }
85
-
86
-
87
-
88
-    /**
89
-     * Adds js variables for localization to the $other_js_data. These should be put
90
-     * in each form's "other_data" javascript object.
91
-     *
92
-     * @param array $other_js_data
93
-     * @return array
94
-     */
95
-    public function get_other_js_data($other_js_data = array())
96
-    {
97
-        return $other_js_data;
98
-    }
14
+	protected $_validation_error_message = '';
15
+
16
+
17
+
18
+	/**
19
+	 * @param null $validation_error_message
20
+	 */
21
+	public function __construct($validation_error_message = null)
22
+	{
23
+		$this->_validation_error_message = $validation_error_message === null
24
+			? __('Input invalid', 'event_espresso')
25
+			: $validation_error_message;
26
+		parent::__construct();
27
+	}
28
+
29
+
30
+
31
+	/**
32
+	 * Performs validation on the request data that corresponds to this field.
33
+	 * If validation fails, should throw an EE_Validation_Error.
34
+	 * Note: most validate() functions should allow $normalized_value to be empty,
35
+	 * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty.
36
+	 *
37
+	 * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
38
+	 *                                this validation strategy is the 'required' validation strategy,
39
+	 *                                most should be OK with a null, empty string, etc)
40
+	 */
41
+	public function validate($normalized_value)
42
+	{
43
+		// by default, the validation strategy does no validation. this should be implemented
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying.
50
+	 * For documentation, see http://jqueryvalidation.org/
51
+	 * Eg to generate the following js for validation, <br><code>
52
+	 *  $( "#myform" ).validate({
53
+	 *      rules: {
54
+	 *          field_name: {
55
+	 *              required: true,
56
+	 *              minlength: 3,
57
+	 *              equalTo: "#password"
58
+	 *          }
59
+	 *      }
60
+	 *  });
61
+	 * </code>
62
+	 * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ).
63
+	 * This is done so that if we are applying multiple sanitization strategies to a field,
64
+	 * we can easily combine them.
65
+	 *
66
+	 * @return array
67
+	 */
68
+	public function get_jquery_validation_rule_array()
69
+	{
70
+		return array();
71
+	}
72
+
73
+
74
+
75
+	/**
76
+	 * Gets the i18n validation error message for when this validation strategy finds
77
+	 * the input is invalid. Used for both frontend and backend validation.
78
+	 *
79
+	 * @return string
80
+	 */
81
+	public function get_validation_error_message()
82
+	{
83
+		return $this->_validation_error_message;
84
+	}
85
+
86
+
87
+
88
+	/**
89
+	 * Adds js variables for localization to the $other_js_data. These should be put
90
+	 * in each form's "other_data" javascript object.
91
+	 *
92
+	 * @param array $other_js_data
93
+	 * @return array
94
+	 */
95
+	public function get_other_js_data($other_js_data = array())
96
+	{
97
+		return $other_js_data;
98
+	}
99 99
     
100
-    /**
101
-     * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
102
-     * This should be called during wp_enqueue_scripts
103
-     */
104
-    public function enqueue_js()
105
-    {
106
-    }
100
+	/**
101
+	 * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
102
+	 * This should be called during wp_enqueue_scripts
103
+	 */
104
+	public function enqueue_js()
105
+	{
106
+	}
107 107
 }
Please login to merge, or discard this patch.
sensitive_data_removal/EE_Credit_Card_Sensitive_Data_Removal.strategy.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Credit_Card_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        // Get the cc Length
17
-        $cc_length = strlen($normalized_value);
18
-        // Replace all characters of credit card except the last four and dashes
19
-        for ($i=0; $i<$cc_length-4; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
21
-                continue;
22
-            }
23
-            $normalized_value[ $i ] = 'X';
24
-        }
25
-        // Return the masked Credit Card #
26
-        return $normalized_value;
27
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		// Get the cc Length
17
+		$cc_length = strlen($normalized_value);
18
+		// Replace all characters of credit card except the last four and dashes
19
+		for ($i=0; $i<$cc_length-4; $i++) {
20
+			if ($normalized_value[ $i ] == '-') {
21
+				continue;
22
+			}
23
+			$normalized_value[ $i ] = 'X';
24
+		}
25
+		// Return the masked Credit Card #
26
+		return $normalized_value;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
         // Get the cc Length
17 17
         $cc_length = strlen($normalized_value);
18 18
         // Replace all characters of credit card except the last four and dashes
19
-        for ($i=0; $i<$cc_length-4; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
19
+        for ($i = 0; $i < $cc_length - 4; $i++) {
20
+            if ($normalized_value[$i] == '-') {
21 21
                 continue;
22 22
             }
23
-            $normalized_value[ $i ] = 'X';
23
+            $normalized_value[$i] = 'X';
24 24
         }
25 25
         // Return the masked Credit Card #
26 26
         return $normalized_value;
Please login to merge, or discard this patch.
sensitive_data_removal/EE_Sensitive_Data_Removal_Base.strategy.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
  */
12 12
 abstract class EE_Sensitive_Data_Removal_Base extends EE_Form_Input_Strategy_Base
13 13
 {
14
-    /**
15
-     * Removes all the sensitive data from this normalized value.
16
-     * For example, should could 'mask' a credit card from
17
-     * '1234 1234 1234 1234' TO '**** **** **** 1234'.
18
-     * Or turn a ccv number from
19
-     * '123' to '***',
20
-     * or turn a password from
21
-     * 'CantHac7Th15' to '*************',
22
-     * or just leave htevalue as-is
23
-     * @return mixed
24
-     */
25
-    abstract public function remove_sensitive_data($normalized_value);
14
+	/**
15
+	 * Removes all the sensitive data from this normalized value.
16
+	 * For example, should could 'mask' a credit card from
17
+	 * '1234 1234 1234 1234' TO '**** **** **** 1234'.
18
+	 * Or turn a ccv number from
19
+	 * '123' to '***',
20
+	 * or turn a password from
21
+	 * 'CantHac7Th15' to '*************',
22
+	 * or just leave htevalue as-is
23
+	 * @return mixed
24
+	 */
25
+	abstract public function remove_sensitive_data($normalized_value);
26 26
 }
Please login to merge, or discard this patch.
sensitive_data_removal/EE_All_Sensitive_Data_Removal.strategy.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class EE_All_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        switch (gettype($normalized_value)) {
17
-            case "boolean":
18
-                return false;
19
-            case "integer":
20
-            case "double":
21
-                return 0;
22
-            case "string":
23
-                return '';
24
-            case "array":
25
-                return array();
26
-            case "object":
27
-            case "resource":
28
-            case "NULL":
29
-            default:
30
-                return null;
31
-        }
32
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		switch (gettype($normalized_value)) {
17
+			case "boolean":
18
+				return false;
19
+			case "integer":
20
+			case "double":
21
+				return 0;
22
+			case "string":
23
+				return '';
24
+			case "array":
25
+				return array();
26
+			case "object":
27
+			case "resource":
28
+			case "NULL":
29
+			default:
30
+				return null;
31
+		}
32
+	}
33 33
 }
Please login to merge, or discard this patch.