Completed
Branch BUG/3575-event-deletion-previe... (bbeda1)
by
unknown
06:40 queued 04:49
created
strategies/validation/EE_Float_Validation_Strategy.strategy.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,36 +12,36 @@
 block discarded – undo
12 12
 class EE_Float_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @param null $validation_error_message
17
-     */
18
-    public function __construct($validation_error_message = null)
19
-    {
20
-        if (! $validation_error_message) {
21
-            $validation_error_message = sprintf(esc_html__("Only numeric characters, commas, periods, and spaces, please!", "event_espresso"));
22
-        }
23
-        parent::__construct($validation_error_message);
24
-    }
25
-
26
-
27
-
28
-    /**
29
-     *
30
-     * @param $normalized_value
31
-     * @return bool
32
-     */
33
-    public function validate($normalized_value)
34
-    {
35
-        // errors should have been detected by the normalization strategy
36
-    }
37
-
38
-
39
-
40
-    /**
41
-     * @return array
42
-     */
43
-    public function get_jquery_validation_rule_array()
44
-    {
45
-        return array('number' => true, 'messages' => array( 'number' => $this->get_validation_error_message() ) );
46
-    }
15
+	/**
16
+	 * @param null $validation_error_message
17
+	 */
18
+	public function __construct($validation_error_message = null)
19
+	{
20
+		if (! $validation_error_message) {
21
+			$validation_error_message = sprintf(esc_html__("Only numeric characters, commas, periods, and spaces, please!", "event_espresso"));
22
+		}
23
+		parent::__construct($validation_error_message);
24
+	}
25
+
26
+
27
+
28
+	/**
29
+	 *
30
+	 * @param $normalized_value
31
+	 * @return bool
32
+	 */
33
+	public function validate($normalized_value)
34
+	{
35
+		// errors should have been detected by the normalization strategy
36
+	}
37
+
38
+
39
+
40
+	/**
41
+	 * @return array
42
+	 */
43
+	public function get_jquery_validation_rule_array()
44
+	{
45
+		return array('number' => true, 'messages' => array( 'number' => $this->get_validation_error_message() ) );
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function __construct($validation_error_message = null)
19 19
     {
20
-        if (! $validation_error_message) {
20
+        if ( ! $validation_error_message) {
21 21
             $validation_error_message = sprintf(esc_html__("Only numeric characters, commas, periods, and spaces, please!", "event_espresso"));
22 22
         }
23 23
         parent::__construct($validation_error_message);
@@ -42,6 +42,6 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function get_jquery_validation_rule_array()
44 44
     {
45
-        return array('number' => true, 'messages' => array( 'number' => $this->get_validation_error_message() ) );
45
+        return array('number' => true, 'messages' => array('number' => $this->get_validation_error_message()));
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Simple_HTML_Validation_Strategy.strategy.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -14,57 +14,57 @@
 block discarded – undo
14 14
 class EE_Simple_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
-            $allowedtags = $this->_get_allowed_tags();
24
-            $validation_error_message = sprintf(esc_html__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags)));
25
-        }
26
-        parent::__construct($validation_error_message);
27
-    }
17
+	/**
18
+	 * @param null $validation_error_message
19
+	 */
20
+	public function __construct($validation_error_message = null)
21
+	{
22
+		if (! $validation_error_message) {
23
+			$allowedtags = $this->_get_allowed_tags();
24
+			$validation_error_message = sprintf(esc_html__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags)));
25
+		}
26
+		parent::__construct($validation_error_message);
27
+	}
28 28
 
29 29
 
30 30
 
31
-    /**
32
-     * get tags allowed
33
-     */
34
-    protected function _get_allowed_tags()
35
-    {
36
-        return EEH_HTML::get_simple_tags();
37
-    }
31
+	/**
32
+	 * get tags allowed
33
+	 */
34
+	protected function _get_allowed_tags()
35
+	{
36
+		return EEH_HTML::get_simple_tags();
37
+	}
38 38
 
39 39
 
40 40
 
41
-    /**
42
-     * add_more_tags
43
-     *
44
-     * generates and returns a string that lists the top-level HTML tags that are allowable for this input
45
-     *
46
-     * @return string
47
-     */
48
-    public function get_list_of_allowed_tags()
49
-    {
50
-        $allowed_tags = $this->_get_allowed_tags();
51
-        ksort($allowed_tags);
52
-        return implode(', ', array_keys($allowed_tags));
53
-    }
41
+	/**
42
+	 * add_more_tags
43
+	 *
44
+	 * generates and returns a string that lists the top-level HTML tags that are allowable for this input
45
+	 *
46
+	 * @return string
47
+	 */
48
+	public function get_list_of_allowed_tags()
49
+	{
50
+		$allowed_tags = $this->_get_allowed_tags();
51
+		ksort($allowed_tags);
52
+		return implode(', ', array_keys($allowed_tags));
53
+	}
54 54
 
55 55
 
56 56
 
57
-    /**
58
-     * @param $normalized_value
59
-     * @throws \EE_Validation_Error
60
-     */
61
-    public function validate($normalized_value)
62
-    {
63
-        $allowedtags = $this->_get_allowed_tags();
64
-        parent::validate($normalized_value);
65
-        $normalized_value_sans_tags =  wp_kses("$normalized_value", $allowedtags);
66
-        if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
67
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
68
-        }
69
-    }
57
+	/**
58
+	 * @param $normalized_value
59
+	 * @throws \EE_Validation_Error
60
+	 */
61
+	public function validate($normalized_value)
62
+	{
63
+		$allowedtags = $this->_get_allowed_tags();
64
+		parent::validate($normalized_value);
65
+		$normalized_value_sans_tags =  wp_kses("$normalized_value", $allowedtags);
66
+		if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
67
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
68
+		}
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 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
             $allowedtags = $this->_get_allowed_tags();
24 24
             $validation_error_message = sprintf(esc_html__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags)));
25 25
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $allowedtags = $this->_get_allowed_tags();
64 64
         parent::validate($normalized_value);
65
-        $normalized_value_sans_tags =  wp_kses("$normalized_value", $allowedtags);
65
+        $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedtags);
66 66
         if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
67 67
             throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
68 68
         }
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Float_Normalization.strategy.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,84 +11,84 @@
 block discarded – undo
11 11
 class EE_Float_Normalization extends EE_Normalization_Strategy_Base
12 12
 {
13 13
 
14
-    /*
14
+	/*
15 15
      * regex pattern that matches for the following:
16 16
      *      * optional negative sign
17 17
      *      * one or more digits or decimals
18 18
      */
19
-    const REGEX = '/^(-?)([\d.]+)$/';
19
+	const REGEX = '/^(-?)([\d.]+)$/';
20 20
 
21 21
 
22 22
 
23
-    /**
24
-     * @param string $value_to_normalize
25
-     * @return float
26
-     * @throws \EE_Validation_Error
27
-     */
28
-    public function normalize($value_to_normalize)
29
-    {
30
-        if ($value_to_normalize === null) {
31
-            return null;
32
-        }
33
-        if (is_float($value_to_normalize) || is_int($value_to_normalize)) {
34
-            return (float) $value_to_normalize;
35
-        }
36
-        if (! is_string($value_to_normalize)) {
37
-            throw new EE_Validation_Error(
38
-                sprintf(
39
-                    esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
40
-                    print_r($value_to_normalize, true),
41
-                    gettype($value_to_normalize)
42
-                )
43
-            );
44
-        }
45
-        $normalized_value = filter_var(
46
-            $value_to_normalize,
47
-            FILTER_SANITIZE_NUMBER_FLOAT,
48
-            FILTER_FLAG_ALLOW_FRACTION
49
-        );
50
-        if ($normalized_value === '') {
51
-            return null;
52
-        }
53
-        if (preg_match(EE_Float_Normalization::REGEX, $normalized_value, $matches)) {
54
-            if (count($matches) === 3) {
55
-                // if first match is the negative sign,
56
-                // then the number needs to be multiplied by -1 to remain negative
57
-                return $matches[1] === '-'
58
-                    ? (float) $matches[2] * -1
59
-                    : (float) $matches[2];
60
-            }
61
-        }
62
-        // find if this input has a float validation strategy
63
-        // in which case, use its message
64
-        $validation_error_message = null;
65
-        foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
66
-            if ($validation_strategy instanceof EE_Float_Validation_Strategy) {
67
-                $validation_error_message = $validation_strategy->get_validation_error_message();
68
-            }
69
-        }
70
-        // this really shouldn't ever happen because fields with a float normalization strategy
71
-        // should also have a float validation strategy, but in case it doesn't use the default
72
-        if (! $validation_error_message) {
73
-            $default_validation_strategy = new EE_Float_Validation_Strategy();
74
-            $validation_error_message = $default_validation_strategy->get_validation_error_message();
75
-        }
76
-        throw new EE_Validation_Error($validation_error_message, 'float_only');
77
-    }
23
+	/**
24
+	 * @param string $value_to_normalize
25
+	 * @return float
26
+	 * @throws \EE_Validation_Error
27
+	 */
28
+	public function normalize($value_to_normalize)
29
+	{
30
+		if ($value_to_normalize === null) {
31
+			return null;
32
+		}
33
+		if (is_float($value_to_normalize) || is_int($value_to_normalize)) {
34
+			return (float) $value_to_normalize;
35
+		}
36
+		if (! is_string($value_to_normalize)) {
37
+			throw new EE_Validation_Error(
38
+				sprintf(
39
+					esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
40
+					print_r($value_to_normalize, true),
41
+					gettype($value_to_normalize)
42
+				)
43
+			);
44
+		}
45
+		$normalized_value = filter_var(
46
+			$value_to_normalize,
47
+			FILTER_SANITIZE_NUMBER_FLOAT,
48
+			FILTER_FLAG_ALLOW_FRACTION
49
+		);
50
+		if ($normalized_value === '') {
51
+			return null;
52
+		}
53
+		if (preg_match(EE_Float_Normalization::REGEX, $normalized_value, $matches)) {
54
+			if (count($matches) === 3) {
55
+				// if first match is the negative sign,
56
+				// then the number needs to be multiplied by -1 to remain negative
57
+				return $matches[1] === '-'
58
+					? (float) $matches[2] * -1
59
+					: (float) $matches[2];
60
+			}
61
+		}
62
+		// find if this input has a float validation strategy
63
+		// in which case, use its message
64
+		$validation_error_message = null;
65
+		foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
66
+			if ($validation_strategy instanceof EE_Float_Validation_Strategy) {
67
+				$validation_error_message = $validation_strategy->get_validation_error_message();
68
+			}
69
+		}
70
+		// this really shouldn't ever happen because fields with a float normalization strategy
71
+		// should also have a float validation strategy, but in case it doesn't use the default
72
+		if (! $validation_error_message) {
73
+			$default_validation_strategy = new EE_Float_Validation_Strategy();
74
+			$validation_error_message = $default_validation_strategy->get_validation_error_message();
75
+		}
76
+		throw new EE_Validation_Error($validation_error_message, 'float_only');
77
+	}
78 78
 
79 79
 
80 80
 
81
-    /**
82
-     * Converts a float into a string
83
-     *
84
-     * @param float $normalized_value
85
-     * @return string
86
-     */
87
-    public function unnormalize($normalized_value)
88
-    {
89
-        if (empty($normalized_value)) {
90
-            return '0.00';
91
-        }
92
-        return "{$normalized_value}";
93
-    }
81
+	/**
82
+	 * Converts a float into a string
83
+	 *
84
+	 * @param float $normalized_value
85
+	 * @return string
86
+	 */
87
+	public function unnormalize($normalized_value)
88
+	{
89
+		if (empty($normalized_value)) {
90
+			return '0.00';
91
+		}
92
+		return "{$normalized_value}";
93
+	}
94 94
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         if (is_float($value_to_normalize) || is_int($value_to_normalize)) {
34 34
             return (float) $value_to_normalize;
35 35
         }
36
-        if (! is_string($value_to_normalize)) {
36
+        if ( ! is_string($value_to_normalize)) {
37 37
             throw new EE_Validation_Error(
38 38
                 sprintf(
39 39
                     esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         }
70 70
         // this really shouldn't ever happen because fields with a float normalization strategy
71 71
         // should also have a float validation strategy, but in case it doesn't use the default
72
-        if (! $validation_error_message) {
72
+        if ( ! $validation_error_message) {
73 73
             $default_validation_strategy = new EE_Float_Validation_Strategy();
74 74
             $validation_error_message = $default_validation_strategy->get_validation_error_message();
75 75
         }
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -11,88 +11,88 @@
 block discarded – undo
11 11
 class EE_Int_Normalization extends EE_Normalization_Strategy_Base
12 12
 {
13 13
 
14
-    /*
14
+	/*
15 15
      * regex pattern that matches for the following:
16 16
      *      * optional negative sign
17 17
      *      * one or more digits
18 18
      */
19
-    const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
19
+	const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
20 20
 
21 21
 
22 22
 
23
-    /**
24
-     * @param string $value_to_normalize
25
-     * @return int|mixed|string
26
-     * @throws \EE_Validation_Error
27
-     */
28
-    public function normalize($value_to_normalize)
29
-    {
30
-        if ($value_to_normalize === null) {
31
-            return null;
32
-        }
33
-        if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
34
-            return (int) $value_to_normalize;
35
-        }
36
-        if (! is_string($value_to_normalize)) {
37
-            throw new EE_Validation_Error(
38
-                sprintf(
39
-                    esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
40
-                    print_r($value_to_normalize, true),
41
-                    gettype($value_to_normalize)
42
-                )
43
-            );
44
-        }
45
-        $value_to_normalize = filter_var(
46
-            $value_to_normalize,
47
-            FILTER_SANITIZE_NUMBER_FLOAT,
48
-            FILTER_FLAG_ALLOW_FRACTION
49
-        );
50
-        if ($value_to_normalize === '') {
51
-            return null;
52
-        }
53
-        $matches = array();
54
-        if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
55
-            if (count($matches) === 3) {
56
-                // if first match is the negative sign,
57
-                // then the number needs to be multiplied by -1 to remain negative
58
-                return $matches[1] === '-'
59
-                    ? (int) $matches[2] * -1
60
-                    : (int) $matches[2];
61
-            }
62
-        }
63
-        // find if this input has a int validation strategy
64
-        // in which case, use its message
65
-        $validation_error_message = null;
66
-        foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
67
-            if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
68
-                $validation_error_message = $validation_strategy->get_validation_error_message();
69
-            }
70
-        }
71
-        // this really shouldn't ever happen because fields with a int normalization strategy
72
-        // should also have a int validation strategy, but in case it doesn't use the default
73
-        if (! $validation_error_message) {
74
-            $default_validation_strategy = new EE_Int_Validation_Strategy();
75
-            $validation_error_message = $default_validation_strategy->get_validation_error_message();
76
-        }
77
-        throw new EE_Validation_Error($validation_error_message, 'numeric_only');
78
-    }
23
+	/**
24
+	 * @param string $value_to_normalize
25
+	 * @return int|mixed|string
26
+	 * @throws \EE_Validation_Error
27
+	 */
28
+	public function normalize($value_to_normalize)
29
+	{
30
+		if ($value_to_normalize === null) {
31
+			return null;
32
+		}
33
+		if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
34
+			return (int) $value_to_normalize;
35
+		}
36
+		if (! is_string($value_to_normalize)) {
37
+			throw new EE_Validation_Error(
38
+				sprintf(
39
+					esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
40
+					print_r($value_to_normalize, true),
41
+					gettype($value_to_normalize)
42
+				)
43
+			);
44
+		}
45
+		$value_to_normalize = filter_var(
46
+			$value_to_normalize,
47
+			FILTER_SANITIZE_NUMBER_FLOAT,
48
+			FILTER_FLAG_ALLOW_FRACTION
49
+		);
50
+		if ($value_to_normalize === '') {
51
+			return null;
52
+		}
53
+		$matches = array();
54
+		if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
55
+			if (count($matches) === 3) {
56
+				// if first match is the negative sign,
57
+				// then the number needs to be multiplied by -1 to remain negative
58
+				return $matches[1] === '-'
59
+					? (int) $matches[2] * -1
60
+					: (int) $matches[2];
61
+			}
62
+		}
63
+		// find if this input has a int validation strategy
64
+		// in which case, use its message
65
+		$validation_error_message = null;
66
+		foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
67
+			if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
68
+				$validation_error_message = $validation_strategy->get_validation_error_message();
69
+			}
70
+		}
71
+		// this really shouldn't ever happen because fields with a int normalization strategy
72
+		// should also have a int validation strategy, but in case it doesn't use the default
73
+		if (! $validation_error_message) {
74
+			$default_validation_strategy = new EE_Int_Validation_Strategy();
75
+			$validation_error_message = $default_validation_strategy->get_validation_error_message();
76
+		}
77
+		throw new EE_Validation_Error($validation_error_message, 'numeric_only');
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * Converts the int into a string for use in teh html form
84
-     *
85
-     * @param int $normalized_value
86
-     * @return string
87
-     */
88
-    public function unnormalize($normalized_value)
89
-    {
90
-        if ($normalized_value === null || $normalized_value === '') {
91
-            return '';
92
-        }
93
-        if (empty($normalized_value)) {
94
-            return '0';
95
-        }
96
-        return "$normalized_value";
97
-    }
82
+	/**
83
+	 * Converts the int into a string for use in teh html form
84
+	 *
85
+	 * @param int $normalized_value
86
+	 * @return string
87
+	 */
88
+	public function unnormalize($normalized_value)
89
+	{
90
+		if ($normalized_value === null || $normalized_value === '') {
91
+			return '';
92
+		}
93
+		if (empty($normalized_value)) {
94
+			return '0';
95
+		}
96
+		return "$normalized_value";
97
+	}
98 98
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
34 34
             return (int) $value_to_normalize;
35 35
         }
36
-        if (! is_string($value_to_normalize)) {
36
+        if ( ! is_string($value_to_normalize)) {
37 37
             throw new EE_Validation_Error(
38 38
                 sprintf(
39 39
                     esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         }
71 71
         // this really shouldn't ever happen because fields with a int normalization strategy
72 72
         // should also have a int validation strategy, but in case it doesn't use the default
73
-        if (! $validation_error_message) {
73
+        if ( ! $validation_error_message) {
74 74
             $default_validation_strategy = new EE_Int_Validation_Strategy();
75 75
             $validation_error_message = $default_validation_strategy->get_validation_error_message();
76 76
         }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 2 patches
Indentation   +1257 added lines, -1257 removed lines patch added patch discarded remove patch
@@ -15,1261 +15,1261 @@
 block discarded – undo
15 15
 abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable
16 16
 {
17 17
 
18
-    /**
19
-     * the input's name attribute
20
-     *
21
-     * @var string
22
-     */
23
-    protected $_html_name;
24
-
25
-    /**
26
-     * id for the html label tag
27
-     *
28
-     * @var string
29
-     */
30
-    protected $_html_label_id;
31
-
32
-    /**
33
-     * class for teh html label tag
34
-     *
35
-     * @var string
36
-     */
37
-    protected $_html_label_class;
38
-
39
-    /**
40
-     * style for teh html label tag
41
-     *
42
-     * @var string
43
-     */
44
-    protected $_html_label_style;
45
-
46
-    /**
47
-     * text to be placed in the html label
48
-     *
49
-     * @var string
50
-     */
51
-    protected $_html_label_text;
52
-
53
-    /**
54
-     * the full html label. If used, all other html_label_* properties are invalid
55
-     *
56
-     * @var string
57
-     */
58
-    protected $_html_label;
59
-
60
-    /**
61
-     * HTML to use for help text (normally placed below form input), in a span which normally
62
-     * has a class of 'description'
63
-     *
64
-     * @var string
65
-     */
66
-    protected $_html_help_text;
67
-
68
-    /**
69
-     * CSS classes for displaying the help span
70
-     *
71
-     * @var string
72
-     */
73
-    protected $_html_help_class = 'description';
74
-
75
-    /**
76
-     * CSS to put in the style attribute on the help span
77
-     *
78
-     * @var string
79
-     */
80
-    protected $_html_help_style;
81
-
82
-    /**
83
-     * Stores whether or not this input's response is required.
84
-     * Because certain styling elements may also want to know that this
85
-     * input is required etc.
86
-     *
87
-     * @var boolean
88
-     */
89
-    protected $_required;
90
-
91
-    /**
92
-     * css class added to required inputs
93
-     *
94
-     * @var string
95
-     */
96
-    protected $_required_css_class = 'ee-required';
97
-
98
-    /**
99
-     * css styles applied to button type inputs
100
-     *
101
-     * @var string
102
-     */
103
-    protected $_button_css_attributes;
104
-
105
-    /**
106
-     * The raw post data submitted for this
107
-     * Generally unsafe for usage in client code
108
-     *
109
-     * @var mixed string or array
110
-     */
111
-    protected $_raw_value;
112
-
113
-    /**
114
-     * Value normalized according to the input's normalization strategy.
115
-     * The normalization strategy dictates whether this is a string, int, float,
116
-     * boolean, or array of any of those.
117
-     *
118
-     * @var mixed
119
-     */
120
-    protected $_normalized_value;
121
-
122
-
123
-    /**
124
-     * Normalized default value either initially set on the input, or provided by calling
125
-     * set_default().
126
-     * @var mixed
127
-     */
128
-    protected $_default;
129
-
130
-    /**
131
-     * Strategy used for displaying this field.
132
-     * Child classes must use _get_display_strategy to access it.
133
-     *
134
-     * @var EE_Display_Strategy_Base
135
-     */
136
-    private $_display_strategy;
137
-
138
-    /**
139
-     * Gets all the validation strategies used on this field
140
-     *
141
-     * @var EE_Validation_Strategy_Base[]
142
-     */
143
-    private $_validation_strategies = array();
144
-
145
-    /**
146
-     * The normalization strategy for this field
147
-     *
148
-     * @var EE_Normalization_Strategy_Base
149
-     */
150
-    private $_normalization_strategy;
151
-
152
-    /**
153
-     * Strategy for removing sensitive data after we're done with the form input
154
-     *
155
-     * @var EE_Sensitive_Data_Removal_Base
156
-     */
157
-    protected $_sensitive_data_removal_strategy;
158
-
159
-    /**
160
-     * Whether this input has been disabled or not.
161
-     * If it's disabled while rendering, an extra hidden input is added that indicates it has been knowingly disabled.
162
-     * (Client-side code that wants to dynamically disable it must also add this hidden input).
163
-     * When the form is submitted, if the input is disabled in the PHP form section, then input is ignored.
164
-     * If the input is missing from the request data but the hidden input indicating the input is disabled, then the input is again ignored.
165
-     *
166
-     * @var boolean
167
-     */
168
-    protected $disabled = false;
169
-
170
-
171
-
172
-    /**
173
-     * @param array                         $input_args       {
174
-     * @type string                         $html_name        the html name for the input
175
-     * @type string                         $html_label_id    the id attribute to give to the html label tag
176
-     * @type string                         $html_label_class the class attribute to give to the html label tag
177
-     * @type string                         $html_label_style the style attribute to give ot teh label tag
178
-     * @type string                         $html_label_text  the text to put in the label tag
179
-     * @type string                         $html_label       the full html label. If used,
180
-     *                                                        all other html_label_* args are invalid
181
-     * @type string                         $html_help_text   text to put in help element
182
-     * @type string                         $html_help_style  style attribute to give to teh help element
183
-     * @type string                         $html_help_class  class attribute to give to the help element
184
-     * @type string                         $default          default value NORMALIZED (eg, if providing the default
185
-     *       for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0')
186
-     * @type EE_Display_Strategy_Base       $display          strategy
187
-     * @type EE_Normalization_Strategy_Base $normalization_strategy
188
-     * @type EE_Validation_Strategy_Base[]  $validation_strategies
189
-     * @type boolean                        $ignore_input special argument which can be used to avoid adding any validation strategies,
190
-     *                                                    and sets the normalization strategy to the Null normalization. This is good
191
-     *                                                    when you want the input to be totally ignored server-side (like when using
192
-     *                                                    React.js form inputs)
193
-     *                                                        }
194
-     */
195
-    public function __construct($input_args = array())
196
-    {
197
-        $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
198
-        // the following properties must be cast as arrays
199
-        if (isset($input_args['validation_strategies'])) {
200
-            foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
201
-                if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
202
-                    $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
203
-                }
204
-            }
205
-            unset($input_args['validation_strategies']);
206
-        }
207
-        if (isset($input_args['ignore_input'])) {
208
-            $this->_validation_strategies = array();
209
-        }
210
-        // loop thru incoming options
211
-        foreach ($input_args as $key => $value) {
212
-            // add underscore to $key to match property names
213
-            $_key = '_' . $key;
214
-            if (property_exists($this, $_key)) {
215
-                $this->{$_key} = $value;
216
-            }
217
-        }
218
-        // ensure that "required" is set correctly
219
-        $this->set_required(
220
-            $this->_required,
221
-            isset($input_args['required_validation_error_message'])
222
-            ? $input_args['required_validation_error_message']
223
-            : null
224
-        );
225
-        // $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
226
-        $this->_display_strategy->_construct_finalize($this);
227
-        foreach ($this->_validation_strategies as $validation_strategy) {
228
-            $validation_strategy->_construct_finalize($this);
229
-        }
230
-        if (isset($input_args['ignore_input'])) {
231
-            $this->_normalization_strategy = new EE_Null_Normalization();
232
-        }
233
-        if (! $this->_normalization_strategy) {
234
-                $this->_normalization_strategy = new EE_Text_Normalization();
235
-        }
236
-        $this->_normalization_strategy->_construct_finalize($this);
237
-        // at least we can use the normalization strategy to populate the default
238
-        if (isset($input_args['default'])) {
239
-            $this->set_default($input_args['default']);
240
-            unset($input_args['default']);
241
-        }
242
-        if (! $this->_sensitive_data_removal_strategy) {
243
-            $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
244
-        }
245
-        $this->_sensitive_data_removal_strategy->_construct_finalize($this);
246
-        parent::__construct($input_args);
247
-    }
248
-
249
-
250
-
251
-    /**
252
-     * Sets the html_name to its default value, if none was specified in teh constructor.
253
-     * Calculation involves using the name and the parent's html_name
254
-     *
255
-     * @throws EE_Error
256
-     */
257
-    protected function _set_default_html_name_if_empty()
258
-    {
259
-        if (! $this->_html_name) {
260
-            $this->_html_name = $this->name();
261
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
262
-                $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
263
-            }
264
-        }
265
-    }
266
-
267
-
268
-
269
-    /**
270
-     * @param $parent_form_section
271
-     * @param $name
272
-     * @throws EE_Error
273
-     */
274
-    public function _construct_finalize($parent_form_section, $name)
275
-    {
276
-        parent::_construct_finalize($parent_form_section, $name);
277
-        if ($this->_html_label === null && $this->_html_label_text === null) {
278
-            $this->_html_label_text = ucwords(str_replace("_", " ", $name));
279
-        }
280
-        do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * Returns the strategy for displaying this form input. If none is set, throws an exception.
287
-     *
288
-     * @return EE_Display_Strategy_Base
289
-     * @throws EE_Error
290
-     */
291
-    protected function _get_display_strategy()
292
-    {
293
-        $this->ensure_construct_finalized_called();
294
-        if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
295
-            throw new EE_Error(
296
-                sprintf(
297
-                    esc_html__(
298
-                        "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor",
299
-                        "event_espresso"
300
-                    ),
301
-                    $this->html_name(),
302
-                    $this->html_id()
303
-                )
304
-            );
305
-        } else {
306
-            return $this->_display_strategy;
307
-        }
308
-    }
309
-
310
-
311
-
312
-    /**
313
-     * Sets the display strategy.
314
-     *
315
-     * @param EE_Display_Strategy_Base $strategy
316
-     */
317
-    protected function _set_display_strategy(EE_Display_Strategy_Base $strategy)
318
-    {
319
-        $this->_display_strategy = $strategy;
320
-    }
321
-
322
-
323
-
324
-    /**
325
-     * Sets the sanitization strategy
326
-     *
327
-     * @param EE_Normalization_Strategy_Base $strategy
328
-     */
329
-    protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy)
330
-    {
331
-        $this->_normalization_strategy = $strategy;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * Gets sensitive_data_removal_strategy
338
-     *
339
-     * @return EE_Sensitive_Data_Removal_Base
340
-     */
341
-    public function get_sensitive_data_removal_strategy()
342
-    {
343
-        return $this->_sensitive_data_removal_strategy;
344
-    }
345
-
346
-
347
-
348
-    /**
349
-     * Sets sensitive_data_removal_strategy
350
-     *
351
-     * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
352
-     * @return void
353
-     */
354
-    public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
355
-    {
356
-        $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
357
-    }
358
-
359
-
360
-
361
-    /**
362
-     * Gets the display strategy for this input
363
-     *
364
-     * @return EE_Display_Strategy_Base
365
-     */
366
-    public function get_display_strategy()
367
-    {
368
-        return $this->_display_strategy;
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Overwrites the display strategy
375
-     *
376
-     * @param EE_Display_Strategy_Base $display_strategy
377
-     */
378
-    public function set_display_strategy($display_strategy)
379
-    {
380
-        $this->_display_strategy = $display_strategy;
381
-        $this->_display_strategy->_construct_finalize($this);
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * Gets the normalization strategy set on this input
388
-     *
389
-     * @return EE_Normalization_Strategy_Base
390
-     */
391
-    public function get_normalization_strategy()
392
-    {
393
-        return $this->_normalization_strategy;
394
-    }
395
-
396
-
397
-
398
-    /**
399
-     * Overwrites the normalization strategy
400
-     *
401
-     * @param EE_Normalization_Strategy_Base $normalization_strategy
402
-     */
403
-    public function set_normalization_strategy($normalization_strategy)
404
-    {
405
-        $this->_normalization_strategy = $normalization_strategy;
406
-        $this->_normalization_strategy->_construct_finalize($this);
407
-    }
408
-
409
-
410
-
411
-    /**
412
-     * Returns all teh validation strategies which apply to this field, numerically indexed
413
-     *
414
-     * @return EE_Validation_Strategy_Base[]
415
-     */
416
-    public function get_validation_strategies()
417
-    {
418
-        return $this->_validation_strategies;
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     * Adds this strategy to the field so it will be used in both JS validation and server-side validation
425
-     *
426
-     * @param EE_Validation_Strategy_Base $validation_strategy
427
-     * @return void
428
-     */
429
-    protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
430
-    {
431
-        $validation_strategy->_construct_finalize($this);
432
-        $this->_validation_strategies[] = $validation_strategy;
433
-    }
434
-
435
-
436
-
437
-    /**
438
-     * Adds a new validation strategy onto the form input
439
-     *
440
-     * @param EE_Validation_Strategy_Base $validation_strategy
441
-     * @return void
442
-     */
443
-    public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
444
-    {
445
-        $this->_add_validation_strategy($validation_strategy);
446
-    }
447
-
448
-
449
-
450
-    /**
451
-     * The classname of the validation strategy to remove
452
-     *
453
-     * @param string $validation_strategy_classname
454
-     */
455
-    public function remove_validation_strategy($validation_strategy_classname)
456
-    {
457
-        foreach ($this->_validation_strategies as $key => $validation_strategy) {
458
-            if (
459
-                $validation_strategy instanceof $validation_strategy_classname
460
-                || is_subclass_of($validation_strategy, $validation_strategy_classname)
461
-            ) {
462
-                unset($this->_validation_strategies[ $key ]);
463
-            }
464
-        }
465
-    }
466
-
467
-
468
-
469
-    /**
470
-     * returns true if input employs any of the validation strategy defined by the supplied array of classnames
471
-     *
472
-     * @param array $validation_strategy_classnames
473
-     * @return bool
474
-     */
475
-    public function has_validation_strategy($validation_strategy_classnames)
476
-    {
477
-        $validation_strategy_classnames = is_array($validation_strategy_classnames)
478
-            ? $validation_strategy_classnames
479
-            : array($validation_strategy_classnames);
480
-        foreach ($this->_validation_strategies as $key => $validation_strategy) {
481
-            if (in_array($key, $validation_strategy_classnames)) {
482
-                return true;
483
-            }
484
-        }
485
-        return false;
486
-    }
487
-
488
-
489
-
490
-    /**
491
-     * Gets the HTML
492
-     *
493
-     * @return string
494
-     */
495
-    public function get_html()
496
-    {
497
-        return $this->_parent_section->get_html_for_input($this);
498
-    }
499
-
500
-
501
-
502
-    /**
503
-     * Gets the HTML for the input itself (no label or errors) according to the
504
-     * input's display strategy
505
-     * Makes sure the JS and CSS are enqueued for it
506
-     *
507
-     * @return string
508
-     * @throws EE_Error
509
-     */
510
-    public function get_html_for_input()
511
-    {
512
-        return $this->_form_html_filter
513
-            ? $this->_form_html_filter->filterHtml(
514
-                $this->_get_display_strategy()->display(),
515
-                $this
516
-            )
517
-            : $this->_get_display_strategy()->display();
518
-    }
519
-
520
-
521
-
522
-    /**
523
-     * @return string
524
-     */
525
-    public function html_other_attributes()
526
-    {
527
-        EE_Error::doing_it_wrong(
528
-            __METHOD__,
529
-            sprintf(
530
-                esc_html__(
531
-                    'This method is no longer in use. You should replace it by %s',
532
-                    'event_espresso'
533
-                ),
534
-                'EE_Form_Section_Base::other_html_attributes()'
535
-            ),
536
-            '4.10.2.p'
537
-        );
538
-
539
-        return $this->other_html_attributes();
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * @param string $html_other_attributes
546
-     */
547
-    public function set_html_other_attributes($html_other_attributes)
548
-    {
549
-        EE_Error::doing_it_wrong(
550
-            __METHOD__,
551
-            sprintf(
552
-                esc_html__(
553
-                    'This method is no longer in use. You should replace it by %s',
554
-                    'event_espresso'
555
-                ),
556
-                'EE_Form_Section_Base::set_other_html_attributes()'
557
-            ),
558
-            '4.10.2.p'
559
-        );
560
-
561
-        $this->set_other_html_attributes($html_other_attributes);
562
-    }
563
-
564
-
565
-
566
-    /**
567
-     * Gets the HTML for displaying the label for this form input
568
-     * according to the form section's layout strategy
569
-     *
570
-     * @return string
571
-     */
572
-    public function get_html_for_label()
573
-    {
574
-        return $this->_parent_section->get_layout_strategy()->display_label($this);
575
-    }
576
-
577
-
578
-
579
-    /**
580
-     * Gets the HTML for displaying the errors section for this form input
581
-     * according to the form section's layout strategy
582
-     *
583
-     * @return string
584
-     */
585
-    public function get_html_for_errors()
586
-    {
587
-        return $this->_parent_section->get_layout_strategy()->display_errors($this);
588
-    }
589
-
590
-
591
-
592
-    /**
593
-     * Gets the HTML for displaying the help text for this form input
594
-     * according to the form section's layout strategy
595
-     *
596
-     * @return string
597
-     */
598
-    public function get_html_for_help()
599
-    {
600
-        return $this->_parent_section->get_layout_strategy()->display_help_text($this);
601
-    }
602
-
603
-
604
-
605
-    /**
606
-     * Validates the input's sanitized value (assumes _sanitize() has already been called)
607
-     * and returns whether or not the form input's submitted value is value
608
-     *
609
-     * @return boolean
610
-     */
611
-    protected function _validate()
612
-    {
613
-        if ($this->isDisabled()) {
614
-            return true;
615
-        }
616
-        foreach ($this->_validation_strategies as $validation_strategy) {
617
-            if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
618
-                try {
619
-                    $validation_strategy->validate($this->normalized_value());
620
-                } catch (EE_Validation_Error $e) {
621
-                    $this->add_validation_error($e);
622
-                }
623
-            }
624
-        }
625
-        if ($this->get_validation_errors()) {
626
-            return false;
627
-        } else {
628
-            return true;
629
-        }
630
-    }
631
-
632
-
633
-
634
-    /**
635
-     * Performs basic sanitization on this value. But what sanitization can be performed anyways?
636
-     * This value MIGHT be allowed to have tags, so we can't really remove them.
637
-     *
638
-     * @param string $value
639
-     * @return null|string
640
-     */
641
-    protected function _sanitize($value)
642
-    {
643
-        return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * Picks out the form value that relates to this form input,
650
-     * and stores it as the sanitized value on the form input, and sets the normalized value.
651
-     * Returns whether or not any validation errors occurred
652
-     *
653
-     * @param array $req_data
654
-     * @return boolean whether or not there was an error
655
-     * @throws EE_Error
656
-     */
657
-    protected function _normalize($req_data)
658
-    {
659
-        // any existing validation errors don't apply so clear them
660
-        $this->_validation_errors = array();
661
-        // if the input is disabled, ignore whatever input was sent in
662
-        if ($this->isDisabled()) {
663
-            $this->_set_raw_value(null);
664
-            $this->_set_normalized_value($this->get_default());
665
-            return false;
666
-        }
667
-        try {
668
-            $raw_input = $this->find_form_data_for_this_section($req_data);
669
-            // super simple sanitization for now
670
-            if (is_array($raw_input)) {
671
-                $raw_value = array();
672
-                foreach ($raw_input as $key => $value) {
673
-                    $raw_value[ $key ] = $this->_sanitize($value);
674
-                }
675
-                $this->_set_raw_value($raw_value);
676
-            } else {
677
-                $this->_set_raw_value($this->_sanitize($raw_input));
678
-            }
679
-            // we want to mostly leave the input alone in case we need to re-display it to the user
680
-            $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
681
-            return false;
682
-        } catch (EE_Validation_Error $e) {
683
-            $this->add_validation_error($e);
684
-            return true;
685
-        }
686
-    }
687
-
688
-
689
-    /**
690
-     * @return string
691
-     * @throws EE_Error
692
-     */
693
-    public function html_name()
694
-    {
695
-        $this->_set_default_html_name_if_empty();
696
-        return $this->_html_name;
697
-    }
698
-
699
-
700
-    /**
701
-     * @return string
702
-     * @throws EE_Error
703
-     */
704
-    public function html_label_id()
705
-    {
706
-        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     * @return string
713
-     */
714
-    public function html_label_class()
715
-    {
716
-        return $this->_html_label_class;
717
-    }
718
-
719
-
720
-
721
-    /**
722
-     * @return string
723
-     */
724
-    public function html_label_style()
725
-    {
726
-        return $this->_html_label_style;
727
-    }
728
-
729
-
730
-
731
-    /**
732
-     * @return string
733
-     */
734
-    public function html_label_text()
735
-    {
736
-        return $this->_html_label_text;
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     * @return string
743
-     */
744
-    public function html_help_text()
745
-    {
746
-        return $this->_html_help_text;
747
-    }
748
-
749
-
750
-
751
-    /**
752
-     * @return string
753
-     */
754
-    public function html_help_class()
755
-    {
756
-        return $this->_html_help_class;
757
-    }
758
-
759
-
760
-
761
-    /**
762
-     * @return string
763
-     */
764
-    public function html_help_style()
765
-    {
766
-        return $this->_html_style;
767
-    }
768
-
769
-
770
-
771
-    /**
772
-     * returns the raw, UNSAFE, input, almost exactly as the user submitted it.
773
-     * Please note that almost all client code should instead use the normalized_value;
774
-     * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag,
775
-     * mostly by escaping quotes)
776
-     * Note, we do not store the exact original value sent in the user's request because
777
-     * it may have malicious content, and we MIGHT want to store the form input in a transient or something...
778
-     * in which case, we would have stored the malicious content to our database.
779
-     *
780
-     * @return string
781
-     */
782
-    public function raw_value()
783
-    {
784
-        return $this->_raw_value;
785
-    }
786
-
787
-
788
-
789
-    /**
790
-     * Returns a string safe to usage in form inputs when displaying, because
791
-     * it escapes all html entities
792
-     *
793
-     * @return string
794
-     */
795
-    public function raw_value_in_form()
796
-    {
797
-        return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
798
-    }
799
-
800
-
801
-
802
-    /**
803
-     * returns the value after it's been sanitized, and then converted into it's proper type
804
-     * in PHP. Eg, a string, an int, an array,
805
-     *
806
-     * @return mixed
807
-     */
808
-    public function normalized_value()
809
-    {
810
-        return $this->_normalized_value;
811
-    }
812
-
813
-
814
-
815
-    /**
816
-     * Returns the normalized value is a presentable way. By default this is just
817
-     * the normalized value by itself, but it can be overridden for when that's not
818
-     * the best thing to display
819
-     *
820
-     * @return string
821
-     */
822
-    public function pretty_value()
823
-    {
824
-        return $this->_normalized_value;
825
-    }
826
-
827
-
828
-
829
-    /**
830
-     * When generating the JS for the jquery validation rules like<br>
831
-     * <code>$( "#myform" ).validate({
832
-     * rules: {
833
-     * password: "required",
834
-     * password_again: {
835
-     * equalTo: "#password"
836
-     * }
837
-     * }
838
-     * });</code>
839
-     * if this field had the name 'password_again', it should return
840
-     * <br><code>password_again: {
841
-     * equalTo: "#password"
842
-     * }</code>
843
-     *
844
-     * @return array
845
-     */
846
-    public function get_jquery_validation_rules()
847
-    {
848
-        $jquery_validation_js = array();
849
-        $jquery_validation_rules = array();
850
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
851
-            $jquery_validation_rules = array_replace_recursive(
852
-                $jquery_validation_rules,
853
-                $validation_strategy->get_jquery_validation_rule_array()
854
-            );
855
-        }
856
-        if (! empty($jquery_validation_rules)) {
857
-            foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
858
-                $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
859
-            }
860
-        }
861
-        return $jquery_validation_js;
862
-    }
863
-
864
-
865
-
866
-    /**
867
-     * Sets the input's default value for use in displaying in the form. Note: value should be
868
-     * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0')
869
-     *
870
-     * @param mixed $value
871
-     * @return void
872
-     */
873
-    public function set_default($value)
874
-    {
875
-        $this->_default = $value;
876
-        $this->_set_normalized_value($value);
877
-        $this->_set_raw_value($value);
878
-    }
879
-
880
-
881
-
882
-    /**
883
-     * Sets the normalized value on this input
884
-     *
885
-     * @param mixed $value
886
-     */
887
-    protected function _set_normalized_value($value)
888
-    {
889
-        $this->_normalized_value = $value;
890
-    }
891
-
892
-
893
-
894
-    /**
895
-     * Sets the raw value on this input (ie, exactly as the user submitted it)
896
-     *
897
-     * @param mixed $value
898
-     */
899
-    protected function _set_raw_value($value)
900
-    {
901
-        $this->_raw_value = $this->_normalization_strategy->unnormalize($value);
902
-    }
903
-
904
-
905
-
906
-    /**
907
-     * Sets the HTML label text after it has already been defined
908
-     *
909
-     * @param string $label
910
-     * @return void
911
-     */
912
-    public function set_html_label_text($label)
913
-    {
914
-        $this->_html_label_text = $label;
915
-    }
916
-
917
-
918
-
919
-    /**
920
-     * Sets whether or not this field is required, and adjusts the validation strategy.
921
-     * If you want to use the EE_Conditionally_Required_Validation_Strategy,
922
-     * please add it as a validation strategy using add_validation_strategy as normal
923
-     *
924
-     * @param boolean $required boolean
925
-     * @param null    $required_text
926
-     */
927
-    public function set_required($required = true, $required_text = null)
928
-    {
929
-        $required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
930
-        // whether $required is a string or a boolean, we want to add a required validation strategy
931
-        if ($required) {
932
-            $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
933
-        } else {
934
-            $this->remove_validation_strategy('EE_Required_Validation_Strategy');
935
-        }
936
-        $this->_required = $required;
937
-    }
938
-
939
-
940
-
941
-    /**
942
-     * Returns whether or not this field is required
943
-     *
944
-     * @return boolean
945
-     */
946
-    public function required()
947
-    {
948
-        return $this->_required;
949
-    }
950
-
951
-
952
-
953
-    /**
954
-     * @param string $required_css_class
955
-     */
956
-    public function set_required_css_class($required_css_class)
957
-    {
958
-        $this->_required_css_class = $required_css_class;
959
-    }
960
-
961
-
962
-
963
-    /**
964
-     * @return string
965
-     */
966
-    public function required_css_class()
967
-    {
968
-        return $this->_required_css_class;
969
-    }
970
-
971
-
972
-
973
-    /**
974
-     * @param bool $add_required
975
-     * @return string
976
-     */
977
-    public function html_class($add_required = false)
978
-    {
979
-        return $add_required && $this->required()
980
-            ? $this->required_css_class() . ' ' . $this->_html_class
981
-            : $this->_html_class;
982
-    }
983
-
984
-
985
-    /**
986
-     * Sets the help text, in case
987
-     *
988
-     * @param string $text
989
-     */
990
-    public function set_html_help_text($text)
991
-    {
992
-        $this->_html_help_text = $text;
993
-    }
994
-
995
-
996
-
997
-    /**
998
-     * Uses the sensitive data removal strategy to remove the sensitive data from this
999
-     * input. If there is any kind of sensitive data removal on this input, we clear
1000
-     * out the raw value completely
1001
-     *
1002
-     * @return void
1003
-     */
1004
-    public function clean_sensitive_data()
1005
-    {
1006
-        // if we do ANY kind of sensitive data removal on this, then just clear out the raw value
1007
-        // if we need more logic than this we'll make a strategy for it
1008
-        if (
1009
-            $this->_sensitive_data_removal_strategy
1010
-            && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal
1011
-        ) {
1012
-            $this->_set_raw_value(null);
1013
-        }
1014
-        // and clean the normalized value according to the appropriate strategy
1015
-        $this->_set_normalized_value(
1016
-            $this->get_sensitive_data_removal_strategy()->remove_sensitive_data(
1017
-                $this->_normalized_value
1018
-            )
1019
-        );
1020
-    }
1021
-
1022
-
1023
-
1024
-    /**
1025
-     * @param bool   $primary
1026
-     * @param string $button_size
1027
-     * @param string $other_attributes
1028
-     */
1029
-    public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '')
1030
-    {
1031
-        $button_css_attributes = 'button';
1032
-        $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary';
1033
-        switch ($button_size) {
1034
-            case 'xs':
1035
-            case 'extra-small':
1036
-                $button_css_attributes .= ' button-xs';
1037
-                break;
1038
-            case 'sm':
1039
-            case 'small':
1040
-                $button_css_attributes .= ' button-sm';
1041
-                break;
1042
-            case 'lg':
1043
-            case 'large':
1044
-                $button_css_attributes .= ' button-lg';
1045
-                break;
1046
-            case 'block':
1047
-                $button_css_attributes .= ' button-block';
1048
-                break;
1049
-            case 'md':
1050
-            case 'medium':
1051
-            default:
1052
-                $button_css_attributes .= '';
1053
-        }
1054
-        $this->_button_css_attributes .= ! empty($other_attributes)
1055
-            ? $button_css_attributes . ' ' . $other_attributes
1056
-            : $button_css_attributes;
1057
-    }
1058
-
1059
-
1060
-
1061
-    /**
1062
-     * @return string
1063
-     */
1064
-    public function button_css_attributes()
1065
-    {
1066
-        if (empty($this->_button_css_attributes)) {
1067
-            $this->set_button_css_attributes();
1068
-        }
1069
-        return $this->_button_css_attributes;
1070
-    }
1071
-
1072
-
1073
-
1074
-    /**
1075
-     * find_form_data_for_this_section
1076
-     * using this section's name and its parents, finds the value of the form data that corresponds to it.
1077
-     * For example, if this form section's HTML name is my_form[subform][form_input_1],
1078
-     * then it's value should be in request at request['my_form']['subform']['form_input_1'].
1079
-     * (If that doesn't exist, we also check for this subsection's name
1080
-     * at the TOP LEVEL of the request data. Eg request['form_input_1'].)
1081
-     * This function finds its value in the form.
1082
-     *
1083
-     * @param array $req_data
1084
-     * @return mixed whatever the raw value of this form section is in the request data
1085
-     * @throws EE_Error
1086
-     */
1087
-    public function find_form_data_for_this_section($req_data)
1088
-    {
1089
-        $name_parts = $this->getInputNameParts();
1090
-        // now get the value for the input
1091
-        $value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1092
-        // check if this thing's name is at the TOP level of the request data
1093
-        if ($value === null && isset($req_data[ $this->name() ])) {
1094
-            $value = $req_data[ $this->name() ];
1095
-        }
1096
-        return $value;
1097
-    }
1098
-
1099
-
1100
-    /**
1101
-     * If this input's name is something like "foo[bar][baz]"
1102
-     * returns an array like `array('foo','bar',baz')`
1103
-     *
1104
-     * @return array
1105
-     * @throws EE_Error
1106
-     */
1107
-    protected function getInputNameParts()
1108
-    {
1109
-        // break up the html name by "[]"
1110
-        if (strpos($this->html_name(), '[') !== false) {
1111
-            $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
1112
-        } else {
1113
-            $before_any_brackets = $this->html_name();
1114
-        }
1115
-        // grab all of the segments
1116
-        preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
1117
-        if (isset($matches[1]) && is_array($matches[1])) {
1118
-            $name_parts = $matches[1];
1119
-            array_unshift($name_parts, $before_any_brackets);
1120
-        } else {
1121
-            $name_parts = array($before_any_brackets);
1122
-        }
1123
-        return $name_parts;
1124
-    }
1125
-
1126
-
1127
-
1128
-    /**
1129
-     * @param array $html_name_parts
1130
-     * @param array $req_data
1131
-     * @return array | NULL
1132
-     */
1133
-    public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1134
-    {
1135
-        $first_part_to_consider = array_shift($html_name_parts);
1136
-        if (isset($req_data[ $first_part_to_consider ])) {
1137
-            if (empty($html_name_parts)) {
1138
-                return $req_data[ $first_part_to_consider ];
1139
-            } else {
1140
-                return $this->findRequestForSectionUsingNameParts(
1141
-                    $html_name_parts,
1142
-                    $req_data[ $first_part_to_consider ]
1143
-                );
1144
-            }
1145
-        } else {
1146
-            return null;
1147
-        }
1148
-    }
1149
-
1150
-
1151
-
1152
-    /**
1153
-     * Checks if this form input's data is in the request data
1154
-     *
1155
-     * @param array $req_data
1156
-     * @return boolean
1157
-     * @throws EE_Error
1158
-     */
1159
-    public function form_data_present_in($req_data = null)
1160
-    {
1161
-        if ($req_data === null) {
1162
-            /** @var RequestInterface $request */
1163
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1164
-            $req_data = $request->postParams();
1165
-        }
1166
-        $checked_value = $this->find_form_data_for_this_section($req_data);
1167
-        if ($checked_value !== null) {
1168
-            return true;
1169
-        } else {
1170
-            return false;
1171
-        }
1172
-    }
1173
-
1174
-
1175
-
1176
-    /**
1177
-     * Overrides parent to add js data from validation and display strategies
1178
-     *
1179
-     * @param array $form_other_js_data
1180
-     * @return array
1181
-     */
1182
-    public function get_other_js_data($form_other_js_data = array())
1183
-    {
1184
-        return $this->get_other_js_data_from_strategies($form_other_js_data);
1185
-    }
1186
-
1187
-
1188
-
1189
-    /**
1190
-     * Gets other JS data for localization from this input's strategies, like
1191
-     * the validation strategies and the display strategy
1192
-     *
1193
-     * @param array $form_other_js_data
1194
-     * @return array
1195
-     */
1196
-    public function get_other_js_data_from_strategies($form_other_js_data = array())
1197
-    {
1198
-        $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
1199
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
1200
-            $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
1201
-        }
1202
-        return $form_other_js_data;
1203
-    }
1204
-
1205
-
1206
-
1207
-    /**
1208
-     * Override parent because we want to give our strategies an opportunity to enqueue some js and css
1209
-     *
1210
-     * @return void
1211
-     */
1212
-    public function enqueue_js()
1213
-    {
1214
-        // ask our display strategy and validation strategies if they have js to enqueue
1215
-        $this->enqueue_js_from_strategies();
1216
-    }
1217
-
1218
-
1219
-
1220
-    /**
1221
-     * Tells strategies when its ok to enqueue their js and css
1222
-     *
1223
-     * @return void
1224
-     */
1225
-    public function enqueue_js_from_strategies()
1226
-    {
1227
-        $this->get_display_strategy()->enqueue_js();
1228
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
1229
-            $validation_strategy->enqueue_js();
1230
-        }
1231
-    }
1232
-
1233
-
1234
-
1235
-    /**
1236
-     * Gets the default value set on the input (not the current value, which may have been
1237
-     * changed because of a form submission). If no default was set, this us null.
1238
-     * @return mixed
1239
-     */
1240
-    public function get_default()
1241
-    {
1242
-        return $this->_default;
1243
-    }
1244
-
1245
-
1246
-
1247
-    /**
1248
-     * Makes this input disabled. That means it will have the HTML attribute 'disabled="disabled"',
1249
-     * and server-side if any input was received it will be ignored
1250
-     */
1251
-    public function disable($disable = true)
1252
-    {
1253
-        $disabled_attribute = ' disabled="disabled"';
1254
-        $this->disabled = filter_var($disable, FILTER_VALIDATE_BOOLEAN);
1255
-        if ($this->disabled) {
1256
-            if (strpos($this->_other_html_attributes, $disabled_attribute) === false) {
1257
-                $this->_other_html_attributes .= $disabled_attribute;
1258
-            }
1259
-            $this->_set_normalized_value($this->get_default());
1260
-        } else {
1261
-            $this->_other_html_attributes = str_replace($disabled_attribute, '', $this->_other_html_attributes);
1262
-        }
1263
-    }
1264
-
1265
-
1266
-
1267
-    /**
1268
-     * Returns whether or not this input is currently disabled.
1269
-     * @return bool
1270
-     */
1271
-    public function isDisabled()
1272
-    {
1273
-        return $this->disabled;
1274
-    }
18
+	/**
19
+	 * the input's name attribute
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $_html_name;
24
+
25
+	/**
26
+	 * id for the html label tag
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected $_html_label_id;
31
+
32
+	/**
33
+	 * class for teh html label tag
34
+	 *
35
+	 * @var string
36
+	 */
37
+	protected $_html_label_class;
38
+
39
+	/**
40
+	 * style for teh html label tag
41
+	 *
42
+	 * @var string
43
+	 */
44
+	protected $_html_label_style;
45
+
46
+	/**
47
+	 * text to be placed in the html label
48
+	 *
49
+	 * @var string
50
+	 */
51
+	protected $_html_label_text;
52
+
53
+	/**
54
+	 * the full html label. If used, all other html_label_* properties are invalid
55
+	 *
56
+	 * @var string
57
+	 */
58
+	protected $_html_label;
59
+
60
+	/**
61
+	 * HTML to use for help text (normally placed below form input), in a span which normally
62
+	 * has a class of 'description'
63
+	 *
64
+	 * @var string
65
+	 */
66
+	protected $_html_help_text;
67
+
68
+	/**
69
+	 * CSS classes for displaying the help span
70
+	 *
71
+	 * @var string
72
+	 */
73
+	protected $_html_help_class = 'description';
74
+
75
+	/**
76
+	 * CSS to put in the style attribute on the help span
77
+	 *
78
+	 * @var string
79
+	 */
80
+	protected $_html_help_style;
81
+
82
+	/**
83
+	 * Stores whether or not this input's response is required.
84
+	 * Because certain styling elements may also want to know that this
85
+	 * input is required etc.
86
+	 *
87
+	 * @var boolean
88
+	 */
89
+	protected $_required;
90
+
91
+	/**
92
+	 * css class added to required inputs
93
+	 *
94
+	 * @var string
95
+	 */
96
+	protected $_required_css_class = 'ee-required';
97
+
98
+	/**
99
+	 * css styles applied to button type inputs
100
+	 *
101
+	 * @var string
102
+	 */
103
+	protected $_button_css_attributes;
104
+
105
+	/**
106
+	 * The raw post data submitted for this
107
+	 * Generally unsafe for usage in client code
108
+	 *
109
+	 * @var mixed string or array
110
+	 */
111
+	protected $_raw_value;
112
+
113
+	/**
114
+	 * Value normalized according to the input's normalization strategy.
115
+	 * The normalization strategy dictates whether this is a string, int, float,
116
+	 * boolean, or array of any of those.
117
+	 *
118
+	 * @var mixed
119
+	 */
120
+	protected $_normalized_value;
121
+
122
+
123
+	/**
124
+	 * Normalized default value either initially set on the input, or provided by calling
125
+	 * set_default().
126
+	 * @var mixed
127
+	 */
128
+	protected $_default;
129
+
130
+	/**
131
+	 * Strategy used for displaying this field.
132
+	 * Child classes must use _get_display_strategy to access it.
133
+	 *
134
+	 * @var EE_Display_Strategy_Base
135
+	 */
136
+	private $_display_strategy;
137
+
138
+	/**
139
+	 * Gets all the validation strategies used on this field
140
+	 *
141
+	 * @var EE_Validation_Strategy_Base[]
142
+	 */
143
+	private $_validation_strategies = array();
144
+
145
+	/**
146
+	 * The normalization strategy for this field
147
+	 *
148
+	 * @var EE_Normalization_Strategy_Base
149
+	 */
150
+	private $_normalization_strategy;
151
+
152
+	/**
153
+	 * Strategy for removing sensitive data after we're done with the form input
154
+	 *
155
+	 * @var EE_Sensitive_Data_Removal_Base
156
+	 */
157
+	protected $_sensitive_data_removal_strategy;
158
+
159
+	/**
160
+	 * Whether this input has been disabled or not.
161
+	 * If it's disabled while rendering, an extra hidden input is added that indicates it has been knowingly disabled.
162
+	 * (Client-side code that wants to dynamically disable it must also add this hidden input).
163
+	 * When the form is submitted, if the input is disabled in the PHP form section, then input is ignored.
164
+	 * If the input is missing from the request data but the hidden input indicating the input is disabled, then the input is again ignored.
165
+	 *
166
+	 * @var boolean
167
+	 */
168
+	protected $disabled = false;
169
+
170
+
171
+
172
+	/**
173
+	 * @param array                         $input_args       {
174
+	 * @type string                         $html_name        the html name for the input
175
+	 * @type string                         $html_label_id    the id attribute to give to the html label tag
176
+	 * @type string                         $html_label_class the class attribute to give to the html label tag
177
+	 * @type string                         $html_label_style the style attribute to give ot teh label tag
178
+	 * @type string                         $html_label_text  the text to put in the label tag
179
+	 * @type string                         $html_label       the full html label. If used,
180
+	 *                                                        all other html_label_* args are invalid
181
+	 * @type string                         $html_help_text   text to put in help element
182
+	 * @type string                         $html_help_style  style attribute to give to teh help element
183
+	 * @type string                         $html_help_class  class attribute to give to the help element
184
+	 * @type string                         $default          default value NORMALIZED (eg, if providing the default
185
+	 *       for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0')
186
+	 * @type EE_Display_Strategy_Base       $display          strategy
187
+	 * @type EE_Normalization_Strategy_Base $normalization_strategy
188
+	 * @type EE_Validation_Strategy_Base[]  $validation_strategies
189
+	 * @type boolean                        $ignore_input special argument which can be used to avoid adding any validation strategies,
190
+	 *                                                    and sets the normalization strategy to the Null normalization. This is good
191
+	 *                                                    when you want the input to be totally ignored server-side (like when using
192
+	 *                                                    React.js form inputs)
193
+	 *                                                        }
194
+	 */
195
+	public function __construct($input_args = array())
196
+	{
197
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
198
+		// the following properties must be cast as arrays
199
+		if (isset($input_args['validation_strategies'])) {
200
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
201
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
202
+					$this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
203
+				}
204
+			}
205
+			unset($input_args['validation_strategies']);
206
+		}
207
+		if (isset($input_args['ignore_input'])) {
208
+			$this->_validation_strategies = array();
209
+		}
210
+		// loop thru incoming options
211
+		foreach ($input_args as $key => $value) {
212
+			// add underscore to $key to match property names
213
+			$_key = '_' . $key;
214
+			if (property_exists($this, $_key)) {
215
+				$this->{$_key} = $value;
216
+			}
217
+		}
218
+		// ensure that "required" is set correctly
219
+		$this->set_required(
220
+			$this->_required,
221
+			isset($input_args['required_validation_error_message'])
222
+			? $input_args['required_validation_error_message']
223
+			: null
224
+		);
225
+		// $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
226
+		$this->_display_strategy->_construct_finalize($this);
227
+		foreach ($this->_validation_strategies as $validation_strategy) {
228
+			$validation_strategy->_construct_finalize($this);
229
+		}
230
+		if (isset($input_args['ignore_input'])) {
231
+			$this->_normalization_strategy = new EE_Null_Normalization();
232
+		}
233
+		if (! $this->_normalization_strategy) {
234
+				$this->_normalization_strategy = new EE_Text_Normalization();
235
+		}
236
+		$this->_normalization_strategy->_construct_finalize($this);
237
+		// at least we can use the normalization strategy to populate the default
238
+		if (isset($input_args['default'])) {
239
+			$this->set_default($input_args['default']);
240
+			unset($input_args['default']);
241
+		}
242
+		if (! $this->_sensitive_data_removal_strategy) {
243
+			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
244
+		}
245
+		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
246
+		parent::__construct($input_args);
247
+	}
248
+
249
+
250
+
251
+	/**
252
+	 * Sets the html_name to its default value, if none was specified in teh constructor.
253
+	 * Calculation involves using the name and the parent's html_name
254
+	 *
255
+	 * @throws EE_Error
256
+	 */
257
+	protected function _set_default_html_name_if_empty()
258
+	{
259
+		if (! $this->_html_name) {
260
+			$this->_html_name = $this->name();
261
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
262
+				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
263
+			}
264
+		}
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 * @param $parent_form_section
271
+	 * @param $name
272
+	 * @throws EE_Error
273
+	 */
274
+	public function _construct_finalize($parent_form_section, $name)
275
+	{
276
+		parent::_construct_finalize($parent_form_section, $name);
277
+		if ($this->_html_label === null && $this->_html_label_text === null) {
278
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
279
+		}
280
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * Returns the strategy for displaying this form input. If none is set, throws an exception.
287
+	 *
288
+	 * @return EE_Display_Strategy_Base
289
+	 * @throws EE_Error
290
+	 */
291
+	protected function _get_display_strategy()
292
+	{
293
+		$this->ensure_construct_finalized_called();
294
+		if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
295
+			throw new EE_Error(
296
+				sprintf(
297
+					esc_html__(
298
+						"Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor",
299
+						"event_espresso"
300
+					),
301
+					$this->html_name(),
302
+					$this->html_id()
303
+				)
304
+			);
305
+		} else {
306
+			return $this->_display_strategy;
307
+		}
308
+	}
309
+
310
+
311
+
312
+	/**
313
+	 * Sets the display strategy.
314
+	 *
315
+	 * @param EE_Display_Strategy_Base $strategy
316
+	 */
317
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy)
318
+	{
319
+		$this->_display_strategy = $strategy;
320
+	}
321
+
322
+
323
+
324
+	/**
325
+	 * Sets the sanitization strategy
326
+	 *
327
+	 * @param EE_Normalization_Strategy_Base $strategy
328
+	 */
329
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy)
330
+	{
331
+		$this->_normalization_strategy = $strategy;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * Gets sensitive_data_removal_strategy
338
+	 *
339
+	 * @return EE_Sensitive_Data_Removal_Base
340
+	 */
341
+	public function get_sensitive_data_removal_strategy()
342
+	{
343
+		return $this->_sensitive_data_removal_strategy;
344
+	}
345
+
346
+
347
+
348
+	/**
349
+	 * Sets sensitive_data_removal_strategy
350
+	 *
351
+	 * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
352
+	 * @return void
353
+	 */
354
+	public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
355
+	{
356
+		$this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
357
+	}
358
+
359
+
360
+
361
+	/**
362
+	 * Gets the display strategy for this input
363
+	 *
364
+	 * @return EE_Display_Strategy_Base
365
+	 */
366
+	public function get_display_strategy()
367
+	{
368
+		return $this->_display_strategy;
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Overwrites the display strategy
375
+	 *
376
+	 * @param EE_Display_Strategy_Base $display_strategy
377
+	 */
378
+	public function set_display_strategy($display_strategy)
379
+	{
380
+		$this->_display_strategy = $display_strategy;
381
+		$this->_display_strategy->_construct_finalize($this);
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * Gets the normalization strategy set on this input
388
+	 *
389
+	 * @return EE_Normalization_Strategy_Base
390
+	 */
391
+	public function get_normalization_strategy()
392
+	{
393
+		return $this->_normalization_strategy;
394
+	}
395
+
396
+
397
+
398
+	/**
399
+	 * Overwrites the normalization strategy
400
+	 *
401
+	 * @param EE_Normalization_Strategy_Base $normalization_strategy
402
+	 */
403
+	public function set_normalization_strategy($normalization_strategy)
404
+	{
405
+		$this->_normalization_strategy = $normalization_strategy;
406
+		$this->_normalization_strategy->_construct_finalize($this);
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 * Returns all teh validation strategies which apply to this field, numerically indexed
413
+	 *
414
+	 * @return EE_Validation_Strategy_Base[]
415
+	 */
416
+	public function get_validation_strategies()
417
+	{
418
+		return $this->_validation_strategies;
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 * Adds this strategy to the field so it will be used in both JS validation and server-side validation
425
+	 *
426
+	 * @param EE_Validation_Strategy_Base $validation_strategy
427
+	 * @return void
428
+	 */
429
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
430
+	{
431
+		$validation_strategy->_construct_finalize($this);
432
+		$this->_validation_strategies[] = $validation_strategy;
433
+	}
434
+
435
+
436
+
437
+	/**
438
+	 * Adds a new validation strategy onto the form input
439
+	 *
440
+	 * @param EE_Validation_Strategy_Base $validation_strategy
441
+	 * @return void
442
+	 */
443
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
444
+	{
445
+		$this->_add_validation_strategy($validation_strategy);
446
+	}
447
+
448
+
449
+
450
+	/**
451
+	 * The classname of the validation strategy to remove
452
+	 *
453
+	 * @param string $validation_strategy_classname
454
+	 */
455
+	public function remove_validation_strategy($validation_strategy_classname)
456
+	{
457
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
458
+			if (
459
+				$validation_strategy instanceof $validation_strategy_classname
460
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
461
+			) {
462
+				unset($this->_validation_strategies[ $key ]);
463
+			}
464
+		}
465
+	}
466
+
467
+
468
+
469
+	/**
470
+	 * returns true if input employs any of the validation strategy defined by the supplied array of classnames
471
+	 *
472
+	 * @param array $validation_strategy_classnames
473
+	 * @return bool
474
+	 */
475
+	public function has_validation_strategy($validation_strategy_classnames)
476
+	{
477
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
478
+			? $validation_strategy_classnames
479
+			: array($validation_strategy_classnames);
480
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
481
+			if (in_array($key, $validation_strategy_classnames)) {
482
+				return true;
483
+			}
484
+		}
485
+		return false;
486
+	}
487
+
488
+
489
+
490
+	/**
491
+	 * Gets the HTML
492
+	 *
493
+	 * @return string
494
+	 */
495
+	public function get_html()
496
+	{
497
+		return $this->_parent_section->get_html_for_input($this);
498
+	}
499
+
500
+
501
+
502
+	/**
503
+	 * Gets the HTML for the input itself (no label or errors) according to the
504
+	 * input's display strategy
505
+	 * Makes sure the JS and CSS are enqueued for it
506
+	 *
507
+	 * @return string
508
+	 * @throws EE_Error
509
+	 */
510
+	public function get_html_for_input()
511
+	{
512
+		return $this->_form_html_filter
513
+			? $this->_form_html_filter->filterHtml(
514
+				$this->_get_display_strategy()->display(),
515
+				$this
516
+			)
517
+			: $this->_get_display_strategy()->display();
518
+	}
519
+
520
+
521
+
522
+	/**
523
+	 * @return string
524
+	 */
525
+	public function html_other_attributes()
526
+	{
527
+		EE_Error::doing_it_wrong(
528
+			__METHOD__,
529
+			sprintf(
530
+				esc_html__(
531
+					'This method is no longer in use. You should replace it by %s',
532
+					'event_espresso'
533
+				),
534
+				'EE_Form_Section_Base::other_html_attributes()'
535
+			),
536
+			'4.10.2.p'
537
+		);
538
+
539
+		return $this->other_html_attributes();
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * @param string $html_other_attributes
546
+	 */
547
+	public function set_html_other_attributes($html_other_attributes)
548
+	{
549
+		EE_Error::doing_it_wrong(
550
+			__METHOD__,
551
+			sprintf(
552
+				esc_html__(
553
+					'This method is no longer in use. You should replace it by %s',
554
+					'event_espresso'
555
+				),
556
+				'EE_Form_Section_Base::set_other_html_attributes()'
557
+			),
558
+			'4.10.2.p'
559
+		);
560
+
561
+		$this->set_other_html_attributes($html_other_attributes);
562
+	}
563
+
564
+
565
+
566
+	/**
567
+	 * Gets the HTML for displaying the label for this form input
568
+	 * according to the form section's layout strategy
569
+	 *
570
+	 * @return string
571
+	 */
572
+	public function get_html_for_label()
573
+	{
574
+		return $this->_parent_section->get_layout_strategy()->display_label($this);
575
+	}
576
+
577
+
578
+
579
+	/**
580
+	 * Gets the HTML for displaying the errors section for this form input
581
+	 * according to the form section's layout strategy
582
+	 *
583
+	 * @return string
584
+	 */
585
+	public function get_html_for_errors()
586
+	{
587
+		return $this->_parent_section->get_layout_strategy()->display_errors($this);
588
+	}
589
+
590
+
591
+
592
+	/**
593
+	 * Gets the HTML for displaying the help text for this form input
594
+	 * according to the form section's layout strategy
595
+	 *
596
+	 * @return string
597
+	 */
598
+	public function get_html_for_help()
599
+	{
600
+		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
601
+	}
602
+
603
+
604
+
605
+	/**
606
+	 * Validates the input's sanitized value (assumes _sanitize() has already been called)
607
+	 * and returns whether or not the form input's submitted value is value
608
+	 *
609
+	 * @return boolean
610
+	 */
611
+	protected function _validate()
612
+	{
613
+		if ($this->isDisabled()) {
614
+			return true;
615
+		}
616
+		foreach ($this->_validation_strategies as $validation_strategy) {
617
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
618
+				try {
619
+					$validation_strategy->validate($this->normalized_value());
620
+				} catch (EE_Validation_Error $e) {
621
+					$this->add_validation_error($e);
622
+				}
623
+			}
624
+		}
625
+		if ($this->get_validation_errors()) {
626
+			return false;
627
+		} else {
628
+			return true;
629
+		}
630
+	}
631
+
632
+
633
+
634
+	/**
635
+	 * Performs basic sanitization on this value. But what sanitization can be performed anyways?
636
+	 * This value MIGHT be allowed to have tags, so we can't really remove them.
637
+	 *
638
+	 * @param string $value
639
+	 * @return null|string
640
+	 */
641
+	protected function _sanitize($value)
642
+	{
643
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * Picks out the form value that relates to this form input,
650
+	 * and stores it as the sanitized value on the form input, and sets the normalized value.
651
+	 * Returns whether or not any validation errors occurred
652
+	 *
653
+	 * @param array $req_data
654
+	 * @return boolean whether or not there was an error
655
+	 * @throws EE_Error
656
+	 */
657
+	protected function _normalize($req_data)
658
+	{
659
+		// any existing validation errors don't apply so clear them
660
+		$this->_validation_errors = array();
661
+		// if the input is disabled, ignore whatever input was sent in
662
+		if ($this->isDisabled()) {
663
+			$this->_set_raw_value(null);
664
+			$this->_set_normalized_value($this->get_default());
665
+			return false;
666
+		}
667
+		try {
668
+			$raw_input = $this->find_form_data_for_this_section($req_data);
669
+			// super simple sanitization for now
670
+			if (is_array($raw_input)) {
671
+				$raw_value = array();
672
+				foreach ($raw_input as $key => $value) {
673
+					$raw_value[ $key ] = $this->_sanitize($value);
674
+				}
675
+				$this->_set_raw_value($raw_value);
676
+			} else {
677
+				$this->_set_raw_value($this->_sanitize($raw_input));
678
+			}
679
+			// we want to mostly leave the input alone in case we need to re-display it to the user
680
+			$this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
681
+			return false;
682
+		} catch (EE_Validation_Error $e) {
683
+			$this->add_validation_error($e);
684
+			return true;
685
+		}
686
+	}
687
+
688
+
689
+	/**
690
+	 * @return string
691
+	 * @throws EE_Error
692
+	 */
693
+	public function html_name()
694
+	{
695
+		$this->_set_default_html_name_if_empty();
696
+		return $this->_html_name;
697
+	}
698
+
699
+
700
+	/**
701
+	 * @return string
702
+	 * @throws EE_Error
703
+	 */
704
+	public function html_label_id()
705
+	{
706
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 * @return string
713
+	 */
714
+	public function html_label_class()
715
+	{
716
+		return $this->_html_label_class;
717
+	}
718
+
719
+
720
+
721
+	/**
722
+	 * @return string
723
+	 */
724
+	public function html_label_style()
725
+	{
726
+		return $this->_html_label_style;
727
+	}
728
+
729
+
730
+
731
+	/**
732
+	 * @return string
733
+	 */
734
+	public function html_label_text()
735
+	{
736
+		return $this->_html_label_text;
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 * @return string
743
+	 */
744
+	public function html_help_text()
745
+	{
746
+		return $this->_html_help_text;
747
+	}
748
+
749
+
750
+
751
+	/**
752
+	 * @return string
753
+	 */
754
+	public function html_help_class()
755
+	{
756
+		return $this->_html_help_class;
757
+	}
758
+
759
+
760
+
761
+	/**
762
+	 * @return string
763
+	 */
764
+	public function html_help_style()
765
+	{
766
+		return $this->_html_style;
767
+	}
768
+
769
+
770
+
771
+	/**
772
+	 * returns the raw, UNSAFE, input, almost exactly as the user submitted it.
773
+	 * Please note that almost all client code should instead use the normalized_value;
774
+	 * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag,
775
+	 * mostly by escaping quotes)
776
+	 * Note, we do not store the exact original value sent in the user's request because
777
+	 * it may have malicious content, and we MIGHT want to store the form input in a transient or something...
778
+	 * in which case, we would have stored the malicious content to our database.
779
+	 *
780
+	 * @return string
781
+	 */
782
+	public function raw_value()
783
+	{
784
+		return $this->_raw_value;
785
+	}
786
+
787
+
788
+
789
+	/**
790
+	 * Returns a string safe to usage in form inputs when displaying, because
791
+	 * it escapes all html entities
792
+	 *
793
+	 * @return string
794
+	 */
795
+	public function raw_value_in_form()
796
+	{
797
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
798
+	}
799
+
800
+
801
+
802
+	/**
803
+	 * returns the value after it's been sanitized, and then converted into it's proper type
804
+	 * in PHP. Eg, a string, an int, an array,
805
+	 *
806
+	 * @return mixed
807
+	 */
808
+	public function normalized_value()
809
+	{
810
+		return $this->_normalized_value;
811
+	}
812
+
813
+
814
+
815
+	/**
816
+	 * Returns the normalized value is a presentable way. By default this is just
817
+	 * the normalized value by itself, but it can be overridden for when that's not
818
+	 * the best thing to display
819
+	 *
820
+	 * @return string
821
+	 */
822
+	public function pretty_value()
823
+	{
824
+		return $this->_normalized_value;
825
+	}
826
+
827
+
828
+
829
+	/**
830
+	 * When generating the JS for the jquery validation rules like<br>
831
+	 * <code>$( "#myform" ).validate({
832
+	 * rules: {
833
+	 * password: "required",
834
+	 * password_again: {
835
+	 * equalTo: "#password"
836
+	 * }
837
+	 * }
838
+	 * });</code>
839
+	 * if this field had the name 'password_again', it should return
840
+	 * <br><code>password_again: {
841
+	 * equalTo: "#password"
842
+	 * }</code>
843
+	 *
844
+	 * @return array
845
+	 */
846
+	public function get_jquery_validation_rules()
847
+	{
848
+		$jquery_validation_js = array();
849
+		$jquery_validation_rules = array();
850
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
851
+			$jquery_validation_rules = array_replace_recursive(
852
+				$jquery_validation_rules,
853
+				$validation_strategy->get_jquery_validation_rule_array()
854
+			);
855
+		}
856
+		if (! empty($jquery_validation_rules)) {
857
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
858
+				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
859
+			}
860
+		}
861
+		return $jquery_validation_js;
862
+	}
863
+
864
+
865
+
866
+	/**
867
+	 * Sets the input's default value for use in displaying in the form. Note: value should be
868
+	 * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0')
869
+	 *
870
+	 * @param mixed $value
871
+	 * @return void
872
+	 */
873
+	public function set_default($value)
874
+	{
875
+		$this->_default = $value;
876
+		$this->_set_normalized_value($value);
877
+		$this->_set_raw_value($value);
878
+	}
879
+
880
+
881
+
882
+	/**
883
+	 * Sets the normalized value on this input
884
+	 *
885
+	 * @param mixed $value
886
+	 */
887
+	protected function _set_normalized_value($value)
888
+	{
889
+		$this->_normalized_value = $value;
890
+	}
891
+
892
+
893
+
894
+	/**
895
+	 * Sets the raw value on this input (ie, exactly as the user submitted it)
896
+	 *
897
+	 * @param mixed $value
898
+	 */
899
+	protected function _set_raw_value($value)
900
+	{
901
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
902
+	}
903
+
904
+
905
+
906
+	/**
907
+	 * Sets the HTML label text after it has already been defined
908
+	 *
909
+	 * @param string $label
910
+	 * @return void
911
+	 */
912
+	public function set_html_label_text($label)
913
+	{
914
+		$this->_html_label_text = $label;
915
+	}
916
+
917
+
918
+
919
+	/**
920
+	 * Sets whether or not this field is required, and adjusts the validation strategy.
921
+	 * If you want to use the EE_Conditionally_Required_Validation_Strategy,
922
+	 * please add it as a validation strategy using add_validation_strategy as normal
923
+	 *
924
+	 * @param boolean $required boolean
925
+	 * @param null    $required_text
926
+	 */
927
+	public function set_required($required = true, $required_text = null)
928
+	{
929
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
930
+		// whether $required is a string or a boolean, we want to add a required validation strategy
931
+		if ($required) {
932
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
933
+		} else {
934
+			$this->remove_validation_strategy('EE_Required_Validation_Strategy');
935
+		}
936
+		$this->_required = $required;
937
+	}
938
+
939
+
940
+
941
+	/**
942
+	 * Returns whether or not this field is required
943
+	 *
944
+	 * @return boolean
945
+	 */
946
+	public function required()
947
+	{
948
+		return $this->_required;
949
+	}
950
+
951
+
952
+
953
+	/**
954
+	 * @param string $required_css_class
955
+	 */
956
+	public function set_required_css_class($required_css_class)
957
+	{
958
+		$this->_required_css_class = $required_css_class;
959
+	}
960
+
961
+
962
+
963
+	/**
964
+	 * @return string
965
+	 */
966
+	public function required_css_class()
967
+	{
968
+		return $this->_required_css_class;
969
+	}
970
+
971
+
972
+
973
+	/**
974
+	 * @param bool $add_required
975
+	 * @return string
976
+	 */
977
+	public function html_class($add_required = false)
978
+	{
979
+		return $add_required && $this->required()
980
+			? $this->required_css_class() . ' ' . $this->_html_class
981
+			: $this->_html_class;
982
+	}
983
+
984
+
985
+	/**
986
+	 * Sets the help text, in case
987
+	 *
988
+	 * @param string $text
989
+	 */
990
+	public function set_html_help_text($text)
991
+	{
992
+		$this->_html_help_text = $text;
993
+	}
994
+
995
+
996
+
997
+	/**
998
+	 * Uses the sensitive data removal strategy to remove the sensitive data from this
999
+	 * input. If there is any kind of sensitive data removal on this input, we clear
1000
+	 * out the raw value completely
1001
+	 *
1002
+	 * @return void
1003
+	 */
1004
+	public function clean_sensitive_data()
1005
+	{
1006
+		// if we do ANY kind of sensitive data removal on this, then just clear out the raw value
1007
+		// if we need more logic than this we'll make a strategy for it
1008
+		if (
1009
+			$this->_sensitive_data_removal_strategy
1010
+			&& ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal
1011
+		) {
1012
+			$this->_set_raw_value(null);
1013
+		}
1014
+		// and clean the normalized value according to the appropriate strategy
1015
+		$this->_set_normalized_value(
1016
+			$this->get_sensitive_data_removal_strategy()->remove_sensitive_data(
1017
+				$this->_normalized_value
1018
+			)
1019
+		);
1020
+	}
1021
+
1022
+
1023
+
1024
+	/**
1025
+	 * @param bool   $primary
1026
+	 * @param string $button_size
1027
+	 * @param string $other_attributes
1028
+	 */
1029
+	public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '')
1030
+	{
1031
+		$button_css_attributes = 'button';
1032
+		$button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary';
1033
+		switch ($button_size) {
1034
+			case 'xs':
1035
+			case 'extra-small':
1036
+				$button_css_attributes .= ' button-xs';
1037
+				break;
1038
+			case 'sm':
1039
+			case 'small':
1040
+				$button_css_attributes .= ' button-sm';
1041
+				break;
1042
+			case 'lg':
1043
+			case 'large':
1044
+				$button_css_attributes .= ' button-lg';
1045
+				break;
1046
+			case 'block':
1047
+				$button_css_attributes .= ' button-block';
1048
+				break;
1049
+			case 'md':
1050
+			case 'medium':
1051
+			default:
1052
+				$button_css_attributes .= '';
1053
+		}
1054
+		$this->_button_css_attributes .= ! empty($other_attributes)
1055
+			? $button_css_attributes . ' ' . $other_attributes
1056
+			: $button_css_attributes;
1057
+	}
1058
+
1059
+
1060
+
1061
+	/**
1062
+	 * @return string
1063
+	 */
1064
+	public function button_css_attributes()
1065
+	{
1066
+		if (empty($this->_button_css_attributes)) {
1067
+			$this->set_button_css_attributes();
1068
+		}
1069
+		return $this->_button_css_attributes;
1070
+	}
1071
+
1072
+
1073
+
1074
+	/**
1075
+	 * find_form_data_for_this_section
1076
+	 * using this section's name and its parents, finds the value of the form data that corresponds to it.
1077
+	 * For example, if this form section's HTML name is my_form[subform][form_input_1],
1078
+	 * then it's value should be in request at request['my_form']['subform']['form_input_1'].
1079
+	 * (If that doesn't exist, we also check for this subsection's name
1080
+	 * at the TOP LEVEL of the request data. Eg request['form_input_1'].)
1081
+	 * This function finds its value in the form.
1082
+	 *
1083
+	 * @param array $req_data
1084
+	 * @return mixed whatever the raw value of this form section is in the request data
1085
+	 * @throws EE_Error
1086
+	 */
1087
+	public function find_form_data_for_this_section($req_data)
1088
+	{
1089
+		$name_parts = $this->getInputNameParts();
1090
+		// now get the value for the input
1091
+		$value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1092
+		// check if this thing's name is at the TOP level of the request data
1093
+		if ($value === null && isset($req_data[ $this->name() ])) {
1094
+			$value = $req_data[ $this->name() ];
1095
+		}
1096
+		return $value;
1097
+	}
1098
+
1099
+
1100
+	/**
1101
+	 * If this input's name is something like "foo[bar][baz]"
1102
+	 * returns an array like `array('foo','bar',baz')`
1103
+	 *
1104
+	 * @return array
1105
+	 * @throws EE_Error
1106
+	 */
1107
+	protected function getInputNameParts()
1108
+	{
1109
+		// break up the html name by "[]"
1110
+		if (strpos($this->html_name(), '[') !== false) {
1111
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
1112
+		} else {
1113
+			$before_any_brackets = $this->html_name();
1114
+		}
1115
+		// grab all of the segments
1116
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
1117
+		if (isset($matches[1]) && is_array($matches[1])) {
1118
+			$name_parts = $matches[1];
1119
+			array_unshift($name_parts, $before_any_brackets);
1120
+		} else {
1121
+			$name_parts = array($before_any_brackets);
1122
+		}
1123
+		return $name_parts;
1124
+	}
1125
+
1126
+
1127
+
1128
+	/**
1129
+	 * @param array $html_name_parts
1130
+	 * @param array $req_data
1131
+	 * @return array | NULL
1132
+	 */
1133
+	public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1134
+	{
1135
+		$first_part_to_consider = array_shift($html_name_parts);
1136
+		if (isset($req_data[ $first_part_to_consider ])) {
1137
+			if (empty($html_name_parts)) {
1138
+				return $req_data[ $first_part_to_consider ];
1139
+			} else {
1140
+				return $this->findRequestForSectionUsingNameParts(
1141
+					$html_name_parts,
1142
+					$req_data[ $first_part_to_consider ]
1143
+				);
1144
+			}
1145
+		} else {
1146
+			return null;
1147
+		}
1148
+	}
1149
+
1150
+
1151
+
1152
+	/**
1153
+	 * Checks if this form input's data is in the request data
1154
+	 *
1155
+	 * @param array $req_data
1156
+	 * @return boolean
1157
+	 * @throws EE_Error
1158
+	 */
1159
+	public function form_data_present_in($req_data = null)
1160
+	{
1161
+		if ($req_data === null) {
1162
+			/** @var RequestInterface $request */
1163
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1164
+			$req_data = $request->postParams();
1165
+		}
1166
+		$checked_value = $this->find_form_data_for_this_section($req_data);
1167
+		if ($checked_value !== null) {
1168
+			return true;
1169
+		} else {
1170
+			return false;
1171
+		}
1172
+	}
1173
+
1174
+
1175
+
1176
+	/**
1177
+	 * Overrides parent to add js data from validation and display strategies
1178
+	 *
1179
+	 * @param array $form_other_js_data
1180
+	 * @return array
1181
+	 */
1182
+	public function get_other_js_data($form_other_js_data = array())
1183
+	{
1184
+		return $this->get_other_js_data_from_strategies($form_other_js_data);
1185
+	}
1186
+
1187
+
1188
+
1189
+	/**
1190
+	 * Gets other JS data for localization from this input's strategies, like
1191
+	 * the validation strategies and the display strategy
1192
+	 *
1193
+	 * @param array $form_other_js_data
1194
+	 * @return array
1195
+	 */
1196
+	public function get_other_js_data_from_strategies($form_other_js_data = array())
1197
+	{
1198
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
1199
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
1200
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
1201
+		}
1202
+		return $form_other_js_data;
1203
+	}
1204
+
1205
+
1206
+
1207
+	/**
1208
+	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
1209
+	 *
1210
+	 * @return void
1211
+	 */
1212
+	public function enqueue_js()
1213
+	{
1214
+		// ask our display strategy and validation strategies if they have js to enqueue
1215
+		$this->enqueue_js_from_strategies();
1216
+	}
1217
+
1218
+
1219
+
1220
+	/**
1221
+	 * Tells strategies when its ok to enqueue their js and css
1222
+	 *
1223
+	 * @return void
1224
+	 */
1225
+	public function enqueue_js_from_strategies()
1226
+	{
1227
+		$this->get_display_strategy()->enqueue_js();
1228
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
1229
+			$validation_strategy->enqueue_js();
1230
+		}
1231
+	}
1232
+
1233
+
1234
+
1235
+	/**
1236
+	 * Gets the default value set on the input (not the current value, which may have been
1237
+	 * changed because of a form submission). If no default was set, this us null.
1238
+	 * @return mixed
1239
+	 */
1240
+	public function get_default()
1241
+	{
1242
+		return $this->_default;
1243
+	}
1244
+
1245
+
1246
+
1247
+	/**
1248
+	 * Makes this input disabled. That means it will have the HTML attribute 'disabled="disabled"',
1249
+	 * and server-side if any input was received it will be ignored
1250
+	 */
1251
+	public function disable($disable = true)
1252
+	{
1253
+		$disabled_attribute = ' disabled="disabled"';
1254
+		$this->disabled = filter_var($disable, FILTER_VALIDATE_BOOLEAN);
1255
+		if ($this->disabled) {
1256
+			if (strpos($this->_other_html_attributes, $disabled_attribute) === false) {
1257
+				$this->_other_html_attributes .= $disabled_attribute;
1258
+			}
1259
+			$this->_set_normalized_value($this->get_default());
1260
+		} else {
1261
+			$this->_other_html_attributes = str_replace($disabled_attribute, '', $this->_other_html_attributes);
1262
+		}
1263
+	}
1264
+
1265
+
1266
+
1267
+	/**
1268
+	 * Returns whether or not this input is currently disabled.
1269
+	 * @return bool
1270
+	 */
1271
+	public function isDisabled()
1272
+	{
1273
+		return $this->disabled;
1274
+	}
1275 1275
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         if (isset($input_args['validation_strategies'])) {
200 200
             foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
201 201
                 if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
202
-                    $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
202
+                    $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
203 203
                 }
204 204
             }
