Completed
Branch back-compat-edtr-taxes (752e0e)
by
unknown
12:08 queued 09:43
created
form_sections/strategies/display/EE_Select_Display_Strategy.strategy.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -15,78 +15,78 @@
 block discarded – undo
15 15
 class EE_Select_Display_Strategy extends EE_Display_Strategy_Base
16 16
 {
17 17
 
18
-    /**
19
-     *
20
-     * @throws EE_Error
21
-     * @return string of html to display the field
22
-     */
23
-    public function display()
24
-    {
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
-            throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27
-        }
18
+	/**
19
+	 *
20
+	 * @throws EE_Error
21
+	 * @return string of html to display the field
22
+	 */
23
+	public function display()
24
+	{
25
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
+			throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27
+		}
28 28
 
29
-        $html = EEH_HTML::nl(0, 'select');
30
-        $html .= '<select';
31
-        $html .= $this->_attributes_string(
32
-            $this->_standard_attributes_array()
33
-        );
34
-        $html .= '>';
29
+		$html = EEH_HTML::nl(0, 'select');
30
+		$html .= '<select';
31
+		$html .= $this->_attributes_string(
32
+			$this->_standard_attributes_array()
33
+		);
34
+		$html .= '>';
35 35
 
36
-        if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37
-            EEH_HTML::indent(1, 'optgroup');
38
-            foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
-                if (! empty($opt_group_label)) {
40
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
41
-                }
42
-                EEH_HTML::indent(1, 'option');
43
-                $html .= $this->_display_options($opt_group);
44
-                EEH_HTML::indent(-1, 'option');
45
-                if (! empty($opt_group_label)) {
46
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
47
-                }
48
-            }
49
-            EEH_HTML::indent(-1, 'optgroup');
50
-        } else {
51
-            $html .= $this->_display_options($this->_input->options());
52
-        }
36
+		if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37
+			EEH_HTML::indent(1, 'optgroup');
38
+			foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
+				if (! empty($opt_group_label)) {
40
+					$html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
41
+				}
42
+				EEH_HTML::indent(1, 'option');
43
+				$html .= $this->_display_options($opt_group);
44
+				EEH_HTML::indent(-1, 'option');
45
+				if (! empty($opt_group_label)) {
46
+					$html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
47
+				}
48
+			}
49
+			EEH_HTML::indent(-1, 'optgroup');
50
+		} else {
51
+			$html .= $this->_display_options($this->_input->options());
52
+		}
53 53
 
54
-        $html .= EEH_HTML::nl(0, 'select') . '</select>';
55
-        return $html;
56
-    }
54
+		$html .= EEH_HTML::nl(0, 'select') . '</select>';
55
+		return $html;
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Displays a flat list of options as option tags
62
-     * @param array $options
63
-     * @return string
64
-     */
65
-    protected function _display_options($options)
66
-    {
67
-        $html = '';
68
-        EEH_HTML::indent(1, 'option');
69
-        foreach ($options as $value => $display_text) {
70
-            // even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
71
-            // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73
-            $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : '';
74
-            $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
75
-        }
76
-        EEH_HTML::indent(-1, 'option');
77
-        return $html;
78
-    }
60
+	/**
61
+	 * Displays a flat list of options as option tags
62
+	 * @param array $options
63
+	 * @return string
64
+	 */
65
+	protected function _display_options($options)
66
+	{
67
+		$html = '';
68
+		EEH_HTML::indent(1, 'option');
69
+		foreach ($options as $value => $display_text) {
70
+			// even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
71
+			// PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72
+			$unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73
+			$selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : '';
74
+			$html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
75
+		}
76
+		EEH_HTML::indent(-1, 'option');
77
+		return $html;
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * Checks if that value is the one selected
84
-     *
85
-     * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
86
-     * @return string
87
-     */
88
-    protected function _check_if_option_selected($option_value)
89
-    {
90
-        return $option_value === $this->_input->raw_value();
91
-    }
82
+	/**
83
+	 * Checks if that value is the one selected
84
+	 *
85
+	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
86
+	 * @return string
87
+	 */
88
+	protected function _check_if_option_selected($option_value)
89
+	{
90
+		return $option_value === $this->_input->raw_value();
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function display()
24 24
     {
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26 26
             throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27 27
         }
28 28
 
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
         if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37 37
             EEH_HTML::indent(1, 'optgroup');
38 38
             foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
-                if (! empty($opt_group_label)) {
40
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
39
+                if ( ! empty($opt_group_label)) {
40
+                    $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">';
41 41
                 }
42 42
                 EEH_HTML::indent(1, 'option');
43 43
                 $html .= $this->_display_options($opt_group);
44 44
                 EEH_HTML::indent(-1, 'option');
45
-                if (! empty($opt_group_label)) {
46
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
45
+                if ( ! empty($opt_group_label)) {
46
+                    $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>';
47 47
                 }
48 48
             }
49 49
             EEH_HTML::indent(-1, 'optgroup');
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $html .= $this->_display_options($this->_input->options());
52 52
         }
53 53
 
54
-        $html .= EEH_HTML::nl(0, 'select') . '</select>';
54
+        $html .= EEH_HTML::nl(0, 'select').'</select>';
55 55
         return $html;
56 56
     }
57 57
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72 72
             $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73 73
             $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : '';
74
-            $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
74
+            $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>';
75 75
         }
76 76
         EEH_HTML::indent(-1, 'option');
77 77
         return $html;
Please login to merge, or discard this patch.
strategies/display/EE_Compound_Input_Display_Strategy.strategy.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -16,57 +16,57 @@
 block discarded – undo
16 16
 abstract class EE_Compound_Input_Display_Strategy extends EE_Display_Strategy_Base
17 17
 {
18 18
 
19
-    /**
20
-     * Gets the html ID for the sub-input for the specified option html value (not display text)
21
-     *
22
-     * @param string $option_value
23
-     * @param bool   $add_pound_sign
24
-     * @return string
25
-     */
26
-    public function get_sub_input_id($option_value, $add_pound_sign = false)
27
-    {
28
-        return $this->_append_chars($this->_input->html_id($add_pound_sign), '-') . sanitize_key($option_value);
29
-    }
19
+	/**
20
+	 * Gets the html ID for the sub-input for the specified option html value (not display text)
21
+	 *
22
+	 * @param string $option_value
23
+	 * @param bool   $add_pound_sign
24
+	 * @return string
25
+	 */
26
+	public function get_sub_input_id($option_value, $add_pound_sign = false)
27
+	{
28
+		return $this->_append_chars($this->_input->html_id($add_pound_sign), '-') . sanitize_key($option_value);
29
+	}
30 30
 
31 31
 
32 32
 
33
-    /**
34
-     * Gets the HTML IDs of all the inputs
35
-     *
36
-     * @param boolean $add_pound_sign
37
-     * @return array
38
-     * @throws \EE_Error
39
-     */
40
-    public function get_html_input_ids($add_pound_sign = false)
41
-    {
42
-        $html_input_ids = array();
43
-        foreach ($this->get_input()->options() as $value => $display) {
44
-            $html_input_ids[] = $this->get_sub_input_id($value, $add_pound_sign);
45
-        }
46
-        return $html_input_ids;
47
-    }
33
+	/**
34
+	 * Gets the HTML IDs of all the inputs
35
+	 *
36
+	 * @param boolean $add_pound_sign
37
+	 * @return array
38
+	 * @throws \EE_Error
39
+	 */
40
+	public function get_html_input_ids($add_pound_sign = false)
41
+	{
42
+		$html_input_ids = array();
43
+		foreach ($this->get_input()->options() as $value => $display) {
44
+			$html_input_ids[] = $this->get_sub_input_id($value, $add_pound_sign);
45
+		}
46
+		return $html_input_ids;
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     * Overrides parent to make sure this display strategy is only used with the
53
-     * appropriate input type
54
-     *
55
-     * @return \EE_Form_Input_With_Options_Base
56
-     * @throws \EE_Error
57
-     */
58
-    public function get_input()
59
-    {
60
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
61
-            throw new EE_Error(
62
-                sprintf(
63
-                    esc_html__(
64
-                        'Can not use a Compound Input Display Strategy (eg checkbox or radio) with an input that doesn\'t have options',
65
-                        'event_espresso'
66
-                    )
67
-                )
68
-            );
69
-        }
70
-        return parent::get_input();
71
-    }
51
+	/**
52
+	 * Overrides parent to make sure this display strategy is only used with the
53
+	 * appropriate input type
54
+	 *
55
+	 * @return \EE_Form_Input_With_Options_Base
56
+	 * @throws \EE_Error
57
+	 */
58
+	public function get_input()
59
+	{
60
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
61
+			throw new EE_Error(
62
+				sprintf(
63
+					esc_html__(
64
+						'Can not use a Compound Input Display Strategy (eg checkbox or radio) with an input that doesn\'t have options',
65
+						'event_espresso'
66
+					)
67
+				)
68
+			);
69
+		}
70
+		return parent::get_input();
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function get_sub_input_id($option_value, $add_pound_sign = false)
27 27
     {
28
-        return $this->_append_chars($this->_input->html_id($add_pound_sign), '-') . sanitize_key($option_value);
28
+        return $this->_append_chars($this->_input->html_id($add_pound_sign), '-').sanitize_key($option_value);
29 29
     }
30 30
 
31 31
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function get_input()
59 59
     {
60
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
60
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
61 61
             throw new EE_Error(
62 62
                 sprintf(
63 63
                     esc_html__(
Please login to merge, or discard this patch.
strategies/validation/EE_Validation_Strategy_Base.strategy.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -12,97 +12,97 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    protected $_validation_error_message = '';
16
-
17
-
18
-
19
-    /**
20
-     * @param null $validation_error_message
21
-     */
22
-    public function __construct($validation_error_message = null)
23
-    {
24
-        $this->_validation_error_message = $validation_error_message === null
25
-            ? esc_html__('Input invalid', 'event_espresso')
26
-            : $validation_error_message;
27
-        parent::__construct();
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * Performs validation on the request data that corresponds to this field.
34
-     * If validation fails, should throw an EE_Validation_Error.
35
-     * Note: most validate() functions should allow $normalized_value to be empty,
36
-     * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty.
37
-     *
38
-     * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
39
-     *                                this validation strategy is the 'required' validation strategy,
40
-     *                                most should be OK with a null, empty string, etc)
41
-     */
42
-    public function validate($normalized_value)
43
-    {
44
-        // by default, the validation strategy does no validation. this should be implemented
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying.
51
-     * For documentation, see http://jqueryvalidation.org/
52
-     * Eg to generate the following js for validation, <br><code>
53
-     *  $( "#myform" ).validate({
54
-     *      rules: {
55
-     *          field_name: {
56
-     *              required: true,
57
-     *              minlength: 3,
58
-     *              equalTo: "#password"
59
-     *          }
60
-     *      }
61
-     *  });
62
-     * </code>
63
-     * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ).
64
-     * This is done so that if we are applying multiple sanitization strategies to a field,
65
-     * we can easily combine them.
66
-     *
67
-     * @return array
68
-     */
69
-    public function get_jquery_validation_rule_array()
70
-    {
71
-        return array();
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * Gets the i18n validation error message for when this validation strategy finds
78
-     * the input is invalid. Used for both frontend and backend validation.
79
-     *
80
-     * @return string
81
-     */
82
-    public function get_validation_error_message()
83
-    {
84
-        return $this->_validation_error_message;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * Adds js variables for localization to the $other_js_data. These should be put
91
-     * in each form's "other_data" javascript object.
92
-     *
93
-     * @param array $other_js_data
94
-     * @return array
95
-     */
96
-    public function get_other_js_data($other_js_data = array())
97
-    {
98
-        return $other_js_data;
99
-    }
100
-
101
-    /**
102
-     * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
103
-     * This should be called during wp_enqueue_scripts
104
-     */
105
-    public function enqueue_js()
106
-    {
107
-    }
15
+	protected $_validation_error_message = '';
16
+
17
+
18
+
19
+	/**
20
+	 * @param null $validation_error_message
21
+	 */
22
+	public function __construct($validation_error_message = null)
23
+	{
24
+		$this->_validation_error_message = $validation_error_message === null
25
+			? esc_html__('Input invalid', 'event_espresso')
26
+			: $validation_error_message;
27
+		parent::__construct();
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * Performs validation on the request data that corresponds to this field.
34
+	 * If validation fails, should throw an EE_Validation_Error.
35
+	 * Note: most validate() functions should allow $normalized_value to be empty,
36
+	 * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty.
37
+	 *
38
+	 * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
39
+	 *                                this validation strategy is the 'required' validation strategy,
40
+	 *                                most should be OK with a null, empty string, etc)
41
+	 */
42
+	public function validate($normalized_value)
43
+	{
44
+		// by default, the validation strategy does no validation. this should be implemented
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying.
51
+	 * For documentation, see http://jqueryvalidation.org/
52
+	 * Eg to generate the following js for validation, <br><code>
53
+	 *  $( "#myform" ).validate({
54
+	 *      rules: {
55
+	 *          field_name: {
56
+	 *              required: true,
57
+	 *              minlength: 3,
58
+	 *              equalTo: "#password"
59
+	 *          }
60
+	 *      }
61
+	 *  });
62
+	 * </code>
63
+	 * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ).
64
+	 * This is done so that if we are applying multiple sanitization strategies to a field,
65
+	 * we can easily combine them.
66
+	 *
67
+	 * @return array
68
+	 */
69
+	public function get_jquery_validation_rule_array()
70
+	{
71
+		return array();
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * Gets the i18n validation error message for when this validation strategy finds
78
+	 * the input is invalid. Used for both frontend and backend validation.
79
+	 *
80
+	 * @return string
81
+	 */
82
+	public function get_validation_error_message()
83
+	{
84
+		return $this->_validation_error_message;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * Adds js variables for localization to the $other_js_data. These should be put
91
+	 * in each form's "other_data" javascript object.
92
+	 *
93
+	 * @param array $other_js_data
94
+	 * @return array
95
+	 */
96
+	public function get_other_js_data($other_js_data = array())
97
+	{
98
+		return $other_js_data;
99
+	}
100
+
101
+	/**
102
+	 * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
103
+	 * This should be called during wp_enqueue_scripts
104
+	 */
105
+	public function enqueue_js()
106
+	{
107
+	}
108 108
 }
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_URL_Validation_Strategy.strategy.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -16,77 +16,77 @@
 block discarded – undo
16 16
 class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base
17 17
 {
18 18
 
19
-    /**
20
-     * @var @boolean whether we should check if the file exists or not
21
-     */
22
-    protected $check_file_exists;
19
+	/**
20
+	 * @var @boolean whether we should check if the file exists or not
21
+	 */
22
+	protected $check_file_exists;
23 23
 
24
-    /**
25
-     * @var URLValidator
26
-     */
27
-    protected $url_validator;
24
+	/**
25
+	 * @var URLValidator
26
+	 */
27
+	protected $url_validator;
28 28
 
29
-    /**
30
-     * @param null $validation_error_message
31
-     * @param boolean $check_file_exists
32
-     * @param URLValidator $url_validator
33
-     * @throws InvalidArgumentException
34
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
35
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
36
-     */
37
-    public function __construct(
38
-        $validation_error_message = null,
39
-        $check_file_exists = false,
40
-        URLValidator $url_validator = null
41
-    ) {
42
-        if (! $url_validator instanceof URLValidator) {
43
-            $url_validator = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\validators\URLValidator');
44
-        }
45
-        $this->url_validator = $url_validator;
46
-        if (! $validation_error_message) {
47
-            $validation_error_message = esc_html__("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
48
-        }
49
-        $this->check_file_exists = $check_file_exists;
50
-        parent::__construct($validation_error_message);
51
-    }
29
+	/**
30
+	 * @param null $validation_error_message
31
+	 * @param boolean $check_file_exists
32
+	 * @param URLValidator $url_validator
33
+	 * @throws InvalidArgumentException
34
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
35
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
36
+	 */
37
+	public function __construct(
38
+		$validation_error_message = null,
39
+		$check_file_exists = false,
40
+		URLValidator $url_validator = null
41
+	) {
42
+		if (! $url_validator instanceof URLValidator) {
43
+			$url_validator = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\validators\URLValidator');
44
+		}
45
+		$this->url_validator = $url_validator;
46
+		if (! $validation_error_message) {
47
+			$validation_error_message = esc_html__("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
48
+		}
49
+		$this->check_file_exists = $check_file_exists;
50
+		parent::__construct($validation_error_message);
51
+	}
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     * just checks the field isn't blank
57
-     *
58
-     * @param $normalized_value
59
-     * @return bool
60
-     * @throws \EE_Validation_Error
61
-     */
62
-    public function validate($normalized_value)
63
-    {
64
-        if ($normalized_value) {
65
-            if (! $this->url_validator->isValid($normalized_value)) {
66
-                throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
67
-            } elseif (apply_filters('FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', $this->check_file_exists, $this->_input)) {
68
-                if (
69
-                    ! EEH_URL::remote_file_exists(
70
-                        $normalized_value,
71
-                        array(
72
-                            'sslverify' => false,
73
-                            '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
74
-                        )
75
-                    )
76
-                ) {
77
-                    throw new EE_Validation_Error(sprintf(esc_html__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
78
-                }
79
-            }
80
-        }
81
-    }
55
+	/**
56
+	 * just checks the field isn't blank
57
+	 *
58
+	 * @param $normalized_value
59
+	 * @return bool
60
+	 * @throws \EE_Validation_Error
61
+	 */
62
+	public function validate($normalized_value)
63
+	{
64
+		if ($normalized_value) {
65
+			if (! $this->url_validator->isValid($normalized_value)) {
66
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
67
+			} elseif (apply_filters('FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', $this->check_file_exists, $this->_input)) {
68
+				if (
69
+					! EEH_URL::remote_file_exists(
70
+						$normalized_value,
71
+						array(
72
+							'sslverify' => false,
73
+							'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
74
+						)
75
+					)
76
+				) {
77
+					throw new EE_Validation_Error(sprintf(esc_html__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
78
+				}
79
+			}
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * @return array
87
-     */
88
-    public function get_jquery_validation_rule_array()
89
-    {
90
-        return array( 'validUrl' => true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
91
-    }
85
+	/**
86
+	 * @return array
87
+	 */
88
+	public function get_jquery_validation_rule_array()
89
+	{
90
+		return array( 'validUrl' => true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
         $check_file_exists = false,
40 40
         URLValidator $url_validator = null
41 41
     ) {
42
-        if (! $url_validator instanceof URLValidator) {
42
+        if ( ! $url_validator instanceof URLValidator) {
43 43
             $url_validator = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\validators\URLValidator');
44 44
         }
45 45
         $this->url_validator = $url_validator;
46
-        if (! $validation_error_message) {
46
+        if ( ! $validation_error_message) {
47 47
             $validation_error_message = esc_html__("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
48 48
         }
49 49
         $this->check_file_exists = $check_file_exists;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     public function validate($normalized_value)
63 63
     {
64 64
         if ($normalized_value) {
65
-            if (! $this->url_validator->isValid($normalized_value)) {
65
+            if ( ! $this->url_validator->isValid($normalized_value)) {
66 66
                 throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
67 67
             } elseif (apply_filters('FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', $this->check_file_exists, $this->_input)) {
68 68
                 if (
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $normalized_value,
71 71
                         array(
72 72
                             'sslverify' => false,
73
-                            '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
73
+                            '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
74 74
                         )
75 75
                     )
76 76
                 ) {
@@ -87,6 +87,6 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function get_jquery_validation_rule_array()
89 89
     {
90
-        return array( 'validUrl' => true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
90
+        return array('validUrl' => true, 'messages' => array('validUrl' => $this->get_validation_error_message()));
91 91
     }
92 92
 }
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_Int_Validation_Strategy.strategy.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@
 block discarded – undo
10 10
 class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param null $validation_error_message
15
-     */
16
-    public function __construct($validation_error_message = null)
17
-    {
18
-        if (! $validation_error_message) {
19
-            $validation_error_message = esc_html__("Only digits are allowed.", "event_espresso");
20
-        }
21
-        parent::__construct($validation_error_message);
22
-    }
23
-
24
-
25
-
26
-    /**
27
-     * @param $normalized_value
28
-     */
29
-    public function validate($normalized_value)
30
-    {
31
-        // this should have already been detected by the normalization strategy
32
-    }
33
-
34
-
35
-
36
-    /**
37
-     * @return array
38
-     */
39
-    public function get_jquery_validation_rule_array()
40
-    {
41
-        return array(
42
-            'number' => true,
43
-            'step' => 1,
44
-            'messages' => array(
45
-                'number' => $this->get_validation_error_message(),
46
-                'step' => $this->get_validation_error_message()
47
-            )
48
-        );
49
-    }
13
+	/**
14
+	 * @param null $validation_error_message
15
+	 */
16
+	public function __construct($validation_error_message = null)
17
+	{
18
+		if (! $validation_error_message) {
19
+			$validation_error_message = esc_html__("Only digits are allowed.", "event_espresso");
20
+		}
21
+		parent::__construct($validation_error_message);
22
+	}
23
+
24
+
25
+
26
+	/**
27
+	 * @param $normalized_value
28
+	 */
29
+	public function validate($normalized_value)
30
+	{
31
+		// this should have already been detected by the normalization strategy
32
+	}
33
+
34
+
35
+
36
+	/**
37
+	 * @return array
38
+	 */
39
+	public function get_jquery_validation_rule_array()
40
+	{
41
+		return array(
42
+			'number' => true,
43
+			'step' => 1,
44
+			'messages' => array(
45
+				'number' => $this->get_validation_error_message(),
46
+				'step' => $this->get_validation_error_message()
47
+			)
48
+		);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      */
16 16
     public function __construct($validation_error_message = null)
17 17
     {
18
-        if (! $validation_error_message) {
18
+        if ( ! $validation_error_message) {
19 19
             $validation_error_message = esc_html__("Only digits are allowed.", "event_espresso");
20 20
         }
21 21
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.
strategies/validation/EE_Full_HTML_Validation_Strategy.strategy.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -14,62 +14,62 @@
 block discarded – undo
14 14
 class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param null $validation_error_message
19
-     */
20
-    public function __construct($validation_error_message = null)
21
-    {
22
-        if (! $validation_error_message) {
23
-            $validation_error_message = sprintf(
24
-                esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
25
-                '<br />',
26
-                $this->get_list_of_allowed_tags()
27
-            );
28
-        }
29
-        parent::__construct($validation_error_message);
30
-    }
17
+	/**
18
+	 * @param null $validation_error_message
19
+	 */
20
+	public function __construct($validation_error_message = null)
21
+	{
22
+		if (! $validation_error_message) {
23
+			$validation_error_message = sprintf(
24
+				esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
25
+				'<br />',
26
+				$this->get_list_of_allowed_tags()
27
+			);
28
+		}
29
+		parent::__construct($validation_error_message);
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
-        $tags_we_allow = $this->getAllowedTags();
43
-        ksort($tags_we_allow);
44
-        return implode(', ', array_keys($tags_we_allow));
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
+		$tags_we_allow = $this->getAllowedTags();
43
+		ksort($tags_we_allow);
44
+		return implode(', ', array_keys($tags_we_allow));
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * Returns an array whose keys are allowed tags and values are an array of allowed attributes
50
-     *
51
-     * @return array
52
-     */
53
-    protected function getAllowedTags()
54
-    {
55
-        global $allowedposttags;
56
-        return array_merge_recursive(
57
-            $allowedposttags,
58
-            EEH_HTML::get_simple_tags()
59
-        );
60
-    }
48
+	/**
49
+	 * Returns an array whose keys are allowed tags and values are an array of allowed attributes
50
+	 *
51
+	 * @return array
52
+	 */
53
+	protected function getAllowedTags()
54
+	{
55
+		global $allowedposttags;
56
+		return array_merge_recursive(
57
+			$allowedposttags,
58
+			EEH_HTML::get_simple_tags()
59
+		);
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @param $normalized_value
65
-     * @throws \EE_Validation_Error
66
-     */
67
-    public function validate($normalized_value)
68
-    {
69
-        parent::validate($normalized_value);
70
-        $normalized_value_sans_tags = wp_kses("$normalized_value", $this->getAllowedTags());
71
-        if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
72
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
73
-        }
74
-    }
63
+	/**
64
+	 * @param $normalized_value
65
+	 * @throws \EE_Validation_Error
66
+	 */
67
+	public function validate($normalized_value)
68
+	{
69
+		parent::validate($normalized_value);
70
+		$normalized_value_sans_tags = wp_kses("$normalized_value", $this->getAllowedTags());
71
+		if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
72
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
73
+		}
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validation_error_message = null)
21 21
     {
22
-        if (! $validation_error_message) {
22
+        if ( ! $validation_error_message) {
23 23
             $validation_error_message = sprintf(
24 24
                 esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
25 25
                 '<br />',
Please login to merge, or discard this patch.
strategies/validation/EE_Credit_Card_Validation_Strategy.strategy.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
 class EE_Credit_Card_Validation_Strategy extends EE_Text_Validation_Strategy
15 15
 {
16 16
 
17
-    /**
18
-     * @param null $validation_error_message
19
-     */
20
-    public function __construct($validation_error_message = null)
21
-    {
22
-        if (! $validation_error_message) {
23
-            $validation_error_message = esc_html__("Please enter a valid credit card number", "event_espresso");
24
-        }
25
-        parent::__construct(
26
-            $validation_error_message,
27
-            // @codingStandardsIgnoreStart
28
-            '~^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|2[2-7][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$~'
29
-            // @codingStandardsIgnoreEnd
30
-        );
31
-    }
17
+	/**
18
+	 * @param null $validation_error_message
19
+	 */
20
+	public function __construct($validation_error_message = null)
21
+	{
22
+		if (! $validation_error_message) {
23
+			$validation_error_message = esc_html__("Please enter a valid credit card number", "event_espresso");
24
+		}
25
+		parent::__construct(
26
+			$validation_error_message,
27
+			// @codingStandardsIgnoreStart
28
+			'~^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|2[2-7][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$~'
29
+			// @codingStandardsIgnoreEnd
30
+		);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validation_error_message = null)
21 21
     {
22
-        if (! $validation_error_message) {
22
+        if ( ! $validation_error_message) {
23 23
             $validation_error_message = esc_html__("Please enter a valid credit card number", "event_espresso");
24 24
         }
25 25
         parent::__construct(
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
@@ -12,51 +12,51 @@
 block discarded – undo
12 12
 class EE_Enum_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14 14
 
15
-    /**
16
-     * Check that the value is in the allowed list
17
-     * @param $normalized_value
18
-     * @throws EE_Error
19
-     * @throws EE_Validation_Error
20
-     * @return boolean
21
-     */
22
-    public function validate($normalized_value)
23
-    {
24
-        parent::validate($normalized_value);
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
-            throw new EE_Error(sprintf(esc_html__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
27
-        }
28
-        $enum_options = $this->_input->flat_options();
29
-        if ($normalized_value === true) {
30
-            $normalized_value = 1;
31
-        } elseif ($normalized_value === false) {
32
-            $normalized_value = 0;
33
-        }
34
-        if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
35
-            throw new EE_Validation_Error(
36
-                $this->get_validation_error_message(),
37
-                'invalid_enum_value'
38
-            );
39
-        } else {
40
-            return true;
41
-        }
42
-    }
15
+	/**
16
+	 * Check that the value is in the allowed list
17
+	 * @param $normalized_value
18
+	 * @throws EE_Error
19
+	 * @throws EE_Validation_Error
20
+	 * @return boolean
21
+	 */
22
+	public function validate($normalized_value)
23
+	{
24
+		parent::validate($normalized_value);
25
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
+			throw new EE_Error(sprintf(esc_html__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
27
+		}
28
+		$enum_options = $this->_input->flat_options();
29
+		if ($normalized_value === true) {
30
+			$normalized_value = 1;
31
+		} elseif ($normalized_value === false) {
32
+			$normalized_value = 0;
33
+		}
34
+		if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
35
+			throw new EE_Validation_Error(
36
+				$this->get_validation_error_message(),
37
+				'invalid_enum_value'
38
+			);
39
+		} else {
40
+			return true;
41
+		}
42
+	}
43 43
 
44
-    /**
45
-     * If we are using the default validation error message, make it dynamic based
46
-     * on the allowed options.
47
-     * @return string
48
-     */
49
-    public function get_validation_error_message()
50
-    {
51
-        $parent_validation_error_message = parent::get_validation_error_message();
52
-        if (! $parent_validation_error_message) {
53
-            $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
54
-            return sprintf(
55
-                esc_html__("This is not allowed option. Allowed options are %s.", "event_espresso"),
56
-                implode(', ', $enum_options)
57
-            );
58
-        } else {
59
-            return $parent_validation_error_message;
60
-        }
61
-    }
44
+	/**
45
+	 * If we are using the default validation error message, make it dynamic based
46
+	 * on the allowed options.
47
+	 * @return string
48
+	 */
49
+	public function get_validation_error_message()
50
+	{
51
+		$parent_validation_error_message = parent::get_validation_error_message();
52
+		if (! $parent_validation_error_message) {
53
+			$enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
54
+			return sprintf(
55
+				esc_html__("This is not allowed option. Allowed options are %s.", "event_espresso"),
56
+				implode(', ', $enum_options)
57
+			);
58
+		} else {
59
+			return $parent_validation_error_message;
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
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function validate($normalized_value)
23 23
     {
24 24
         parent::validate($normalized_value);
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26 26
             throw new EE_Error(sprintf(esc_html__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
27 27
         }
28 28
         $enum_options = $this->_input->flat_options();
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function get_validation_error_message()
50 50
     {
51 51
         $parent_validation_error_message = parent::get_validation_error_message();
52
-        if (! $parent_validation_error_message) {
52
+        if ( ! $parent_validation_error_message) {
53 53
             $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
54 54
             return sprintf(
55 55
                 esc_html__("This is not allowed option. Allowed options are %s.", "event_espresso"),
Please login to merge, or discard this patch.
strategies/validation/EE_Required_Validation_Strategy.strategy.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-    /**
18
-     * @param string $validation_error_message
19
-     */
20
-    public function __construct($validation_error_message = null)
21
-    {
22
-        if (! $validation_error_message) {
23
-            $validation_error_message = esc_html__("This field is required.", "event_espresso");
24
-        }
25
-        parent::__construct($validation_error_message);
26
-    }
17
+	/**
18
+	 * @param string $validation_error_message
19
+	 */
20
+	public function __construct($validation_error_message = null)
21
+	{
22
+		if (! $validation_error_message) {
23
+			$validation_error_message = esc_html__("This field is required.", "event_espresso");
24
+		}
25
+		parent::__construct($validation_error_message);
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * just checks the field isn't blank, provided the requirement conditions
32
-     * indicate this input is still required
33
-     *
34
-     * @param $normalized_value
35
-     * @return bool
36
-     * @throws \EE_Error
37
-     * @throws \EE_Validation_Error
38
-     */
39
-    public function validate($normalized_value)
40
-    {
41
-        if (
42
-            $normalized_value === ''
43
-            || $normalized_value === null
44
-            || $normalized_value === array()
45
-        ) {
46
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
47
-        } else {
48
-            return true;
49
-        }
50
-    }
30
+	/**
31
+	 * just checks the field isn't blank, provided the requirement conditions
32
+	 * indicate this input is still required
33
+	 *
34
+	 * @param $normalized_value
35
+	 * @return bool
36
+	 * @throws \EE_Error
37
+	 * @throws \EE_Validation_Error
38
+	 */
39
+	public function validate($normalized_value)
40
+	{
41
+		if (
42
+			$normalized_value === ''
43
+			|| $normalized_value === null
44
+			|| $normalized_value === array()
45
+		) {
46
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
47
+		} else {
48
+			return true;
49
+		}
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * @return array
56
-     * @throws \EE_Error
57
-     */
58
-    public function get_jquery_validation_rule_array()
59
-    {
60
-        return array(
61
-            'required' => true,
62
-            'messages' => array(
63
-                'required' => $this->get_validation_error_message()
64
-            )
65
-        );
66
-    }
54
+	/**
55
+	 * @return array
56
+	 * @throws \EE_Error
57
+	 */
58
+	public function get_jquery_validation_rule_array()
59
+	{
60
+		return array(
61
+			'required' => true,
62
+			'messages' => array(
63
+				'required' => $this->get_validation_error_message()
64
+			)
65
+		);
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validation_error_message = null)
21 21
     {
22
-        if (! $validation_error_message) {
22
+        if ( ! $validation_error_message) {
23 23
             $validation_error_message = esc_html__("This field is required.", "event_espresso");
24 24
         }
25 25
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.