@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * ------------------------------------------------------------------------ |
| 23 | 23 | */ |
| 24 | -class EE_Template_Layout extends EE_Div_Per_Section_Layout{ |
|
| 24 | +class EE_Template_Layout extends EE_Div_Per_Section_Layout { |
|
| 25 | 25 | |
| 26 | 26 | protected $_layout_template_file = NULL; |
| 27 | 27 | protected $_layout_begin_template_file = NULL; |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * @type array $_template_args |
| 43 | 43 | * } |
| 44 | 44 | */ |
| 45 | - public function __construct( $template_options = array() ) { |
|
| 45 | + public function __construct($template_options = array()) { |
|
| 46 | 46 | // loop thru incoming options |
| 47 | - foreach( $template_options as $key => $value ) { |
|
| 47 | + foreach ($template_options as $key => $value) { |
|
| 48 | 48 | // add underscore to $key to match property names |
| 49 | - $_key = '_' . $key; |
|
| 50 | - if ( property_exists( $this, $_key )) { |
|
| 49 | + $_key = '_'.$key; |
|
| 50 | + if (property_exists($this, $_key)) { |
|
| 51 | 51 | $this->$_key = $value; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | 67 | public function layout_form() { |
| 68 | - if ( $this->_layout_template_file ) { |
|
| 69 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
| 70 | - return EEH_Template::locate_template( $this->_layout_template_file, $this->template_args(), TRUE, TRUE ); |
|
| 68 | + if ($this->_layout_template_file) { |
|
| 69 | + EE_Registry::instance()->load_helper('Template'); |
|
| 70 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), TRUE, TRUE); |
|
| 71 | 71 | } else { |
| 72 | 72 | return parent::layout_form(); |
| 73 | 73 | } |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | 82 | public function layout_form_begin() { |
| 83 | - if($this->_layout_begin_template_file){ |
|
| 83 | + if ($this->_layout_begin_template_file) { |
|
| 84 | 84 | EE_Registry::instance()->load_helper('Template'); |
| 85 | - return EEH_Template::locate_template( $this->_layout_begin_template_file, $this->template_args(), TRUE, TRUE ); |
|
| 86 | - }else{ |
|
| 85 | + return EEH_Template::locate_template($this->_layout_begin_template_file, $this->template_args(), TRUE, TRUE); |
|
| 86 | + } else { |
|
| 87 | 87 | return parent::layout_form_begin(); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | * @param EE_Form_Input_Base $input |
| 97 | 97 | * @return string |
| 98 | 98 | */ |
| 99 | - public function layout_input( $input ) { |
|
| 100 | - if($this->_input_template_file){ |
|
| 99 | + public function layout_input($input) { |
|
| 100 | + if ($this->_input_template_file) { |
|
| 101 | 101 | EE_Registry::instance()->load_helper('Template'); |
| 102 | - return EEH_Template::locate_template( $this->_input_template_file, array( 'input' => $input ), TRUE, TRUE ); |
|
| 102 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), TRUE, TRUE); |
|
| 103 | 103 | } |
| 104 | 104 | return parent::layout_input($input); |
| 105 | 105 | } |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * @param EE_Form_Section_Proper $form_section |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | - public function layout_subsection( $form_section ) { |
|
| 116 | - if($this->_subsection_template_file){ |
|
| 115 | + public function layout_subsection($form_section) { |
|
| 116 | + if ($this->_subsection_template_file) { |
|
| 117 | 117 | EE_Registry::instance()->load_helper('Template'); |
| 118 | - return EEH_Template::locate_template( $this->_subsection_template_file, $this->template_args(), TRUE, TRUE ); |
|
| 118 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), TRUE, TRUE); |
|
| 119 | 119 | } |
| 120 | - return parent::layout_subsection( $form_section ); |
|
| 120 | + return parent::layout_subsection($form_section); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | 129 | public function layout_form_end() { |
| 130 | - if($this->_layout_end_template_file){ |
|
| 130 | + if ($this->_layout_end_template_file) { |
|
| 131 | 131 | EE_Registry::instance()->load_helper('Template'); |
| 132 | - return EEH_Template::locate_template( $this->_layout_end_template_file, $this->template_args(), TRUE, TRUE); |
|
| 133 | - }else{ |
|
| 132 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), TRUE, TRUE); |
|
| 133 | + } else { |
|
| 134 | 134 | return parent::layout_form_end(); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | /** |
| 141 | 141 | * @param array $template_args |
| 142 | 142 | */ |
| 143 | - public function set_template_args( $template_args = array() ) { |
|
| 143 | + public function set_template_args($template_args = array()) { |
|
| 144 | 144 | $this->_template_args = $template_args; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | /** |
| 150 | 150 | * @param array $template_args |
| 151 | 151 | */ |
| 152 | - public function add_template_args( $template_args = array() ) { |
|
| 153 | - $this->_template_args = array_merge_recursive( $this->_template_args, $template_args ); |
|
| 152 | + public function add_template_args($template_args = array()) { |
|
| 153 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | * @return array |
| 160 | 160 | */ |
| 161 | 161 | public function template_args() { |
| 162 | - foreach ( $this->form_section()->subsections() as $subsection_name => $subsection ) { |
|
| 163 | - $subsection_name = self::prep_form_subsection_key_name( $subsection_name ); |
|
| 164 | - if ( strpos( $subsection_name, '[' ) !== FALSE ) { |
|
| 165 | - $sub_name = explode( '[', $subsection_name ); |
|
| 166 | - $this->_template_args[ $sub_name[0] ][ rtrim( $sub_name[1], ']' ) ] = $this->layout_subsection( $subsection ); |
|
| 162 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
| 163 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
| 164 | + if (strpos($subsection_name, '[') !== FALSE) { |
|
| 165 | + $sub_name = explode('[', $subsection_name); |
|
| 166 | + $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
| 167 | 167 | } else { |
| 168 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection( $subsection ); |
|
| 168 | + $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | // d( $this->_template_args ); |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | * @param string $subsection_name |
| 182 | 182 | * @return string |
| 183 | 183 | */ |
| 184 | - public static function prep_form_subsection_key_name( $subsection_name = '' ) { |
|
| 185 | - $subsection_name = str_replace( array( '-', ' ' ), array( '', '_' ), $subsection_name ); |
|
| 186 | - return is_numeric( substr( $subsection_name, 0, 1 )) ? 'form_' . $subsection_name : $subsection_name; |
|
| 184 | + public static function prep_form_subsection_key_name($subsection_name = '') { |
|
| 185 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
| 186 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | * @param string $subsection_name |
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | - public static function get_subform_name( $subsection_name = '' ) { |
|
| 199 | - return EE_Template_Layout::prep_form_subsection_key_name( $subsection_name ); |
|
| 198 | + public static function get_subform_name($subsection_name = '') { |
|
| 199 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
| 43 | 43 | } |
| 44 | 44 | throw new EE_Validation_Error( $validation_error_message, 'float_only' ); |
| 45 | - }else{ |
|
| 45 | + } else{ |
|
| 46 | 46 | return floatval($normalized_value); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public function unnormalize($normalized_value) { |
| 56 | 56 | if( empty( $normalized_value ) ){ |
| 57 | 57 | return '0.00'; |
| 58 | - }else{ |
|
| 58 | + } else{ |
|
| 59 | 59 | return "$normalized_value"; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -1,14 +1,14 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base{ |
|
| 3 | +class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base { |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
| 7 | 7 | * @param array $additional_args |
| 8 | 8 | * @return string |
| 9 | 9 | */ |
| 10 | - public function layout_form_begin( $additional_args = array() ) { |
|
| 11 | - return EEH_HTML::table( '', $this->_form_section->html_id(), $this->_form_section->html_class(), $this->_form_section->html_style() ) . EEH_HTML::tbody(); |
|
| 10 | + public function layout_form_begin($additional_args = array()) { |
|
| 11 | + return EEH_HTML::table('', $this->_form_section->html_id(), $this->_form_section->html_class(), $this->_form_section->html_style()).EEH_HTML::tbody(); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | * @param array $additional_args |
| 19 | 19 | * @return string |
| 20 | 20 | */ |
| 21 | - public function layout_form_end( $additional_args = array() ) { |
|
| 22 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex( $this->_form_section->html_id() ); |
|
| 21 | + public function layout_form_end($additional_args = array()) { |
|
| 22 | + return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | * @param EE_Form_Input_Base $input |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - public function layout_input( $input ) { |
|
| 32 | + public function layout_input($input) { |
|
| 33 | 33 | $html = ''; |
| 34 | - if ( $input instanceof EE_Hidden_Input ) { |
|
| 34 | + if ($input instanceof EE_Hidden_Input) { |
|
| 35 | 35 | $html .= $input->get_html_for_input(); |
| 36 | 36 | } else { |
| 37 | 37 | $html_for_input = $input->get_html_for_input(); |
| 38 | - $html_for_input .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
| 39 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
| 38 | + $html_for_input .= $input->get_html_for_errors() != '' ? EEH_HTML::nl().$input->get_html_for_errors() : ''; |
|
| 39 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
| 40 | 40 | $html .= EEH_HTML::tr( |
| 41 | - EEH_HTML::th( $input->get_html_for_label() ) . |
|
| 42 | - EEH_HTML::td( $html_for_input ) |
|
| 41 | + EEH_HTML::th($input->get_html_for_label()). |
|
| 42 | + EEH_HTML::td($html_for_input) |
|
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | return $html; |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | * @param EE_Form_Section_Proper $form_section |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - public function layout_subsection( $form_section ){ |
|
| 55 | + public function layout_subsection($form_section) { |
|
| 56 | 56 | $html = ''; |
| 57 | - if ( $form_section instanceof EE_Form_Section_HTML ) { |
|
| 57 | + if ($form_section instanceof EE_Form_Section_HTML) { |
|
| 58 | 58 | $html .= $form_section->get_html_and_js(); |
| 59 | 59 | } else { |
| 60 | 60 | $html .= EEH_HTML::tr( |
| 61 | - EEH_HTML::td( $form_section->get_html_and_js(), '', '', '', 'colspan="2"' ) |
|
| 61 | + EEH_HTML::td($form_section->get_html_and_js(), '', '', '', 'colspan="2"') |
|
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | return $html; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @subpackage |
| 9 | 9 | * @author Mike Nelson |
| 10 | 10 | */ |
| 11 | -class EE_All_Caps_Normalization extends EE_Normalization_Strategy_Base{ |
|
| 11 | +class EE_All_Caps_Normalization extends EE_Normalization_Strategy_Base { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @param string $value_to_normalize |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param string $normalized_value |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | - public function unnormalize( $normalized_value ) { |
|
| 27 | + public function unnormalize($normalized_value) { |
|
| 28 | 28 | return $normalized_value; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | * @subpackage |
| 11 | 11 | * @author Mike Nelson |
| 12 | 12 | */ |
| 13 | -class EE_Boolean_Normalization extends EE_Normalization_Strategy_Base{ |
|
| 13 | +class EE_Boolean_Normalization extends EE_Normalization_Strategy_Base { |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param string | int | bool $value_to_normalize |
| 17 | 17 | * @return boolean |
| 18 | 18 | */ |
| 19 | - public function normalize( $value_to_normalize ) { |
|
| 20 | - return filter_var( $value_to_normalize, FILTER_VALIDATE_BOOLEAN ); |
|
| 19 | + public function normalize($value_to_normalize) { |
|
| 20 | + return filter_var($value_to_normalize, FILTER_VALIDATE_BOOLEAN); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | * @param boolean $normalized_value |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | - public function unnormalize( $normalized_value ) { |
|
| 31 | - if( $normalized_value ){ |
|
| 30 | + public function unnormalize($normalized_value) { |
|
| 31 | + if ($normalized_value) { |
|
| 32 | 32 | return '1'; |
| 33 | - }else{ |
|
| 33 | + } else { |
|
| 34 | 34 | return '0'; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -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,7 +6,7 @@ |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Credit_Card_Normalization extends EE_Text_Normalization{ |
|
| 9 | +class EE_Credit_Card_Normalization extends EE_Text_Normalization { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param string $value_to_normalize |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @subpackage |
| 8 | 8 | * @author Mike Nelson |
| 9 | 9 | */ |
| 10 | -class EE_Float_Normalization extends EE_Normalization_Strategy_Base{ |
|
| 10 | +class EE_Float_Normalization extends EE_Normalization_Strategy_Base { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @param string $value_to_normalize |
@@ -15,34 +15,34 @@ discard block |
||
| 15 | 15 | * @throws \EE_Validation_Error |
| 16 | 16 | */ |
| 17 | 17 | public function normalize($value_to_normalize) { |
| 18 | - if($value_to_normalize === NULL){ |
|
| 18 | + if ($value_to_normalize === NULL) { |
|
| 19 | 19 | return 0.00; |
| 20 | 20 | } |
| 21 | 21 | $normalized_value = ''; |
| 22 | - if(is_string($value_to_normalize)){ |
|
| 23 | - $normalized_value = str_replace(array(" ",EE_Config::instance()->currency->thsnds),"",$value_to_normalize); |
|
| 22 | + if (is_string($value_to_normalize)) { |
|
| 23 | + $normalized_value = str_replace(array(" ", EE_Config::instance()->currency->thsnds), "", $value_to_normalize); |
|
| 24 | 24 | //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
| 25 | - $normalized_value = str_replace( EE_Config::instance()->currency->dec_mrk, ".", $normalized_value) ; |
|
| 25 | + $normalized_value = str_replace(EE_Config::instance()->currency->dec_mrk, ".", $normalized_value); |
|
| 26 | 26 | //double-check there's absolutely nothing left on this string besides numbers |
| 27 | - $normalized_value = preg_replace( "/[^0-9,. ]/", "", $normalized_value); |
|
| 27 | + $normalized_value = preg_replace("/[^0-9,. ]/", "", $normalized_value); |
|
| 28 | 28 | } |
| 29 | - if(strlen($value_to_normalize) > strlen($normalized_value)){ |
|
| 29 | + if (strlen($value_to_normalize) > strlen($normalized_value)) { |
|
| 30 | 30 | //find if this input has a float validation strategy |
| 31 | 31 | //in which case, use its message |
| 32 | 32 | $validation_error_message = NULL; |
| 33 | - foreach( $this->_input->get_validation_strategies() as $validation_strategy ){ |
|
| 34 | - if( $validation_strategy instanceof EE_Float_Validation_Strategy ){ |
|
| 33 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 34 | + if ($validation_strategy instanceof EE_Float_Validation_Strategy) { |
|
| 35 | 35 | $validation_error_message = $validation_strategy->get_validation_error_message(); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | //this really shouldn't ever happen because fields with a float normalization strategy |
| 39 | 39 | //should also have a float validation strategy, but in case it doesnt use the default |
| 40 | - if( ! $validation_error_message ){ |
|
| 40 | + if ( ! $validation_error_message) { |
|
| 41 | 41 | $default_validation_strategy = new EE_Float_Validation_Strategy(); |
| 42 | 42 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
| 43 | 43 | } |
| 44 | - throw new EE_Validation_Error( $validation_error_message, 'float_only' ); |
|
| 45 | - }else{ |
|
| 44 | + throw new EE_Validation_Error($validation_error_message, 'float_only'); |
|
| 45 | + } else { |
|
| 46 | 46 | return floatval($normalized_value); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | 55 | public function unnormalize($normalized_value) { |
| 56 | - if( empty( $normalized_value ) ){ |
|
| 56 | + if (empty($normalized_value)) { |
|
| 57 | 57 | return '0.00'; |
| 58 | - }else{ |
|
| 58 | + } else { |
|
| 59 | 59 | return "$normalized_value"; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
| 43 | 43 | } |
| 44 | 44 | throw new EE_Validation_Error( $validation_error_message, 'float_only' ); |
| 45 | - }else{ |
|
| 45 | + } else{ |
|
| 46 | 46 | return floatval($normalized_value); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public function unnormalize($normalized_value) { |
| 56 | 56 | if( empty( $normalized_value ) ){ |
| 57 | 57 | return '0.00'; |
| 58 | - }else{ |
|
| 58 | + } else{ |
|
| 59 | 59 | return "$normalized_value"; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Many_Valued_Normalization extends EE_Normalization_Strategy_Base{ |
|
| 9 | +class EE_Many_Valued_Normalization extends EE_Normalization_Strategy_Base { |
|
| 10 | 10 | protected $_individual_item_normalization_strategy = array(); |
| 11 | 11 | /** |
| 12 | 12 | * |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | * @return array |
| 24 | 24 | */ |
| 25 | 25 | public function normalize($value_to_normalize) { |
| 26 | - if ( is_array( $value_to_normalize )){ |
|
| 26 | + if (is_array($value_to_normalize)) { |
|
| 27 | 27 | $items_to_normalize = $value_to_normalize; |
| 28 | - } else if( $value_to_normalize !== NULL ){ |
|
| 29 | - $items_to_normalize = array( $value_to_normalize ); |
|
| 28 | + } else if ($value_to_normalize !== NULL) { |
|
| 29 | + $items_to_normalize = array($value_to_normalize); |
|
| 30 | 30 | } else { |
| 31 | 31 | $items_to_normalize = array(); |
| 32 | 32 | } |
| 33 | 33 | $normalized_array_value = array(); |
| 34 | - foreach( $items_to_normalize as $key => $individual_item ){ |
|
| 35 | - $normalized_array_value[ $key ] = $this->normalize_one( $individual_item ); |
|
| 34 | + foreach ($items_to_normalize as $key => $individual_item) { |
|
| 35 | + $normalized_array_value[$key] = $this->normalize_one($individual_item); |
|
| 36 | 36 | } |
| 37 | 37 | return $normalized_array_value; |
| 38 | 38 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param string $individual_value_to_normalize but definitely NOT an array |
| 43 | 43 | * @return mixed |
| 44 | 44 | */ |
| 45 | - public function normalize_one( $individual_value_to_normalize ) { |
|
| 46 | - return $this->_individual_item_normalization_strategy->normalize( $individual_value_to_normalize ); |
|
| 45 | + public function normalize_one($individual_value_to_normalize) { |
|
| 46 | + return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | * @param array $normalized_values |
| 52 | 52 | * @return string[] |
| 53 | 53 | */ |
| 54 | - public function unnormalize( $normalized_values ) { |
|
| 55 | - if( ! is_array( $normalized_values ) ){ |
|
| 56 | - $normalized_values = array( $normalized_values ); |
|
| 54 | + public function unnormalize($normalized_values) { |
|
| 55 | + if ( ! is_array($normalized_values)) { |
|
| 56 | + $normalized_values = array($normalized_values); |
|
| 57 | 57 | } |
| 58 | 58 | $non_normal_values = array(); |
| 59 | - foreach( $normalized_values as $key => $value ) { |
|
| 60 | - $non_normal_values[ $key ] = $this->unnormalize_one( $value ); |
|
| 59 | + foreach ($normalized_values as $key => $value) { |
|
| 60 | + $non_normal_values[$key] = $this->unnormalize_one($value); |
|
| 61 | 61 | } |
| 62 | 62 | return $non_normal_values; |
| 63 | 63 | } |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * @param mixed $individual_value_to_unnormalize but certainly NOT an array |
| 68 | 68 | * @return string |
| 69 | 69 | */ |
| 70 | - public function unnormalize_one( $individual_value_to_unnormalize ) { |
|
| 71 | - return $this->_individual_item_normalization_strategy->unnormalize( $individual_value_to_unnormalize ); |
|
| 70 | + public function unnormalize_one($individual_value_to_unnormalize) { |
|
| 71 | + return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -abstract class EE_Normalization_Strategy_Base extends EE_Form_Input_Strategy_Base{ |
|
| 9 | +abstract class EE_Normalization_Strategy_Base extends EE_Form_Input_Strategy_Base { |
|
| 10 | 10 | /** |
| 11 | 11 | * Takes the sanitized value for the input and casts it into the correct PHP type. |
| 12 | 12 | * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * @param string $individual_item_to_normalize |
| 30 | 30 | * @return mixed |
| 31 | 31 | */ |
| 32 | - public function normalize_one( $individual_item_to_normalize ){ |
|
| 33 | - return $this->normalize( $individual_item_to_normalize ); |
|
| 32 | + public function normalize_one($individual_item_to_normalize) { |
|
| 33 | + return $this->normalize($individual_item_to_normalize); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param $normalized_value |
| 43 | 43 | * @return array|string the 'raw' value as used in the form, usually a string or array of strings. |
| 44 | 44 | */ |
| 45 | - abstract function unnormalize( $normalized_value ); |
|
| 45 | + abstract function unnormalize($normalized_value); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Normally the same as unnormalize, except it CANNOT be passed an array and |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * @param mixed $individual_item_to_unnormalize NOT an array |
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | - public function unnormalize_one( $individual_item_to_unnormalize ) { |
|
| 54 | - return $this->unnormalize( $individual_item_to_unnormalize ); |
|
| 53 | + public function unnormalize_one($individual_item_to_unnormalize) { |
|
| 54 | + return $this->unnormalize($individual_item_to_unnormalize); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @subpackage |
| 8 | 8 | * @author Mike Nelson |
| 9 | 9 | */ |
| 10 | -class EE_Slug_Normalization extends EE_Normalization_Strategy_Base{ |
|
| 10 | +class EE_Slug_Normalization extends EE_Normalization_Strategy_Base { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @param string $value_to_normalize |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | * @param string $normalized_value |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - public function unnormalize( $normalized_value ) { |
|
| 26 | - return str_replace( "-", " ", $normalized_value ); |
|
| 25 | + public function unnormalize($normalized_value) { |
|
| 26 | + return str_replace("-", " ", $normalized_value); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | } |