@@ -13,41 +13,41 @@ |
||
13 | 13 | class EE_File_Normalization extends EE_Normalization_Strategy_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Convert the $_FILES inputted data into a well-defined object. |
|
18 | - * @param string $value_to_normalize |
|
19 | - * @return UploadedFile |
|
20 | - */ |
|
21 | - public function normalize($value_to_normalize) |
|
22 | - { |
|
23 | - if (is_array($value_to_normalize)) { |
|
24 | - return new UploadedFile($value_to_normalize); |
|
25 | - } elseif( $value_to_normalize instanceof UploadedFile){ |
|
26 | - return $value_to_normalize; |
|
27 | - } else { |
|
28 | - throw new EE_Validation_Error( |
|
29 | - esc_html__('The file input has an inavlid format.', 'event_espresso') |
|
30 | - ); |
|
31 | - } |
|
32 | - } |
|
16 | + /** |
|
17 | + * Convert the $_FILES inputted data into a well-defined object. |
|
18 | + * @param string $value_to_normalize |
|
19 | + * @return UploadedFile |
|
20 | + */ |
|
21 | + public function normalize($value_to_normalize) |
|
22 | + { |
|
23 | + if (is_array($value_to_normalize)) { |
|
24 | + return new UploadedFile($value_to_normalize); |
|
25 | + } elseif( $value_to_normalize instanceof UploadedFile){ |
|
26 | + return $value_to_normalize; |
|
27 | + } else { |
|
28 | + throw new EE_Validation_Error( |
|
29 | + esc_html__('The file input has an inavlid format.', 'event_espresso') |
|
30 | + ); |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Convert the object back into a string of the filename. |
|
37 | - * |
|
38 | - * @param string $normalized_value |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function unnormalize($normalized_value) |
|
42 | - { |
|
43 | - if ($normalized_value instanceof UploadedFile) { |
|
44 | - // Leave it as the object, it can be treated like a string because it |
|
45 | - // overrides __toString() |
|
46 | - return $normalized_value; |
|
47 | - } elseif (is_array($normalized_value)) { |
|
48 | - return new UploadedFile($normalized_value); |
|
49 | - } else { |
|
50 | - return (string) $normalized_value; |
|
51 | - } |
|
52 | - } |
|
35 | + /** |
|
36 | + * Convert the object back into a string of the filename. |
|
37 | + * |
|
38 | + * @param string $normalized_value |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function unnormalize($normalized_value) |
|
42 | + { |
|
43 | + if ($normalized_value instanceof UploadedFile) { |
|
44 | + // Leave it as the object, it can be treated like a string because it |
|
45 | + // overrides __toString() |
|
46 | + return $normalized_value; |
|
47 | + } elseif (is_array($normalized_value)) { |
|
48 | + return new UploadedFile($normalized_value); |
|
49 | + } else { |
|
50 | + return (string) $normalized_value; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | \ No newline at end of file |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | if (is_array($value_to_normalize)) { |
24 | 24 | return new UploadedFile($value_to_normalize); |
25 | - } elseif( $value_to_normalize instanceof UploadedFile){ |
|
25 | + } elseif ($value_to_normalize instanceof UploadedFile) { |
|
26 | 26 | return $value_to_normalize; |
27 | 27 | } else { |
28 | 28 | throw new EE_Validation_Error( |
@@ -10,20 +10,20 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_File_Input_Display_Strategy extends EE_Text_Input_Display_Strategy |
12 | 12 | { |
13 | - /** |
|
14 | - * The html "type" attribute value. default is "text" |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $allowed_extensions; |
|
13 | + /** |
|
14 | + * The html "type" attribute value. default is "text" |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $allowed_extensions; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param string $allowed_extensions |
|
23 | - */ |
|
24 | - public function __construct($type = 'file', $allowed_extensions = []) |
|
25 | - { |
|
26 | - $this->allowed_extensions = $allowed_extensions; |
|
27 | - parent::__construct($type); |
|
28 | - } |
|
21 | + /** |
|
22 | + * @param string $allowed_extensions |
|
23 | + */ |
|
24 | + public function __construct($type = 'file', $allowed_extensions = []) |
|
25 | + { |
|
26 | + $this->allowed_extensions = $allowed_extensions; |
|
27 | + parent::__construct($type); |
|
28 | + } |
|
29 | 29 | } |
@@ -13,58 +13,58 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base |
15 | 15 | { |
16 | - /** |
|
17 | - * The html "type" attribute value. default is "text" |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $_type; |
|
16 | + /** |
|
17 | + * The html "type" attribute value. default is "text" |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $_type; |
|
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @param string $allowed_extensions |
|
26 | - */ |
|
27 | - public function __construct($allowed_extensions = 'text') |
|
28 | - { |
|
29 | - $this->_type = $allowed_extensions; |
|
30 | - parent::__construct(); |
|
31 | - } |
|
24 | + /** |
|
25 | + * @param string $allowed_extensions |
|
26 | + */ |
|
27 | + public function __construct($allowed_extensions = 'text') |
|
28 | + { |
|
29 | + $this->_type = $allowed_extensions; |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Gets the html "type" attribute's value |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function get_type() |
|
40 | - { |
|
41 | - if ($this->_type === 'email' |
|
42 | - && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
43 | - ) { |
|
44 | - return 'text'; |
|
45 | - } |
|
46 | - return $this->_type; |
|
47 | - } |
|
35 | + /** |
|
36 | + * Gets the html "type" attribute's value |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function get_type() |
|
40 | + { |
|
41 | + if ($this->_type === 'email' |
|
42 | + && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
43 | + ) { |
|
44 | + return 'text'; |
|
45 | + } |
|
46 | + return $this->_type; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * |
|
53 | - * @return string of html to display the field |
|
54 | - */ |
|
55 | - public function display() |
|
56 | - { |
|
57 | - $input = '<input type="'. $this->get_type() .'"'; |
|
58 | - $input .= ' name="' . $this->_input->html_name() . '"'; |
|
59 | - $input .= ' id="' . $this->_input->html_id() . '"'; |
|
60 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
61 | - $input .= ' class="' . $class . '"'; |
|
62 | - // add html5 required |
|
63 | - $input .= $this->_input->required() ? ' required' : ''; |
|
64 | - $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
65 | - $input .= ' style="' . $this->_input->html_style() . '"'; |
|
66 | - $input .= $this->_input->other_html_attributes(); |
|
67 | - $input .= '/>'; |
|
68 | - return $input; |
|
69 | - } |
|
51 | + /** |
|
52 | + * |
|
53 | + * @return string of html to display the field |
|
54 | + */ |
|
55 | + public function display() |
|
56 | + { |
|
57 | + $input = '<input type="'. $this->get_type() .'"'; |
|
58 | + $input .= ' name="' . $this->_input->html_name() . '"'; |
|
59 | + $input .= ' id="' . $this->_input->html_id() . '"'; |
|
60 | + $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
61 | + $input .= ' class="' . $class . '"'; |
|
62 | + // add html5 required |
|
63 | + $input .= $this->_input->required() ? ' required' : ''; |
|
64 | + $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
65 | + $input .= ' style="' . $this->_input->html_style() . '"'; |
|
66 | + $input .= $this->_input->other_html_attributes(); |
|
67 | + $input .= '/>'; |
|
68 | + return $input; |
|
69 | + } |
|
70 | 70 | } |