@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
3 | 3 | |
4 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
4 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EE_Array |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $array2 an array of objects |
27 | 27 | * @return array an array of objects found in array 1 that aren't found in array 2. |
28 | 28 | */ |
29 | - public static function object_array_diff( $array1, $array2 ) { |
|
30 | - return array_udiff( $array1, $array2, array('self', '_compare_objects' )); |
|
29 | + public static function object_array_diff($array1, $array2) { |
|
30 | + return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @param array $array |
37 | 37 | * @return boolean |
38 | 38 | */ |
39 | - public static function is_associative_array( array $array ) { |
|
40 | - return array_keys( $array ) !== range( 0, count( $array ) - 1 ); |
|
39 | + public static function is_associative_array(array $array) { |
|
40 | + return array_keys($array) !== range(0, count($array) - 1); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param array $arr |
47 | 47 | * @return mixed what ever is in the array |
48 | 48 | */ |
49 | - public static function get_one_item_from_array($arr){ |
|
49 | + public static function get_one_item_from_array($arr) { |
|
50 | 50 | $item = end($arr); |
51 | 51 | reset($arr); |
52 | 52 | return $item; |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * @param mixed $arr |
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | - public static function is_multi_dimensional_array($arr){ |
|
61 | - if(is_array($arr)){ |
|
60 | + public static function is_multi_dimensional_array($arr) { |
|
61 | + if (is_array($arr)) { |
|
62 | 62 | $first_item = reset($arr); |
63 | - if(is_array($first_item)){ |
|
64 | - return true;//yep, there's at least 2 levels to this array |
|
65 | - }else{ |
|
66 | - return false;//nope, only 1 level |
|
63 | + if (is_array($first_item)) { |
|
64 | + return true; //yep, there's at least 2 levels to this array |
|
65 | + } else { |
|
66 | + return false; //nope, only 1 level |
|
67 | 67 | } |
68 | - }else{ |
|
69 | - return false;//its not an array at all! |
|
68 | + } else { |
|
69 | + return false; //its not an array at all! |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param mixed $default |
78 | 78 | * @return mixed |
79 | 79 | */ |
80 | - public static function is_set( $arr, $index, $default ) { |
|
81 | - return isset( $arr[ $index ] ) ? $arr[ $index ] : $default; |
|
80 | + public static function is_set($arr, $index, $default) { |
|
81 | + return isset($arr[$index]) ? $arr[$index] : $default; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * @param mixed $value usually a string, but could be an array or object |
87 | 87 | * @return mixed the UN-serialized data |
88 | 88 | */ |
89 | - public static function maybe_unserialize( $value ) { |
|
89 | + public static function maybe_unserialize($value) { |
|
90 | 90 | $data = maybe_unserialize($value); |
91 | 91 | //it's possible that this still has serialized data if its the session. WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically. |
92 | 92 | $token = 'C'; |
93 | 93 | $data = is_string($data) ? trim($data) : $data; |
94 | - if ( is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match( "/^{$token}:[0-9]+:/s", $data ) ) { |
|
94 | + if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
95 | 95 | return unserialize($data); |
96 | 96 | } else { |
97 | 97 | return $data; |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public static function insert_into_array( $target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true ) { |
|
113 | + public static function insert_into_array($target_array = array(), $array_to_insert = array(), $offset = null, $add_before = true, $preserve_keys = true) { |
|
114 | 114 | // ensure incoming arrays are actually arrays |
115 | - $target_array = (array)$target_array; |
|
116 | - $array_to_insert = (array)$array_to_insert; |
|
115 | + $target_array = (array) $target_array; |
|
116 | + $array_to_insert = (array) $array_to_insert; |
|
117 | 117 | // if no offset key was supplied |
118 | - if ( empty( $offset )) { |
|
118 | + if (empty($offset)) { |
|
119 | 119 | // use start or end of $target_array based on whether we are adding before or not |
120 | - $offset = $add_before ? 0 : count( $target_array ); |
|
120 | + $offset = $add_before ? 0 : count($target_array); |
|
121 | 121 | } |
122 | 122 | // if offset key is a string, then find the corresponding numeric location for that element |
123 | - $offset = is_int( $offset ) ? $offset : array_search( $offset, array_keys( $target_array ) ); |
|
123 | + $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array)); |
|
124 | 124 | // add one to the offset if adding after |
125 | 125 | $offset = $add_before ? $offset : $offset + 1; |
126 | 126 | // but ensure offset does not exceed the length of the array |
127 | - $offset = $offset > count( $target_array ) ? count( $target_array ) : $offset; |
|
127 | + $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
128 | 128 | // reindex array ??? |
129 | - if ( $preserve_keys ) { |
|
129 | + if ($preserve_keys) { |
|
130 | 130 | // take a slice of the target array from the beginning till the offset, |
131 | 131 | // then add the new data |
132 | 132 | // then add another slice that starts at the offset and goes till the end |
133 | - return array_slice( $target_array, 0, $offset, true ) + $array_to_insert + array_slice( $target_array, $offset, null, true ); |
|
133 | + return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice($target_array, $offset, null, true); |
|
134 | 134 | } else { |
135 | 135 | // since we don't want to preserve keys, we can use array_splice |
136 | - array_splice( $target_array, $offset, 0, $array_to_insert ); |
|
136 | + array_splice($target_array, $offset, 0, $array_to_insert); |
|
137 | 137 | return $target_array; |
138 | 138 | } |
139 | 139 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param array $array2 |
152 | 152 | * @return array |
153 | 153 | */ |
154 | - public static function merge_arrays_and_overwrite_keys( array $array1, array $array2 ) { |
|
155 | - foreach ( $array2 as $key => $value ) { |
|
156 | - $array1[ $key ] = $value; |
|
154 | + public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) { |
|
155 | + foreach ($array2 as $key => $value) { |
|
156 | + $array1[$key] = $value; |
|
157 | 157 | } |
158 | 158 | return $array1; |
159 | 159 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @param mixed $final_value |
172 | 172 | * @return array |
173 | 173 | */ |
174 | - public static function convert_array_values_to_keys( array $flat_array, $final_value = null ) { |
|
174 | + public static function convert_array_values_to_keys(array $flat_array, $final_value = null) { |
|
175 | 175 | $multidimensional = array(); |
176 | 176 | $reference = &$multidimensional; |
177 | - foreach ( $flat_array as $key ) { |
|
178 | - $reference[ $key ] = array(); |
|
179 | - $reference = &$reference[ $key ]; |
|
177 | + foreach ($flat_array as $key) { |
|
178 | + $reference[$key] = array(); |
|
179 | + $reference = &$reference[$key]; |
|
180 | 180 | } |
181 | - if ( $final_value !== null ) { |
|
181 | + if ($final_value !== null) { |
|
182 | 182 | $reference = $final_value; |
183 | 183 | } |
184 | 184 | return $multidimensional; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | // add generic non-identifying messages for non-privileged users |
119 | 119 | if ( ! WP_DEBUG ) { |
120 | 120 | $output .= '<span class="ee-error-user-msg-spn">' |
121 | - . trim( $msg ) |
|
122 | - . '</span> <sup>' |
|
123 | - . $code |
|
124 | - . '</sup><br />'; |
|
121 | + . trim( $msg ) |
|
122 | + . '</span> <sup>' |
|
123 | + . $code |
|
124 | + . '</sup><br />'; |
|
125 | 125 | } else { |
126 | 126 | // or helpful developer messages if debugging is on |
127 | 127 | $output .= ' |
@@ -130,39 +130,39 @@ discard block |
||
130 | 130 | ' |
131 | 131 | . sprintf( |
132 | 132 | __( '%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso' ), |
133 | - '<strong class="ee-error-dev-msg-str">', |
|
133 | + '<strong class="ee-error-dev-msg-str">', |
|
134 | 134 | get_class( $exception ), |
135 | 135 | '</strong> <span>', |
136 | 136 | $code . '</span>' |
137 | 137 | ) |
138 | 138 | . '<br /> |
139 | 139 | <span class="big-text">"' |
140 | - . trim( $msg ) |
|
141 | - . '"</span><br/> |
|
140 | + . trim( $msg ) |
|
141 | + . '"</span><br/> |
|
142 | 142 | <a id="display-ee-error-trace-1' |
143 | - . $time |
|
144 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
145 | - . $time |
|
146 | - . '"> |
|
143 | + . $time |
|
144 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
145 | + . $time |
|
146 | + . '"> |
|
147 | 147 | ' |
148 | - . __( 'click to view backtrace and class/method details', 'event_espresso' ) |
|
149 | - . ' |
|
148 | + . __( 'click to view backtrace and class/method details', 'event_espresso' ) |
|
149 | + . ' |
|
150 | 150 | </a><br /> |
151 | 151 | ' |
152 | - . $exception->getFile() |
|
153 | - . sprintf( |
|
154 | - __( '%1$s( line no: %2$s )%3$s', 'event_espresso' ), |
|
155 | - ' <span class="small-text lt-grey-text">', |
|
156 | - $exception->getLine(), |
|
157 | - '</span>' |
|
158 | - ) |
|
159 | - . ' |
|
152 | + . $exception->getFile() |
|
153 | + . sprintf( |
|
154 | + __( '%1$s( line no: %2$s )%3$s', 'event_espresso' ), |
|
155 | + ' <span class="small-text lt-grey-text">', |
|
156 | + $exception->getLine(), |
|
157 | + '</span>' |
|
158 | + ) |
|
159 | + . ' |
|
160 | 160 | </p> |
161 | 161 | <div id="ee-error-trace-1' |
162 | - . $time |
|
163 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
162 | + . $time |
|
163 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
164 | 164 | ' |
165 | - . $trace_details; |
|
165 | + . $trace_details; |
|
166 | 166 | if ( ! empty( $class ) ) { |
167 | 167 | $output .= ' |
168 | 168 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\exceptions; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param \Exception $exception |
24 | 24 | */ |
25 | - public function __construct( \Exception $exception ) { |
|
26 | - if ( WP_DEBUG ) { |
|
27 | - $this->displayException( $exception ); |
|
25 | + public function __construct(\Exception $exception) { |
|
26 | + if (WP_DEBUG) { |
|
27 | + $this->displayException($exception); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
@@ -34,27 +34,27 @@ discard block |
||
34 | 34 | * @access protected |
35 | 35 | * @param \Exception $exception |
36 | 36 | */ |
37 | - protected function displayException( \Exception $exception ) { |
|
37 | + protected function displayException(\Exception $exception) { |
|
38 | 38 | |
39 | 39 | $error_code = ''; |
40 | 40 | $trace_details = ''; |
41 | 41 | $time = time(); |
42 | 42 | $trace = $exception->getTrace(); |
43 | 43 | // get separate user and developer messages if they exist |
44 | - $msg = explode( '||', $exception->getMessage() ); |
|
44 | + $msg = explode('||', $exception->getMessage()); |
|
45 | 45 | $user_msg = $msg[0]; |
46 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
46 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
47 | 47 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
48 | 48 | // start gathering output |
49 | 49 | $output = $this->exceptionStyles(); |
50 | 50 | $output .= ' |
51 | 51 | <div id="ee-error-message" class="error">'; |
52 | - if ( ! WP_DEBUG ) { |
|
52 | + if ( ! WP_DEBUG) { |
|
53 | 53 | $output .= ' |
54 | 54 | <p>'; |
55 | 55 | } |
56 | 56 | // process trace info |
57 | - if ( empty( $trace ) ) { |
|
57 | + if (empty($trace)) { |
|
58 | 58 | $trace_details .= __( |
59 | 59 | 'Sorry, but no trace information was available for this exception.', |
60 | 60 | 'event_espresso' |
@@ -67,47 +67,47 @@ discard block |
||
67 | 67 | <th scope="col" align="right" style="width:2.5%;">#</th> |
68 | 68 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
69 | 69 | <th scope="col" align="left" style="width:40%;">File</th> |
70 | - <th scope="col" align="left">' . __( 'Class', 'event_espresso' ) . '->' . __( 'Method( arguments )', 'event_espresso' ) . '</th> |
|
70 | + <th scope="col" align="left">' . __('Class', 'event_espresso').'->'.__('Method( arguments )', 'event_espresso').'</th> |
|
71 | 71 | </tr>'; |
72 | - $last_on_stack = count( $trace ) - 1; |
|
72 | + $last_on_stack = count($trace) - 1; |
|
73 | 73 | // reverse array so that stack is in proper chronological order |
74 | - $sorted_trace = array_reverse( $trace ); |
|
75 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
76 | - $file = isset( $trace['file'] ) ? $trace['file'] : ''; |
|
77 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
78 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
79 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
80 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
81 | - $args = isset( $trace['args'] ) && count( $trace['args'] ) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
82 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
74 | + $sorted_trace = array_reverse($trace); |
|
75 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
76 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
77 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
78 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
79 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
80 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
81 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args; |
|
82 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
83 | 83 | $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
84 | - if ( empty( $file ) && ! empty( $class ) ) { |
|
85 | - $a = new \ReflectionClass( $class ); |
|
84 | + if (empty($file) && ! empty($class)) { |
|
85 | + $a = new \ReflectionClass($class); |
|
86 | 86 | $file = $a->getFileName(); |
87 | - if ( empty( $line ) && ! empty( $function ) ) { |
|
88 | - $b = new \ReflectionMethod( $class, $function ); |
|
87 | + if (empty($line) && ! empty($function)) { |
|
88 | + $b = new \ReflectionMethod($class, $function); |
|
89 | 89 | $line = $b->getStartLine(); |
90 | 90 | } |
91 | 91 | } |
92 | - if ( $nmbr === $last_on_stack ) { |
|
92 | + if ($nmbr === $last_on_stack) { |
|
93 | 93 | $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
94 | 94 | $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
95 | - $error_code = $this->generate_error_code( $file, $trace['function'], $line ); |
|
95 | + $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
96 | 96 | } |
97 | - $file = \EEH_File::standardise_directory_separators( $file ); |
|
98 | - $nmbr = ! empty( $nmbr ) ? $nmbr : ' '; |
|
99 | - $line = ! empty( $line ) ? $line : ' '; |
|
100 | - $file = ! empty( $file ) ? $file : ' '; |
|
101 | - $class_display = ! empty( $class ) ? $class : ''; |
|
102 | - $type = ! empty( $type ) ? $type : ''; |
|
103 | - $function = ! empty( $function ) ? $function : ''; |
|
104 | - $args = ! empty( $args ) ? '( ' . $args . ' )' : '()'; |
|
97 | + $file = \EEH_File::standardise_directory_separators($file); |
|
98 | + $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
99 | + $line = ! empty($line) ? $line : ' '; |
|
100 | + $file = ! empty($file) ? $file : ' '; |
|
101 | + $class_display = ! empty($class) ? $class : ''; |
|
102 | + $type = ! empty($type) ? $type : ''; |
|
103 | + $function = ! empty($function) ? $function : ''; |
|
104 | + $args = ! empty($args) ? '( '.$args.' )' : '()'; |
|
105 | 105 | $trace_details .= ' |
106 | 106 | <tr> |
107 | - <td align="right" valign="top" class="' . $zebra . '">' . $nmbr . '</td> |
|
108 | - <td align="right" valign="top" class="' . $zebra . '">' . $line . '</td> |
|
109 | - <td align="left" valign="top" class="' . $zebra . '">' . $file . '</td> |
|
110 | - <td align="left" valign="top" class="' . $zebra . '">' . $class_display . $type . $function . $args . '</td> |
|
107 | + <td align="right" valign="top" class="' . $zebra.'">'.$nmbr.'</td> |
|
108 | + <td align="right" valign="top" class="' . $zebra.'">'.$line.'</td> |
|
109 | + <td align="left" valign="top" class="' . $zebra.'">'.$file.'</td> |
|
110 | + <td align="left" valign="top" class="' . $zebra.'">'.$class_display.$type.$function.$args.'</td> |
|
111 | 111 | </tr>'; |
112 | 112 | } |
113 | 113 | $trace_details .= ' |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | } |
117 | 117 | $code = $exception->getCode() ? $exception->getCode() : $error_code; |
118 | 118 | // add generic non-identifying messages for non-privileged users |
119 | - if ( ! WP_DEBUG ) { |
|
119 | + if ( ! WP_DEBUG) { |
|
120 | 120 | $output .= '<span class="ee-error-user-msg-spn">' |
121 | - . trim( $msg ) |
|
121 | + . trim($msg) |
|
122 | 122 | . '</span> <sup>' |
123 | 123 | . $code |
124 | 124 | . '</sup><br />'; |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | <p class="ee-error-dev-msg-pg"> |
130 | 130 | ' |
131 | 131 | . sprintf( |
132 | - __( '%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso' ), |
|
132 | + __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
133 | 133 | '<strong class="ee-error-dev-msg-str">', |
134 | - get_class( $exception ), |
|
134 | + get_class($exception), |
|
135 | 135 | '</strong> <span>', |
136 | - $code . '</span>' |
|
136 | + $code.'</span>' |
|
137 | 137 | ) |
138 | 138 | . '<br /> |
139 | 139 | <span class="big-text">"' |
140 | - . trim( $msg ) |
|
140 | + . trim($msg) |
|
141 | 141 | . '"</span><br/> |
142 | 142 | <a id="display-ee-error-trace-1' |
143 | 143 | . $time |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | . $time |
146 | 146 | . '"> |
147 | 147 | ' |
148 | - . __( 'click to view backtrace and class/method details', 'event_espresso' ) |
|
148 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
149 | 149 | . ' |
150 | 150 | </a><br /> |
151 | 151 | ' |
152 | 152 | . $exception->getFile() |
153 | 153 | . sprintf( |
154 | - __( '%1$s( line no: %2$s )%3$s', 'event_espresso' ), |
|
154 | + __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
155 | 155 | ' <span class="small-text lt-grey-text">', |
156 | 156 | $exception->getLine(), |
157 | 157 | '</span>' |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | . '-dv" class="ee-error-trace-dv" style="display: none;"> |
164 | 164 | ' |
165 | 165 | . $trace_details; |
166 | - if ( ! empty( $class ) ) { |
|
166 | + if ( ! empty($class)) { |
|
167 | 167 | $output .= ' |
168 | 168 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
169 | 169 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
170 | - <h3>' . __( 'Class Details', 'event_espresso' ) . '</h3>'; |
|
171 | - $a = new \ReflectionClass( $class ); |
|
170 | + <h3>' . __('Class Details', 'event_espresso').'</h3>'; |
|
171 | + $a = new \ReflectionClass($class); |
|
172 | 172 | $output .= ' |
173 | - <pre>' . $a . '</pre> |
|
173 | + <pre>' . $a.'</pre> |
|
174 | 174 | </div> |
175 | 175 | </div>'; |
176 | 176 | } |
@@ -180,16 +180,16 @@ discard block |
||
180 | 180 | <br />'; |
181 | 181 | } |
182 | 182 | // remove last linebreak |
183 | - $output = substr( $output, 0, count( $output ) - 7 ); |
|
184 | - if ( ! WP_DEBUG ) { |
|
183 | + $output = substr($output, 0, count($output) - 7); |
|
184 | + if ( ! WP_DEBUG) { |
|
185 | 185 | $output .= ' |
186 | 186 | </p>'; |
187 | 187 | } |
188 | 188 | $output .= ' |
189 | 189 | </div>'; |
190 | - $output .= $this->printScripts( true ); |
|
191 | - if ( defined( 'DOING_AJAX' ) ) { |
|
192 | - echo json_encode( array( 'error' => $output ) ); |
|
190 | + $output .= $this->printScripts(true); |
|
191 | + if (defined('DOING_AJAX')) { |
|
192 | + echo json_encode(array('error' => $output)); |
|
193 | 193 | exit(); |
194 | 194 | } |
195 | 195 | echo $output; |
@@ -206,56 +206,56 @@ discard block |
||
206 | 206 | * @param bool $array |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - private function _convert_args_to_string( $arguments = array(), $indent = 0, $array = false ) { |
|
209 | + private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) { |
|
210 | 210 | $args = array(); |
211 | - $args_count = count( $arguments ); |
|
212 | - if ( $args_count > 2 ) { |
|
211 | + $args_count = count($arguments); |
|
212 | + if ($args_count > 2) { |
|
213 | 213 | $indent++; |
214 | 214 | $args[] = '<br />'; |
215 | 215 | } |
216 | 216 | $x = 0; |
217 | - foreach ( $arguments as $arg ) { |
|
217 | + foreach ($arguments as $arg) { |
|
218 | 218 | $x++; |
219 | - for( $i = 0; $i < $indent; $i++ ) { |
|
219 | + for ($i = 0; $i < $indent; $i++) { |
|
220 | 220 | $args[] = ' '; |
221 | 221 | } |
222 | - if ( is_string( $arg ) ) { |
|
223 | - if ( ! $array && strlen( $arg ) > 75 ) { |
|
222 | + if (is_string($arg)) { |
|
223 | + if ( ! $array && strlen($arg) > 75) { |
|
224 | 224 | $args[] = "<br />"; |
225 | - for ( $i = 0; $i <= $indent; $i++ ) { |
|
225 | + for ($i = 0; $i <= $indent; $i++) { |
|
226 | 226 | $args[] = ' '; |
227 | 227 | } |
228 | - $args[] = "'" . $arg . "'<br />"; |
|
228 | + $args[] = "'".$arg."'<br />"; |
|
229 | 229 | } else { |
230 | - $args[] = " '" . $arg . "'"; |
|
230 | + $args[] = " '".$arg."'"; |
|
231 | 231 | } |
232 | - } elseif ( is_array( $arg ) ) { |
|
233 | - $arg_count = count( $arg ); |
|
234 | - if ( $arg_count > 2 ) { |
|
232 | + } elseif (is_array($arg)) { |
|
233 | + $arg_count = count($arg); |
|
234 | + if ($arg_count > 2) { |
|
235 | 235 | $indent++; |
236 | - $args[] = " array(" . $this->_convert_args_to_string( $arg, $indent, true ) . ")"; |
|
236 | + $args[] = " array(".$this->_convert_args_to_string($arg, $indent, true).")"; |
|
237 | 237 | $indent--; |
238 | - } else if ( $arg_count === 0 ) { |
|
238 | + } else if ($arg_count === 0) { |
|
239 | 239 | $args[] = " array()"; |
240 | 240 | } else { |
241 | - $args[] = " array( " . $this->_convert_args_to_string( $arg ) . " )"; |
|
241 | + $args[] = " array( ".$this->_convert_args_to_string($arg)." )"; |
|
242 | 242 | } |
243 | - } elseif ( $arg === null ) { |
|
243 | + } elseif ($arg === null) { |
|
244 | 244 | $args[] = ' null'; |
245 | - } elseif ( is_bool( $arg ) ) { |
|
245 | + } elseif (is_bool($arg)) { |
|
246 | 246 | $args[] = $arg ? ' true' : ' false'; |
247 | - } elseif ( is_object( $arg ) ) { |
|
248 | - $args[] = get_class( $arg ); |
|
249 | - } elseif ( is_resource( $arg ) ) { |
|
250 | - $args[] = get_resource_type( $arg ); |
|
247 | + } elseif (is_object($arg)) { |
|
248 | + $args[] = get_class($arg); |
|
249 | + } elseif (is_resource($arg)) { |
|
250 | + $args[] = get_resource_type($arg); |
|
251 | 251 | } else { |
252 | 252 | $args[] = $arg; |
253 | 253 | } |
254 | - if ( $x === $args_count ) { |
|
255 | - if ( $args_count > 2 ) { |
|
254 | + if ($x === $args_count) { |
|
255 | + if ($args_count > 2) { |
|
256 | 256 | $args[] = "<br />"; |
257 | 257 | $indent--; |
258 | - for ( $i = 1; $i < $indent; $i++ ) { |
|
258 | + for ($i = 1; $i < $indent; $i++) { |
|
259 | 259 | $args[] = ' '; |
260 | 260 | } |
261 | 261 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $args[] = $args_count > 2 ? ",<br />" : ', '; |
264 | 264 | } |
265 | 265 | } |
266 | - return implode( '', $args ); |
|
266 | + return implode('', $args); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | * @param string $line |
279 | 279 | * @return string |
280 | 280 | */ |
281 | - protected function generate_error_code( $file = '', $func = '', $line = '' ) { |
|
282 | - $file_bits = explode( '.', basename( $file ) ); |
|
283 | - $error_code = ! empty( $file_bits[0] ) ? $file_bits[0] : ''; |
|
284 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
285 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
281 | + protected function generate_error_code($file = '', $func = '', $line = '') { |
|
282 | + $file_bits = explode('.', basename($file)); |
|
283 | + $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
284 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
285 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
286 | 286 | return $error_code; |
287 | 287 | } |
288 | 288 | |
@@ -366,26 +366,26 @@ discard block |
||
366 | 366 | * @param bool $force_print |
367 | 367 | * @return string|void |
368 | 368 | */ |
369 | - private function printScripts( $force_print = false ) { |
|
370 | - if ( ! $force_print && ( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' ) ) ) { |
|
371 | - if ( wp_script_is( 'ee_error_js', 'enqueued' ) ) { |
|
369 | + private function printScripts($force_print = false) { |
|
370 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
371 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
372 | 372 | return ''; |
373 | - } else if ( wp_script_is( 'ee_error_js', 'registered' ) ) { |
|
374 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
375 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
376 | - wp_enqueue_script( 'ee_error_js' ); |
|
377 | - wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) ); |
|
373 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
374 | + add_filter('FHEE_load_css', '__return_true'); |
|
375 | + add_filter('FHEE_load_js', '__return_true'); |
|
376 | + wp_enqueue_script('ee_error_js'); |
|
377 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
378 | 378 | } |
379 | 379 | } else { |
380 | 380 | return ' |
381 | 381 | <script> |
382 | 382 | /* <![CDATA[ */ |
383 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
383 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
384 | 384 | /* ]]> */ |
385 | 385 | </script> |
386 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
387 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
388 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
386 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
387 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
388 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
389 | 389 | '; |
390 | 390 | } |
391 | 391 | return ''; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\exceptions; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | * @param int $code |
25 | 25 | * @param \Exception $previous |
26 | 26 | */ |
27 | - public function __construct( $action, $message = '', $code = 0, \Exception $previous = null ) { |
|
28 | - if ( empty( $message ) ) { |
|
27 | + public function __construct($action, $message = '', $code = 0, \Exception $previous = null) { |
|
28 | + if (empty($message)) { |
|
29 | 29 | $message = sprintf( |
30 | 30 | __( |
31 | 31 | 'We\'re sorry, but you do not have the required permissions to perform the following action: ', |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $action |
35 | 35 | ); |
36 | 36 | } |
37 | - parent::__construct( $message, $code, $previous ); |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\form_sections\form_handlers; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param int $code |
27 | 27 | * @param \Exception $previous |
28 | 28 | */ |
29 | - public function __construct( $actual, $message = '', $code = 0, \Exception $previous = null ) { |
|
30 | - if ( empty( $message ) ) { |
|
29 | + public function __construct($actual, $message = '', $code = 0, \Exception $previous = null) { |
|
30 | + if (empty($message)) { |
|
31 | 31 | $message = sprintf( |
32 | 32 | __( |
33 | 33 | 'A valid Form Handler was expected but instead "%1$s" was received.', |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $actual |
37 | 37 | ); |
38 | 38 | } |
39 | - parent::__construct( $message, $code, $previous ); |
|
39 | + parent::__construct($message, $code, $previous); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
@@ -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 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @param \EE_Form_Section_Proper $form |
38 | 38 | */ |
39 | - public function setForm( \EE_Form_Section_Proper $form ); |
|
39 | + public function setForm(\EE_Form_Section_Proper $form); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @param boolean $displayable |
55 | 55 | */ |
56 | - public function setDisplayable( $displayable = false ); |
|
56 | + public function setDisplayable($displayable = false); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @param string $submit_btn_text |
96 | 96 | */ |
97 | - public function setSubmitBtnText( $submit_btn_text ); |
|
97 | + public function setSubmitBtnText($submit_btn_text); |
|
98 | 98 | |
99 | 99 | |
100 | 100 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @param string $form_action |
110 | 110 | */ |
111 | - public function setFormAction( $form_action ); |
|
111 | + public function setFormAction($form_action); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * @param array $form_args |
117 | 117 | */ |
118 | - public function addFormActionArgs( $form_args = array() ); |
|
118 | + public function addFormActionArgs($form_args = array()); |
|
119 | 119 | |
120 | 120 | |
121 | 121 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param string $form_config |
137 | 137 | */ |
138 | - public function setFormConfig( $form_config ); |
|
138 | + public function setFormConfig($form_config); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param array $submitted_form_data |
188 | 188 | * @return bool |
189 | 189 | */ |
190 | - public function process( $submitted_form_data = array() ); |
|
190 | + public function process($submitted_form_data = array()); |
|
191 | 191 | |
192 | 192 | |
193 | 193 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param string $text |
198 | 198 | * @return \EE_Submit_Input |
199 | 199 | */ |
200 | - public function generateSubmitButton( $text = '' ); |
|
200 | + public function generateSubmitButton($text = ''); |
|
201 | 201 | |
202 | 202 | |
203 | 203 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param string $text |
217 | 217 | * @return \EE_Submit_Input |
218 | 218 | */ |
219 | - public function generateCancelButton( $text = '' ); |
|
219 | + public function generateCancelButton($text = ''); |
|
220 | 220 | |
221 | 221 | |
222 | 222 |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | use InvalidArgumentException; |
6 | 6 | |
7 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
8 | - exit( 'No direct script access allowed' ); |
|
7 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param int $order |
33 | 33 | * @throws InvalidArgumentException |
34 | 34 | */ |
35 | - public function setOrder( $order ); |
|
35 | + public function setOrder($order); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @throws InvalidDataTypeException |
49 | 49 | * @throws InvalidArgumentException |
50 | 50 | */ |
51 | - public function setRedirectUrl( $redirect_url ); |
|
51 | + public function setRedirectUrl($redirect_url); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @throws InvalidDataTypeException |
58 | 58 | * @throws InvalidArgumentException |
59 | 59 | */ |
60 | - public function addRedirectArgs( $redirect_args = array() ); |
|
60 | + public function addRedirectArgs($redirect_args = array()); |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * @param string $redirect_to |
73 | 73 | */ |
74 | - public function setRedirectTo( $redirect_to ); |
|
74 | + public function setRedirectTo($redirect_to); |
|
75 | 75 | |
76 | 76 | |
77 | 77 |
@@ -12,8 +12,6 @@ |
||
12 | 12 | KEY `group_id` (`group_id`), |
13 | 13 | KEY `question_id` (`question_id`) |
14 | 14 | ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8$$ |
15 | - |
|
16 | - |
|
17 | 15 | * 4.1 question group question model's tables and fields: |
18 | 16 | $this->_tables = array( |
19 | 17 | 'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question','QGQ_ID') |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
11 | 11 | use EventEspresso\core\exceptions\InvalidFormSubmissionException; |
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 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @author Brent Christensen |
29 | 29 | * @since 4.9.0 |
30 | 30 | */ |
31 | -abstract class FormHandler implements FormHandlerInterface{ |
|
31 | +abstract class FormHandler implements FormHandlerInterface { |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * will add opening and closing HTML form tags as well as a submit button |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
140 | 140 | \EE_Registry $registry |
141 | 141 | ) { |
142 | - $this->setFormName( $form_name ); |
|
143 | - $this->setAdminName( $admin_name ); |
|
144 | - $this->setSlug( $slug ); |
|
145 | - $this->setFormAction( $form_action ); |
|
146 | - $this->setFormConfig( $form_config ); |
|
147 | - $this->setSubmitBtnText( __( 'Submit', 'event_espresso' ) ); |
|
142 | + $this->setFormName($form_name); |
|
143 | + $this->setAdminName($admin_name); |
|
144 | + $this->setSlug($slug); |
|
145 | + $this->setFormAction($form_action); |
|
146 | + $this->setFormConfig($form_config); |
|
147 | + $this->setSubmitBtnText(__('Submit', 'event_espresso')); |
|
148 | 148 | $this->registry = $registry; |
149 | 149 | } |
150 | 150 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * @throws \EE_Error |
171 | 171 | * @throws \LogicException |
172 | 172 | */ |
173 | - public function form( $for_display = false ) { |
|
174 | - if ( ! $this->formIsValid() ) { |
|
173 | + public function form($for_display = false) { |
|
174 | + if ( ! $this->formIsValid()) { |
|
175 | 175 | return null; |
176 | 176 | } |
177 | - if ( $for_display ) { |
|
177 | + if ($for_display) { |
|
178 | 178 | $form_config = $this->formConfig(); |
179 | 179 | if ( |
180 | 180 | $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * @throws LogicException |
195 | 195 | */ |
196 | 196 | public function formIsValid() { |
197 | - if ( ! $this->form instanceof \EE_Form_Section_Proper ) { |
|
197 | + if ( ! $this->form instanceof \EE_Form_Section_Proper) { |
|
198 | 198 | static $generated = false; |
199 | - if ( ! $generated ) { |
|
199 | + if ( ! $generated) { |
|
200 | 200 | $generated = true; |
201 | 201 | $this->generate(); |
202 | 202 | } |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | * @throws LogicException |
213 | 213 | */ |
214 | 214 | public function verifyForm() { |
215 | - if ( $this->form instanceof \EE_Form_Section_Proper ) { |
|
215 | + if ($this->form instanceof \EE_Form_Section_Proper) { |
|
216 | 216 | return true; |
217 | 217 | } |
218 | 218 | throw new LogicException( |
219 | 219 | sprintf( |
220 | - __( 'The "%1$s" form is invalid or missing', 'event_espresso' ), |
|
220 | + __('The "%1$s" form is invalid or missing', 'event_espresso'), |
|
221 | 221 | $this->form_name |
222 | 222 | ) |
223 | 223 | ); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | /** |
229 | 229 | * @param \EE_Form_Section_Proper $form |
230 | 230 | */ |
231 | - public function setForm( \EE_Form_Section_Proper $form ) { |
|
231 | + public function setForm(\EE_Form_Section_Proper $form) { |
|
232 | 232 | $this->form = $form; |
233 | 233 | } |
234 | 234 | |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * @param boolean $displayable |
248 | 248 | */ |
249 | - public function setDisplayable( $displayable = false ) { |
|
250 | - $this->displayable = filter_var( $displayable, FILTER_VALIDATE_BOOLEAN ); |
|
249 | + public function setDisplayable($displayable = false) { |
|
250 | + $this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | * @param string $form_name |
268 | 268 | * @throws InvalidDataTypeException |
269 | 269 | */ |
270 | - public function setFormName( $form_name ) { |
|
271 | - if ( ! is_string( $form_name ) ) { |
|
272 | - throw new InvalidDataTypeException( '$form_name', $form_name, 'string' ); |
|
270 | + public function setFormName($form_name) { |
|
271 | + if ( ! is_string($form_name)) { |
|
272 | + throw new InvalidDataTypeException('$form_name', $form_name, 'string'); |
|
273 | 273 | } |
274 | 274 | $this->form_name = $form_name; |
275 | 275 | } |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @param string $admin_name |
292 | 292 | * @throws InvalidDataTypeException |
293 | 293 | */ |
294 | - public function setAdminName( $admin_name ) { |
|
295 | - if ( ! is_string( $admin_name ) ) { |
|
296 | - throw new InvalidDataTypeException( '$admin_name', $admin_name, 'string' ); |
|
294 | + public function setAdminName($admin_name) { |
|
295 | + if ( ! is_string($admin_name)) { |
|
296 | + throw new InvalidDataTypeException('$admin_name', $admin_name, 'string'); |
|
297 | 297 | } |
298 | 298 | $this->admin_name = $admin_name; |
299 | 299 | } |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | * @param string $slug |
316 | 316 | * @throws InvalidDataTypeException |
317 | 317 | */ |
318 | - public function setSlug( $slug ) { |
|
319 | - if ( ! is_string( $slug ) ) { |
|
320 | - throw new InvalidDataTypeException( '$slug', $slug, 'string' ); |
|
318 | + public function setSlug($slug) { |
|
319 | + if ( ! is_string($slug)) { |
|
320 | + throw new InvalidDataTypeException('$slug', $slug, 'string'); |
|
321 | 321 | } |
322 | 322 | $this->slug = $slug; |
323 | 323 | } |
@@ -336,13 +336,13 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * @param string $submit_btn_text |
338 | 338 | */ |
339 | - public function setSubmitBtnText( $submit_btn_text ) { |
|
340 | - if ( ! is_string( $submit_btn_text ) ) { |
|
341 | - throw new InvalidDataTypeException( '$submit_btn_text', $submit_btn_text, 'string' ); |
|
339 | + public function setSubmitBtnText($submit_btn_text) { |
|
340 | + if ( ! is_string($submit_btn_text)) { |
|
341 | + throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string'); |
|
342 | 342 | } |
343 | - if ( empty( $submit_btn_text ) ) { |
|
343 | + if (empty($submit_btn_text)) { |
|
344 | 344 | throw new InvalidArgumentException( |
345 | - __( 'Can not set Submit button text because an empty string was provided.', 'event_espresso' ) |
|
345 | + __('Can not set Submit button text because an empty string was provided.', 'event_espresso') |
|
346 | 346 | ); |
347 | 347 | } |
348 | 348 | $this->submit_btn_text = $submit_btn_text; |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @return string |
355 | 355 | */ |
356 | 356 | public function formAction() { |
357 | - return ! empty( $this->form_args ) |
|
358 | - ? add_query_arg( $this->form_args, $this->form_action ) |
|
357 | + return ! empty($this->form_args) |
|
358 | + ? add_query_arg($this->form_args, $this->form_action) |
|
359 | 359 | : $this->form_action; |
360 | 360 | } |
361 | 361 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | * @param string $form_action |
366 | 366 | * @throws InvalidDataTypeException |
367 | 367 | */ |
368 | - public function setFormAction( $form_action ) { |
|
369 | - if ( ! is_string( $form_action ) ) { |
|
370 | - throw new InvalidDataTypeException( '$form_action', $form_action, 'string' ); |
|
368 | + public function setFormAction($form_action) { |
|
369 | + if ( ! is_string($form_action)) { |
|
370 | + throw new InvalidDataTypeException('$form_action', $form_action, 'string'); |
|
371 | 371 | } |
372 | 372 | $this->form_action = $form_action; |
373 | 373 | } |
@@ -379,20 +379,20 @@ discard block |
||
379 | 379 | * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
380 | 380 | * @throws \InvalidArgumentException |
381 | 381 | */ |
382 | - public function addFormActionArgs( $form_args = array() ) { |
|
383 | - if ( is_object( $form_args ) ) { |
|
382 | + public function addFormActionArgs($form_args = array()) { |
|
383 | + if (is_object($form_args)) { |
|
384 | 384 | throw new InvalidDataTypeException( |
385 | 385 | '$form_args', |
386 | 386 | $form_args, |
387 | 387 | 'anything other than an object was expected.' |
388 | 388 | ); |
389 | 389 | } |
390 | - if ( empty( $form_args ) ) { |
|
390 | + if (empty($form_args)) { |
|
391 | 391 | throw new InvalidArgumentException( |
392 | - __( 'The redirect arguments can not be an empty array.', 'event_espresso' ) |
|
392 | + __('The redirect arguments can not be an empty array.', 'event_espresso') |
|
393 | 393 | ); |
394 | 394 | } |
395 | - $this->form_args = array_merge( $this->form_args, $form_args ); |
|
395 | + $this->form_args = array_merge($this->form_args, $form_args); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param string $form_config |
411 | 411 | * @throws DomainException |
412 | 412 | */ |
413 | - public function setFormConfig( $form_config ) { |
|
413 | + public function setFormConfig($form_config) { |
|
414 | 414 | if ( |
415 | 415 | ! in_array( |
416 | 416 | $form_config, |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | ) { |
425 | 425 | throw new DomainException( |
426 | 426 | sprintf( |
427 | - __( '"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form', 'event_espresso' ), |
|
427 | + __('"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form', 'event_espresso'), |
|
428 | 428 | $form_config |
429 | 429 | ) |
430 | 430 | ); |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @return boolean |
445 | 445 | */ |
446 | 446 | public function initialize() { |
447 | - $this->form_has_errors = \EE_Error::has_error( true ); |
|
447 | + $this->form_has_errors = \EE_Error::has_error(true); |
|
448 | 448 | return true; |
449 | 449 | } |
450 | 450 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @throws \EE_Error |
459 | 459 | */ |
460 | 460 | public function enqueueStylesAndScripts() { |
461 | - $this->form( false )->enqueue_js(); |
|
461 | + $this->form(false)->enqueue_js(); |
|
462 | 462 | |
463 | 463 | } |
464 | 464 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return EE_Form_Section_Proper |
471 | 471 | */ |
472 | - abstract public function generate() ; |
|
472 | + abstract public function generate(); |
|
473 | 473 | |
474 | 474 | |
475 | 475 | |
@@ -479,15 +479,15 @@ discard block |
||
479 | 479 | * @param string $text |
480 | 480 | * @return \EE_Submit_Input |
481 | 481 | */ |
482 | - public function generateSubmitButton( $text = '' ) { |
|
483 | - $text = ! empty( $text ) ? $text : $this->submitBtnText(); |
|
482 | + public function generateSubmitButton($text = '') { |
|
483 | + $text = ! empty($text) ? $text : $this->submitBtnText(); |
|
484 | 484 | return new EE_Submit_Input( |
485 | 485 | array( |
486 | - 'html_name' => 'ee-form-submit-' . $this->slug(), |
|
487 | - 'html_id' => 'ee-form-submit-' . $this->slug(), |
|
486 | + 'html_name' => 'ee-form-submit-'.$this->slug(), |
|
487 | + 'html_id' => 'ee-form-submit-'.$this->slug(), |
|
488 | 488 | 'html_class' => 'ee-form-submit', |
489 | 489 | 'html_label' => ' ', |
490 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
490 | + 'other_html_attributes' => ' rel="'.$this->slug().'"', |
|
491 | 491 | 'default' => $text |
492 | 492 | ) |
493 | 493 | ); |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | * @throws \LogicException |
504 | 504 | * @throws \EE_Error |
505 | 505 | */ |
506 | - public function appendSubmitButton( $text = '' ) { |
|
507 | - if ( $this->form->subsection_exists( $this->slug() . '-submit-btn' ) ) { |
|
506 | + public function appendSubmitButton($text = '') { |
|
507 | + if ($this->form->subsection_exists($this->slug().'-submit-btn')) { |
|
508 | 508 | return; |
509 | 509 | } |
510 | 510 | $this->form->add_subsections( |
511 | - array( $this->slug() . '-submit-btn' => $this->generateSubmitButton( $text ) ), |
|
511 | + array($this->slug().'-submit-btn' => $this->generateSubmitButton($text)), |
|
512 | 512 | null, |
513 | 513 | false |
514 | 514 | ); |
@@ -522,18 +522,18 @@ discard block |
||
522 | 522 | * @param string $text |
523 | 523 | * @return \EE_Submit_Input |
524 | 524 | */ |
525 | - public function generateCancelButton( $text = '' ) { |
|
525 | + public function generateCancelButton($text = '') { |
|
526 | 526 | $cancel_button = new EE_Submit_Input( |
527 | 527 | array( |
528 | - 'html_name' => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!! |
|
529 | - 'html_id' => 'ee-cancel-form-' . $this->slug(), |
|
528 | + 'html_name' => 'ee-form-submit-'.$this->slug(), // YES! Same name as submit !!! |
|
529 | + 'html_id' => 'ee-cancel-form-'.$this->slug(), |
|
530 | 530 | 'html_class' => 'ee-cancel-form', |
531 | 531 | 'html_label' => ' ', |
532 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
533 | - 'default' => ! empty( $text ) ? $text : __( 'Cancel', 'event_espresso' ) |
|
532 | + 'other_html_attributes' => ' rel="'.$this->slug().'"', |
|
533 | + 'default' => ! empty($text) ? $text : __('Cancel', 'event_espresso') |
|
534 | 534 | ) |
535 | 535 | ); |
536 | - $cancel_button->set_button_css_attributes( false ); |
|
536 | + $cancel_button->set_button_css_attributes(false); |
|
537 | 537 | return $cancel_button; |
538 | 538 | } |
539 | 539 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $this->form->add_subsections( |
550 | 550 | array( |
551 | 551 | 'clear-submit-btn-float' => new \EE_Form_Section_HTML( |
552 | - EEH_HTML::div( '', '', 'clear-float' ) . EEH_HTML::divx() |
|
552 | + EEH_HTML::div('', '', 'clear-float').EEH_HTML::divx() |
|
553 | 553 | ) |
554 | 554 | ), |
555 | 555 | null, |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
575 | 575 | || $form_config === FormHandler::ADD_FORM_TAGS_ONLY |
576 | 576 | ) { |
577 | - $form_html .= $this->form()->form_open( $this->formAction() ); |
|
577 | + $form_html .= $this->form()->form_open($this->formAction()); |
|
578 | 578 | } |
579 | - $form_html .= $this->form( true )->get_html( $this->form_has_errors ); |
|
579 | + $form_html .= $this->form(true)->get_html($this->form_has_errors); |
|
580 | 580 | if ( |
581 | 581 | $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
582 | 582 | || $form_config === FormHandler::ADD_FORM_TAGS_ONLY |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | * @throws \LogicException |
599 | 599 | * @throws InvalidFormSubmissionException |
600 | 600 | */ |
601 | - public function process( $submitted_form_data = array() ) { |
|
602 | - if ( ! $this->form()->was_submitted( $submitted_form_data ) ) { |
|
603 | - throw new InvalidFormSubmissionException( $this->form_name ); |
|
601 | + public function process($submitted_form_data = array()) { |
|
602 | + if ( ! $this->form()->was_submitted($submitted_form_data)) { |
|
603 | + throw new InvalidFormSubmissionException($this->form_name); |
|
604 | 604 | } |
605 | - $this->form( true )->receive_form_submission( $submitted_form_data ); |
|
606 | - if ( ! $this->form()->is_valid() ) { |
|
605 | + $this->form(true)->receive_form_submission($submitted_form_data); |
|
606 | + if ( ! $this->form()->is_valid()) { |
|
607 | 607 | throw new InvalidFormSubmissionException( |
608 | 608 | $this->form_name, |
609 | 609 | sprintf( |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | use InvalidArgumentException; |
6 | 6 | |
7 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
8 | - exit( 'No direct script access allowed' ); |
|
7 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | $form_config = 'add_form_tags_and_submit', |
87 | 87 | \EE_Registry $registry |
88 | 88 | ) { |
89 | - $this->setOrder( $order ); |
|
90 | - parent::__construct( $form_name, $admin_name, $slug, $form_action, $form_config, $registry ); |
|
89 | + $this->setOrder($order); |
|
90 | + parent::__construct($form_name, $admin_name, $slug, $form_action, $form_config, $registry); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | * @param int $order |
106 | 106 | * @throws InvalidArgumentException |
107 | 107 | */ |
108 | - public function setOrder( $order ) { |
|
109 | - $order = absint( $order ); |
|
110 | - if ( ! $order > 0 ) { |
|
108 | + public function setOrder($order) { |
|
109 | + $order = absint($order); |
|
110 | + if ( ! $order > 0) { |
|
111 | 111 | throw new InvalidArgumentException( |
112 | - __( 'The form order property must be a positive integer.', 'event_espresso' ) |
|
112 | + __('The form order property must be a positive integer.', 'event_espresso') |
|
113 | 113 | ); |
114 | 114 | } |
115 | 115 | $this->order = $order; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return string |
123 | 123 | */ |
124 | 124 | public function redirectUrl() { |
125 | - return ! empty( $this->redirect_args ) |
|
126 | - ? add_query_arg( $this->redirect_args, $this->redirect_url ) |
|
125 | + return ! empty($this->redirect_args) |
|
126 | + ? add_query_arg($this->redirect_args, $this->redirect_url) |
|
127 | 127 | : $this->redirect_url; |
128 | 128 | } |
129 | 129 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @throws InvalidDataTypeException |
135 | 135 | * @throws InvalidArgumentException |
136 | 136 | */ |
137 | - public function setRedirectUrl( $redirect_url ) { |
|
138 | - if ( ! is_string( $redirect_url ) ) { |
|
139 | - throw new InvalidDataTypeException( '$redirect_url', $redirect_url, 'string' ); |
|
137 | + public function setRedirectUrl($redirect_url) { |
|
138 | + if ( ! is_string($redirect_url)) { |
|
139 | + throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string'); |
|
140 | 140 | } |
141 | - if ( empty( $redirect_url ) ) { |
|
141 | + if (empty($redirect_url)) { |
|
142 | 142 | throw new InvalidArgumentException( |
143 | - __( 'The redirect URL can not be an empty string.', 'event_espresso' ) |
|
143 | + __('The redirect URL can not be an empty string.', 'event_espresso') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | $this->redirect_url = $redirect_url; |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | * @throws InvalidDataTypeException |
154 | 154 | * @throws InvalidArgumentException |
155 | 155 | */ |
156 | - public function addRedirectArgs( $redirect_args = array() ) { |
|
157 | - if ( is_object( $redirect_args ) ) { |
|
156 | + public function addRedirectArgs($redirect_args = array()) { |
|
157 | + if (is_object($redirect_args)) { |
|
158 | 158 | throw new InvalidDataTypeException( |
159 | 159 | '$redirect_args', |
160 | 160 | $redirect_args, |
161 | 161 | 'anything other than an object was expected.' |
162 | 162 | ); |
163 | 163 | } |
164 | - if ( empty( $redirect_args ) ) { |
|
164 | + if (empty($redirect_args)) { |
|
165 | 165 | throw new InvalidArgumentException( |
166 | - __( 'The redirect argument can not be an empty array.', 'event_espresso' ) |
|
166 | + __('The redirect argument can not be an empty array.', 'event_espresso') |
|
167 | 167 | ); |
168 | 168 | } |
169 | - $this->redirect_args = array_merge( $this->redirect_args, (array) $redirect_args ); |
|
169 | + $this->redirect_args = array_merge($this->redirect_args, (array) $redirect_args); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | * @throws InvalidDataTypeException |
177 | 177 | * @throws InvalidArgumentException |
178 | 178 | */ |
179 | - public function removeRedirectArgs( $redirect_arg_keys_to_remove = array() ) { |
|
180 | - if ( is_object( $redirect_arg_keys_to_remove ) ) { |
|
179 | + public function removeRedirectArgs($redirect_arg_keys_to_remove = array()) { |
|
180 | + if (is_object($redirect_arg_keys_to_remove)) { |
|
181 | 181 | throw new InvalidDataTypeException( |
182 | 182 | '$redirect_arg_keys_to_remove', |
183 | 183 | $redirect_arg_keys_to_remove, |
184 | 184 | 'anything other than an object was expected.' |
185 | 185 | ); |
186 | 186 | } |
187 | - if ( empty( $redirect_arg_keys_to_remove ) ) { |
|
187 | + if (empty($redirect_arg_keys_to_remove)) { |
|
188 | 188 | throw new InvalidArgumentException( |
189 | - __( 'The $redirect_arg_keys_to_remove argument can not be an empty array.', 'event_espresso' ) |
|
189 | + __('The $redirect_arg_keys_to_remove argument can not be an empty array.', 'event_espresso') |
|
190 | 190 | ); |
191 | 191 | } |
192 | - foreach ( $redirect_arg_keys_to_remove as $redirect_arg_key ) { |
|
193 | - unset( $this->redirect_args[ $redirect_arg_key ] ); |
|
192 | + foreach ($redirect_arg_keys_to_remove as $redirect_arg_key) { |
|
193 | + unset($this->redirect_args[$redirect_arg_key]); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | /** |
209 | 209 | * @param string $redirect_to |
210 | 210 | */ |
211 | - public function setRedirectTo( $redirect_to ) { |
|
211 | + public function setRedirectTo($redirect_to) { |
|
212 | 212 | if ( |
213 | 213 | ! in_array( |
214 | 214 | $redirect_to, |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | if(isset($default_data[$subsection_name])){ |
300 | 300 | if($subsection instanceof EE_Form_Input_Base){ |
301 | 301 | $subsection->set_default($default_data[$subsection_name]); |
302 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
302 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
303 | 303 | $subsection->populate_defaults($default_data[$subsection_name]); |
304 | 304 | } |
305 | 305 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | foreach($this->subsections() as $subsection){ |
626 | 626 | if( $subsection instanceof EE_Form_Input_Base ){ |
627 | 627 | $inputs[ $subsection->html_name() ] = $subsection; |
628 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
628 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
629 | 629 | $inputs += $subsection->inputs_in_subsections(); |
630 | 630 | } |
631 | 631 | } |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | public function html_name_prefix(){ |
1117 | 1117 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
1118 | 1118 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
1119 | - }else{ |
|
1119 | + } else{ |
|
1120 | 1120 | return $this->name(); |
1121 | 1121 | } |
1122 | 1122 | } |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | if( $subsection->form_data_present_in( $req_data ) ) { |
1179 | 1179 | return TRUE; |
1180 | 1180 | } |
1181 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
1181 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
1182 | 1182 | if( $subsection->form_data_present_in( $req_data ) ) { |
1183 | 1183 | return TRUE; |
1184 | 1184 | } |
@@ -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 | const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data'; |
13 | 13 | |
@@ -71,49 +71,49 @@ discard block |
||
71 | 71 | * } @see EE_Form_Section_Validatable::__construct() |
72 | 72 | * @throws \EE_Error |
73 | 73 | */ |
74 | - public function __construct( $options_array = array() ){ |
|
75 | - $options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
74 | + public function __construct($options_array = array()) { |
|
75 | + $options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
76 | 76 | //call parent first, as it may be setting the name |
77 | 77 | parent::__construct($options_array); |
78 | 78 | //if they've included subsections in the constructor, add them now |
79 | - if( isset( $options_array['include'] )){ |
|
79 | + if (isset($options_array['include'])) { |
|
80 | 80 | //we are going to make sure we ONLY have those subsections to include |
81 | 81 | //AND we are going to make sure they're in that specified order |
82 | 82 | $reordered_subsections = array(); |
83 | - foreach($options_array['include'] as $input_name){ |
|
84 | - if(isset($this->_subsections[$input_name])){ |
|
83 | + foreach ($options_array['include'] as $input_name) { |
|
84 | + if (isset($this->_subsections[$input_name])) { |
|
85 | 85 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | $this->_subsections = $reordered_subsections; |
89 | 89 | } |
90 | - if(isset($options_array['exclude'])){ |
|
90 | + if (isset($options_array['exclude'])) { |
|
91 | 91 | $exclude = $options_array['exclude']; |
92 | 92 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
93 | 93 | } |
94 | - if(isset($options_array['layout_strategy'])){ |
|
94 | + if (isset($options_array['layout_strategy'])) { |
|
95 | 95 | $this->_layout_strategy = $options_array['layout_strategy']; |
96 | 96 | } |
97 | - if( ! $this->_layout_strategy){ |
|
97 | + if ( ! $this->_layout_strategy) { |
|
98 | 98 | $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout(); |
99 | 99 | } |
100 | 100 | $this->_layout_strategy->_construct_finalize($this); |
101 | 101 | |
102 | 102 | //ok so we are definitely going to want the forms JS, |
103 | 103 | //so enqueue it or remember to enqueue it during wp_enqueue_scripts |
104 | - if( did_action( 'wp_enqueue_scripts' ) |
|
105 | - || did_action( 'admin_enqueue_scripts' ) ) { |
|
104 | + if (did_action('wp_enqueue_scripts') |
|
105 | + || did_action('admin_enqueue_scripts')) { |
|
106 | 106 | //ok so they've constructed this object after when they should have. |
107 | 107 | //just enqueue the generic form scripts and initialize the form immediately in the JS |
108 | - \EE_Form_Section_Proper::wp_enqueue_scripts( true ); |
|
108 | + \EE_Form_Section_Proper::wp_enqueue_scripts(true); |
|
109 | 109 | } else { |
110 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
111 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
110 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
111 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
112 | 112 | } |
113 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
113 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
114 | 114 | |
115 | - if( isset( $options_array[ 'name' ] ) ) { |
|
116 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
115 | + if (isset($options_array['name'])) { |
|
116 | + $this->_construct_finalize(null, $options_array['name']); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -126,25 +126,25 @@ discard block |
||
126 | 126 | * @param string $name |
127 | 127 | * @throws \EE_Error |
128 | 128 | */ |
129 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
129 | + public function _construct_finalize($parent_form_section, $name) { |
|
130 | 130 | parent::_construct_finalize($parent_form_section, $name); |
131 | 131 | $this->_set_default_name_if_empty(); |
132 | 132 | $this->_set_default_html_id_if_empty(); |
133 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
134 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
135 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
133 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
134 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
135 | + $subsection->_construct_finalize($this, $subsection_name); |
|
136 | 136 | } else { |
137 | 137 | throw new EE_Error( |
138 | 138 | sprintf( |
139 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
139 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
140 | 140 | $subsection_name, |
141 | 141 | get_class($this), |
142 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
142 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | } |
146 | 146 | } |
147 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
147 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * Gets the layout strategy for this form section |
154 | 154 | * @return EE_Form_Section_Layout_Base |
155 | 155 | */ |
156 | - public function get_layout_strategy(){ |
|
156 | + public function get_layout_strategy() { |
|
157 | 157 | return $this->_layout_strategy; |
158 | 158 | } |
159 | 159 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param EE_Form_Input_Base $input |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public function get_html_for_input($input){ |
|
168 | + public function get_html_for_input($input) { |
|
169 | 169 | return $this->_layout_strategy->layout_input($input); |
170 | 170 | } |
171 | 171 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param null $form_data |
179 | 179 | * @return boolean |
180 | 180 | */ |
181 | - public function was_submitted($form_data = NULL){ |
|
181 | + public function was_submitted($form_data = NULL) { |
|
182 | 182 | return $this->form_data_present_in($form_data); |
183 | 183 | } |
184 | 184 | |
@@ -203,21 +203,21 @@ discard block |
||
203 | 203 | * (eg you validated the data then stored it in the DB) |
204 | 204 | * you may want to skip this step. |
205 | 205 | */ |
206 | - public function receive_form_submission( $req_data = null, $validate = true ){ |
|
207 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
208 | - if( $req_data === null ){ |
|
209 | - $req_data = array_merge( $_GET, $_POST ); |
|
206 | + public function receive_form_submission($req_data = null, $validate = true) { |
|
207 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
208 | + if ($req_data === null) { |
|
209 | + $req_data = array_merge($_GET, $_POST); |
|
210 | 210 | } |
211 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
212 | - $this->_normalize( $req_data ); |
|
213 | - if( $validate ){ |
|
211 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
212 | + $this->_normalize($req_data); |
|
213 | + if ($validate) { |
|
214 | 214 | $this->_validate(); |
215 | 215 | //if it's invalid, we're going to want to re-display so remember what they submitted |
216 | - if ( ! $this->is_valid() ) { |
|
216 | + if ( ! $this->is_valid()) { |
|
217 | 217 | $this->store_submitted_form_data_in_session(); |
218 | 218 | } |
219 | 219 | } |
220 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
220 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function store_submitted_form_data_in_session() { |
232 | 232 | return EE_Registry::instance()->SSN->set_session_data( |
233 | 233 | array( |
234 | - \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values( true ) |
|
234 | + \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true) |
|
235 | 235 | ) |
236 | 236 | ); |
237 | 237 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | protected function flush_submitted_form_data_from_session() { |
261 | 261 | return EE_Registry::instance()->SSN->reset_data( |
262 | - array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY ) |
|
262 | + array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY) |
|
263 | 263 | ); |
264 | 264 | } |
265 | 265 | |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function populate_from_session() { |
277 | 277 | $form_data_in_session = $this->get_submitted_form_data_from_session(); |
278 | - if ( empty( $form_data_in_session ) ) { |
|
278 | + if (empty($form_data_in_session)) { |
|
279 | 279 | return false; |
280 | 280 | } |
281 | - $this->receive_form_submission( $form_data_in_session ); |
|
281 | + $this->receive_form_submission($form_data_in_session); |
|
282 | 282 | $this->flush_submitted_form_data_from_session(); |
283 | - if ( $this->form_data_present_in( $form_data_in_session ) ) { |
|
283 | + if ($this->form_data_present_in($form_data_in_session)) { |
|
284 | 284 | return true; |
285 | 285 | } else { |
286 | 286 | return false; |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | * the value being an array formatted in teh same way |
298 | 298 | * @param array $default_data |
299 | 299 | */ |
300 | - public function populate_defaults($default_data){ |
|
301 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
302 | - if(isset($default_data[$subsection_name])){ |
|
303 | - if($subsection instanceof EE_Form_Input_Base){ |
|
300 | + public function populate_defaults($default_data) { |
|
301 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
302 | + if (isset($default_data[$subsection_name])) { |
|
303 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
304 | 304 | $subsection->set_default($default_data[$subsection_name]); |
305 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
305 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
306 | 306 | $subsection->populate_defaults($default_data[$subsection_name]); |
307 | 307 | } |
308 | 308 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | * @param string $name |
318 | 318 | * @return boolean |
319 | 319 | */ |
320 | - public function subsection_exists( $name ){ |
|
321 | - return isset( $this->_subsections[ $name ] ) ? true : false; |
|
320 | + public function subsection_exists($name) { |
|
321 | + return isset($this->_subsections[$name]) ? true : false; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | * @return EE_Form_Section_Base |
337 | 337 | * @throws \EE_Error |
338 | 338 | */ |
339 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
340 | - if( $require_construction_to_be_finalized ){ |
|
339 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
340 | + if ($require_construction_to_be_finalized) { |
|
341 | 341 | $this->ensure_construct_finalized_called(); |
342 | 342 | } |
343 | - return $this->subsection_exists( $name ) ? $this->_subsections[$name] : NULL; |
|
343 | + return $this->subsection_exists($name) ? $this->_subsections[$name] : NULL; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | * Gets all the validatable subsections of this form section |
350 | 350 | * @return EE_Form_Section_Validatable[] |
351 | 351 | */ |
352 | - public function get_validatable_subsections(){ |
|
352 | + public function get_validatable_subsections() { |
|
353 | 353 | $validatable_subsections = array(); |
354 | - foreach($this->subsections() as $name=>$obj){ |
|
355 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
354 | + foreach ($this->subsections() as $name=>$obj) { |
|
355 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
356 | 356 | $validatable_subsections[$name] = $obj; |
357 | 357 | } |
358 | 358 | } |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | * @return EE_Form_Input_Base |
373 | 373 | * @throws EE_Error |
374 | 374 | */ |
375 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
375 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
376 | 376 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
377 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
377 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
378 | 378 | throw new EE_Error( |
379 | 379 | sprintf( |
380 | 380 | __( |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | 'event_espresso' |
383 | 383 | ), |
384 | 384 | $name, |
385 | - get_class( $this ), |
|
386 | - $subsection ? get_class( $subsection ) : __( "NULL", 'event_espresso' ) |
|
385 | + get_class($this), |
|
386 | + $subsection ? get_class($subsection) : __("NULL", 'event_espresso') |
|
387 | 387 | ) |
388 | 388 | ); |
389 | 389 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | * @return EE_Form_Section_Proper |
404 | 404 | * @throws EE_Error |
405 | 405 | */ |
406 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
407 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
408 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
406 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
407 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
408 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
409 | 409 | throw new EE_Error( |
410 | 410 | sprintf( |
411 | - __( "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso' ), |
|
411 | + __("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), |
|
412 | 412 | $name, |
413 | - get_class( $this ) |
|
413 | + get_class($this) |
|
414 | 414 | ) |
415 | 415 | ); |
416 | 416 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @return mixed depending on the input's type and its normalization strategy |
428 | 428 | * @throws \EE_Error |
429 | 429 | */ |
430 | - public function get_input_value($name){ |
|
430 | + public function get_input_value($name) { |
|
431 | 431 | $input = $this->get_input($name); |
432 | 432 | return $input->normalized_value(); |
433 | 433 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return boolean |
441 | 441 | */ |
442 | 442 | public function is_valid() { |
443 | - if( ! $this->has_received_submission()){ |
|
443 | + if ( ! $this->has_received_submission()) { |
|
444 | 444 | throw new EE_Error( |
445 | 445 | sprintf( |
446 | 446 | __( |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | } |
453 | - if( ! parent::is_valid() ) { |
|
453 | + if ( ! parent::is_valid()) { |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 | // ok so no general errors to this entire form section. |
457 | 457 | // so let's check the subsections, but only set errors if that hasn't been done yet |
458 | 458 | $set_submission_errors = $this->submission_error_message() === '' ? true : false; |
459 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
460 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){ |
|
461 | - if ( $set_submission_errors ) { |
|
462 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
459 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
460 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') { |
|
461 | + if ($set_submission_errors) { |
|
462 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
463 | 463 | } |
464 | 464 | return false; |
465 | 465 | } |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | * gets teh default name of this form section if none is specified |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - protected function _set_default_name_if_empty(){ |
|
477 | - if( ! $this->_name ){ |
|
476 | + protected function _set_default_name_if_empty() { |
|
477 | + if ( ! $this->_name) { |
|
478 | 478 | $classname = get_class($this); |
479 | 479 | $default_name = str_replace("EE_", "", $classname); |
480 | - $this->_name = $default_name; |
|
480 | + $this->_name = $default_name; |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * and get_html when you are about to display the form. |
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | - public function get_html_and_js(){ |
|
496 | + public function get_html_and_js() { |
|
497 | 497 | //no doing_it_wrong yet because we ourselves are still doing it wrong... |
498 | 498 | //and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts" |
499 | 499 | $this->enqueue_js(); |
@@ -508,9 +508,9 @@ discard block |
||
508 | 508 | * @param bool $display_previously_submitted_data |
509 | 509 | * @return string |
510 | 510 | */ |
511 | - public function get_html( $display_previously_submitted_data = true ){ |
|
511 | + public function get_html($display_previously_submitted_data = true) { |
|
512 | 512 | $this->ensure_construct_finalized_called(); |
513 | - if ( $display_previously_submitted_data ) { |
|
513 | + if ($display_previously_submitted_data) { |
|
514 | 514 | $this->populate_from_session(); |
515 | 515 | } |
516 | 516 | return $this->_layout_strategy->layout_form(); |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | * @return string |
525 | 525 | * @throws \EE_Error |
526 | 526 | */ |
527 | - public function enqueue_js(){ |
|
527 | + public function enqueue_js() { |
|
528 | 528 | $this->_enqueue_and_localize_form_js(); |
529 | - foreach( $this->subsections() as $subsection ) { |
|
529 | + foreach ($this->subsections() as $subsection) { |
|
530 | 530 | $subsection->enqueue_js(); |
531 | 531 | } |
532 | 532 | } |
@@ -545,19 +545,19 @@ discard block |
||
545 | 545 | * to be triggered automatically or not |
546 | 546 | * @return void |
547 | 547 | */ |
548 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){ |
|
549 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
548 | + public static function wp_enqueue_scripts($init_form_validation_automatically = true) { |
|
549 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
550 | 550 | wp_register_script( |
551 | 551 | 'ee_form_section_validation', |
552 | - EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', |
|
553 | - array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), |
|
552 | + EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', |
|
553 | + array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), |
|
554 | 554 | EVENT_ESPRESSO_VERSION, |
555 | 555 | true |
556 | 556 | ); |
557 | 557 | wp_localize_script( |
558 | 558 | 'ee_form_section_validation', |
559 | 559 | 'ee_form_section_validation_init', |
560 | - array( 'init' => $init_form_validation_automatically ? true : false ) |
|
560 | + array('init' => $init_form_validation_automatically ? true : false) |
|
561 | 561 | ); |
562 | 562 | } |
563 | 563 | |
@@ -570,14 +570,14 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @throws \EE_Error |
572 | 572 | */ |
573 | - public function _enqueue_and_localize_form_js(){ |
|
573 | + public function _enqueue_and_localize_form_js() { |
|
574 | 574 | $this->ensure_construct_finalized_called(); |
575 | 575 | //actually, we don't want to localize just yet. There may be other forms on the page. |
576 | 576 | //so we need to add our form section data to a static variable accessible by all form sections |
577 | 577 | //and localize it just before the footer |
578 | 578 | $this->localize_validation_rules(); |
579 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
580 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
579 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
580 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | |
@@ -589,12 +589,12 @@ discard block |
||
589 | 589 | * @return void |
590 | 590 | * @throws \EE_Error |
591 | 591 | */ |
592 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
592 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
593 | 593 | // we only want to localize vars ONCE for the entire form, |
594 | 594 | // so if the form section doesn't have a parent, then it must be the top dog |
595 | - if ( $return_for_subsection || ! $this->parent_section() ) { |
|
596 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
597 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
595 | + if ($return_for_subsection || ! $this->parent_section()) { |
|
596 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
597 | + 'form_section_id'=> $this->html_id(TRUE), |
|
598 | 598 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
599 | 599 | 'other_data' => $this->get_other_js_data(), |
600 | 600 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | * @param array $form_other_js_data |
611 | 611 | * @return array |
612 | 612 | */ |
613 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
614 | - foreach( $this->subsections() as $subsection ) { |
|
615 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
613 | + public function get_other_js_data($form_other_js_data = array()) { |
|
614 | + foreach ($this->subsections() as $subsection) { |
|
615 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
616 | 616 | } |
617 | 617 | return $form_other_js_data; |
618 | 618 | } |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | * Keys are their form names, and values are the inputs themselves |
624 | 624 | * @return EE_Form_Input_Base |
625 | 625 | */ |
626 | - public function inputs_in_subsections(){ |
|
626 | + public function inputs_in_subsections() { |
|
627 | 627 | $inputs = array(); |
628 | - foreach($this->subsections() as $subsection){ |
|
629 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
630 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
631 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
628 | + foreach ($this->subsections() as $subsection) { |
|
629 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
630 | + $inputs[$subsection->html_name()] = $subsection; |
|
631 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
632 | 632 | $inputs += $subsection->inputs_in_subsections(); |
633 | 633 | } |
634 | 634 | } |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | * and values are a string of all their validation errors |
642 | 642 | * @return string[] |
643 | 643 | */ |
644 | - public function subsection_validation_errors_by_html_name(){ |
|
644 | + public function subsection_validation_errors_by_html_name() { |
|
645 | 645 | $inputs = $this->inputs(); |
646 | 646 | $errors = array(); |
647 | - foreach( $inputs as $form_input ){ |
|
648 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
649 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
647 | + foreach ($inputs as $form_input) { |
|
648 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
649 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | return $errors; |
@@ -658,15 +658,15 @@ discard block |
||
658 | 658 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
659 | 659 | * Should be setup by each form during the _enqueues_and_localize_form_js |
660 | 660 | */ |
661 | - public static function localize_script_for_all_forms(){ |
|
661 | + public static function localize_script_for_all_forms() { |
|
662 | 662 | //allow inputs and stuff to hook in their JS and stuff here |
663 | - do_action( 'AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin' ); |
|
663 | + do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
|
664 | 664 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
665 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
665 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
666 | 666 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
667 | 667 | : 'wp_default'; |
668 | 668 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
669 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
669 | + wp_enqueue_script('ee_form_section_validation'); |
|
670 | 670 | wp_localize_script( |
671 | 671 | 'ee_form_section_validation', |
672 | 672 | 'ee_form_section_vars', |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | /** |
680 | 680 | * ensure_scripts_localized |
681 | 681 | */ |
682 | - public function ensure_scripts_localized(){ |
|
683 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
682 | + public function ensure_scripts_localized() { |
|
683 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
684 | 684 | $this->_enqueue_and_localize_form_js(); |
685 | 685 | } |
686 | 686 | } |
@@ -692,10 +692,10 @@ discard block |
||
692 | 692 | * is that the key here should be the same as the custom validation rule put in the JS file |
693 | 693 | * @return array keys are custom validation rules, and values are internationalized strings |
694 | 694 | */ |
695 | - private static function _get_localized_error_messages(){ |
|
695 | + private static function _get_localized_error_messages() { |
|
696 | 696 | return array( |
697 | 697 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
698 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
698 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
699 | 699 | ); |
700 | 700 | } |
701 | 701 | |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @return array |
727 | 727 | */ |
728 | - public function get_jquery_validation_rules(){ |
|
728 | + public function get_jquery_validation_rules() { |
|
729 | 729 | $jquery_validation_rules = array(); |
730 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
730 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
731 | 731 | $jquery_validation_rules = array_merge( |
732 | 732 | $jquery_validation_rules, |
733 | 733 | $subsection->get_jquery_validation_rules() |
@@ -744,14 +744,14 @@ discard block |
||
744 | 744 | * @param array $req_data like $_POST |
745 | 745 | * @return void |
746 | 746 | */ |
747 | - protected function _normalize( $req_data ) { |
|
747 | + protected function _normalize($req_data) { |
|
748 | 748 | $this->_received_submission = true; |
749 | 749 | $this->_validation_errors = array(); |
750 | - foreach ( $this->get_validatable_subsections() as $subsection ) { |
|
750 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
751 | 751 | try { |
752 | - $subsection->_normalize( $req_data ); |
|
753 | - } catch ( EE_Validation_Error $e ) { |
|
754 | - $subsection->add_validation_error( $e ); |
|
752 | + $subsection->_normalize($req_data); |
|
753 | + } catch (EE_Validation_Error $e) { |
|
754 | + $subsection->add_validation_error($e); |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | } |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | * calling parent::_validate() first. |
769 | 769 | */ |
770 | 770 | protected function _validate() { |
771 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
772 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
773 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
771 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
772 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
773 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
774 | 774 | } |
775 | 775 | $subsection->_validate(); |
776 | 776 | } |
@@ -782,13 +782,13 @@ discard block |
||
782 | 782 | * Gets all the validated inputs for the form section |
783 | 783 | * @return array |
784 | 784 | */ |
785 | - public function valid_data(){ |
|
785 | + public function valid_data() { |
|
786 | 786 | $inputs = array(); |
787 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
788 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
789 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
790 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
791 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
787 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
788 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
789 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
790 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
791 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
792 | 792 | } |
793 | 793 | } |
794 | 794 | return $inputs; |
@@ -800,11 +800,11 @@ discard block |
||
800 | 800 | * Gets all the inputs on this form section |
801 | 801 | * @return EE_Form_Input_Base[] |
802 | 802 | */ |
803 | - public function inputs(){ |
|
803 | + public function inputs() { |
|
804 | 804 | $inputs = array(); |
805 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
806 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
807 | - $inputs[ $subsection_name ] = $subsection; |
|
805 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
806 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
807 | + $inputs[$subsection_name] = $subsection; |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | return $inputs; |
@@ -816,10 +816,10 @@ discard block |
||
816 | 816 | * Gets all the subsections which are a proper form |
817 | 817 | * @return EE_Form_Section_Proper[] |
818 | 818 | */ |
819 | - public function subforms(){ |
|
819 | + public function subforms() { |
|
820 | 820 | $form_sections = array(); |
821 | - foreach($this->subsections() as $name=>$obj){ |
|
822 | - if($obj instanceof EE_Form_Section_Proper){ |
|
821 | + foreach ($this->subsections() as $name=>$obj) { |
|
822 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
823 | 823 | $form_sections[$name] = $obj; |
824 | 824 | } |
825 | 825 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | * if you only want form inputs or proper form sections. |
835 | 835 | * @return EE_Form_Section_Proper[] |
836 | 836 | */ |
837 | - public function subsections(){ |
|
837 | + public function subsections() { |
|
838 | 838 | $this->ensure_construct_finalized_called(); |
839 | 839 | return $this->_subsections; |
840 | 840 | } |
@@ -856,8 +856,8 @@ discard block |
||
856 | 856 | * where keys are always subsection names and values are either |
857 | 857 | * the input's normalized value, or an array like the top-level array |
858 | 858 | */ |
859 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
860 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
859 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
860 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | * where keys are always subsection names and values are either |
878 | 878 | * the input's normalized value, or an array like the top-level array |
879 | 879 | */ |
880 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
881 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
880 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
881 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -896,19 +896,19 @@ discard block |
||
896 | 896 | * where keys are always subsection names and values are either |
897 | 897 | * the input's normalized value, or an array like the top-level array |
898 | 898 | */ |
899 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
899 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
900 | 900 | $input_values = array(); |
901 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
902 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
903 | - $input_values[ $subsection_name ] = $pretty |
|
901 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
902 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
903 | + $input_values[$subsection_name] = $pretty |
|
904 | 904 | ? $subsection->pretty_value() |
905 | 905 | : $subsection->normalized_value(); |
906 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
907 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
908 | - if( $flatten ) { |
|
909 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
906 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
907 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
908 | + if ($flatten) { |
|
909 | + $input_values = array_merge($input_values, $subform_input_values); |
|
910 | 910 | } else { |
911 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
911 | + $input_values[$subsection_name] = $subform_input_values; |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | } |
@@ -929,23 +929,23 @@ discard block |
||
929 | 929 | * where keys are always subsection names and values are either |
930 | 930 | * the input's normalized value, or an array like the top-level array |
931 | 931 | */ |
932 | - public function submitted_values( $include_subforms = false ) { |
|
932 | + public function submitted_values($include_subforms = false) { |
|
933 | 933 | $submitted_values = array(); |
934 | - foreach( $this->subsections() as $subsection ) { |
|
935 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
934 | + foreach ($this->subsections() as $subsection) { |
|
935 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
936 | 936 | // is this input part of an array of inputs? |
937 | - if ( strpos( $subsection->html_name(), '[' ) !== false ) { |
|
937 | + if (strpos($subsection->html_name(), '[') !== false) { |
|
938 | 938 | $full_input_name = \EEH_Array::convert_array_values_to_keys( |
939 | - explode( '[', str_replace( ']', '', $subsection->html_name() ) ), |
|
939 | + explode('[', str_replace(']', '', $subsection->html_name())), |
|
940 | 940 | $subsection->raw_value() |
941 | 941 | ); |
942 | - $submitted_values = array_replace_recursive( $submitted_values, $full_input_name ); |
|
942 | + $submitted_values = array_replace_recursive($submitted_values, $full_input_name); |
|
943 | 943 | } else { |
944 | - $submitted_values[ $subsection->html_name() ] = $subsection->raw_value(); |
|
944 | + $submitted_values[$subsection->html_name()] = $subsection->raw_value(); |
|
945 | 945 | } |
946 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subforms ) { |
|
947 | - $subform_input_values = $subsection->submitted_values( $include_subforms ); |
|
948 | - $submitted_values = array_replace_recursive( $submitted_values, $subform_input_values ); |
|
946 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) { |
|
947 | + $subform_input_values = $subsection->submitted_values($include_subforms); |
|
948 | + $submitted_values = array_replace_recursive($submitted_values, $subform_input_values); |
|
949 | 949 | } |
950 | 950 | } |
951 | 951 | return $submitted_values; |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | * @return boolean |
961 | 961 | * @throws \EE_Error |
962 | 962 | */ |
963 | - public function has_received_submission(){ |
|
963 | + public function has_received_submission() { |
|
964 | 964 | $this->ensure_construct_finalized_called(); |
965 | 965 | return $this->_received_submission; |
966 | 966 | } |
@@ -973,8 +973,8 @@ discard block |
||
973 | 973 | * @param array $inputs_to_exclude values are the input names |
974 | 974 | * @return void |
975 | 975 | */ |
976 | - public function exclude($inputs_to_exclude = array()){ |
|
977 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
976 | + public function exclude($inputs_to_exclude = array()) { |
|
977 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
978 | 978 | unset($this->_subsections[$input_to_exclude_name]); |
979 | 979 | } |
980 | 980 | } |
@@ -985,8 +985,8 @@ discard block |
||
985 | 985 | * @param array $inputs_to_hide |
986 | 986 | * @throws \EE_Error |
987 | 987 | */ |
988 | - public function hide($inputs_to_hide= array()){ |
|
989 | - foreach($inputs_to_hide as $input_to_hide){ |
|
988 | + public function hide($inputs_to_hide = array()) { |
|
989 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
990 | 990 | $input = $this->get_input($input_to_hide); |
991 | 991 | |
992 | 992 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -1016,21 +1016,21 @@ discard block |
||
1016 | 1016 | * @return void |
1017 | 1017 | * @throws \EE_Error |
1018 | 1018 | */ |
1019 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
1020 | - foreach( $new_subsections as $subsection_name => $subsection ){ |
|
1021 | - if( ! $subsection instanceof EE_Form_Section_Base ){ |
|
1019 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
1020 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
1021 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
1022 | 1022 | EE_Error::add_error( |
1023 | 1023 | sprintf( |
1024 | 1024 | __( |
1025 | 1025 | "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", |
1026 | 1026 | "event_espresso" |
1027 | 1027 | ), |
1028 | - get_class( $subsection ), |
|
1028 | + get_class($subsection), |
|
1029 | 1029 | $subsection_name, |
1030 | 1030 | $this->name() |
1031 | 1031 | ) |
1032 | 1032 | ); |
1033 | - unset( $new_subsections[ $subsection_name ] ); |
|
1033 | + unset($new_subsections[$subsection_name]); |
|
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | $this->_subsections = EEH_Array::insert_into_array( |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | ); |
1042 | 1042 | |
1043 | 1043 | |
1044 | - if( $this->_construction_finalized ){ |
|
1045 | - foreach($this->_subsections as $name => $subsection){ |
|
1044 | + if ($this->_construction_finalized) { |
|
1045 | + foreach ($this->_subsections as $name => $subsection) { |
|
1046 | 1046 | $subsection->_construct_finalize($this, $name); |
1047 | 1047 | } |
1048 | 1048 | } |
@@ -1053,8 +1053,8 @@ discard block |
||
1053 | 1053 | /** |
1054 | 1054 | * Just gets all validatable subsections to clean their sensitive data |
1055 | 1055 | */ |
1056 | - public function clean_sensitive_data(){ |
|
1057 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
1056 | + public function clean_sensitive_data() { |
|
1057 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1058 | 1058 | $subsection->clean_sensitive_data(); |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1064,10 +1064,10 @@ discard block |
||
1064 | 1064 | /** |
1065 | 1065 | * @param string $form_submission_error_message |
1066 | 1066 | */ |
1067 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
1068 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) |
|
1067 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
1068 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) |
|
1069 | 1069 | ? $form_submission_error_message |
1070 | - : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
1070 | + : __('Form submission failed due to errors', 'event_espresso'); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | |
@@ -1084,10 +1084,10 @@ discard block |
||
1084 | 1084 | /** |
1085 | 1085 | * @param string $form_submission_success_message |
1086 | 1086 | */ |
1087 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
1088 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) |
|
1087 | + public function set_submission_success_message($form_submission_success_message) { |
|
1088 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) |
|
1089 | 1089 | ? $form_submission_success_message |
1090 | - : __( 'Form submitted successfully', 'event_espresso' ); |
|
1090 | + : __('Form submitted successfully', 'event_espresso'); |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | |
@@ -1110,10 +1110,10 @@ discard block |
||
1110 | 1110 | * @return string |
1111 | 1111 | * @throws \EE_Error |
1112 | 1112 | */ |
1113 | - public function html_name_prefix(){ |
|
1114 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
1115 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
1116 | - }else{ |
|
1113 | + public function html_name_prefix() { |
|
1114 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
1115 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
1116 | + } else { |
|
1117 | 1117 | return $this->name(); |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | * @return string |
1129 | 1129 | * @throws \EE_Error |
1130 | 1130 | */ |
1131 | - public function name(){ |
|
1131 | + public function name() { |
|
1132 | 1132 | $this->ensure_construct_finalized_called(); |
1133 | 1133 | return parent::name(); |
1134 | 1134 | } |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | * @return EE_Form_Section_Proper |
1140 | 1140 | * @throws \EE_Error |
1141 | 1141 | */ |
1142 | - public function parent_section(){ |
|
1142 | + public function parent_section() { |
|
1143 | 1143 | $this->ensure_construct_finalized_called(); |
1144 | 1144 | return parent::parent_section(); |
1145 | 1145 | } |
@@ -1152,9 +1152,9 @@ discard block |
||
1152 | 1152 | * @return void |
1153 | 1153 | * @throws \EE_Error |
1154 | 1154 | */ |
1155 | - public function ensure_construct_finalized_called(){ |
|
1156 | - if( ! $this->_construction_finalized ){ |
|
1157 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
1155 | + public function ensure_construct_finalized_called() { |
|
1156 | + if ( ! $this->_construction_finalized) { |
|
1157 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
1158 | 1158 | } |
1159 | 1159 | } |
1160 | 1160 | |
@@ -1166,17 +1166,17 @@ discard block |
||
1166 | 1166 | * @param array $req_data |
1167 | 1167 | * @return boolean |
1168 | 1168 | */ |
1169 | - public function form_data_present_in( $req_data = NULL ) { |
|
1170 | - if( $req_data === NULL){ |
|
1169 | + public function form_data_present_in($req_data = NULL) { |
|
1170 | + if ($req_data === NULL) { |
|
1171 | 1171 | $req_data = $_POST; |
1172 | 1172 | } |
1173 | - foreach( $this->subsections() as $subsection ) { |
|
1174 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
1175 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
1173 | + foreach ($this->subsections() as $subsection) { |
|
1174 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
1175 | + if ($subsection->form_data_present_in($req_data)) { |
|
1176 | 1176 | return TRUE; |
1177 | 1177 | } |
1178 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
1179 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
1178 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
1179 | + if ($subsection->form_data_present_in($req_data)) { |
|
1180 | 1180 | return TRUE; |
1181 | 1181 | } |
1182 | 1182 | } |
@@ -1193,14 +1193,14 @@ discard block |
||
1193 | 1193 | */ |
1194 | 1194 | public function get_validation_errors_accumulated() { |
1195 | 1195 | $validation_errors = $this->get_validation_errors(); |
1196 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
1197 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
1196 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1197 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
1198 | 1198 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
1199 | 1199 | } else { |
1200 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1200 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1201 | 1201 | } |
1202 | - if( $validation_errors_on_this_subsection ){ |
|
1203 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
1202 | + if ($validation_errors_on_this_subsection) { |
|
1203 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
1204 | 1204 | } |
1205 | 1205 | } |
1206 | 1206 | return $validation_errors; |
@@ -1222,24 +1222,24 @@ discard block |
||
1222 | 1222 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
1223 | 1223 | * @return EE_Form_Section_Base |
1224 | 1224 | */ |
1225 | - public function find_section_from_path( $form_section_path ) { |
|
1225 | + public function find_section_from_path($form_section_path) { |
|
1226 | 1226 | //check if we can find the input from purely going straight up the tree |
1227 | - $input = parent::find_section_from_path( $form_section_path ); |
|
1228 | - if( $input instanceof EE_Form_Section_Base ) { |
|
1227 | + $input = parent::find_section_from_path($form_section_path); |
|
1228 | + if ($input instanceof EE_Form_Section_Base) { |
|
1229 | 1229 | return $input; |
1230 | 1230 | } |
1231 | 1231 | |
1232 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
1233 | - if( $next_slash_pos !== false ) { |
|
1234 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
1235 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
1232 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
1233 | + if ($next_slash_pos !== false) { |
|
1234 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
1235 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
1236 | 1236 | } else { |
1237 | 1237 | $child_section_name = $form_section_path; |
1238 | 1238 | $subpath = ''; |
1239 | 1239 | } |
1240 | - $child_section = $this->get_subsection( $child_section_name ); |
|
1241 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
1242 | - return $child_section->find_section_from_path( $subpath ); |
|
1240 | + $child_section = $this->get_subsection($child_section_name); |
|
1241 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
1242 | + return $child_section->find_section_from_path($subpath); |
|
1243 | 1243 | } else { |
1244 | 1244 | return null; |
1245 | 1245 | } |