@@ -13,98 +13,98 @@ |
||
13 | 13 | class EE_Table_Row_Layout extends EE_Form_Section_Layout_Base |
14 | 14 | { |
15 | 15 | |
16 | - private bool $add_ids_and_classes; |
|
16 | + private bool $add_ids_and_classes; |
|
17 | 17 | |
18 | - public function __construct(bool $add_ids_and_classes = true) |
|
19 | - { |
|
20 | - $this->add_ids_and_classes = $add_ids_and_classes; |
|
21 | - parent::__construct(); |
|
22 | - } |
|
18 | + public function __construct(bool $add_ids_and_classes = true) |
|
19 | + { |
|
20 | + $this->add_ids_and_classes = $add_ids_and_classes; |
|
21 | + parent::__construct(); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param array $additional_args |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function layout_form_begin($additional_args = []) |
|
30 | - { |
|
31 | - return $this->add_ids_and_classes |
|
32 | - ? EEH_HTML::tr( |
|
33 | - '', |
|
34 | - $additional_args['id'] ?? '', |
|
35 | - $additional_args['class'] ?? '', |
|
36 | - $additional_args['style'] ?? '', |
|
37 | - $additional_args['other'] ?? '' |
|
38 | - ) |
|
39 | - : EEH_HTML::tr(); |
|
40 | - } |
|
25 | + /** |
|
26 | + * @param array $additional_args |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function layout_form_begin($additional_args = []) |
|
30 | + { |
|
31 | + return $this->add_ids_and_classes |
|
32 | + ? EEH_HTML::tr( |
|
33 | + '', |
|
34 | + $additional_args['id'] ?? '', |
|
35 | + $additional_args['class'] ?? '', |
|
36 | + $additional_args['style'] ?? '', |
|
37 | + $additional_args['other'] ?? '' |
|
38 | + ) |
|
39 | + : EEH_HTML::tr(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param array $additional_args |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function layout_form_end($additional_args = []) |
|
48 | - { |
|
49 | - return $this->add_ids_and_classes |
|
50 | - ? EEH_HTML::trx( |
|
51 | - $additional_args['id'] ?? '', |
|
52 | - $additional_args['class'] ?? '' |
|
53 | - ) |
|
54 | - : EEH_HTML::trx(); |
|
55 | - } |
|
43 | + /** |
|
44 | + * @param array $additional_args |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function layout_form_end($additional_args = []) |
|
48 | + { |
|
49 | + return $this->add_ids_and_classes |
|
50 | + ? EEH_HTML::trx( |
|
51 | + $additional_args['id'] ?? '', |
|
52 | + $additional_args['class'] ?? '' |
|
53 | + ) |
|
54 | + : EEH_HTML::trx(); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Lays out the input, including label and errors |
|
60 | - * |
|
61 | - * @param EE_Form_Input_Base $input |
|
62 | - * @return string |
|
63 | - * @throws EE_Error |
|
64 | - */ |
|
65 | - public function layout_input($input) |
|
66 | - { |
|
67 | - if ($input instanceof EE_Hidden_Input) { |
|
68 | - return $input->get_html_for_input(); |
|
69 | - } |
|
58 | + /** |
|
59 | + * Lays out the input, including label and errors |
|
60 | + * |
|
61 | + * @param EE_Form_Input_Base $input |
|
62 | + * @return string |
|
63 | + * @throws EE_Error |
|
64 | + */ |
|
65 | + public function layout_input($input) |
|
66 | + { |
|
67 | + if ($input instanceof EE_Hidden_Input) { |
|
68 | + return $input->get_html_for_input(); |
|
69 | + } |
|
70 | 70 | |
71 | - $html = $input->get_html_for_input(); |
|
72 | - $html .= $input->get_html_for_errors() != '' |
|
73 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
74 | - : ''; |
|
75 | - $html .= $input->get_html_for_help() != '' |
|
76 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
77 | - : ''; |
|
71 | + $html = $input->get_html_for_input(); |
|
72 | + $html .= $input->get_html_for_errors() != '' |
|
73 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
74 | + : ''; |
|
75 | + $html .= $input->get_html_for_help() != '' |
|
76 | + ? EEH_HTML::nl() . $input->get_html_for_help() |
|
77 | + : ''; |
|
78 | 78 | |
79 | - return $this->add_ids_and_classes |
|
80 | - ? EEH_HTML::td( |
|
81 | - $html, |
|
82 | - $input->html_id(), |
|
83 | - $input->html_class(), |
|
84 | - $input->html_style(), |
|
85 | - $input->other_html_attributes() |
|
86 | - ) |
|
87 | - : EEH_HTML::td($html); |
|
88 | - } |
|
79 | + return $this->add_ids_and_classes |
|
80 | + ? EEH_HTML::td( |
|
81 | + $html, |
|
82 | + $input->html_id(), |
|
83 | + $input->html_class(), |
|
84 | + $input->html_style(), |
|
85 | + $input->other_html_attributes() |
|
86 | + ) |
|
87 | + : EEH_HTML::td($html); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * Lays out a table cell for the subsection. |
|
93 | - * |
|
94 | - * @param EE_Form_Section_Proper $form_section |
|
95 | - * @return string |
|
96 | - * @throws EE_Error |
|
97 | - */ |
|
98 | - public function layout_subsection($form_section) |
|
99 | - { |
|
100 | - return $this->add_ids_and_classes |
|
101 | - ? EEH_HTML::td( |
|
102 | - $form_section->get_html(), |
|
103 | - $form_section->html_id(), |
|
104 | - $form_section->html_class(), |
|
105 | - $form_section->html_style(), |
|
106 | - $form_section->other_html_attributes() |
|
107 | - ) |
|
108 | - : EEH_HTML::td($form_section->get_html()); |
|
109 | - } |
|
91 | + /** |
|
92 | + * Lays out a table cell for the subsection. |
|
93 | + * |
|
94 | + * @param EE_Form_Section_Proper $form_section |
|
95 | + * @return string |
|
96 | + * @throws EE_Error |
|
97 | + */ |
|
98 | + public function layout_subsection($form_section) |
|
99 | + { |
|
100 | + return $this->add_ids_and_classes |
|
101 | + ? EEH_HTML::td( |
|
102 | + $form_section->get_html(), |
|
103 | + $form_section->html_id(), |
|
104 | + $form_section->html_class(), |
|
105 | + $form_section->html_style(), |
|
106 | + $form_section->other_html_attributes() |
|
107 | + ) |
|
108 | + : EEH_HTML::td($form_section->get_html()); |
|
109 | + } |
|
110 | 110 | } |
@@ -70,10 +70,10 @@ |
||
70 | 70 | |
71 | 71 | $html = $input->get_html_for_input(); |
72 | 72 | $html .= $input->get_html_for_errors() != '' |
73 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
73 | + ? EEH_HTML::nl().$input->get_html_for_errors() |
|
74 | 74 | : ''; |
75 | 75 | $html .= $input->get_html_for_help() != '' |
76 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
76 | + ? EEH_HTML::nl().$input->get_html_for_help() |
|
77 | 77 | : ''; |
78 | 78 | |
79 | 79 | return $this->add_ids_and_classes |
@@ -10,42 +10,42 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Text_Normalization extends EE_Normalization_Strategy_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $value_to_normalize |
|
15 | - * @return array|mixed|string |
|
16 | - */ |
|
17 | - public function normalize($value_to_normalize) |
|
18 | - { |
|
19 | - if (is_array($value_to_normalize)) { |
|
20 | - return (string) array_shift($value_to_normalize); |
|
21 | - } |
|
22 | - // consider `"null"` values to be equivalent to null. |
|
23 | - if ($value_to_normalize === '' || $value_to_normalize === null) { |
|
24 | - return null; |
|
25 | - } |
|
26 | - return (string) $value_to_normalize; |
|
27 | - } |
|
13 | + /** |
|
14 | + * @param string $value_to_normalize |
|
15 | + * @return array|mixed|string |
|
16 | + */ |
|
17 | + public function normalize($value_to_normalize) |
|
18 | + { |
|
19 | + if (is_array($value_to_normalize)) { |
|
20 | + return (string) array_shift($value_to_normalize); |
|
21 | + } |
|
22 | + // consider `"null"` values to be equivalent to null. |
|
23 | + if ($value_to_normalize === '' || $value_to_normalize === null) { |
|
24 | + return null; |
|
25 | + } |
|
26 | + return (string) $value_to_normalize; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * IF it's a string in PHP, it will be a string in the HTML form. easy |
|
33 | - * |
|
34 | - * @param string $normalized_value |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function unnormalize($normalized_value) |
|
38 | - { |
|
39 | - // form generation can sometimes result in values being arrays, so we'll just grab the first value |
|
40 | - if (is_array($normalized_value)) { |
|
41 | - $normalized_value = array_shift($normalized_value); |
|
42 | - } |
|
43 | - // account for default "select here" option values |
|
44 | - if ($normalized_value === null) { |
|
45 | - return ''; |
|
46 | - } |
|
47 | - // double-check it's a string. It's possible this value was a question option that happened to be a numeric |
|
48 | - // string, in which case PHP has automatically converted it to an integer! |
|
49 | - return (string) $normalized_value; |
|
50 | - } |
|
31 | + /** |
|
32 | + * IF it's a string in PHP, it will be a string in the HTML form. easy |
|
33 | + * |
|
34 | + * @param string $normalized_value |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function unnormalize($normalized_value) |
|
38 | + { |
|
39 | + // form generation can sometimes result in values being arrays, so we'll just grab the first value |
|
40 | + if (is_array($normalized_value)) { |
|
41 | + $normalized_value = array_shift($normalized_value); |
|
42 | + } |
|
43 | + // account for default "select here" option values |
|
44 | + if ($normalized_value === null) { |
|
45 | + return ''; |
|
46 | + } |
|
47 | + // double-check it's a string. It's possible this value was a question option that happened to be a numeric |
|
48 | + // string, in which case PHP has automatically converted it to an integer! |
|
49 | + return (string) $normalized_value; |
|
50 | + } |
|
51 | 51 | } |
@@ -10,86 +10,86 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Int_Normalization extends EE_Normalization_Strategy_Base |
12 | 12 | { |
13 | - /* |
|
13 | + /* |
|
14 | 14 | * regex pattern that matches for the following: |
15 | 15 | * * optional negative sign |
16 | 16 | * * one or more digits |
17 | 17 | */ |
18 | - const REGEX = '/^(-?)(\d+)(?:\.0+)?$/'; |
|
18 | + const REGEX = '/^(-?)(\d+)(?:\.0+)?$/'; |
|
19 | 19 | |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @param string $value_to_normalize |
|
24 | - * @return int|null |
|
25 | - * @throws EE_Validation_Error |
|
26 | - */ |
|
27 | - public function normalize($value_to_normalize) |
|
28 | - { |
|
29 | - if ($value_to_normalize === null) { |
|
30 | - return null; |
|
31 | - } |
|
32 | - if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
|
33 | - return (int) $value_to_normalize; |
|
34 | - } |
|
35 | - if (! is_string($value_to_normalize)) { |
|
36 | - throw new EE_Validation_Error( |
|
37 | - sprintf( |
|
38 | - esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
|
39 | - print_r($value_to_normalize, true), |
|
40 | - gettype($value_to_normalize) |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - $value_to_normalize = filter_var( |
|
45 | - $value_to_normalize, |
|
46 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
47 | - FILTER_FLAG_ALLOW_FRACTION |
|
48 | - ); |
|
49 | - if ($value_to_normalize === '') { |
|
50 | - return null; |
|
51 | - } |
|
52 | - $matches = array(); |
|
53 | - if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $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] === '-' ? (int) $matches[2] * -1 : (int) $matches[2]; |
|
58 | - } |
|
59 | - } |
|
60 | - // find if this input has a int validation strategy |
|
61 | - // in which case, use its message |
|
62 | - $validation_error_message = null; |
|
63 | - foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
64 | - if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
65 | - $validation_error_message = $validation_strategy->get_validation_error_message(); |
|
66 | - } |
|
67 | - } |
|
68 | - // this really shouldn't ever happen because fields with a int normalization strategy |
|
69 | - // should also have a int validation strategy, but in case it doesn't use the default |
|
70 | - if (! $validation_error_message) { |
|
71 | - $default_validation_strategy = new EE_Int_Validation_Strategy(); |
|
72 | - $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
|
73 | - } |
|
74 | - throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
75 | - } |
|
22 | + /** |
|
23 | + * @param string $value_to_normalize |
|
24 | + * @return int|null |
|
25 | + * @throws EE_Validation_Error |
|
26 | + */ |
|
27 | + public function normalize($value_to_normalize) |
|
28 | + { |
|
29 | + if ($value_to_normalize === null) { |
|
30 | + return null; |
|
31 | + } |
|
32 | + if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
|
33 | + return (int) $value_to_normalize; |
|
34 | + } |
|
35 | + if (! is_string($value_to_normalize)) { |
|
36 | + throw new EE_Validation_Error( |
|
37 | + sprintf( |
|
38 | + esc_html__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
|
39 | + print_r($value_to_normalize, true), |
|
40 | + gettype($value_to_normalize) |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + $value_to_normalize = filter_var( |
|
45 | + $value_to_normalize, |
|
46 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
47 | + FILTER_FLAG_ALLOW_FRACTION |
|
48 | + ); |
|
49 | + if ($value_to_normalize === '') { |
|
50 | + return null; |
|
51 | + } |
|
52 | + $matches = array(); |
|
53 | + if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $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] === '-' ? (int) $matches[2] * -1 : (int) $matches[2]; |
|
58 | + } |
|
59 | + } |
|
60 | + // find if this input has a int validation strategy |
|
61 | + // in which case, use its message |
|
62 | + $validation_error_message = null; |
|
63 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
64 | + if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
65 | + $validation_error_message = $validation_strategy->get_validation_error_message(); |
|
66 | + } |
|
67 | + } |
|
68 | + // this really shouldn't ever happen because fields with a int normalization strategy |
|
69 | + // should also have a int validation strategy, but in case it doesn't use the default |
|
70 | + if (! $validation_error_message) { |
|
71 | + $default_validation_strategy = new EE_Int_Validation_Strategy(); |
|
72 | + $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
|
73 | + } |
|
74 | + throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * Converts the int into a string for use in teh html form |
|
81 | - * |
|
82 | - * @param int $normalized_value |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function unnormalize($normalized_value) |
|
86 | - { |
|
87 | - if ($normalized_value === null || $normalized_value === '') { |
|
88 | - return ''; |
|
89 | - } |
|
90 | - if (empty($normalized_value)) { |
|
91 | - return '0'; |
|
92 | - } |
|
93 | - return "$normalized_value"; |
|
94 | - } |
|
79 | + /** |
|
80 | + * Converts the int into a string for use in teh html form |
|
81 | + * |
|
82 | + * @param int $normalized_value |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function unnormalize($normalized_value) |
|
86 | + { |
|
87 | + if ($normalized_value === null || $normalized_value === '') { |
|
88 | + return ''; |
|
89 | + } |
|
90 | + if (empty($normalized_value)) { |
|
91 | + return '0'; |
|
92 | + } |
|
93 | + return "$normalized_value"; |
|
94 | + } |
|
95 | 95 | } |
@@ -9,68 +9,68 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Select_Multiple_Display_Strategy extends EE_Select_Display_Strategy |
11 | 11 | { |
12 | - /** |
|
13 | - * @return string of html to display the field |
|
14 | - * @throws EE_Error |
|
15 | - */ |
|
16 | - public function display(): string |
|
17 | - { |
|
18 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
19 | - throw new EE_Error( |
|
20 | - esc_html__( |
|
21 | - 'Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', |
|
22 | - "event_espresso" |
|
23 | - ) |
|
24 | - ); |
|
25 | - } |
|
12 | + /** |
|
13 | + * @return string of html to display the field |
|
14 | + * @throws EE_Error |
|
15 | + */ |
|
16 | + public function display(): string |
|
17 | + { |
|
18 | + if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
19 | + throw new EE_Error( |
|
20 | + esc_html__( |
|
21 | + 'Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', |
|
22 | + "event_espresso" |
|
23 | + ) |
|
24 | + ); |
|
25 | + } |
|
26 | 26 | |
27 | - $html = EEH_HTML::nl(0, 'select'); |
|
28 | - $html .= '<select multiple'; |
|
29 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
30 | - $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
31 | - $class = $this->_input->required() |
|
32 | - ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() |
|
33 | - : $this->_input->html_class(); |
|
34 | - $html .= $class ? ' class="' . $class . '"' : ''; |
|
35 | - if ($this->_input->hasLabel()) { |
|
36 | - $html .= ' aria-labelledby="' . $this->_input->html_label_id() . '"'; |
|
37 | - } |
|
38 | - // add html5 required |
|
39 | - $html .= $this->_input->required() ? ' required' : ''; |
|
40 | - $html .= $this->_input->html_style() ? ' style="' . $this->_input->html_style() . '"' : ''; |
|
41 | - $html .= $this->_input->other_html_attributes(); |
|
42 | - $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
43 | - $html .= '>'; |
|
27 | + $html = EEH_HTML::nl(0, 'select'); |
|
28 | + $html .= '<select multiple'; |
|
29 | + $html .= ' id="' . $this->_input->html_id() . '"'; |
|
30 | + $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
31 | + $class = $this->_input->required() |
|
32 | + ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() |
|
33 | + : $this->_input->html_class(); |
|
34 | + $html .= $class ? ' class="' . $class . '"' : ''; |
|
35 | + if ($this->_input->hasLabel()) { |
|
36 | + $html .= ' aria-labelledby="' . $this->_input->html_label_id() . '"'; |
|
37 | + } |
|
38 | + // add html5 required |
|
39 | + $html .= $this->_input->required() ? ' required' : ''; |
|
40 | + $html .= $this->_input->html_style() ? ' style="' . $this->_input->html_style() . '"' : ''; |
|
41 | + $html .= $this->_input->other_html_attributes(); |
|
42 | + $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
|
43 | + $html .= '>'; |
|
44 | 44 | |
45 | - EEH_HTML::indent(1, 'select'); |
|
46 | - if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
47 | - throw new EE_Error( |
|
48 | - esc_html__( |
|
49 | - "Select multiple display strategy does not allow for nested arrays of options.", |
|
50 | - "event_espresso" |
|
51 | - ) |
|
52 | - ); |
|
53 | - } else { |
|
54 | - $html .= $this->_display_options($this->_input->options()); |
|
55 | - } |
|
45 | + EEH_HTML::indent(1, 'select'); |
|
46 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
47 | + throw new EE_Error( |
|
48 | + esc_html__( |
|
49 | + "Select multiple display strategy does not allow for nested arrays of options.", |
|
50 | + "event_espresso" |
|
51 | + ) |
|
52 | + ); |
|
53 | + } else { |
|
54 | + $html .= $this->_display_options($this->_input->options()); |
|
55 | + } |
|
56 | 56 | |
57 | - $html .= EEH_HTML::nl(-1, 'select') . "</select>"; |
|
58 | - return $html; |
|
59 | - } |
|
57 | + $html .= EEH_HTML::nl(-1, 'select') . "</select>"; |
|
58 | + return $html; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Checks if that $value is one of the selected ones |
|
64 | - * |
|
65 | - * @param string|int $value unnormalized value option (string) |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - protected function _check_if_option_selected($value): bool |
|
69 | - { |
|
70 | - $selected_options = $this->_input->raw_value(); |
|
71 | - if (empty($selected_options)) { |
|
72 | - return false; |
|
73 | - } |
|
74 | - return in_array($value, $selected_options); |
|
75 | - } |
|
62 | + /** |
|
63 | + * Checks if that $value is one of the selected ones |
|
64 | + * |
|
65 | + * @param string|int $value unnormalized value option (string) |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + protected function _check_if_option_selected($value): bool |
|
69 | + { |
|
70 | + $selected_options = $this->_input->raw_value(); |
|
71 | + if (empty($selected_options)) { |
|
72 | + return false; |
|
73 | + } |
|
74 | + return in_array($value, $selected_options); |
|
75 | + } |
|
76 | 76 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function display(): string |
17 | 17 | { |
18 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
18 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
19 | 19 | throw new EE_Error( |
20 | 20 | esc_html__( |
21 | 21 | 'Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | |
27 | 27 | $html = EEH_HTML::nl(0, 'select'); |
28 | 28 | $html .= '<select multiple'; |
29 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
30 | - $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
29 | + $html .= ' id="'.$this->_input->html_id().'"'; |
|
30 | + $html .= ' name="'.$this->_input->html_name().'[]"'; |
|
31 | 31 | $class = $this->_input->required() |
32 | - ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() |
|
32 | + ? $this->_input->required_css_class().' '.$this->_input->html_class() |
|
33 | 33 | : $this->_input->html_class(); |
34 | - $html .= $class ? ' class="' . $class . '"' : ''; |
|
34 | + $html .= $class ? ' class="'.$class.'"' : ''; |
|
35 | 35 | if ($this->_input->hasLabel()) { |
36 | - $html .= ' aria-labelledby="' . $this->_input->html_label_id() . '"'; |
|
36 | + $html .= ' aria-labelledby="'.$this->_input->html_label_id().'"'; |
|
37 | 37 | } |
38 | 38 | // add html5 required |
39 | 39 | $html .= $this->_input->required() ? ' required' : ''; |
40 | - $html .= $this->_input->html_style() ? ' style="' . $this->_input->html_style() . '"' : ''; |
|
40 | + $html .= $this->_input->html_style() ? ' style="'.$this->_input->html_style().'"' : ''; |
|
41 | 41 | $html .= $this->_input->other_html_attributes(); |
42 | 42 | $html .= $this->dataAttributesString($this->_input->dataAttributes()); |
43 | 43 | $html .= '>'; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $html .= $this->_display_options($this->_input->options()); |
55 | 55 | } |
56 | 56 | |
57 | - $html .= EEH_HTML::nl(-1, 'select') . "</select>"; |
|
57 | + $html .= EEH_HTML::nl(-1, 'select')."</select>"; |
|
58 | 58 | return $html; |
59 | 59 | } |
60 | 60 |
@@ -11,66 +11,66 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Checkbox_Display_Strategy extends EE_Compound_Input_Display_Strategy |
13 | 13 | { |
14 | - /** |
|
15 | - * @return string of html to display the field |
|
16 | - * @throws EE_Error |
|
17 | - */ |
|
18 | - public function display(): string |
|
19 | - { |
|
20 | - $input = $this->get_input(); |
|
21 | - $input->set_label_sizes(); |
|
22 | - $label_size_class = $input->get_label_size_class(); |
|
23 | - $html = ''; |
|
24 | - if ($input->hasMultipleSelections() && ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
25 | - EE_Error::doing_it_wrong( |
|
26 | - 'EE_Checkbox_Display_Strategy::display()', |
|
27 | - sprintf( |
|
28 | - esc_html_x( |
|
29 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
30 | - 'Input values for checkboxes should be an array of values, but the value for input "form-input-id" is "form-input-value". Please verify that the input name is exactly "form_input_name[]"', |
|
31 | - 'event_espresso' |
|
32 | - ), |
|
33 | - $input->html_id(), |
|
34 | - var_export($input->raw_value(), true), |
|
35 | - $input->html_name() . '[]' |
|
36 | - ), |
|
37 | - '4.8.1' |
|
38 | - ); |
|
39 | - } |
|
40 | - $input_raw_value = (array) $input->raw_value(); |
|
41 | - foreach ($input->options() as $value => $display_text) { |
|
42 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
14 | + /** |
|
15 | + * @return string of html to display the field |
|
16 | + * @throws EE_Error |
|
17 | + */ |
|
18 | + public function display(): string |
|
19 | + { |
|
20 | + $input = $this->get_input(); |
|
21 | + $input->set_label_sizes(); |
|
22 | + $label_size_class = $input->get_label_size_class(); |
|
23 | + $html = ''; |
|
24 | + if ($input->hasMultipleSelections() && ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
25 | + EE_Error::doing_it_wrong( |
|
26 | + 'EE_Checkbox_Display_Strategy::display()', |
|
27 | + sprintf( |
|
28 | + esc_html_x( |
|
29 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
30 | + 'Input values for checkboxes should be an array of values, but the value for input "form-input-id" is "form-input-value". Please verify that the input name is exactly "form_input_name[]"', |
|
31 | + 'event_espresso' |
|
32 | + ), |
|
33 | + $input->html_id(), |
|
34 | + var_export($input->raw_value(), true), |
|
35 | + $input->html_name() . '[]' |
|
36 | + ), |
|
37 | + '4.8.1' |
|
38 | + ); |
|
39 | + } |
|
40 | + $input_raw_value = (array) $input->raw_value(); |
|
41 | + foreach ($input->options() as $value => $display_text) { |
|
42 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
43 | 43 | |
44 | - $html_id = $this->get_sub_input_id($value); |
|
44 | + $html_id = $this->get_sub_input_id($value); |
|
45 | 45 | |
46 | - $html_name = $input->html_name(); |
|
47 | - $html_name .= $input->hasMultipleSelections() ? '[]' : ''; |
|
46 | + $html_name = $input->html_name(); |
|
47 | + $html_name .= $input->hasMultipleSelections() ? '[]' : ''; |
|
48 | 48 | |
49 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
50 | - $html .= " |
|
49 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
50 | + $html .= " |
|
51 | 51 | <label for=\"$html_id\" |
52 | 52 | id=\"$html_id-lbl\" |
53 | 53 | class=\"ee-checkbox-label-after$label_size_class\" |
54 | 54 | >"; |
55 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
56 | - $html .= '<input type="checkbox"'; |
|
57 | - $html .= ' name="' . $html_name . '"'; |
|
58 | - $html .= $html_id ? ' id="' . $html_id . '"' : ''; |
|
59 | - $html .= $input->html_class() ? $input->html_class() ? ' class="' . $input->html_class() . '"' : '' : ''; |
|
60 | - $html .= $input->html_style() ? $input->html_style() ? ' style="' . $input->html_style() . '"' : '' : ''; |
|
61 | - if ($input->hasLabel()) { |
|
62 | - $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
63 | - } |
|
64 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
65 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
66 | - ? ' checked' |
|
67 | - : ''; |
|
68 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
69 | - $html .= ' data-question_label="' . $html_id . '-lbl"'; |
|
70 | - $html .= '> '; |
|
71 | - $html .= $display_text; |
|
72 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
73 | - } |
|
74 | - return $html; |
|
75 | - } |
|
55 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
56 | + $html .= '<input type="checkbox"'; |
|
57 | + $html .= ' name="' . $html_name . '"'; |
|
58 | + $html .= $html_id ? ' id="' . $html_id . '"' : ''; |
|
59 | + $html .= $input->html_class() ? $input->html_class() ? ' class="' . $input->html_class() . '"' : '' : ''; |
|
60 | + $html .= $input->html_style() ? $input->html_style() ? ' style="' . $input->html_style() . '"' : '' : ''; |
|
61 | + if ($input->hasLabel()) { |
|
62 | + $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
63 | + } |
|
64 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
65 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
66 | + ? ' checked' |
|
67 | + : ''; |
|
68 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
69 | + $html .= ' data-question_label="' . $html_id . '-lbl"'; |
|
70 | + $html .= '> '; |
|
71 | + $html .= $display_text; |
|
72 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
73 | + } |
|
74 | + return $html; |
|
75 | + } |
|
76 | 76 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ), |
33 | 33 | $input->html_id(), |
34 | 34 | var_export($input->raw_value(), true), |
35 | - $input->html_name() . '[]' |
|
35 | + $input->html_name().'[]' |
|
36 | 36 | ), |
37 | 37 | '4.8.1' |
38 | 38 | ); |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | >"; |
55 | 55 | $html .= EEH_HTML::nl(1, 'checkbox'); |
56 | 56 | $html .= '<input type="checkbox"'; |
57 | - $html .= ' name="' . $html_name . '"'; |
|
58 | - $html .= $html_id ? ' id="' . $html_id . '"' : ''; |
|
59 | - $html .= $input->html_class() ? $input->html_class() ? ' class="' . $input->html_class() . '"' : '' : ''; |
|
60 | - $html .= $input->html_style() ? $input->html_style() ? ' style="' . $input->html_style() . '"' : '' : ''; |
|
57 | + $html .= ' name="'.$html_name.'"'; |
|
58 | + $html .= $html_id ? ' id="'.$html_id.'"' : ''; |
|
59 | + $html .= $input->html_class() ? $input->html_class() ? ' class="'.$input->html_class().'"' : '' : ''; |
|
60 | + $html .= $input->html_style() ? $input->html_style() ? ' style="'.$input->html_style().'"' : '' : ''; |
|
61 | 61 | if ($input->hasLabel()) { |
62 | - $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
62 | + $html .= ' aria-labelledby="'.$html_id.'-lbl"'; |
|
63 | 63 | } |
64 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
64 | + $html .= ' value="'.esc_attr($value).'"'; |
|
65 | 65 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
66 | 66 | ? ' checked' |
67 | 67 | : ''; |
68 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
69 | - $html .= ' data-question_label="' . $html_id . '-lbl"'; |
|
68 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
69 | + $html .= ' data-question_label="'.$html_id.'-lbl"'; |
|
70 | 70 | $html .= '> '; |
71 | 71 | $html .= $display_text; |
72 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
72 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
73 | 73 | } |
74 | 74 | return $html; |
75 | 75 | } |
@@ -10,182 +10,182 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Checkbox_Dropdown_Selector_Display_Strategy extends EE_Compound_Input_Display_Strategy |
12 | 12 | { |
13 | - /** |
|
14 | - * enqueues css and js, so that this can be called statically |
|
15 | - */ |
|
16 | - public static function enqueue_styles_and_scripts() |
|
17 | - { |
|
18 | - wp_register_style( |
|
19 | - 'checkbox_dropdown_selector', |
|
20 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
21 | - ['espresso_default'], |
|
22 | - EVENT_ESPRESSO_VERSION |
|
23 | - ); |
|
24 | - wp_register_style( |
|
25 | - 'espresso_default', |
|
26 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
27 | - ['dashicons'], |
|
28 | - EVENT_ESPRESSO_VERSION |
|
29 | - ); |
|
30 | - wp_enqueue_style('checkbox_dropdown_selector'); |
|
31 | - wp_register_script( |
|
32 | - 'checkbox_dropdown_selector', |
|
33 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
34 | - ['jquery'], |
|
35 | - EVENT_ESPRESSO_VERSION, |
|
36 | - true |
|
37 | - ); |
|
38 | - wp_localize_script( |
|
39 | - 'ticket_selector', |
|
40 | - 'eeDTS', |
|
41 | - [ |
|
42 | - 'maxChecked' => EE_Registry::instance() |
|
43 | - ->CFG |
|
44 | - ->template_settings |
|
45 | - ->EED_Ticket_Selector |
|
46 | - ->getDatetimeSelectorMaxChecked(), |
|
47 | - ] |
|
48 | - ); |
|
49 | - wp_enqueue_script('checkbox_dropdown_selector'); |
|
50 | - } |
|
13 | + /** |
|
14 | + * enqueues css and js, so that this can be called statically |
|
15 | + */ |
|
16 | + public static function enqueue_styles_and_scripts() |
|
17 | + { |
|
18 | + wp_register_style( |
|
19 | + 'checkbox_dropdown_selector', |
|
20 | + EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
21 | + ['espresso_default'], |
|
22 | + EVENT_ESPRESSO_VERSION |
|
23 | + ); |
|
24 | + wp_register_style( |
|
25 | + 'espresso_default', |
|
26 | + EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
27 | + ['dashicons'], |
|
28 | + EVENT_ESPRESSO_VERSION |
|
29 | + ); |
|
30 | + wp_enqueue_style('checkbox_dropdown_selector'); |
|
31 | + wp_register_script( |
|
32 | + 'checkbox_dropdown_selector', |
|
33 | + EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
34 | + ['jquery'], |
|
35 | + EVENT_ESPRESSO_VERSION, |
|
36 | + true |
|
37 | + ); |
|
38 | + wp_localize_script( |
|
39 | + 'ticket_selector', |
|
40 | + 'eeDTS', |
|
41 | + [ |
|
42 | + 'maxChecked' => EE_Registry::instance() |
|
43 | + ->CFG |
|
44 | + ->template_settings |
|
45 | + ->EED_Ticket_Selector |
|
46 | + ->getDatetimeSelectorMaxChecked(), |
|
47 | + ] |
|
48 | + ); |
|
49 | + wp_enqueue_script('checkbox_dropdown_selector'); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
55 | - */ |
|
56 | - public function enqueue_js() |
|
57 | - { |
|
58 | - EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
59 | - } |
|
53 | + /** |
|
54 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
55 | + */ |
|
56 | + public function enqueue_js() |
|
57 | + { |
|
58 | + EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * callback for Iframe::addStylesheets() child class methods |
|
64 | - * |
|
65 | - * @param array $iframe_css |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function iframe_css(array $iframe_css): array |
|
69 | - { |
|
70 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
71 | - return $iframe_css; |
|
72 | - } |
|
62 | + /** |
|
63 | + * callback for Iframe::addStylesheets() child class methods |
|
64 | + * |
|
65 | + * @param array $iframe_css |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function iframe_css(array $iframe_css): array |
|
69 | + { |
|
70 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
71 | + return $iframe_css; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * callback for Iframe::addScripts() child class methods |
|
77 | - * |
|
78 | - * @param array $iframe_js |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - public function iframe_js(array $iframe_js): array |
|
82 | - { |
|
83 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
84 | - return $iframe_js; |
|
85 | - } |
|
75 | + /** |
|
76 | + * callback for Iframe::addScripts() child class methods |
|
77 | + * |
|
78 | + * @param array $iframe_js |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + public function iframe_js(array $iframe_js): array |
|
82 | + { |
|
83 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
84 | + return $iframe_js; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * @return string of html to display the field |
|
90 | - * @throws EE_Error |
|
91 | - */ |
|
92 | - public function display(): string |
|
93 | - { |
|
94 | - $input = $this->get_input(); |
|
95 | - $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input |
|
96 | - ? $input->select_button_text() |
|
97 | - : ''; |
|
98 | - // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
99 | - $input->set_label_sizes(); |
|
100 | - $label_size_class = $input->get_label_size_class(); |
|
101 | - if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
102 | - EE_Error::doing_it_wrong( |
|
103 | - 'EE_Checkbox_Display_Strategy::display()', |
|
104 | - sprintf( |
|
105 | - esc_html__( |
|
106 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
107 | - 'event_espresso' |
|
108 | - ), |
|
109 | - $input->html_id(), |
|
110 | - var_export($input->raw_value(), true), |
|
111 | - $input->html_name() . '[]' |
|
112 | - ), |
|
113 | - '4.8.1' |
|
114 | - ); |
|
115 | - } |
|
88 | + /** |
|
89 | + * @return string of html to display the field |
|
90 | + * @throws EE_Error |
|
91 | + */ |
|
92 | + public function display(): string |
|
93 | + { |
|
94 | + $input = $this->get_input(); |
|
95 | + $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input |
|
96 | + ? $input->select_button_text() |
|
97 | + : ''; |
|
98 | + // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
99 | + $input->set_label_sizes(); |
|
100 | + $label_size_class = $input->get_label_size_class(); |
|
101 | + if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
102 | + EE_Error::doing_it_wrong( |
|
103 | + 'EE_Checkbox_Display_Strategy::display()', |
|
104 | + sprintf( |
|
105 | + esc_html__( |
|
106 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
107 | + 'event_espresso' |
|
108 | + ), |
|
109 | + $input->html_id(), |
|
110 | + var_export($input->raw_value(), true), |
|
111 | + $input->html_name() . '[]' |
|
112 | + ), |
|
113 | + '4.8.1' |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - $html = EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
118 | + $html = EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
119 | 119 | |
120 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
121 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button--secondary button"'; |
|
122 | - $html .= ' style="' . $input->html_style() . '"'; |
|
123 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
124 | - $html .= ' ' . $input->other_html_attributes() . '>'; |
|
125 | - $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
126 | - $html .= $select_button_text; |
|
127 | - $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
128 | - $html .= '</button>'; |
|
120 | + $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
121 | + $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button--secondary button"'; |
|
122 | + $html .= ' style="' . $input->html_style() . '"'; |
|
123 | + $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
124 | + $html .= ' ' . $input->other_html_attributes() . '>'; |
|
125 | + $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
126 | + $html .= $select_button_text; |
|
127 | + $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
128 | + $html .= '</button>'; |
|
129 | 129 | |
130 | - $html .= EEH_HTML::div( |
|
131 | - '', |
|
132 | - $input->html_id() . '-options-dv', |
|
133 | - 'checkbox-dropdown-selector' |
|
134 | - ); |
|
135 | - $html .= EEH_HTML::link( |
|
136 | - '', |
|
137 | - '<span class="dashicons dashicons-no"></span>', |
|
138 | - esc_html__('close datetime selector', 'event_espresso'), |
|
139 | - '', |
|
140 | - 'close-espresso-notice' |
|
141 | - ); |
|
142 | - $html .= EEH_HTML::ul(); |
|
130 | + $html .= EEH_HTML::div( |
|
131 | + '', |
|
132 | + $input->html_id() . '-options-dv', |
|
133 | + 'checkbox-dropdown-selector' |
|
134 | + ); |
|
135 | + $html .= EEH_HTML::link( |
|
136 | + '', |
|
137 | + '<span class="dashicons dashicons-no"></span>', |
|
138 | + esc_html__('close datetime selector', 'event_espresso'), |
|
139 | + '', |
|
140 | + 'close-espresso-notice' |
|
141 | + ); |
|
142 | + $html .= EEH_HTML::ul(); |
|
143 | 143 | |
144 | - $input_raw_value = (array) $input->raw_value(); |
|
145 | - foreach ($input->options() as $value => $display_text) { |
|
146 | - $html .= EEH_HTML::li(); |
|
147 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
148 | - $html_id = $this->get_sub_input_id($value); |
|
149 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
150 | - $html .= " |
|
144 | + $input_raw_value = (array) $input->raw_value(); |
|
145 | + foreach ($input->options() as $value => $display_text) { |
|
146 | + $html .= EEH_HTML::li(); |
|
147 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
148 | + $html_id = $this->get_sub_input_id($value); |
|
149 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
150 | + $html .= " |
|
151 | 151 | <label for='$html_id' |
152 | 152 | id='$html_id-lbl' |
153 | 153 | class='ee-checkbox-label-after$label_size_class' |
154 | 154 | >"; |
155 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
156 | - $html .= '<input type="checkbox"'; |
|
157 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
158 | - $html .= ' id="' . $html_id . '"'; |
|
159 | - $html .= $input->html_class() ? ' class="' . $input->html_class() . '-option"' : ''; |
|
160 | - $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : ''; |
|
161 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
162 | - if ($input->hasLabel()) { |
|
163 | - $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
164 | - } |
|
165 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
166 | - ? ' checked' |
|
167 | - : ''; |
|
168 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
169 | - $html .= '>'; |
|
170 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
171 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
172 | - $html .= EEH_HTML::lix(); |
|
173 | - } |
|
174 | - $html .= EEH_HTML::ulx(); |
|
175 | - $html .= EEH_HTML::divx(); |
|
176 | - $html .= EEH_HTML::divx(); |
|
177 | - $html .= EEH_HTML::p( |
|
178 | - apply_filters( |
|
179 | - 'FHEE__EE_Checkbox_Dropdown_Selector_Display_Strategy__display__html', |
|
180 | - esc_html__( |
|
181 | - 'To view additional ticket options, click the "Filter by Date" button and select more dates.', |
|
182 | - 'event_espresso' |
|
183 | - ) |
|
184 | - ), |
|
185 | - $input->html_id() . '-date-time-filter-notice-pg', |
|
186 | - 'date-time-filter-notice-pg small-text lt-grey-text' |
|
187 | - ); |
|
188 | - $html .= EEH_HTML::br(); |
|
189 | - return $html; |
|
190 | - } |
|
155 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
156 | + $html .= '<input type="checkbox"'; |
|
157 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
158 | + $html .= ' id="' . $html_id . '"'; |
|
159 | + $html .= $input->html_class() ? ' class="' . $input->html_class() . '-option"' : ''; |
|
160 | + $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : ''; |
|
161 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
162 | + if ($input->hasLabel()) { |
|
163 | + $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
164 | + } |
|
165 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
166 | + ? ' checked' |
|
167 | + : ''; |
|
168 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
169 | + $html .= '>'; |
|
170 | + $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
171 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
172 | + $html .= EEH_HTML::lix(); |
|
173 | + } |
|
174 | + $html .= EEH_HTML::ulx(); |
|
175 | + $html .= EEH_HTML::divx(); |
|
176 | + $html .= EEH_HTML::divx(); |
|
177 | + $html .= EEH_HTML::p( |
|
178 | + apply_filters( |
|
179 | + 'FHEE__EE_Checkbox_Dropdown_Selector_Display_Strategy__display__html', |
|
180 | + esc_html__( |
|
181 | + 'To view additional ticket options, click the "Filter by Date" button and select more dates.', |
|
182 | + 'event_espresso' |
|
183 | + ) |
|
184 | + ), |
|
185 | + $input->html_id() . '-date-time-filter-notice-pg', |
|
186 | + 'date-time-filter-notice-pg small-text lt-grey-text' |
|
187 | + ); |
|
188 | + $html .= EEH_HTML::br(); |
|
189 | + return $html; |
|
190 | + } |
|
191 | 191 | } |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | { |
18 | 18 | wp_register_style( |
19 | 19 | 'checkbox_dropdown_selector', |
20 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
20 | + EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css', |
|
21 | 21 | ['espresso_default'], |
22 | 22 | EVENT_ESPRESSO_VERSION |
23 | 23 | ); |
24 | 24 | wp_register_style( |
25 | 25 | 'espresso_default', |
26 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
26 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
27 | 27 | ['dashicons'], |
28 | 28 | EVENT_ESPRESSO_VERSION |
29 | 29 | ); |
30 | 30 | wp_enqueue_style('checkbox_dropdown_selector'); |
31 | 31 | wp_register_script( |
32 | 32 | 'checkbox_dropdown_selector', |
33 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
33 | + EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js', |
|
34 | 34 | ['jquery'], |
35 | 35 | EVENT_ESPRESSO_VERSION, |
36 | 36 | true |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function iframe_css(array $iframe_css): array |
69 | 69 | { |
70 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
70 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css'; |
|
71 | 71 | return $iframe_css; |
72 | 72 | } |
73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function iframe_js(array $iframe_js): array |
82 | 82 | { |
83 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
83 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js'; |
|
84 | 84 | return $iframe_js; |
85 | 85 | } |
86 | 86 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
99 | 99 | $input->set_label_sizes(); |
100 | 100 | $label_size_class = $input->get_label_size_class(); |
101 | - if (! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
101 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
102 | 102 | EE_Error::doing_it_wrong( |
103 | 103 | 'EE_Checkbox_Display_Strategy::display()', |
104 | 104 | sprintf( |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ), |
109 | 109 | $input->html_id(), |
110 | 110 | var_export($input->raw_value(), true), |
111 | - $input->html_name() . '[]' |
|
111 | + $input->html_name().'[]' |
|
112 | 112 | ), |
113 | 113 | '4.8.1' |
114 | 114 | ); |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | |
118 | 118 | $html = EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
119 | 119 | |
120 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
121 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button--secondary button"'; |
|
122 | - $html .= ' style="' . $input->html_style() . '"'; |
|
123 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
124 | - $html .= ' ' . $input->other_html_attributes() . '>'; |
|
120 | + $html .= '<button id="'.$input->html_id().'-btn"'; |
|
121 | + $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button--secondary button"'; |
|
122 | + $html .= ' style="'.$input->html_style().'"'; |
|
123 | + $html .= ' data-target="'.$input->html_id().'-options-dv"'; |
|
124 | + $html .= ' '.$input->other_html_attributes().'>'; |
|
125 | 125 | $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
126 | 126 | $html .= $select_button_text; |
127 | 127 | $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $html .= EEH_HTML::div( |
131 | 131 | '', |
132 | - $input->html_id() . '-options-dv', |
|
132 | + $input->html_id().'-options-dv', |
|
133 | 133 | 'checkbox-dropdown-selector' |
134 | 134 | ); |
135 | 135 | $html .= EEH_HTML::link( |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | >"; |
155 | 155 | $html .= EEH_HTML::nl(1, 'checkbox'); |
156 | 156 | $html .= '<input type="checkbox"'; |
157 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
158 | - $html .= ' id="' . $html_id . '"'; |
|
159 | - $html .= $input->html_class() ? ' class="' . $input->html_class() . '-option"' : ''; |
|
160 | - $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : ''; |
|
161 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
157 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
158 | + $html .= ' id="'.$html_id.'"'; |
|
159 | + $html .= $input->html_class() ? ' class="'.$input->html_class().'-option"' : ''; |
|
160 | + $html .= $input->html_style() ? ' style="'.$input->html_style().'"' : ''; |
|
161 | + $html .= ' value="'.esc_attr($value).'"'; |
|
162 | 162 | if ($input->hasLabel()) { |
163 | - $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
163 | + $html .= ' aria-labelledby="'.$html_id.'-lbl"'; |
|
164 | 164 | } |
165 | 165 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
166 | 166 | ? ' checked' |
167 | 167 | : ''; |
168 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
168 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
169 | 169 | $html .= '>'; |
170 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
171 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
170 | + $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>'; |
|
171 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
172 | 172 | $html .= EEH_HTML::lix(); |
173 | 173 | } |
174 | 174 | $html .= EEH_HTML::ulx(); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'event_espresso' |
183 | 183 | ) |
184 | 184 | ), |
185 | - $input->html_id() . '-date-time-filter-notice-pg', |
|
185 | + $input->html_id().'-date-time-filter-notice-pg', |
|
186 | 186 | 'date-time-filter-notice-pg small-text lt-grey-text' |
187 | 187 | ); |
188 | 188 | $html .= EEH_HTML::br(); |
@@ -14,64 +14,64 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * The html "type" attribute value. default is "text" |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected string $_type; |
|
17 | + /** |
|
18 | + * The html "type" attribute value. default is "text" |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected string $_type; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param string $type |
|
27 | - */ |
|
28 | - public function __construct(string $type = 'text') |
|
29 | - { |
|
30 | - $this->_type = $type; |
|
31 | - parent::__construct(); |
|
32 | - } |
|
25 | + /** |
|
26 | + * @param string $type |
|
27 | + */ |
|
28 | + public function __construct(string $type = 'text') |
|
29 | + { |
|
30 | + $this->_type = $type; |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Gets the html "type" attribute's value |
|
37 | - * |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function get_type(): string |
|
41 | - { |
|
42 | - if ( |
|
43 | - $this->_type === 'email' |
|
44 | - && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', true) |
|
45 | - ) { |
|
46 | - return 'text'; |
|
47 | - } |
|
48 | - return $this->_type; |
|
49 | - } |
|
35 | + /** |
|
36 | + * Gets the html "type" attribute's value |
|
37 | + * |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function get_type(): string |
|
41 | + { |
|
42 | + if ( |
|
43 | + $this->_type === 'email' |
|
44 | + && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', true) |
|
45 | + ) { |
|
46 | + return 'text'; |
|
47 | + } |
|
48 | + return $this->_type; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return string of html to display the field |
|
54 | - * @throws EE_Error |
|
55 | - */ |
|
56 | - public function display(): string |
|
57 | - { |
|
58 | - $type = $this->get_type(); |
|
59 | - $name = $this->_input->html_name(); |
|
60 | - $html_id = $this->_input->html_id(); |
|
61 | - $class = $this->_input->required() |
|
62 | - ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() |
|
63 | - : $this->_input->html_class(); |
|
64 | - $labelledby = $this->_input->hasLabel() |
|
65 | - ? ' aria-labelledby="' . $this->_input->html_label_id() . '"' |
|
66 | - : ''; |
|
67 | - // add html5 required |
|
68 | - $required = $this->_input->required() ? ' required' : ''; |
|
69 | - $value = $this->_input->raw_value_in_form(); |
|
70 | - $style = $this->_input->html_style(); |
|
71 | - $style = $style ? " style=\"$style\"" : ''; |
|
72 | - $attributes = $this->_input->other_html_attributes(); |
|
73 | - $data_attributes = $this->dataAttributesString($this->_input->dataAttributes()); |
|
74 | - return " |
|
52 | + /** |
|
53 | + * @return string of html to display the field |
|
54 | + * @throws EE_Error |
|
55 | + */ |
|
56 | + public function display(): string |
|
57 | + { |
|
58 | + $type = $this->get_type(); |
|
59 | + $name = $this->_input->html_name(); |
|
60 | + $html_id = $this->_input->html_id(); |
|
61 | + $class = $this->_input->required() |
|
62 | + ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() |
|
63 | + : $this->_input->html_class(); |
|
64 | + $labelledby = $this->_input->hasLabel() |
|
65 | + ? ' aria-labelledby="' . $this->_input->html_label_id() . '"' |
|
66 | + : ''; |
|
67 | + // add html5 required |
|
68 | + $required = $this->_input->required() ? ' required' : ''; |
|
69 | + $value = $this->_input->raw_value_in_form(); |
|
70 | + $style = $this->_input->html_style(); |
|
71 | + $style = $style ? " style=\"$style\"" : ''; |
|
72 | + $attributes = $this->_input->other_html_attributes(); |
|
73 | + $data_attributes = $this->dataAttributesString($this->_input->dataAttributes()); |
|
74 | + return " |
|
75 | 75 | <input type=\"$type\" name=\"$name\" id=\"$html_id\" class=\"$class\" value=\"$value\"$labelledby$attributes$data_attributes$style$required />"; |
76 | - } |
|
76 | + } |
|
77 | 77 | } |
@@ -59,10 +59,10 @@ |
||
59 | 59 | $name = $this->_input->html_name(); |
60 | 60 | $html_id = $this->_input->html_id(); |
61 | 61 | $class = $this->_input->required() |
62 | - ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() |
|
62 | + ? $this->_input->required_css_class().' '.$this->_input->html_class() |
|
63 | 63 | : $this->_input->html_class(); |
64 | 64 | $labelledby = $this->_input->hasLabel() |
65 | - ? ' aria-labelledby="' . $this->_input->html_label_id() . '"' |
|
65 | + ? ' aria-labelledby="'.$this->_input->html_label_id().'"' |
|
66 | 66 | : ''; |
67 | 67 | // add html5 required |
68 | 68 | $required = $this->_input->required() ? ' required' : ''; |
@@ -2,29 +2,29 @@ discard block |
||
2 | 2 | |
3 | 3 | class EE_Text_Area_Display_Strategy extends EE_Display_Strategy_Base |
4 | 4 | { |
5 | - /** |
|
6 | - * @return string of html to display the field |
|
7 | - * @throws EE_Error |
|
8 | - */ |
|
9 | - public function display(): string |
|
10 | - { |
|
11 | - $input = $this->_input; |
|
12 | - $raw_value = maybe_serialize((string) $input->raw_value()); |
|
13 | - if ($input instanceof EE_Text_Area_Input) { |
|
14 | - $rows = $input->get_rows(); |
|
15 | - $cols = $input->get_cols(); |
|
16 | - } else { |
|
17 | - $rows = 4; |
|
18 | - $cols = 20; |
|
19 | - } |
|
5 | + /** |
|
6 | + * @return string of html to display the field |
|
7 | + * @throws EE_Error |
|
8 | + */ |
|
9 | + public function display(): string |
|
10 | + { |
|
11 | + $input = $this->_input; |
|
12 | + $raw_value = maybe_serialize((string) $input->raw_value()); |
|
13 | + if ($input instanceof EE_Text_Area_Input) { |
|
14 | + $rows = $input->get_rows(); |
|
15 | + $cols = $input->get_cols(); |
|
16 | + } else { |
|
17 | + $rows = 4; |
|
18 | + $cols = 20; |
|
19 | + } |
|
20 | 20 | |
21 | - $labelledby = $input->hasLabel() ? ' aria-labelledby="' . $input->html_label_id() . '"' : ''; |
|
22 | - $other_attributes = $input->other_html_attributes(); |
|
23 | - $data_attributes = $this->dataAttributesString($input->dataAttributes()); |
|
21 | + $labelledby = $input->hasLabel() ? ' aria-labelledby="' . $input->html_label_id() . '"' : ''; |
|
22 | + $other_attributes = $input->other_html_attributes(); |
|
23 | + $data_attributes = $this->dataAttributesString($input->dataAttributes()); |
|
24 | 24 | |
25 | - $text = esc_textarea($raw_value); |
|
25 | + $text = esc_textarea($raw_value); |
|
26 | 26 | |
27 | - $html = " |
|
27 | + $html = " |
|
28 | 28 | <textarea id='{$input->html_id()}' |
29 | 29 | name='{$input->html_name()}' |
30 | 30 | class='{$input->html_class()}' |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | cols='$cols' |
37 | 37 | >$text</textarea>"; |
38 | 38 | |
39 | - foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
40 | - if ( |
|
41 | - $validation_strategy instanceof EE_Simple_HTML_Validation_Strategy |
|
42 | - || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy |
|
43 | - ) { |
|
44 | - $html .= sprintf( |
|
45 | - esc_html__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), |
|
46 | - '<p class="ee-question-desc description">', |
|
47 | - $validation_strategy->get_list_of_allowed_tags(), |
|
48 | - '</p>' |
|
49 | - ); |
|
50 | - } |
|
51 | - } |
|
52 | - return $html; |
|
53 | - } |
|
39 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
40 | + if ( |
|
41 | + $validation_strategy instanceof EE_Simple_HTML_Validation_Strategy |
|
42 | + || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy |
|
43 | + ) { |
|
44 | + $html .= sprintf( |
|
45 | + esc_html__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), |
|
46 | + '<p class="ee-question-desc description">', |
|
47 | + $validation_strategy->get_list_of_allowed_tags(), |
|
48 | + '</p>' |
|
49 | + ); |
|
50 | + } |
|
51 | + } |
|
52 | + return $html; |
|
53 | + } |
|
54 | 54 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $cols = 20; |
19 | 19 | } |
20 | 20 | |
21 | - $labelledby = $input->hasLabel() ? ' aria-labelledby="' . $input->html_label_id() . '"' : ''; |
|
21 | + $labelledby = $input->hasLabel() ? ' aria-labelledby="'.$input->html_label_id().'"' : ''; |
|
22 | 22 | $other_attributes = $input->other_html_attributes(); |
23 | 23 | $data_attributes = $this->dataAttributesString($input->dataAttributes()); |
24 | 24 |
@@ -11,65 +11,65 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Radio_Button_Display_Strategy extends EE_Compound_Input_Display_Strategy |
13 | 13 | { |
14 | - /** |
|
15 | - * |
|
16 | - * @throws EE_Error |
|
17 | - * @return string of html to display the field |
|
18 | - */ |
|
19 | - public function display(): string |
|
20 | - { |
|
21 | - $input = $this->get_input(); |
|
22 | - $input->set_label_sizes(); |
|
23 | - $label_size_class = $input->get_label_size_class(); |
|
24 | - $html = ''; |
|
25 | - foreach ($input->options() as $value => $display_text) { |
|
26 | - $value = $input->get_normalization_strategy()->unnormalize($value); |
|
14 | + /** |
|
15 | + * |
|
16 | + * @throws EE_Error |
|
17 | + * @return string of html to display the field |
|
18 | + */ |
|
19 | + public function display(): string |
|
20 | + { |
|
21 | + $input = $this->get_input(); |
|
22 | + $input->set_label_sizes(); |
|
23 | + $label_size_class = $input->get_label_size_class(); |
|
24 | + $html = ''; |
|
25 | + foreach ($input->options() as $value => $display_text) { |
|
26 | + $value = $input->get_normalization_strategy()->unnormalize($value); |
|
27 | 27 | |
28 | - $html_id = $this->get_sub_input_id($value); |
|
29 | - $html .= EEH_HTML::nl(0, 'radio'); |
|
28 | + $html_id = $this->get_sub_input_id($value); |
|
29 | + $html .= EEH_HTML::nl(0, 'radio'); |
|
30 | 30 | |
31 | - $html .= $this->_opening_tag('label'); |
|
32 | - $html .= $this->_attributes_string( |
|
33 | - array( |
|
34 | - 'for' => $html_id, |
|
35 | - 'id' => $html_id . '-lbl', |
|
36 | - 'class' => apply_filters( |
|
37 | - 'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class', |
|
38 | - 'ee-radio-label-after' . $label_size_class, |
|
39 | - $this, |
|
40 | - $input, |
|
41 | - $value |
|
42 | - ) |
|
43 | - ) |
|
44 | - ); |
|
45 | - $html .= '>'; |
|
46 | - $html .= EEH_HTML::nl(1, 'radio'); |
|
47 | - $html .= $this->_opening_tag('input'); |
|
48 | - $attributes = array( |
|
49 | - 'id' => $html_id, |
|
50 | - 'name' => $input->html_name(), |
|
51 | - 'class' => $input->html_class(), |
|
52 | - 'style' => $input->html_style(), |
|
53 | - 'type' => 'radio', |
|
54 | - 'value' => $value, |
|
55 | - 0 => $input->other_html_attributes(), |
|
56 | - 'data-question_label' => "$html_id-lbl" |
|
57 | - ); |
|
58 | - if ($input->raw_value() === $value) { |
|
59 | - $attributes['checked'] = 'checked'; |
|
60 | - } |
|
61 | - $html .= $this->_attributes_string($attributes); |
|
31 | + $html .= $this->_opening_tag('label'); |
|
32 | + $html .= $this->_attributes_string( |
|
33 | + array( |
|
34 | + 'for' => $html_id, |
|
35 | + 'id' => $html_id . '-lbl', |
|
36 | + 'class' => apply_filters( |
|
37 | + 'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class', |
|
38 | + 'ee-radio-label-after' . $label_size_class, |
|
39 | + $this, |
|
40 | + $input, |
|
41 | + $value |
|
42 | + ) |
|
43 | + ) |
|
44 | + ); |
|
45 | + $html .= '>'; |
|
46 | + $html .= EEH_HTML::nl(1, 'radio'); |
|
47 | + $html .= $this->_opening_tag('input'); |
|
48 | + $attributes = array( |
|
49 | + 'id' => $html_id, |
|
50 | + 'name' => $input->html_name(), |
|
51 | + 'class' => $input->html_class(), |
|
52 | + 'style' => $input->html_style(), |
|
53 | + 'type' => 'radio', |
|
54 | + 'value' => $value, |
|
55 | + 0 => $input->other_html_attributes(), |
|
56 | + 'data-question_label' => "$html_id-lbl" |
|
57 | + ); |
|
58 | + if ($input->raw_value() === $value) { |
|
59 | + $attributes['checked'] = 'checked'; |
|
60 | + } |
|
61 | + $html .= $this->_attributes_string($attributes); |
|
62 | 62 | |
63 | - if ($input->hasLabel()) { |
|
64 | - $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
65 | - } |
|
63 | + if ($input->hasLabel()) { |
|
64 | + $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
65 | + } |
|
66 | 66 | |
67 | - $html .= '> '; |
|
68 | - $html .= $display_text; |
|
69 | - $html .= EEH_HTML::nl(-1, 'radio') . '</label>'; |
|
70 | - } |
|
71 | - $html .= EEH_HTML::div('', '', 'clear-float'); |
|
72 | - $html .= EEH_HTML::divx(); |
|
73 | - return apply_filters('FHEE__EE_Radio_Button_Display_Strategy__display', $html, $this, $this->_input); |
|
74 | - } |
|
67 | + $html .= '> '; |
|
68 | + $html .= $display_text; |
|
69 | + $html .= EEH_HTML::nl(-1, 'radio') . '</label>'; |
|
70 | + } |
|
71 | + $html .= EEH_HTML::div('', '', 'clear-float'); |
|
72 | + $html .= EEH_HTML::divx(); |
|
73 | + return apply_filters('FHEE__EE_Radio_Button_Display_Strategy__display', $html, $this, $this->_input); |
|
74 | + } |
|
75 | 75 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | $html .= $this->_attributes_string( |
33 | 33 | array( |
34 | 34 | 'for' => $html_id, |
35 | - 'id' => $html_id . '-lbl', |
|
35 | + 'id' => $html_id.'-lbl', |
|
36 | 36 | 'class' => apply_filters( |
37 | 37 | 'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class', |
38 | - 'ee-radio-label-after' . $label_size_class, |
|
38 | + 'ee-radio-label-after'.$label_size_class, |
|
39 | 39 | $this, |
40 | 40 | $input, |
41 | 41 | $value |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | $html .= $this->_attributes_string($attributes); |
62 | 62 | |
63 | 63 | if ($input->hasLabel()) { |
64 | - $html .= ' aria-labelledby="' . $html_id . '-lbl"'; |
|
64 | + $html .= ' aria-labelledby="'.$html_id.'-lbl"'; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $html .= '> '; |
68 | 68 | $html .= $display_text; |
69 | - $html .= EEH_HTML::nl(-1, 'radio') . '</label>'; |
|
69 | + $html .= EEH_HTML::nl(-1, 'radio').'</label>'; |
|
70 | 70 | } |
71 | 71 | $html .= EEH_HTML::div('', '', 'clear-float'); |
72 | 72 | $html .= EEH_HTML::divx(); |