@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - * @throws \EE_Error |
|
62 | - */ |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + * @throws \EE_Error |
|
62 | + */ |
|
63 | 63 | public function generate_reg_form() { |
64 | 64 | // create empty form so that things don't break |
65 | 65 | $this->reg_form = new EE_Form_Section_Proper(); |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return boolean |
|
73 | - * @throws \RuntimeException |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
71 | + /** |
|
72 | + * @return boolean |
|
73 | + * @throws \RuntimeException |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | 76 | public function process_reg_step() { |
77 | - // ensure all data gets refreshed from the db |
|
77 | + // ensure all data gets refreshed from the db |
|
78 | 78 | $this->checkout->refresh_all_entities( true ); |
79 | 79 | // ensures that all details and statuses for transaction, registration, and payments are updated |
80 | 80 | $txn_update_params = $this->_finalize_transaction(); |
81 | - // maybe send messages |
|
82 | - $this->_set_notification_triggers(); |
|
83 | - // send messages |
|
84 | - /** @type EE_Registration_Processor $registration_processor */ |
|
85 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
86 | - $registration_processor->trigger_registration_update_notifications( |
|
87 | - $this->checkout->transaction->primary_registration(), |
|
88 | - $txn_update_params |
|
89 | - ); |
|
90 | - // set a hook point |
|
81 | + // maybe send messages |
|
82 | + $this->_set_notification_triggers(); |
|
83 | + // send messages |
|
84 | + /** @type EE_Registration_Processor $registration_processor */ |
|
85 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
86 | + $registration_processor->trigger_registration_update_notifications( |
|
87 | + $this->checkout->transaction->primary_registration(), |
|
88 | + $txn_update_params |
|
89 | + ); |
|
90 | + // set a hook point |
|
91 | 91 | do_action( |
92 | 92 | 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', |
93 | 93 | $this->checkout, |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if ( |
105 | 105 | ! ( |
106 | 106 | $this->checkout->payment_method instanceof EE_Payment_Method |
107 | - && $this->checkout->payment_method->is_off_site() |
|
107 | + && $this->checkout->payment_method->is_off_site() |
|
108 | 108 | ) |
109 | 109 | ) { |
110 | 110 | // mark this reg step as completed |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * _finalize_transaction |
|
121 | - * ensures that all details and statuses for transaction, registration, and payments are updated |
|
122 | - * |
|
123 | - * @return array |
|
124 | - * @throws \RuntimeException |
|
125 | - * @throws \EE_Error |
|
126 | - */ |
|
119 | + /** |
|
120 | + * _finalize_transaction |
|
121 | + * ensures that all details and statuses for transaction, registration, and payments are updated |
|
122 | + * |
|
123 | + * @return array |
|
124 | + * @throws \RuntimeException |
|
125 | + * @throws \EE_Error |
|
126 | + */ |
|
127 | 127 | protected function _finalize_transaction() { |
128 | 128 | /** @type EE_Transaction_Processor $transaction_processor */ |
129 | 129 | $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | } |
140 | 140 | // maybe update status, but don't save transaction just yet |
141 | 141 | $this->checkout->transaction->update_status_based_on_total_paid( false ); |
142 | - // this will result in the base session properties getting saved to the TXN_Session_data field |
|
142 | + // this will result in the base session properties getting saved to the TXN_Session_data field |
|
143 | 143 | $this->checkout->transaction->set_txn_session_data( |
144 | 144 | EE_Registry::instance()->SSN->get_session_data( null, true ) |
145 | 145 | ); |
146 | - // update the TXN if payment conditions have changed, but do NOT trigger notifications, |
|
147 | - // because we will do that in process_reg_step() after setting some more triggers |
|
146 | + // update the TXN if payment conditions have changed, but do NOT trigger notifications, |
|
147 | + // because we will do that in process_reg_step() after setting some more triggers |
|
148 | 148 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
149 | 149 | $this->checkout->transaction, |
150 | 150 | $this->checkout->payment, |
151 | 151 | $this->checkout->reg_cache_where_params, |
152 | - false |
|
152 | + false |
|
153 | 153 | ); |
154 | 154 | } |
155 | 155 | |
@@ -167,43 +167,43 @@ discard block |
||
167 | 167 | protected function _set_notification_triggers() { |
168 | 168 | |
169 | 169 | if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
170 | - // let's start with the assumption that we need to trigger notifications |
|
171 | - // then toggle this to false for conditions where we know we don't need to |
|
172 | - $deliver_notifications = true; |
|
173 | - if ( |
|
174 | - // if SPCO revisit |
|
175 | - filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN) |
|
176 | - // and TXN or REG statuses have NOT changed due to a payment |
|
177 | - && ! ( |
|
178 | - $this->checkout->transaction->txn_status_updated() |
|
179 | - || $this->checkout->any_reg_status_updated() |
|
180 | - ) |
|
181 | - ) { |
|
182 | - $deliver_notifications = false; |
|
183 | - } |
|
184 | - if ($this->checkout->payment_method->is_off_site()) { |
|
185 | - /** @var EE_Gateway $gateway */ |
|
186 | - $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
187 | - // and the gateway uses a separate request to process the IPN |
|
188 | - if ( |
|
189 | - $gateway instanceof EE_Offsite_Gateway |
|
190 | - && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true) |
|
191 | - ) { |
|
192 | - // IPN request will handle triggering notifications |
|
193 | - $deliver_notifications = false; |
|
194 | - // no really... don't send any notices in this request |
|
195 | - remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
196 | - add_filter( |
|
197 | - 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
|
198 | - '__return_false', |
|
199 | - 15 |
|
200 | - ); |
|
201 | - } |
|
202 | - } |
|
203 | - if ($deliver_notifications) { |
|
204 | - // send out notifications |
|
205 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | - } |
|
170 | + // let's start with the assumption that we need to trigger notifications |
|
171 | + // then toggle this to false for conditions where we know we don't need to |
|
172 | + $deliver_notifications = true; |
|
173 | + if ( |
|
174 | + // if SPCO revisit |
|
175 | + filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN) |
|
176 | + // and TXN or REG statuses have NOT changed due to a payment |
|
177 | + && ! ( |
|
178 | + $this->checkout->transaction->txn_status_updated() |
|
179 | + || $this->checkout->any_reg_status_updated() |
|
180 | + ) |
|
181 | + ) { |
|
182 | + $deliver_notifications = false; |
|
183 | + } |
|
184 | + if ($this->checkout->payment_method->is_off_site()) { |
|
185 | + /** @var EE_Gateway $gateway */ |
|
186 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
187 | + // and the gateway uses a separate request to process the IPN |
|
188 | + if ( |
|
189 | + $gateway instanceof EE_Offsite_Gateway |
|
190 | + && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true) |
|
191 | + ) { |
|
192 | + // IPN request will handle triggering notifications |
|
193 | + $deliver_notifications = false; |
|
194 | + // no really... don't send any notices in this request |
|
195 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
196 | + add_filter( |
|
197 | + 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
|
198 | + '__return_false', |
|
199 | + 15 |
|
200 | + ); |
|
201 | + } |
|
202 | + } |
|
203 | + if ($deliver_notifications) { |
|
204 | + // send out notifications |
|
205 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * @access public |
22 | 22 | * @param EE_Checkout $checkout |
23 | 23 | */ |
24 | - public function __construct( EE_Checkout $checkout ) { |
|
24 | + public function __construct(EE_Checkout $checkout) { |
|
25 | 25 | $this->_slug = 'finalize_registration'; |
26 | - $this->_name = __( 'Finalize Registration', 'event_espresso' ); |
|
26 | + $this->_name = __('Finalize Registration', 'event_espresso'); |
|
27 | 27 | $this->_submit_button_text = $this->_name; |
28 | 28 | $this->_template = ''; |
29 | 29 | $this->checkout = $checkout; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function initialize_reg_step() { |
48 | 48 | // there's actually no reg form to process if this is the final step |
49 | - if ( $this->is_current_step() ) { |
|
49 | + if ($this->is_current_step()) { |
|
50 | 50 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
51 | 51 | $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
52 | 52 | $this->checkout->generate_reg_form = false; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function process_reg_step() { |
77 | 77 | // ensure all data gets refreshed from the db |
78 | - $this->checkout->refresh_all_entities( true ); |
|
78 | + $this->checkout->refresh_all_entities(true); |
|
79 | 79 | // ensures that all details and statuses for transaction, registration, and payments are updated |
80 | 80 | $txn_update_params = $this->_finalize_transaction(); |
81 | 81 | // maybe send messages |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | $txn_update_params |
95 | 95 | ); |
96 | 96 | // check if transaction has a primary registrant and that it has a related Attendee object |
97 | - if ( ! $this->_validate_primary_registrant() ) { |
|
97 | + if ( ! $this->_validate_primary_registrant()) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | // you don't have to go home but you can't stay here ! |
101 | 101 | $this->checkout->redirect = true; |
102 | 102 | $this->checkout->continue_reg = true; |
103 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
103 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
104 | 104 | if ( |
105 | 105 | ! ( |
106 | 106 | $this->checkout->payment_method instanceof EE_Payment_Method |
@@ -126,22 +126,22 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function _finalize_transaction() { |
128 | 128 | /** @type EE_Transaction_Processor $transaction_processor */ |
129 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
129 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
130 | 130 | //set revisit flag in txn processor |
131 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
131 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
132 | 132 | // at this point we'll consider a TXN to not have been abandoned |
133 | 133 | $this->checkout->transaction->toggle_abandoned_transaction_status(); |
134 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
134 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
135 | 135 | // save TXN data to the cart |
136 | 136 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
137 | 137 | $this->checkout->transaction->ID() |
138 | 138 | ); |
139 | 139 | } |
140 | 140 | // maybe update status, but don't save transaction just yet |
141 | - $this->checkout->transaction->update_status_based_on_total_paid( false ); |
|
141 | + $this->checkout->transaction->update_status_based_on_total_paid(false); |
|
142 | 142 | // this will result in the base session properties getting saved to the TXN_Session_data field |
143 | 143 | $this->checkout->transaction->set_txn_session_data( |
144 | - EE_Registry::instance()->SSN->get_session_data( null, true ) |
|
144 | + EE_Registry::instance()->SSN->get_session_data(null, true) |
|
145 | 145 | ); |
146 | 146 | // update the TXN if payment conditions have changed, but do NOT trigger notifications, |
147 | 147 | // because we will do that in process_reg_step() after setting some more triggers |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function _set_notification_triggers() { |
168 | 168 | |
169 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
169 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
170 | 170 | // let's start with the assumption that we need to trigger notifications |
171 | 171 | // then toggle this to false for conditions where we know we don't need to |
172 | 172 | $deliver_notifications = true; |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @throws \EE_Error |
217 | 217 | */ |
218 | 218 | protected function _validate_primary_registrant() { |
219 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
219 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
220 | 220 | EE_Error::add_error( |
221 | - __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), |
|
221 | + __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), |
|
222 | 222 | __FILE__, |
223 | 223 | __FUNCTION__, |
224 | 224 | __LINE__ |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | // setup URL for redirect |
231 | 231 | $this->checkout->redirect_url = add_query_arg( |
232 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
232 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
233 | 233 | $this->checkout->thank_you_page_url |
234 | 234 | ); |
235 | 235 | return true; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function update_reg_step() { |
244 | 244 | EE_Error::doing_it_wrong( |
245 | - __CLASS__ . '::' . __FILE__, |
|
245 | + __CLASS__.'::'.__FILE__, |
|
246 | 246 | __( |
247 | 247 | 'Can not call update_reg_step() on the Finalize Registration reg step.', |
248 | 248 | 'event_espresso' |
@@ -39,7 +39,6 @@ discard block |
||
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Return the schema for a given model from a given model. |
42 | - * @param \EEM_Base $model |
|
43 | 42 | * @return array |
44 | 43 | */ |
45 | 44 | public function getModelSchema() |
@@ -103,7 +102,6 @@ discard block |
||
103 | 102 | |
104 | 103 | /** |
105 | 104 | * Outputs the schema header for a model. |
106 | - * @param \EEM_Base $model |
|
107 | 105 | * @return array |
108 | 106 | */ |
109 | 107 | public function getInitialSchemaStructure() |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function getModelSchemaForFields(array $model_fields, array $schema) |
65 | 65 | { |
66 | 66 | foreach ($model_fields as $field => $model_field) { |
67 | - if (! $model_field instanceof EE_Model_Field_Base) { |
|
67 | + if ( ! $model_field instanceof EE_Model_Field_Base) { |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | $schema['properties'][$field] = $model_field->getSchema(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
96 | 96 | { |
97 | 97 | foreach ($relations_on_model as $model_name => $relation) { |
98 | - if (! $relation instanceof EE_Model_Relation_Base) { |
|
98 | + if ( ! $relation instanceof EE_Model_Relation_Base) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
@@ -25,120 +25,120 @@ |
||
25 | 25 | class JsonModelSchema |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var \EEM_Base |
|
30 | - */ |
|
31 | - protected $model; |
|
32 | - |
|
33 | - /** |
|
34 | - * JsonModelSchema constructor. |
|
35 | - * |
|
36 | - * @param \EEM_Base $model |
|
37 | - */ |
|
38 | - public function __construct(EEM_Base $model) |
|
39 | - { |
|
40 | - $this->model = $model; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Return the schema for a given model from a given model. |
|
45 | - * @param \EEM_Base $model |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - public function getModelSchema() |
|
49 | - { |
|
50 | - return $this->getModelSchemaForRelations( |
|
51 | - $this->model->relation_settings(), |
|
52 | - $this->getModelSchemaForFields( |
|
53 | - $this->model->field_settings(), |
|
54 | - $this->getInitialSchemaStructure() |
|
55 | - ) |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Get the schema for a given set of model fields. |
|
62 | - * @param \EE_Model_Field_Base[] $model_fields |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public function getModelSchemaForFields(array $model_fields, array $schema) |
|
66 | - { |
|
67 | - foreach ($model_fields as $field => $model_field) { |
|
68 | - if (! $model_field instanceof EE_Model_Field_Base) { |
|
69 | - continue; |
|
70 | - } |
|
71 | - $schema['properties'][$field] = $model_field->getSchema(); |
|
72 | - |
|
73 | - //if this is a primary key field add the primary key item |
|
74 | - if ($model_field instanceof EE_Primary_Key_Field_Base) { |
|
75 | - $schema['properties'][$field]['primary_key'] = true; |
|
76 | - if ($model_field instanceof EE_Primary_Key_Int_Field) { |
|
77 | - $schema['properties'][$field]['readonly'] = true; |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - //if this is a foreign key field add the foreign key item |
|
82 | - if ($model_field instanceof EE_Foreign_Key_Field_Base) { |
|
83 | - $schema['properties'][$field]['foreign_key'] = array( |
|
84 | - 'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'), |
|
85 | - 'type' => 'array', |
|
86 | - 'enum' => $model_field->get_model_class_names_pointed_to() |
|
87 | - ); |
|
88 | - } |
|
89 | - } |
|
90 | - return $schema; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * Get the schema for a given set of model relations |
|
96 | - * @param EE_Model_Relation_Base[] $relations_on_model |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
|
100 | - { |
|
101 | - foreach ($relations_on_model as $model_name => $relation) { |
|
102 | - if (! $relation instanceof EE_Model_Relation_Base) { |
|
103 | - continue; |
|
104 | - } |
|
105 | - $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
|
106 | - ? strtolower($model_name) |
|
107 | - : EEH_Inflector::pluralize_and_lower($model_name); |
|
108 | - $schema['properties'][$model_name_for_schema] = $relation->getSchema(); |
|
109 | - $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name; |
|
110 | - } |
|
111 | - return $schema; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Outputs the schema header for a model. |
|
117 | - * @param \EEM_Base $model |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function getInitialSchemaStructure() |
|
121 | - { |
|
122 | - return array( |
|
123 | - '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
124 | - 'title' => $this->model->get_this_model_name(), |
|
125 | - 'type' => 'object', |
|
126 | - 'properties' => array() |
|
127 | - ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Allows one to just use the object as a string to get the json. |
|
133 | - * eg. |
|
134 | - * |
|
135 | - * $json_schema = new JsonModelSchema(EEM_Event::instance()); |
|
136 | - * echo $json_schema; //outputs the schema as a json formatted string. |
|
137 | - * |
|
138 | - * @return bool|false|mixed|string |
|
139 | - */ |
|
140 | - public function __toString() |
|
141 | - { |
|
142 | - return wp_json_encode($this->getModelSchema()); |
|
143 | - } |
|
28 | + /** |
|
29 | + * @var \EEM_Base |
|
30 | + */ |
|
31 | + protected $model; |
|
32 | + |
|
33 | + /** |
|
34 | + * JsonModelSchema constructor. |
|
35 | + * |
|
36 | + * @param \EEM_Base $model |
|
37 | + */ |
|
38 | + public function __construct(EEM_Base $model) |
|
39 | + { |
|
40 | + $this->model = $model; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Return the schema for a given model from a given model. |
|
45 | + * @param \EEM_Base $model |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + public function getModelSchema() |
|
49 | + { |
|
50 | + return $this->getModelSchemaForRelations( |
|
51 | + $this->model->relation_settings(), |
|
52 | + $this->getModelSchemaForFields( |
|
53 | + $this->model->field_settings(), |
|
54 | + $this->getInitialSchemaStructure() |
|
55 | + ) |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Get the schema for a given set of model fields. |
|
62 | + * @param \EE_Model_Field_Base[] $model_fields |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public function getModelSchemaForFields(array $model_fields, array $schema) |
|
66 | + { |
|
67 | + foreach ($model_fields as $field => $model_field) { |
|
68 | + if (! $model_field instanceof EE_Model_Field_Base) { |
|
69 | + continue; |
|
70 | + } |
|
71 | + $schema['properties'][$field] = $model_field->getSchema(); |
|
72 | + |
|
73 | + //if this is a primary key field add the primary key item |
|
74 | + if ($model_field instanceof EE_Primary_Key_Field_Base) { |
|
75 | + $schema['properties'][$field]['primary_key'] = true; |
|
76 | + if ($model_field instanceof EE_Primary_Key_Int_Field) { |
|
77 | + $schema['properties'][$field]['readonly'] = true; |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + //if this is a foreign key field add the foreign key item |
|
82 | + if ($model_field instanceof EE_Foreign_Key_Field_Base) { |
|
83 | + $schema['properties'][$field]['foreign_key'] = array( |
|
84 | + 'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'), |
|
85 | + 'type' => 'array', |
|
86 | + 'enum' => $model_field->get_model_class_names_pointed_to() |
|
87 | + ); |
|
88 | + } |
|
89 | + } |
|
90 | + return $schema; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * Get the schema for a given set of model relations |
|
96 | + * @param EE_Model_Relation_Base[] $relations_on_model |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function getModelSchemaForRelations(array $relations_on_model, array $schema) |
|
100 | + { |
|
101 | + foreach ($relations_on_model as $model_name => $relation) { |
|
102 | + if (! $relation instanceof EE_Model_Relation_Base) { |
|
103 | + continue; |
|
104 | + } |
|
105 | + $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation |
|
106 | + ? strtolower($model_name) |
|
107 | + : EEH_Inflector::pluralize_and_lower($model_name); |
|
108 | + $schema['properties'][$model_name_for_schema] = $relation->getSchema(); |
|
109 | + $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name; |
|
110 | + } |
|
111 | + return $schema; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Outputs the schema header for a model. |
|
117 | + * @param \EEM_Base $model |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function getInitialSchemaStructure() |
|
121 | + { |
|
122 | + return array( |
|
123 | + '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
124 | + 'title' => $this->model->get_this_model_name(), |
|
125 | + 'type' => 'object', |
|
126 | + 'properties' => array() |
|
127 | + ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Allows one to just use the object as a string to get the json. |
|
133 | + * eg. |
|
134 | + * |
|
135 | + * $json_schema = new JsonModelSchema(EEM_Event::instance()); |
|
136 | + * echo $json_schema; //outputs the schema as a json formatted string. |
|
137 | + * |
|
138 | + * @return bool|false|mixed|string |
|
139 | + */ |
|
140 | + public function __toString() |
|
141 | + { |
|
142 | + return wp_json_encode($this->getModelSchema()); |
|
143 | + } |
|
144 | 144 | } |
@@ -5,63 +5,63 @@ |
||
5 | 5 | |
6 | 6 | interface HasSchemaInterface |
7 | 7 | { |
8 | - /** |
|
9 | - * Returns whatever is set as the nicename for the object. |
|
10 | - * |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - public function getSchemaDescription(); |
|
8 | + /** |
|
9 | + * Returns whatever is set as the nicename for the object. |
|
10 | + * |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + public function getSchemaDescription(); |
|
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * Returns whatever is set as the $_schema_type property for the object. |
|
18 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
19 | - * |
|
20 | - * @return string|array |
|
21 | - */ |
|
22 | - public function getSchemaType(); |
|
16 | + /** |
|
17 | + * Returns whatever is set as the $_schema_type property for the object. |
|
18 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
19 | + * |
|
20 | + * @return string|array |
|
21 | + */ |
|
22 | + public function getSchemaType(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
27 | - * this method and return the properties for the schema. |
|
28 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
29 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
30 | - * |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function getSchemaProperties(); |
|
25 | + /** |
|
26 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
27 | + * this method and return the properties for the schema. |
|
28 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
29 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
30 | + * |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function getSchemaProperties(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * If a child class has enum values, they should override this method and provide a simple array |
|
37 | - * of the enum values. |
|
38 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
39 | - * are set on the instantiated object that could be filtered after construct. |
|
40 | - * |
|
41 | - * @return array |
|
42 | - */ |
|
43 | - public function getSchemaEnum(); |
|
35 | + /** |
|
36 | + * If a child class has enum values, they should override this method and provide a simple array |
|
37 | + * of the enum values. |
|
38 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
39 | + * are set on the instantiated object that could be filtered after construct. |
|
40 | + * |
|
41 | + * @return array |
|
42 | + */ |
|
43 | + public function getSchemaEnum(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * This returns the value of the $_schema_format property on the object. |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getSchemaFormat(); |
|
45 | + /** |
|
46 | + * This returns the value of the $_schema_format property on the object. |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getSchemaFormat(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * This returns the value of the $_schema_readonly property on the object. |
|
54 | - * |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - public function getSchemaReadonly(); |
|
52 | + /** |
|
53 | + * This returns the value of the $_schema_readonly property on the object. |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + public function getSchemaReadonly(); |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * This returns elements used to represent this field in the json schema. |
|
62 | - * |
|
63 | - * @link http://json-schema.org/ |
|
64 | - * @return array |
|
65 | - */ |
|
66 | - public function getSchema(); |
|
60 | + /** |
|
61 | + * This returns elements used to represent this field in the json schema. |
|
62 | + * |
|
63 | + * @link http://json-schema.org/ |
|
64 | + * @return array |
|
65 | + */ |
|
66 | + public function getSchema(); |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -4,22 +4,22 @@ |
||
4 | 4 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - public function __construct($table_column, $nicename) |
|
8 | - { |
|
9 | - parent::__construct($table_column, $nicename, null); |
|
10 | - } |
|
7 | + public function __construct($table_column, $nicename) |
|
8 | + { |
|
9 | + parent::__construct($table_column, $nicename, null); |
|
10 | + } |
|
11 | 11 | |
12 | - /** |
|
13 | - * removes all tags when setting |
|
14 | - * |
|
15 | - * @param string $value_inputted_for_field_on_model_object |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
19 | - { |
|
20 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
21 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
22 | - } |
|
23 | - return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
24 | - } |
|
12 | + /** |
|
13 | + * removes all tags when setting |
|
14 | + * |
|
15 | + * @param string $value_inputted_for_field_on_model_object |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
19 | + { |
|
20 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
21 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
22 | + } |
|
23 | + return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -4,6 +4,9 @@ |
||
4 | 4 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | + /** |
|
8 | + * @param string $table_column |
|
9 | + */ |
|
7 | 10 | public function __construct($table_column, $nicename) |
8 | 11 | { |
9 | 12 | parent::__construct($table_column, $nicename, null); |
@@ -6,14 +6,14 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_All_Caps_Text_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * makes it all upper case, and key-like |
|
11 | - * |
|
12 | - * @param string $value_inputted_for_field_on_model_object |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | - { |
|
17 | - return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | - } |
|
9 | + /** |
|
10 | + * makes it all upper case, and key-like |
|
11 | + * |
|
12 | + * @param string $value_inputted_for_field_on_model_object |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | + { |
|
17 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | /** @var string $default_hidden_inputs */ |
5 | 5 | ?> |
6 | 6 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
7 | - <?php echo apply_filters( 'FHEE__registration_page_attendee_information__attendee_information_pg', sprintf( __('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>' )); ?> |
|
7 | + <?php echo apply_filters('FHEE__registration_page_attendee_information__attendee_information_pg', sprintf(__('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>')); ?> |
|
8 | 8 | </p> |
9 | 9 | |
10 | 10 | <?php |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | $prev_event = 0; |
13 | 13 | $prev_ticket = 0; |
14 | 14 | |
15 | -if ( count( $registrations ) > 0 ) { |
|
16 | - foreach ( $registrations as $registration ) { |
|
17 | - if ( $registration instanceof EE_Registration ) { |
|
15 | +if (count($registrations) > 0) { |
|
16 | + foreach ($registrations as $registration) { |
|
17 | + if ($registration instanceof EE_Registration) { |
|
18 | 18 | $att_nmbr++; |
19 | 19 | ?> |
20 | 20 | |
21 | - <div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link();?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID();?>"> |
|
21 | + <div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link(); ?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID(); ?>"> |
|
22 | 22 | |
23 | - <?php if ( $registration->event()->ID() !== $prev_event ) { ?> |
|
23 | + <?php if ($registration->event()->ID() !== $prev_event) { ?> |
|
24 | 24 | <h4 id="event_title-<?php echo $registration->event()->ID() ?>" class="big-event-title-hdr"> |
25 | 25 | <?php echo $registration->event()->name(); ?> |
26 | 26 | </h4> |
27 | 27 | <?php } ?> |
28 | - <?php if ( $registration->ticket()->ID() !== $prev_ticket ) { ?> |
|
29 | - <?php if ( ! $revisit ) { ?> |
|
28 | + <?php if ($registration->ticket()->ID() !== $prev_ticket) { ?> |
|
29 | + <?php if ( ! $revisit) { ?> |
|
30 | 30 | <div class="spco-ticket-info-dv small-text"> |
31 | - <h5><?php _e('Details', 'event_espresso');?></h5> |
|
31 | + <h5><?php _e('Details', 'event_espresso'); ?></h5> |
|
32 | 32 | <table> |
33 | 33 | <thead> |
34 | 34 | <tr> |
35 | - <th scope="col" width=""><?php _e('Name and Description', 'event_espresso');?></th> |
|
36 | - <th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso');?></th> |
|
37 | - <th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso');?></th> |
|
38 | - <th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso');?></th> |
|
35 | + <th scope="col" width=""><?php _e('Name and Description', 'event_espresso'); ?></th> |
|
36 | + <th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso'); ?></th> |
|
37 | + <th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso'); ?></th> |
|
38 | + <th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso'); ?></th> |
|
39 | 39 | </tr> |
40 | 40 | </thead> |
41 | 41 | <tbody> |
42 | - <?php echo $ticket_line_item[ $registration->ticket()->ID() ]; ?> |
|
42 | + <?php echo $ticket_line_item[$registration->ticket()->ID()]; ?> |
|
43 | 43 | </tbody> |
44 | 44 | </table> |
45 | 45 | </div> |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | <?php |
50 | 50 | // ATTENDEE QUESTIONS |
51 | - $reg_form = EE_Template_Layout::get_subform_name( $registration->reg_url_link() ); |
|
51 | + $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
52 | 52 | echo ${$reg_form}; |
53 | 53 | ?> |
54 | 54 |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * @param string $table_column |
16 | 16 | * @param string $nicename |
17 | 17 | * @param bool $nullable |
18 | - * @param null $default_value |
|
18 | + * @param string|null $default_value |
|
19 | 19 | */ |
20 | 20 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
21 | 21 | { |
@@ -11,28 +11,28 @@ |
||
11 | 11 | abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $table_column |
|
16 | - * @param string $nicename |
|
17 | - * @param bool $nullable |
|
18 | - * @param null $default_value |
|
19 | - */ |
|
20 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
21 | - { |
|
22 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
23 | - $this->setSchemaReadOnly(true); |
|
24 | - } |
|
14 | + /** |
|
15 | + * @param string $table_column |
|
16 | + * @param string $nicename |
|
17 | + * @param bool $nullable |
|
18 | + * @param null $default_value |
|
19 | + */ |
|
20 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
21 | + { |
|
22 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
23 | + $this->setSchemaReadOnly(true); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * All these children classes are for the db-only (meaning, we should select them |
|
29 | - * on get_all queries, update, delete, and will still want to set their default value |
|
30 | - * on inserts, but the model object won't have reference to these fields) |
|
31 | - * |
|
32 | - * @return boolean |
|
33 | - */ |
|
34 | - function is_db_only_field() |
|
35 | - { |
|
36 | - return true; |
|
37 | - } |
|
27 | + /** |
|
28 | + * All these children classes are for the db-only (meaning, we should select them |
|
29 | + * on get_all queries, update, delete, and will still want to set their default value |
|
30 | + * on inserts, but the model object won't have reference to these fields) |
|
31 | + * |
|
32 | + * @return boolean |
|
33 | + */ |
|
34 | + function is_db_only_field() |
|
35 | + { |
|
36 | + return true; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @param string $table_column |
13 | 13 | * @param string $nicename |
14 | 14 | * @param bool $nullable |
15 | - * @param null $default_value |
|
15 | + * @param integer|null $default_value |
|
16 | 16 | */ |
17 | 17 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
18 | 18 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
28 | 28 | * Returns a float |
29 | 29 | * |
30 | - * @param type $value_inputted_for_field_on_model_object |
|
30 | + * @param string $value_inputted_for_field_on_model_object |
|
31 | 31 | * @return float |
32 | 32 | */ |
33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) |
@@ -8,64 +8,64 @@ |
||
8 | 8 | class EE_Float_Field extends EE_Model_Field_Base |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * @param string $table_column |
|
13 | - * @param string $nicename |
|
14 | - * @param bool $nullable |
|
15 | - * @param null $default_value |
|
16 | - */ |
|
17 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
18 | - { |
|
19 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
20 | - $this->setSchemaType('number'); |
|
21 | - } |
|
11 | + /** |
|
12 | + * @param string $table_column |
|
13 | + * @param string $nicename |
|
14 | + * @param bool $nullable |
|
15 | + * @param null $default_value |
|
16 | + */ |
|
17 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
18 | + { |
|
19 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
20 | + $this->setSchemaType('number'); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
26 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
27 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
28 | - * Returns a float |
|
29 | - * |
|
30 | - * @param type $value_inputted_for_field_on_model_object |
|
31 | - * @return float |
|
32 | - */ |
|
33 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
34 | - { |
|
24 | + /** |
|
25 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
26 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
27 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
28 | + * Returns a float |
|
29 | + * |
|
30 | + * @param type $value_inputted_for_field_on_model_object |
|
31 | + * @return float |
|
32 | + */ |
|
33 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
34 | + { |
|
35 | 35 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
36 | - //remove whitespaces and thousands separators |
|
37 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
38 | - $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | - "", $value_inputted_for_field_on_model_object); |
|
36 | + //remove whitespaces and thousands separators |
|
37 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
38 | + $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | + "", $value_inputted_for_field_on_model_object); |
|
40 | 40 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
41 | 41 | //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
42 | - $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
43 | - $value_inputted_for_field_on_model_object); |
|
42 | + $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
43 | + $value_inputted_for_field_on_model_object); |
|
44 | 44 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
45 | 45 | //double-check there's absolutely nothing left on this string besides numbers |
46 | - $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
47 | - $value_inputted_for_field_on_model_object); |
|
48 | - } |
|
46 | + $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
47 | + $value_inputted_for_field_on_model_object); |
|
48 | + } |
|
49 | 49 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
50 | - return floatval($value_inputted_for_field_on_model_object); |
|
51 | - } |
|
50 | + return floatval($value_inputted_for_field_on_model_object); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
55 | - * |
|
56 | - * @param float $value_on_field_to_be_outputted |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
60 | - { |
|
61 | - $EE = EE_Registry::instance(); |
|
62 | - return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
63 | - $EE->CFG->currency->thsnds); |
|
64 | - } |
|
53 | + /** |
|
54 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
55 | + * |
|
56 | + * @param float $value_on_field_to_be_outputted |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
60 | + { |
|
61 | + $EE = EE_Registry::instance(); |
|
62 | + return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
63 | + $EE->CFG->currency->thsnds); |
|
64 | + } |
|
65 | 65 | |
66 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
67 | - { |
|
66 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
67 | + { |
|
68 | 68 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
69 | - return floatval($value_found_in_db_for_model_object); |
|
70 | - } |
|
69 | + return floatval($value_found_in_db_for_model_object); |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | \ No newline at end of file |
@@ -8,7 +8,7 @@ |
||
8 | 8 | * @param string $table_column name fo column for field |
9 | 9 | * @param string $nicename should eb internationalized with __('blah','event_espresso') |
10 | 10 | * @param boolean $nullable |
11 | - * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
11 | + * @param integer|null $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
12 | 12 | * dbe a string |
13 | 13 | * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the |
14 | 14 | * "EEM_" |
@@ -4,37 +4,37 @@ |
||
4 | 4 | class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * @param string $table_column name fo column for field |
|
9 | - * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
10 | - * @param boolean $nullable |
|
11 | - * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
12 | - * dbe a string |
|
13 | - * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the |
|
14 | - * "EEM_" |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value, $model_name) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name); |
|
19 | - $this->setSchemaType('integer'); |
|
20 | - } |
|
7 | + /** |
|
8 | + * @param string $table_column name fo column for field |
|
9 | + * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
10 | + * @param boolean $nullable |
|
11 | + * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul |
|
12 | + * dbe a string |
|
13 | + * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the |
|
14 | + * "EEM_" |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value, $model_name) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value, $model_name); |
|
19 | + $this->setSchemaType('integer'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param int|EE_Base_Class $value_inputted_for_field_on_model_object |
|
25 | - * @return int |
|
26 | - */ |
|
27 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
28 | - { |
|
29 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
30 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
31 | - } |
|
32 | - return absint($value_inputted_for_field_on_model_object); |
|
33 | - } |
|
23 | + /** |
|
24 | + * @param int|EE_Base_Class $value_inputted_for_field_on_model_object |
|
25 | + * @return int |
|
26 | + */ |
|
27 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
28 | + { |
|
29 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
30 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
31 | + } |
|
32 | + return absint($value_inputted_for_field_on_model_object); |
|
33 | + } |
|
34 | 34 | |
35 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
36 | - { |
|
37 | - return intval($value_found_in_db_for_model_object); |
|
38 | - } |
|
35 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
36 | + { |
|
37 | + return intval($value_found_in_db_for_model_object); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | \ No newline at end of file |