@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php. |
11 | 11 | * @author Mike Nelson |
12 | 12 | */ |
13 | -class EE_Model_Matching_Query_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
13 | +class EE_Model_Matching_Query_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | * @param array $query_params @see EEM_Base::get_all() |
28 | 28 | * @param string $input_field_name the input will be treated as this field's value |
29 | 29 | */ |
30 | - public function __construct( $validation_error_message = NULL, $model_name = '', $query_params = array(), $input_field_name = '' ) { |
|
31 | - if( ! EE_Registry::instance()->is_model_name( $model_name ) ) { |
|
32 | - throw new EE_Error( sprintf( __( 'You must provide a valid model object ', 'event_espresso'), $model_name ) ); |
|
30 | + public function __construct($validation_error_message = NULL, $model_name = '', $query_params = array(), $input_field_name = '') { |
|
31 | + if ( ! EE_Registry::instance()->is_model_name($model_name)) { |
|
32 | + throw new EE_Error(sprintf(__('You must provide a valid model object ', 'event_espresso'), $model_name)); |
|
33 | 33 | } |
34 | - $this->_model = EE_Registry::instance()->load_model( $model_name ); |
|
34 | + $this->_model = EE_Registry::instance()->load_model($model_name); |
|
35 | 35 | $this->_query_params = $query_params; |
36 | - if( empty( $input_field_name ) ) { |
|
36 | + if (empty($input_field_name)) { |
|
37 | 37 | $input_field_name = $this->_model->primary_key_name(); |
38 | 38 | } |
39 | 39 | $this->_input_field_name = $input_field_name; |
40 | - parent::__construct( $validation_error_message ); |
|
40 | + parent::__construct($validation_error_message); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param $normalized_value |
45 | 45 | */ |
46 | 46 | public function validate($normalized_value) { |
47 | - if( empty( $normalized_value ) ) { |
|
47 | + if (empty($normalized_value)) { |
|
48 | 48 | return true; |
49 | 49 | } |
50 | 50 | $combined_query_params = $this->get_query_params(); |
51 | - $combined_query_params[0][ $this->treat_input_as_field() ] = $normalized_value; |
|
52 | - if( ! $this->get_model()->exists( $combined_query_params ) ) { |
|
53 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'no_matching_model_object' ); |
|
51 | + $combined_query_params[0][$this->treat_input_as_field()] = $normalized_value; |
|
52 | + if ( ! $this->get_model()->exists($combined_query_params)) { |
|
53 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'no_matching_model_object'); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return array |
68 | 68 | */ |
69 | 69 | public function get_query_params() { |
70 | - return (array)$this->_query_params; |
|
70 | + return (array) $this->_query_params; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base{ |
|
11 | +class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @var string $_model_name |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * And the arguments accepted by EE_Form_Input_With_Options_Base |
41 | 41 | * @throws \EE_Error |
42 | 42 | */ |
43 | - public function __construct( $input_settings = array() ) { |
|
43 | + public function __construct($input_settings = array()) { |
|
44 | 44 | //needed input settings: |
45 | 45 | //select2_args |
46 | 46 | $this->_model_name = EEH_Array::is_set( |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $query_params = EEH_Array::is_set( |
53 | 53 | $input_settings, |
54 | 54 | 'query_params', |
55 | - array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ) |
|
55 | + array('limit' => 10, 'caps' => EEM_Base::caps_read_admin) |
|
56 | 56 | ); |
57 | 57 | $this->_value_field_name = EEH_Array::is_set( |
58 | 58 | $input_settings, |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $this->_display_field_name = EEH_Array::is_set( |
63 | 63 | $input_settings, |
64 | 64 | 'display_field_name', |
65 | - $model->get_a_field_of_type( 'EE_Text_Field_Base' )->get_name() |
|
65 | + $model->get_a_field_of_type('EE_Text_Field_Base')->get_name() |
|
66 | 66 | ); |
67 | 67 | $this->_add_validation_strategy( |
68 | 68 | new EE_Model_Matching_Query_Validation_Strategy( |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | ); |
75 | 75 | //get resource endpoint |
76 | 76 | $rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read(); |
77 | - $rest_controller->set_requested_version( EED_Core_Rest_Api::latest_rest_api_version() ); |
|
78 | - $url = $rest_controller->get_versioned_link_to( EEH_Inflector::pluralize_and_lower( $this->_model_name ) ); |
|
77 | + $rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version()); |
|
78 | + $url = $rest_controller->get_versioned_link_to(EEH_Inflector::pluralize_and_lower($this->_model_name)); |
|
79 | 79 | $default_select2_args = array( |
80 | 80 | 'ajax' => array( |
81 | 81 | 'url' => $url, |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | 'delay' => '250', |
84 | 84 | 'data_interface' => 'EE_Select2_REST_API_Interface', |
85 | 85 | 'data_interface_args' => array( |
86 | - 'default_query_params' => (object)$query_params, |
|
86 | + 'default_query_params' => (object) $query_params, |
|
87 | 87 | 'display_field' => $this->_display_field_name, |
88 | 88 | 'value_field' => $this->_value_field_name, |
89 | - 'nonce' => wp_create_nonce( 'wp_rest' ) |
|
89 | + 'nonce' => wp_create_nonce('wp_rest') |
|
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | 'cache' => true, |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | ); |
95 | 95 | $select2_args = array_replace_recursive( |
96 | 96 | $default_select2_args, |
97 | - EEH_Array::is_set( $input_settings, 'select2_args', array() ) |
|
97 | + EEH_Array::is_set($input_settings, 'select2_args', array()) |
|
98 | 98 | ); |
99 | - $this->set_display_strategy( new EE_Select2_Display_Strategy( $select2_args ) ); |
|
100 | - parent::__construct( array(), $input_settings ); |
|
99 | + $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args)); |
|
100 | + parent::__construct(array(), $input_settings); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -110,33 +110,33 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public function set_default( $value ) { |
|
113 | + public function set_default($value) { |
|
114 | 114 | |
115 | - $values_for_options = (array)$value; |
|
116 | - $value_field = $this->_get_model()->field_settings_for( $this->_value_field_name ); |
|
117 | - $display_field = $this->_get_model()->field_settings_for( $this->_display_field_name ); |
|
115 | + $values_for_options = (array) $value; |
|
116 | + $value_field = $this->_get_model()->field_settings_for($this->_value_field_name); |
|
117 | + $display_field = $this->_get_model()->field_settings_for($this->_display_field_name); |
|
118 | 118 | $display_values = $this->_get_model()->get_all_wpdb_results( |
119 | 119 | array( |
120 | 120 | array( |
121 | - $this->_value_field_name => array( 'IN', $values_for_options ) |
|
121 | + $this->_value_field_name => array('IN', $values_for_options) |
|
122 | 122 | ) |
123 | 123 | ), |
124 | 124 | ARRAY_A, |
125 | 125 | implode( |
126 | 126 | ',', |
127 | 127 | array( |
128 | - $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name, |
|
129 | - $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name |
|
128 | + $value_field->get_qualified_column().' AS '.$this->_value_field_name, |
|
129 | + $display_field->get_qualified_column().' AS '.$this->_display_field_name |
|
130 | 130 | ) |
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | $select_options = array(); |
134 | - foreach( $display_values as $db_rows ) { |
|
135 | - $db_rows = (array)$db_rows; |
|
136 | - $select_options[ $db_rows[ $this->_value_field_name ] ] = $db_rows[ $this->_display_field_name ]; |
|
134 | + foreach ($display_values as $db_rows) { |
|
135 | + $db_rows = (array) $db_rows; |
|
136 | + $select_options[$db_rows[$this->_value_field_name]] = $db_rows[$this->_display_field_name]; |
|
137 | 137 | } |
138 | - $this->set_select_options( $select_options ); |
|
139 | - parent::set_default( $value ); |
|
138 | + $this->set_select_options($select_options); |
|
139 | + parent::set_default($value); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @throws EE_Error |
146 | 146 | */ |
147 | 147 | protected function _get_model() { |
148 | - if( ! EE_Registry::instance()->is_model_name( $this->_model_name ) ) { |
|
148 | + if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) { |
|
149 | 149 | throw new EE_Error( |
150 | 150 | sprintf( |
151 | 151 | __( |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | } else { |
159 | - return EE_Registry::instance()->load_model( $this->_model_name ); |
|
159 | + return EE_Registry::instance()->load_model($this->_model_name); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base{ |
|
11 | +abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base { |
|
12 | 12 | /** |
13 | 13 | * returns HTML and javascript related to the displaying of this input |
14 | 14 | * @return string |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @param string $chars - exact string of characters to remove |
25 | 25 | * @return string |
26 | 26 | */ |
27 | - protected function _remove_chars( $string = '', $chars = '-' ) { |
|
28 | - $char_length = strlen( $chars ) * -1; |
|
27 | + protected function _remove_chars($string = '', $chars = '-') { |
|
28 | + $char_length = strlen($chars) * -1; |
|
29 | 29 | // if last three characters of string is " - ", then remove it |
30 | - return substr( $string, $char_length ) === $chars ? substr( $string, 0, $char_length ) : $string; |
|
30 | + return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | * @param string $chars - exact string of characters to be added to end of string |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - protected function _append_chars( $string = '', $chars = '-' ) { |
|
43 | - return $this->_remove_chars( $string, $chars ) . $chars; |
|
42 | + protected function _append_chars($string = '', $chars = '-') { |
|
43 | + return $this->_remove_chars($string, $chars).$chars; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param array $other_js_data |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - public function get_other_js_data( $other_js_data = array() ) { |
|
55 | + public function get_other_js_data($other_js_data = array()) { |
|
56 | 56 | return $other_js_data; |
57 | 57 | } |
58 | 58 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @since $VID:$ |
13 | 13 | * |
14 | 14 | */ |
15 | -class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy{ |
|
15 | +class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Arguments that will be passed into the select2 javascript constructor |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
26 | 26 | * to pass into the select2 js/html input. See https://select2.github.io |
27 | 27 | */ |
28 | - public function __construct( $select2_js_args = array() ) { |
|
28 | + public function __construct($select2_js_args = array()) { |
|
29 | 29 | $this->_select2_js_args = $select2_js_args; |
30 | 30 | parent::__construct(); |
31 | 31 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * the select2 css |
36 | 36 | */ |
37 | 37 | public function enqueue_js() { |
38 | - wp_enqueue_script( 'form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true ); |
|
39 | - wp_enqueue_style( 'select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all' ); |
|
38 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true); |
|
39 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Sets the exact js args which will be passed into the select2 js/html input |
52 | 52 | * @param array $js_args |
53 | 53 | */ |
54 | - public function set_js_args( $js_args ) { |
|
54 | + public function set_js_args($js_args) { |
|
55 | 55 | $this->_select2_js_args = $js_args; |
56 | 56 | } |
57 | 57 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param array $other_js_data |
61 | 61 | * @return array |
62 | 62 | */ |
63 | - public function get_other_js_data( $other_js_data = array() ) { |
|
64 | - $other_js_data = parent::get_other_js_data( $other_js_data ); |
|
65 | - if( ! isset( $other_js_data[ 'select2s' ] ) ) { |
|
63 | + public function get_other_js_data($other_js_data = array()) { |
|
64 | + $other_js_data = parent::get_other_js_data($other_js_data); |
|
65 | + if ( ! isset($other_js_data['select2s'])) { |
|
66 | 66 | $other_js_data['select2s'] = array(); |
67 | 67 | } |
68 | - $other_js_data[ 'select2s' ][ $this->_input->html_id() ] = $this->get_js_args(); |
|
68 | + $other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args(); |
|
69 | 69 | return $other_js_data; |
70 | 70 | } |
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -69,49 +69,49 @@ discard block |
||
69 | 69 | * } @see EE_Form_Section_Validatable::__construct() |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - public function __construct( $options_array = array() ){ |
|
73 | - $options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
72 | + public function __construct($options_array = array()) { |
|
73 | + $options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
74 | 74 | //call parent first, as it may be setting the name |
75 | 75 | parent::__construct($options_array); |
76 | 76 | //if they've included subsections in the constructor, add them now |
77 | - if( isset( $options_array['include'] )){ |
|
77 | + if (isset($options_array['include'])) { |
|
78 | 78 | //we are going to make sure we ONLY have those subsections to include |
79 | 79 | //AND we are going to make sure they're in that specified order |
80 | 80 | $reordered_subsections = array(); |
81 | - foreach($options_array['include'] as $input_name){ |
|
82 | - if(isset($this->_subsections[$input_name])){ |
|
81 | + foreach ($options_array['include'] as $input_name) { |
|
82 | + if (isset($this->_subsections[$input_name])) { |
|
83 | 83 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | $this->_subsections = $reordered_subsections; |
87 | 87 | } |
88 | - if(isset($options_array['exclude'])){ |
|
88 | + if (isset($options_array['exclude'])) { |
|
89 | 89 | $exclude = $options_array['exclude']; |
90 | 90 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
91 | 91 | } |
92 | - if(isset($options_array['layout_strategy'])){ |
|
92 | + if (isset($options_array['layout_strategy'])) { |
|
93 | 93 | $this->_layout_strategy = $options_array['layout_strategy']; |
94 | 94 | } |
95 | - if( ! $this->_layout_strategy){ |
|
95 | + if ( ! $this->_layout_strategy) { |
|
96 | 96 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
97 | 97 | } |
98 | 98 | $this->_layout_strategy->_construct_finalize($this); |
99 | 99 | |
100 | 100 | //ok so we are definitely going to want the forms JS, |
101 | 101 | //so enqueue it or remember to enqueue it during wp_enqueue_scripts |
102 | - if( did_action( 'wp_enqueue_scripts' ) |
|
103 | - || did_action( 'admin_enqueue_scripts' ) ) { |
|
102 | + if (did_action('wp_enqueue_scripts') |
|
103 | + || did_action('admin_enqueue_scripts')) { |
|
104 | 104 | //ok so they've constructed this object after when they should have. |
105 | 105 | //just enqueue the generic form scripts and initialize the form immediately in the JS |
106 | - \EE_Form_Section_Proper::wp_enqueue_scripts( true ); |
|
106 | + \EE_Form_Section_Proper::wp_enqueue_scripts(true); |
|
107 | 107 | } else { |
108 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
109 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
108 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
109 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
110 | 110 | } |
111 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
111 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
112 | 112 | |
113 | - if( isset( $options_array[ 'name' ] ) ) { |
|
114 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
113 | + if (isset($options_array['name'])) { |
|
114 | + $this->_construct_finalize(null, $options_array['name']); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | * @param string $name |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
127 | + public function _construct_finalize($parent_form_section, $name) { |
|
128 | 128 | parent::_construct_finalize($parent_form_section, $name); |
129 | 129 | $this->_set_default_name_if_empty(); |
130 | 130 | $this->_set_default_html_id_if_empty(); |
131 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
132 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
133 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
131 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
132 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
133 | + $subsection->_construct_finalize($this, $subsection_name); |
|
134 | 134 | } else { |
135 | 135 | throw new EE_Error( |
136 | 136 | sprintf( |
137 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
137 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
138 | 138 | $subsection_name, |
139 | 139 | get_class($this), |
140 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
140 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
141 | 141 | ) |
142 | 142 | ); |
143 | 143 | } |
144 | 144 | } |
145 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
145 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * Gets the layout strategy for this form section |
152 | 152 | * @return EE_Form_Section_Layout_Base |
153 | 153 | */ |
154 | - public function get_layout_strategy(){ |
|
154 | + public function get_layout_strategy() { |
|
155 | 155 | return $this->_layout_strategy; |
156 | 156 | } |
157 | 157 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param EE_Form_Input_Base $input |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function get_html_for_input($input){ |
|
166 | + public function get_html_for_input($input) { |
|
167 | 167 | return $this->_layout_strategy->layout_input($input); |
168 | 168 | } |
169 | 169 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param null $form_data |
177 | 177 | * @return boolean |
178 | 178 | */ |
179 | - public function was_submitted($form_data = NULL){ |
|
179 | + public function was_submitted($form_data = NULL) { |
|
180 | 180 | return $this->form_data_present_in($form_data); |
181 | 181 | } |
182 | 182 | |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | * (eg you validated the data then stored it in the DB) you may want to skip this step. |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
205 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
206 | - if( $req_data === NULL){ |
|
207 | - $req_data = array_merge( $_GET, $_POST ); |
|
204 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
205 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
206 | + if ($req_data === NULL) { |
|
207 | + $req_data = array_merge($_GET, $_POST); |
|
208 | 208 | } |
209 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
209 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
210 | 210 | $this->_normalize($req_data); |
211 | - if( $validate ){ |
|
211 | + if ($validate) { |
|
212 | 212 | $this->_validate(); |
213 | 213 | } |
214 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
214 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * the value being an array formatted in teh same way |
225 | 225 | * @param array $default_data |
226 | 226 | */ |
227 | - public function populate_defaults($default_data){ |
|
228 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
229 | - if(isset($default_data[$subsection_name])){ |
|
230 | - if($subsection instanceof EE_Form_Input_Base){ |
|
227 | + public function populate_defaults($default_data) { |
|
228 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
229 | + if (isset($default_data[$subsection_name])) { |
|
230 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
231 | 231 | $subsection->set_default($default_data[$subsection_name]); |
232 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
232 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
233 | 233 | $subsection->populate_defaults($default_data[$subsection_name]); |
234 | 234 | } |
235 | 235 | } |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @return EE_Form_Section_Base |
252 | 252 | * @throws \EE_Error |
253 | 253 | */ |
254 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
255 | - if( $require_construction_to_be_finalized ){ |
|
254 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
255 | + if ($require_construction_to_be_finalized) { |
|
256 | 256 | $this->ensure_construct_finalized_called(); |
257 | 257 | } |
258 | 258 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * Gets all the validatable subsections of this form section |
265 | 265 | * @return EE_Form_Section_Validatable[] |
266 | 266 | */ |
267 | - public function get_validatable_subsections(){ |
|
267 | + public function get_validatable_subsections() { |
|
268 | 268 | $validatable_subsections = array(); |
269 | - foreach($this->subsections() as $name=>$obj){ |
|
270 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
269 | + foreach ($this->subsections() as $name=>$obj) { |
|
270 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
271 | 271 | $validatable_subsections[$name] = $obj; |
272 | 272 | } |
273 | 273 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @return EE_Form_Input_Base |
288 | 288 | * @throws EE_Error |
289 | 289 | */ |
290 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
290 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
291 | 291 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
292 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
293 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
292 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
293 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
294 | 294 | } |
295 | 295 | return $subsection; |
296 | 296 | } |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | * @return EE_Form_Section_Proper |
309 | 309 | * @throws EE_Error |
310 | 310 | */ |
311 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
312 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
313 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
314 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
311 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
312 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
313 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
314 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
315 | 315 | } |
316 | 316 | return $subsection; |
317 | 317 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @return mixed depending on the input's type and its normalization strategy |
327 | 327 | * @throws \EE_Error |
328 | 328 | */ |
329 | - public function get_input_value($name){ |
|
329 | + public function get_input_value($name) { |
|
330 | 330 | $input = $this->get_input($name); |
331 | 331 | return $input->normalized_value(); |
332 | 332 | } |
@@ -339,16 +339,16 @@ discard block |
||
339 | 339 | * @return boolean |
340 | 340 | */ |
341 | 341 | public function is_valid() { |
342 | - if( ! $this->has_received_submission()){ |
|
342 | + if ( ! $this->has_received_submission()) { |
|
343 | 343 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
344 | 344 | } |
345 | - if( ! parent::is_valid()){ |
|
345 | + if ( ! parent::is_valid()) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | //ok so no errors general to this entire form section. so let's check the subsections |
349 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
350 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){ |
|
351 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
349 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
350 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') { |
|
351 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
352 | 352 | return false; |
353 | 353 | } |
354 | 354 | } |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * gets teh default name of this form section if none is specified |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - protected function _set_default_name_if_empty(){ |
|
365 | - if( ! $this->_name ){ |
|
364 | + protected function _set_default_name_if_empty() { |
|
365 | + if ( ! $this->_name) { |
|
366 | 366 | $classname = get_class($this); |
367 | 367 | $default_name = str_replace("EE_", "", $classname); |
368 | - $this->_name = $default_name; |
|
368 | + $this->_name = $default_name; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * and get_html when you are about to display the form. |
381 | 381 | * @throws \EE_Error |
382 | 382 | */ |
383 | - public function get_html_and_js(){ |
|
383 | + public function get_html_and_js() { |
|
384 | 384 | //no doing_it_wrong yet because we ourselves are still doing it wrong... |
385 | 385 | //and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts" |
386 | 386 | $this->enqueue_js(); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @return string |
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | - public function get_html(){ |
|
398 | + public function get_html() { |
|
399 | 399 | $this->ensure_construct_finalized_called(); |
400 | 400 | return $this->_layout_strategy->layout_form(); |
401 | 401 | } |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @return string |
409 | 409 | * @throws \EE_Error |
410 | 410 | */ |
411 | - public function enqueue_js(){ |
|
411 | + public function enqueue_js() { |
|
412 | 412 | $this->_enqueue_and_localize_form_js(); |
413 | - foreach( $this->subsections() as $subsection ) { |
|
413 | + foreach ($this->subsections() as $subsection) { |
|
414 | 414 | $subsection->enqueue_js(); |
415 | 415 | } |
416 | 416 | } |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not |
428 | 428 | * @return void |
429 | 429 | */ |
430 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){ |
|
431 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
432 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
433 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ? true : false ) ); |
|
430 | + public static function wp_enqueue_scripts($init_form_validation_automatically = true) { |
|
431 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
432 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE); |
|
433 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically ? true : false)); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -442,14 +442,14 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @throws \EE_Error |
444 | 444 | */ |
445 | - public function _enqueue_and_localize_form_js(){ |
|
445 | + public function _enqueue_and_localize_form_js() { |
|
446 | 446 | $this->ensure_construct_finalized_called(); |
447 | 447 | //actually, we don't want to localize just yet. There may be other forms on the page. |
448 | 448 | //so we need to add our form section data to a static variable accessible by all form sections |
449 | 449 | //and localize it just before the footer |
450 | 450 | $this->localize_validation_rules(); |
451 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
452 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
451 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
452 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | * @return void |
462 | 462 | * @throws \EE_Error |
463 | 463 | */ |
464 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
464 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
465 | 465 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
466 | - if ( $return_for_subsection || ! $this->parent_section() ) { |
|
467 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
468 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
466 | + if ($return_for_subsection || ! $this->parent_section()) { |
|
467 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
468 | + 'form_section_id'=> $this->html_id(TRUE), |
|
469 | 469 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
470 | 470 | 'other_data' => $this->get_other_js_data(), |
471 | 471 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -481,9 +481,9 @@ discard block |
||
481 | 481 | * @param array $form_other_js_data |
482 | 482 | * @return array |
483 | 483 | */ |
484 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
485 | - foreach( $this->subsections() as $subsection ) { |
|
486 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
484 | + public function get_other_js_data($form_other_js_data = array()) { |
|
485 | + foreach ($this->subsections() as $subsection) { |
|
486 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
487 | 487 | } |
488 | 488 | return $form_other_js_data; |
489 | 489 | } |
@@ -494,12 +494,12 @@ discard block |
||
494 | 494 | * Keys are their form names, and values are the inputs themselves |
495 | 495 | * @return EE_Form_Input_Base |
496 | 496 | */ |
497 | - public function inputs_in_subsections(){ |
|
497 | + public function inputs_in_subsections() { |
|
498 | 498 | $inputs = array(); |
499 | - foreach($this->subsections() as $subsection){ |
|
500 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
501 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
502 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
499 | + foreach ($this->subsections() as $subsection) { |
|
500 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
501 | + $inputs[$subsection->html_name()] = $subsection; |
|
502 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
503 | 503 | $inputs += $subsection->inputs_in_subsections(); |
504 | 504 | } |
505 | 505 | } |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | * and values are a string of all their validation errors |
513 | 513 | * @return string[] |
514 | 514 | */ |
515 | - public function subsection_validation_errors_by_html_name(){ |
|
515 | + public function subsection_validation_errors_by_html_name() { |
|
516 | 516 | $inputs = $this->inputs(); |
517 | 517 | $errors = array(); |
518 | - foreach( $inputs as $form_input ){ |
|
519 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
520 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
518 | + foreach ($inputs as $form_input) { |
|
519 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
520 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | return $errors; |
@@ -529,16 +529,16 @@ discard block |
||
529 | 529 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
530 | 530 | * Should be setup by each form during the _enqueues_and_localize_form_js |
531 | 531 | */ |
532 | - public static function localize_script_for_all_forms(){ |
|
532 | + public static function localize_script_for_all_forms() { |
|
533 | 533 | //allow inputs and stuff to hook in their JS and stuff here |
534 | 534 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
535 | 535 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
536 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
536 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
537 | 537 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
538 | 538 | : 'wp_default'; |
539 | 539 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
540 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
541 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
540 | + wp_enqueue_script('ee_form_section_validation'); |
|
541 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | /** |
547 | 547 | * ensure_scripts_localized |
548 | 548 | */ |
549 | - public function ensure_scripts_localized(){ |
|
550 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
549 | + public function ensure_scripts_localized() { |
|
550 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
551 | 551 | $this->_enqueue_and_localize_form_js(); |
552 | 552 | } |
553 | 553 | } |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | * is that the key here should be the same as the custom validation rule put in the JS file |
560 | 560 | * @return array keys are custom validation rules, and values are internationalized strings |
561 | 561 | */ |
562 | - private static function _get_localized_error_messages(){ |
|
562 | + private static function _get_localized_error_messages() { |
|
563 | 563 | return array( |
564 | 564 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
565 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
565 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
566 | 566 | ); |
567 | 567 | } |
568 | 568 | |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
591 | 591 | * @return array |
592 | 592 | */ |
593 | - public function get_jquery_validation_rules(){ |
|
593 | + public function get_jquery_validation_rules() { |
|
594 | 594 | $jquery_validation_rules = array(); |
595 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
596 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
595 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
596 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
597 | 597 | } |
598 | 598 | return $jquery_validation_rules; |
599 | 599 | } |
@@ -608,11 +608,11 @@ discard block |
||
608 | 608 | protected function _normalize($req_data) { |
609 | 609 | $this->_received_submission = TRUE; |
610 | 610 | $this->_validation_errors = array(); |
611 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
612 | - try{ |
|
611 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
612 | + try { |
|
613 | 613 | $subsection->_normalize($req_data); |
614 | - }catch( EE_Validation_Error $e ){ |
|
615 | - $subsection->add_validation_error( $e ); |
|
614 | + } catch (EE_Validation_Error $e) { |
|
615 | + $subsection->add_validation_error($e); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | } |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | * calling parent::_validate() first. |
627 | 627 | */ |
628 | 628 | protected function _validate() { |
629 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
630 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
631 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
629 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
630 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
631 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
632 | 632 | } |
633 | 633 | $subsection->_validate(); |
634 | 634 | } |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | * Gets all the validated inputs for the form section |
641 | 641 | * @return array |
642 | 642 | */ |
643 | - public function valid_data(){ |
|
643 | + public function valid_data() { |
|
644 | 644 | $inputs = array(); |
645 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
646 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
647 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
648 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
649 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
645 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
646 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
647 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
648 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
649 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | return $inputs; |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | * Gets all the inputs on this form section |
659 | 659 | * @return EE_Form_Input_Base[] |
660 | 660 | */ |
661 | - public function inputs(){ |
|
661 | + public function inputs() { |
|
662 | 662 | $inputs = array(); |
663 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
664 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
665 | - $inputs[ $subsection_name ] = $subsection; |
|
663 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
664 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
665 | + $inputs[$subsection_name] = $subsection; |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | return $inputs; |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | * Gets all the subsections which are a proper form |
675 | 675 | * @return EE_Form_Section_Proper[] |
676 | 676 | */ |
677 | - public function subforms(){ |
|
677 | + public function subforms() { |
|
678 | 678 | $form_sections = array(); |
679 | - foreach($this->subsections() as $name=>$obj){ |
|
680 | - if($obj instanceof EE_Form_Section_Proper){ |
|
679 | + foreach ($this->subsections() as $name=>$obj) { |
|
680 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
681 | 681 | $form_sections[$name] = $obj; |
682 | 682 | } |
683 | 683 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * if you only want form inputs or proper form sections. |
693 | 693 | * @return EE_Form_Section_Proper[] |
694 | 694 | */ |
695 | - public function subsections(){ |
|
695 | + public function subsections() { |
|
696 | 696 | $this->ensure_construct_finalized_called(); |
697 | 697 | return $this->_subsections; |
698 | 698 | } |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | * it can be a multidimensional array where keys are always subsection names and values are either the |
711 | 711 | * input's normalized value, or an array like the top-level array |
712 | 712 | */ |
713 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
714 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
713 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
714 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | * it can be a multidimensional array where keys are always subsection names and values are either the |
728 | 728 | * input's normalized value, or an array like the top-level array |
729 | 729 | */ |
730 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
731 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
730 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
731 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | /** |
@@ -741,17 +741,17 @@ discard block |
||
741 | 741 | * it can be a multidimensional array where keys are always subsection names and values are either the |
742 | 742 | * input's normalized value, or an array like the top-level array |
743 | 743 | */ |
744 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
744 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
745 | 745 | $input_values = array(); |
746 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
747 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
748 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
749 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
750 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
751 | - if( $flatten ) { |
|
752 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
746 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
747 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
748 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
749 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
750 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
751 | + if ($flatten) { |
|
752 | + $input_values = array_merge($input_values, $subform_input_values); |
|
753 | 753 | } else { |
754 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
754 | + $input_values[$subsection_name] = $subform_input_values; |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | } |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | * @return boolean |
768 | 768 | * @throws \EE_Error |
769 | 769 | */ |
770 | - public function has_received_submission(){ |
|
770 | + public function has_received_submission() { |
|
771 | 771 | $this->ensure_construct_finalized_called(); |
772 | 772 | return $this->_received_submission; |
773 | 773 | } |
@@ -780,8 +780,8 @@ discard block |
||
780 | 780 | * @param array $inputs_to_exclude values are the input names |
781 | 781 | * @return void |
782 | 782 | */ |
783 | - public function exclude($inputs_to_exclude = array()){ |
|
784 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
783 | + public function exclude($inputs_to_exclude = array()) { |
|
784 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
785 | 785 | unset($this->_subsections[$input_to_exclude_name]); |
786 | 786 | } |
787 | 787 | } |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | * @param array $inputs_to_hide |
793 | 793 | * @throws \EE_Error |
794 | 794 | */ |
795 | - public function hide($inputs_to_hide= array()){ |
|
796 | - foreach($inputs_to_hide as $input_to_hide){ |
|
795 | + public function hide($inputs_to_hide = array()) { |
|
796 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
797 | 797 | $input = $this->get_input($input_to_hide); |
798 | 798 | |
799 | 799 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | * @return void |
819 | 819 | * @throws \EE_Error |
820 | 820 | */ |
821 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
822 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
823 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
821 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
822 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
823 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
824 | 824 | EE_Error::add_error( |
825 | 825 | sprintf( |
826 | 826 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
827 | - get_class( $subsection ), |
|
827 | + get_class($subsection), |
|
828 | 828 | $subsection_name, |
829 | 829 | $this->name() |
830 | 830 | ) |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
836 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
837 | 837 | |
838 | 838 | /*$subsections_before = array(); |
839 | 839 | if( $subsection_name_to_target ){ |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | $this->_subsections = $new_subsections; |
865 | 865 | } |
866 | 866 | }*/ |
867 | - if( $this->_construction_finalized ){ |
|
868 | - foreach($this->_subsections as $name => $subsection){ |
|
867 | + if ($this->_construction_finalized) { |
|
868 | + foreach ($this->_subsections as $name => $subsection) { |
|
869 | 869 | $subsection->_construct_finalize($this, $name); |
870 | 870 | } |
871 | 871 | } |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | /** |
877 | 877 | * Just gets all validatable subsections to clean their sensitive data |
878 | 878 | */ |
879 | - public function clean_sensitive_data(){ |
|
880 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
879 | + public function clean_sensitive_data() { |
|
880 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
881 | 881 | $subsection->clean_sensitive_data(); |
882 | 882 | } |
883 | 883 | } |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | /** |
888 | 888 | * @param string $form_submission_error_message |
889 | 889 | */ |
890 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
891 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
890 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
891 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | /** |
906 | 906 | * @param string $form_submission_success_message |
907 | 907 | */ |
908 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
909 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
908 | + public function set_submission_success_message($form_submission_success_message) { |
|
909 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | |
@@ -929,10 +929,10 @@ discard block |
||
929 | 929 | * @return string |
930 | 930 | * @throws \EE_Error |
931 | 931 | */ |
932 | - public function html_name_prefix(){ |
|
933 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
934 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
935 | - }else{ |
|
932 | + public function html_name_prefix() { |
|
933 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
934 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
935 | + } else { |
|
936 | 936 | return $this->name(); |
937 | 937 | } |
938 | 938 | } |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * @return string |
948 | 948 | * @throws \EE_Error |
949 | 949 | */ |
950 | - public function name(){ |
|
950 | + public function name() { |
|
951 | 951 | $this->ensure_construct_finalized_called(); |
952 | 952 | return parent::name(); |
953 | 953 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | * @return EE_Form_Section_Proper |
959 | 959 | * @throws \EE_Error |
960 | 960 | */ |
961 | - public function parent_section(){ |
|
961 | + public function parent_section() { |
|
962 | 962 | $this->ensure_construct_finalized_called(); |
963 | 963 | return parent::parent_section(); |
964 | 964 | } |
@@ -971,9 +971,9 @@ discard block |
||
971 | 971 | * @return void |
972 | 972 | * @throws \EE_Error |
973 | 973 | */ |
974 | - public function ensure_construct_finalized_called(){ |
|
975 | - if( ! $this->_construction_finalized ){ |
|
976 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
974 | + public function ensure_construct_finalized_called() { |
|
975 | + if ( ! $this->_construction_finalized) { |
|
976 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | |
@@ -985,17 +985,17 @@ discard block |
||
985 | 985 | * @param array $req_data |
986 | 986 | * @return boolean |
987 | 987 | */ |
988 | - public function form_data_present_in( $req_data = NULL ) { |
|
989 | - if( $req_data === NULL){ |
|
988 | + public function form_data_present_in($req_data = NULL) { |
|
989 | + if ($req_data === NULL) { |
|
990 | 990 | $req_data = $_POST; |
991 | 991 | } |
992 | - foreach( $this->subsections() as $subsection ) { |
|
993 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
994 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
992 | + foreach ($this->subsections() as $subsection) { |
|
993 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
994 | + if ($subsection->form_data_present_in($req_data)) { |
|
995 | 995 | return TRUE; |
996 | 996 | } |
997 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
998 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
997 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
998 | + if ($subsection->form_data_present_in($req_data)) { |
|
999 | 999 | return TRUE; |
1000 | 1000 | } |
1001 | 1001 | } |
@@ -1012,14 +1012,14 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | public function get_validation_errors_accumulated() { |
1014 | 1014 | $validation_errors = $this->get_validation_errors(); |
1015 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
1016 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
1015 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1016 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
1017 | 1017 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
1018 | 1018 | } else { |
1019 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1019 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1020 | 1020 | } |
1021 | - if( $validation_errors_on_this_subsection ){ |
|
1022 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
1021 | + if ($validation_errors_on_this_subsection) { |
|
1022 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | return $validation_errors; |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
1042 | 1042 | * @return EE_Form_Section_Base |
1043 | 1043 | */ |
1044 | - public function find_section_from_path( $form_section_path ) { |
|
1044 | + public function find_section_from_path($form_section_path) { |
|
1045 | 1045 | //check if we can find the input from purely going straight up the tree |
1046 | - $input = parent::find_section_from_path( $form_section_path ); |
|
1047 | - if( $input instanceof EE_Form_Section_Base ) { |
|
1046 | + $input = parent::find_section_from_path($form_section_path); |
|
1047 | + if ($input instanceof EE_Form_Section_Base) { |
|
1048 | 1048 | return $input; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
1052 | - if( $next_slash_pos !== false ) { |
|
1053 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
1054 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
1051 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
1052 | + if ($next_slash_pos !== false) { |
|
1053 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
1054 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
1055 | 1055 | } else { |
1056 | 1056 | $child_section_name = $form_section_path; |
1057 | 1057 | $subpath = ''; |
1058 | 1058 | } |
1059 | - $child_section = $this->get_subsection( $child_section_name ); |
|
1060 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
1061 | - return $child_section->find_section_from_path( $subpath ); |
|
1059 | + $child_section = $this->get_subsection($child_section_name); |
|
1060 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
1061 | + return $child_section->find_section_from_path($subpath); |
|
1062 | 1062 | } else { |
1063 | 1063 | return null; |
1064 | 1064 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | |
164 | 164 | /** |
165 | - * @param $default_form_step |
|
165 | + * @param string $default_form_step |
|
166 | 166 | * @throws InvalidDataTypeException |
167 | 167 | */ |
168 | 168 | protected function setDefaultFormStep( $default_form_step ) { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | |
226 | 226 | /** |
227 | - * @return Collection|null |
|
227 | + * @return ProgressStepCollection |
|
228 | 228 | * @throws InvalidInterfaceException |
229 | 229 | */ |
230 | 230 | protected function getProgressStepsCollection() { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | /** |
350 | 350 | * @param array $form_data |
351 | - * @return bool |
|
351 | + * @return boolean|null |
|
352 | 352 | */ |
353 | 353 | public function processCurrentStepForm( $form_data = array() ) { |
354 | 354 | if ( $this->getCurrentStep()->process( $form_data ) ) { |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | use EventEspresso\core\services\progress_steps\ProgressStepManager; |
15 | 15 | use InvalidArgumentException; |
16 | 16 | |
17 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
18 | - exit( 'No direct script access allowed' ); |
|
17 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
18 | + exit('No direct script access allowed'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @throws InvalidDataTypeException |
92 | 92 | * @throws InvalidArgumentException |
93 | 93 | */ |
94 | - public function __construct( $base_url, $default_form_step, $progress_step_style, EE_Request $request ) { |
|
95 | - $this->setBaseUrl( $base_url ); |
|
96 | - $this->setDefaultFormStep( $default_form_step ); |
|
97 | - $this->setProgressStepStyle( $progress_step_style ); |
|
94 | + public function __construct($base_url, $default_form_step, $progress_step_style, EE_Request $request) { |
|
95 | + $this->setBaseUrl($base_url); |
|
96 | + $this->setDefaultFormStep($default_form_step); |
|
97 | + $this->setProgressStepStyle($progress_step_style); |
|
98 | 98 | $this->request = $request; |
99 | 99 | // set the base URL that the redirect URL will be built from |
100 | - $this->setBaseUrl( $this->defaultFormStep() ); |
|
100 | + $this->setBaseUrl($this->defaultFormStep()); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | * @throws InvalidDataTypeException |
117 | 117 | * @throws InvalidArgumentException |
118 | 118 | */ |
119 | - protected function setBaseUrl( $base_url ) { |
|
120 | - if ( ! is_string( $base_url ) ) { |
|
121 | - throw new InvalidDataTypeException( '$base_url', $base_url, 'string' ); |
|
119 | + protected function setBaseUrl($base_url) { |
|
120 | + if ( ! is_string($base_url)) { |
|
121 | + throw new InvalidDataTypeException('$base_url', $base_url, 'string'); |
|
122 | 122 | } |
123 | - if ( empty( $base_url ) ) { |
|
123 | + if (empty($base_url)) { |
|
124 | 124 | throw new InvalidArgumentException( |
125 | - __( 'The base URL can not be an empty string.', 'event_espresso' ) |
|
125 | + __('The base URL can not be an empty string.', 'event_espresso') |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 | $this->base_url = $base_url; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | * @param string $form_step_url_key |
144 | 144 | * @throws InvalidDataTypeException |
145 | 145 | */ |
146 | - public function setFormStepUrlKey( $form_step_url_key = 'ee-form-step' ) { |
|
147 | - if ( ! is_string( $form_step_url_key ) ) { |
|
148 | - throw new InvalidDataTypeException( '$form_step_key', $form_step_url_key, 'string' ); |
|
146 | + public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') { |
|
147 | + if ( ! is_string($form_step_url_key)) { |
|
148 | + throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string'); |
|
149 | 149 | } |
150 | - $this->form_step_url_key = ! empty( $form_step_url_key ) ? $form_step_url_key : 'ee-form-step'; |
|
150 | + $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param $default_form_step |
166 | 166 | * @throws InvalidDataTypeException |
167 | 167 | */ |
168 | - protected function setDefaultFormStep( $default_form_step ) { |
|
169 | - if ( ! is_string( $default_form_step ) ) { |
|
170 | - throw new InvalidDataTypeException( '$default_form_step', $default_form_step, 'string' ); |
|
168 | + protected function setDefaultFormStep($default_form_step) { |
|
169 | + if ( ! is_string($default_form_step)) { |
|
170 | + throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string'); |
|
171 | 171 | } |
172 | 172 | $this->default_form_step = $default_form_step; |
173 | 173 | } |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * @throws BaseException |
180 | 180 | */ |
181 | 181 | protected function setCurrentStepFromRequest() { |
182 | - $current_step = $this->request()->get( $this->formStepUrlKey(), $this->defaultFormStep() ); |
|
183 | - if ( ! $this->form_steps->setCurrent( $current_step ) ) { |
|
184 | - throw new BaseException( 'Form Step could not be set' ); |
|
182 | + $current_step = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep()); |
|
183 | + if ( ! $this->form_steps->setCurrent($current_step)) { |
|
184 | + throw new BaseException('Form Step could not be set'); |
|
185 | 185 | } |
186 | 186 | return $current_step; |
187 | 187 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | /** |
210 | 210 | * @param string $progress_step_style |
211 | 211 | */ |
212 | - public function setProgressStepStyle( $progress_step_style ) { |
|
212 | + public function setProgressStepStyle($progress_step_style) { |
|
213 | 213 | $this->progress_step_style = $progress_step_style; |
214 | 214 | } |
215 | 215 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function getProgressStepsCollection() { |
231 | 231 | static $collection = null; |
232 | - if ( ! $collection instanceof ProgressStepCollection ) { |
|
232 | + if ( ! $collection instanceof ProgressStepCollection) { |
|
233 | 233 | $collection = new ProgressStepCollection(); |
234 | 234 | } |
235 | 235 | return $collection; |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @throws InvalidClassException |
246 | 246 | * @throws InvalidInterfaceException |
247 | 247 | */ |
248 | - protected function GenerateProgressSteps( Collection $progress_steps_collection ) { |
|
248 | + protected function GenerateProgressSteps(Collection $progress_steps_collection) { |
|
249 | 249 | /** @var SequentialStepForm $form_step */ |
250 | - foreach ( $this->form_steps as $form_step ) { |
|
250 | + foreach ($this->form_steps as $form_step) { |
|
251 | 251 | // is this step active ? |
252 | - if ( ! $form_step->initialize() ) { |
|
252 | + if ( ! $form_step->initialize()) { |
|
253 | 253 | continue; |
254 | 254 | } |
255 | 255 | $progress_steps_collection->add( |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @throws \InvalidArgumentException |
298 | 298 | */ |
299 | 299 | public function buildCurrentStepFormForProcessing() { |
300 | - $this->buildCurrentStepForm( false ); |
|
300 | + $this->buildCurrentStepForm(false); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @throws InvalidEntityException |
312 | 312 | * @throws InvalidInterfaceException |
313 | 313 | */ |
314 | - private function buildCurrentStepForm( $for_display = true ) { |
|
314 | + private function buildCurrentStepForm($for_display = true) { |
|
315 | 315 | $this->form_steps = $this->getFormStepsCollection(); |
316 | - if ( $for_display ) { |
|
316 | + if ($for_display) { |
|
317 | 317 | $this->progress_step_manager = $this->GenerateProgressSteps( |
318 | 318 | $this->getProgressStepsCollection() |
319 | 319 | ); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $form_step = $this->getCurrentStep(); |
326 | 326 | $form_step->generate(); |
327 | 327 | // \EEH_Debug_Tools::printr( $form_step, '$form_step', __FILE__, __LINE__ ); |
328 | - if ( $for_display ) { |
|
328 | + if ($for_display) { |
|
329 | 329 | $form_step->enqueueStylesAndScripts(); |
330 | 330 | } |
331 | 331 | } |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @param bool $return_as_string |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - public function displayProgressSteps( $return_as_string = true ) { |
|
340 | - if ( $return_as_string ) { |
|
339 | + public function displayProgressSteps($return_as_string = true) { |
|
340 | + if ($return_as_string) { |
|
341 | 341 | return $this->progress_step_manager->displaySteps(); |
342 | 342 | } |
343 | 343 | echo $this->progress_step_manager->displaySteps(); |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | * @param array $form_data |
351 | 351 | * @return bool |
352 | 352 | */ |
353 | - public function processCurrentStepForm( $form_data = array() ) { |
|
354 | - if ( $this->getCurrentStep()->process( $form_data ) ) { |
|
355 | - wp_safe_redirect( $this->getCurrentStep()->redirectUrl() ); |
|
353 | + public function processCurrentStepForm($form_data = array()) { |
|
354 | + if ($this->getCurrentStep()->process($form_data)) { |
|
355 | + wp_safe_redirect($this->getCurrentStep()->redirectUrl()); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | * @param bool $return_as_string |
363 | 363 | * @return string |
364 | 364 | */ |
365 | - public function displayCurrentStepForm( $return_as_string = true ) { |
|
366 | - if ( $return_as_string ) { |
|
365 | + public function displayCurrentStepForm($return_as_string = true) { |
|
366 | + if ($return_as_string) { |
|
367 | 367 | return $this->getCurrentStep()->display(); |
368 | 368 | } |
369 | 369 | echo $this->getCurrentStep()->display(); |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | use EventEspresso\core\services\collections\CollectionInterface; |
11 | 11 | use EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface; |
12 | 12 | |
13 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
14 | - exit( 'No direct script access allowed' ); |
|
13 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
14 | + exit('No direct script access allowed'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | CollectionInterface $collection = null, |
77 | 77 | EE_Request $request = null |
78 | 78 | ) { |
79 | - $this->setDisplayStrategy( $display_strategy_name ); |
|
80 | - $this->setDefaultStep( $default_step ); |
|
81 | - $this->setFormStepUrlKey( $form_step_url_key ); |
|
82 | - if ( ! $collection instanceof CollectionInterface ) { |
|
83 | - $collection = new Collection( '\EventEspresso\core\services\progress_steps\ProgressStepInterface' ); |
|
79 | + $this->setDisplayStrategy($display_strategy_name); |
|
80 | + $this->setDefaultStep($default_step); |
|
81 | + $this->setFormStepUrlKey($form_step_url_key); |
|
82 | + if ( ! $collection instanceof CollectionInterface) { |
|
83 | + $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
|
84 | 84 | } |
85 | 85 | $this->collection = $collection; |
86 | - if ( ! $request instanceof EE_Request ) { |
|
87 | - $request = \EE_Registry::instance()->load_core( 'Request' ); |
|
86 | + if ( ! $request instanceof EE_Request) { |
|
87 | + $request = \EE_Registry::instance()->load_core('Request'); |
|
88 | 88 | } |
89 | 89 | $this->request = $request; |
90 | 90 | } |
@@ -96,28 +96,28 @@ discard block |
||
96 | 96 | * @throws InvalidDataTypeException |
97 | 97 | * @throws InvalidClassException |
98 | 98 | */ |
99 | - protected function setDisplayStrategy( $display_strategy_name = 'number_bubbles' ) { |
|
100 | - if ( ! is_string( $display_strategy_name ) ) { |
|
101 | - throw new InvalidDataTypeException( '$display_strategy_name', $display_strategy_name, 'string' ); |
|
99 | + protected function setDisplayStrategy($display_strategy_name = 'number_bubbles') { |
|
100 | + if ( ! is_string($display_strategy_name)) { |
|
101 | + throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string'); |
|
102 | 102 | } |
103 | 103 | // build up FQCN from incoming display strategy folder name |
104 | 104 | $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\'; |
105 | - $display_strategy_class .= $display_strategy_name . '\\'; |
|
106 | - $display_strategy_class .= str_replace( ' ', '', ucwords( str_replace( '_', ' ', $display_strategy_name ) ) ); |
|
105 | + $display_strategy_class .= $display_strategy_name.'\\'; |
|
106 | + $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name))); |
|
107 | 107 | $display_strategy_class .= 'ProgressStepsDisplay'; |
108 | 108 | $display_strategy_class = apply_filters( |
109 | 109 | 'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class', |
110 | 110 | $display_strategy_class |
111 | 111 | ); |
112 | - if ( ! class_exists( $display_strategy_class ) ) { |
|
113 | - throw new InvalidClassException( $display_strategy_class ); |
|
112 | + if ( ! class_exists($display_strategy_class)) { |
|
113 | + throw new InvalidClassException($display_strategy_class); |
|
114 | 114 | } |
115 | 115 | $display_strategy = new $display_strategy_class(); |
116 | - if ( ! $display_strategy instanceof ProgressStepsDisplayInterface ) { |
|
116 | + if ( ! $display_strategy instanceof ProgressStepsDisplayInterface) { |
|
117 | 117 | throw new InvalidClassException( |
118 | 118 | $display_strategy_class, |
119 | 119 | sprintf( |
120 | - __( 'The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso' ), |
|
120 | + __('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'), |
|
121 | 121 | $display_strategy_class, |
122 | 122 | '\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface' |
123 | 123 | ) |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * @param string $default_step |
133 | 133 | * @throws InvalidDataTypeException |
134 | 134 | */ |
135 | - public function setDefaultStep( $default_step ) { |
|
136 | - if ( ! is_string( $default_step ) ) { |
|
137 | - throw new InvalidDataTypeException( '$default_step', $default_step, 'string' ); |
|
135 | + public function setDefaultStep($default_step) { |
|
136 | + if ( ! is_string($default_step)) { |
|
137 | + throw new InvalidDataTypeException('$default_step', $default_step, 'string'); |
|
138 | 138 | } |
139 | 139 | $this->default_step = $default_step; |
140 | 140 | } |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | * @param string $form_step_url_key |
146 | 146 | * @throws InvalidDataTypeException |
147 | 147 | */ |
148 | - public function setFormStepUrlKey( $form_step_url_key = 'ee-form-step' ) { |
|
149 | - if ( ! is_string( $form_step_url_key ) ) { |
|
150 | - throw new InvalidDataTypeException( '$form_step_key', $form_step_url_key, 'string' ); |
|
148 | + public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') { |
|
149 | + if ( ! is_string($form_step_url_key)) { |
|
150 | + throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string'); |
|
151 | 151 | } |
152 | - $this->form_step_url_key = ! empty( $form_step_url_key ) ? $form_step_url_key : 'ee-form-step'; |
|
152 | + $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step'; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -158,26 +158,26 @@ discard block |
||
158 | 158 | * @param string $step |
159 | 159 | * @throws InvalidIdentifierException |
160 | 160 | */ |
161 | - public function setCurrentStep( $step = '' ) { |
|
161 | + public function setCurrentStep($step = '') { |
|
162 | 162 | // use incoming value if it's set, otherwise use request param if it's set, otherwise use default |
163 | - $step = ! empty( $step ) |
|
163 | + $step = ! empty($step) |
|
164 | 164 | ? $step |
165 | - : $this->request->get( $this->form_step_url_key, $this->default_step ); |
|
165 | + : $this->request->get($this->form_step_url_key, $this->default_step); |
|
166 | 166 | // grab the step previously known as current, in case we need to revert |
167 | 167 | $current_current_step = $this->collection->current(); |
168 | 168 | // verify that requested step exists |
169 | - if ( ! $this->collection->has( $step ) ) { |
|
170 | - throw new InvalidIdentifierException( $step, $this->default_step ); |
|
169 | + if ( ! $this->collection->has($step)) { |
|
170 | + throw new InvalidIdentifierException($step, $this->default_step); |
|
171 | 171 | } |
172 | - if ( $this->collection->setCurrent( $step ) ) { |
|
172 | + if ($this->collection->setCurrent($step)) { |
|
173 | 173 | // if the old boss is the same as the new boss, then nothing changes |
174 | - if ( $this->collection->current() !== $current_current_step ) { |
|
175 | - $current_current_step->setIsCurrent( false ); |
|
174 | + if ($this->collection->current() !== $current_current_step) { |
|
175 | + $current_current_step->setIsCurrent(false); |
|
176 | 176 | } |
177 | 177 | $this->collection->current()->setIsCurrent(); |
178 | 178 | } else { |
179 | - $this->collection->setCurrent( $current_current_step->id() ); |
|
180 | - $current_current_step->setIsCurrent( true ); |
|
179 | + $this->collection->setCurrent($current_current_step->id()); |
|
180 | + $current_current_step->setIsCurrent(true); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | public function displaySteps() { |
219 | 219 | return \EEH_Template::display_template( |
220 | 220 | $this->display_strategy->getTemplate(), |
221 | - array( 'progress_steps' => $this->collection ), |
|
221 | + array('progress_steps' => $this->collection), |
|
222 | 222 | true |
223 | 223 | ); |
224 | 224 | } |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\Core\Exceptions\InvalidFormSubmissionException; |
7 | 7 | use LogicException; |
8 | 8 | |
9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @author Brent Christensen |
21 | 21 | * @since 4.9.0 |
22 | 22 | */ |
23 | -abstract class Form implements FormInterface{ |
|
23 | +abstract class Form implements FormInterface { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string $form_name |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * @param string $slug |
53 | 53 | * @throws InvalidDataTypeException |
54 | 54 | */ |
55 | - public function __construct( $form_name, $admin_name, $slug ) { |
|
56 | - $this->setFormName( $form_name ); |
|
57 | - $this->setAdminName( $admin_name ); |
|
58 | - $this->setSlug( $slug ); |
|
55 | + public function __construct($form_name, $admin_name, $slug) { |
|
56 | + $this->setFormName($form_name); |
|
57 | + $this->setAdminName($admin_name); |
|
58 | + $this->setSlug($slug); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @throws LogicException |
66 | 66 | */ |
67 | 67 | public function form() { |
68 | - if ( ! $this->formIsValid() ) { |
|
68 | + if ( ! $this->formIsValid()) { |
|
69 | 69 | return null; |
70 | 70 | } |
71 | 71 | return $this->form; |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @throws LogicException |
79 | 79 | */ |
80 | 80 | public function formIsValid() { |
81 | - if ( ! $this->form instanceof \EE_Form_Section_Proper ) { |
|
81 | + if ( ! $this->form instanceof \EE_Form_Section_Proper) { |
|
82 | 82 | static $generated = false; |
83 | - if ( ! $generated ) { |
|
83 | + if ( ! $generated) { |
|
84 | 84 | $generated = true; |
85 | 85 | $this->generate(); |
86 | 86 | } |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | * @throws LogicException |
97 | 97 | */ |
98 | 98 | public function verifyForm() { |
99 | - if ( $this->form instanceof \EE_Form_Section_Proper ) { |
|
99 | + if ($this->form instanceof \EE_Form_Section_Proper) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | throw new LogicException( |
103 | 103 | sprintf( |
104 | - __( 'The "%1$s" form is invalid or missing', 'event_espresso' ), |
|
104 | + __('The "%1$s" form is invalid or missing', 'event_espresso'), |
|
105 | 105 | $this->form_name |
106 | 106 | ) |
107 | 107 | ); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * @param \EE_Form_Section_Proper $form |
114 | 114 | */ |
115 | - public function setForm( \EE_Form_Section_Proper $form ) { |
|
115 | + public function setForm(\EE_Form_Section_Proper $form) { |
|
116 | 116 | $this->form = $form; |
117 | 117 | } |
118 | 118 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | * @param string $form_name |
134 | 134 | * @throws InvalidDataTypeException |
135 | 135 | */ |
136 | - public function setFormName( $form_name ) { |
|
137 | - if ( ! is_string( $form_name ) ) { |
|
138 | - throw new InvalidDataTypeException( '$form_name', $form_name, 'string' ); |
|
136 | + public function setFormName($form_name) { |
|
137 | + if ( ! is_string($form_name)) { |
|
138 | + throw new InvalidDataTypeException('$form_name', $form_name, 'string'); |
|
139 | 139 | } |
140 | 140 | $this->form_name = $form_name; |
141 | 141 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param string $admin_name |
158 | 158 | * @throws InvalidDataTypeException |
159 | 159 | */ |
160 | - public function setAdminName( $admin_name ) { |
|
161 | - if ( ! is_string( $admin_name ) ) { |
|
162 | - throw new InvalidDataTypeException( '$admin_name', $admin_name, 'string' ); |
|
160 | + public function setAdminName($admin_name) { |
|
161 | + if ( ! is_string($admin_name)) { |
|
162 | + throw new InvalidDataTypeException('$admin_name', $admin_name, 'string'); |
|
163 | 163 | } |
164 | 164 | $this->admin_name = $admin_name; |
165 | 165 | } |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @param string $slug |
182 | 182 | * @throws InvalidDataTypeException |
183 | 183 | */ |
184 | - public function setSlug( $slug ) { |
|
185 | - if ( ! is_string( $slug ) ) { |
|
186 | - throw new InvalidDataTypeException( '$slug', $slug, 'string' ); |
|
184 | + public function setSlug($slug) { |
|
185 | + if ( ! is_string($slug)) { |
|
186 | + throw new InvalidDataTypeException('$slug', $slug, 'string'); |
|
187 | 187 | } |
188 | 188 | $this->slug = $slug; |
189 | 189 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @return void |
212 | 212 | */ |
213 | 213 | public function localizeVariables() { |
214 | - \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
214 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
215 | 215 | //form variables are localized when calling EE_Form_Section_Base::enqueue_js, which is done during Form::enqueueStylesAndScripts() |
216 | 216 | } |
217 | 217 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @throws \EE_Error |
226 | 226 | */ |
227 | 227 | public function enqueueStylesAndScripts() { |
228 | - \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
228 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
229 | 229 | $this->form()->enqueue_js(); |
230 | 230 | |
231 | 231 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return EE_Form_Section_Proper |
239 | 239 | */ |
240 | - abstract public function generate() ; |
|
240 | + abstract public function generate(); |
|
241 | 241 | |
242 | 242 | |
243 | 243 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @throws \EE_Error |
251 | 251 | */ |
252 | 252 | public function display() { |
253 | - \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
253 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
254 | 254 | return $this->form()->get_html(); |
255 | 255 | } |
256 | 256 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | * @throws \LogicException |
267 | 267 | * @throws InvalidFormSubmissionException |
268 | 268 | */ |
269 | - public function process( $form_data = array() ) { |
|
270 | - if ( ! $this->form()->was_submitted( $form_data ) ) { |
|
271 | - throw new InvalidFormSubmissionException( $this->form_name ); |
|
269 | + public function process($form_data = array()) { |
|
270 | + if ( ! $this->form()->was_submitted($form_data)) { |
|
271 | + throw new InvalidFormSubmissionException($this->form_name); |
|
272 | 272 | } |
273 | - $this->form->receive_form_submission( $form_data ); |
|
274 | - if ( $this->form->is_valid() ) { |
|
273 | + $this->form->receive_form_submission($form_data); |
|
274 | + if ($this->form->is_valid()) { |
|
275 | 275 | return $this->form->valid_data(); |
276 | 276 | } |
277 | 277 | return array(); |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EE_Form_Section_Proper; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @param \EE_Form_Section_Proper $form |
28 | 28 | */ |
29 | - public function setForm( \EE_Form_Section_Proper $form ) ; |
|
29 | + public function setForm(\EE_Form_Section_Proper $form); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * a public name for the form that can be displayed on the frontend of a site |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $form_data |
110 | 110 | * @return bool |
111 | 111 | */ |
112 | - public function process( $form_data = array() ); |
|
112 | + public function process($form_data = array()); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | } |