@@ -65,25 +65,25 @@ discard block |
||
65 | 65 | * } |
66 | 66 | * @return void |
67 | 67 | */ |
68 | - public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
68 | + public static function register($mt_name = NULL, $setup_args = array()) { |
|
69 | 69 | |
70 | 70 | //required fields MUST be present, so let's make sure they are. |
71 | - if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) ) |
|
71 | + if ( ! isset($mt_name) || ! is_array($setup_args) || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths'])) |
|
72 | 72 | throw new EE_Error( |
73 | - __( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' ) |
|
73 | + __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | //make sure we don't register twice |
77 | - if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){ |
|
77 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | 81 | //make sure this was called in the right place! |
82 | - if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
82 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) { |
|
83 | 83 | EE_Error::doing_it_wrong( |
84 | 84 | __METHOD__, |
85 | 85 | sprintf( |
86 | - __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'), |
|
86 | + __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', 'event_espresso'), |
|
87 | 87 | $mt_name |
88 | 88 | ), |
89 | 89 | '4.3.0' |
@@ -91,22 +91,22 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | //setup $__ee_message_type_registry array from incoming values. |
94 | - self::$_ee_message_type_registry[ $mt_name ] = array( |
|
94 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
95 | 95 | 'mtfilename' => (string) $setup_args['mtfilename'], |
96 | 96 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
97 | - 'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) ? (array) $setup_args['messengers_to_activate_with'] : array(), |
|
98 | - 'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) ? (array) $setup_args['messengers_to_validate_with'] : array(), |
|
99 | - 'force_activation' => ! empty( $setup_args['force_activation'] ) ? (bool) $setup_args['force_activation'] : array() |
|
97 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) ? (array) $setup_args['messengers_to_activate_with'] : array(), |
|
98 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) ? (array) $setup_args['messengers_to_validate_with'] : array(), |
|
99 | + 'force_activation' => ! empty($setup_args['force_activation']) ? (bool) $setup_args['force_activation'] : array() |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | //add filters |
103 | - add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Message_Type', 'register_msgs_autoload_paths'), 10 ); |
|
104 | - add_filter('FHEE__EE_messages__get_installed__messagetype_files', array( 'EE_Register_Message_Type', 'register_messagetype_files'), 10, 1 ); |
|
105 | - add_filter( 'FHEE__EE_messenger__get_default_message_types__default_types', array( 'EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), 10, 2 ); |
|
106 | - add_filter( 'FHEE__EE_messenger__get_valid_message_types__valid_types', array( 'EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), 10, 2 ); |
|
103 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), 10); |
|
104 | + add_filter('FHEE__EE_messages__get_installed__messagetype_files', array('EE_Register_Message_Type', 'register_messagetype_files'), 10, 1); |
|
105 | + add_filter('FHEE__EE_messenger__get_default_message_types__default_types', array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), 10, 2); |
|
106 | + add_filter('FHEE__EE_messenger__get_valid_message_types__valid_types', array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), 10, 2); |
|
107 | 107 | |
108 | 108 | //actions |
109 | - add_action( 'AHEE__EE_Addon__initialize_default_data__begin', array( 'EE_Register_Message_Type', 'set_defaults' ) ); |
|
109 | + add_action('AHEE__EE_Addon__initialize_default_data__begin', array('EE_Register_Message_Type', 'set_defaults')); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | EEH_Activation::generate_default_message_templates(); |
120 | 120 | |
121 | 121 | //for any message types with force activation, let's ensure they are activated |
122 | - foreach ( self::$_ee_message_type_registry as $mtname => $settings ) { |
|
123 | - if ( $settings['force_activation'] ) { |
|
122 | + foreach (self::$_ee_message_type_registry as $mtname => $settings) { |
|
123 | + if ($settings['force_activation']) { |
|
124 | 124 | $MSG = new EE_Messages(); |
125 | - foreach ( $settings['messengers_to_activate_with'] as $messenger ) { |
|
126 | - $MSG->ensure_message_type_is_active( $mtname, $messenger ); |
|
125 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
126 | + $MSG->ensure_message_type_is_active($mtname, $messenger); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | * @param string $mt_name the name for the message type that was previously registered |
140 | 140 | * @return void |
141 | 141 | */ |
142 | - public static function deregister( $mt_name = NULL ) { |
|
143 | - if ( !empty( self::$_ee_message_type_registry[$mt_name] ) ) { |
|
142 | + public static function deregister($mt_name = NULL) { |
|
143 | + if ( ! empty(self::$_ee_message_type_registry[$mt_name])) { |
|
144 | 144 | //let's make sure that we remove any place this message type was made active |
145 | 145 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
146 | - foreach( $active_messengers as $messenger => $settings ) { |
|
147 | - if ( !empty( $settings['settings'][$messenger . '-message_types'][$mt_name] ) ) { |
|
148 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
146 | + foreach ($active_messengers as $messenger => $settings) { |
|
147 | + if ( ! empty($settings['settings'][$messenger.'-message_types'][$mt_name])) { |
|
148 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]); |
|
149 | 149 | } |
150 | 150 | } |
151 | - EEH_MSG_Template::update_to_inactive( '', $mt_name ); |
|
152 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
153 | - unset( self::$_ee_message_type_registry[$mt_name] ); |
|
151 | + EEH_MSG_Template::update_to_inactive('', $mt_name); |
|
152 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
153 | + unset(self::$_ee_message_type_registry[$mt_name]); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | * @param array $messagetype_files The current array of message type file names |
165 | 165 | * @return array Array of message type file names |
166 | 166 | */ |
167 | - public static function register_messagetype_files( $messagetype_files ) { |
|
168 | - if ( empty( self::$_ee_message_type_registry ) ) |
|
167 | + public static function register_messagetype_files($messagetype_files) { |
|
168 | + if (empty(self::$_ee_message_type_registry)) |
|
169 | 169 | return $messagetype_files; |
170 | 170 | |
171 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
172 | - if ( empty( $mt_reg['mtfilename' ] ) ) |
|
171 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
172 | + if (empty($mt_reg['mtfilename'])) |
|
173 | 173 | continue; |
174 | 174 | $messagetype_files[] = $mt_reg['mtfilename']; |
175 | 175 | } |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * @param array $paths array of paths to be checked by EE_messages autoloader. |
190 | 190 | * @return array |
191 | 191 | */ |
192 | - public static function register_msgs_autoload_paths( $paths ) { |
|
192 | + public static function register_msgs_autoload_paths($paths) { |
|
193 | 193 | |
194 | - if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
195 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
196 | - if ( empty( $mt_reg['autoloadpaths'] ) ) |
|
194 | + if ( ! empty(self::$_ee_message_type_registry)) { |
|
195 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
196 | + if (empty($mt_reg['autoloadpaths'])) |
|
197 | 197 | continue; |
198 | - $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
198 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -217,17 +217,17 @@ discard block |
||
217 | 217 | * @param EE_messenger $messenger The EE_messenger the filter is called from. |
218 | 218 | * @return array |
219 | 219 | */ |
220 | - public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) { |
|
221 | - if ( empty( self::$_ee_message_type_registry ) ) |
|
220 | + public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) { |
|
221 | + if (empty(self::$_ee_message_type_registry)) |
|
222 | 222 | return $default_types; |
223 | 223 | |
224 | - foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) { |
|
225 | - if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) |
|
224 | + foreach (self::$_ee_message_type_registry as $mt_name => $mt_reg) { |
|
225 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) |
|
226 | 226 | continue; |
227 | 227 | |
228 | 228 | //loop through each of the messengers and if it matches the loaded class then we add this message type to the |
229 | - foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
230 | - if ( $messenger->name == $msgr ) { |
|
229 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
230 | + if ($messenger->name == $msgr) { |
|
231 | 231 | $default_types[] = $mt_name; |
232 | 232 | } |
233 | 233 | } |
@@ -249,17 +249,17 @@ discard block |
||
249 | 249 | * @param EE_messenger $messenger The EE_messenger the filter is called from. |
250 | 250 | * @return array |
251 | 251 | */ |
252 | - public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
|
253 | - if ( empty( self::$_ee_message_type_registry ) ) |
|
252 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) { |
|
253 | + if (empty(self::$_ee_message_type_registry)) |
|
254 | 254 | return $valid_types; |
255 | 255 | |
256 | - foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) { |
|
257 | - if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) |
|
256 | + foreach (self::$_ee_message_type_registry as $mt_name => $mt_reg) { |
|
257 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) |
|
258 | 258 | continue; |
259 | 259 | |
260 | 260 | //loop through each of the messengers and if it matches the loaded class then we add this message type to the |
261 | - foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
262 | - if ( $messenger->name == $msgr ) { |
|
261 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
262 | + if ($messenger->name == $msgr) { |
|
263 | 263 | $valid_types[] = $mt_name; |
264 | 264 | } |
265 | 265 | } |
@@ -18,58 +18,58 @@ discard block |
||
18 | 18 | class EE_Register_Message_Type implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Holds values for registered message types |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_message_type_registry = array(); |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * Method for registering new message types in the EE_messages system. |
|
30 | - * |
|
31 | - * Note: All message types must have the following files in order to work: |
|
32 | - * |
|
33 | - * - Template files for default templates getting setup. See /core/libraries/messages/defaults/default/ for examples (note that template files match a specific naming schema). These templates will need to be registered with the default template pack. |
|
34 | - * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
35 | - * for examples. Note for any new message types, there will need to be a validator for each |
|
36 | - * messenger combo this message type can activate with. |
|
37 | - * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
38 | - * message type and its properties. |
|
39 | - * |
|
40 | - * @since 4.3.0 |
|
41 | - * |
|
21 | + /** |
|
22 | + * Holds values for registered message types |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_message_type_registry = array(); |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * Method for registering new message types in the EE_messages system. |
|
30 | + * |
|
31 | + * Note: All message types must have the following files in order to work: |
|
32 | + * |
|
33 | + * - Template files for default templates getting setup. See /core/libraries/messages/defaults/default/ for examples (note that template files match a specific naming schema). These templates will need to be registered with the default template pack. |
|
34 | + * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
35 | + * for examples. Note for any new message types, there will need to be a validator for each |
|
36 | + * messenger combo this message type can activate with. |
|
37 | + * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
38 | + * message type and its properties. |
|
39 | + * |
|
40 | + * @since 4.3.0 |
|
41 | + * |
|
42 | 42 | * @param string $mt_name Whatever is defined for the $name property of |
43 | 43 | * the message type you are registering (eg. |
44 | 44 | * declined_registration). Required. |
45 | - * @param array $setup_args { |
|
46 | - * An array of arguments provided for registering the message type. |
|
47 | - * |
|
48 | - * @type string $mtfilename The filename of the message type being |
|
49 | - * registered. This will be the main |
|
50 | - * EE_{Messagetype_Name}_message_type class. ( |
|
51 | - * eg. EE_Declined_Registration_message_type. |
|
52 | - * class.php). Required. |
|
53 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
54 | - * autoloader for the new message type. Required. |
|
55 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
56 | - * type should activate with. Each value in the |
|
57 | - * array should match the name property of a |
|
58 | - * EE_messenger. Optional. |
|
59 | - * @type array $messengers_to_validate_with An array of messengers that this message type is valid for. Each |
|
60 | - * value in the array should match the name property of an |
|
61 | - * EE_messenger. Optional. |
|
62 | - * @type bool $force_activation This simply is a way of indicating that this message type MUST be * |
|
63 | - * activated when the plugin is activated/reactivated (default false) |
|
64 | - * |
|
65 | - * } |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
69 | - |
|
70 | - //required fields MUST be present, so let's make sure they are. |
|
71 | - if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) ) |
|
72 | - throw new EE_Error( |
|
45 | + * @param array $setup_args { |
|
46 | + * An array of arguments provided for registering the message type. |
|
47 | + * |
|
48 | + * @type string $mtfilename The filename of the message type being |
|
49 | + * registered. This will be the main |
|
50 | + * EE_{Messagetype_Name}_message_type class. ( |
|
51 | + * eg. EE_Declined_Registration_message_type. |
|
52 | + * class.php). Required. |
|
53 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
54 | + * autoloader for the new message type. Required. |
|
55 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
56 | + * type should activate with. Each value in the |
|
57 | + * array should match the name property of a |
|
58 | + * EE_messenger. Optional. |
|
59 | + * @type array $messengers_to_validate_with An array of messengers that this message type is valid for. Each |
|
60 | + * value in the array should match the name property of an |
|
61 | + * EE_messenger. Optional. |
|
62 | + * @type bool $force_activation This simply is a way of indicating that this message type MUST be * |
|
63 | + * activated when the plugin is activated/reactivated (default false) |
|
64 | + * |
|
65 | + * } |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
69 | + |
|
70 | + //required fields MUST be present, so let's make sure they are. |
|
71 | + if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) ) |
|
72 | + throw new EE_Error( |
|
73 | 73 | __( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' ) |
74 | 74 | ); |
75 | 75 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - //make sure this was called in the right place! |
|
82 | - if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
83 | - EE_Error::doing_it_wrong( |
|
81 | + //make sure this was called in the right place! |
|
82 | + if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
83 | + EE_Error::doing_it_wrong( |
|
84 | 84 | __METHOD__, |
85 | 85 | sprintf( |
86 | 86 | __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'), |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | ), |
89 | 89 | '4.3.0' |
90 | 90 | ); |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | 93 | //setup $__ee_message_type_registry array from incoming values. |
94 | 94 | self::$_ee_message_type_registry[ $mt_name ] = array( |
95 | 95 | 'mtfilename' => (string) $setup_args['mtfilename'], |
96 | 96 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
97 | 97 | 'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) ? (array) $setup_args['messengers_to_activate_with'] : array(), |
98 | - 'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) ? (array) $setup_args['messengers_to_validate_with'] : array(), |
|
99 | - 'force_activation' => ! empty( $setup_args['force_activation'] ) ? (bool) $setup_args['force_activation'] : array() |
|
98 | + 'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) ? (array) $setup_args['messengers_to_validate_with'] : array(), |
|
99 | + 'force_activation' => ! empty( $setup_args['force_activation'] ) ? (bool) $setup_args['force_activation'] : array() |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | //add filters |
@@ -107,164 +107,164 @@ discard block |
||
107 | 107 | |
108 | 108 | //actions |
109 | 109 | add_action( 'AHEE__EE_Addon__initialize_default_data__begin', array( 'EE_Register_Message_Type', 'set_defaults' ) ); |
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of. |
|
116 | - */ |
|
117 | - public static function set_defaults() { |
|
118 | - //only set defaults if we're not in EE_Maintenance mode |
|
119 | - EEH_Activation::generate_default_message_templates(); |
|
120 | - |
|
121 | - //for any message types with force activation, let's ensure they are activated |
|
122 | - foreach ( self::$_ee_message_type_registry as $mtname => $settings ) { |
|
123 | - if ( $settings['force_activation'] ) { |
|
124 | - $MSG = new EE_Messages(); |
|
125 | - foreach ( $settings['messengers_to_activate_with'] as $messenger ) { |
|
126 | - $MSG->ensure_message_type_is_active( $mtname, $messenger ); |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * This deregisters a message type that was previously registered with a specific mtname. |
|
136 | - * |
|
137 | - * @since 4.3.0 |
|
138 | - * |
|
139 | - * @param string $mt_name the name for the message type that was previously registered |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public static function deregister( $mt_name = NULL ) { |
|
143 | - if ( !empty( self::$_ee_message_type_registry[$mt_name] ) ) { |
|
144 | - //let's make sure that we remove any place this message type was made active |
|
145 | - $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
|
146 | - foreach( $active_messengers as $messenger => $settings ) { |
|
147 | - if ( !empty( $settings['settings'][$messenger . '-message_types'][$mt_name] ) ) { |
|
148 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
149 | - } |
|
150 | - } |
|
151 | - EEH_MSG_Template::update_to_inactive( '', $mt_name ); |
|
152 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
153 | - unset( self::$_ee_message_type_registry[$mt_name] ); |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
161 | - * |
|
162 | - * @since 4.3.0 |
|
163 | - * |
|
164 | - * @param array $messagetype_files The current array of message type file names |
|
165 | - * @return array Array of message type file names |
|
166 | - */ |
|
167 | - public static function register_messagetype_files( $messagetype_files ) { |
|
168 | - if ( empty( self::$_ee_message_type_registry ) ) |
|
169 | - return $messagetype_files; |
|
170 | - |
|
171 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
172 | - if ( empty( $mt_reg['mtfilename' ] ) ) |
|
173 | - continue; |
|
174 | - $messagetype_files[] = $mt_reg['mtfilename']; |
|
175 | - } |
|
176 | - |
|
177 | - return $messagetype_files; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
186 | - * |
|
187 | - * @since 4.3.0 |
|
188 | - * |
|
189 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
190 | - * @return array |
|
191 | - */ |
|
192 | - public static function register_msgs_autoload_paths( $paths ) { |
|
193 | - |
|
194 | - if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
195 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
196 | - if ( empty( $mt_reg['autoloadpaths'] ) ) |
|
197 | - continue; |
|
198 | - $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
199 | - } |
|
200 | - } |
|
201 | - |
|
202 | - return $paths; |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
211 | - * |
|
212 | - * @since 4.3.0 |
|
213 | - * |
|
214 | - * |
|
215 | - * @param array $default_types array of message types activated with messenger ( |
|
216 | - * corresponds to the $name property of message type) |
|
217 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
218 | - * @return array |
|
219 | - */ |
|
220 | - public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) { |
|
221 | - if ( empty( self::$_ee_message_type_registry ) ) |
|
222 | - return $default_types; |
|
223 | - |
|
224 | - foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) { |
|
225 | - if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) |
|
226 | - continue; |
|
227 | - |
|
228 | - //loop through each of the messengers and if it matches the loaded class then we add this message type to the |
|
229 | - foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
230 | - if ( $messenger->name == $msgr ) { |
|
231 | - $default_types[] = $mt_name; |
|
232 | - } |
|
233 | - } |
|
234 | - } |
|
235 | - |
|
236 | - return $default_types; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
243 | - * |
|
244 | - * @since 4.3.0 |
|
245 | - * |
|
246 | - * |
|
247 | - * @param array $valid_types array of message types valid with messenger ( |
|
248 | - * corresponds to the $name property of message type) |
|
249 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
250 | - * @return array |
|
251 | - */ |
|
252 | - public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
|
253 | - if ( empty( self::$_ee_message_type_registry ) ) |
|
254 | - return $valid_types; |
|
255 | - |
|
256 | - foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) { |
|
257 | - if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) |
|
258 | - continue; |
|
259 | - |
|
260 | - //loop through each of the messengers and if it matches the loaded class then we add this message type to the |
|
261 | - foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
262 | - if ( $messenger->name == $msgr ) { |
|
263 | - $valid_types[] = $mt_name; |
|
264 | - } |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - return $valid_types; |
|
269 | - } |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of. |
|
116 | + */ |
|
117 | + public static function set_defaults() { |
|
118 | + //only set defaults if we're not in EE_Maintenance mode |
|
119 | + EEH_Activation::generate_default_message_templates(); |
|
120 | + |
|
121 | + //for any message types with force activation, let's ensure they are activated |
|
122 | + foreach ( self::$_ee_message_type_registry as $mtname => $settings ) { |
|
123 | + if ( $settings['force_activation'] ) { |
|
124 | + $MSG = new EE_Messages(); |
|
125 | + foreach ( $settings['messengers_to_activate_with'] as $messenger ) { |
|
126 | + $MSG->ensure_message_type_is_active( $mtname, $messenger ); |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * This deregisters a message type that was previously registered with a specific mtname. |
|
136 | + * |
|
137 | + * @since 4.3.0 |
|
138 | + * |
|
139 | + * @param string $mt_name the name for the message type that was previously registered |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public static function deregister( $mt_name = NULL ) { |
|
143 | + if ( !empty( self::$_ee_message_type_registry[$mt_name] ) ) { |
|
144 | + //let's make sure that we remove any place this message type was made active |
|
145 | + $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
|
146 | + foreach( $active_messengers as $messenger => $settings ) { |
|
147 | + if ( !empty( $settings['settings'][$messenger . '-message_types'][$mt_name] ) ) { |
|
148 | + unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
149 | + } |
|
150 | + } |
|
151 | + EEH_MSG_Template::update_to_inactive( '', $mt_name ); |
|
152 | + EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
153 | + unset( self::$_ee_message_type_registry[$mt_name] ); |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
161 | + * |
|
162 | + * @since 4.3.0 |
|
163 | + * |
|
164 | + * @param array $messagetype_files The current array of message type file names |
|
165 | + * @return array Array of message type file names |
|
166 | + */ |
|
167 | + public static function register_messagetype_files( $messagetype_files ) { |
|
168 | + if ( empty( self::$_ee_message_type_registry ) ) |
|
169 | + return $messagetype_files; |
|
170 | + |
|
171 | + foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
172 | + if ( empty( $mt_reg['mtfilename' ] ) ) |
|
173 | + continue; |
|
174 | + $messagetype_files[] = $mt_reg['mtfilename']; |
|
175 | + } |
|
176 | + |
|
177 | + return $messagetype_files; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
186 | + * |
|
187 | + * @since 4.3.0 |
|
188 | + * |
|
189 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
190 | + * @return array |
|
191 | + */ |
|
192 | + public static function register_msgs_autoload_paths( $paths ) { |
|
193 | + |
|
194 | + if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
195 | + foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
196 | + if ( empty( $mt_reg['autoloadpaths'] ) ) |
|
197 | + continue; |
|
198 | + $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
199 | + } |
|
200 | + } |
|
201 | + |
|
202 | + return $paths; |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
211 | + * |
|
212 | + * @since 4.3.0 |
|
213 | + * |
|
214 | + * |
|
215 | + * @param array $default_types array of message types activated with messenger ( |
|
216 | + * corresponds to the $name property of message type) |
|
217 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
218 | + * @return array |
|
219 | + */ |
|
220 | + public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) { |
|
221 | + if ( empty( self::$_ee_message_type_registry ) ) |
|
222 | + return $default_types; |
|
223 | + |
|
224 | + foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) { |
|
225 | + if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) |
|
226 | + continue; |
|
227 | + |
|
228 | + //loop through each of the messengers and if it matches the loaded class then we add this message type to the |
|
229 | + foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
230 | + if ( $messenger->name == $msgr ) { |
|
231 | + $default_types[] = $mt_name; |
|
232 | + } |
|
233 | + } |
|
234 | + } |
|
235 | + |
|
236 | + return $default_types; |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
243 | + * |
|
244 | + * @since 4.3.0 |
|
245 | + * |
|
246 | + * |
|
247 | + * @param array $valid_types array of message types valid with messenger ( |
|
248 | + * corresponds to the $name property of message type) |
|
249 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
250 | + * @return array |
|
251 | + */ |
|
252 | + public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
|
253 | + if ( empty( self::$_ee_message_type_registry ) ) |
|
254 | + return $valid_types; |
|
255 | + |
|
256 | + foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) { |
|
257 | + if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) |
|
258 | + continue; |
|
259 | + |
|
260 | + //loop through each of the messengers and if it matches the loaded class then we add this message type to the |
|
261 | + foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
262 | + if ( $messenger->name == $msgr ) { |
|
263 | + $valid_types[] = $mt_name; |
|
264 | + } |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + return $valid_types; |
|
269 | + } |
|
270 | 270 | } |
@@ -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() . ': ' : ''; |
|
273 | + $html = EEH_HTML::tr('', '', $row_class); |
|
274 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type().': ' : ''; |
|
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(); |
@@ -57,29 +57,29 @@ discard block |
||
57 | 57 | * @param array $options |
58 | 58 | * @return mixed |
59 | 59 | */ |
60 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
60 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
61 | 61 | |
62 | 62 | $html = ''; |
63 | 63 | // set some default options and merge with incoming |
64 | 64 | $default_options = array( |
65 | - 'show_desc' => TRUE, // TRUE FALSE |
|
65 | + 'show_desc' => TRUE, // TRUE FALSE |
|
66 | 66 | 'odd' => FALSE |
67 | 67 | ); |
68 | - $options = array_merge( $default_options, (array)$options ); |
|
68 | + $options = array_merge($default_options, (array) $options); |
|
69 | 69 | |
70 | - switch( $line_item->type() ) { |
|
70 | + switch ($line_item->type()) { |
|
71 | 71 | |
72 | 72 | case EEM_Line_Item::type_line_item: |
73 | 73 | // item row |
74 | - $html .= $this->_item_row( $line_item, $options ); |
|
74 | + $html .= $this->_item_row($line_item, $options); |
|
75 | 75 | // got any kids? |
76 | - foreach ( $line_item->children() as $child_line_item ) { |
|
77 | - $this->display_line_item( $child_line_item, $options ); |
|
76 | + foreach ($line_item->children() as $child_line_item) { |
|
77 | + $this->display_line_item($child_line_item, $options); |
|
78 | 78 | } |
79 | 79 | break; |
80 | 80 | |
81 | 81 | case EEM_Line_Item::type_sub_line_item: |
82 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
82 | + $html .= $this->_sub_item_row($line_item, $options); |
|
83 | 83 | break; |
84 | 84 | |
85 | 85 | case EEM_Line_Item::type_sub_total: |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | break; |
91 | 91 | |
92 | 92 | case EEM_Line_Item::type_tax_sub_total: |
93 | - foreach ( $line_item->children() as $child_line_item ) { |
|
94 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax ) { |
|
93 | + foreach ($line_item->children() as $child_line_item) { |
|
94 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
95 | 95 | // recursively feed children back into this method |
96 | - $this->display_line_item( $child_line_item, $options ); |
|
96 | + $this->display_line_item($child_line_item, $options); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | break; |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | case EEM_Line_Item::type_total: |
102 | 102 | // get all child line items |
103 | 103 | $children = $line_item->children(); |
104 | - if ( $options[ 'set_tax_rate' ] === true ) { |
|
104 | + if ($options['set_tax_rate'] === true) { |
|
105 | 105 | // loop thru tax child line items just to determine tax rate |
106 | - foreach ( $children as $child_line_item ) { |
|
107 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) { |
|
106 | + foreach ($children as $child_line_item) { |
|
107 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
108 | 108 | // recursively feed children back into this method |
109 | - $this->display_line_item( $child_line_item, $options ); |
|
109 | + $this->display_line_item($child_line_item, $options); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } else { |
113 | 113 | // now loop thru all non-tax child line items |
114 | - foreach ( $children as $child_line_item ) { |
|
115 | - if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) { |
|
114 | + foreach ($children as $child_line_item) { |
|
115 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
116 | 116 | // recursively feed children back into this method |
117 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
117 | + $html .= $this->display_line_item($child_line_item, $options); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * @param array $options |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
137 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
138 | 138 | // start of row |
139 | 139 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
140 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
140 | + $html = EEH_HTML::tr('', '', $row_class); |
|
141 | 141 | // name && desc |
142 | 142 | $name_and_desc = apply_filters( |
143 | 143 | 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name', |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | ); |
147 | 147 | $name_and_desc .= apply_filters( |
148 | 148 | 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
149 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
149 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
150 | 150 | $line_item, |
151 | 151 | $options |
152 | 152 | ); |
153 | - $name_and_desc .= $line_item->is_taxable() ? '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable item', 'event_espresso' ) . '</span>' : ''; |
|
153 | + $name_and_desc .= $line_item->is_taxable() ? '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable item', 'event_espresso').'</span>' : ''; |
|
154 | 154 | // name td |
155 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
155 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
156 | 156 | // quantity td |
157 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
158 | - $tax_rate = $line_item->is_taxable() ? 1 + ( $this->_tax_rate / 100 ) : 1; |
|
157 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
158 | + $tax_rate = $line_item->is_taxable() ? 1 + ($this->_tax_rate / 100) : 1; |
|
159 | 159 | // price td |
160 | - $unit_price = EEH_Template::format_currency( $line_item->unit_price() * $tax_rate, false, false ); |
|
161 | - $html .= EEH_HTML::td( $unit_price, '', 'item_c jst-rght' ); |
|
160 | + $unit_price = EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false); |
|
161 | + $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght'); |
|
162 | 162 | // total td |
163 | - $total = EEH_Template::format_currency( $line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false ); |
|
164 | - $html .= EEH_HTML::td( $total, '', 'item_r jst-rght' ); |
|
163 | + $total = EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false); |
|
164 | + $html .= EEH_HTML::td($total, '', 'item_r jst-rght'); |
|
165 | 165 | // end of row |
166 | 166 | $html .= EEH_HTML::trx(); |
167 | 167 | |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | * @param array $options |
178 | 178 | * @return mixed |
179 | 179 | */ |
180 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
180 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
181 | 181 | // start of row |
182 | - $html = EEH_HTML::tr( '', 'item sub-item-row' ); |
|
182 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
183 | 183 | // name && desc |
184 | 184 | $name_and_desc = $line_item->name(); |
185 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
185 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
186 | 186 | // name td |
187 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
187 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
188 | 188 | // discount/surcharge td |
189 | - if ( $line_item->is_percent() ) { |
|
190 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c' ); |
|
189 | + if ($line_item->is_percent()) { |
|
190 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
191 | 191 | } else { |
192 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
192 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
193 | 193 | } |
194 | 194 | // total td |
195 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
195 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
196 | 196 | // end of row |
197 | 197 | $html .= EEH_HTML::trx(); |
198 | 198 | return $html; |
@@ -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; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param array $options |
19 | 19 | * @return mixed |
20 | 20 | */ |
21 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
21 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
22 | 22 | |
23 | 23 | $html = ''; |
24 | 24 | // set some default options and merge with incoming |
@@ -26,58 +26,58 @@ discard block |
||
26 | 26 | 'show_desc' => TRUE, |
27 | 27 | 'odd' => FALSE |
28 | 28 | ); |
29 | - $options = array_merge( $default_options, (array)$options ); |
|
29 | + $options = array_merge($default_options, (array) $options); |
|
30 | 30 | |
31 | - switch( $line_item->type() ) { |
|
31 | + switch ($line_item->type()) { |
|
32 | 32 | |
33 | 33 | case EEM_Line_Item::type_total: |
34 | 34 | // loop thru children |
35 | - foreach( $line_item->children() as $child_line_item ) { |
|
35 | + foreach ($line_item->children() as $child_line_item) { |
|
36 | 36 | // recursively feed children back into this method |
37 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
37 | + $html .= $this->display_line_item($child_line_item, $options); |
|
38 | 38 | } |
39 | - $html .= $this->_separator_row( $options ); |
|
40 | - $html .= $this->_total_row( $line_item, __('Total', 'event_espresso'), $options ); |
|
39 | + $html .= $this->_separator_row($options); |
|
40 | + $html .= $this->_total_row($line_item, __('Total', 'event_espresso'), $options); |
|
41 | 41 | break; |
42 | 42 | |
43 | 43 | |
44 | 44 | case EEM_Line_Item::type_sub_total: |
45 | 45 | // loop thru children |
46 | - foreach( $line_item->children() as $child_line_item ) { |
|
46 | + foreach ($line_item->children() as $child_line_item) { |
|
47 | 47 | // recursively feed children back into this method |
48 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
48 | + $html .= $this->display_line_item($child_line_item, $options); |
|
49 | 49 | } |
50 | - $html .= $this->_total_row( $line_item, __('Sub-Total', 'event_espresso'), $options ); |
|
50 | + $html .= $this->_total_row($line_item, __('Sub-Total', 'event_espresso'), $options); |
|
51 | 51 | break; |
52 | 52 | |
53 | 53 | |
54 | 54 | case EEM_Line_Item::type_tax_sub_total: |
55 | 55 | // loop thru children |
56 | - foreach( $line_item->children() as $child_line_item ) { |
|
56 | + foreach ($line_item->children() as $child_line_item) { |
|
57 | 57 | // recursively feed children back into this method |
58 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
58 | + $html .= $this->display_line_item($child_line_item, $options); |
|
59 | 59 | } |
60 | - $html .= $this->_total_row( $line_item, __('Tax Total', 'event_espresso'), $options ); |
|
60 | + $html .= $this->_total_row($line_item, __('Tax Total', 'event_espresso'), $options); |
|
61 | 61 | break; |
62 | 62 | |
63 | 63 | |
64 | 64 | case EEM_Line_Item::type_line_item: |
65 | 65 | // item row |
66 | - $html .= $this->_item_row( $line_item, $options ); |
|
66 | + $html .= $this->_item_row($line_item, $options); |
|
67 | 67 | // got any kids? |
68 | - foreach( $line_item->children() as $child_line_item ) { |
|
69 | - $this->display_line_item( $child_line_item, $options ); |
|
68 | + foreach ($line_item->children() as $child_line_item) { |
|
69 | + $this->display_line_item($child_line_item, $options); |
|
70 | 70 | } |
71 | 71 | break; |
72 | 72 | |
73 | 73 | |
74 | 74 | case EEM_Line_Item::type_sub_line_item: |
75 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
75 | + $html .= $this->_sub_item_row($line_item, $options); |
|
76 | 76 | break; |
77 | 77 | |
78 | 78 | |
79 | 79 | case EEM_Line_Item::type_tax: |
80 | - $html .= $this->_tax_row( $line_item, $options ); |
|
80 | + $html .= $this->_tax_row($line_item, $options); |
|
81 | 81 | break; |
82 | 82 | |
83 | 83 | } |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | * @param array $options |
95 | 95 | * @return mixed |
96 | 96 | */ |
97 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
97 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
98 | 98 | // start of row |
99 | 99 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
100 | - $html = EEH_HTML::tr( '', $row_class ); |
|
100 | + $html = EEH_HTML::tr('', $row_class); |
|
101 | 101 | // name td |
102 | - $html .= EEH_HTML::td( $line_item->name(), '', 'item_l' ); |
|
102 | + $html .= EEH_HTML::td($line_item->name(), '', 'item_l'); |
|
103 | 103 | // desc td |
104 | - $html .= $options['show_desc'] ? EEH_HTML::td( $line_item->desc(), '', 'item_l' ) : ''; |
|
104 | + $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
105 | 105 | // quantity td |
106 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l' ); |
|
106 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l'); |
|
107 | 107 | // price td |
108 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c' ); |
|
108 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
|
109 | 109 | // total td |
110 | - $total = $line_item->is_taxable() ? $line_item->total_no_code() . '*' : $line_item->total_no_code(); |
|
111 | - $html .= EEH_HTML::td( $total, '', 'item_r' ); |
|
110 | + $total = $line_item->is_taxable() ? $line_item->total_no_code().'*' : $line_item->total_no_code(); |
|
111 | + $html .= EEH_HTML::td($total, '', 'item_r'); |
|
112 | 112 | // end of row |
113 | 113 | $html .= EEH_HTML::trx(); |
114 | 114 | return $html; |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | * @param array $options |
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
126 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
127 | 127 | // start of row |
128 | - $html = EEH_HTML::tr( '', 'item sub-item-row' ); |
|
128 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
129 | 129 | // name td |
130 | - $html .= EEH_HTML::td( $line_item->name(), '', 'item_l sub-item' ); |
|
130 | + $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
|
131 | 131 | // desc td |
132 | - $html .= $options['show_desc'] ? EEH_HTML::td( $line_item->desc(), '', 'item_l' ) : ''; |
|
133 | - $html .= EEH_HTML::td() . EEH_HTML::tdx(); |
|
132 | + $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
133 | + $html .= EEH_HTML::td().EEH_HTML::tdx(); |
|
134 | 134 | // discount/surcharge td |
135 | - if ( $line_item->is_percent() ) { |
|
136 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c' ); |
|
135 | + if ($line_item->is_percent()) { |
|
136 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
137 | 137 | } else { |
138 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c' ); |
|
138 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
|
139 | 139 | } |
140 | 140 | // total td |
141 | - $html .= EEH_HTML::td( $line_item->total_no_code(), '', 'item_r' ); |
|
141 | + $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
|
142 | 142 | // end of row |
143 | 143 | $html .= EEH_HTML::trx(); |
144 | 144 | return $html; |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | * @param array $options |
154 | 154 | * @return mixed |
155 | 155 | */ |
156 | - private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
156 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
157 | 157 | // start of row |
158 | - $html = EEH_HTML::tr( '', 'item sub-item tax-total' ); |
|
158 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
159 | 159 | // name td |
160 | - $html .= EEH_HTML::td( $line_item->name(), '', 'item_l sub-item' ); |
|
160 | + $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
|
161 | 161 | // desc td |
162 | - $html .= $options['show_desc'] ? EEH_HTML::td( $line_item->desc(), '', 'item_l' ) : ''; |
|
162 | + $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
163 | 163 | // percent td |
164 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c', '', ' colspan="2"' ); |
|
164 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c', '', ' colspan="2"'); |
|
165 | 165 | // total td |
166 | - $html .= EEH_HTML::td( $line_item->total_no_code(), '', 'item_r' ); |
|
166 | + $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
|
167 | 167 | // end of row |
168 | 168 | $html .= EEH_HTML::trx(); |
169 | 169 | return $html; |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | * @param array $options |
180 | 180 | * @return mixed |
181 | 181 | */ |
182 | - private function _total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
182 | + private function _total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
183 | 183 | // colspan |
184 | 184 | $colspan = $options['show_desc'] ? ' colspan="2"' : ''; |
185 | 185 | // start of row |
186 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
186 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
187 | 187 | // empty td |
188 | - $html .= EEH_HTML::td( EEH_HTML::nbsp(), '', '', '', $colspan ); |
|
188 | + $html .= EEH_HTML::td(EEH_HTML::nbsp(), '', '', '', $colspan); |
|
189 | 189 | // total td |
190 | - $html .= EEH_HTML::td( $text, '', 'total_currency total', '', $colspan ); |
|
190 | + $html .= EEH_HTML::td($text, '', 'total_currency total', '', $colspan); |
|
191 | 191 | // total td |
192 | - $html .= EEH_HTML::td( $line_item->total_no_code(), '', 'total' ); |
|
192 | + $html .= EEH_HTML::td($line_item->total_no_code(), '', 'total'); |
|
193 | 193 | // end of row |
194 | 194 | $html .= EEH_HTML::trx(); |
195 | 195 | return $html; |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @param array $options |
204 | 204 | * @return mixed |
205 | 205 | */ |
206 | - private function _separator_row( $options = array() ) { |
|
206 | + private function _separator_row($options = array()) { |
|
207 | 207 | // colspan |
208 | 208 | $colspan = $options['show_desc'] ? ' colspan="5"' : ' colspan="4"'; |
209 | 209 | // start of row |
210 | - $html = EEH_HTML::tr( EEH_HTML::td( '<hr>', '', '', '', $colspan )); |
|
210 | + $html = EEH_HTML::tr(EEH_HTML::td('<hr>', '', '', '', $colspan)); |
|
211 | 211 | // // separator td |
212 | 212 | // $html .= EEH_HTML::td( '<hr>', '', '', '', $colspan ); |
213 | 213 | // // end of row |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $options |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
52 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
53 | 53 | |
54 | 54 | $html = ''; |
55 | 55 | // set some default options and merge with incoming |
@@ -60,40 +60,40 @@ discard block |
||
60 | 60 | 'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr', |
61 | 61 | 'total_tr_css_class' => 'admin-primary-mbox-total-tr' |
62 | 62 | ); |
63 | - $options = array_merge( $default_options, (array)$options ); |
|
63 | + $options = array_merge($default_options, (array) $options); |
|
64 | 64 | |
65 | - switch( $line_item->type() ) { |
|
65 | + switch ($line_item->type()) { |
|
66 | 66 | |
67 | 67 | case EEM_Line_Item::type_line_item: |
68 | 68 | // item row |
69 | - $html .= $this->_item_row( $line_item, $options ); |
|
69 | + $html .= $this->_item_row($line_item, $options); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | case EEM_Line_Item::type_sub_line_item: |
73 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
73 | + $html .= $this->_sub_item_row($line_item, $options); |
|
74 | 74 | break; |
75 | 75 | |
76 | 76 | case EEM_Line_Item::type_sub_total: |
77 | 77 | //loop through children |
78 | 78 | $child_line_items = $line_item->children(); |
79 | 79 | //loop through children |
80 | - foreach ( $child_line_items as $child_line_item ) { |
|
80 | + foreach ($child_line_items as $child_line_item) { |
|
81 | 81 | //recursively feed children back into this method |
82 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
82 | + $html .= $this->display_line_item($child_line_item, $options); |
|
83 | 83 | } |
84 | - $html .= $this->_sub_total_row( $line_item, $options ); |
|
84 | + $html .= $this->_sub_total_row($line_item, $options); |
|
85 | 85 | break; |
86 | 86 | |
87 | 87 | case EEM_Line_Item::type_tax: |
88 | - if ( $this->_show_taxes ) { |
|
89 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
88 | + if ($this->_show_taxes) { |
|
89 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
90 | 90 | } |
91 | 91 | break; |
92 | 92 | |
93 | 93 | case EEM_Line_Item::type_tax_sub_total: |
94 | - foreach( $line_item->children() as $child_line_item ) { |
|
95 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax ) { |
|
96 | - $this->display_line_item( $child_line_item, $options ); |
|
94 | + foreach ($line_item->children() as $child_line_item) { |
|
95 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
96 | + $this->display_line_item($child_line_item, $options); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | break; |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $children = $line_item->children(); |
106 | 106 | |
107 | 107 | // loop thru all non-tax child line items |
108 | - foreach( $children as $child_line_item ) { |
|
109 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
108 | + foreach ($children as $child_line_item) { |
|
109 | + $html .= $this->display_line_item($child_line_item, $options); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $html .= $this->_taxes_html; |
113 | - $html .= $this->_total_row( $line_item, $options ); |
|
114 | - if ( $options['use_table_wrapper'] ) { |
|
115 | - $html = $this->_table_header( $options ) . $html . $this->_table_footer( $options ); |
|
113 | + $html .= $this->_total_row($line_item, $options); |
|
114 | + if ($options['use_table_wrapper']) { |
|
115 | + $html = $this->_table_header($options).$html.$this->_table_footer($options); |
|
116 | 116 | } |
117 | 117 | break; |
118 | 118 | |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * @param array $options |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - protected function _table_header( $options ) { |
|
133 | - $html = EEH_HTML::table( '','', $options['table_css_class'] ); |
|
132 | + protected function _table_header($options) { |
|
133 | + $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
134 | 134 | $html .= EEH_HTML::thead(); |
135 | 135 | $html .= EEH_HTML::tr(); |
136 | - $html .= EEH_HTML::th( __( 'Name', 'event_espresso' ), '', 'jst-left' ); |
|
137 | - $html .= EEH_HTML::th( __( 'Type', 'event_espresso'), '', 'jst-left' ); |
|
138 | - $html .= EEH_HTML::th( __( 'Amount', 'event_espresso' ), '', 'jst-cntr' ); |
|
139 | - $html .= EEH_HTML::th( __( 'Qty', 'event_espresso' ), '', 'jst-cntr' ); |
|
140 | - $html .= EEH_HTML::th( __( 'Line Total', 'event_espresso'), '', 'jst-cntr' ); |
|
136 | + $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
137 | + $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
138 | + $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
139 | + $html .= EEH_HTML::th(__('Qty', 'event_espresso'), '', 'jst-cntr'); |
|
140 | + $html .= EEH_HTML::th(__('Line Total', 'event_espresso'), '', 'jst-cntr'); |
|
141 | 141 | $html .= EEH_HTML::tbody(); |
142 | 142 | return $html; |
143 | 143 | } |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param array $options array of options for the table. |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - protected function _table_footer( $options ) { |
|
153 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex(); |
|
152 | + protected function _table_footer($options) { |
|
153 | + return EEH_HTML::tbodyx().EEH_HTML::tablex(); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * @param array $options |
163 | 163 | * @return mixed |
164 | 164 | */ |
165 | - protected function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
165 | + protected function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
166 | 166 | $line_item_related_object = $line_item->get_object(); |
167 | 167 | $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null; |
168 | 168 | // start of row |
169 | 169 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
170 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
170 | + $html = EEH_HTML::tr('', '', $row_class); |
|
171 | 171 | |
172 | 172 | |
173 | 173 | //Name Column |
@@ -175,44 +175,44 @@ discard block |
||
175 | 175 | |
176 | 176 | //related object scope. |
177 | 177 | $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : ''; |
178 | - $parent_related_object_name = empty( $parent_related_object_name ) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
178 | + $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
179 | 179 | $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : ''; |
180 | 180 | |
181 | 181 | |
182 | 182 | $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name(); |
183 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html; |
|
183 | + $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>' : $name_html; |
|
184 | 184 | $name_html .= $line_item->is_taxable() ? ' *' : ''; |
185 | 185 | //maybe preface with icon? |
186 | - $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html; |
|
187 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
188 | - $name_html .= sprintf( |
|
189 | - _x( '%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
186 | + $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon().$name_html : $name_html; |
|
187 | + $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>'; |
|
188 | + $name_html .= sprintf( |
|
189 | + _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
190 | 190 | '<span class="ee-line-item-related-parent-object">', |
191 | - $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type() : __( 'Item:', 'event_espresso' ), |
|
192 | - $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name, |
|
191 | + $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type() : __('Item:', 'event_espresso'), |
|
192 | + $parent_related_object_link ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>' : $parent_related_object_name, |
|
193 | 193 | '</span>' |
194 | 194 | ); |
195 | - $html .= EEH_HTML::td( $name_html, '', 'jst-left' ); |
|
195 | + $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
196 | 196 | |
197 | 197 | //Type Column |
198 | - $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type() . '<br />' : ''; |
|
198 | + $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type().'<br />' : ''; |
|
199 | 199 | $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
200 | - $type_html .= ! empty( $code ) ? '<span class="ee-line-item-id">' . sprintf( __( 'Code: %s', 'event_espresso' ), $code ) . '</span>' : ''; |
|
201 | - $html .= EEH_HTML::td( $type_html, '', 'jst-left' ); |
|
200 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : ''; |
|
201 | + $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
202 | 202 | |
203 | 203 | |
204 | 204 | //Amount Column |
205 | - if ( $line_item->is_percent() ) { |
|
206 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'jst-rght' ); |
|
205 | + if ($line_item->is_percent()) { |
|
206 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght'); |
|
207 | 207 | } else { |
208 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'jst-rght' ); |
|
208 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | //QTY column |
212 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'jst-rght' ); |
|
212 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'jst-rght'); |
|
213 | 213 | |
214 | 214 | //total column |
215 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
215 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
216 | 216 | |
217 | 217 | //finish things off and return |
218 | 218 | $html .= EEH_HTML::trx(); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $options |
229 | 229 | * @return mixed |
230 | 230 | */ |
231 | - protected function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
231 | + protected function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
232 | 232 | //for now we're not showing sub-items |
233 | 233 | return ''; |
234 | 234 | } |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | * @param array $options |
243 | 243 | * @return mixed |
244 | 244 | */ |
245 | - protected function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
245 | + protected function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
246 | 246 | // start of row |
247 | - $html = EEH_HTML::tr( '', 'admin-primary-mbox-taxes-tr' ); |
|
247 | + $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
248 | 248 | // name th |
249 | - $html .= EEH_HTML::th( $line_item->name() . '(' . $line_item->get_pretty( 'LIN_percent' ) . '%)', '', 'jst-rght', '', ' colspan="4"' ); |
|
249 | + $html .= EEH_HTML::th($line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)', '', 'jst-rght', '', ' colspan="4"'); |
|
250 | 250 | // total th |
251 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
251 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
252 | 252 | // end of row |
253 | 253 | $html .= EEH_HTML::trx(); |
254 | 254 | return $html; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @param array $options |
266 | 266 | * @return mixed |
267 | 267 | */ |
268 | - protected function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
268 | + protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
269 | 269 | //currently not showing subtotal row |
270 | 270 | return ''; |
271 | 271 | } |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | * @param array $options |
280 | 280 | * @return mixed |
281 | 281 | */ |
282 | - protected function _total_row( EE_Line_Item $line_item, $options = array() ) { |
|
282 | + protected function _total_row(EE_Line_Item $line_item, $options = array()) { |
|
283 | 283 | // start of row |
284 | - $html = EEH_HTML::tr( '', '', 'admin-primary-mbox-total-tr' ); |
|
284 | + $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
285 | 285 | // Total th label |
286 | - $total_label = sprintf( __( 'Transaction Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' ); |
|
287 | - $html .= EEH_HTML::th( $total_label, '', 'jst-rght', '', ' colspan="4"' ); |
|
286 | + $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
287 | + $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"'); |
|
288 | 288 | // total th |
289 | 289 | |
290 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
290 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
291 | 291 | // end of row |
292 | 292 | $html .= EEH_HTML::trx(); |
293 | 293 | return $html; |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @param \WP_REST_Request $request |
47 | 47 | * @return \WP_REST_Response|\WP_Error |
48 | 48 | */ |
49 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
49 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
50 | 50 | $controller = new Read(); |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $matches = $controller->parse_route( |
53 | 53 | $request->get_route(), |
54 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
55 | - array( 'version', 'model' ) |
|
54 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
55 | + array('version', 'model') |
|
56 | 56 | ); |
57 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
58 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
59 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
57 | + $controller->set_requested_version($matches['version']); |
|
58 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
59 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
60 | 60 | return $controller->send_response( |
61 | 61 | new \WP_Error( |
62 | 62 | 'endpoint_parsing_error', |
63 | 63 | sprintf( |
64 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
64 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
65 | 65 | $model_name_singular |
66 | 66 | ) |
67 | 67 | ) |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | return $controller->send_response( |
71 | 71 | $controller->get_entities_from_model( |
72 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
72 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
73 | 73 | $request |
74 | 74 | ) |
75 | 75 | ); |
76 | - } catch( \Exception $e ) { |
|
77 | - return $controller->send_response( $e ); |
|
76 | + } catch (\Exception $e) { |
|
77 | + return $controller->send_response($e); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @param \WP_REST_Request $request |
85 | 85 | * @return \WP_REST_Response|\WP_Error |
86 | 86 | */ |
87 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
87 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
88 | 88 | $controller = new Read(); |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $matches = $controller->parse_route( |
91 | 91 | $request->get_route(), |
92 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
93 | - array( 'version', 'model', 'id' ) ); |
|
94 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
95 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
96 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
92 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
93 | + array('version', 'model', 'id') ); |
|
94 | + $controller->set_requested_version($matches['version']); |
|
95 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
96 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
97 | 97 | return $controller->send_response( |
98 | 98 | new \WP_Error( |
99 | 99 | 'endpoint_parsing_error', |
100 | 100 | sprintf( |
101 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
101 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
102 | 102 | $model_name_singular |
103 | 103 | ) |
104 | 104 | ) |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | return $controller->send_response( |
108 | 108 | $controller->get_entity_from_model( |
109 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
109 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
110 | 110 | $request |
111 | 111 | ) |
112 | 112 | ); |
113 | - } catch( \Exception $e ) { |
|
114 | - return $controller->send_response( $e ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return $controller->send_response($e); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | * @param \WP_REST_Request $request |
124 | 124 | * @return \WP_REST_Response|\WP_Error |
125 | 125 | */ |
126 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
126 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
127 | 127 | $controller = new Read(); |
128 | - try{ |
|
128 | + try { |
|
129 | 129 | $matches = $controller->parse_route( |
130 | 130 | $request->get_route(), |
131 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
132 | - array( 'version', 'model', 'id', 'related_model' ) |
|
131 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
132 | + array('version', 'model', 'id', 'related_model') |
|
133 | 133 | ); |
134 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
135 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
136 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
134 | + $controller->set_requested_version($matches['version']); |
|
135 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
136 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
137 | 137 | return $controller->send_response( |
138 | 138 | new \WP_Error( |
139 | 139 | 'endpoint_parsing_error', |
140 | 140 | sprintf( |
141 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
141 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
142 | 142 | $main_model_name_singular |
143 | 143 | ) |
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | } |
147 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
147 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
148 | 148 | //assume the related model name is plural and try to find the model's name |
149 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
149 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
152 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
152 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
153 | 153 | } |
154 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
154 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
155 | 155 | return $controller->send_response( |
156 | 156 | new \WP_Error( |
157 | 157 | 'endpoint_parsing_error', |
158 | 158 | sprintf( |
159 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
159 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
160 | 160 | $related_model_name_singular |
161 | 161 | ) |
162 | 162 | ) |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | |
166 | 166 | return $controller->send_response( |
167 | 167 | $controller->get_entities_from_relation( |
168 | - $request->get_param( 'id' ), |
|
169 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
168 | + $request->get_param('id'), |
|
169 | + $main_model->related_settings_for($related_model_name_singular), |
|
170 | 170 | $request |
171 | 171 | ) |
172 | 172 | ); |
173 | - } catch( \Exception $e ) { |
|
174 | - return $controller->send_response( $e ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + return $controller->send_response($e); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,28 +184,28 @@ discard block |
||
184 | 184 | * @param \WP_REST_Request $request |
185 | 185 | * @return array |
186 | 186 | */ |
187 | - public function get_entities_from_model( $model, $request) { |
|
188 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
189 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
190 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
187 | + public function get_entities_from_model($model, $request) { |
|
188 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
189 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
190 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
191 | 191 | return new \WP_Error( |
192 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
192 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
193 | 193 | sprintf( |
194 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
194 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
195 | 195 | $model_name_plural, |
196 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
196 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
197 | 197 | ), |
198 | - array( 'status' => 403 ) |
|
198 | + array('status' => 403) |
|
199 | 199 | ); |
200 | 200 | } |
201 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
202 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
201 | + if ( ! $request->get_header('no_rest_headers')) { |
|
202 | + $this->_set_headers_from_query_params($model, $query_params); |
|
203 | 203 | } |
204 | 204 | /** @type array $results */ |
205 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
205 | + $results = $model->get_all_wpdb_results($query_params); |
|
206 | 206 | $nice_results = array( ); |
207 | - foreach ( $results as $result ) { |
|
208 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
207 | + foreach ($results as $result) { |
|
208 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
209 | 209 | $model, |
210 | 210 | $result, |
211 | 211 | $request |
@@ -226,64 +226,64 @@ discard block |
||
226 | 226 | * @param \WP_REST_Request $request |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
230 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
229 | + public function get_entities_from_relation($id, $relation, $request) { |
|
230 | + $context = $this->validate_context($request->get_param('caps')); |
|
231 | 231 | $model = $relation->get_this_model(); |
232 | 232 | $related_model = $relation->get_other_model(); |
233 | 233 | //check if they can access the 1st model object |
234 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
235 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
234 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
235 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
236 | 236 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
237 | 237 | } |
238 | 238 | $restricted_query_params = $query_params; |
239 | - $restricted_query_params[ 'caps' ] = $context; |
|
240 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
241 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
239 | + $restricted_query_params['caps'] = $context; |
|
240 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
241 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
242 | 242 | |
243 | - if( |
|
243 | + if ( |
|
244 | 244 | ! ( |
245 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
246 | - && $model->exists( $restricted_query_params ) |
|
245 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
246 | + && $model->exists($restricted_query_params) |
|
247 | 247 | ) |
248 | - ){ |
|
249 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
250 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
251 | - }else{ |
|
252 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
248 | + ) { |
|
249 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
250 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
251 | + } else { |
|
252 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
253 | 253 | } |
254 | 254 | return new \WP_Error( |
255 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
255 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
256 | 256 | sprintf( |
257 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
257 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
258 | 258 | $related_model_name_maybe_plural, |
259 | 259 | $relation->get_this_model()->get_this_model_name(), |
260 | 260 | implode( |
261 | 261 | ',', |
262 | 262 | array_keys( |
263 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
263 | + Capabilities::get_missing_permissions($related_model, $context) |
|
264 | 264 | ) |
265 | 265 | ) |
266 | 266 | ), |
267 | - array( 'status' => 403 ) |
|
267 | + array('status' => 403) |
|
268 | 268 | ); |
269 | 269 | } |
270 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
271 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
272 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
273 | - $query_params[ 'caps' ] = $context; |
|
274 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
275 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
270 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
271 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
272 | + $query_params['default_where_conditions'] = 'none'; |
|
273 | + $query_params['caps'] = $context; |
|
274 | + if ( ! $request->get_header('no_rest_headers')) { |
|
275 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
276 | 276 | } |
277 | 277 | /** @type array $results */ |
278 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
278 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
279 | 279 | $nice_results = array(); |
280 | - foreach( $results as $result ) { |
|
280 | + foreach ($results as $result) { |
|
281 | 281 | $nice_result = $this->create_entity_from_wpdb_result( |
282 | 282 | $relation->get_other_model(), |
283 | 283 | $result, |
284 | 284 | $request |
285 | 285 | ); |
286 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
286 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
287 | 287 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
288 | 288 | //if there are conflicts we prefer the properties from the main model |
289 | 289 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | $result, |
292 | 292 | $request |
293 | 293 | ); |
294 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
294 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
295 | 295 | //but keep the meta stuff from the main model |
296 | - if( isset( $nice_result['meta'] ) ){ |
|
296 | + if (isset($nice_result['meta'])) { |
|
297 | 297 | $joined_result['meta'] = $nice_result['meta']; |
298 | 298 | } |
299 | 299 | $nice_result = $joined_result; |
300 | 300 | } |
301 | 301 | $nice_results[] = $nice_result; |
302 | 302 | } |
303 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
304 | - return array_shift( $nice_results ); |
|
305 | - }else{ |
|
303 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
304 | + return array_shift($nice_results); |
|
305 | + } else { |
|
306 | 306 | return $nice_results; |
307 | 307 | } |
308 | 308 | } |
@@ -315,30 +315,30 @@ discard block |
||
315 | 315 | * @param array $query_params |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
319 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
320 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
318 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
319 | + $this->_set_debug_info('model query params', $query_params); |
|
320 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
321 | 321 | //normally the limit to a 2-part array, where the 2nd item is the limit |
322 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
323 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
322 | + if ( ! isset($query_params['limit'])) { |
|
323 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
324 | 324 | } |
325 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
326 | - $limit_parts = $query_params[ 'limit' ]; |
|
325 | + if (is_array($query_params['limit'])) { |
|
326 | + $limit_parts = $query_params['limit']; |
|
327 | 327 | } else { |
328 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
329 | - if( count( $limit_parts ) == 1 ){ |
|
330 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
328 | + $limit_parts = explode(',', $query_params['limit']); |
|
329 | + if (count($limit_parts) == 1) { |
|
330 | + $limit_parts = array(0, $limit_parts[0]); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | //remove the group by and having parts of the query, as those will |
334 | 334 | //make the sql query return an array of values, instead of just a single value |
335 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
336 | - $count = $model->count( $query_params, null, true ); |
|
335 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
336 | + $count = $model->count($query_params, null, true); |
|
337 | 337 | |
338 | - $pages = $count / $limit_parts[ 1 ]; |
|
339 | - $this->_set_response_header( 'Total', $count, false ); |
|
340 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
341 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
338 | + $pages = $count / $limit_parts[1]; |
|
339 | + $this->_set_response_header('Total', $count, false); |
|
340 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
341 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -351,47 +351,47 @@ discard block |
||
351 | 351 | * @param string $deprecated no longer used |
352 | 352 | * @return array ready for being converted into json for sending to client |
353 | 353 | */ |
354 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
355 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
354 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
355 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
356 | 356 | //ok so this was called in the old style, where the 3rd arg was |
357 | 357 | //$include, and the 4th arg was $context |
358 | 358 | //now setup the request just to avoid fatal errors, although we won't be able |
359 | 359 | //to truly make use of it because it's kinda devoid of info |
360 | 360 | $rest_request = new \WP_REST_Request(); |
361 | - $rest_request->set_param( 'include', $rest_request ); |
|
362 | - $rest_request->set_param( 'caps', $deprecated ); |
|
361 | + $rest_request->set_param('include', $rest_request); |
|
362 | + $rest_request->set_param('caps', $deprecated); |
|
363 | 363 | } |
364 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
365 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
364 | + if ($rest_request->get_param('caps') == null) { |
|
365 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
366 | 366 | } |
367 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
368 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
369 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
370 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
371 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
367 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
368 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
369 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
370 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
371 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
372 | 372 | $entity_array = apply_filters( |
373 | 373 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
374 | 374 | $entity_array, |
375 | 375 | $model, |
376 | - $rest_request->get_param( 'caps' ), |
|
376 | + $rest_request->get_param('caps'), |
|
377 | 377 | $rest_request, |
378 | 378 | $this |
379 | 379 | ); |
380 | 380 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
381 | 381 | $entity_array, |
382 | 382 | $model, |
383 | - $rest_request->get_param( 'caps' ), |
|
383 | + $rest_request->get_param('caps'), |
|
384 | 384 | $this->get_model_version_info() |
385 | 385 | ); |
386 | 386 | $this->_set_debug_info( |
387 | 387 | 'inaccessible fields', |
388 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
388 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
389 | 389 | ); |
390 | 390 | return apply_filters( |
391 | 391 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
392 | 392 | $result_without_inaccessible_fields, |
393 | 393 | $model, |
394 | - $rest_request->get_param( 'caps' ) |
|
394 | + $rest_request->get_param('caps') |
|
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
@@ -403,38 +403,38 @@ discard block |
||
403 | 403 | * @param array $db_row |
404 | 404 | * @return array entity mostly ready for converting to JSON and sending in the response |
405 | 405 | */ |
406 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
407 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
408 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
409 | - foreach( $result as $field_name => $raw_field_value ) { |
|
406 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
407 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
408 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
409 | + foreach ($result as $field_name => $raw_field_value) { |
|
410 | 410 | $field_obj = $model->field_settings_for($field_name); |
411 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
412 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
413 | - unset( $result[ $field_name ] ); |
|
414 | - }elseif( |
|
415 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
416 | - ){ |
|
417 | - $result[ $field_name ] = array( |
|
418 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
419 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
411 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
412 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
413 | + unset($result[$field_name]); |
|
414 | + }elseif ( |
|
415 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
416 | + ) { |
|
417 | + $result[$field_name] = array( |
|
418 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
419 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
420 | 420 | ); |
421 | - }elseif( |
|
422 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
423 | - ){ |
|
424 | - $result[ $field_name ] = array( |
|
425 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
426 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
421 | + }elseif ( |
|
422 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
423 | + ) { |
|
424 | + $result[$field_name] = array( |
|
425 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
426 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
427 | 427 | ); |
428 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
429 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
428 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
429 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | 430 | $field_obj, |
431 | 431 | $field_value, |
432 | 432 | $this->get_model_version_info()->requested_version() |
433 | 433 | ); |
434 | 434 | } else { |
435 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
435 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | 436 | $field_obj, |
437 | - $field_obj->prepare_for_get( $field_value ), |
|
437 | + $field_obj->prepare_for_get($field_value), |
|
438 | 438 | $this->get_model_version_info()->requested_version() |
439 | 439 | ); |
440 | 440 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | * @param array $entity_array |
450 | 450 | * @return array modified entity |
451 | 451 | */ |
452 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
453 | - if( $model instanceof \EEM_CPT_Base ) { |
|
454 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
452 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
453 | + if ($model instanceof \EEM_CPT_Base) { |
|
454 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
455 | 455 | } |
456 | 456 | return $entity_array; |
457 | 457 | } |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | * @param array $entity_array |
466 | 466 | * @return array the _links item in the entity |
467 | 467 | */ |
468 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
468 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
469 | 469 | //add basic links |
470 | 470 | $links = array( |
471 | 471 | 'self' => array( |
472 | 472 | array( |
473 | 473 | 'href' => $this->get_versioned_link_to( |
474 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
474 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
475 | 475 | ) |
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'collection' => array( |
479 | 479 | array( |
480 | 480 | 'href' => $this->get_versioned_link_to( |
481 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
481 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
482 | 482 | ) |
483 | 483 | ) |
484 | 484 | ), |
@@ -486,24 +486,24 @@ discard block |
||
486 | 486 | |
487 | 487 | //add link to the wp core endpoint, if wp api is active |
488 | 488 | global $wp_rest_server; |
489 | - if( $model instanceof \EEM_CPT_Base && |
|
489 | + if ($model instanceof \EEM_CPT_Base && |
|
490 | 490 | $wp_rest_server instanceof \WP_REST_Server && |
491 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
492 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
491 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
492 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
493 | 493 | array( |
494 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
494 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
495 | 495 | 'single' => true |
496 | 496 | ) |
497 | 497 | ); |
498 | 498 | } |
499 | 499 | |
500 | 500 | //add links to related models |
501 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
502 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
503 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
501 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
502 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
503 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
504 | 504 | array( |
505 | 505 | 'href' => $this->get_versioned_link_to( |
506 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
506 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
507 | 507 | ), |
508 | 508 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
509 | 509 | ) |
@@ -519,51 +519,51 @@ discard block |
||
519 | 519 | * @param array $entity_array |
520 | 520 | * @return array the modified entity |
521 | 521 | */ |
522 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
523 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
524 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
522 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
523 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
524 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
525 | 525 | //if they passed in * or didn't specify any includes, return everything |
526 | - if( ! in_array( '*', $includes_for_this_model ) |
|
527 | - && ! empty( $includes_for_this_model ) ) { |
|
528 | - if( $model->has_primary_key_field() ) { |
|
526 | + if ( ! in_array('*', $includes_for_this_model) |
|
527 | + && ! empty($includes_for_this_model)) { |
|
528 | + if ($model->has_primary_key_field()) { |
|
529 | 529 | //always include the primary key. ya just gotta know that at least |
530 | 530 | $includes_for_this_model[] = $model->primary_key_name(); |
531 | 531 | } |
532 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
532 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
533 | 533 | $includes_for_this_model[] = '_calculated_fields'; |
534 | 534 | } |
535 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
535 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
536 | 536 | } |
537 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
538 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
537 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
538 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
539 | 539 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
540 | - $rest_request->get_param( 'include' ), |
|
540 | + $rest_request->get_param('include'), |
|
541 | 541 | $relation_name |
542 | 542 | ); |
543 | 543 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
544 | - $rest_request->get_param( 'calculate' ), |
|
544 | + $rest_request->get_param('calculate'), |
|
545 | 545 | $relation_name |
546 | 546 | ); |
547 | 547 | //did they specify they wanted to include a related model, or |
548 | 548 | //specific fields from a related model? |
549 | 549 | //or did they specify to calculate a field from a related model? |
550 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
550 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
551 | 551 | //if so, we should include at least some part of the related model |
552 | 552 | $pretend_related_request = new \WP_REST_Request(); |
553 | 553 | $pretend_related_request->set_query_params( |
554 | 554 | array( |
555 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
555 | + 'caps' => $rest_request->get_param('caps'), |
|
556 | 556 | 'include' => $related_fields_to_include, |
557 | 557 | 'calculate' => $related_fields_to_calculate, |
558 | 558 | ) |
559 | 559 | ); |
560 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
560 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
561 | 561 | $related_results = $this->get_entities_from_relation( |
562 | - $entity_array[ $model->primary_key_name() ], |
|
562 | + $entity_array[$model->primary_key_name()], |
|
563 | 563 | $relation_obj, |
564 | 564 | $pretend_related_request |
565 | 565 | ); |
566 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
566 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
567 | 567 | ? null |
568 | 568 | : $related_results; |
569 | 569 | } |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | * @param array $arr |
578 | 578 | * @return array |
579 | 579 | */ |
580 | - private function _remove_model_names_from_array( $arr ) { |
|
581 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
580 | + private function _remove_model_names_from_array($arr) { |
|
581 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
582 | 582 | } |
583 | 583 | /** |
584 | 584 | * Gets the calculated fields for the response |
@@ -588,15 +588,15 @@ discard block |
||
588 | 588 | * @param \WP_REST_Request $rest_request |
589 | 589 | * @return array the _calculations item in the entity |
590 | 590 | */ |
591 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
591 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
592 | 592 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
593 | - $rest_request->get_param( 'calculate' ), |
|
593 | + $rest_request->get_param('calculate'), |
|
594 | 594 | '' |
595 | 595 | ); |
596 | 596 | //note: setting calculate=* doesn't do anything |
597 | 597 | $calculated_fields_to_return = new \stdClass(); |
598 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
599 | - try{ |
|
598 | + foreach ($calculated_fields as $field_to_calculate) { |
|
599 | + try { |
|
600 | 600 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
601 | 601 | null, |
602 | 602 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -608,10 +608,10 @@ discard block |
||
608 | 608 | ), |
609 | 609 | $this->get_model_version_info()->requested_version() |
610 | 610 | ); |
611 | - } catch( Rest_Exception $e ) { |
|
611 | + } catch (Rest_Exception $e) { |
|
612 | 612 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
613 | 613 | $this->_set_response_header( |
614 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
614 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
615 | 615 | $e->getMessage(), |
616 | 616 | true |
617 | 617 | ); |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
626 | 626 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
627 | 627 | */ |
628 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
628 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
629 | 629 | return rest_url( |
630 | 630 | \EED_Core_Rest_Api::ee_api_namespace |
631 | 631 | . $this->get_model_version_info()->requested_version() |
@@ -641,11 +641,11 @@ discard block |
||
641 | 641 | * @param \EE_Model_Relation_Base $relation_obj |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
645 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
646 | - return strtolower( $relation_name ); |
|
647 | - }else{ |
|
648 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
644 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
645 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
646 | + return strtolower($relation_name); |
|
647 | + } else { |
|
648 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
@@ -658,43 +658,43 @@ discard block |
||
658 | 658 | * @param \WP_REST_Request $request |
659 | 659 | * @return array |
660 | 660 | */ |
661 | - public function get_entity_from_model( $model, $request ) { |
|
662 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
663 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
661 | + public function get_entity_from_model($model, $request) { |
|
662 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
663 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
664 | 664 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
665 | 665 | } |
666 | 666 | $restricted_query_params = $query_params; |
667 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
668 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
669 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
670 | - if ( ! empty ( $model_rows ) ) { |
|
667 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
668 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
669 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
670 | + if ( ! empty ($model_rows)) { |
|
671 | 671 | return $this->create_entity_from_wpdb_result( |
672 | 672 | $model, |
673 | - array_shift( $model_rows ), |
|
673 | + array_shift($model_rows), |
|
674 | 674 | $request ); |
675 | 675 | } else { |
676 | 676 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
677 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
678 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
679 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
677 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
678 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
679 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
680 | 680 | //you got shafted- it existed but we didn't want to tell you! |
681 | 681 | return new \WP_Error( |
682 | 682 | 'rest_user_cannot_read', |
683 | 683 | sprintf( |
684 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
685 | - strtolower( $model->get_this_model_name() ), |
|
684 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
685 | + strtolower($model->get_this_model_name()), |
|
686 | 686 | Capabilities::get_missing_permissions_string( |
687 | 687 | $model, |
688 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
688 | + $this->validate_context($request->get_param('caps')) ) |
|
689 | 689 | ), |
690 | - array( 'status' => 403 ) |
|
690 | + array('status' => 403) |
|
691 | 691 | ); |
692 | 692 | } else { |
693 | 693 | //it's not you. It just doesn't exist |
694 | 694 | return new \WP_Error( |
695 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
696 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
697 | - array( 'status' => 404 ) |
|
695 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
696 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
697 | + array('status' => 404) |
|
698 | 698 | ); |
699 | 699 | } |
700 | 700 | } |
@@ -707,14 +707,14 @@ discard block |
||
707 | 707 | * @param string $context |
708 | 708 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
709 | 709 | */ |
710 | - public function validate_context( $context ) { |
|
711 | - if( ! $context ) { |
|
710 | + public function validate_context($context) { |
|
711 | + if ( ! $context) { |
|
712 | 712 | $context = \EEM_Base::caps_read; |
713 | 713 | } |
714 | 714 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
715 | - if( in_array( $context, $valid_contexts ) ){ |
|
715 | + if (in_array($context, $valid_contexts)) { |
|
716 | 716 | return $context; |
717 | - }else{ |
|
717 | + } else { |
|
718 | 718 | return \EEM_Base::caps_read; |
719 | 719 | } |
720 | 720 | } |
@@ -733,77 +733,77 @@ discard block |
||
733 | 733 | * that absolutely no results should be returned |
734 | 734 | * @throws \EE_Error |
735 | 735 | */ |
736 | - public function create_model_query_params( $model, $query_parameters ) { |
|
736 | + public function create_model_query_params($model, $query_parameters) { |
|
737 | 737 | $model_query_params = array( ); |
738 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
739 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
740 | - $query_parameters[ 'where' ], |
|
738 | + if (isset($query_parameters['where'])) { |
|
739 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
740 | + $query_parameters['where'], |
|
741 | 741 | $model, |
742 | 742 | $this->get_model_version_info()->requested_version() |
743 | 743 | ); |
744 | 744 | } |
745 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
746 | - $order_by = $query_parameters[ 'order_by' ]; |
|
747 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
748 | - $order_by = $query_parameters[ 'orderby' ]; |
|
749 | - }else{ |
|
745 | + if (isset($query_parameters['order_by'])) { |
|
746 | + $order_by = $query_parameters['order_by']; |
|
747 | + } elseif (isset($query_parameters['orderby'])) { |
|
748 | + $order_by = $query_parameters['orderby']; |
|
749 | + } else { |
|
750 | 750 | $order_by = null; |
751 | 751 | } |
752 | - if( $order_by !== null ){ |
|
753 | - $model_query_params[ 'order_by' ] = $order_by; |
|
752 | + if ($order_by !== null) { |
|
753 | + $model_query_params['order_by'] = $order_by; |
|
754 | 754 | } |
755 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
756 | - $group_by = $query_parameters[ 'group_by' ]; |
|
757 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
758 | - $group_by = $query_parameters[ 'groupby' ]; |
|
759 | - }else{ |
|
755 | + if (isset($query_parameters['group_by'])) { |
|
756 | + $group_by = $query_parameters['group_by']; |
|
757 | + } elseif (isset($query_parameters['groupby'])) { |
|
758 | + $group_by = $query_parameters['groupby']; |
|
759 | + } else { |
|
760 | 760 | $group_by = null; |
761 | 761 | } |
762 | - if( $group_by !== null ){ |
|
763 | - $model_query_params[ 'group_by' ] = $group_by; |
|
762 | + if ($group_by !== null) { |
|
763 | + $model_query_params['group_by'] = $group_by; |
|
764 | 764 | } |
765 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
766 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
767 | - $query_parameters[ 'having' ], |
|
765 | + if (isset($query_parameters['having'])) { |
|
766 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
767 | + $query_parameters['having'], |
|
768 | 768 | $model, |
769 | 769 | $this->get_model_version_info()->requested_version() |
770 | 770 | ); |
771 | 771 | } |
772 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
773 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
772 | + if (isset($query_parameters['order'])) { |
|
773 | + $model_query_params['order'] = $query_parameters['order']; |
|
774 | 774 | } |
775 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
776 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
775 | + if (isset($query_parameters['mine'])) { |
|
776 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
777 | 777 | } |
778 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
778 | + if (isset($query_parameters['limit'])) { |
|
779 | 779 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
780 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
781 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
782 | - }else { |
|
783 | - $limit_array = $query_parameters[ 'limit' ]; |
|
780 | + if ( ! is_array($query_parameters['limit'])) { |
|
781 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
782 | + } else { |
|
783 | + $limit_array = $query_parameters['limit']; |
|
784 | 784 | } |
785 | 785 | $sanitized_limit = array(); |
786 | - foreach( $limit_array as $key => $limit_part ) { |
|
787 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
786 | + foreach ($limit_array as $key => $limit_part) { |
|
787 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
788 | 788 | throw new \EE_Error( |
789 | 789 | sprintf( |
790 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
791 | - json_encode( $query_parameters[ 'limit' ] ) |
|
790 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
791 | + json_encode($query_parameters['limit']) |
|
792 | 792 | ) |
793 | 793 | ); |
794 | 794 | } |
795 | - $sanitized_limit[] = (int)$limit_part; |
|
795 | + $sanitized_limit[] = (int) $limit_part; |
|
796 | 796 | } |
797 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
798 | - }else{ |
|
799 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
797 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
798 | + } else { |
|
799 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
800 | 800 | } |
801 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
802 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
803 | - }else{ |
|
804 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
801 | + if (isset($query_parameters['caps'])) { |
|
802 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
803 | + } else { |
|
804 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
805 | 805 | } |
806 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
806 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
@@ -815,13 +815,13 @@ discard block |
||
815 | 815 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
816 | 816 | * @return array |
817 | 817 | */ |
818 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
818 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
819 | 819 | $model_ready_query_params = array(); |
820 | - foreach( $query_params as $key => $value ) { |
|
821 | - if( is_array( $value ) ) { |
|
822 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
823 | - }else{ |
|
824 | - $model_ready_query_params[ $key ] = $value; |
|
820 | + foreach ($query_params as $key => $value) { |
|
821 | + if (is_array($value)) { |
|
822 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
823 | + } else { |
|
824 | + $model_ready_query_params[$key] = $value; |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | return $model_ready_query_params; |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | * @param $query_params |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
838 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
839 | 839 | $model_ready_query_params = array(); |
840 | - foreach( $query_params as $key => $value ) { |
|
841 | - if( is_array( $value ) ) { |
|
842 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
840 | + foreach ($query_params as $key => $value) { |
|
841 | + if (is_array($value)) { |
|
842 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
843 | 843 | } else { |
844 | - $model_ready_query_params[ $key ] = $value; |
|
844 | + $model_ready_query_params[$key] = $value; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | return $model_ready_query_params; |
@@ -856,33 +856,33 @@ discard block |
||
856 | 856 | * we only return strings starting with that and a period; if no prefix was specified |
857 | 857 | * we return all items containing NO periods |
858 | 858 | */ |
859 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
860 | - if( is_string( $string_to_explode ) ) { |
|
861 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
862 | - } else if( is_array( $string_to_explode ) ) { |
|
859 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
860 | + if (is_string($string_to_explode)) { |
|
861 | + $exploded_contents = explode(',', $string_to_explode); |
|
862 | + } else if (is_array($string_to_explode)) { |
|
863 | 863 | $exploded_contents = $string_to_explode; |
864 | 864 | } else { |
865 | 865 | $exploded_contents = array(); |
866 | 866 | } |
867 | 867 | //if the string was empty, we want an empty array |
868 | - $exploded_contents = array_filter( $exploded_contents ); |
|
868 | + $exploded_contents = array_filter($exploded_contents); |
|
869 | 869 | $contents_with_prefix = array(); |
870 | - foreach( $exploded_contents as $item ) { |
|
871 | - $item = trim( $item ); |
|
870 | + foreach ($exploded_contents as $item) { |
|
871 | + $item = trim($item); |
|
872 | 872 | //if no prefix was provided, so we look for items with no "." in them |
873 | - if( ! $prefix ) { |
|
873 | + if ( ! $prefix) { |
|
874 | 874 | //does this item have a period? |
875 | - if( strpos( $item, '.' ) === false ) { |
|
875 | + if (strpos($item, '.') === false) { |
|
876 | 876 | //if not, then its what we're looking for |
877 | 877 | $contents_with_prefix[] = $item; |
878 | 878 | } |
879 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
879 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
880 | 880 | //this item has the prefix and a period, grab it |
881 | 881 | $contents_with_prefix[] = substr( |
882 | 882 | $item, |
883 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
883 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
884 | 884 | ); |
885 | - } else if( $item === $prefix ) { |
|
885 | + } else if ($item === $prefix) { |
|
886 | 886 | //this item is JUST the prefix |
887 | 887 | //so let's grab everything after, which is a blank string |
888 | 888 | $contents_with_prefix[] = ''; |
@@ -905,33 +905,33 @@ discard block |
||
905 | 905 | * the fields for that model, with the model's name removed from each. |
906 | 906 | * If $include_string was blank or '*' returns an empty array |
907 | 907 | */ |
908 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
909 | - if( is_array( $include_string ) ) { |
|
910 | - $include_string = implode( ',', $include_string ); |
|
908 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
909 | + if (is_array($include_string)) { |
|
910 | + $include_string = implode(',', $include_string); |
|
911 | 911 | } |
912 | - if( $include_string === '*' || $include_string === '' ) { |
|
912 | + if ($include_string === '*' || $include_string === '') { |
|
913 | 913 | return array(); |
914 | 914 | } |
915 | - $includes = explode( ',', $include_string ); |
|
915 | + $includes = explode(',', $include_string); |
|
916 | 916 | $extracted_fields_to_include = array(); |
917 | - if( $model_name ){ |
|
918 | - foreach( $includes as $field_to_include ) { |
|
919 | - $field_to_include = trim( $field_to_include ); |
|
920 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
917 | + if ($model_name) { |
|
918 | + foreach ($includes as $field_to_include) { |
|
919 | + $field_to_include = trim($field_to_include); |
|
920 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
921 | 921 | //found the model name at the exact start |
922 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
922 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
923 | 923 | $extracted_fields_to_include[] = $field_sans_model_name; |
924 | - }elseif( $field_to_include == $model_name ){ |
|
924 | + }elseif ($field_to_include == $model_name) { |
|
925 | 925 | $extracted_fields_to_include[] = '*'; |
926 | 926 | } |
927 | 927 | } |
928 | - }else{ |
|
928 | + } else { |
|
929 | 929 | //look for ones with no period |
930 | - foreach( $includes as $field_to_include ) { |
|
931 | - $field_to_include = trim( $field_to_include ); |
|
930 | + foreach ($includes as $field_to_include) { |
|
931 | + $field_to_include = trim($field_to_include); |
|
932 | 932 | if ( |
933 | - strpos( $field_to_include, '.' ) === false |
|
934 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
933 | + strpos($field_to_include, '.') === false |
|
934 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
935 | 935 | ) { |
936 | 936 | $extracted_fields_to_include[] = $field_to_include; |
937 | 937 | } |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | use EventEspressoBatchRequest\Helpers\JobParameters; |
20 | 20 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
21 | 21 | |
22 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
23 | - exit( 'No direct script access allowed' ); |
|
22 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
23 | + exit('No direct script access allowed'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @throws BatchRequestException |
36 | 36 | * @return JobStepResponse |
37 | 37 | */ |
38 | - public function create_job( JobParameters $job_parameters ) { |
|
39 | - $event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) ); |
|
40 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) { |
|
38 | + public function create_job(JobParameters $job_parameters) { |
|
39 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | 41 | throw new BatchRequestException( |
42 | - __( 'You do not have permission to view registrations', 'event_espresso') |
|
42 | + __('You do not have permission to view registrations', 'event_espresso') |
|
43 | 43 | ); |
44 | 44 | } |
45 | 45 | $filepath = $this->create_file_from_job_with_name( |
46 | 46 | $job_parameters->job_id(), |
47 | - $this->get_filename_from_event( $event_id ) |
|
47 | + $this->get_filename_from_event($event_id) |
|
48 | 48 | ); |
49 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
50 | - $question_data_for_columns = $this->_get_questions_for_report( $event_id ); |
|
51 | - $job_parameters->add_extra_data( 'questions_data', $question_data_for_columns ); |
|
52 | - $job_parameters->set_job_size( $this->count_units_to_process( $event_id ) ); |
|
49 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
50 | + $question_data_for_columns = $this->_get_questions_for_report($event_id); |
|
51 | + $job_parameters->add_extra_data('questions_data', $question_data_for_columns); |
|
52 | + $job_parameters->set_job_size($this->count_units_to_process($event_id)); |
|
53 | 53 | //we should also set the header columns |
54 | 54 | $csv_data_for_row = $this->get_csv_data_for( |
55 | 55 | $event_id, |
56 | 56 | 0, |
57 | 57 | 1, |
58 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
59 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
58 | + $job_parameters->extra_datum('questions_data') ); |
|
59 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
60 | 60 | //if we actually processed a row there, record it |
61 | - if( $job_parameters->job_size() ) { |
|
62 | - $job_parameters->mark_processed( 1 ); |
|
61 | + if ($job_parameters->job_size()) { |
|
62 | + $job_parameters->mark_processed(1); |
|
63 | 63 | } |
64 | 64 | return new JobStepResponse( |
65 | 65 | $job_parameters, |
66 | - __( 'Registrations report started successfully...', 'event_espresso' ) |
|
66 | + __('Registrations report started successfully...', 'event_espresso') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | * @param int $event_id |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - protected function get_filename_from_event( $event_id ) { |
|
78 | - if( $event_id ){ |
|
79 | - $event_slug = \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
80 | - if( ! $event_slug ) { |
|
81 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
77 | + protected function get_filename_from_event($event_id) { |
|
78 | + if ($event_id) { |
|
79 | + $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
80 | + if ( ! $event_slug) { |
|
81 | + $event_slug = __('unknown', 'event_espresso'); |
|
82 | 82 | } |
83 | - }else{ |
|
84 | - $event_slug = __( 'all', 'event_espresso' ); |
|
83 | + } else { |
|
84 | + $event_slug = __('all', 'event_espresso'); |
|
85 | 85 | } |
86 | - return sprintf( "registrations-for-%s.csv", $event_slug ); |
|
86 | + return sprintf("registrations-for-%s.csv", $event_slug); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | * @param int|null $event_id |
93 | 93 | * @return array of wpdb results for questions which are to be used for this report |
94 | 94 | */ |
95 | - protected function _get_questions_for_report( $event_id ) { |
|
95 | + protected function _get_questions_for_report($event_id) { |
|
96 | 96 | $question_query_params = array( |
97 | 97 | array( |
98 | - 'Answer.ANS_ID' => array( 'IS_NOT_NULL' ), |
|
98 | + 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
99 | 99 | ), |
100 | - 'group_by' => array( 'QST_ID' ) |
|
100 | + 'group_by' => array('QST_ID') |
|
101 | 101 | ); |
102 | - if( $event_id ) { |
|
102 | + if ($event_id) { |
|
103 | 103 | $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
104 | 104 | } |
105 | - return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params ); |
|
105 | + return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -115,27 +115,27 @@ discard block |
||
115 | 115 | * @return JobStepResponse |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) { |
|
118 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
|
119 | 119 | $csv_data = $this->get_csv_data_for( |
120 | - $job_parameters->request_datum( 'EVT_ID', '0'), |
|
120 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
121 | 121 | $job_parameters->units_processed(), |
122 | 122 | $batch_size, |
123 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
124 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
125 | - $units_processed = count( $csv_data ); |
|
126 | - $job_parameters->mark_processed( $units_processed ); |
|
123 | + $job_parameters->extra_datum('questions_data') ); |
|
124 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
125 | + $units_processed = count($csv_data); |
|
126 | + $job_parameters->mark_processed($units_processed); |
|
127 | 127 | $extra_response_data = array( |
128 | 128 | 'file_url' => '' |
129 | 129 | ); |
130 | - if( $units_processed < $batch_size ) { |
|
131 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
132 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
130 | + if ($units_processed < $batch_size) { |
|
131 | + $job_parameters->set_status(JobParameters::status_complete); |
|
132 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
133 | 133 | } |
134 | 134 | return new JobStepResponse( |
135 | 135 | $job_parameters, |
136 | 136 | sprintf( |
137 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
138 | - count( $csv_data ) ), |
|
137 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
138 | + count($csv_data) ), |
|
139 | 139 | $extra_response_data ); |
140 | 140 | } |
141 | 141 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return array top-level keys are numeric, next-level keys are column headers |
149 | 149 | * |
150 | 150 | */ |
151 | - function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) { |
|
151 | + function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) { |
|
152 | 152 | $reg_fields_to_include = array( |
153 | 153 | 'TXN_ID', |
154 | 154 | 'ATT_ID', |
@@ -179,165 +179,165 @@ discard block |
||
179 | 179 | array( |
180 | 180 | 'OR' => array( |
181 | 181 | //don't include registrations from failed or abandoned transactions... |
182 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
182 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
183 | 183 | //unless the registration is approved, in which case include it regardless of transaction status |
184 | 184 | 'STS_ID' => \EEM_Registration::status_id_approved |
185 | 185 | ), |
186 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
186 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
187 | 187 | ), |
188 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
189 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
190 | - 'limit' => array( $offset, $limit ), |
|
188 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
189 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
190 | + 'limit' => array($offset, $limit), |
|
191 | 191 | ), |
192 | 192 | $event_id |
193 | 193 | ); |
194 | - if( $event_id ){ |
|
195 | - $query_params[0]['EVT_ID'] = $event_id; |
|
196 | - }else{ |
|
197 | - $query_params[ 'force_join' ][] = 'Event'; |
|
194 | + if ($event_id) { |
|
195 | + $query_params[0]['EVT_ID'] = $event_id; |
|
196 | + } else { |
|
197 | + $query_params['force_join'][] = 'Event'; |
|
198 | 198 | } |
199 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
199 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
200 | 200 | //get all questions which relate to someone in this group |
201 | 201 | $registration_ids = array(); |
202 | - foreach( $registration_rows as $reg_row ) { |
|
203 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
202 | + foreach ($registration_rows as $reg_row) { |
|
203 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
204 | 204 | } |
205 | 205 | |
206 | - foreach($registration_rows as $reg_row){ |
|
207 | - if ( is_array( $reg_row ) ) { |
|
206 | + foreach ($registration_rows as $reg_row) { |
|
207 | + if (is_array($reg_row)) { |
|
208 | 208 | $reg_csv_array = array(); |
209 | - if( ! $event_id ){ |
|
209 | + if ( ! $event_id) { |
|
210 | 210 | //get the event's name and Id |
211 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
211 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
212 | 212 | } |
213 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
213 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
214 | 214 | /*@var $reg_row EE_Registration */ |
215 | - foreach($reg_fields_to_include as $field_name){ |
|
215 | + foreach ($reg_fields_to_include as $field_name) { |
|
216 | 216 | $field = $reg_model->field_settings_for($field_name); |
217 | - if($field_name == 'REG_final_price'){ |
|
218 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
219 | - }elseif( $field_name == 'REG_count' ){ |
|
220 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
221 | - }elseif( $field_name == 'REG_date' ) { |
|
222 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
223 | - }else{ |
|
224 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
217 | + if ($field_name == 'REG_final_price') { |
|
218 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
219 | + }elseif ($field_name == 'REG_count') { |
|
220 | + $value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
221 | + }elseif ($field_name == 'REG_date') { |
|
222 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
223 | + } else { |
|
224 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
225 | 225 | } |
226 | 226 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
227 | - if($field_name == 'REG_final_price'){ |
|
227 | + if ($field_name == 'REG_final_price') { |
|
228 | 228 | //add a column named Currency after the final price |
229 | 229 | $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | //get pretty status |
233 | - $stati = \EEM_Status::instance()->localized_status( array( |
|
234 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
235 | - $reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
233 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
234 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
235 | + $reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ), |
|
236 | 236 | FALSE, |
237 | - 'sentence' ); |
|
238 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
237 | + 'sentence'); |
|
238 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
239 | 239 | //get pretty transaction status |
240 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ]; |
|
241 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00'; |
|
242 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
240 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']]; |
|
241 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00'; |
|
242 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00'; |
|
243 | 243 | $payment_methods = array(); |
244 | 244 | $gateway_txn_ids_etc = array(); |
245 | 245 | $payment_times = array(); |
246 | - if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){ |
|
246 | + if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) { |
|
247 | 247 | $payments_info = \EEM_Payment::instance()->get_all_wpdb_results( |
248 | 248 | array( |
249 | 249 | array( |
250 | - 'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ], |
|
250 | + 'TXN_ID' => $reg_row['Transaction.TXN_ID'], |
|
251 | 251 | 'STS_ID' => \EEM_Payment::status_id_approved |
252 | 252 | ), |
253 | - 'force_join' => array( 'Payment_Method' ), |
|
253 | + 'force_join' => array('Payment_Method'), |
|
254 | 254 | |
255 | 255 | ), |
256 | 256 | ARRAY_A, |
257 | 257 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
258 | 258 | |
259 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
260 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
261 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
262 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
259 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
260 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
261 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
262 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | } |
266 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
267 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
268 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
266 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
267 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
268 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
269 | 269 | |
270 | 270 | //get whether or not the user has checked in |
271 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
271 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
272 | 272 | //get ticket of registration and its price |
273 | 273 | $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
274 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
275 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
274 | + if ($reg_row['Ticket.TKT_ID']) { |
|
275 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
276 | 276 | $datetimes_strings = array(); |
277 | - foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
278 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
277 | + foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
278 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | } else { |
282 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
283 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
282 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
283 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
284 | 284 | } |
285 | 285 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
286 | 286 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
287 | 287 | //get datetime(s) of registration |
288 | 288 | |
289 | 289 | //add attendee columns |
290 | - foreach($att_fields_to_include as $att_field_name){ |
|
290 | + foreach ($att_fields_to_include as $att_field_name) { |
|
291 | 291 | $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
292 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
293 | - if($att_field_name == 'STA_ID'){ |
|
294 | - $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
295 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
296 | - $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
297 | - }else{ |
|
298 | - $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
292 | + if ($reg_row['Attendee_CPT.ID']) { |
|
293 | + if ($att_field_name == 'STA_ID') { |
|
294 | + $value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
295 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
296 | + $value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
297 | + } else { |
|
298 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
299 | 299 | } |
300 | - }else{ |
|
300 | + } else { |
|
301 | 301 | $value = ''; |
302 | 302 | } |
303 | 303 | |
304 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
304 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | //make sure each registration has the same questions in the same order |
308 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
309 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
310 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
308 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
309 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
310 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | $answers = \EEM_Answer::instance()->get_all_wpdb_results( |
314 | 314 | array( |
315 | - array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), |
|
316 | - 'force_join' => array( 'Question' ) |
|
315 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
316 | + 'force_join' => array('Question') |
|
317 | 317 | ) |
318 | 318 | ); |
319 | 319 | //now fill out the questions THEY answered |
320 | - foreach( $answers as $answer_row ){ |
|
321 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
320 | + foreach ($answers as $answer_row) { |
|
321 | + if ($answer_row['Question.QST_ID']) { |
|
322 | 322 | $question_label = \EEH_Export::prepare_value_from_db_for_display( |
323 | 323 | \EEM_Question::instance(), |
324 | 324 | 'QST_admin_label', |
325 | - $answer_row[ 'Question.QST_admin_label' ] |
|
325 | + $answer_row['Question.QST_admin_label'] |
|
326 | 326 | ); |
327 | 327 | } else { |
328 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
328 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
329 | 329 | } |
330 | - if ( isset( $answer_row[ 'Question.QST_type' ] ) |
|
331 | - && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state |
|
330 | + if (isset($answer_row['Question.QST_type']) |
|
331 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
332 | 332 | ) { |
333 | - $reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID( |
|
334 | - $answer_row[ 'Answer.ANS_value' ] |
|
333 | + $reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID( |
|
334 | + $answer_row['Answer.ANS_value'] |
|
335 | 335 | ); |
336 | 336 | } else { |
337 | - $reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display( |
|
337 | + $reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display( |
|
338 | 338 | \EEM_Answer::instance(), |
339 | 339 | 'ANS_value', |
340 | - $answer_row[ 'Answer.ANS_value' ] |
|
340 | + $answer_row['Answer.ANS_value'] |
|
341 | 341 | ); |
342 | 342 | } |
343 | 343 | } |
@@ -348,17 +348,17 @@ discard block |
||
348 | 348 | } |
349 | 349 | } |
350 | 350 | //if we couldn't export anything, we want to at least show the column headers |
351 | - if ( empty( $registrations_csv_ready_array ) ) { |
|
351 | + if (empty($registrations_csv_ready_array)) { |
|
352 | 352 | $reg_csv_array = array(); |
353 | 353 | $model_and_fields_to_include = array( |
354 | 354 | 'Registration' => $reg_fields_to_include, |
355 | 355 | 'Attendee' => $att_fields_to_include |
356 | 356 | ); |
357 | - foreach ( $model_and_fields_to_include as $model_name => $field_list ) { |
|
358 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
359 | - foreach ( $field_list as $field_name ) { |
|
360 | - $field = $model->field_settings_for( $field_name ); |
|
361 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null; |
|
357 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
358 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
359 | + foreach ($field_list as $field_name) { |
|
360 | + $field = $model->field_settings_for($field_name); |
|
361 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | $registrations_csv_ready_array[] = $reg_csv_array; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param int $event_id |
375 | 375 | * @return int |
376 | 376 | */ |
377 | - public function count_units_to_process( $event_id ) { |
|
377 | + public function count_units_to_process($event_id) { |
|
378 | 378 | //use the legacy filter |
379 | 379 | $query_params = apply_filters( |
380 | 380 | 'FHEE__EE_Export__report_registration_for_event', |
@@ -382,23 +382,23 @@ discard block |
||
382 | 382 | array( |
383 | 383 | 'OR' => array( |
384 | 384 | //don't include registrations from failed or abandoned transactions... |
385 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
385 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
386 | 386 | //unless the registration is approved, in which case include it regardless of transaction status |
387 | 387 | 'STS_ID' => \EEM_Registration::status_id_approved |
388 | 388 | ), |
389 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
389 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
390 | 390 | ), |
391 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
392 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ) |
|
391 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
392 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee') |
|
393 | 393 | ), |
394 | 394 | $event_id |
395 | 395 | ); |
396 | - if( $event_id ){ |
|
397 | - $query_params[0]['EVT_ID'] = $event_id; |
|
396 | + if ($event_id) { |
|
397 | + $query_params[0]['EVT_ID'] = $event_id; |
|
398 | 398 | } else { |
399 | - $query_params[ 'force_join' ][] = 'Event'; |
|
399 | + $query_params['force_join'][] = 'Event'; |
|
400 | 400 | } |
401 | - return \EEM_Registration::instance()->count( $query_params ); |
|
401 | + return \EEM_Registration::instance()->count($query_params); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | * @param JobParameters $job_parameters |
410 | 410 | * @return boolean |
411 | 411 | */ |
412 | - public function cleanup_job( JobParameters $job_parameters ){ |
|
412 | + public function cleanup_job(JobParameters $job_parameters) { |
|
413 | 413 | $this->_file_helper->delete( |
414 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
414 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
415 | 415 | true, |
416 | 416 | 'd' |
417 | 417 | ); |
418 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
418 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use EventEspressoBatchRequest\Helpers\JobParameters; |
19 | 19 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
20 | 20 | |
21 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
22 | 22 | exit('No direct script access allowed'); |
23 | 23 | } |
24 | 24 | |
@@ -27,81 +27,81 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | public function create_job(JobParameters $job_parameters) { |
30 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) { |
|
30 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) { |
|
31 | 31 | throw new BatchRequestException( |
32 | - __( 'You do not have permission to view contacts', 'event_espresso') |
|
32 | + __('You do not have permission to view contacts', 'event_espresso') |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | $filepath = $this->create_file_from_job_with_name( |
36 | 36 | $job_parameters->job_id(), |
37 | 37 | __('contact-list-report.csv', 'event_espresso') |
38 | 38 | ); |
39 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
40 | - $job_parameters->set_job_size( $this->count_units_to_process() ); |
|
39 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
40 | + $job_parameters->set_job_size($this->count_units_to_process()); |
|
41 | 41 | //we should also set the header columns |
42 | - $csv_data_for_row = $this->get_csv_data( 0, 1 ); |
|
43 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
42 | + $csv_data_for_row = $this->get_csv_data(0, 1); |
|
43 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
44 | 44 | //if we actually processed a row there, record it |
45 | - if( $job_parameters->job_size() ) { |
|
46 | - $job_parameters->mark_processed( 1 ); |
|
45 | + if ($job_parameters->job_size()) { |
|
46 | + $job_parameters->mark_processed(1); |
|
47 | 47 | } |
48 | 48 | return new JobStepResponse( |
49 | 49 | $job_parameters, |
50 | - __( 'Contacts report started successfully...', 'event_espresso' ) |
|
50 | + __('Contacts report started successfully...', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
56 | - $csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size ); |
|
57 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
58 | - $units_processed = count( $csv_data ); |
|
59 | - $job_parameters->mark_processed( $units_processed ); |
|
56 | + $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size); |
|
57 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
58 | + $units_processed = count($csv_data); |
|
59 | + $job_parameters->mark_processed($units_processed); |
|
60 | 60 | $extra_response_data = array( |
61 | 61 | 'file_url' => '' |
62 | 62 | ); |
63 | - if( $units_processed < $batch_size ) { |
|
64 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
65 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
63 | + if ($units_processed < $batch_size) { |
|
64 | + $job_parameters->set_status(JobParameters::status_complete); |
|
65 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
66 | 66 | } |
67 | 67 | return new JobStepResponse( |
68 | 68 | $job_parameters, |
69 | 69 | sprintf( |
70 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
71 | - count( $csv_data ) ), |
|
70 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
71 | + count($csv_data) ), |
|
72 | 72 | $extra_response_data ); |
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | 76 | public function cleanup_job(JobParameters $job_parameters) { |
77 | 77 | $this->_file_helper->delete( |
78 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
78 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
79 | 79 | true, |
80 | 80 | 'd' |
81 | 81 | ); |
82 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
82 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function count_units_to_process() { |
86 | 86 | return \EEM_Attendee::instance()->count(); |
87 | 87 | } |
88 | - public function get_csv_data( $offset, $limit ) { |
|
88 | + public function get_csv_data($offset, $limit) { |
|
89 | 89 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
90 | 90 | array( |
91 | - 'limit' => array( $offset, $limit ), |
|
92 | - 'force_join' => array( 'State', 'Country' ) ) ); |
|
91 | + 'limit' => array($offset, $limit), |
|
92 | + 'force_join' => array('State', 'Country') ) ); |
|
93 | 93 | $csv_data = array(); |
94 | - foreach( $attendee_rows as $attendee_row ){ |
|
94 | + foreach ($attendee_rows as $attendee_row) { |
|
95 | 95 | $csv_row = array(); |
96 | - foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
97 | - if( $field_name == 'STA_ID' ){ |
|
98 | - $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
99 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
100 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
101 | - $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
102 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
103 | - }else{ |
|
104 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
96 | + foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
97 | + if ($field_name == 'STA_ID') { |
|
98 | + $state_name_field = \EEM_State::instance()->field_settings_for('STA_name'); |
|
99 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
100 | + }elseif ($field_name == 'CNT_ISO') { |
|
101 | + $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name'); |
|
102 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
103 | + } else { |
|
104 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | $csv_data[] = $csv_row; |