205 205
             unset($input_args['validation_strategies']);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         // loop thru incoming options
211 211
         foreach ($input_args as $key => $value) {
212 212
             // add underscore to $key to match property names
213
-            $_key = '_' . $key;
213
+            $_key = '_'.$key;
214 214
             if (property_exists($this, $_key)) {
215 215
                 $this->{$_key} = $value;
216 216
             }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         if (isset($input_args['ignore_input'])) {
231 231
             $this->_normalization_strategy = new EE_Null_Normalization();
232 232
         }
233
-        if (! $this->_normalization_strategy) {
233
+        if ( ! $this->_normalization_strategy) {
234 234
                 $this->_normalization_strategy = new EE_Text_Normalization();
235 235
         }
236 236
         $this->_normalization_strategy->_construct_finalize($this);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             $this->set_default($input_args['default']);
240 240
             unset($input_args['default']);
241 241
         }
242
-        if (! $this->_sensitive_data_removal_strategy) {
242
+        if ( ! $this->_sensitive_data_removal_strategy) {
243 243
             $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
244 244
         }
245 245
         $this->_sensitive_data_removal_strategy->_construct_finalize($this);
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
      */
257 257
     protected function _set_default_html_name_if_empty()
258 258
     {
259
-        if (! $this->_html_name) {
259
+        if ( ! $this->_html_name) {
260 260
             $this->_html_name = $this->name();
261 261
             if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
262
-                $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
262
+                $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
263 263
             }
264 264
         }
265 265
     }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     protected function _get_display_strategy()
292 292
     {
293 293
         $this->ensure_construct_finalized_called();
294
-        if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
294
+        if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
295 295
             throw new EE_Error(
296 296
                 sprintf(
297 297
                     esc_html__(
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                 $validation_strategy instanceof $validation_strategy_classname
460 460
                 || is_subclass_of($validation_strategy, $validation_strategy_classname)
461 461
             ) {
462
-                unset($this->_validation_strategies[ $key ]);
462
+                unset($this->_validation_strategies[$key]);
463 463
             }
464 464
         }
465 465
     }
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
             if (is_array($raw_input)) {
671 671
                 $raw_value = array();
672 672
                 foreach ($raw_input as $key => $value) {
673
-                    $raw_value[ $key ] = $this->_sanitize($value);
673
+                    $raw_value[$key] = $this->_sanitize($value);
674 674
                 }
675 675
                 $this->_set_raw_value($raw_value);
676 676
             } else {
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
      */
704 704
     public function html_label_id()
705 705
     {
706
-        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
706
+        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id().'-lbl';
707 707
     }
708 708
 
709 709
 
@@ -853,9 +853,9 @@  discard block
 block discarded – undo
853 853
                 $validation_strategy->get_jquery_validation_rule_array()
854 854
             );
855 855
         }
856
-        if (! empty($jquery_validation_rules)) {
856
+        if ( ! empty($jquery_validation_rules)) {
857 857
             foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
858
-                $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
858
+                $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
859 859
             }
860 860
         }
861 861
         return $jquery_validation_js;
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
     public function html_class($add_required = false)
978 978
     {
979 979
         return $add_required && $this->required()
980
-            ? $this->required_css_class() . ' ' . $this->_html_class
980
+            ? $this->required_css_class().' '.$this->_html_class
981 981
             : $this->_html_class;
982 982
     }
983 983
 
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
                 $button_css_attributes .= '';
1053 1053
         }
1054 1054
         $this->_button_css_attributes .= ! empty($other_attributes)
1055
-            ? $button_css_attributes . ' ' . $other_attributes
1055
+            ? $button_css_attributes.' '.$other_attributes
1056 1056
             : $button_css_attributes;
1057 1057
     }
1058 1058
 
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
         // now get the value for the input
1091 1091
         $value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1092 1092
         // check if this thing's name is at the TOP level of the request data
1093
-        if ($value === null && isset($req_data[ $this->name() ])) {
1094
-            $value = $req_data[ $this->name() ];
1093
+        if ($value === null && isset($req_data[$this->name()])) {
1094
+            $value = $req_data[$this->name()];
1095 1095
         }
1096 1096
         return $value;
1097 1097
     }
@@ -1133,13 +1133,13 @@  discard block
 block discarded – undo
1133 1133
     public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1134 1134
     {
1135 1135
         $first_part_to_consider = array_shift($html_name_parts);
1136
-        if (isset($req_data[ $first_part_to_consider ])) {
1136
+        if (isset($req_data[$first_part_to_consider])) {
1137 1137
             if (empty($html_name_parts)) {
1138
-                return $req_data[ $first_part_to_consider ];
1138
+                return $req_data[$first_part_to_consider];
1139 1139
             } else {
1140 1140
                 return $this->findRequestForSectionUsingNameParts(
1141 1141
                     $html_name_parts,
1142
-                    $req_data[ $first_part_to_consider ]
1142
+                    $req_data[$first_part_to_consider]
1143 1143
                 );
1144 1144
             }
1145 1145
         } else {
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Yes_No_Input.input.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 class EE_Yes_No_Input extends EE_Select_Input
11 11
 {
12 12
 
13
-    /**
14
-     * @param array $options
15
-     */
16
-    public function __construct($options = array())
17
-    {
18
-        $select_options = array(true =>  esc_html__("Yes", "event_espresso"),false =>  esc_html__("No", "event_espresso"));
13
+	/**
14
+	 * @param array $options
15
+	 */
16
+	public function __construct($options = array())
17
+	{
18
+		$select_options = array(true =>  esc_html__("Yes", "event_espresso"),false =>  esc_html__("No", "event_espresso"));
19 19
 
20
-        parent::__construct($select_options, $options);
21
-    }
20
+		parent::__construct($select_options, $options);
21
+	}
22 22
 }
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($options = array())
17 17
     {
18
-        $select_options = array(true =>  esc_html__("Yes", "event_espresso"),false =>  esc_html__("No", "event_espresso"));
18
+        $select_options = array(true =>  esc_html__("Yes", "event_espresso"), false =>  esc_html__("No", "event_espresso"));
19 19
 
20 20
         parent::__construct($select_options, $options);
21 21
     }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Phone_Input.input.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Phone_Input extends EE_Text_Input
16 16
 {
17
-    /**
18
-     * @param array $options
19
-     */
20
-    public function __construct($options = array())
21
-    {
22
-        $this->_add_validation_strategy(
23
-            new EE_Text_Validation_Strategy(
24
-                esc_html__('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'),
25
-                '~^(([\d]{10})|(^[\d]{3}-[\d]{3}-[\d]{4}))$~'
26
-            )
27
-        );
28
-        parent::__construct($options);
29
-    }
17
+	/**
18
+	 * @param array $options
19
+	 */
20
+	public function __construct($options = array())
21
+	{
22
+		$this->_add_validation_strategy(
23
+			new EE_Text_Validation_Strategy(
24
+				esc_html__('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'),
25
+				'~^(([\d]{10})|(^[\d]{3}-[\d]{3}-[\d]{4}))$~'
26
+			)
27
+		);
28
+		parent::__construct($options);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Select_Ajax_Model_Rest_Input.input.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -17,189 +17,189 @@
 block discarded – undo
17 17
 class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $_model_name
22
-     */
23
-    protected $_model_name;
20
+	/**
21
+	 * @var string $_model_name
22
+	 */
23
+	protected $_model_name;
24 24
 
25
-    /**
26
-     * @var string $_display_field_name
27
-     */
28
-    protected $_display_field_name;
25
+	/**
26
+	 * @var string $_display_field_name
27
+	 */
28
+	protected $_display_field_name;
29 29
 
30
-    /**
31
-     * @var string $_value_field_name
32
-     */
33
-    protected $_value_field_name;
30
+	/**
31
+	 * @var string $_value_field_name
32
+	 */
33
+	protected $_value_field_name;
34 34
 
35
-    /**
36
-     * @var array $_extra_select_columns
37
-     */
38
-    protected $_extra_select_columns = array();
35
+	/**
36
+	 * @var array $_extra_select_columns
37
+	 */
38
+	protected $_extra_select_columns = array();
39 39
 
40 40
 
41
-    /**
42
-     * @param array $input_settings     {
43
-     * @type string $model_name         the name of model to be used for searching, both via the REST API and server-side model queries
44
-     * @type array  $query_params       default query parameters which will apply to both REST API queries and server-side queries. This should be
45
-     *                                  in the exact format that will be used for server-side model usage (eg use index 0 for where conditions, not
46
-     *                                  the string "where")
47
-     * @type string $value_field_name   the name of the model field on this model to
48
-     *                                  be used for the HTML select's option's values
49
-     * @type string $display_field_name the name of the model field on this model
50
-     *                                  to be used for the HTML select's option's display text
51
-     * @type array  $select2_args       arguments to be passed directly into the select2's JS constructor
52
-     *                                  }
53
-     *                                  And the arguments accepted by EE_Form_Input_With_Options_Base
54
-     * }
55
-     * @throws EE_Error
56
-     * @throws InvalidArgumentException
57
-     * @throws InvalidDataTypeException
58
-     * @throws InvalidInterfaceException
59
-     */
60
-    public function __construct($input_settings = array())
61
-    {
62
-        // needed input settings:
63
-        // select2_args
64
-        $this->_model_name = EEH_Array::is_set(
65
-            $input_settings,
66
-            'model_name',
67
-            null
68
-        );
69
-        $model = $this->_get_model();
70
-        $query_params = EEH_Array::is_set(
71
-            $input_settings,
72
-            'query_params',
73
-            array()
74
-        );
75
-        // make sure limit and caps are always set
76
-        $query_params = array_merge(
77
-            array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ),
78
-            $query_params
79
-        );
80
-        $this->_value_field_name = EEH_Array::is_set(
81
-            $input_settings,
82
-            'value_field_name',
83
-            $model->primary_key_name()
84
-        );
85
-        $this->_display_field_name = EEH_Array::is_set(
86
-            $input_settings,
87
-            'display_field_name',
88
-            $model->get_a_field_of_type('EE_Text_Field_Base')->get_name()
89
-        );
90
-        $this->_extra_select_columns = EEH_Array::is_set(
91
-            $input_settings,
92
-            'extra_select_columns',
93
-            array()
94
-        );
95
-        $this->_add_validation_strategy(
96
-            new EE_Model_Matching_Query_Validation_Strategy(
97
-                '',
98
-                $this->_model_name,
99
-                $query_params,
100
-                $this->_value_field_name
101
-            )
102
-        );
103
-        // get resource endpoint
104
-        $rest_controller = LoaderFactory::getLoader()->getNew(
105
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read'
106
-        );
107
-        $rest_controller->setRequestedVersion(EED_Core_Rest_Api::latest_rest_api_version());
108
-        $default_select2_args = array(
109
-            'ajax' => array(
110
-                'url' => $rest_controller->getVersionedLinkTo(
111
-                    EEH_Inflector::pluralize_and_lower($this->_model_name)
112
-                ),
113
-                'dataType' => 'json',
114
-                'delay' => '250',
115
-                'data_interface' => 'EE_Select2_REST_API_Interface',
116
-                'data_interface_args' => array(
117
-                    'default_query_params' => (object) ModelDataTranslator::prepareQueryParamsForRestApi(
118
-                        $query_params,
119
-                        $model
120
-                    ),
121
-                    'display_field' => $this->_display_field_name,
122
-                    'value_field' => $this->_value_field_name,
123
-                    'nonce' => wp_create_nonce('wp_rest'),
124
-                    'locale' => str_replace('_', '-', strtolower(get_locale()))
125
-                ),
126
-            ),
127
-            'cache' => true,
128
-            'width' => 'resolve'
129
-        );
130
-        $select2_args = array_replace_recursive(
131
-            $default_select2_args,
132
-            (array) EEH_Array::is_set($input_settings, 'select2_args', array())
133
-        );
134
-        $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args));
135
-        parent::__construct(array(), $input_settings);
136
-    }
41
+	/**
42
+	 * @param array $input_settings     {
43
+	 * @type string $model_name         the name of model to be used for searching, both via the REST API and server-side model queries
44
+	 * @type array  $query_params       default query parameters which will apply to both REST API queries and server-side queries. This should be
45
+	 *                                  in the exact format that will be used for server-side model usage (eg use index 0 for where conditions, not
46
+	 *                                  the string "where")
47
+	 * @type string $value_field_name   the name of the model field on this model to
48
+	 *                                  be used for the HTML select's option's values
49
+	 * @type string $display_field_name the name of the model field on this model
50
+	 *                                  to be used for the HTML select's option's display text
51
+	 * @type array  $select2_args       arguments to be passed directly into the select2's JS constructor
52
+	 *                                  }
53
+	 *                                  And the arguments accepted by EE_Form_Input_With_Options_Base
54
+	 * }
55
+	 * @throws EE_Error
56
+	 * @throws InvalidArgumentException
57
+	 * @throws InvalidDataTypeException
58
+	 * @throws InvalidInterfaceException
59
+	 */
60
+	public function __construct($input_settings = array())
61
+	{
62
+		// needed input settings:
63
+		// select2_args
64
+		$this->_model_name = EEH_Array::is_set(
65
+			$input_settings,
66
+			'model_name',
67
+			null
68
+		);
69
+		$model = $this->_get_model();
70
+		$query_params = EEH_Array::is_set(
71
+			$input_settings,
72
+			'query_params',
73
+			array()
74
+		);
75
+		// make sure limit and caps are always set
76
+		$query_params = array_merge(
77
+			array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ),
78
+			$query_params
79
+		);
80
+		$this->_value_field_name = EEH_Array::is_set(
81
+			$input_settings,
82
+			'value_field_name',
83
+			$model->primary_key_name()
84
+		);
85
+		$this->_display_field_name = EEH_Array::is_set(
86
+			$input_settings,
87
+			'display_field_name',
88
+			$model->get_a_field_of_type('EE_Text_Field_Base')->get_name()
89
+		);
90
+		$this->_extra_select_columns = EEH_Array::is_set(
91
+			$input_settings,
92
+			'extra_select_columns',
93
+			array()
94
+		);
95
+		$this->_add_validation_strategy(
96
+			new EE_Model_Matching_Query_Validation_Strategy(
97
+				'',
98
+				$this->_model_name,
99
+				$query_params,
100
+				$this->_value_field_name
101
+			)
102
+		);
103
+		// get resource endpoint
104
+		$rest_controller = LoaderFactory::getLoader()->getNew(
105
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read'
106
+		);
107
+		$rest_controller->setRequestedVersion(EED_Core_Rest_Api::latest_rest_api_version());
108
+		$default_select2_args = array(
109
+			'ajax' => array(
110
+				'url' => $rest_controller->getVersionedLinkTo(
111
+					EEH_Inflector::pluralize_and_lower($this->_model_name)
112
+				),
113
+				'dataType' => 'json',
114
+				'delay' => '250',
115
+				'data_interface' => 'EE_Select2_REST_API_Interface',
116
+				'data_interface_args' => array(
117
+					'default_query_params' => (object) ModelDataTranslator::prepareQueryParamsForRestApi(
118
+						$query_params,
119
+						$model
120
+					),
121
+					'display_field' => $this->_display_field_name,
122
+					'value_field' => $this->_value_field_name,
123
+					'nonce' => wp_create_nonce('wp_rest'),
124
+					'locale' => str_replace('_', '-', strtolower(get_locale()))
125
+				),
126
+			),
127
+			'cache' => true,
128
+			'width' => 'resolve'
129
+		);
130
+		$select2_args = array_replace_recursive(
131
+			$default_select2_args,
132
+			(array) EEH_Array::is_set($input_settings, 'select2_args', array())
133
+		);
134
+		$this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args));
135
+		parent::__construct(array(), $input_settings);
136
+	}
137 137
 
138 138
 
139 139
 
140
-    /**
141
-     * Before setting the raw value (usually because we're setting the default,
142
-     * or we've received a form submission and this might be re-displayed to the user),
143
-     * sets the options so that the current selections appear on initial display.
144
-     *
145
-     * Note: because this input uses EE_Model_Matching_Query_Validation_Strategy
146
-     * for validation, this input's options only affect DISPLAY and NOT validation,
147
-     * which is why its ok to just assume the provided $value to be in the list of acceptable values
148
-     *
149
-     * @param mixed $value
150
-     * @return void
151
-     * @throws \EE_Error
152
-     */
153
-    public function _set_raw_value($value)
154
-    {
155
-        $values_for_options = (array) $value;
156
-        $value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
157
-        $display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
158
-        $this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
159
-        $this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
160
-        $display_values = $this->_get_model()->get_all_wpdb_results(
161
-            array(
162
-                array(
163
-                    $this->_value_field_name => array( 'IN', $values_for_options )
164
-                )
165
-            ),
166
-            ARRAY_A,
167
-            implode(',', $this->_extra_select_columns)
168
-        );
169
-        $select_options = array();
170
-        if (is_array($select_options)) {
171
-            foreach ($display_values as $db_rows) {
172
-                $db_rows = (array) $db_rows;
173
-                $select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
174
-                    'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
175
-                    $db_rows[ $this->_display_field_name ],
176
-                    $db_rows
177
-                );
178
-            }
179
-        }
180
-        $this->set_select_options($select_options);
181
-        parent::_set_raw_value($value);
182
-    }
140
+	/**
141
+	 * Before setting the raw value (usually because we're setting the default,
142
+	 * or we've received a form submission and this might be re-displayed to the user),
143
+	 * sets the options so that the current selections appear on initial display.
144
+	 *
145
+	 * Note: because this input uses EE_Model_Matching_Query_Validation_Strategy
146
+	 * for validation, this input's options only affect DISPLAY and NOT validation,
147
+	 * which is why its ok to just assume the provided $value to be in the list of acceptable values
148
+	 *
149
+	 * @param mixed $value
150
+	 * @return void
151
+	 * @throws \EE_Error
152
+	 */
153
+	public function _set_raw_value($value)
154
+	{
155
+		$values_for_options = (array) $value;
156
+		$value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
157
+		$display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
158
+		$this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
159
+		$this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
160
+		$display_values = $this->_get_model()->get_all_wpdb_results(
161
+			array(
162
+				array(
163
+					$this->_value_field_name => array( 'IN', $values_for_options )
164
+				)
165
+			),
166
+			ARRAY_A,
167
+			implode(',', $this->_extra_select_columns)
168
+		);
169
+		$select_options = array();
170
+		if (is_array($select_options)) {
171
+			foreach ($display_values as $db_rows) {
172
+				$db_rows = (array) $db_rows;
173
+				$select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
174
+					'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
175
+					$db_rows[ $this->_display_field_name ],
176
+					$db_rows
177
+				);
178
+			}
179
+		}
180
+		$this->set_select_options($select_options);
181
+		parent::_set_raw_value($value);
182
+	}
183 183
 
184
-    /**
185
-     * Returns the model, or throws an exception if the model name provided in constructor doesn't exist
186
-     * @return EEM_Base
187
-     * @throws EE_Error
188
-     */
189
-    protected function _get_model()
190
-    {
191
-        if (! EE_Registry::instance()->is_model_name($this->_model_name)) {
192
-            throw new EE_Error(
193
-                sprintf(
194
-                    esc_html__(
195
-                        '%1$s is not a proper model name. Please provide a model name in the "model_name" form input argument',
196
-                        'event_espresso'
197
-                    ),
198
-                    $this->_model_name
199
-                )
200
-            );
201
-        } else {
202
-            return EE_Registry::instance()->load_model($this->_model_name);
203
-        }
204
-    }
184
+	/**
185
+	 * Returns the model, or throws an exception if the model name provided in constructor doesn't exist
186
+	 * @return EEM_Base
187
+	 * @throws EE_Error
188
+	 */
189
+	protected function _get_model()
190
+	{
191
+		if (! EE_Registry::instance()->is_model_name($this->_model_name)) {
192
+			throw new EE_Error(
193
+				sprintf(
194
+					esc_html__(
195
+						'%1$s is not a proper model name. Please provide a model name in the "model_name" form input argument',
196
+						'event_espresso'
197
+					),
198
+					$this->_model_name
199
+				)
200
+			);
201
+		} else {
202
+			return EE_Registry::instance()->load_model($this->_model_name);
203
+		}
204
+	}
205 205
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         );
75 75
         // make sure limit and caps are always set
76 76
         $query_params = array_merge(
77
-            array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ),
77
+            array('limit' => 10, 'caps' => EEM_Base::caps_read_admin),
78 78
             $query_params
79 79
         );
80 80
         $this->_value_field_name = EEH_Array::is_set(
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
         $values_for_options = (array) $value;
156 156
         $value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
157 157
         $display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
158
-        $this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
159
-        $this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
158
+        $this->_extra_select_columns[] = $value_field->get_qualified_column().' AS '.$this->_value_field_name;
159
+        $this->_extra_select_columns[] = $display_field->get_qualified_column().' AS '.$this->_display_field_name;
160 160
         $display_values = $this->_get_model()->get_all_wpdb_results(
161 161
             array(
162 162
                 array(
163
-                    $this->_value_field_name => array( 'IN', $values_for_options )
163
+                    $this->_value_field_name => array('IN', $values_for_options)
164 164
                 )
165 165
             ),
166 166
             ARRAY_A,
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
         if (is_array($select_options)) {
171 171
             foreach ($display_values as $db_rows) {
172 172
                 $db_rows = (array) $db_rows;
173
-                $select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
173
+                $select_options[$db_rows[$this->_value_field_name]] = apply_filters(
174 174
                     'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
175
-                    $db_rows[ $this->_display_field_name ],
175
+                    $db_rows[$this->_display_field_name],
176 176
                     $db_rows
177 177
                 );
178 178
             }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      */
189 189
     protected function _get_model()
190 190
     {
191
-        if (! EE_Registry::instance()->is_model_name($this->_model_name)) {
191
+        if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) {
192 192
             throw new EE_Error(
193 193
                 sprintf(
194 194
                     esc_html__(
Please login to merge, or discard this patch.
core/admin/PostShortcodeTracking.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -12,138 +12,138 @@
 block discarded – undo
12 12
 class PostShortcodeTracking
13 13
 {
14 14
 
15
-    /**
16
-     * @deprecated 4.9.26
17
-     * @return    void
18
-     */
19
-    public static function set_hooks_admin()
20
-    {
21
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
22
-    }
23
-
24
-
25
-    /**
26
-     * @deprecated 4.9.26
27
-     * @param $post_ID
28
-     * @param $post
29
-     * @return void
30
-     */
31
-    public static function parse_post_content_on_save($post_ID, $post)
32
-    {
33
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
34
-    }
35
-
36
-
37
-    /**
38
-     * @deprecated 4.9.26
39
-     * @param $page_for_posts
40
-     * @return void
41
-     */
42
-    protected static function set_post_shortcodes_for_posts_page($page_for_posts)
43
-    {
44
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
45
-    }
46
-
47
-
48
-    /**
49
-     * @deprecated 4.9.26
50
-     * @param $page_for_posts
51
-     * @param $EES_Shortcode
52
-     * @param $post_ID
53
-     * @return void
54
-     */
55
-    protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID)
56
-    {
57
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
58
-    }
59
-
60
-
61
-    /**
62
-     * @deprecated 4.9.26
63
-     * @param $ID
64
-     * @return void
65
-     */
66
-    public static function unset_post_shortcodes_on_delete($ID)
67
-    {
68
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
69
-    }
70
-
71
-
72
-    /**
73
-     * @deprecated 4.9.26
74
-     * @param      $ID
75
-     * @param      $shortcode_class
76
-     * @param      $shortcode_posts
77
-     * @param      $page_for_posts
78
-     * @param bool $update_post_shortcodes
79
-     * @return void
80
-     */
81
-    protected static function unset_posts_page_shortcode_for_post(
82
-        $ID,
83
-        $shortcode_class,
84
-        $shortcode_posts,
85
-        $page_for_posts,
86
-        $update_post_shortcodes = false
87
-    ) {
88
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
89
-    }
90
-
91
-
92
-    /**
93
-     * @deprecated 4.9.26
94
-     * @param string $page_for_posts
95
-     * @return void
96
-     */
97
-    public static function update_post_shortcodes($page_for_posts = '')
98
-    {
99
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
100
-    }
101
-
102
-
103
-    /**
104
-     * @deprecated 4.9.26
105
-     * @param $option
106
-     * @param $value
107
-     * @return void
108
-     */
109
-    public static function reset_page_for_posts_on_initial_set($option, $value)
110
-    {
111
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
112
-    }
113
-
114
-
115
-    /**
116
-     * @deprecated 4.9.26
117
-     * @param        $option
118
-     * @param string $old_value
119
-     * @param string $value
120
-     * @return void
121
-     */
122
-    public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '')
123
-    {
124
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
125
-    }
126
-
127
-
128
-    /**
129
-     * @deprecated 4.9.26
130
-     * @param $option
131
-     * @return void
132
-     */
133
-    public static function reset_page_for_posts_on_delete($option)
134
-    {
135
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
136
-    }
137
-
138
-
139
-    /**
140
-     * @deprecated 4.9.26
141
-     * @param      $shortcodes
142
-     * @param bool $index_results
143
-     * @return void
144
-     */
145
-    public static function get_post_ids_for_shortcode($shortcodes, $index_results = true)
146
-    {
147
-        \EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
148
-    }
15
+	/**
16
+	 * @deprecated 4.9.26
17
+	 * @return    void
18
+	 */
19
+	public static function set_hooks_admin()
20
+	{
21
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
22
+	}
23
+
24
+
25
+	/**
26
+	 * @deprecated 4.9.26
27
+	 * @param $post_ID
28
+	 * @param $post
29
+	 * @return void
30
+	 */
31
+	public static function parse_post_content_on_save($post_ID, $post)
32
+	{
33
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
34
+	}
35
+
36
+
37
+	/**
38
+	 * @deprecated 4.9.26
39
+	 * @param $page_for_posts
40
+	 * @return void
41
+	 */
42
+	protected static function set_post_shortcodes_for_posts_page($page_for_posts)
43
+	{
44
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
45
+	}
46
+
47
+
48
+	/**
49
+	 * @deprecated 4.9.26
50
+	 * @param $page_for_posts
51
+	 * @param $EES_Shortcode
52
+	 * @param $post_ID
53
+	 * @return void
54
+	 */
55
+	protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID)
56
+	{
57
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
58
+	}
59
+
60
+
61
+	/**
62
+	 * @deprecated 4.9.26
63
+	 * @param $ID
64
+	 * @return void
65
+	 */
66
+	public static function unset_post_shortcodes_on_delete($ID)
67
+	{
68
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
69
+	}
70
+
71
+
72
+	/**
73
+	 * @deprecated 4.9.26
74
+	 * @param      $ID
75
+	 * @param      $shortcode_class
76
+	 * @param      $shortcode_posts
77
+	 * @param      $page_for_posts
78
+	 * @param bool $update_post_shortcodes
79
+	 * @return void
80
+	 */
81
+	protected static function unset_posts_page_shortcode_for_post(
82
+		$ID,
83
+		$shortcode_class,
84
+		$shortcode_posts,
85
+		$page_for_posts,
86
+		$update_post_shortcodes = false
87
+	) {
88
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
89
+	}
90
+
91
+
92
+	/**
93
+	 * @deprecated 4.9.26
94
+	 * @param string $page_for_posts
95
+	 * @return void
96
+	 */
97
+	public static function update_post_shortcodes($page_for_posts = '')
98
+	{
99
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
100
+	}
101
+
102
+
103
+	/**
104
+	 * @deprecated 4.9.26
105
+	 * @param $option
106
+	 * @param $value
107
+	 * @return void
108
+	 */
109
+	public static function reset_page_for_posts_on_initial_set($option, $value)
110
+	{
111
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
112
+	}
113
+
114
+
115
+	/**
116
+	 * @deprecated 4.9.26
117
+	 * @param        $option
118
+	 * @param string $old_value
119
+	 * @param string $value
120
+	 * @return void
121
+	 */
122
+	public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '')
123
+	{
124
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
125
+	}
126
+
127
+
128
+	/**
129
+	 * @deprecated 4.9.26
130
+	 * @param $option
131
+	 * @return void
132
+	 */
133
+	public static function reset_page_for_posts_on_delete($option)
134
+	{
135
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
136
+	}
137
+
138
+
139
+	/**
140
+	 * @deprecated 4.9.26
141
+	 * @param      $shortcodes
142
+	 * @param bool $index_results
143
+	 * @return void
144
+	 */
145
+	public static function get_post_ids_for_shortcode($shortcodes, $index_results = true)
146
+	{
147
+		\EE_Error::doing_it_wrong(__METHOD__, esc_html__('Usage is deprecated.', 'event_espresso'), '4.9.26');
148
+	}
149 149
 }
Please login to merge, or discard this patch.