@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @subpackage |
| 8 | 8 | * @author Mike Nelson |
| 9 | 9 | */ |
| 10 | -class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base{ |
|
| 10 | +class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * array of available options to choose as an answer |
@@ -53,18 +53,18 @@ discard block |
||
| 53 | 53 | * @param array $answer_options |
| 54 | 54 | * @param array $input_settings |
| 55 | 55 | */ |
| 56 | - public function __construct( $answer_options = array(), $input_settings = array() ) { |
|
| 57 | - if ( isset( $input_settings['label_size'] )) { |
|
| 58 | - $this->_set_label_size( $input_settings['label_size'] ); |
|
| 59 | - if ( isset( $input_settings['enforce_label_size'] ) && $input_settings['enforce_label_size'] ) { |
|
| 56 | + public function __construct($answer_options = array(), $input_settings = array()) { |
|
| 57 | + if (isset($input_settings['label_size'])) { |
|
| 58 | + $this->_set_label_size($input_settings['label_size']); |
|
| 59 | + if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) { |
|
| 60 | 60 | $this->_enforce_label_size = TRUE; |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | - if ( isset( $input_settings['display_html_label_text'] )) { |
|
| 64 | - $this->set_display_html_label_text( $input_settings['display_html_label_text'] ); |
|
| 63 | + if (isset($input_settings['display_html_label_text'])) { |
|
| 64 | + $this->set_display_html_label_text($input_settings['display_html_label_text']); |
|
| 65 | 65 | } |
| 66 | - $this->set_select_options( $answer_options ); |
|
| 67 | - parent::__construct( $input_settings ); |
|
| 66 | + $this->set_select_options($answer_options); |
|
| 67 | + parent::__construct($input_settings); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -75,47 +75,47 @@ discard block |
||
| 75 | 75 | * @param array $answer_options |
| 76 | 76 | * @return void just has the side-effect of setting the options for this input |
| 77 | 77 | */ |
| 78 | - public function set_select_options( $answer_options = array() ){ |
|
| 79 | - $answer_options = is_array( $answer_options ) ? $answer_options : array( $answer_options ); |
|
| 78 | + public function set_select_options($answer_options = array()) { |
|
| 79 | + $answer_options = is_array($answer_options) ? $answer_options : array($answer_options); |
|
| 80 | 80 | //get the first item in the select options and check it's type |
| 81 | - if ( reset( $answer_options ) instanceof EE_Question_Option ) { |
|
| 82 | - $this->_options = $this->_process_question_options( $answer_options ); |
|
| 81 | + if (reset($answer_options) instanceof EE_Question_Option) { |
|
| 82 | + $this->_options = $this->_process_question_options($answer_options); |
|
| 83 | 83 | } else { |
| 84 | 84 | $this->_options = $answer_options; |
| 85 | 85 | } |
| 86 | 86 | //d( $this->_options ); |
| 87 | - $select_option_keys = array_keys( $this->_options ); |
|
| 87 | + $select_option_keys = array_keys($this->_options); |
|
| 88 | 88 | // attempt to determine data type for values in order to set normalization type |
| 89 | 89 | if ( |
| 90 | - count( $this->_options ) == 2 |
|
| 90 | + count($this->_options) == 2 |
|
| 91 | 91 | && |
| 92 | 92 | ( |
| 93 | - ( in_array( TRUE, $select_option_keys, true ) && in_array( FALSE, $select_option_keys, true )) |
|
| 94 | - || ( in_array( 1, $select_option_keys, true ) && in_array( 0, $select_option_keys, true )) |
|
| 93 | + (in_array(TRUE, $select_option_keys, true) && in_array(FALSE, $select_option_keys, true)) |
|
| 94 | + || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true)) |
|
| 95 | 95 | ) |
| 96 | - ){ |
|
| 96 | + ) { |
|
| 97 | 97 | // values appear to be boolean, like TRUE, FALSE, 1, 0 |
| 98 | 98 | $normalization = new EE_Boolean_Normalization(); |
| 99 | - } else{ |
|
| 99 | + } else { |
|
| 100 | 100 | //are ALL the options ints? If so use int validation |
| 101 | 101 | $all_ints = true; |
| 102 | - foreach($select_option_keys as $value ){ |
|
| 103 | - if( ! is_int( $value ) ){ |
|
| 102 | + foreach ($select_option_keys as $value) { |
|
| 103 | + if ( ! is_int($value)) { |
|
| 104 | 104 | $all_ints = false; |
| 105 | 105 | break; |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | - if( $all_ints ){ |
|
| 108 | + if ($all_ints) { |
|
| 109 | 109 | $normalization = new EE_Int_Normalization(); |
| 110 | - }else{ |
|
| 110 | + } else { |
|
| 111 | 111 | $normalization = new EE_Text_Normalization(); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | // does input type have multiple options ? |
| 115 | - if ( $this->_multiple_selections ) { |
|
| 116 | - $this->_set_normalization_strategy( new EE_Many_Valued_Normalization( $normalization )); |
|
| 115 | + if ($this->_multiple_selections) { |
|
| 116 | + $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization)); |
|
| 117 | 117 | } else { |
| 118 | - $this->_set_normalization_strategy( $normalization ); |
|
| 118 | + $this->_set_normalization_strategy($normalization); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * @return array |
| 126 | 126 | */ |
| 127 | - public function options(){ |
|
| 127 | + public function options() { |
|
| 128 | 128 | return $this->_options; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * Returns an array which is guaranteed to not be multidimensional |
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | - public function flat_options(){ |
|
| 137 | + public function flat_options() { |
|
| 138 | 138 | return $this->_flatten_select_options($this->options()); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -145,20 +145,20 @@ discard block |
||
| 145 | 145 | * @param array $arr |
| 146 | 146 | * @return array |
| 147 | 147 | */ |
| 148 | - protected function _flatten_select_options( $arr ){ |
|
| 148 | + protected function _flatten_select_options($arr) { |
|
| 149 | 149 | $flat_array = array(); |
| 150 | 150 | EE_Registry::instance()->load_helper('Array'); |
| 151 | - if ( EEH_Array::is_multi_dimensional_array( $arr )) { |
|
| 152 | - foreach( $arr as $sub_array ){ |
|
| 153 | - foreach( $sub_array as $key => $value ) { |
|
| 154 | - $flat_array[ $key ] = $value; |
|
| 155 | - $this->_set_label_size( $value ); |
|
| 151 | + if (EEH_Array::is_multi_dimensional_array($arr)) { |
|
| 152 | + foreach ($arr as $sub_array) { |
|
| 153 | + foreach ($sub_array as $key => $value) { |
|
| 154 | + $flat_array[$key] = $value; |
|
| 155 | + $this->_set_label_size($value); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } else { |
| 159 | - foreach( $arr as $key => $value ) { |
|
| 160 | - $flat_array[ $key ] = $value; |
|
| 161 | - $this->_set_label_size( $value ); |
|
| 159 | + foreach ($arr as $key => $value) { |
|
| 160 | + $flat_array[$key] = $value; |
|
| 161 | + $this->_set_label_size($value); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | return $flat_array; |
@@ -170,18 +170,18 @@ discard block |
||
| 170 | 170 | * @param EE_Question_Option[] $question_options_array |
| 171 | 171 | * @return array |
| 172 | 172 | */ |
| 173 | - protected function _process_question_options( $question_options_array = array() ) { |
|
| 173 | + protected function _process_question_options($question_options_array = array()) { |
|
| 174 | 174 | $flat_array = array(); |
| 175 | - foreach( $question_options_array as $question_option ) { |
|
| 176 | - if ( $question_option instanceof EE_Question_Option ) { |
|
| 175 | + foreach ($question_options_array as $question_option) { |
|
| 176 | + if ($question_option instanceof EE_Question_Option) { |
|
| 177 | 177 | $desc = ''; |
| 178 | - if ( $this->_use_desc_in_label ) { |
|
| 178 | + if ($this->_use_desc_in_label) { |
|
| 179 | 179 | $desc = $question_option->desc(); |
| 180 | - $desc = ! empty( $desc ) ? '<span class="ee-question-option-desc"> - ' . $desc . '</span>' : ''; |
|
| 180 | + $desc = ! empty($desc) ? '<span class="ee-question-option-desc"> - '.$desc.'</span>' : ''; |
|
| 181 | 181 | } |
| 182 | - $flat_array[ $question_option->value() ] = $question_option->value() . $desc; |
|
| 183 | - } elseif ( is_array( $question_option )) { |
|
| 184 | - $non_question_option = $this->_flatten_select_options( $question_option ); |
|
| 182 | + $flat_array[$question_option->value()] = $question_option->value().$desc; |
|
| 183 | + } elseif (is_array($question_option)) { |
|
| 184 | + $non_question_option = $this->_flatten_select_options($question_option); |
|
| 185 | 185 | $flat_array = $flat_array + $non_question_option; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | * set_label_sizes |
| 195 | 195 | * @return void |
| 196 | 196 | */ |
| 197 | - public function set_label_sizes(){ |
|
| 197 | + public function set_label_sizes() { |
|
| 198 | 198 | // did the input settings specifically say to NOT set the label size dynamically ? |
| 199 | - if ( ! $this->_enforce_label_size ) { |
|
| 200 | - foreach( $this->_options as $option ) { |
|
| 199 | + if ( ! $this->_enforce_label_size) { |
|
| 200 | + foreach ($this->_options as $option) { |
|
| 201 | 201 | // calculate the strlen of the label |
| 202 | - $this->_set_label_size( $option ); |
|
| 202 | + $this->_set_label_size($option); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | * @param int|string $value |
| 212 | 212 | * @return void |
| 213 | 213 | */ |
| 214 | - private function _set_label_size( $value = '' ){ |
|
| 214 | + private function _set_label_size($value = '') { |
|
| 215 | 215 | // determine length of option value |
| 216 | - $val_size = is_int( $value ) ? $value : strlen( $value ); |
|
| 216 | + $val_size = is_int($value) ? $value : strlen($value); |
|
| 217 | 217 | // use new value if bigger than existing |
| 218 | 218 | $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size; |
| 219 | 219 | } |
@@ -224,22 +224,22 @@ discard block |
||
| 224 | 224 | * get_label_size_class |
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | - function get_label_size_class(){ |
|
| 227 | + function get_label_size_class() { |
|
| 228 | 228 | // use maximum option value length to determine label size |
| 229 | - if( $this->_label_size < 3 ) { |
|
| 229 | + if ($this->_label_size < 3) { |
|
| 230 | 230 | $size = ' nano-lbl'; |
| 231 | - } else if ( $this->_label_size < 6 ) { |
|
| 232 | - $size = ' micro-lbl'; |
|
| 233 | - } else if ( $this->_label_size < 12 ) { |
|
| 234 | - $size = ' tiny-lbl'; |
|
| 235 | - } else if ( $this->_label_size < 25 ) { |
|
| 236 | - $size = ' small-lbl'; |
|
| 237 | - } else if ( $this->_label_size < 50 ) { |
|
| 238 | - $size = ' medium-lbl'; |
|
| 239 | - } else if ( $this->_label_size >= 100 ) { |
|
| 240 | - $size = ' big-lbl'; |
|
| 231 | + } else if ($this->_label_size < 6) { |
|
| 232 | + $size = ' micro-lbl'; |
|
| 233 | + } else if ($this->_label_size < 12) { |
|
| 234 | + $size = ' tiny-lbl'; |
|
| 235 | + } else if ($this->_label_size < 25) { |
|
| 236 | + $size = ' small-lbl'; |
|
| 237 | + } else if ($this->_label_size < 50) { |
|
| 238 | + $size = ' medium-lbl'; |
|
| 239 | + } else if ($this->_label_size >= 100) { |
|
| 240 | + $size = ' big-lbl'; |
|
| 241 | 241 | } else { |
| 242 | - $size = ' medium-lbl'; |
|
| 242 | + $size = ' medium-lbl'; |
|
| 243 | 243 | } |
| 244 | 244 | return $size; |
| 245 | 245 | } |
@@ -248,21 +248,21 @@ discard block |
||
| 248 | 248 | * Returns the pretty value for the normalized value |
| 249 | 249 | * @return string |
| 250 | 250 | */ |
| 251 | - function pretty_value(){ |
|
| 251 | + function pretty_value() { |
|
| 252 | 252 | $options = $this->flat_options(); |
| 253 | - $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize( $this->_normalized_value ); |
|
| 254 | - if( ! $this->_multiple_selections ){ |
|
| 255 | - $unnormalized_value_choices = array( $unnormalized_value_choices ); |
|
| 253 | + $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value); |
|
| 254 | + if ( ! $this->_multiple_selections) { |
|
| 255 | + $unnormalized_value_choices = array($unnormalized_value_choices); |
|
| 256 | 256 | } |
| 257 | 257 | $pretty_strings = array(); |
| 258 | - foreach( $unnormalized_value_choices as $unnormalized_value_choice ){ |
|
| 259 | - if( isset( $options[ $unnormalized_value_choice ] ) ){ |
|
| 260 | - $pretty_strings[] = $options[ $unnormalized_value_choice ]; |
|
| 261 | - }else{ |
|
| 258 | + foreach ($unnormalized_value_choices as $unnormalized_value_choice) { |
|
| 259 | + if (isset($options[$unnormalized_value_choice])) { |
|
| 260 | + $pretty_strings[] = $options[$unnormalized_value_choice]; |
|
| 261 | + } else { |
|
| 262 | 262 | $pretty_strings[] = $this->normalized_value(); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | - return implode(", ", $pretty_strings ); |
|
| 265 | + return implode(", ", $pretty_strings); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @param boolean $display_html_label_text |
| 281 | 281 | */ |
| 282 | - public function set_display_html_label_text( $display_html_label_text ) { |
|
| 283 | - $this->_display_html_label_text = filter_var( $display_html_label_text, FILTER_VALIDATE_BOOLEAN ); |
|
| 282 | + public function set_display_html_label_text($display_html_label_text) { |
|
| 283 | + $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | foreach( $answer_options as $model_obj ){ |
| 53 | 53 | if( $this->_naming_method ){ |
| 54 | 54 | $display_value = call_user_func( array( $model_obj, $this->_naming_method )); |
| 55 | - }else{ |
|
| 55 | + } else{ |
|
| 56 | 56 | $display_value = $model_obj->name(); |
| 57 | 57 | } |
| 58 | 58 | $select_options[ $model_obj->ID() ] = $display_value; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | foreach($values as $key => $value){ |
| 73 | 73 | if($value instanceof EE_Base_Class){ |
| 74 | 74 | $defaults_as_simple_ids[] = $value->ID(); |
| 75 | - }else{ |
|
| 75 | + } else{ |
|
| 76 | 76 | $defaults_as_simple_ids[] = $value; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -6,20 +6,20 @@ |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Hidden_Input extends EE_Form_Input_Base{ |
|
| 9 | +class EE_Hidden_Input extends EE_Form_Input_Base { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param array $input_settings |
| 13 | 13 | */ |
| 14 | - function __construct($input_settings = array()){ |
|
| 14 | + function __construct($input_settings = array()) { |
|
| 15 | 15 | //require_once('strategies/display_strategies/EE_Text_Input_Display_Strategy.strategy.php'); |
| 16 | 16 | $this->_set_display_strategy(new EE_Hidden_Display_Strategy()); |
| 17 | - if ( isset( $input_settings['normalization_strategy'] ) && $input_settings['normalization_strategy'] instanceof EE_Normalization_Strategy_Base ) { |
|
| 18 | - $this->_set_normalization_strategy( $input_settings['normalization_strategy'] ); |
|
| 17 | + if (isset($input_settings['normalization_strategy']) && $input_settings['normalization_strategy'] instanceof EE_Normalization_Strategy_Base) { |
|
| 18 | + $this->_set_normalization_strategy($input_settings['normalization_strategy']); |
|
| 19 | 19 | } else { |
| 20 | - $this->_set_normalization_strategy( new EE_Text_Normalization() ); |
|
| 20 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 21 | 21 | } |
| 22 | - parent::__construct( $input_settings ); |
|
| 22 | + parent::__construct($input_settings); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -6,14 +6,14 @@ discard block |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Month_Input extends EE_Select_Input{ |
|
| 9 | +class EE_Month_Input extends EE_Select_Input { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param bool $leading_zero |
| 13 | 13 | * @param array $input_settings |
| 14 | 14 | */ |
| 15 | - function __construct( $leading_zero = false, $input_settings = array()){ |
|
| 16 | - if($leading_zero){ |
|
| 15 | + function __construct($leading_zero = false, $input_settings = array()) { |
|
| 16 | + if ($leading_zero) { |
|
| 17 | 17 | $select_options = array( |
| 18 | 18 | '01'=>'01', |
| 19 | 19 | '02'=>'02', |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | '11'=>'11', |
| 29 | 29 | '12'=>'12' |
| 30 | 30 | ); |
| 31 | - }else{ |
|
| 31 | + } else { |
|
| 32 | 32 | $select_options = array( |
| 33 | 33 | 1=>'01', |
| 34 | 34 | 2=>'02', |
@@ -44,6 +44,6 @@ discard block |
||
| 44 | 44 | 12=>'12' |
| 45 | 45 | ); |
| 46 | 46 | } |
| 47 | - parent::__construct($select_options,$input_settings); |
|
| 47 | + parent::__construct($select_options, $input_settings); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
| 91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
| 92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
| 93 | - }else{ |
|
| 93 | + } else{ |
|
| 94 | 94 | return parent::finalize_payment_for( $transaction ); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -6,17 +6,17 @@ |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Password_Input extends EE_Form_Input_Base{ |
|
| 9 | +class EE_Password_Input extends EE_Form_Input_Base { |
|
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @param array $input_settings |
| 14 | 14 | */ |
| 15 | - function __construct($input_settings = array()){ |
|
| 15 | + function __construct($input_settings = array()) { |
|
| 16 | 16 | $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('password')); |
| 17 | 17 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
| 18 | 18 | parent::__construct($input_settings); |
| 19 | - $this->set_html_class( $this->html_class() . 'password' ); |
|
| 19 | + $this->set_html_class($this->html_class().'password'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -15,13 +15,13 @@ discard block |
||
| 15 | 15 | * @author Mike Nelson |
| 16 | 16 | * |
| 17 | 17 | */ |
| 18 | -class EE_Phone_Input extends EE_Text_Input{ |
|
| 18 | +class EE_Phone_Input extends EE_Text_Input { |
|
| 19 | 19 | /** |
| 20 | 20 | * @param array $options |
| 21 | 21 | */ |
| 22 | - function __construct($options = array()){ |
|
| 23 | - $this->_add_validation_strategy( new EE_Text_Validation_Strategy( __( 'Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso' ), '~^([\d]{10})|([\d]{3}-[\d]{3}-[\d]{4})$~')); |
|
| 24 | - parent::__construct( $options ); |
|
| 22 | + function __construct($options = array()) { |
|
| 23 | + $this->_add_validation_strategy(new EE_Text_Validation_Strategy(__('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'), '~^([\d]{10})|([\d]{3}-[\d]{3}-[\d]{4})$~')); |
|
| 24 | + parent::__construct($options); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 2 | 2 | /** |
| 3 | 3 | * |
| 4 | 4 | * Class EE_Radio_Button_Input |
@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | * @since $VID:$ |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Radio_Button_Input extends EE_Form_Input_With_Options_Base{ |
|
| 14 | +class EE_Radio_Button_Input extends EE_Form_Input_With_Options_Base { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * @param array $answer_options |
| 18 | 18 | * @param array $input_settings |
| 19 | 19 | */ |
| 20 | - function __construct( $answer_options, $input_settings = array() ){ |
|
| 21 | - $this->_set_display_strategy( new EE_Radio_Button_Display_Strategy() ); |
|
| 22 | - $this->_add_validation_strategy( new EE_Enum_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
| 20 | + function __construct($answer_options, $input_settings = array()) { |
|
| 21 | + $this->_set_display_strategy(new EE_Radio_Button_Display_Strategy()); |
|
| 22 | + $this->_add_validation_strategy(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
| 23 | 23 | $this->_multiple_selections = FALSE; |
| 24 | - parent::__construct( $answer_options, $input_settings ); |
|
| 24 | + parent::__construct($answer_options, $input_settings); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 2 | 2 | /** |
| 3 | 3 | * Class EE_Select_Input |
| 4 | 4 | * |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | * @since 4.6 |
| 11 | 11 | * |
| 12 | 12 | */ |
| 13 | -class EE_Select_Input extends EE_Form_Input_With_Options_Base{ |
|
| 13 | +class EE_Select_Input extends EE_Form_Input_With_Options_Base { |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param array $answer_options |
| 17 | 17 | * @param array $input_settings |
| 18 | 18 | */ |
| 19 | - function __construct( $answer_options, $input_settings = array() ){ |
|
| 20 | - $this->_set_display_strategy( new EE_Select_Display_Strategy( $answer_options )); |
|
| 21 | - $this->_add_validation_strategy( new EE_Enum_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
| 22 | - parent::__construct( $answer_options, $input_settings ); |
|
| 19 | + function __construct($answer_options, $input_settings = array()) { |
|
| 20 | + $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
| 21 | + $this->_add_validation_strategy(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
| 22 | + parent::__construct($answer_options, $input_settings); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @subpackage |
| 9 | 9 | * @author Mike Nelson |
| 10 | 10 | */ |
| 11 | -class EE_Select_Multi_Model_Input extends EE_Select_Multiple_Input{ |
|
| 11 | +class EE_Select_Multi_Model_Input extends EE_Select_Multiple_Input { |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | protected $_naming_method; |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
| 25 | 25 | * } |
| 26 | 26 | */ |
| 27 | - public function __construct( $answer_options = array(), $input_settings = array() ) { |
|
| 28 | - if( isset( $input_settings['naming_method'] )){ |
|
| 29 | - $this->set_option_naming_method( $input_settings['naming_method'] ); |
|
| 27 | + public function __construct($answer_options = array(), $input_settings = array()) { |
|
| 28 | + if (isset($input_settings['naming_method'])) { |
|
| 29 | + $this->set_option_naming_method($input_settings['naming_method']); |
|
| 30 | 30 | } |
| 31 | - parent::__construct( $answer_options, $input_settings ); |
|
| 31 | + parent::__construct($answer_options, $input_settings); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Sets the method name which will be called when outputting the options list |
| 36 | 36 | * @param string $method |
| 37 | 37 | */ |
| 38 | - public function set_option_naming_method($method){ |
|
| 38 | + public function set_option_naming_method($method) { |
|
| 39 | 39 | $this->_naming_method = $method; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | * @param EE_Base_Class[] $answer_options |
| 47 | 47 | * @return null|void |
| 48 | 48 | */ |
| 49 | - public function set_select_options( $answer_options = array() ) { |
|
| 49 | + public function set_select_options($answer_options = array()) { |
|
| 50 | 50 | //convert the model objects to select from into normal select options |
| 51 | 51 | $select_options = array(); |
| 52 | - foreach( $answer_options as $model_obj ){ |
|
| 53 | - if( $this->_naming_method ){ |
|
| 54 | - $display_value = call_user_func( array( $model_obj, $this->_naming_method )); |
|
| 55 | - }else{ |
|
| 52 | + foreach ($answer_options as $model_obj) { |
|
| 53 | + if ($this->_naming_method) { |
|
| 54 | + $display_value = call_user_func(array($model_obj, $this->_naming_method)); |
|
| 55 | + } else { |
|
| 56 | 56 | $display_value = $model_obj->name(); |
| 57 | 57 | } |
| 58 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
| 58 | + $select_options[$model_obj->ID()] = $display_value; |
|
| 59 | 59 | } |
| 60 | 60 | parent::set_select_options($select_options); |
| 61 | 61 | } |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | * into the format EE_Select_Multiple expects |
| 68 | 68 | * @param EE_Base_Class[]|array $values |
| 69 | 69 | */ |
| 70 | - public function set_default($values){ |
|
| 70 | + public function set_default($values) { |
|
| 71 | 71 | $defaults_as_simple_ids = array(); |
| 72 | - foreach($values as $key => $value){ |
|
| 73 | - if($value instanceof EE_Base_Class){ |
|
| 72 | + foreach ($values as $key => $value) { |
|
| 73 | + if ($value instanceof EE_Base_Class) { |
|
| 74 | 74 | $defaults_as_simple_ids[] = $value->ID(); |
| 75 | - }else{ |
|
| 75 | + } else { |
|
| 76 | 76 | $defaults_as_simple_ids[] = $value; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | foreach( $answer_options as $model_obj ){ |
| 53 | 53 | if( $this->_naming_method ){ |
| 54 | 54 | $display_value = call_user_func( array( $model_obj, $this->_naming_method )); |
| 55 | - }else{ |
|
| 55 | + } else{ |
|
| 56 | 56 | $display_value = $model_obj->name(); |
| 57 | 57 | } |
| 58 | 58 | $select_options[ $model_obj->ID() ] = $display_value; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | foreach($values as $key => $value){ |
| 73 | 73 | if($value instanceof EE_Base_Class){ |
| 74 | 74 | $defaults_as_simple_ids[] = $value->ID(); |
| 75 | - }else{ |
|
| 75 | + } else{ |
|
| 76 | 76 | $defaults_as_simple_ids[] = $value; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -6,17 +6,17 @@ |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base{ |
|
| 9 | +class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param array | EE_Question_Option[] $answer_options |
| 13 | 13 | * @param array $input_settings |
| 14 | 14 | */ |
| 15 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
| 16 | - $this->_set_display_strategy( new EE_Select_Multiple_Display_Strategy() ); |
|
| 17 | - $this->_add_validation_strategy( new EE_Many_Valued_Validation_Strategy( array( new EE_Enum_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ))); |
|
| 15 | + public function __construct($answer_options, $input_settings = array()) { |
|
| 16 | + $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
| 17 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)))); |
|
| 18 | 18 | $this->_multiple_selections = TRUE; |
| 19 | - parent::__construct( $answer_options, $input_settings ); |
|
| 19 | + parent::__construct($answer_options, $input_settings); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | } |