@@ -6,7 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage helper |
8 | 8 | */ |
9 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | +} |
|
10 | 12 | /** |
11 | 13 | * |
12 | 14 | * Money helper class. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * ------------------------------------------------------------------------ |
22 | 22 | */ |
23 | -class EEH_Money extends EEH_Base { |
|
23 | +class EEH_Money extends EEH_Base { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @return float |
62 | 62 | * @throws EE_Error |
63 | 63 | */ |
64 | - public static function convert_to_float_from_localized_money($money_value ) { |
|
64 | + public static function convert_to_float_from_localized_money($money_value) { |
|
65 | 65 | //float it! and round to three decimal places |
66 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
66 | + return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | * @throws EE_Error |
83 | 83 | */ |
84 | 84 | |
85 | - public static function compare_floats( $float1, $float2, $operator='=' ) { |
|
85 | + public static function compare_floats($float1, $float2, $operator = '=') { |
|
86 | 86 | // Check numbers to 5 digits of precision |
87 | 87 | $epsilon = 0.00001; |
88 | 88 | |
89 | - $float1 = (float)$float1; |
|
90 | - $float2 = (float)$float2; |
|
89 | + $float1 = (float) $float1; |
|
90 | + $float2 = (float) $float2; |
|
91 | 91 | |
92 | 92 | switch ($operator) { |
93 | 93 | // equal |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | break; |
145 | 145 | default: |
146 | - throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) ); |
|
146 | + throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso')); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return false; |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * @return string |
160 | 160 | * @throws EE_Error |
161 | 161 | */ |
162 | - public static function get_format_for_jqplot( $CNT_ISO = '') { |
|
162 | + public static function get_format_for_jqplot($CNT_ISO = '') { |
|
163 | 163 | //default format |
164 | 164 | $format = 'f'; |
165 | 165 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
166 | 166 | //first get the decimal place and number of places |
167 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
167 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
168 | 168 | //currency symbol on right side. |
169 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
169 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
170 | 170 | return $format; |
171 | 171 | } |
172 | 172 | |
@@ -182,20 +182,20 @@ discard block |
||
182 | 182 | * @return string |
183 | 183 | * @throws EE_Error |
184 | 184 | */ |
185 | - public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
|
185 | + public static function get_format_for_google_charts($CNT_ISO = '') { |
|
186 | 186 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
187 | - $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
|
187 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
188 | 188 | //first get the decimal place and number of places |
189 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
189 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
190 | 190 | |
191 | 191 | //currency symbol on right side. |
192 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
192 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
193 | 193 | $formatterObject = array( |
194 | 194 | 'decimalSymbol' => $currency_config->dec_mrk, |
195 | 195 | 'groupingSymbol' => $currency_config->thsnds, |
196 | 196 | 'fractionDigits' => $currency_config->dec_plc, |
197 | 197 | ); |
198 | - if ( $currency_config->sign_b4 ) { |
|
198 | + if ($currency_config->sign_b4) { |
|
199 | 199 | $formatterObject['prefix'] = $currency_config->sign; |
200 | 200 | } else { |
201 | 201 | $formatterObject['suffix'] = $currency_config->sign; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ? new EE_Currency_Config($CNT_ISO) |
221 | 221 | : null; |
222 | 222 | //default currency settings for site if not set |
223 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
223 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
224 | 224 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
225 | 225 | ? EE_Registry::instance()->CFG->currency |
226 | 226 | : new EE_Currency_Config(); |
@@ -8,71 +8,71 @@ discard block |
||
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
10 | 10 | /** |
11 | - * |
|
12 | - * Money helper class. |
|
13 | - * This class has helper methods that help with money related conversions and calculations. |
|
14 | - * |
|
15 | - * @since %VER% |
|
16 | - * |
|
17 | - * @package Event Espresso |
|
18 | - * @subpackage helpers |
|
19 | - * @author Darren Ethier |
|
20 | - * |
|
21 | - * ------------------------------------------------------------------------ |
|
22 | - */ |
|
11 | + * |
|
12 | + * Money helper class. |
|
13 | + * This class has helper methods that help with money related conversions and calculations. |
|
14 | + * |
|
15 | + * @since %VER% |
|
16 | + * |
|
17 | + * @package Event Espresso |
|
18 | + * @subpackage helpers |
|
19 | + * @author Darren Ethier |
|
20 | + * |
|
21 | + * ------------------------------------------------------------------------ |
|
22 | + */ |
|
23 | 23 | class EEH_Money extends EEH_Base { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * This removes all localized money formatting from the incoming value |
|
28 | - * |
|
29 | - * Note: uses this site's currency settings for deciding what is considered a |
|
30 | - * "thousands separator" (usually the character "," ) |
|
31 | - * and what is a "decimal mark" (usually the character ".") |
|
32 | - * |
|
33 | - * @param int|float|string $money_value |
|
34 | - * @param string $CNT_ISO |
|
35 | - * @return float |
|
36 | - * @throws EE_Error |
|
37 | - */ |
|
26 | + /** |
|
27 | + * This removes all localized money formatting from the incoming value |
|
28 | + * |
|
29 | + * Note: uses this site's currency settings for deciding what is considered a |
|
30 | + * "thousands separator" (usually the character "," ) |
|
31 | + * and what is a "decimal mark" (usually the character ".") |
|
32 | + * |
|
33 | + * @param int|float|string $money_value |
|
34 | + * @param string $CNT_ISO |
|
35 | + * @return float |
|
36 | + * @throws EE_Error |
|
37 | + */ |
|
38 | 38 | public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') { |
39 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | - $money_value = str_replace( |
|
41 | - array( |
|
42 | - $currency_config->thsnds, |
|
43 | - $currency_config->dec_mrk, |
|
44 | - ), |
|
45 | - array( |
|
46 | - '', // remove thousands separator |
|
47 | - '.', // convert decimal mark to what PHP expects |
|
48 | - ), |
|
49 | - $money_value |
|
50 | - ); |
|
51 | - $money_value = filter_var( |
|
52 | - $money_value, |
|
53 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | - FILTER_FLAG_ALLOW_FRACTION |
|
55 | - ); |
|
56 | - return $money_value; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
63 | - * |
|
64 | - * Only use this if you know the $money_value follows your currency configuration's |
|
65 | - * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
66 | - * "thousands separator" (usually the character "," ) |
|
67 | - * and what is a "decimal mark" (usually the character ".") |
|
68 | - * |
|
69 | - * @param int|string $money_value |
|
70 | - * @return float |
|
71 | - * @throws EE_Error |
|
72 | - */ |
|
39 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | + $money_value = str_replace( |
|
41 | + array( |
|
42 | + $currency_config->thsnds, |
|
43 | + $currency_config->dec_mrk, |
|
44 | + ), |
|
45 | + array( |
|
46 | + '', // remove thousands separator |
|
47 | + '.', // convert decimal mark to what PHP expects |
|
48 | + ), |
|
49 | + $money_value |
|
50 | + ); |
|
51 | + $money_value = filter_var( |
|
52 | + $money_value, |
|
53 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | + FILTER_FLAG_ALLOW_FRACTION |
|
55 | + ); |
|
56 | + return $money_value; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
63 | + * |
|
64 | + * Only use this if you know the $money_value follows your currency configuration's |
|
65 | + * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
66 | + * "thousands separator" (usually the character "," ) |
|
67 | + * and what is a "decimal mark" (usually the character ".") |
|
68 | + * |
|
69 | + * @param int|string $money_value |
|
70 | + * @return float |
|
71 | + * @throws EE_Error |
|
72 | + */ |
|
73 | 73 | public static function convert_to_float_from_localized_money($money_value ) { |
74 | 74 | //float it! and round to three decimal places |
75 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
75 | + return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -160,19 +160,19 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * This returns a localized format string suitable for jQplot. |
|
165 | - * |
|
166 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
167 | - * Otherwise will use currency settings for current active country on site. |
|
168 | - * @return string |
|
169 | - * @throws EE_Error |
|
170 | - */ |
|
163 | + /** |
|
164 | + * This returns a localized format string suitable for jQplot. |
|
165 | + * |
|
166 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
167 | + * Otherwise will use currency settings for current active country on site. |
|
168 | + * @return string |
|
169 | + * @throws EE_Error |
|
170 | + */ |
|
171 | 171 | public static function get_format_for_jqplot( $CNT_ISO = '') { |
172 | 172 | //default format |
173 | 173 | $format = 'f'; |
174 | 174 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
175 | - //first get the decimal place and number of places |
|
175 | + //first get the decimal place and number of places |
|
176 | 176 | $format = "%'." . $currency_config->dec_plc . $format; |
177 | 177 | //currency symbol on right side. |
178 | 178 | $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | |
182 | 182 | |
183 | 183 | |
184 | - /** |
|
185 | - * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
186 | - * |
|
187 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
188 | - * Otherwise will use currency settings for current active country on site. |
|
189 | - * Note: GoogleCharts uses ICU pattern set |
|
190 | - * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
191 | - * @return string |
|
192 | - * @throws EE_Error |
|
193 | - */ |
|
184 | + /** |
|
185 | + * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
186 | + * |
|
187 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
188 | + * Otherwise will use currency settings for current active country on site. |
|
189 | + * Note: GoogleCharts uses ICU pattern set |
|
190 | + * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
191 | + * @return string |
|
192 | + * @throws EE_Error |
|
193 | + */ |
|
194 | 194 | public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
195 | 195 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
196 | 196 | $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - /** |
|
221 | - * @param string $CNT_ISO |
|
222 | - * @return EE_Currency_Config|null |
|
223 | - * @throws EE_Error |
|
224 | - */ |
|
225 | - public static function get_currency_config($CNT_ISO = '') |
|
226 | - { |
|
227 | - //if CNT_ISO passed lets try to get currency settings for it. |
|
228 | - $currency_config = $CNT_ISO !== '' |
|
229 | - ? new EE_Currency_Config($CNT_ISO) |
|
230 | - : null; |
|
231 | - //default currency settings for site if not set |
|
232 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
233 | - $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
234 | - ? EE_Registry::instance()->CFG->currency |
|
235 | - : new EE_Currency_Config(); |
|
236 | - } |
|
237 | - return $currency_config; |
|
238 | - } |
|
220 | + /** |
|
221 | + * @param string $CNT_ISO |
|
222 | + * @return EE_Currency_Config|null |
|
223 | + * @throws EE_Error |
|
224 | + */ |
|
225 | + public static function get_currency_config($CNT_ISO = '') |
|
226 | + { |
|
227 | + //if CNT_ISO passed lets try to get currency settings for it. |
|
228 | + $currency_config = $CNT_ISO !== '' |
|
229 | + ? new EE_Currency_Config($CNT_ISO) |
|
230 | + : null; |
|
231 | + //default currency settings for site if not set |
|
232 | + if (! $currency_config instanceof EE_Currency_Config) { |
|
233 | + $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
234 | + ? EE_Registry::instance()->CFG->currency |
|
235 | + : new EE_Currency_Config(); |
|
236 | + } |
|
237 | + return $currency_config; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | } //end class EEH_Money |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param mixed $info |
26 | 26 | * @return bool |
27 | 27 | */ |
28 | - public function add( $object, $info = null ); |
|
28 | + public function add($object, $info = null); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param mixed $info |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function set_info( $object, $info = null ); |
|
42 | + public function set_info($object, $info = null); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param mixed |
53 | 53 | * @return null | object |
54 | 54 | */ |
55 | - public function get_by_info( $info ); |
|
55 | + public function get_by_info($info); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param object $object |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function has( $object ); |
|
68 | + public function has($object); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param $object |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - public function remove( $object ); |
|
81 | + public function remove($object); |
|
82 | 82 | |
83 | 83 | |
84 | 84 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return bool | int |
31 | 31 | * @throws \EE_Error |
32 | 32 | */ |
33 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ); |
|
33 | + public function persist($persistence_callback = '', $persistence_arguments = array()); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $persistence_callback name of method found on object that can be used for persisting it |
44 | 44 | * @return bool | int |
45 | 45 | */ |
46 | - public function persist_all( $persistence_callback = '' ); |
|
46 | + public function persist_all($persistence_callback = ''); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | // End of file EEI_Repository.interface.php |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EEI_Line_Item |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param mixed $field_value |
19 | 19 | * @param bool $use_default |
20 | 20 | */ |
21 | - public function set( $field_name, $field_value, $use_default = false ); |
|
21 | + public function set($field_name, $field_value, $use_default = false); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Sets quantity |
57 | 57 | * @param int $quantity |
58 | 58 | */ |
59 | - function set_quantity( $quantity ); |
|
59 | + function set_quantity($quantity); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
116 | 116 | * @return int count of items saved |
117 | 117 | */ |
118 | - function save_this_and_descendants_to_txn( $txn_id = null ); |
|
118 | + function save_this_and_descendants_to_txn($txn_id = null); |
|
119 | 119 | |
120 | 120 | |
121 | 121 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param bool $set_order |
143 | 143 | * @return bool true for success, false for fail |
144 | 144 | */ |
145 | - function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ); |
|
145 | + function add_child_line_item(EEI_Line_Item $line_item, $set_order = true); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param float $total |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - function set_total( $total ); |
|
200 | + function set_total($total); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Sets unit_price |
204 | 204 | * @param float $unit_price |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - function set_unit_price( $unit_price ); |
|
207 | + function set_unit_price($unit_price); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param bool $stop_search_once_found |
216 | 216 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
217 | 217 | */ |
218 | - function delete_child_line_item( $code, $stop_search_once_found = true ); |
|
218 | + function delete_child_line_item($code, $stop_search_once_found = true); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Forgets the cached model of the given relation Name. So the next time we request it, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param boolean $allow_persist |
239 | 239 | * @return boolean |
240 | 240 | */ |
241 | - function set_allow_persist( $allow_persist ); |
|
241 | + function set_allow_persist($allow_persist); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param \EEI_Line_Item $line_item |
27 | 27 | * @return \EEI_Line_Item |
28 | 28 | */ |
29 | - public function process( EEI_Line_Item $line_item ); |
|
29 | + public function process(EEI_Line_Item $line_item); |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -class EE_Sample_Form extends EE_Form_Section_Proper{ |
|
3 | - function __construct(){ |
|
2 | +class EE_Sample_Form extends EE_Form_Section_Proper { |
|
3 | + function __construct() { |
|
4 | 4 | $this->_subsections = array( |
5 | 5 | 'h1'=>new EE_Form_Section_HTML('hello wordl'), |
6 | - 'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')), |
|
6 | + 'name'=>new EE_Text_Input(array('required'=>true, 'default'=>'your name here')), |
|
7 | 7 | 'email'=>new EE_Email_Input(array('required'=>false)), |
8 | - 'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=> __("Small", "event_espresso"),'m'=> __("Medium", "event_espresso"),'l'=> __("Large", "event_espresso")),array('required'=>true,'default'=>'s')), |
|
8 | + 'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=> __("Small", "event_espresso"), 'm'=> __("Medium", "event_espresso"), 'l'=> __("Large", "event_espresso")), array('required'=>true, 'default'=>'s')), |
|
9 | 9 | 'month_normal'=>new EE_Month_Input(), |
10 | 10 | 'month_leading_zero'=>new EE_Month_Input(true), |
11 | 11 | 'year_2'=>new EE_Year_Input(false, 1, 1), |
12 | - 'year_4'=>new EE_Year_Input(true, 0,10,array('default'=>'2017')), |
|
12 | + 'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')), |
|
13 | 13 | 'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=> __("Yes or No", "event_espresso"))), |
14 | 14 | 'credit_card'=>new EE_Credit_Card_Input(), |
15 | 15 | 'image_1'=>new EE_Admin_File_Uploader_Input(), |
16 | 16 | 'image_2'=>new EE_Admin_File_Uploader_Input(), |
17 | - 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'),array('default'=>array('php'))), |
|
17 | + 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP', 'mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
18 | 18 | 'float'=>new EE_Float_Input(), |
19 | 19 | 'essay'=>new EE_Text_Area_Input(), |
20 | 20 | 'amenities'=>new EE_Select_Multiple_Input( |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * Extra validation for the 'name' input. |
41 | 41 | * @param EE_Text_Input $form_input |
42 | 42 | */ |
43 | - function _validate_name($form_input){ |
|
44 | - if($form_input->raw_value() != 'Mike'){ |
|
43 | + function _validate_name($form_input) { |
|
44 | + if ($form_input->raw_value() != 'Mike') { |
|
45 | 45 | $form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike'); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - function _validate(){ |
|
49 | + function _validate() { |
|
50 | 50 | parent::_validate(); |
51 | - if($this->_subsections['shirt_size']->normalized_value() =='s' |
|
52 | - && $this->_subsections['year_4']->normalized_value() < 2010){ |
|
51 | + if ($this->_subsections['shirt_size']->normalized_value() == 's' |
|
52 | + && $this->_subsections['year_4']->normalized_value() < 2010) { |
|
53 | 53 | $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old'); |
54 | 54 | } |
55 | 55 | } |
@@ -2,16 +2,16 @@ |
||
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) |
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | - * EE_Form_Section_HTML |
|
6 | - * HTML to be laid out like a proper subsection |
|
7 | - * |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage |
|
11 | - * @author Mike Nelson |
|
12 | - * |
|
13 | - * ------------------------------------------------------------------------ |
|
14 | - */ |
|
5 | + * EE_Form_Section_HTML |
|
6 | + * HTML to be laid out like a proper subsection |
|
7 | + * |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage |
|
11 | + * @author Mike Nelson |
|
12 | + * |
|
13 | + * ------------------------------------------------------------------------ |
|
14 | + */ |
|
15 | 15 | class EE_Form_Section_HTML extends EE_Form_Section_Base{ |
16 | 16 | |
17 | 17 | protected $_html = ''; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | 5 | * EE_Form_Section_HTML |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * ------------------------------------------------------------------------ |
14 | 14 | */ |
15 | -class EE_Form_Section_HTML extends EE_Form_Section_Base{ |
|
15 | +class EE_Form_Section_HTML extends EE_Form_Section_Base { |
|
16 | 16 | |
17 | 17 | protected $_html = ''; |
18 | 18 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param string $html |
23 | 23 | * @param array $options_array |
24 | 24 | */ |
25 | - public function __construct( $html = '', $options_array = array() ) { |
|
25 | + public function __construct($html = '', $options_array = array()) { |
|
26 | 26 | $this->_html = $html; |
27 | - parent::__construct( $options_array ); |
|
27 | + parent::__construct($options_array); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | +} |
|
4 | 5 | /** |
5 | 6 | * EE_Form_Section_HTML |
6 | 7 | * HTML to be laid out like a proper subsection |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class EE_Validation_Error extends Exception{ |
|
3 | +class EE_Validation_Error extends Exception { |
|
4 | 4 | /** |
5 | 5 | * Form Section from which this error originated. |
6 | 6 | * @var EE_Form_Section |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param EE_Form_Section_Validatable $form_section |
21 | 21 | * @param Exception $previous if there was an exception that caused this exception |
22 | 22 | */ |
23 | - function __construct( $message = null, $string_code = null,$form_section = null, $previous = null){ |
|
23 | + function __construct($message = null, $string_code = null, $form_section = null, $previous = null) { |
|
24 | 24 | $this->_form_section = $form_section; |
25 | 25 | $this->_string_code = $string_code; |
26 | 26 | parent::__construct($message, 500, $previous); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * returns teh form section which caused the error. |
31 | 31 | * @return EE_Form_Section_Validatable |
32 | 32 | */ |
33 | - public function get_form_section(){ |
|
33 | + public function get_form_section() { |
|
34 | 34 | return $this->_form_section; |
35 | 35 | } |
36 | 36 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param EE_Form_Section_Validatable $form_section |
39 | 39 | * @return void |
40 | 40 | */ |
41 | - public function set_form_section($form_section){ |
|
41 | + public function set_form_section($form_section) { |
|
42 | 42 | $this->_form_section = $form_section; |
43 | 43 | } |
44 | 44 |