@@ -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_Checkbox_Multi_Input |
@@ -11,16 +11,16 @@ discard block |
||
| 11 | 11 | * @since $VID:$ |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base{ |
|
| 14 | +class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * @param array $input_settings |
| 18 | 18 | * @param array | EE_Question_Option[] $answer_options |
| 19 | 19 | */ |
| 20 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
| 21 | - $this->_set_display_strategy( new EE_Checkbox_Display_Strategy() ); |
|
| 22 | - $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 ) ))); |
|
| 20 | + public function __construct($answer_options, $input_settings = array()) { |
|
| 21 | + $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
| 22 | + $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)))); |
|
| 23 | 23 | $this->_multiple_selections = TRUE; |
| 24 | - parent::__construct( $answer_options, $input_settings ); |
|
| 24 | + parent::__construct($answer_options, $input_settings); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | \ 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_Country_Select_Input |
| 4 | 4 | * |
@@ -11,20 +11,20 @@ discard block |
||
| 11 | 11 | * @since $VID:$ |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Country_Select_Input extends EE_Select_Input{ |
|
| 14 | +class EE_Country_Select_Input extends EE_Select_Input { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * @param array $country_options |
| 18 | 18 | * @param array $input_settings |
| 19 | 19 | * @return EE_Country_Select_Input |
| 20 | 20 | */ |
| 21 | - public function __construct( $country_options = NULL, $input_settings = array() ){ |
|
| 21 | + public function __construct($country_options = NULL, $input_settings = array()) { |
|
| 22 | 22 | $country_options = apply_filters( |
| 23 | 23 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
| 24 | - $this->get_country_answer_options( $country_options ), |
|
| 24 | + $this->get_country_answer_options($country_options), |
|
| 25 | 25 | $this |
| 26 | 26 | ); |
| 27 | - parent::__construct( $country_options, $input_settings ); |
|
| 27 | + parent::__construct($country_options, $input_settings); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | * @param array $country_options |
| 36 | 36 | * @return array |
| 37 | 37 | */ |
| 38 | - public function get_country_answer_options( $country_options = NULL ){ |
|
| 38 | + public function get_country_answer_options($country_options = NULL) { |
|
| 39 | 39 | // if passed something that is NOT an array |
| 40 | - if ( ! is_array( $country_options )) { |
|
| 40 | + if ( ! is_array($country_options)) { |
|
| 41 | 41 | // get possibly cached list of countries |
| 42 | 42 | $countries = EEM_Country::instance()->get_all_active_countries(); |
| 43 | - if ( ! empty( $countries )) { |
|
| 44 | - $country_options[ '' ] = ''; |
|
| 45 | - foreach( $countries as $country ){ |
|
| 46 | - if ( $country instanceof EE_Country ) { |
|
| 47 | - $country_options[ $country->ID() ] = $country->name(); |
|
| 43 | + if ( ! empty($countries)) { |
|
| 44 | + $country_options[''] = ''; |
|
| 45 | + foreach ($countries as $country) { |
|
| 46 | + if ($country instanceof EE_Country) { |
|
| 47 | + $country_options[$country->ID()] = $country->name(); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } else { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * ------------------------------------------------------------------------ |
| 26 | 26 | */ |
| 27 | -class EE_Credit_Card_Month_Input extends EE_Month_Input{ |
|
| 27 | +class EE_Credit_Card_Month_Input extends EE_Month_Input { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @param bool $leading_zero |
| 31 | 31 | * @param array $input_settings |
| 32 | 32 | */ |
| 33 | - function __construct( $leading_zero = false, $input_settings = array()){ |
|
| 34 | - $this->set_sensitive_data_removal_strategy( new EE_All_Sensitive_Data_Removal() ); |
|
| 35 | - parent::__construct($leading_zero,$input_settings); |
|
| 33 | + function __construct($leading_zero = false, $input_settings = array()) { |
|
| 34 | + $this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal()); |
|
| 35 | + parent::__construct($leading_zero, $input_settings); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | /** |
| 7 | 8 | * Event Espresso |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @subpackage |
| 10 | 10 | * @author Mike Nelson |
| 11 | 11 | */ |
| 12 | -class EE_Credit_Card_Year_Input extends EE_Year_Input{ |
|
| 12 | +class EE_Credit_Card_Year_Input extends EE_Year_Input { |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @param array $input_settings |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * @param int $years_behind |
| 18 | 18 | * @param int $years_ahead |
| 19 | 19 | */ |
| 20 | - function __construct( $input_settings = array(), $four_digit_year = true, $years_behind = 0, $years_ahead = 15 ){ |
|
| 21 | - $this->set_sensitive_data_removal_strategy( new EE_All_Sensitive_Data_Removal() ); |
|
| 22 | - parent::__construct( $input_settings, $four_digit_year, $years_behind, $years_ahead ); |
|
| 20 | + function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 0, $years_ahead = 15) { |
|
| 21 | + $this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal()); |
|
| 22 | + parent::__construct($input_settings, $four_digit_year, $years_behind, $years_ahead); |
|
| 23 | 23 | } |
| 24 | 24 | } |
@@ -1,6 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | +} |
|
| 4 | 5 | |
| 5 | 6 | /** |
| 6 | 7 | * EE_Credit_Card_Year_Input |
@@ -8,24 +8,24 @@ |
||
| 8 | 8 | * @author Mike Nelson |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_Currency_Input extends EE_Select_Input{ |
|
| 11 | +class EE_Currency_Input extends EE_Select_Input { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * |
| 15 | 15 | * @param array $only_specific_currency_codes numerically-indexed array of allowed currency codes. By default, all are allowed |
| 16 | 16 | * @param array $input_settings |
| 17 | 17 | */ |
| 18 | - function __construct( $only_specific_currency_codes = array(), $input_settings = array()){ |
|
| 18 | + function __construct($only_specific_currency_codes = array(), $input_settings = array()) { |
|
| 19 | 19 | $query_params = array('order_by'=>array('CNT_name'=>'asc')); |
| 20 | - if($only_specific_currency_codes){ |
|
| 21 | - $query_params[0]['CNT_cur_code'] = array('IN',$only_specific_currency_codes); |
|
| 20 | + if ($only_specific_currency_codes) { |
|
| 21 | + $query_params[0]['CNT_cur_code'] = array('IN', $only_specific_currency_codes); |
|
| 22 | 22 | } |
| 23 | 23 | $all_countries = EEM_Country::instance()->get_all($query_params); |
| 24 | 24 | $country_options = array(); |
| 25 | - foreach($all_countries as $country){ |
|
| 25 | + foreach ($all_countries as $country) { |
|
| 26 | 26 | /* @var $country EE_Country */ |
| 27 | - $country_options[$country->currency_code()] = $country->name().": ".$country->currency_name_single() ." (".$country->currency_sign().")"; |
|
| 27 | + $country_options[$country->currency_code()] = $country->name().": ".$country->currency_name_single()." (".$country->currency_sign().")"; |
|
| 28 | 28 | } |
| 29 | - parent::__construct($country_options,'int',$input_settings); |
|
| 29 | + parent::__construct($country_options, 'int', $input_settings); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -6,16 +6,16 @@ |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Email_Input extends EE_Form_Input_Base{ |
|
| 9 | +class EE_Email_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 | $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
| 16 | 16 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
| 17 | - $this->_add_validation_strategy(new EE_Email_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
| 17 | + $this->_add_validation_strategy(new EE_Email_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
| 18 | 18 | parent::__construct($input_settings); |
| 19 | - $this->set_html_class( $this->html_class() . ' email' ); |
|
| 19 | + $this->set_html_class($this->html_class().' email'); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Brent Christensen |
| 8 | 8 | */ |
| 9 | -class EE_Fixed_Hidden_Input extends EE_Hidden_Input{ |
|
| 9 | +class EE_Fixed_Hidden_Input extends EE_Hidden_Input { |
|
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param array $req_data like $_POST |
| 18 | 18 | * @return boolean whether or not there was an error |
| 19 | 19 | */ |
| 20 | - protected function _normalize( $req_data ) { |
|
| 20 | + protected function _normalize($req_data) { |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | if( ! $this->_html_name){ |
| 201 | 201 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
| 202 | 202 | $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
| 203 | - }else{ |
|
| 203 | + } else{ |
|
| 204 | 204 | $this->_html_name = $this->name(); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | protected function _get_display_strategy(){ |
| 231 | 231 | if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
| 232 | 232 | throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
| 233 | - }else{ |
|
| 233 | + } else{ |
|
| 234 | 234 | return $this->_display_strategy; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | public function get_validation_strategies(){ |
| 307 | 307 | if(is_array($this->_validation_strategies)){ |
| 308 | 308 | return $this->_validation_strategies; |
| 309 | - }else{ |
|
| 309 | + } else{ |
|
| 310 | 310 | return array(); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
| 414 | 414 | try{ |
| 415 | 415 | $validation_strategy->validate($this->normalized_value()); |
| 416 | - }catch(EE_Validation_Error $e){ |
|
| 416 | + } catch(EE_Validation_Error $e){ |
|
| 417 | 417 | $this->add_validation_error($e); |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | if( $this->get_validation_errors()){ |
| 423 | 423 | return false; |
| 424 | - }else{ |
|
| 424 | + } else{ |
|
| 425 | 425 | return true; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | if(! empty($jquery_validation_rules)){ |
| 604 | 604 | $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
| 605 | - }else{ |
|
| 605 | + } else{ |
|
| 606 | 606 | return array(); |
| 607 | 607 | } |
| 608 | 608 | return $jquery_validation_js; |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
| 770 | 770 | $name_parts = $matches[ 1 ]; |
| 771 | 771 | array_unshift($name_parts, $before_any_brackets); |
| 772 | - }else{ |
|
| 772 | + } else{ |
|
| 773 | 773 | $name_parts = array( $before_any_brackets ); |
| 774 | 774 | } |
| 775 | 775 | // now get the value for the input |
@@ -796,10 +796,10 @@ discard block |
||
| 796 | 796 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
| 797 | 797 | if( empty($html_name_parts ) ){ |
| 798 | 798 | return $req_data[ $first_part_to_consider ]; |
| 799 | - }else{ |
|
| 799 | + } else{ |
|
| 800 | 800 | return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
| 801 | 801 | } |
| 802 | - }else{ |
|
| 802 | + } else{ |
|
| 803 | 803 | return NULL; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
| 819 | 819 | if( $checked_value !== null ){ |
| 820 | 820 | return TRUE; |
| 821 | - }else{ |
|
| 821 | + } else{ |
|
| 822 | 822 | return FALSE; |
| 823 | 823 | } |
| 824 | 824 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @subpackage |
| 9 | 9 | * @author Mike Nelson |
| 10 | 10 | */ |
| 11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
| 11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * the input's name attribute |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
| 142 | 142 | * } |
| 143 | 143 | */ |
| 144 | - public function __construct( $input_args = array() ){ |
|
| 144 | + public function __construct($input_args = array()) { |
|
| 145 | 145 | // the following properties must be cast as arrays |
| 146 | 146 | $set_as_array = array( |
| 147 | 147 | 'display_strategy', |
@@ -150,60 +150,60 @@ discard block |
||
| 150 | 150 | 'validation_strategies' |
| 151 | 151 | ); |
| 152 | 152 | // loop thru incoming options |
| 153 | - foreach( $input_args as $key => $value ) { |
|
| 153 | + foreach ($input_args as $key => $value) { |
|
| 154 | 154 | // add underscore to $key to match property names |
| 155 | - $_key = '_' . $key; |
|
| 156 | - if ( property_exists( $this, $_key )) { |
|
| 155 | + $_key = '_'.$key; |
|
| 156 | + if (property_exists($this, $_key)) { |
|
| 157 | 157 | // first check if this property needs to be set as an array |
| 158 | - if ( isset( $set_as_array[ $key ] )) { |
|
| 158 | + if (isset($set_as_array[$key])) { |
|
| 159 | 159 | // ensure value is an array |
| 160 | - $value = is_array( $value ) ? $value : array( $value ); |
|
| 160 | + $value = is_array($value) ? $value : array($value); |
|
| 161 | 161 | // and merge with existing values |
| 162 | - $this->$_key = array_merge( $this->$_key, $value ); |
|
| 162 | + $this->$_key = array_merge($this->$_key, $value); |
|
| 163 | 163 | } else { |
| 164 | 164 | $this->$_key = $value; |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | // ensure that "required" is set correctly |
| 169 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
| 169 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
| 170 | 170 | |
| 171 | - $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
| 171 | + $this->_html_name_specified = isset($input_args['html_name']) ? TRUE : FALSE; |
|
| 172 | 172 | |
| 173 | 173 | $this->_display_strategy->_construct_finalize($this); |
| 174 | 174 | |
| 175 | - if ( $this->_validation_strategies ){ |
|
| 176 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
| 175 | + if ($this->_validation_strategies) { |
|
| 176 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 177 | 177 | $validation_strategy->_construct_finalize($this); |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if( ! $this->_normalization_strategy){ |
|
| 181 | + if ( ! $this->_normalization_strategy) { |
|
| 182 | 182 | $this->_normalization_strategy = new EE_Text_Normalization(); |
| 183 | 183 | } |
| 184 | 184 | $this->_normalization_strategy->_construct_finalize($this); |
| 185 | 185 | |
| 186 | 186 | //at least we can use the normalization strategy to populate the default |
| 187 | - if( isset( $input_args[ 'default' ] ) ) { |
|
| 188 | - $this->set_default( $input_args[ 'default' ] ); |
|
| 187 | + if (isset($input_args['default'])) { |
|
| 188 | + $this->set_default($input_args['default']); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
| 191 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
| 192 | 192 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
| 193 | 193 | } |
| 194 | 194 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
| 195 | - parent::__construct( $input_args ); |
|
| 195 | + parent::__construct($input_args); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | 199 | * Sets the html_name to its default value, if none was specified in teh constructor. |
| 200 | 200 | * Calculation involves using the name and the parent's html_name |
| 201 | 201 | */ |
| 202 | - protected function _set_default_html_name_if_empty(){ |
|
| 203 | - if( ! $this->_html_name){ |
|
| 204 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
| 205 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
| 206 | - }else{ |
|
| 202 | + protected function _set_default_html_name_if_empty() { |
|
| 203 | + if ( ! $this->_html_name) { |
|
| 204 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 205 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
| 206 | + } else { |
|
| 207 | 207 | $this->_html_name = $this->name(); |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | function _construct_finalize($parent_form_section, $name) { |
| 219 | 219 | parent::_construct_finalize($parent_form_section, $name); |
| 220 | 220 | $this->_set_default_html_name_if_empty(); |
| 221 | - if( ! $this->_html_label ){ |
|
| 222 | - if( ! $this->_html_label_text){ |
|
| 223 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
| 221 | + if ( ! $this->_html_label) { |
|
| 222 | + if ( ! $this->_html_label_text) { |
|
| 223 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | * @return EE_Display_Strategy_Base |
| 231 | 231 | * @throws EE_Error |
| 232 | 232 | */ |
| 233 | - protected function _get_display_strategy(){ |
|
| 234 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
| 235 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
| 236 | - }else{ |
|
| 233 | + protected function _get_display_strategy() { |
|
| 234 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
| 235 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
| 236 | + } else { |
|
| 237 | 237 | return $this->_display_strategy; |
| 238 | 238 | } |
| 239 | 239 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * Sets the display strategy. |
| 242 | 242 | * @param EE_Display_Strategy_Base $strategy |
| 243 | 243 | */ |
| 244 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
| 244 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
| 245 | 245 | $this->_display_strategy = $strategy; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * Sets the sanitization strategy |
| 250 | 250 | * @param EE_Normalization_Strategy_Base $strategy |
| 251 | 251 | */ |
| 252 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
| 252 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
| 253 | 253 | $this->_normalization_strategy = $strategy; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -275,14 +275,14 @@ discard block |
||
| 275 | 275 | * Gets the display strategy for this input |
| 276 | 276 | * @return EE_Display_Strategy_Base |
| 277 | 277 | */ |
| 278 | - public function get_display_strategy(){ |
|
| 278 | + public function get_display_strategy() { |
|
| 279 | 279 | return $this->_display_strategy; |
| 280 | 280 | } |
| 281 | 281 | /** |
| 282 | 282 | * Overwrites the display strategy |
| 283 | 283 | * @param EE_Display_Strategy_Base $display_strategy |
| 284 | 284 | */ |
| 285 | - public function set_display_strategy($display_strategy){ |
|
| 285 | + public function set_display_strategy($display_strategy) { |
|
| 286 | 286 | $this->_display_strategy = $display_strategy; |
| 287 | 287 | $this->_display_strategy->_construct_finalize($this); |
| 288 | 288 | } |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | * Gets the normalization strategy set on this input |
| 291 | 291 | * @return EE_Normalization_Strategy_Base |
| 292 | 292 | */ |
| 293 | - public function get_normalization_strategy(){ |
|
| 293 | + public function get_normalization_strategy() { |
|
| 294 | 294 | return $this->_normalization_strategy; |
| 295 | 295 | } |
| 296 | 296 | /** |
| 297 | 297 | * Overwrites the normalization strategy |
| 298 | 298 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
| 299 | 299 | */ |
| 300 | - public function set_normalization_strategy($normalization_strategy){ |
|
| 300 | + public function set_normalization_strategy($normalization_strategy) { |
|
| 301 | 301 | $this->_normalization_strategy = $normalization_strategy; |
| 302 | 302 | $this->_normalization_strategy->_construct_finalize($this); |
| 303 | 303 | } |
@@ -306,10 +306,10 @@ discard block |
||
| 306 | 306 | * Returns all teh validation strategies which apply to this field, numerically indexed |
| 307 | 307 | * @return EE_Validation_Strategy_Base[] |
| 308 | 308 | */ |
| 309 | - public function get_validation_strategies(){ |
|
| 310 | - if(is_array($this->_validation_strategies)){ |
|
| 309 | + public function get_validation_strategies() { |
|
| 310 | + if (is_array($this->_validation_strategies)) { |
|
| 311 | 311 | return $this->_validation_strategies; |
| 312 | - }else{ |
|
| 312 | + } else { |
|
| 313 | 313 | return array(); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -319,15 +319,15 @@ discard block |
||
| 319 | 319 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 320 | 320 | * @return void |
| 321 | 321 | */ |
| 322 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
| 323 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
| 322 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 323 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
| 324 | 324 | } |
| 325 | 325 | /** |
| 326 | 326 | * Gets the HTML, JS, and CSS necessary to display this field according |
| 327 | 327 | * to the parent form's layout strategy |
| 328 | 328 | * @return string |
| 329 | 329 | */ |
| 330 | - public function get_html_and_js(){ |
|
| 330 | + public function get_html_and_js() { |
|
| 331 | 331 | return $this->_parent_section->get_html_for_input($this); |
| 332 | 332 | } |
| 333 | 333 | /** |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * Makes sure the JS and CSS are enqueued for it |
| 337 | 337 | * @return string |
| 338 | 338 | */ |
| 339 | - public function get_html_for_input(){ |
|
| 339 | + public function get_html_for_input() { |
|
| 340 | 340 | return $this->_get_display_strategy()->display(); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @return string |
| 347 | 347 | */ |
| 348 | 348 | public function html_other_attributes() { |
| 349 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
| 349 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | /** |
| 355 | 355 | * @param string $html_other_attributes |
| 356 | 356 | */ |
| 357 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
| 357 | + public function set_html_other_attributes($html_other_attributes) { |
|
| 358 | 358 | $this->_html_other_attributes = $html_other_attributes; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * according to the form section's layout strategy |
| 364 | 364 | * @return string |
| 365 | 365 | */ |
| 366 | - public function get_html_for_label(){ |
|
| 366 | + public function get_html_for_label() { |
|
| 367 | 367 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
| 368 | 368 | } |
| 369 | 369 | /** |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * according to the form section's layout strategy |
| 372 | 372 | * @return string |
| 373 | 373 | */ |
| 374 | - public function get_html_for_errors(){ |
|
| 374 | + public function get_html_for_errors() { |
|
| 375 | 375 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
| 376 | 376 | } |
| 377 | 377 | /** |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * according to the form section's layout strategy |
| 380 | 380 | * @return string |
| 381 | 381 | */ |
| 382 | - public function get_html_for_help(){ |
|
| 382 | + public function get_html_for_help() { |
|
| 383 | 383 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
| 384 | 384 | } |
| 385 | 385 | /** |
@@ -388,20 +388,20 @@ discard block |
||
| 388 | 388 | * @return boolean |
| 389 | 389 | */ |
| 390 | 390 | protected function _validate() { |
| 391 | - if(is_array($this->_validation_strategies)){ |
|
| 392 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
| 393 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 394 | - try{ |
|
| 391 | + if (is_array($this->_validation_strategies)) { |
|
| 392 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 393 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 394 | + try { |
|
| 395 | 395 | $validation_strategy->validate($this->normalized_value()); |
| 396 | - }catch(EE_Validation_Error $e){ |
|
| 396 | + } catch (EE_Validation_Error $e) { |
|
| 397 | 397 | $this->add_validation_error($e); |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | - if( $this->get_validation_errors()){ |
|
| 402 | + if ($this->get_validation_errors()) { |
|
| 403 | 403 | return false; |
| 404 | - }else{ |
|
| 404 | + } else { |
|
| 405 | 405 | return true; |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | * @param string $value |
| 415 | 415 | * @return null|string |
| 416 | 416 | */ |
| 417 | - private function _sanitize($value){ |
|
| 418 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
| 417 | + private function _sanitize($value) { |
|
| 418 | + return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | |
@@ -427,24 +427,24 @@ discard block |
||
| 427 | 427 | * @param array $req_data like $_POST |
| 428 | 428 | * @return boolean whether or not there was an error |
| 429 | 429 | */ |
| 430 | - protected function _normalize( $req_data ) { |
|
| 430 | + protected function _normalize($req_data) { |
|
| 431 | 431 | //any existing validation errors don't apply so clear them |
| 432 | 432 | $this->_validation_errors = array(); |
| 433 | 433 | try { |
| 434 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
| 434 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
| 435 | 435 | //super simple sanitization for now |
| 436 | - if ( is_array( $raw_input )) { |
|
| 436 | + if (is_array($raw_input)) { |
|
| 437 | 437 | $this->_raw_value = array(); |
| 438 | - foreach( $raw_input as $key => $value ) { |
|
| 439 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
| 438 | + foreach ($raw_input as $key => $value) { |
|
| 439 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
| 440 | 440 | } |
| 441 | 441 | } else { |
| 442 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
| 442 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
| 443 | 443 | } |
| 444 | 444 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
| 445 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
| 446 | - } catch ( EE_Validation_Error $e ) { |
|
| 447 | - $this->add_validation_error( $e ); |
|
| 445 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
| 446 | + } catch (EE_Validation_Error $e) { |
|
| 447 | + $this->add_validation_error($e); |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | /** |
| 454 | 454 | * @return string |
| 455 | 455 | */ |
| 456 | - public function html_name(){ |
|
| 456 | + public function html_name() { |
|
| 457 | 457 | return $this->_html_name; |
| 458 | 458 | } |
| 459 | 459 | |
@@ -462,8 +462,8 @@ discard block |
||
| 462 | 462 | /** |
| 463 | 463 | * @return string |
| 464 | 464 | */ |
| 465 | - function html_label_id(){ |
|
| 466 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
| 465 | + function html_label_id() { |
|
| 466 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | /** |
| 472 | 472 | * @return string |
| 473 | 473 | */ |
| 474 | - function html_label_class(){ |
|
| 474 | + function html_label_class() { |
|
| 475 | 475 | return $this->_html_label_class; |
| 476 | 476 | } |
| 477 | 477 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | /** |
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | - function html_label_style(){ |
|
| 483 | + function html_label_style() { |
|
| 484 | 484 | return $this->_html_label_style; |
| 485 | 485 | } |
| 486 | 486 | |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | /** |
| 490 | 490 | * @return string |
| 491 | 491 | */ |
| 492 | - function html_label_text(){ |
|
| 492 | + function html_label_text() { |
|
| 493 | 493 | return $this->_html_label_text; |
| 494 | 494 | } |
| 495 | 495 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | /** |
| 499 | 499 | * @return string |
| 500 | 500 | */ |
| 501 | - function html_help_text(){ |
|
| 501 | + function html_help_text() { |
|
| 502 | 502 | return $this->_html_help_text; |
| 503 | 503 | } |
| 504 | 504 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | /** |
| 508 | 508 | * @return string |
| 509 | 509 | */ |
| 510 | - function html_help_class(){ |
|
| 510 | + function html_help_class() { |
|
| 511 | 511 | return $this->_html_help_class; |
| 512 | 512 | } |
| 513 | 513 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | /** |
| 517 | 517 | * @return string |
| 518 | 518 | */ |
| 519 | - function html_help_style(){ |
|
| 519 | + function html_help_style() { |
|
| 520 | 520 | return $this->_html_style; |
| 521 | 521 | } |
| 522 | 522 | /** |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | * in which case, we would have stored the malicious content to our database. |
| 530 | 530 | * @return string |
| 531 | 531 | */ |
| 532 | - function raw_value(){ |
|
| 532 | + function raw_value() { |
|
| 533 | 533 | return $this->_raw_value; |
| 534 | 534 | } |
| 535 | 535 | /** |
@@ -537,15 +537,15 @@ discard block |
||
| 537 | 537 | * it escapes all html entities |
| 538 | 538 | * @return string |
| 539 | 539 | */ |
| 540 | - function raw_value_in_form(){ |
|
| 541 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
| 540 | + function raw_value_in_form() { |
|
| 541 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
| 542 | 542 | } |
| 543 | 543 | /** |
| 544 | 544 | * returns the value after it's been sanitized, and then converted into it's proper type |
| 545 | 545 | * in PHP. Eg, a string, an int, an array, |
| 546 | 546 | * @return mixed |
| 547 | 547 | */ |
| 548 | - function normalized_value(){ |
|
| 548 | + function normalized_value() { |
|
| 549 | 549 | return $this->_normalized_value; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | * the best thing to display |
| 556 | 556 | * @return string |
| 557 | 557 | */ |
| 558 | - function pretty_value(){ |
|
| 558 | + function pretty_value() { |
|
| 559 | 559 | return $this->_normalized_value; |
| 560 | 560 | } |
| 561 | 561 | /** |
@@ -574,15 +574,15 @@ discard block |
||
| 574 | 574 | }</code> |
| 575 | 575 | * @return array |
| 576 | 576 | */ |
| 577 | - function get_jquery_validation_rules(){ |
|
| 577 | + function get_jquery_validation_rules() { |
|
| 578 | 578 | $jquery_validation_rules = array(); |
| 579 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
| 580 | - $jquery_validation_rules = array_replace_recursive( $jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array()); |
|
| 579 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
| 580 | + $jquery_validation_rules = array_replace_recursive($jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array()); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - if(! empty($jquery_validation_rules)){ |
|
| 584 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
| 585 | - }else{ |
|
| 583 | + if ( ! empty($jquery_validation_rules)) { |
|
| 584 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
| 585 | + } else { |
|
| 586 | 586 | return array(); |
| 587 | 587 | } |
| 588 | 588 | return $jquery_validation_js; |
@@ -594,9 +594,9 @@ discard block |
||
| 594 | 594 | * @param mixed $value |
| 595 | 595 | * @return void |
| 596 | 596 | */ |
| 597 | - function set_default($value){ |
|
| 597 | + function set_default($value) { |
|
| 598 | 598 | $this->_normalized_value = $value; |
| 599 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
| 599 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param string $label |
| 605 | 605 | * @return void |
| 606 | 606 | */ |
| 607 | - function set_html_label_text($label){ |
|
| 607 | + function set_html_label_text($label) { |
|
| 608 | 608 | $this->_html_label_text = $label; |
| 609 | 609 | } |
| 610 | 610 | |
@@ -616,12 +616,12 @@ discard block |
||
| 616 | 616 | * @param boolean $required |
| 617 | 617 | * @param null $required_text |
| 618 | 618 | */ |
| 619 | - function set_required($required = true, $required_text = NULL ){ |
|
| 620 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
| 621 | - if ( $required ) { |
|
| 622 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
| 619 | + function set_required($required = true, $required_text = NULL) { |
|
| 620 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
| 621 | + if ($required) { |
|
| 622 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
| 623 | 623 | } else { |
| 624 | - unset( $this->_validation_strategies[ get_class( new EE_Required_Validation_Strategy() ) ] ); |
|
| 624 | + unset($this->_validation_strategies[get_class(new EE_Required_Validation_Strategy())]); |
|
| 625 | 625 | } |
| 626 | 626 | $this->_required = $required; |
| 627 | 627 | } |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | * Returns whether or not this field is required |
| 630 | 630 | * @return boolean |
| 631 | 631 | */ |
| 632 | - public function required(){ |
|
| 632 | + public function required() { |
|
| 633 | 633 | return $this->_required; |
| 634 | 634 | } |
| 635 | 635 | |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | /** |
| 639 | 639 | * @param string $required_css_class |
| 640 | 640 | */ |
| 641 | - public function set_required_css_class( $required_css_class ) { |
|
| 641 | + public function set_required_css_class($required_css_class) { |
|
| 642 | 642 | $this->_required_css_class = $required_css_class; |
| 643 | 643 | } |
| 644 | 644 | |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | * Sets the help text, in case |
| 658 | 658 | * @param string $text |
| 659 | 659 | */ |
| 660 | - public function set_html_help_text($text){ |
|
| 660 | + public function set_html_help_text($text) { |
|
| 661 | 661 | $this->_html_help_text = $text; |
| 662 | 662 | } |
| 663 | 663 | /** |
@@ -669,8 +669,8 @@ discard block |
||
| 669 | 669 | public function clean_sensitive_data() { |
| 670 | 670 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
| 671 | 671 | //if we need more logic than this we'll make a strategy for it |
| 672 | - if( $this->_sensitive_data_removal_strategy && |
|
| 673 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
| 672 | + if ($this->_sensitive_data_removal_strategy && |
|
| 673 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
| 674 | 674 | $this->_raw_value = NULL; |
| 675 | 675 | } |
| 676 | 676 | //and clean the normalized value according to the appropriate strategy |
@@ -684,10 +684,10 @@ discard block |
||
| 684 | 684 | * @param string $button_size |
| 685 | 685 | * @param string $other_attributes |
| 686 | 686 | */ |
| 687 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
| 687 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
| 688 | 688 | $button_css_attributes = 'button'; |
| 689 | 689 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
| 690 | - switch ( $button_size ) { |
|
| 690 | + switch ($button_size) { |
|
| 691 | 691 | case 'xs' : |
| 692 | 692 | case 'extra-small' : |
| 693 | 693 | $button_css_attributes .= ' button-xs'; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | default : |
| 709 | 709 | $button_css_attributes .= ''; |
| 710 | 710 | } |
| 711 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
| 711 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * @return string |
| 718 | 718 | */ |
| 719 | 719 | public function button_css_attributes() { |
| 720 | - if ( empty( $this->_button_css_attributes )) { |
|
| 720 | + if (empty($this->_button_css_attributes)) { |
|
| 721 | 721 | $this->set_button_css_attributes(); |
| 722 | 722 | } |
| 723 | 723 | return $this->_button_css_attributes; |
@@ -737,27 +737,27 @@ discard block |
||
| 737 | 737 | * @param array $req_data |
| 738 | 738 | * @return mixed whatever the raw value of this form section is in the request data |
| 739 | 739 | */ |
| 740 | - public function find_form_data_for_this_section( $req_data ){ |
|
| 740 | + public function find_form_data_for_this_section($req_data) { |
|
| 741 | 741 | // break up the html name by "[]" |
| 742 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
| 743 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
| 742 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
| 743 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
| 744 | 744 | } else { |
| 745 | 745 | $before_any_brackets = $this->html_name(); |
| 746 | 746 | } |
| 747 | 747 | // grab all of the segments |
| 748 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
| 749 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
| 750 | - $name_parts = $matches[ 1 ]; |
|
| 748 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
| 749 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
| 750 | + $name_parts = $matches[1]; |
|
| 751 | 751 | array_unshift($name_parts, $before_any_brackets); |
| 752 | - }else{ |
|
| 753 | - $name_parts = array( $before_any_brackets ); |
|
| 752 | + } else { |
|
| 753 | + $name_parts = array($before_any_brackets); |
|
| 754 | 754 | } |
| 755 | 755 | // now get the value for the input |
| 756 | 756 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
| 757 | - if( $value === NULL ){ |
|
| 757 | + if ($value === NULL) { |
|
| 758 | 758 | //check if this thing's name is at the TOP level of the request data |
| 759 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
| 760 | - $value = $req_data[ $this->name() ]; |
|
| 759 | + if (isset($req_data[$this->name()])) { |
|
| 760 | + $value = $req_data[$this->name()]; |
|
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | return $value; |
@@ -771,15 +771,15 @@ discard block |
||
| 771 | 771 | * @param array $req_data |
| 772 | 772 | * @return array | NULL |
| 773 | 773 | */ |
| 774 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
| 775 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
| 776 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
| 777 | - if( empty($html_name_parts ) ){ |
|
| 778 | - return $req_data[ $first_part_to_consider ]; |
|
| 779 | - }else{ |
|
| 780 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
| 774 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
| 775 | + $first_part_to_consider = array_shift($html_name_parts); |
|
| 776 | + if (isset($req_data[$first_part_to_consider])) { |
|
| 777 | + if (empty($html_name_parts)) { |
|
| 778 | + return $req_data[$first_part_to_consider]; |
|
| 779 | + } else { |
|
| 780 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
| 781 | 781 | } |
| 782 | - }else{ |
|
| 782 | + } else { |
|
| 783 | 783 | return NULL; |
| 784 | 784 | } |
| 785 | 785 | } |
@@ -791,14 +791,14 @@ discard block |
||
| 791 | 791 | * @param array $req_data like $_POST |
| 792 | 792 | * @return boolean |
| 793 | 793 | */ |
| 794 | - public function form_data_present_in($req_data = NULL){ |
|
| 795 | - if( $req_data === NULL ){ |
|
| 794 | + public function form_data_present_in($req_data = NULL) { |
|
| 795 | + if ($req_data === NULL) { |
|
| 796 | 796 | $req_data = $_POST; |
| 797 | 797 | } |
| 798 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
| 799 | - if( $checked_value !== null ){ |
|
| 798 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
| 799 | + if ($checked_value !== null) { |
|
| 800 | 800 | return TRUE; |
| 801 | - }else{ |
|
| 801 | + } else { |
|
| 802 | 802 | return FALSE; |
| 803 | 803 | } |
| 804 | 804 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 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 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | foreach( $unnormalized_value_choices as $unnormalized_value_choice ){ |
| 259 | 259 | if( isset( $options[ $unnormalized_value_choice ] ) ){ |
| 260 | 260 | $pretty_strings[] = $options[ $unnormalized_value_choice ]; |
| 261 | - }else{ |
|
| 261 | + } else{ |
|
| 262 | 262 | $pretty_strings[] = $this->normalized_value(); |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -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 ) && in_array( FALSE, $select_option_keys )) |
|
| 94 | - || ( in_array( 1, $select_option_keys ) && in_array( 0, $select_option_keys )) |
|
| 93 | + (in_array(TRUE, $select_option_keys) && in_array(FALSE, $select_option_keys)) |
|
| 94 | + || (in_array(1, $select_option_keys) && in_array(0, $select_option_keys)) |
|
| 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 | |