@@ -101,7 +101,7 @@ |
||
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * @param $payment_method_type |
|
| 104 | + * @param EE_PMT_Base $payment_method_type |
|
| 105 | 105 | * @throws EE_Error |
| 106 | 106 | */ |
| 107 | 107 | public function set_payment_method_type( $payment_method_type ){ |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields. |
| 5 | 5 | * Uses EEM_Payment_Method as the model |
| 6 | 6 | */ |
| 7 | -class EE_Payment_Method_Form extends EE_Model_Form_Section{ |
|
| 7 | +class EE_Payment_Method_Form extends EE_Model_Form_Section { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * All the subsection inputs that correspond ot extra meta rows |
@@ -39,37 +39,37 @@ discard block |
||
| 39 | 39 | * @see EE_Model_Form_Section::__construct() for more |
| 40 | 40 | * } |
| 41 | 41 | */ |
| 42 | - public function __construct($options_array = array()){ |
|
| 42 | + public function __construct($options_array = array()) { |
|
| 43 | 43 | $this->_model = EEM_Payment_Method::instance(); |
| 44 | 44 | $this->_options_array = $options_array; |
| 45 | - if(isset($options_array['payment_method_type'])){ |
|
| 45 | + if (isset($options_array['payment_method_type'])) { |
|
| 46 | 46 | $this->_payment_method_type = $options_array['payment_method_type']; |
| 47 | 47 | } |
| 48 | 48 | $options_array = $this->_options_array; |
| 49 | - if(isset($options_array['extra_meta_inputs'])){ |
|
| 50 | - $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']); |
|
| 49 | + if (isset($options_array['extra_meta_inputs'])) { |
|
| 50 | + $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
| 51 | 51 | } |
| 52 | - if($this->_extra_meta_inputs){ |
|
| 53 | - $this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs); |
|
| 52 | + if ($this->_extra_meta_inputs) { |
|
| 53 | + $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
| 54 | 54 | } |
| 55 | 55 | $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
| 56 | - array( 'html_label_text'=> __( 'Button URL', 'event_espresso' )) |
|
| 56 | + array('html_label_text'=> __('Button URL', 'event_espresso')) |
|
| 57 | 57 | ); |
| 58 | 58 | $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
| 59 | 59 | EEM_Payment_Method::instance()->scopes(), |
| 60 | - array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' )) |
|
| 60 | + array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview')) |
|
| 61 | 61 | ); |
| 62 | 62 | //setup the currency options |
| 63 | 63 | $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
| 64 | - EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ), |
|
| 64 | + EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
| 65 | 65 | array( |
| 66 | - 'html_label_text'=> __( 'Currencies Supported', 'event_espresso' ), |
|
| 66 | + 'html_label_text'=> __('Currencies Supported', 'event_espresso'), |
|
| 67 | 67 | 'required'=>TRUE |
| 68 | 68 | ) |
| 69 | 69 | ); |
| 70 | - $this->_subsections['PMD_order'] = new EE_Text_Input( array( |
|
| 71 | - 'html_label_text' => __( 'Order', 'event_espresso' ), |
|
| 72 | - 'html_help_text' => __( 'Lowest numbers will be shown first', 'event_espresso' ), |
|
| 70 | + $this->_subsections['PMD_order'] = new EE_Text_Input(array( |
|
| 71 | + 'html_label_text' => __('Order', 'event_espresso'), |
|
| 72 | + 'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), |
|
| 73 | 73 | 'normalization_strategy' => new EE_Int_Normalization(), |
| 74 | 74 | 'validation_strategies' => array( |
| 75 | 75 | new EE_Int_Validation_Strategy() |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | )); |
| 79 | 79 | $this->_layout_strategy = new EE_Admin_Two_Column_Layout(); |
| 80 | 80 | parent::__construct($options_array); |
| 81 | - $debug_mode = isset( $this->_subsections[ 'PMD_debug_mode' ] ) ? $this->_subsections[ 'PMD_debug_mode' ] : null; |
|
| 82 | - if( $debug_mode instanceof EE_Form_Input_Base ) { |
|
| 83 | - $debug_mode->set_html_help_text( __( 'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso' ) ); |
|
| 81 | + $debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null; |
|
| 82 | + if ($debug_mode instanceof EE_Form_Input_Base) { |
|
| 83 | + $debug_mode->set_html_help_text(__('This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso')); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | * @param string $name |
| 93 | 93 | * @throws EE_Error |
| 94 | 94 | */ |
| 95 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
| 96 | - if( ! $this->_payment_method_type instanceof EE_PMT_Base ){ |
|
| 97 | - throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' ))); |
|
| 95 | + public function _construct_finalize($parent_form_section, $name) { |
|
| 96 | + if ( ! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
| 97 | + throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso'))); |
|
| 98 | 98 | } |
| 99 | 99 | //set the name of this form based on the payment method type |
| 100 | - if( ! $this->_name && ! $name ){ |
|
| 101 | - $name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
| 100 | + if ( ! $this->_name && ! $name) { |
|
| 101 | + $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
| 102 | 102 | } |
| 103 | - parent::_construct_finalize( $parent_form_section, $name ); |
|
| 103 | + parent::_construct_finalize($parent_form_section, $name); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | * @param $payment_method_type |
| 110 | 110 | * @throws EE_Error |
| 111 | 111 | */ |
| 112 | - public function set_payment_method_type( $payment_method_type ){ |
|
| 113 | - if( ! $payment_method_type instanceof EE_PMT_Base){ |
|
| 112 | + public function set_payment_method_type($payment_method_type) { |
|
| 113 | + if ( ! $payment_method_type instanceof EE_PMT_Base) { |
|
| 114 | 114 | throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso"))); |
| 115 | 115 | } |
| 116 | 116 | $this->_payment_method_type = $payment_method_type; |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | * extends the model form section's save method to also save the extra meta field values |
| 123 | 123 | * @return int ID of the payment method inserted, or true on update |
| 124 | 124 | */ |
| 125 | - public function save(){ |
|
| 125 | + public function save() { |
|
| 126 | 126 | $parent_save_val = parent::save(); |
| 127 | - if( $this->_model_object && $this->_model_object->ID()){ |
|
| 128 | - foreach($this->_extra_meta_inputs as $input_name => $input){ |
|
| 127 | + if ($this->_model_object && $this->_model_object->ID()) { |
|
| 128 | + foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
| 129 | 129 | $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
| 143 | 143 | parent::populate_model_obj($model_obj); |
| 144 | 144 | $extra_meta = $model_obj->all_extra_meta_array(); |
| 145 | - foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){ |
|
| 146 | - if(isset($extra_meta[$input_name])){ |
|
| 145 | + foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
| 146 | + if (isset($extra_meta[$input_name])) { |
|
| 147 | 147 | $extra_meta_input->set_default($extra_meta[$input_name]); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | * gets the default name of this form section if none is specified |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - protected function _set_default_name_if_empty(){ |
|
| 159 | - if( ! $this->_name ){ |
|
| 160 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
| 161 | - $this->_name = $default_name; |
|
| 158 | + protected function _set_default_name_if_empty() { |
|
| 159 | + if ( ! $this->_name) { |
|
| 160 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
| 161 | + $this->_name = $default_name; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * Gets all the extra meta inputs in this form |
| 169 | 169 | * @return EE_Form_Input_Base[] |
| 170 | 170 | */ |
| 171 | - public function extra_meta_inputs(){ |
|
| 171 | + public function extra_meta_inputs() { |
|
| 172 | 172 | return $this->_extra_meta_inputs; |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | /** |
| 81 | 81 | * Checks if that value is the one selected |
| 82 | 82 | * @param string|int $value unnormalized value option (string) |
| 83 | - * @return string |
|
| 83 | + * @return boolean |
|
| 84 | 84 | */ |
| 85 | 85 | protected function _check_if_option_selected( $value ){ |
| 86 | 86 | return $this->_input->raw_value() == $value ? TRUE : FALSE; |
@@ -11,48 +11,48 @@ discard block |
||
| 11 | 11 | * @since $VID:$ |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Select_Display_Strategy extends EE_Display_Strategy_Base{ |
|
| 14 | +class EE_Select_Display_Strategy extends EE_Display_Strategy_Base { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
| 18 | 18 | * @throws EE_Error |
| 19 | 19 | * @return string of html to display the field |
| 20 | 20 | */ |
| 21 | - function display(){ |
|
| 22 | - if( ! $this->_input instanceof EE_Form_Input_With_Options_Base){ |
|
| 23 | - throw new EE_Error( sprintf( __( 'Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso' ))); |
|
| 21 | + function display() { |
|
| 22 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
| 23 | + throw new EE_Error(sprintf(__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso'))); |
|
| 24 | 24 | } |
| 25 | 25 | EE_Registry::instance()->load_helper('Array'); |
| 26 | 26 | |
| 27 | - $html = EEH_HTML::nl( 0, 'select' ); |
|
| 27 | + $html = EEH_HTML::nl(0, 'select'); |
|
| 28 | 28 | $html .= '<select'; |
| 29 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
| 30 | - $html .= ' name="' . $this->_input->html_name() . '"'; |
|
| 31 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
| 32 | - $html .= ' class="' . $class . '"'; |
|
| 29 | + $html .= ' id="'.$this->_input->html_id().'"'; |
|
| 30 | + $html .= ' name="'.$this->_input->html_name().'"'; |
|
| 31 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
| 32 | + $html .= ' class="'.$class.'"'; |
|
| 33 | 33 | // add html5 required |
| 34 | 34 | |
| 35 | 35 | $html .= $this->_input->required() ? ' required' : ''; |
| 36 | - $html .= ' style="' . $this->_input->html_style() . '"'; |
|
| 37 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
| 36 | + $html .= ' style="'.$this->_input->html_style().'"'; |
|
| 37 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
| 38 | 38 | $html .= '>'; |
| 39 | 39 | |
| 40 | 40 | // EEH_HTML::indent( 1, 'select' ); |
| 41 | - if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) { |
|
| 42 | - EEH_HTML::indent( 1, 'optgroup' ); |
|
| 43 | - foreach( $this->_input->options() as $opt_group_label => $opt_group ){ |
|
| 44 | - $html .= EEH_HTML::nl( 0, 'optgroup' ) . '<optgroup label="' . esc_attr( $opt_group_label ) . '">'; |
|
| 45 | - EEH_HTML::indent( 1, 'option' ); |
|
| 46 | - $html .= $this->_display_options( $opt_group ); |
|
| 41 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
| 42 | + EEH_HTML::indent(1, 'optgroup'); |
|
| 43 | + foreach ($this->_input->options() as $opt_group_label => $opt_group) { |
|
| 44 | + $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">'; |
|
| 45 | + EEH_HTML::indent(1, 'option'); |
|
| 46 | + $html .= $this->_display_options($opt_group); |
|
| 47 | 47 | $html .= EEH_HTML::indent( -1, 'option' ); |
| 48 | - $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>'; |
|
| 48 | + $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>'; |
|
| 49 | 49 | } |
| 50 | 50 | EEH_HTML::indent( -1, 'optgroup' ); |
| 51 | 51 | } else { |
| 52 | - $html.=$this->_display_options( $this->_input->options() ); |
|
| 52 | + $html .= $this->_display_options($this->_input->options()); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $html.= EEH_HTML::nl( 0, 'select' ) . '</select>'; |
|
| 55 | + $html .= EEH_HTML::nl(0, 'select').'</select>'; |
|
| 56 | 56 | // $html.= EEH_HTML::nl( -1, 'select' ) . '</select>'; |
| 57 | 57 | return $html; |
| 58 | 58 | } |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | * @param array $options |
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | - protected function _display_options($options){ |
|
| 67 | + protected function _display_options($options) { |
|
| 68 | 68 | $html = ''; |
| 69 | - EEH_HTML::indent( 1, 'option' ); |
|
| 70 | - foreach( $options as $value => $display_text ){ |
|
| 71 | - $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value ); |
|
| 72 | - $selected = $this->_check_if_option_selected( $unnormalized_value ) ? ' selected="selected"' : ''; |
|
| 73 | - $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr( $unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>'; |
|
| 69 | + EEH_HTML::indent(1, 'option'); |
|
| 70 | + foreach ($options as $value => $display_text) { |
|
| 71 | + $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value); |
|
| 72 | + $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : ''; |
|
| 73 | + $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>'; |
|
| 74 | 74 | } |
| 75 | 75 | EEH_HTML::indent( -1, 'option' ); |
| 76 | 76 | return $html; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string|int $value unnormalized value option (string) |
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | - protected function _check_if_option_selected( $value ){ |
|
| 86 | + protected function _check_if_option_selected($value) { |
|
| 87 | 87 | return $this->_input->raw_value() == $value ? TRUE : FALSE; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @param string $value_to_normalize |
| 14 | - * @return int|mixed|string |
|
| 14 | + * @return integer |
|
| 15 | 15 | * @throws \EE_Validation_Error |
| 16 | 16 | */ |
| 17 | 17 | public function normalize($value_to_normalize) { |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @subpackage |
| 8 | 8 | * @author Mike Nelson |
| 9 | 9 | */ |
| 10 | -class EE_Int_Normalization extends EE_Normalization_Strategy_Base{ |
|
| 10 | +class EE_Int_Normalization extends EE_Normalization_Strategy_Base { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @param string $value_to_normalize |
@@ -15,33 +15,33 @@ discard block |
||
| 15 | 15 | * @throws \EE_Validation_Error |
| 16 | 16 | */ |
| 17 | 17 | public function normalize($value_to_normalize) { |
| 18 | - if( is_int( $value_to_normalize ) ){ |
|
| 18 | + if (is_int($value_to_normalize)) { |
|
| 19 | 19 | return $value_to_normalize; |
| 20 | 20 | } |
| 21 | - if( ! is_string( $value_to_normalize )){ |
|
| 22 | - throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) ); |
|
| 21 | + if ( ! is_string($value_to_normalize)) { |
|
| 22 | + throw new EE_Validation_Error(sprintf(__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), print_r($value_to_normalize, TRUE), gettype($value_to_normalize))); |
|
| 23 | 23 | } |
| 24 | 24 | $thousands_separator = EE_Config::instance()->currency->thsnds; |
| 25 | - $value_to_normalize = str_replace( $thousands_separator, "", $value_to_normalize ); |
|
| 26 | - $value_to_normalize = str_replace( array(" ","\t"), '', $value_to_normalize ); |
|
| 27 | - if ( preg_match( '/^\d+$/', $value_to_normalize )) { |
|
| 28 | - return intval( $value_to_normalize ); |
|
| 25 | + $value_to_normalize = str_replace($thousands_separator, "", $value_to_normalize); |
|
| 26 | + $value_to_normalize = str_replace(array(" ", "\t"), '', $value_to_normalize); |
|
| 27 | + if (preg_match('/^\d+$/', $value_to_normalize)) { |
|
| 28 | + return intval($value_to_normalize); |
|
| 29 | 29 | } else { |
| 30 | 30 | //find if this input has a int 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_Int_Validation_Strategy ){ |
|
| 33 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 34 | + if ($validation_strategy instanceof EE_Int_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 int normalization strategy |
| 39 | 39 | //should also have a int 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_Int_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, 'numeric_only' ); |
|
| 44 | + throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * @param int $normalized_value |
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | - public function unnormalize( $normalized_value ) { |
|
| 54 | - if( empty( $normalized_value ) ){ |
|
| 53 | + public function unnormalize($normalized_value) { |
|
| 54 | + if (empty($normalized_value)) { |
|
| 55 | 55 | return '0'; |
| 56 | - }else{ |
|
| 56 | + } else { |
|
| 57 | 57 | return "$normalized_value"; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Applies all teh individual item validation strategies on each item in the array |
| 29 | 29 | * @param array $normalized_value |
| 30 | - * @return boolean |
|
| 30 | + * @return boolean|null |
|
| 31 | 31 | */ |
| 32 | 32 | function validate($normalized_value) { |
| 33 | 33 | if( is_array($normalized_value)){ |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | * @since 4.6 |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Many_Valued_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 14 | +class EE_Many_Valued_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 15 | 15 | protected $_individual_item_validation_strategies = array(); |
| 16 | 16 | /** |
| 17 | 17 | * |
| 18 | 18 | * @param EE_Validation_Strategy_Base[] $individual_item_validation_strategies (or a single EE_Validation_Strategy_Base) |
| 19 | 19 | */ |
| 20 | 20 | public function __construct($individual_item_validation_strategies) { |
| 21 | - if( ! is_array($individual_item_validation_strategies)){ |
|
| 21 | + if ( ! is_array($individual_item_validation_strategies)) { |
|
| 22 | 22 | $individual_item_validation_strategies = array($individual_item_validation_strategies); |
| 23 | 23 | } |
| 24 | 24 | $this->_individual_item_validation_strategies = $individual_item_validation_strategies; |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | * @return boolean |
| 31 | 31 | */ |
| 32 | 32 | function validate($normalized_value) { |
| 33 | - if( is_array($normalized_value)){ |
|
| 33 | + if (is_array($normalized_value)) { |
|
| 34 | 34 | $items_to_validate = $normalized_value; |
| 35 | - }else{ |
|
| 35 | + } else { |
|
| 36 | 36 | $items_to_validate = array($normalized_value); |
| 37 | 37 | } |
| 38 | - foreach($items_to_validate as $individual_item){ |
|
| 39 | - foreach($this->_individual_item_validation_strategies as $validation_strategy){ |
|
| 40 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 38 | + foreach ($items_to_validate as $individual_item) { |
|
| 39 | + foreach ($this->_individual_item_validation_strategies as $validation_strategy) { |
|
| 40 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 41 | 41 | $validation_strategy->validate($individual_item); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function _construct_finalize(\EE_Form_Input_Base $form_input) { |
| 52 | 52 | parent::_construct_finalize($form_input); |
| 53 | - foreach($this->_individual_item_validation_strategies as $item_validation_strategy){ |
|
| 54 | - if ( $item_validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 53 | + foreach ($this->_individual_item_validation_strategies as $item_validation_strategy) { |
|
| 54 | + if ($item_validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 55 | 55 | $item_validation_strategy->_construct_finalize($form_input); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -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 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * just checks the field isn't blank |
| 27 | 27 | * |
| 28 | 28 | * @param $normalized_value |
| 29 | - * @return bool |
|
| 29 | + * @return boolean|null |
|
| 30 | 30 | * @throws \EE_Validation_Error |
| 31 | 31 | */ |
| 32 | 32 | function validate($normalized_value) { |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | if( $normalized_value ){ |
| 34 | 34 | if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){ |
| 35 | 35 | throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url'); |
| 36 | - }else{ |
|
| 36 | + } else{ |
|
| 37 | 37 | EE_Registry::instance()->load_helper('URL'); |
| 38 | 38 | if( ! EEH_URL::remote_file_exists( |
| 39 | 39 | $normalized_value, |
@@ -8,16 +8,16 @@ discard block |
||
| 8 | 8 | * @since 4.6 |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 11 | +class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @param null $validation_error_message |
| 15 | 15 | */ |
| 16 | - public function __construct( $validation_error_message = NULL ) { |
|
| 17 | - if( ! $validation_error_message ){ |
|
| 16 | + public function __construct($validation_error_message = NULL) { |
|
| 17 | + if ( ! $validation_error_message) { |
|
| 18 | 18 | $validation_error_message = __("Please enter a valid URL", "event_espresso"); |
| 19 | 19 | } |
| 20 | - parent::__construct( $validation_error_message ); |
|
| 20 | + parent::__construct($validation_error_message); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | * @throws \EE_Validation_Error |
| 31 | 31 | */ |
| 32 | 32 | function validate($normalized_value) { |
| 33 | - if( $normalized_value ){ |
|
| 34 | - if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){ |
|
| 35 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url'); |
|
| 36 | - }else{ |
|
| 37 | - if( ! EEH_URL::remote_file_exists( |
|
| 33 | + if ($normalized_value) { |
|
| 34 | + if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) { |
|
| 35 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); |
|
| 36 | + } else { |
|
| 37 | + if ( ! EEH_URL::remote_file_exists( |
|
| 38 | 38 | $normalized_value, |
| 39 | 39 | array( |
| 40 | 40 | 'sslverify' => false, |
| 41 | - 'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
| 42 | - ))){ |
|
| 41 | + 'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
| 42 | + ))) { |
|
| 43 | 43 | throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso"))); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | - function get_jquery_validation_rule_array(){ |
|
| 55 | - return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) ); |
|
| 54 | + function get_jquery_validation_rule_array() { |
|
| 55 | + return array('validUrl'=>true, 'messages' => array('validUrl' => $this->get_validation_error_message())); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | /** |
| 32 | 32 | * @param EE_Line_Item $line_item |
| 33 | 33 | * @param array $options |
| 34 | - * @return mixed |
|
| 34 | + * @return string |
|
| 35 | 35 | */ |
| 36 | 36 | public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
| 37 | 37 | |
@@ -14,17 +14,17 @@ |
||
| 14 | 14 | * ------------------------------------------------------------------------ |
| 15 | 15 | */ |
| 16 | 16 | /** |
| 17 | - * |
|
| 18 | - * Class EE_Receipt_Line_Item_Display_Strategy |
|
| 19 | - * |
|
| 20 | - * Description |
|
| 21 | - * |
|
| 22 | - * @package Event Espresso |
|
| 23 | - * @subpackage core |
|
| 24 | - * @author Brent Christensen |
|
| 25 | - * @since $VID:$ |
|
| 26 | - * |
|
| 27 | - */ |
|
| 17 | + * |
|
| 18 | + * Class EE_Receipt_Line_Item_Display_Strategy |
|
| 19 | + * |
|
| 20 | + * Description |
|
| 21 | + * |
|
| 22 | + * @package Event Espresso |
|
| 23 | + * @subpackage core |
|
| 24 | + * @author Brent Christensen |
|
| 25 | + * @since $VID:$ |
|
| 26 | + * |
|
| 27 | + */ |
|
| 28 | 28 | |
| 29 | 29 | class EE_Receipt_Line_Item_Display_Strategy implements EEI_Line_Item_Display { |
| 30 | 30 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $options |
| 34 | 34 | * @return mixed |
| 35 | 35 | */ |
| 36 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
| 36 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
| 37 | 37 | |
| 38 | 38 | $html = ''; |
| 39 | 39 | // set some default options and merge with incoming |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | 'show_desc' => TRUE, |
| 42 | 42 | 'odd' => FALSE |
| 43 | 43 | ); |
| 44 | - $options = array_merge( $default_options, (array)$options ); |
|
| 45 | - switch( $line_item->type() ) { |
|
| 44 | + $options = array_merge($default_options, (array) $options); |
|
| 45 | + switch ($line_item->type()) { |
|
| 46 | 46 | |
| 47 | 47 | case EEM_Line_Item::type_total: |
| 48 | 48 | // loop thru children |
| 49 | - foreach( $line_item->children() as $child_line_item ) { |
|
| 49 | + foreach ($line_item->children() as $child_line_item) { |
|
| 50 | 50 | // recursively feed children back into this method |
| 51 | 51 | // $html .= $this->display_line_item( $child_line_item, $options ); |
| 52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | case EEM_Line_Item::type_sub_total: |
| 59 | 59 | // loop thru children |
| 60 | - foreach( $line_item->children() as $child_line_item ) { |
|
| 60 | + foreach ($line_item->children() as $child_line_item) { |
|
| 61 | 61 | // recursively feed children back into this method |
| 62 | 62 | // $html .= $this->display_line_item( $child_line_item, $options ); |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | case EEM_Line_Item::type_tax_sub_total: |
| 69 | 69 | // loop thru children |
| 70 | - foreach( $line_item->children() as $child_line_item ) { |
|
| 70 | + foreach ($line_item->children() as $child_line_item) { |
|
| 71 | 71 | // recursively feed children back into this method |
| 72 | 72 | // $html .= $this->display_line_item( $child_line_item, $options ); |
| 73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // item row |
| 80 | 80 | // $html .= $this->_item_row( $line_item, $options ); |
| 81 | 81 | // got any kids? |
| 82 | - foreach( $line_item->children() as $child_line_item ) { |
|
| 82 | + foreach ($line_item->children() as $child_line_item) { |
|
| 83 | 83 | // $this->display_line_item( $child_line_item, $options ); |
| 84 | 84 | } |
| 85 | 85 | break; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @param EE_Line_Item $line_item |
| 69 | 69 | * @param array $options |
| 70 | - * @return mixed |
|
| 70 | + * @return string |
|
| 71 | 71 | */ |
| 72 | 72 | public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
| 73 | 73 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * _event_row - basically a Heading row displayed once above each event's ticket rows |
| 207 | 207 | * |
| 208 | 208 | * @param EE_Line_Item $line_item |
| 209 | - * @return mixed |
|
| 209 | + * @return string |
|
| 210 | 210 | */ |
| 211 | 211 | private function _event_row( EE_Line_Item $line_item ) { |
| 212 | 212 | // start of row |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @param EE_Line_Item $line_item |
| 227 | 227 | * @param array $options |
| 228 | - * @return mixed |
|
| 228 | + * @return string |
|
| 229 | 229 | */ |
| 230 | 230 | private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
| 231 | 231 | // start of row |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @param EE_Line_Item $line_item |
| 270 | 270 | * @param array $options |
| 271 | - * @return mixed |
|
| 271 | + * @return string |
|
| 272 | 272 | */ |
| 273 | 273 | private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
| 274 | 274 | // start of row |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @param EE_Line_Item $line_item |
| 316 | 316 | * @param array $options |
| 317 | - * @return mixed |
|
| 317 | + * @return string |
|
| 318 | 318 | */ |
| 319 | 319 | private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
| 320 | 320 | // start of row |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @param EE_Line_Item $line_item |
| 346 | 346 | * @param array $options |
| 347 | - * @return mixed |
|
| 347 | + * @return string |
|
| 348 | 348 | */ |
| 349 | 349 | private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
| 350 | 350 | // start of row |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @param EE_Line_Item $line_item |
| 375 | 375 | * @param string $text |
| 376 | 376 | * @param array $options |
| 377 | - * @return mixed |
|
| 377 | + * @return string |
|
| 378 | 378 | */ |
| 379 | 379 | private function _total_tax_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
| 380 | 380 | $html = ''; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @param EE_Line_Item $line_item |
| 402 | 402 | * @param string $text |
| 403 | 403 | * @param array $options |
| 404 | - * @return mixed |
|
| 404 | + * @return string |
|
| 405 | 405 | */ |
| 406 | 406 | private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
| 407 | 407 | $html = ''; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @param EE_Line_Item $line_item |
| 428 | 428 | * @param string $text |
| 429 | - * @return mixed |
|
| 429 | + * @return string |
|
| 430 | 430 | */ |
| 431 | 431 | private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
| 432 | 432 | // start of row |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | * _payments_and_amount_owing_rows |
| 447 | 447 | * |
| 448 | 448 | * @param EE_Line_Item $line_item |
| 449 | - * @return mixed |
|
| 449 | + * @return string |
|
| 450 | 450 | */ |
| 451 | 451 | private function _payments_and_amount_owing_rows( EE_Line_Item $line_item ) { |
| 452 | 452 | $html = ''; |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
| 2 | 2 | /** |
| 3 | - * |
|
| 4 | - * Class EE_SPCO_Line_Item_Display_Strategy |
|
| 5 | - * |
|
| 6 | - * Description |
|
| 7 | - * |
|
| 8 | - * @package Event Espresso |
|
| 9 | - * @subpackage core |
|
| 10 | - * @author Brent Christensen |
|
| 11 | - * @since $VID:$ |
|
| 12 | - * |
|
| 13 | - */ |
|
| 3 | + * |
|
| 4 | + * Class EE_SPCO_Line_Item_Display_Strategy |
|
| 5 | + * |
|
| 6 | + * Description |
|
| 7 | + * |
|
| 8 | + * @package Event Espresso |
|
| 9 | + * @subpackage core |
|
| 10 | + * @author Brent Christensen |
|
| 11 | + * @since $VID:$ |
|
| 12 | + * |
|
| 13 | + */ |
|
| 14 | 14 | |
| 15 | 15 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display { |
| 16 | 16 | |
@@ -69,101 +69,101 @@ discard block |
||
| 69 | 69 | * @param array $options |
| 70 | 70 | * @return mixed |
| 71 | 71 | */ |
| 72 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
| 72 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
| 73 | 73 | |
| 74 | 74 | $html = ''; |
| 75 | 75 | // set some default options and merge with incoming |
| 76 | 76 | $default_options = array( |
| 77 | - 'show_desc' => true, // true false |
|
| 77 | + 'show_desc' => true, // true false |
|
| 78 | 78 | 'odd' => false |
| 79 | 79 | ); |
| 80 | - $options = array_merge( $default_options, (array)$options ); |
|
| 80 | + $options = array_merge($default_options, (array) $options); |
|
| 81 | 81 | |
| 82 | - switch( $line_item->type() ) { |
|
| 82 | + switch ($line_item->type()) { |
|
| 83 | 83 | |
| 84 | 84 | case EEM_Line_Item::type_line_item: |
| 85 | 85 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
| 86 | - if ( $line_item->OBJ_type() == 'Ticket' ) { |
|
| 86 | + if ($line_item->OBJ_type() == 'Ticket') { |
|
| 87 | 87 | // item row |
| 88 | - $html .= $this->_ticket_row( $line_item, $options ); |
|
| 88 | + $html .= $this->_ticket_row($line_item, $options); |
|
| 89 | 89 | // got any kids? |
| 90 | - foreach ( $line_item->children() as $child_line_item ) { |
|
| 91 | - $this->display_line_item( $child_line_item, $options ); |
|
| 90 | + foreach ($line_item->children() as $child_line_item) { |
|
| 91 | + $this->display_line_item($child_line_item, $options); |
|
| 92 | 92 | } |
| 93 | 93 | } else { |
| 94 | 94 | // item row |
| 95 | - $html .= $this->_item_row( $line_item, $options ); |
|
| 95 | + $html .= $this->_item_row($line_item, $options); |
|
| 96 | 96 | // got any kids? |
| 97 | - foreach ( $line_item->children() as $child_line_item ) { |
|
| 98 | - $this->display_line_item( $child_line_item, $options ); |
|
| 97 | + foreach ($line_item->children() as $child_line_item) { |
|
| 98 | + $this->display_line_item($child_line_item, $options); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | break; |
| 102 | 102 | |
| 103 | 103 | case EEM_Line_Item::type_sub_line_item: |
| 104 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
| 104 | + $html .= $this->_sub_item_row($line_item, $options); |
|
| 105 | 105 | break; |
| 106 | 106 | |
| 107 | 107 | case EEM_Line_Item::type_sub_total: |
| 108 | 108 | static $sub_total = 0; |
| 109 | 109 | $event_sub_total = 0; |
| 110 | - $text = __( 'Sub-Total', 'event_espresso' ); |
|
| 111 | - if ( $line_item->OBJ_type() == 'Event' ) { |
|
| 112 | - $options[ 'event_id' ] = $event_id = $line_item->OBJ_ID(); |
|
| 113 | - if ( ! isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
| 114 | - $event = EEM_Event::instance()->get_one_by_ID( $options[ 'event_id' ] ); |
|
| 115 | - if ( $event instanceof EE_Event ) { |
|
| 116 | - if ( $event->default_registration_status() == EEM_Registration::status_id_not_approved ) { |
|
| 110 | + $text = __('Sub-Total', 'event_espresso'); |
|
| 111 | + if ($line_item->OBJ_type() == 'Event') { |
|
| 112 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
| 113 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
| 114 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
| 115 | + if ($event instanceof EE_Event) { |
|
| 116 | + if ($event->default_registration_status() == EEM_Registration::status_id_not_approved) { |
|
| 117 | 117 | return ''; |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | - $this->_events[ $options[ 'event_id' ] ] = 0; |
|
| 121 | - $html .= $this->_event_row( $line_item ); |
|
| 122 | - $text = __( 'Event Sub-Total', 'event_espresso' ); |
|
| 120 | + $this->_events[$options['event_id']] = 0; |
|
| 121 | + $html .= $this->_event_row($line_item); |
|
| 122 | + $text = __('Event Sub-Total', 'event_espresso'); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | $child_line_items = $line_item->children(); |
| 126 | 126 | // loop thru children |
| 127 | - foreach( $child_line_items as $child_line_item ) { |
|
| 127 | + foreach ($child_line_items as $child_line_item) { |
|
| 128 | 128 | // recursively feed children back into this method |
| 129 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
| 129 | + $html .= $this->display_line_item($child_line_item, $options); |
|
| 130 | 130 | } |
| 131 | - $event_sub_total += isset( $options[ 'event_id' ] ) ? $this->_events[ $options[ 'event_id' ] ] : 0; |
|
| 131 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
| 132 | 132 | $sub_total += $event_sub_total; |
| 133 | 133 | if ( |
| 134 | 134 | ( |
| 135 | 135 | // event subtotals |
| 136 | 136 | $line_item->code() != 'pre-tax-subtotal' && |
| 137 | - count( $child_line_items ) > 1 |
|
| 137 | + count($child_line_items) > 1 |
|
| 138 | 138 | ) |
| 139 | 139 | || |
| 140 | 140 | ( |
| 141 | 141 | // pre-tax subtotals |
| 142 | 142 | $line_item->code() == 'pre-tax-subtotal' && |
| 143 | - count( $this->_events ) > 1 |
|
| 143 | + count($this->_events) > 1 |
|
| 144 | 144 | ) |
| 145 | 145 | ) { |
| 146 | 146 | $options['sub_total'] = $line_item->OBJ_type() == 'Event' ? $event_sub_total : $sub_total; |
| 147 | - $html .= $this->_sub_total_row( $line_item, $text, $options ); |
|
| 147 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
| 148 | 148 | } |
| 149 | 149 | break; |
| 150 | 150 | |
| 151 | 151 | case EEM_Line_Item::type_tax: |
| 152 | - if ( $this->_show_taxes ) { |
|
| 153 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
| 152 | + if ($this->_show_taxes) { |
|
| 153 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
| 154 | 154 | } |
| 155 | 155 | break; |
| 156 | 156 | |
| 157 | 157 | case EEM_Line_Item::type_tax_sub_total: |
| 158 | - if ( $this->_show_taxes ) { |
|
| 158 | + if ($this->_show_taxes) { |
|
| 159 | 159 | $child_line_items = $line_item->children(); |
| 160 | 160 | // loop thru children |
| 161 | - foreach( $child_line_items as $child_line_item ) { |
|
| 161 | + foreach ($child_line_items as $child_line_item) { |
|
| 162 | 162 | // recursively feed children back into this method |
| 163 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
| 163 | + $html .= $this->display_line_item($child_line_item, $options); |
|
| 164 | 164 | } |
| 165 | - if ( count( $child_line_items ) > 1 ) { |
|
| 166 | - $this->_taxes_html .= $this->_total_tax_row( $line_item, __( 'Tax Total', 'event_espresso' ) ); |
|
| 165 | + if (count($child_line_items) > 1) { |
|
| 166 | + $this->_taxes_html .= $this->_total_tax_row($line_item, __('Tax Total', 'event_espresso')); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | break; |
@@ -172,25 +172,25 @@ discard block |
||
| 172 | 172 | // get all child line items |
| 173 | 173 | $children = $line_item->children(); |
| 174 | 174 | // loop thru all non-tax child line items |
| 175 | - foreach( $children as $child_line_item ) { |
|
| 176 | - if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) { |
|
| 175 | + foreach ($children as $child_line_item) { |
|
| 176 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
| 177 | 177 | // recursively feed children back into this method |
| 178 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
| 178 | + $html .= $this->display_line_item($child_line_item, $options); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // now loop thru tax child line items |
| 183 | - foreach( $children as $child_line_item ) { |
|
| 184 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) { |
|
| 183 | + foreach ($children as $child_line_item) { |
|
| 184 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
| 185 | 185 | // recursively feed children back into this method |
| 186 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
| 186 | + $html .= $this->display_line_item($child_line_item, $options); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | $html .= $this->_taxes_html; |
| 190 | - $html .= $this->_total_row( $line_item, __('Total', 'event_espresso') ); |
|
| 190 | + $html .= $this->_total_row($line_item, __('Total', 'event_espresso')); |
|
| 191 | 191 | |
| 192 | 192 | |
| 193 | - $html .= $this->_payments_and_amount_owing_rows( $line_item, $options ); |
|
| 193 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
| 194 | 194 | break; |
| 195 | 195 | |
| 196 | 196 | } |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | * @param EE_Line_Item $line_item |
| 206 | 206 | * @return mixed |
| 207 | 207 | */ |
| 208 | - private function _event_row( EE_Line_Item $line_item ) { |
|
| 208 | + private function _event_row(EE_Line_Item $line_item) { |
|
| 209 | 209 | // start of row |
| 210 | - $html = EEH_HTML::tr( '', 'event-cart-total-row', 'total_tr odd' ); |
|
| 210 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
| 211 | 211 | // event name td |
| 212 | - $html .= EEH_HTML::td( EEH_HTML::strong( $line_item->name() ), '', 'event-header', '', ' colspan="4"' ); |
|
| 212 | + $html .= EEH_HTML::td(EEH_HTML::strong($line_item->name()), '', 'event-header', '', ' colspan="4"'); |
|
| 213 | 213 | // end of row |
| 214 | 214 | $html .= EEH_HTML::trx(); |
| 215 | 215 | return $html; |
@@ -224,10 +224,10 @@ discard block |
||
| 224 | 224 | * @param array $options |
| 225 | 225 | * @return mixed |
| 226 | 226 | */ |
| 227 | - private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
|
| 227 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) { |
|
| 228 | 228 | // start of row |
| 229 | 229 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
| 230 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
| 230 | + $html = EEH_HTML::tr('', '', $row_class); |
|
| 231 | 231 | // name && desc |
| 232 | 232 | $name_and_desc = apply_filters( |
| 233 | 233 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
@@ -236,23 +236,23 @@ discard block |
||
| 236 | 236 | ); |
| 237 | 237 | $name_and_desc .= apply_filters( |
| 238 | 238 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
| 239 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
| 239 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
| 240 | 240 | $line_item, |
| 241 | 241 | $options |
| 242 | 242 | ); |
| 243 | 243 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
| 244 | 244 | // name td |
| 245 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
| 245 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
| 246 | 246 | // price td |
| 247 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
| 247 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 248 | 248 | // quantity td |
| 249 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
| 249 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 250 | 250 | $this->_total_items += $line_item->quantity(); |
| 251 | 251 | // determine total for line item |
| 252 | 252 | $total = $line_item->total(); |
| 253 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
| 253 | + $this->_events[$options['event_id']] += $total; |
|
| 254 | 254 | // total td |
| 255 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
| 255 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
| 256 | 256 | // end of row |
| 257 | 257 | $html .= EEH_HTML::trx(); |
| 258 | 258 | return $html; |
@@ -267,41 +267,41 @@ discard block |
||
| 267 | 267 | * @param array $options |
| 268 | 268 | * @return mixed |
| 269 | 269 | */ |
| 270 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
| 270 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
| 271 | 271 | // start of row |
| 272 | 272 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
| 273 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
| 274 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
| 273 | + $html = EEH_HTML::tr('', '', $row_class); |
|
| 274 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
| 275 | 275 | // name && desc |
| 276 | 276 | $name_and_desc = apply_filters( |
| 277 | 277 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
| 278 | - $obj_name . $line_item->name(), |
|
| 278 | + $obj_name.$line_item->name(), |
|
| 279 | 279 | $line_item |
| 280 | 280 | ); |
| 281 | 281 | $name_and_desc .= apply_filters( |
| 282 | 282 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
| 283 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
| 283 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
| 284 | 284 | $line_item, |
| 285 | 285 | $options |
| 286 | 286 | ); |
| 287 | 287 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
| 288 | 288 | // name td |
| 289 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l' ); |
|
| 289 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
| 290 | 290 | // price td |
| 291 | - if ( $line_item->is_percent() ) { |
|
| 292 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' ); |
|
| 291 | + if ($line_item->is_percent()) { |
|
| 292 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
| 293 | 293 | } else { |
| 294 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
| 294 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 295 | 295 | } |
| 296 | 296 | // quantity td |
| 297 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
| 297 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 298 | 298 | //$total = $line_item->total() * $line_item->quantity(); |
| 299 | 299 | $total = $line_item->total(); |
| 300 | - if( isset( $options[ 'event_id' ] ) && isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
| 301 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
| 300 | + if (isset($options['event_id']) && isset($this->_events[$options['event_id']])) { |
|
| 301 | + $this->_events[$options['event_id']] += $total; |
|
| 302 | 302 | } |
| 303 | 303 | // total td |
| 304 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
| 304 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
| 305 | 305 | // end of row |
| 306 | 306 | $html .= EEH_HTML::trx(); |
| 307 | 307 | return $html; |
@@ -316,22 +316,22 @@ discard block |
||
| 316 | 316 | * @param array $options |
| 317 | 317 | * @return mixed |
| 318 | 318 | */ |
| 319 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
| 319 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
| 320 | 320 | // start of row |
| 321 | - $html = EEH_HTML::tr( '', 'item sub-item-row' ); |
|
| 321 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
| 322 | 322 | // name && desc |
| 323 | 323 | $name_and_desc = $line_item->name(); |
| 324 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
| 324 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
| 325 | 325 | // name td |
| 326 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
| 326 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
| 327 | 327 | // discount/surcharge td |
| 328 | - if ( $line_item->is_percent() ) { |
|
| 329 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c' ); |
|
| 328 | + if ($line_item->is_percent()) { |
|
| 329 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
| 330 | 330 | } else { |
| 331 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
| 331 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 332 | 332 | } |
| 333 | 333 | // total td |
| 334 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
| 334 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
| 335 | 335 | // end of row |
| 336 | 336 | $html .= EEH_HTML::trx(); |
| 337 | 337 | return $html; |
@@ -346,21 +346,21 @@ discard block |
||
| 346 | 346 | * @param array $options |
| 347 | 347 | * @return mixed |
| 348 | 348 | */ |
| 349 | - private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
| 349 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
| 350 | 350 | // start of row |
| 351 | - $html = EEH_HTML::tr( '', 'item sub-item tax-total' ); |
|
| 351 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
| 352 | 352 | // name && desc |
| 353 | 353 | $name_and_desc = $line_item->name(); |
| 354 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>'; |
|
| 355 | - $name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : ''; |
|
| 354 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>'; |
|
| 355 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
| 356 | 356 | // name td |
| 357 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
| 357 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
| 358 | 358 | // percent td |
| 359 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', ' jst-rght', '' ); |
|
| 359 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
| 360 | 360 | // empty td (price) |
| 361 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
| 361 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 362 | 362 | // total td |
| 363 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
| 363 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
| 364 | 364 | // end of row |
| 365 | 365 | $html .= EEH_HTML::trx(); |
| 366 | 366 | return $html; |
@@ -375,17 +375,17 @@ discard block |
||
| 375 | 375 | * @param string $text |
| 376 | 376 | * @return mixed |
| 377 | 377 | */ |
| 378 | - private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) { |
|
| 378 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') { |
|
| 379 | 379 | $html = ''; |
| 380 | - if ( $line_item->total() ) { |
|
| 380 | + if ($line_item->total()) { |
|
| 381 | 381 | // start of row |
| 382 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
| 382 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 383 | 383 | // total td |
| 384 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' ); |
|
| 384 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"'); |
|
| 385 | 385 | // empty td (price) |
| 386 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
| 386 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 387 | 387 | // total td |
| 388 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
| 388 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
| 389 | 389 | // end of row |
| 390 | 390 | $html .= EEH_HTML::trx(); |
| 391 | 391 | } |
@@ -402,15 +402,15 @@ discard block |
||
| 402 | 402 | * @param array $options |
| 403 | 403 | * @return mixed |
| 404 | 404 | */ |
| 405 | - private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
| 405 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
| 406 | 406 | $html = ''; |
| 407 | - if ( $line_item->total() ) { |
|
| 407 | + if ($line_item->total()) { |
|
| 408 | 408 | // start of row |
| 409 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
| 409 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 410 | 410 | // total td |
| 411 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
| 411 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
| 412 | 412 | // total td |
| 413 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' ); |
|
| 413 | + $html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght'); |
|
| 414 | 414 | // end of row |
| 415 | 415 | $html .= EEH_HTML::trx(); |
| 416 | 416 | } |
@@ -427,13 +427,13 @@ discard block |
||
| 427 | 427 | * @param string $text |
| 428 | 428 | * @return mixed |
| 429 | 429 | */ |
| 430 | - private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
|
| 430 | + private function _total_row(EE_Line_Item $line_item, $text = '') { |
|
| 431 | 431 | // start of row |
| 432 | - $html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' ); |
|
| 432 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
| 433 | 433 | // total td |
| 434 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
| 434 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
| 435 | 435 | // total td |
| 436 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
| 436 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
| 437 | 437 | // end of row |
| 438 | 438 | $html .= EEH_HTML::trx(); |
| 439 | 439 | return $html; |
@@ -448,30 +448,30 @@ discard block |
||
| 448 | 448 | * @param array $options |
| 449 | 449 | * @return mixed |
| 450 | 450 | */ |
| 451 | - private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) { |
|
| 451 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) { |
|
| 452 | 452 | $html = ''; |
| 453 | 453 | $owing = $line_item->total(); |
| 454 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() ); |
|
| 455 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 454 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
| 455 | + if ($transaction instanceof EE_Transaction) { |
|
| 456 | 456 | $registration_payments = array(); |
| 457 | - $registrations = ! empty( $options['registrations'] ) |
|
| 458 | - ? $options[ 'registrations' ] |
|
| 457 | + $registrations = ! empty($options['registrations']) |
|
| 458 | + ? $options['registrations'] |
|
| 459 | 459 | : $transaction->registrations(); |
| 460 | - foreach ( $registrations as $registration ) { |
|
| 461 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
| 460 | + foreach ($registrations as $registration) { |
|
| 461 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 462 | 462 | $registration_payments = $registration_payments + $registration->registration_payments(); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | - if ( ! empty( $registration_payments )) { |
|
| 466 | - foreach ( $registration_payments as $registration_payment ) { |
|
| 467 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
| 465 | + if ( ! empty($registration_payments)) { |
|
| 466 | + foreach ($registration_payments as $registration_payment) { |
|
| 467 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
| 468 | 468 | $owing = $owing - $registration_payment->amount(); |
| 469 | 469 | $payment = $registration_payment->payment(); |
| 470 | - if ( $payment instanceof EE_Payment ) { |
|
| 470 | + if ($payment instanceof EE_Payment) { |
|
| 471 | 471 | $payment_desc = sprintf( |
| 472 | - __( 'Payment%1$s Received: %2$s', 'event_espresso' ), |
|
| 472 | + __('Payment%1$s Received: %2$s', 'event_espresso'), |
|
| 473 | 473 | $payment->txn_id_chq_nmbr() != '' |
| 474 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
| 474 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
| 475 | 475 | : '', |
| 476 | 476 | $payment->timestamp() |
| 477 | 477 | ); |
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | $payment_desc = ''; |
| 480 | 480 | } |
| 481 | 481 | // start of row |
| 482 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
| 482 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 483 | 483 | // payment desc |
| 484 | - $html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' ); |
|
| 484 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
| 485 | 485 | // total td |
| 486 | 486 | $html .= EEH_HTML::td( |
| 487 | - EEH_Template::format_currency( $registration_payment->amount(), false, false ), |
|
| 487 | + EEH_Template::format_currency($registration_payment->amount(), false, false), |
|
| 488 | 488 | '', |
| 489 | 489 | 'total jst-rght' |
| 490 | 490 | ); |
@@ -492,17 +492,17 @@ discard block |
||
| 492 | 492 | $html .= EEH_HTML::trx(); |
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | - if ( $line_item->total() ) { |
|
| 495 | + if ($line_item->total()) { |
|
| 496 | 496 | // start of row |
| 497 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
| 497 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 498 | 498 | // total td |
| 499 | 499 | $html .= EEH_HTML::td( |
| 500 | 500 | __('Amount Owing', 'event_espresso'), |
| 501 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
| 501 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
| 502 | 502 | ); |
| 503 | 503 | // total td |
| 504 | 504 | $html .= EEH_HTML::td( |
| 505 | - EEH_Template::format_currency( $owing, false, false ), '', 'total jst-rght' |
|
| 505 | + EEH_Template::format_currency($owing, false, false), '', 'total jst-rght' |
|
| 506 | 506 | ); |
| 507 | 507 | // end of row |
| 508 | 508 | $html .= EEH_HTML::trx(); |
@@ -316,6 +316,7 @@ |
||
| 316 | 316 | * @param EE_message_type $message_type |
| 317 | 317 | * @param string $field The field reference for the specific template being looked up. |
| 318 | 318 | * @param string $context The context reference for the specific template being looked up |
| 319 | + * @param EE_Messages_Template_Pack_Default|null $default_pack |
|
| 319 | 320 | * |
| 320 | 321 | * @return string The template contents. |
| 321 | 322 | */ |
@@ -5,7 +5,9 @@ discard block |
||
| 5 | 5 | * @subpackage messages |
| 6 | 6 | * @since 4.5.0 |
| 7 | 7 | */ |
| 8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 9 | + exit('No direct script access allowed'); |
|
| 10 | +} |
|
| 9 | 11 | |
| 10 | 12 | /** |
| 11 | 13 | * EE_Template_Packs are classes that contain all the information related to messages templates for a given "template pack". |
@@ -282,8 +284,9 @@ discard block |
||
| 282 | 284 | |
| 283 | 285 | foreach ( $contexts as $context => $details ) { |
| 284 | 286 | foreach ( $fields as $field => $field_details ) { |
| 285 | - if ( empty( $field_details ) ) |
|
| 286 | - continue; |
|
| 287 | + if ( empty( $field_details ) ) { |
|
| 288 | + continue; |
|
| 289 | + } |
|
| 287 | 290 | /** |
| 288 | 291 | * is this a field array (linked to a main field)? |
| 289 | 292 | */ |
@@ -167,44 +167,44 @@ discard block |
||
| 167 | 167 | public function __construct() { |
| 168 | 168 | $this->_set_props(); |
| 169 | 169 | //make sure classname is correct |
| 170 | - $classname = get_class( $this ); |
|
| 170 | + $classname = get_class($this); |
|
| 171 | 171 | //make sure required props have been set |
| 172 | 172 | |
| 173 | 173 | //if label is empty then throw an error because we should have it defined by now. |
| 174 | - if ( ! isset( $this->label ) ) { |
|
| 175 | - throw new EE_Error( sprintf( __('The label property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
| 174 | + if ( ! isset($this->label)) { |
|
| 175 | + throw new EE_Error(sprintf(__('The label property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | //the reference for this template pack |
| 180 | - if ( ! isset( $this->dbref ) ) { |
|
| 181 | - throw new EE_Error( sprintf( __('The dbref property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
| 180 | + if ( ! isset($this->dbref)) { |
|
| 181 | + throw new EE_Error(sprintf(__('The dbref property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | //make sure dbref is safe |
| 185 | - $this->dbref = str_replace( '-', '_', sanitize_key( $this->dbref ) ); |
|
| 185 | + $this->dbref = str_replace('-', '_', sanitize_key($this->dbref)); |
|
| 186 | 186 | |
| 187 | - $should_be = 'EE_Messages_Template_Pack_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $this->dbref ) ) ); |
|
| 187 | + $should_be = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref))); |
|
| 188 | 188 | |
| 189 | - if ( $should_be !== $classname ) { |
|
| 190 | - throw new EE_Error( sprintf( __('The name of the template pack instantiated class is "%s". It should be "%s". Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso' ), $classname, $should_be ) ); |
|
| 189 | + if ($should_be !== $classname) { |
|
| 190 | + throw new EE_Error(sprintf(__('The name of the template pack instantiated class is "%s". It should be "%s". Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be)); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | //if _base_path is not set then throw an error because a base path string is needed. |
| 194 | - if ( empty( $this->_base_path ) ) { |
|
| 195 | - throw new EE_Error( sprintf( __('The _base_path property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
| 194 | + if (empty($this->_base_path)) { |
|
| 195 | + throw new EE_Error(sprintf(__('The _base_path property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | //if _base_url is not set then throw an error because a string is needed for variations. |
| 200 | - if ( empty( $this->_base_url ) ) { |
|
| 201 | - throw new EE_Error( sprintf( __('The _base_url property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
| 200 | + if (empty($this->_base_url)) { |
|
| 201 | + throw new EE_Error(sprintf(__('The _base_url property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
| 205 | 205 | //if $supports is not set then throw an error because that effectively means this template_pack does not have any templates! |
| 206 | - if ( empty( $this->_supports ) ) { |
|
| 207 | - throw new EE_Error( sprintf( __('The supports property is not set for %s. Please ensure that is set for the class.', 'event_espresso' ), $classname ) ); |
|
| 206 | + if (empty($this->_supports)) { |
|
| 207 | + throw new EE_Error(sprintf(__('The supports property is not set for %s. Please ensure that is set for the class.', 'event_espresso'), $classname)); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @return array |
| 243 | 243 | */ |
| 244 | - public function get_templates( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 245 | - return isset( $this->_templates[$messenger->name][$message_type->name] ) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates( $messenger, $message_type ); |
|
| 244 | + public function get_templates(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 245 | + return isset($this->_templates[$messenger->name][$message_type->name]) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates($messenger, $message_type); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @return array Returns an multi-level associative array indexed by template context and field in the format: |
| 260 | 260 | * array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) ); |
| 261 | 261 | */ |
| 262 | - protected function _get_templates( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 262 | + protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 263 | 263 | $templates = array(); |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -278,28 +278,28 @@ discard block |
||
| 278 | 278 | $contexts = $message_type->get_contexts(); |
| 279 | 279 | |
| 280 | 280 | |
| 281 | - foreach ( $contexts as $context => $details ) { |
|
| 282 | - foreach ( $fields as $field => $field_details ) { |
|
| 283 | - if ( empty( $field_details ) ) |
|
| 281 | + foreach ($contexts as $context => $details) { |
|
| 282 | + foreach ($fields as $field => $field_details) { |
|
| 283 | + if (empty($field_details)) |
|
| 284 | 284 | continue; |
| 285 | 285 | /** |
| 286 | 286 | * is this a field array (linked to a main field)? |
| 287 | 287 | */ |
| 288 | - if ( $field == 'extra' ) { |
|
| 289 | - foreach ( $field_details as $main_field => $sub_fields ) { |
|
| 290 | - foreach ( $sub_fields as $sub_field => $sub_field_details ) { |
|
| 288 | + if ($field == 'extra') { |
|
| 289 | + foreach ($field_details as $main_field => $sub_fields) { |
|
| 290 | + foreach ($sub_fields as $sub_field => $sub_field_details) { |
|
| 291 | 291 | //make sure that the template_field_ref matches what the main template field is for this template group. |
| 292 | 292 | $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field; |
| 293 | - $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template( $default_pack, $messenger, $message_type, $template_field_ref, $context ); |
|
| 293 | + $templates[$context][$main_field][$sub_field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | } else { |
| 297 | - $templates[ $context ][ $field ] = $this->_get_specific_template( $default_pack, $messenger, $message_type, $field, $context ); |
|
| 297 | + $templates[$context][$field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $templates = apply_filters( 'FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this ); |
|
| 302 | + $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this); |
|
| 303 | 303 | |
| 304 | 304 | $this->_templates[$messenger->name][$message_type->name] = $templates; |
| 305 | 305 | return $templates; |
@@ -317,22 +317,22 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return string The template contents. |
| 319 | 319 | */ |
| 320 | - protected function _get_specific_template( $default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context ) { |
|
| 320 | + protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context) { |
|
| 321 | 321 | |
| 322 | 322 | //default templates |
| 323 | - $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates( $messenger, $message_type ) : array(); |
|
| 323 | + $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array(); |
|
| 324 | 324 | |
| 325 | 325 | //first we allow for the $_base_path to be filtered. However, we assign this to a new variable so that we have the original base_path as a fallback. |
| 326 | - $filtered_base_path = apply_filters( 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this ); |
|
| 326 | + $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this); |
|
| 327 | 327 | |
| 328 | 328 | $master_templates = $message_type->get_master_templates(); |
| 329 | - $master_templates_mt = isset( $master_templates[$messenger->name] ) ? $master_templates[$messenger->name] : $message_type->name; |
|
| 330 | - $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php'; |
|
| 331 | - $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php'; |
|
| 332 | - $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php'; |
|
| 333 | - $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php'; |
|
| 334 | - $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php'; |
|
| 335 | - $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php'; |
|
| 329 | + $master_templates_mt = isset($master_templates[$messenger->name]) ? $master_templates[$messenger->name] : $message_type->name; |
|
| 330 | + $full_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'_'.$context.'.template.php'; |
|
| 331 | + $fallback_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'.template.php'; |
|
| 332 | + $mt_defined_full_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php'; |
|
| 333 | + $mt_defined_fallback_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php'; |
|
| 334 | + $base_defined_full_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php'; |
|
| 335 | + $base_defined_fallback_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php'; |
|
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * Template checks are done hierarchically in the following order: |
@@ -346,28 +346,28 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | |
| 348 | 348 | |
| 349 | - if ( is_readable( $full_path ) ) { |
|
| 349 | + if (is_readable($full_path)) { |
|
| 350 | 350 | $actual_path = $full_path; |
| 351 | - } elseif ( is_readable( $fallback_path ) ) { |
|
| 351 | + } elseif (is_readable($fallback_path)) { |
|
| 352 | 352 | $actual_path = $fallback_path; |
| 353 | - } elseif ( is_readable( $mt_defined_full_path ) ) { |
|
| 353 | + } elseif (is_readable($mt_defined_full_path)) { |
|
| 354 | 354 | $actual_path = $mt_defined_full_path; |
| 355 | - } elseif ( is_readable( $mt_defined_fallback_path ) ) { |
|
| 355 | + } elseif (is_readable($mt_defined_fallback_path)) { |
|
| 356 | 356 | $actual_path = $mt_defined_fallback_path; |
| 357 | - } elseif ( is_readable( $base_defined_full_path ) ) { |
|
| 357 | + } elseif (is_readable($base_defined_full_path)) { |
|
| 358 | 358 | $actual_path = $base_defined_full_path; |
| 359 | - } elseif ( is_readable( $base_defined_fallback_path ) ) { |
|
| 359 | + } elseif (is_readable($base_defined_fallback_path)) { |
|
| 360 | 360 | $actual_path = $base_defined_fallback_path; |
| 361 | - } else { |
|
| 361 | + } else { |
|
| 362 | 362 | $actual_path = ''; |
| 363 | 363 | } |
| 364 | - if ( empty( $actual_path ) ) { |
|
| 365 | - $contents = isset( $default_templates[$context][$field] ) ? $default_templates[$context][$field] : ''; |
|
| 364 | + if (empty($actual_path)) { |
|
| 365 | + $contents = isset($default_templates[$context][$field]) ? $default_templates[$context][$field] : ''; |
|
| 366 | 366 | } else { |
| 367 | - $contents = EEH_Template::display_template( $actual_path, array(), TRUE ); |
|
| 367 | + $contents = EEH_Template::display_template($actual_path, array(), TRUE); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this ); |
|
| 370 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * @return array |
| 383 | 383 | */ |
| 384 | 384 | public function get_supports() { |
| 385 | - $supports = apply_filters( 'FHEE__' . get_class( $this ) . '__get_supports', $this->_supports ); |
|
| 386 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this ); |
|
| 385 | + $supports = apply_filters('FHEE__'.get_class($this).'__get_supports', $this->_supports); |
|
| 386 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | |
@@ -398,11 +398,11 @@ discard block |
||
| 398 | 398 | * |
| 399 | 399 | * @return array|string |
| 400 | 400 | */ |
| 401 | - public function get_default_variation_labels( $messenger = '' ) { |
|
| 402 | - $label = empty( $messenger ) ? $this->_default_variation_labels : array(); |
|
| 403 | - $label = empty( $label ) && ! empty( $this->_default_variation_labels[$messenger] ) ? $this->_default_variation_labels[$messenger] : __('Default', 'event_espresso'); |
|
| 401 | + public function get_default_variation_labels($messenger = '') { |
|
| 402 | + $label = empty($messenger) ? $this->_default_variation_labels : array(); |
|
| 403 | + $label = empty($label) && ! empty($this->_default_variation_labels[$messenger]) ? $this->_default_variation_labels[$messenger] : __('Default', 'event_espresso'); |
|
| 404 | 404 | |
| 405 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger ); |
|
| 405 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | |
@@ -418,25 +418,25 @@ discard block |
||
| 418 | 418 | * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set). Otherwise the array of variations per message type are returned. If message_type is provided but NOT the messenger, then just all variations for all messengers are returned. |
| 419 | 419 | * @return array |
| 420 | 420 | */ |
| 421 | - public function get_variations( $messenger = '', $message_type = '' ) { |
|
| 422 | - $messenger_variations = ! empty( $messenger ) && isset( $this->_variations[$messenger] ) ? $this->_variations[$messenger] : array(); |
|
| 421 | + public function get_variations($messenger = '', $message_type = '') { |
|
| 422 | + $messenger_variations = ! empty($messenger) && isset($this->_variations[$messenger]) ? $this->_variations[$messenger] : array(); |
|
| 423 | 423 | |
| 424 | 424 | //message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present. |
| 425 | - $variations = !empty( $messenger ) && !empty( $message_type ) && isset( $messenger_variations[$message_type] ) ? $messenger_variations[$message_type] : array(); |
|
| 425 | + $variations = ! empty($messenger) && ! empty($message_type) && isset($messenger_variations[$message_type]) ? $messenger_variations[$message_type] : array(); |
|
| 426 | 426 | |
| 427 | 427 | //now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type). |
| 428 | - $variations = empty( $variations ) && !empty( $messenger ) && empty( $message_type ) ? $messenger_variations : $variations; |
|
| 428 | + $variations = empty($variations) && ! empty($messenger) && empty($message_type) ? $messenger_variations : $variations; |
|
| 429 | 429 | |
| 430 | 430 | //filter per template pack and globally. |
| 431 | - $variations = apply_filters( 'FHEE__' . get_class( $this ) . '__get_variations', $variations, $messenger, $message_type ); |
|
| 432 | - $variations = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this ); |
|
| 431 | + $variations = apply_filters('FHEE__'.get_class($this).'__get_variations', $variations, $messenger, $message_type); |
|
| 432 | + $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this); |
|
| 433 | 433 | |
| 434 | 434 | //prepend the _default_variation, but ONLY if we're returning the fully validated array. |
| 435 | - if ( !empty( $messenger ) && !empty( $message_type ) && ! empty( $variations ) ) { |
|
| 436 | - $variations = array( 'default' => $this->get_default_variation_labels( $messenger ) ) + $variations; |
|
| 435 | + if ( ! empty($messenger) && ! empty($message_type) && ! empty($variations)) { |
|
| 436 | + $variations = array('default' => $this->get_default_variation_labels($messenger)) + $variations; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - return empty( $variations ) ? array( 'default' => $this->get_default_variation_labels('dft') ): $variations; |
|
| 439 | + return empty($variations) ? array('default' => $this->get_default_variation_labels('dft')) : $variations; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | |
@@ -457,39 +457,39 @@ discard block |
||
| 457 | 457 | * |
| 458 | 458 | * @return string The variation path or url (typically css reference) |
| 459 | 459 | */ |
| 460 | - public function get_variation( $messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = FALSE ) { |
|
| 460 | + public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = FALSE) { |
|
| 461 | 461 | |
| 462 | 462 | $base = $url ? $this->_base_url : $this->_base_path; |
| 463 | 463 | $base_path = $this->_base_path; |
| 464 | 464 | |
| 465 | - if ( ! $skip_filters ) { |
|
| 466 | - $base = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this ); |
|
| 467 | - $base_path = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, FALSE, $file_extension, $this ); |
|
| 465 | + if ( ! $skip_filters) { |
|
| 466 | + $base = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this); |
|
| 467 | + $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, FALSE, $file_extension, $this); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $default_pack = get_class( $this ) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this; |
|
| 470 | + $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this; |
|
| 471 | 471 | |
| 472 | 472 | //possible variation paths considering whether message type is present or not in the file name. |
| 473 | - $path_string = 'variations/' . $messenger . '_' . $message_type . '_' . $type . '_' . $variation . $file_extension; |
|
| 474 | - $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
| 473 | + $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_'.$variation.$file_extension; |
|
| 474 | + $default_path_string = 'variations/'.$messenger.'_'.$type.'_'.$variation.$file_extension; |
|
| 475 | 475 | |
| 476 | 476 | //first see if fully validated file exists. |
| 477 | - if ( is_readable( $base_path . $path_string ) ) { |
|
| 478 | - $variation_path = $base . $path_string; |
|
| 477 | + if (is_readable($base_path.$path_string)) { |
|
| 478 | + $variation_path = $base.$path_string; |
|
| 479 | 479 | //otherwise see if default exists. |
| 480 | - } elseif ( is_readable( $base_path . $default_path_string ) ) { |
|
| 481 | - $variation_path = $base . $default_path_string; |
|
| 480 | + } elseif (is_readable($base_path.$default_path_string)) { |
|
| 481 | + $variation_path = $base.$default_path_string; |
|
| 482 | 482 | } else { |
| 483 | - $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation( $messenger, $message_type, $type, $url, $file_extension ) : ''; |
|
| 483 | + $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : ''; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - if ( $skip_filters ) { |
|
| 486 | + if ($skip_filters) { |
|
| 487 | 487 | return $variation_path; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | //filter result |
| 491 | - $variation_path = apply_filters( 'FHEE__' . get_class( $this ) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url ); |
|
| 492 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this ); |
|
| 491 | + $variation_path = apply_filters('FHEE__'.get_class($this).'__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url); |
|
| 492 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | |
@@ -504,19 +504,19 @@ discard block |
||
| 504 | 504 | * |
| 505 | 505 | * @return string returns the path for the requested wrapper template. |
| 506 | 506 | */ |
| 507 | - public function get_wrapper( $messenger, $type = 'main' ) { |
|
| 508 | - $default_pack = get_class( $this ) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : NULL; |
|
| 507 | + public function get_wrapper($messenger, $type = 'main') { |
|
| 508 | + $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : NULL; |
|
| 509 | 509 | |
| 510 | - $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php'; |
|
| 510 | + $path_string = $this->_base_path.$messenger.'_'.$type.'_wrapper.template.php'; |
|
| 511 | 511 | |
| 512 | - if ( is_readable( $path_string ) ) { |
|
| 512 | + if (is_readable($path_string)) { |
|
| 513 | 513 | $template = $path_string; |
| 514 | 514 | } else { |
| 515 | - $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper( $messenger, $type ) : ''; |
|
| 515 | + $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : ''; |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | //filter |
| 519 | - $template = apply_filters( 'FHEE__' . get_class( $this ) . '__get_wrapper', $template, $messenger, $type ); |
|
| 520 | - return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this ); |
|
| 519 | + $template = apply_filters('FHEE__'.get_class($this).'__get_wrapper', $template, $messenger, $type); |
|
| 520 | + return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this); |
|
| 521 | 521 | } |
| 522 | 522 | } |
@@ -332,7 +332,7 @@ |
||
| 332 | 332 | |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | - * @return string |
|
| 335 | + * @return boolean|null |
|
| 336 | 336 | */ |
| 337 | 337 | protected function _preview() { return $this->_send_message(); } |
| 338 | 338 | |
@@ -6,8 +6,9 @@ |
||
| 6 | 6 | * @package Event Espresso |
| 7 | 7 | * @subpackage messages |
| 8 | 8 | */ |
| 9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
| 10 | 10 | exit('NO direct script access allowed'); |
| 11 | +} |
|
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Event Espresso |
| 7 | 7 | * @subpackage messages |
| 8 | 8 | */ |
| 9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 10 | 10 | exit('NO direct script access allowed'); |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @subpackage messages |
| 21 | 21 | * @author Darren Ethier |
| 22 | 22 | */ |
| 23 | -class EE_Pdf_messenger extends EE_messenger { |
|
| 23 | +class EE_Pdf_messenger extends EE_messenger { |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @see abstract declaration in EE_messenger for details. |
| 66 | 66 | */ |
| 67 | 67 | protected function _set_admin_pages() { |
| 68 | - $this->admin_registered_pages = array( 'events_edit' => false ); |
|
| 68 | + $this->admin_registered_pages = array('events_edit' => false); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | protected function _set_validator_config() { |
| 86 | 86 | $this->_validator_config = array( |
| 87 | 87 | 'subject' => array( |
| 88 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
| 88 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
| 89 | 89 | ), |
| 90 | 90 | 'content' => array( |
| 91 | - 'shortcodes' => array( 'recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
| 91 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
| 92 | 92 | ), |
| 93 | 93 | 'attendee_list' => array( |
| 94 | 94 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | 'required' => array('[EVENT_LIST]') |
| 100 | 100 | ), |
| 101 | 101 | 'ticket_list' => array( |
| 102 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'), |
|
| 102 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
| 103 | 103 | 'required' => array('[TICKET_LIST]') |
| 104 | 104 | ), |
| 105 | 105 | 'datetime_list' => array( |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function enqueue_scripts_styles() { |
| 121 | 121 | parent::enqueue_scripts_styles(); |
| 122 | - do_action( 'AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
| 122 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -245,18 +245,18 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | protected function _send_message() { |
| 247 | 247 | $this->_template_args = array( |
| 248 | - 'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8"), |
|
| 249 | - 'base_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation ), |
|
| 250 | - 'print_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation ), |
|
| 251 | - 'main_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation ), |
|
| 252 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
| 253 | - 'main_body' => apply_filters( 'FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep( html_entity_decode($this->_content, ENT_QUOTES,"UTF-8" ) )), $this->_content ) |
|
| 248 | + 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
| 249 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation), |
|
| 250 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation), |
|
| 251 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation), |
|
| 252 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
| 253 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $this->_content) |
|
| 254 | 254 | ); |
| 255 | 255 | $this->_deregister_wp_hooks(); |
| 256 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
| 256 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
| 257 | 257 | $content = $this->_get_main_template(); |
| 258 | 258 | // die( $content ); |
| 259 | - $this->_do_pdf( $content ); |
|
| 259 | + $this->_do_pdf($content); |
|
| 260 | 260 | exit(0); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
| 282 | 282 | add_action('wp_head', 'wp_enqueue_scripts'); |
| 283 | - add_action( 'wp_footer', 'wp_print_footer_scripts' ); |
|
| 284 | - add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
| 283 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
| 284 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | * @param bool $preview |
| 295 | 295 | * @return string |
| 296 | 296 | */ |
| 297 | - protected function _get_main_template( $preview = FALSE ) { |
|
| 298 | - $wrapper_template = $this->_tmp_pack->get_wrapper( 'html', 'main' ); |
|
| 297 | + protected function _get_main_template($preview = FALSE) { |
|
| 298 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
| 299 | 299 | //add message type to template_args |
| 300 | 300 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
| 301 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
| 301 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
@@ -311,21 +311,21 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | - protected function _do_pdf( $content = '' ) { |
|
| 315 | - $invoice_name = html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8"); |
|
| 314 | + protected function _do_pdf($content = '') { |
|
| 315 | + $invoice_name = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8"); |
|
| 316 | 316 | |
| 317 | 317 | //only load dompdf if nobody else has yet... |
| 318 | - if( ! defined('DOMPDF_DIR')){ |
|
| 318 | + if ( ! defined('DOMPDF_DIR')) { |
|
| 319 | 319 | define('DOMPDF_ENABLE_REMOTE', TRUE); |
| 320 | 320 | define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
| 321 | 321 | define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
| 322 | - require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
| 322 | + require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php'); |
|
| 323 | 323 | } |
| 324 | 324 | $dompdf = new DOMPDF(); |
| 325 | 325 | $dompdf->load_html($content); |
| 326 | 326 | $dompdf->render(); |
| 327 | 327 | //forcing the browser to open a download dialog. |
| 328 | - $dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => TRUE )); |
|
| 328 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => TRUE)); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |