Completed
Branch master (8b94c8)
by
unknown
04:54
created
core/libraries/messages/data_class/EE_Messages_incoming_data.core.php 2 patches
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         $answers            = $questions = $attendees = $line_items = $registrations = array();
333 333
         $total_ticket_count = 0;
334 334
 
335
-        if (! empty($this->reg_objs)) {
335
+        if ( ! empty($this->reg_objs)) {
336 336
             $event_attendee_count = array();
337 337
             /** @var EE_Registration $reg */
338 338
             foreach ($this->reg_objs as $reg) {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 
345 345
                 $evt_id = $reg->event_ID();
346 346
                 /** @type EE_Ticket $ticket */
347
-                $ticket          = $reg->get_first_related('Ticket');
347
+                $ticket = $reg->get_first_related('Ticket');
348 348
                 $attendee = $reg->attendee();
349 349
                 $event = $reg->event();
350 350
                 // if none of the following entities are available, then we can't setup other data reliably,
@@ -358,67 +358,67 @@  discard block
 block discarded – undo
358 358
                 }
359 359
                 $relateddatetime = $ticket->datetimes();
360 360
                 $total_ticket_count++;
361
-                $tickets[ $ticket->ID() ]['ticket']                        = $ticket;
362
-                $tickets[ $ticket->ID() ]['count']                         = is_array($tickets[ $ticket->ID() ])
363
-                                                                           && isset($tickets[ $ticket->ID() ]['count'])
364
-                    ? $tickets[ $ticket->ID() ]['count'] + 1
361
+                $tickets[$ticket->ID()]['ticket']                        = $ticket;
362
+                $tickets[$ticket->ID()]['count']                         = is_array($tickets[$ticket->ID()])
363
+                                                                           && isset($tickets[$ticket->ID()]['count'])
364
+                    ? $tickets[$ticket->ID()]['count'] + 1
365 365
                     : 1;
366
-                $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee;
367
-                $tickets[ $ticket->ID() ]['dtt_objs']                      = $relateddatetime;
368
-                $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ]          = $reg;
369
-                $tickets[ $ticket->ID() ]['EE_Event']                      = $event;
370
-                $evtcache[ $evt_id ]                                       = $event;
371
-                $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ]             = $reg;
372
-                $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ]          = $ticket;
373
-                $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ]    = $attendee;
374
-                $event_attendee_count[ $evt_id ]                           = isset($event_attendee_count[ $evt_id ])
375
-                    ? $event_attendee_count[ $evt_id ] + 1
366
+                $tickets[$ticket->ID()]['att_objs'][$attendee->ID()] = $attendee;
367
+                $tickets[$ticket->ID()]['dtt_objs']                      = $relateddatetime;
368
+                $tickets[$ticket->ID()]['reg_objs'][$reg->ID()]          = $reg;
369
+                $tickets[$ticket->ID()]['EE_Event']                      = $event;
370
+                $evtcache[$evt_id]                                       = $event;
371
+                $eventsetup[$evt_id]['reg_objs'][$reg->ID()]             = $reg;
372
+                $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()]          = $ticket;
373
+                $eventsetup[$evt_id]['att_objs'][$attendee->ID()] = $attendee;
374
+                $event_attendee_count[$evt_id]                           = isset($event_attendee_count[$evt_id])
375
+                    ? $event_attendee_count[$evt_id] + 1
376 376
                     : 0;
377
-                $attendees[ $reg->attendee_ID() ]['line_ref'][]            = $evt_id;
378
-                $attendees[ $reg->attendee_ID() ]['att_obj']               = $attendee;
379
-                $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ]  = $reg;
377
+                $attendees[$reg->attendee_ID()]['line_ref'][]            = $evt_id;
378
+                $attendees[$reg->attendee_ID()]['att_obj']               = $attendee;
379
+                $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()]  = $reg;
380 380
                 // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
381
-                $attendees[ $reg->attendee_ID() ]['attendee_email']          = $attendee->email();
382
-                $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
383
-                $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ]       = $event;
381
+                $attendees[$reg->attendee_ID()]['attendee_email']          = $attendee->email();
382
+                $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket;
383
+                $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id]       = $event;
384 384
 
385 385
                 // registrations
386
-                $registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
387
-                $registrations[ $reg->ID() ]['evt_obj'] = $event;
388
-                $registrations[ $reg->ID() ]['reg_obj'] = $reg;
389
-                $registrations[ $reg->ID() ]['att_obj'] = $attendee;
386
+                $registrations[$reg->ID()]['tkt_obj'] = $ticket;
387
+                $registrations[$reg->ID()]['evt_obj'] = $event;
388
+                $registrations[$reg->ID()]['reg_obj'] = $reg;
389
+                $registrations[$reg->ID()]['att_obj'] = $attendee;
390 390
 
391 391
                 // set up answer objects
392 392
                 $rel_ans = $reg->get_many_related('Answer');
393 393
                 foreach ($rel_ans as $ansid => $answer) {
394
-                    if (! isset($questions[ $ansid ])) {
395
-                        $questions[ $ansid ] = $answer->get_first_related('Question');
394
+                    if ( ! isset($questions[$ansid])) {
395
+                        $questions[$ansid] = $answer->get_first_related('Question');
396 396
                     }
397
-                    $answers[ $ansid ]                               = $answer;
398
-                    $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
397
+                    $answers[$ansid] = $answer;
398
+                    $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer;
399 399
                 }
400 400
                 /**
401 401
                  * @var int $dtt_id
402 402
                  * @var EE_Datetime $datetime
403 403
                  */
404 404
                 foreach ($relateddatetime as $dtt_id => $datetime) {
405
-                    $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ]       = $datetime;
406
-                    $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
405
+                    $eventsetup[$evt_id]['dtt_objs'][$dtt_id]       = $datetime;
406
+                    $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime;
407 407
 
408
-                    if (isset($datetimes[ $dtt_id ])) {
408
+                    if (isset($datetimes[$dtt_id])) {
409 409
                         continue; // already have this info in the datetimes array.
410 410
                     }
411 411
 
412
-                    $datetimes[ $dtt_id ]['tkt_objs'][]           = $ticket;
413
-                    $datetimes[ $dtt_id ]['datetime']             = $datetime;
414
-                    $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ]    = $event;
415
-                    $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
412
+                    $datetimes[$dtt_id]['tkt_objs'][]           = $ticket;
413
+                    $datetimes[$dtt_id]['datetime']             = $datetime;
414
+                    $datetimes[$dtt_id]['evt_objs'][$evt_id]    = $event;
415
+                    $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg;
416 416
                 }
417 417
             }
418 418
 
419 419
             // let's loop through the unique event=>reg items and setup data on them
420 420
 
421
-            if (! empty($eventsetup)) {
421
+            if ( ! empty($eventsetup)) {
422 422
                 foreach ($eventsetup as $evt_id => $items) {
423 423
                     $ticket_line_items_for_event = array();
424 424
                     if ($this->txn instanceof EE_Transaction) {
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
                             )
433 433
                         );
434 434
                     }
435
-                    $events[ $evt_id ] = array(
435
+                    $events[$evt_id] = array(
436 436
                         'ID'              => $evt_id,
437
-                        'event'           => $evtcache[ $evt_id ],
438
-                        'name'            => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
439
-                        'total_attendees' => $event_attendee_count[ $evt_id ],
437
+                        'event'           => $evtcache[$evt_id],
438
+                        'name'            => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '',
439
+                        'total_attendees' => $event_attendee_count[$evt_id],
440 440
                         'reg_objs'        => $items['reg_objs'],
441 441
                         'tkt_objs'        => $items['tkt_objs'],
442 442
                         'att_objs'        => $items['att_objs'],
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
                     // make sure the tickets have the line items setup for them.
448 448
                     foreach ($ticket_line_items_for_event as $line_id => $line_item) {
449 449
                         // only add the ticket line items if we already have this ticket in the $tickets array.
450
-                        if ($line_item instanceof EE_Line_Item && isset($tickets[ $line_item->ticket()->ID() ])) {
451
-                            $tickets[ $line_item->ticket()->ID() ]['line_item']      = $line_item;
452
-                            $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
453
-                            $line_items[ $line_item->ID() ]['children']              = $line_item->children();
454
-                            $line_items[ $line_item->ID() ]['EE_Ticket']             = $line_item->ticket();
450
+                        if ($line_item instanceof EE_Line_Item && isset($tickets[$line_item->ticket()->ID()])) {
451
+                            $tickets[$line_item->ticket()->ID()]['line_item']      = $line_item;
452
+                            $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children();
453
+                            $line_items[$line_item->ID()]['children']              = $line_item->children();
454
+                            $line_items[$line_item->ID()]['EE_Ticket']             = $line_item->ticket();
455 455
                         }
456 456
                     }
457 457
                 }
Please login to merge, or discard this patch.
Indentation   +518 added lines, -518 removed lines patch added patch discarded remove patch
@@ -16,522 +16,522 @@
 block discarded – undo
16 16
  */
17 17
 abstract class EE_Messages_incoming_data
18 18
 {
19
-    /**
20
-     * user id for logged in user when data collected
21
-     *
22
-     * @var string $user_id
23
-     */
24
-    public $user_id;
25
-
26
-    /**
27
-     * IP Address of browser used
28
-     *
29
-     * @var string $ip_address
30
-     */
31
-    public $ip_address;
32
-
33
-    /**
34
-     * browser
35
-     *
36
-     * @var string $user_agent
37
-     */
38
-    public $user_agent;
39
-
40
-    /**
41
-     * Unix timestamp
42
-     *
43
-     * @var string $init_access
44
-     */
45
-    public $init_access;
46
-
47
-    /**
48
-     * Unix timestamp
49
-     *
50
-     * @var string $last_access
51
-     */
52
-    public $last_access;
53
-
54
-    /**
55
-     * The registrations details from the cart
56
-     *
57
-     * @var array $reg_info
58
-     */
59
-    public $reg_info;
60
-
61
-    /**
62
-     * Some data handlers can set what reg status all the registrations are filtered by.
63
-     * The status should match a EEM_Registration status constant.
64
-     *
65
-     * @var string $filtered_reg_status
66
-     */
67
-    public $filtered_reg_status;
68
-
69
-    /**
70
-     * will hold an array of events assembled from $reg_info
71
-     *
72
-     * @var EE_Event[] $events
73
-     */
74
-    public $events;
75
-
76
-    /**
77
-     * holds an array of datetimes assembled from the incoming data.
78
-     *
79
-     * @var EE_Datetime[] $datetimes
80
-     */
81
-    public $datetimes;
82
-
83
-    /**
84
-     * holds an array of tickets assembled from the incoming data.
85
-     *
86
-     * @var EE_Ticket[] $tickets
87
-     */
88
-    public $tickets;
89
-
90
-    /**
91
-     * holds an array with a key of parent line item and values are an array of children of that line item.
92
-     *
93
-     * @since 4.5.0
94
-     * @var EE_Line_Item[] $line_items_with_children
95
-     */
96
-    public $line_items_with_children;
97
-
98
-    /**
99
-     * will hold an array of attendees assembled from the $reg_info
100
-     *
101
-     * @var EE_Attendee[] $attendees
102
-     */
103
-    public $attendees;
104
-
105
-    /**
106
-     * will hold an array of cached registration objects and info assembled from reg_info
107
-     *
108
-     * @var array $registrations
109
-     */
110
-    public $registrations;
111
-
112
-    /**
113
-     * will hold an array of answers assembled from the $reg_info
114
-     *
115
-     * @var EE_Answer[] $answers
116
-     */
117
-    public $answers;
118
-
119
-    /**
120
-     * will hold an array of questions assembled from the $reg_info (indexed by Answer ID);
121
-     *
122
-     * @var EE_Question[] $questions
123
-     */
124
-    public $questions;
125
-
126
-    /**
127
-     * Will hold billing data assembled from $billing_info (if present)
128
-     *
129
-     * @var mixed (array|null) $billing
130
-     */
131
-    public $billing;
132
-
133
-    /**
134
-     * The total amount of tax for the transaction
135
-     *
136
-     * @var float $taxes
137
-     */
138
-    public $taxes;
139
-
140
-    /**
141
-     * Holds the line items related to taxes
142
-     *
143
-     * @since 4.5.0
144
-     * @var EE_Line_Item[] $tax_line_items
145
-     */
146
-    public $tax_line_items;
147
-
148
-    /**
149
-     * Hold the line items which aren't taxes and don't relate
150
-     * to tickets. So: promotions and miscellaneous charges
151
-     *
152
-     * @since 4.5
153
-     * @var EE_Line_Item[] $additional_line_items
154
-     */
155
-    public $additional_line_items;
156
-
157
-    /**
158
-     * Holds the grand total EE_Line_Item
159
-     *
160
-     * @var EE_Line_Item $grand_total_line_item
161
-     */
162
-    public $grand_total_line_item;
163
-
164
-    /**
165
-     * holds the grand total price object
166
-     * currently not used.
167
-     *
168
-     * @var null $grand_total_price_object
169
-     */
170
-    public $grand_total_price_object;
171
-
172
-    /**
173
-     * total number of tickets
174
-     *
175
-     * @var int $total_ticket_count
176
-     */
177
-    public $total_ticket_count;
178
-
179
-    /**
180
-     * Will hold the final transaction object (EE_Transaction)
181
-     *
182
-     * @var EE_Transaction $txn
183
-     */
184
-    public $txn;
185
-
186
-    /**
187
-     * Holds the payments related to a transaction
188
-     *
189
-     * @since 4.5.0
190
-     * @var EE_Payment[] $payments
191
-     */
192
-    public $payments;
193
-
194
-    /**
195
-     * Holds the first related payment related for a transaction
196
-     *
197
-     * @since 4.5.0
198
-     * @var EE_Payment $payment
199
-     */
200
-    public $payment;
201
-
202
-    /**
203
-     * Will hold the label for the txn status
204
-     *
205
-     * @var string $txn_status
206
-     */
207
-    public $txn_status;
208
-
209
-    /**
210
-     * Will hold the final registration object (EE_Registration)
211
-     *
212
-     * @var EE_Registration[] $reg_objs
213
-     */
214
-    public $reg_objs;
215
-
216
-    /**
217
-     * Will hold an array of primary attendee data (if present)
218
-     *
219
-     * @var array $primary_attendee_data
220
-     */
221
-    public $primary_attendee_data;
222
-
223
-    /**
224
-     * This is just an internal object used for passing around the incoming data.
225
-     *
226
-     * @var mixed $_data
227
-     */
228
-    protected $_data;
229
-
230
-    /**
231
-     * This is just an internal object used for passing around the incoming data.
232
-     *
233
-     * @var mixed $incoming_data
234
-     */
235
-    public $incoming_data;
236
-
237
-    /**
238
-     * hold objects that might be created
239
-     *
240
-     * @type EE_Registration $reg_obj
241
-     */
242
-    public $reg_obj;
243
-
244
-
245
-    /**
246
-     * constructor
247
-     *
248
-     * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
249
-     *                    data object.  But here parent will be generic because we don't know what's coming in.
250
-     */
251
-    public function __construct($data)
252
-    {
253
-        $this->_data = $data;
254
-        $this->_setup_data();
255
-    }
256
-
257
-
258
-    /**
259
-     * Every child class has to setup the data object !
260
-     *
261
-     * @return void
262
-     */
263
-    abstract protected function _setup_data();
264
-
265
-
266
-    /**
267
-     * Returns database safe representation of the data later used to when instantiating this object.
268
-     *
269
-     * @param mixed $data The incoming data to be prepped.
270
-     * @return mixed   The prepped data for db
271
-     */
272
-    public static function convert_data_for_persistent_storage($data)
273
-    {
274
-        return $data;
275
-    }
276
-
277
-
278
-    /**
279
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
280
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
281
-     *
282
-     * @param $data
283
-     * @return mixed
284
-     */
285
-    public static function convert_data_from_persistent_storage($data)
286
-    {
287
-        return $data;
288
-    }
289
-
290
-
291
-    /**
292
-     * only purpose is to return the data
293
-     *
294
-     * @access public
295
-     * @return mixed the formatted data object!
296
-     */
297
-    public function data()
298
-    {
299
-        return $this->_data;
300
-    }
301
-
302
-
303
-    /**
304
-     * This helper method can be used by any incoming data handlers to setup the data correctly.  All that is required
305
-     * is that $this->reg_objs be set.
306
-     *
307
-     * @throws EE_Error
308
-     * @throws InvalidDataTypeException
309
-     * @throws InvalidInterfaceException
310
-     * @throws InvalidArgumentException
311
-     * @throws EntityNotFoundException
312
-     */
313
-    protected function _assemble_data()
314
-    {
315
-        // verify that reg_objs is set
316
-        if (
317
-            ! is_array($this->reg_objs)
318
-            && ! reset($this->reg_objs) instanceof EE_Registration
319
-        ) {
320
-            throw new EE_Error(
321
-                esc_html__(
322
-                    'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects',
323
-                    'event_espresso'
324
-                )
325
-            );
326
-        }
327
-
328
-        // get all attendee and events associated with the registrations in this transaction
329
-        $events             = $event_setup = $evtcache = $tickets = $datetimes = array();
330
-        $answers            = $questions = $attendees = $line_items = $registrations = array();
331
-        $total_ticket_count = 0;
332
-
333
-        if (! empty($this->reg_objs)) {
334
-            $event_attendee_count = array();
335
-            /** @var EE_Registration $reg */
336
-            foreach ($this->reg_objs as $reg) {
337
-                if (
338
-                    $this->_skip_registration_for_processing($reg)
339
-                ) {
340
-                    continue;
341
-                }
342
-
343
-                $evt_id = $reg->event_ID();
344
-                /** @type EE_Ticket $ticket */
345
-                $ticket          = $reg->get_first_related('Ticket');
346
-                $attendee = $reg->attendee();
347
-                $event = $reg->event();
348
-                // if none of the following entities are available, then we can't setup other data reliably,
349
-                // so let's just skip.
350
-                if (
351
-                    ! $ticket instanceof EE_Ticket
352
-                    || ! $attendee instanceof EE_Attendee
353
-                    || ! $event instanceof EE_Event
354
-                ) {
355
-                    continue;
356
-                }
357
-                $relateddatetime = $ticket->datetimes();
358
-                $total_ticket_count++;
359
-                $tickets[ $ticket->ID() ]['ticket']                        = $ticket;
360
-                $tickets[ $ticket->ID() ]['count']                         = is_array($tickets[ $ticket->ID() ])
361
-                                                                           && isset($tickets[ $ticket->ID() ]['count'])
362
-                    ? $tickets[ $ticket->ID() ]['count'] + 1
363
-                    : 1;
364
-                $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee;
365
-                $tickets[ $ticket->ID() ]['dtt_objs']                      = $relateddatetime;
366
-                $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ]          = $reg;
367
-                $tickets[ $ticket->ID() ]['EE_Event']                      = $event;
368
-                $evtcache[ $evt_id ]                                       = $event;
369
-                $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ]             = $reg;
370
-                $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ]          = $ticket;
371
-                $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ]    = $attendee;
372
-                $event_attendee_count[ $evt_id ]                           = isset($event_attendee_count[ $evt_id ])
373
-                    ? $event_attendee_count[ $evt_id ] + 1
374
-                    : 0;
375
-                $attendees[ $reg->attendee_ID() ]['line_ref'][]            = $evt_id;
376
-                $attendees[ $reg->attendee_ID() ]['att_obj']               = $attendee;
377
-                $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ]  = $reg;
378
-                // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
379
-                $attendees[ $reg->attendee_ID() ]['attendee_email']          = $attendee->email();
380
-                $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
381
-                $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ]       = $event;
382
-
383
-                // registrations
384
-                $registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
385
-                $registrations[ $reg->ID() ]['evt_obj'] = $event;
386
-                $registrations[ $reg->ID() ]['reg_obj'] = $reg;
387
-                $registrations[ $reg->ID() ]['att_obj'] = $attendee;
388
-
389
-                // set up answer objects
390
-                $rel_ans = $reg->get_many_related('Answer');
391
-                foreach ($rel_ans as $ansid => $answer) {
392
-                    if (! isset($questions[ $ansid ])) {
393
-                        $questions[ $ansid ] = $answer->get_first_related('Question');
394
-                    }
395
-                    $answers[ $ansid ]                               = $answer;
396
-                    $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
397
-                }
398
-                /**
399
-                 * @var int $dtt_id
400
-                 * @var EE_Datetime $datetime
401
-                 */
402
-                foreach ($relateddatetime as $dtt_id => $datetime) {
403
-                    $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ]       = $datetime;
404
-                    $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
405
-
406
-                    if (isset($datetimes[ $dtt_id ])) {
407
-                        continue; // already have this info in the datetimes array.
408
-                    }
409
-
410
-                    $datetimes[ $dtt_id ]['tkt_objs'][]           = $ticket;
411
-                    $datetimes[ $dtt_id ]['datetime']             = $datetime;
412
-                    $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ]    = $event;
413
-                    $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
414
-                }
415
-            }
416
-
417
-            // let's loop through the unique event=>reg items and setup data on them
418
-
419
-            if (! empty($eventsetup)) {
420
-                foreach ($eventsetup as $evt_id => $items) {
421
-                    $ticket_line_items_for_event = array();
422
-                    if ($this->txn instanceof EE_Transaction) {
423
-                        $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
424
-                            array(
425
-                                array(
426
-                                    'Ticket.Datetime.EVT_ID' => $evt_id,
427
-                                    'TXN_ID'                 => $this->txn->ID(),
428
-                                ),
429
-                                'default_where_conditions' => 'none',
430
-                            )
431
-                        );
432
-                    }
433
-                    $events[ $evt_id ] = array(
434
-                        'ID'              => $evt_id,
435
-                        'event'           => $evtcache[ $evt_id ],
436
-                        'name'            => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
437
-                        'total_attendees' => $event_attendee_count[ $evt_id ],
438
-                        'reg_objs'        => $items['reg_objs'],
439
-                        'tkt_objs'        => $items['tkt_objs'],
440
-                        'att_objs'        => $items['att_objs'],
441
-                        'dtt_objs'        => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
442
-                        'line_items'      => $ticket_line_items_for_event,
443
-                    );
444
-
445
-                    // make sure the tickets have the line items setup for them.
446
-                    foreach ($ticket_line_items_for_event as $line_id => $line_item) {
447
-                        // only add the ticket line items if we already have this ticket in the $tickets array.
448
-                        if ($line_item instanceof EE_Line_Item && isset($tickets[ $line_item->ticket()->ID() ])) {
449
-                            $tickets[ $line_item->ticket()->ID() ]['line_item']      = $line_item;
450
-                            $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
451
-                            $line_items[ $line_item->ID() ]['children']              = $line_item->children();
452
-                            $line_items[ $line_item->ID() ]['EE_Ticket']             = $line_item->ticket();
453
-                        }
454
-                    }
455
-                }
456
-            }
457
-
458
-            $this->grand_total_line_item = $this->txn instanceof EE_Transaction
459
-                ? $this->txn->total_line_item()
460
-                : null;
461
-        }
462
-
463
-        // lets set the attendees and events properties
464
-        $this->attendees                = $attendees;
465
-        $this->events                   = $events;
466
-        $this->tickets                  = $tickets;
467
-        $this->line_items_with_children = $line_items;
468
-        $this->datetimes                = $datetimes;
469
-        $this->questions                = $questions;
470
-        $this->answers                  = $answers;
471
-        $this->total_ticket_count       = $total_ticket_count;
472
-        $this->registrations            = $registrations;
473
-
474
-        if ($this->txn instanceof EE_Transaction) {
475
-            $this->tax_line_items        = $this->txn->tax_items();
476
-            $this->additional_line_items = $this->txn->non_ticket_line_items();
477
-            $this->payments              = $this->txn->payments();
478
-
479
-            // setup primary registration if we have a single transaction object to work with
480
-
481
-            // let's get just the primary_attendee_data!  First we get the primary registration object.
482
-            $primary_reg = $this->txn->primary_registration();
483
-            // verify
484
-            if ($primary_reg instanceof EE_Registration) {
485
-                // get attendee object
486
-                if ($primary_reg->attendee() instanceof EE_Attendee) {
487
-                    // now we can setup the primary_attendee_data array
488
-                    $this->primary_attendee_data = array(
489
-                        'registration_id' => $primary_reg->ID(),
490
-                        'att_obj'         => $primary_reg->attendee(),
491
-                        'reg_obj'         => $primary_reg,
492
-                        'primary_att_obj' => $primary_reg->attendee(),
493
-                        'primary_reg_obj' => $primary_reg,
494
-                    );
495
-                } else {
496
-                    EE_Error::add_error(
497
-                        esc_html__(
498
-                            'Incoming data does not have a valid Attendee object for the primary registrant.',
499
-                            'event_espresso'
500
-                        ),
501
-                        __FILE__,
502
-                        __FUNCTION__,
503
-                        __LINE__
504
-                    );
505
-                }
506
-            } else {
507
-                EE_Error::add_error(
508
-                    esc_html__(
509
-                        'Incoming data does not have a valid Registration object for the primary registrant.',
510
-                        'event_espresso'
511
-                    ),
512
-                    __FILE__,
513
-                    __FUNCTION__,
514
-                    __LINE__
515
-                );
516
-            }
517
-        }
518
-    }
519
-
520
-    /**
521
-     * This simply considers whether the given registration should be processed or not based on comparison with the
522
-     * filtered_reg_status property.
523
-     *
524
-     * @param EE_Registration $registration
525
-     * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
526
-     *               processing
527
-     */
528
-    protected function _skip_registration_for_processing(EE_Registration $registration)
529
-    {
530
-        if (empty($this->filtered_reg_status)) {
531
-            return false;
532
-        }
533
-
534
-        // if we made it here then we just compare the filtered_reg_status with the registration status and return that
535
-        return $this->filtered_reg_status !== $registration->status_ID();
536
-    }
19
+	/**
20
+	 * user id for logged in user when data collected
21
+	 *
22
+	 * @var string $user_id
23
+	 */
24
+	public $user_id;
25
+
26
+	/**
27
+	 * IP Address of browser used
28
+	 *
29
+	 * @var string $ip_address
30
+	 */
31
+	public $ip_address;
32
+
33
+	/**
34
+	 * browser
35
+	 *
36
+	 * @var string $user_agent
37
+	 */
38
+	public $user_agent;
39
+
40
+	/**
41
+	 * Unix timestamp
42
+	 *
43
+	 * @var string $init_access
44
+	 */
45
+	public $init_access;
46
+
47
+	/**
48
+	 * Unix timestamp
49
+	 *
50
+	 * @var string $last_access
51
+	 */
52
+	public $last_access;
53
+
54
+	/**
55
+	 * The registrations details from the cart
56
+	 *
57
+	 * @var array $reg_info
58
+	 */
59
+	public $reg_info;
60
+
61
+	/**
62
+	 * Some data handlers can set what reg status all the registrations are filtered by.
63
+	 * The status should match a EEM_Registration status constant.
64
+	 *
65
+	 * @var string $filtered_reg_status
66
+	 */
67
+	public $filtered_reg_status;
68
+
69
+	/**
70
+	 * will hold an array of events assembled from $reg_info
71
+	 *
72
+	 * @var EE_Event[] $events
73
+	 */
74
+	public $events;
75
+
76
+	/**
77
+	 * holds an array of datetimes assembled from the incoming data.
78
+	 *
79
+	 * @var EE_Datetime[] $datetimes
80
+	 */
81
+	public $datetimes;
82
+
83
+	/**
84
+	 * holds an array of tickets assembled from the incoming data.
85
+	 *
86
+	 * @var EE_Ticket[] $tickets
87
+	 */
88
+	public $tickets;
89
+
90
+	/**
91
+	 * holds an array with a key of parent line item and values are an array of children of that line item.
92
+	 *
93
+	 * @since 4.5.0
94
+	 * @var EE_Line_Item[] $line_items_with_children
95
+	 */
96
+	public $line_items_with_children;
97
+
98
+	/**
99
+	 * will hold an array of attendees assembled from the $reg_info
100
+	 *
101
+	 * @var EE_Attendee[] $attendees
102
+	 */
103
+	public $attendees;
104
+
105
+	/**
106
+	 * will hold an array of cached registration objects and info assembled from reg_info
107
+	 *
108
+	 * @var array $registrations
109
+	 */
110
+	public $registrations;
111
+
112
+	/**
113
+	 * will hold an array of answers assembled from the $reg_info
114
+	 *
115
+	 * @var EE_Answer[] $answers
116
+	 */
117
+	public $answers;
118
+
119
+	/**
120
+	 * will hold an array of questions assembled from the $reg_info (indexed by Answer ID);
121
+	 *
122
+	 * @var EE_Question[] $questions
123
+	 */
124
+	public $questions;
125
+
126
+	/**
127
+	 * Will hold billing data assembled from $billing_info (if present)
128
+	 *
129
+	 * @var mixed (array|null) $billing
130
+	 */
131
+	public $billing;
132
+
133
+	/**
134
+	 * The total amount of tax for the transaction
135
+	 *
136
+	 * @var float $taxes
137
+	 */
138
+	public $taxes;
139
+
140
+	/**
141
+	 * Holds the line items related to taxes
142
+	 *
143
+	 * @since 4.5.0
144
+	 * @var EE_Line_Item[] $tax_line_items
145
+	 */
146
+	public $tax_line_items;
147
+
148
+	/**
149
+	 * Hold the line items which aren't taxes and don't relate
150
+	 * to tickets. So: promotions and miscellaneous charges
151
+	 *
152
+	 * @since 4.5
153
+	 * @var EE_Line_Item[] $additional_line_items
154
+	 */
155
+	public $additional_line_items;
156
+
157
+	/**
158
+	 * Holds the grand total EE_Line_Item
159
+	 *
160
+	 * @var EE_Line_Item $grand_total_line_item
161
+	 */
162
+	public $grand_total_line_item;
163
+
164
+	/**
165
+	 * holds the grand total price object
166
+	 * currently not used.
167
+	 *
168
+	 * @var null $grand_total_price_object
169
+	 */
170
+	public $grand_total_price_object;
171
+
172
+	/**
173
+	 * total number of tickets
174
+	 *
175
+	 * @var int $total_ticket_count
176
+	 */
177
+	public $total_ticket_count;
178
+
179
+	/**
180
+	 * Will hold the final transaction object (EE_Transaction)
181
+	 *
182
+	 * @var EE_Transaction $txn
183
+	 */
184
+	public $txn;
185
+
186
+	/**
187
+	 * Holds the payments related to a transaction
188
+	 *
189
+	 * @since 4.5.0
190
+	 * @var EE_Payment[] $payments
191
+	 */
192
+	public $payments;
193
+
194
+	/**
195
+	 * Holds the first related payment related for a transaction
196
+	 *
197
+	 * @since 4.5.0
198
+	 * @var EE_Payment $payment
199
+	 */
200
+	public $payment;
201
+
202
+	/**
203
+	 * Will hold the label for the txn status
204
+	 *
205
+	 * @var string $txn_status
206
+	 */
207
+	public $txn_status;
208
+
209
+	/**
210
+	 * Will hold the final registration object (EE_Registration)
211
+	 *
212
+	 * @var EE_Registration[] $reg_objs
213
+	 */
214
+	public $reg_objs;
215
+
216
+	/**
217
+	 * Will hold an array of primary attendee data (if present)
218
+	 *
219
+	 * @var array $primary_attendee_data
220
+	 */
221
+	public $primary_attendee_data;
222
+
223
+	/**
224
+	 * This is just an internal object used for passing around the incoming data.
225
+	 *
226
+	 * @var mixed $_data
227
+	 */
228
+	protected $_data;
229
+
230
+	/**
231
+	 * This is just an internal object used for passing around the incoming data.
232
+	 *
233
+	 * @var mixed $incoming_data
234
+	 */
235
+	public $incoming_data;
236
+
237
+	/**
238
+	 * hold objects that might be created
239
+	 *
240
+	 * @type EE_Registration $reg_obj
241
+	 */
242
+	public $reg_obj;
243
+
244
+
245
+	/**
246
+	 * constructor
247
+	 *
248
+	 * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
249
+	 *                    data object.  But here parent will be generic because we don't know what's coming in.
250
+	 */
251
+	public function __construct($data)
252
+	{
253
+		$this->_data = $data;
254
+		$this->_setup_data();
255
+	}
256
+
257
+
258
+	/**
259
+	 * Every child class has to setup the data object !
260
+	 *
261
+	 * @return void
262
+	 */
263
+	abstract protected function _setup_data();
264
+
265
+
266
+	/**
267
+	 * Returns database safe representation of the data later used to when instantiating this object.
268
+	 *
269
+	 * @param mixed $data The incoming data to be prepped.
270
+	 * @return mixed   The prepped data for db
271
+	 */
272
+	public static function convert_data_for_persistent_storage($data)
273
+	{
274
+		return $data;
275
+	}
276
+
277
+
278
+	/**
279
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
280
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
281
+	 *
282
+	 * @param $data
283
+	 * @return mixed
284
+	 */
285
+	public static function convert_data_from_persistent_storage($data)
286
+	{
287
+		return $data;
288
+	}
289
+
290
+
291
+	/**
292
+	 * only purpose is to return the data
293
+	 *
294
+	 * @access public
295
+	 * @return mixed the formatted data object!
296
+	 */
297
+	public function data()
298
+	{
299
+		return $this->_data;
300
+	}
301
+
302
+
303
+	/**
304
+	 * This helper method can be used by any incoming data handlers to setup the data correctly.  All that is required
305
+	 * is that $this->reg_objs be set.
306
+	 *
307
+	 * @throws EE_Error
308
+	 * @throws InvalidDataTypeException
309
+	 * @throws InvalidInterfaceException
310
+	 * @throws InvalidArgumentException
311
+	 * @throws EntityNotFoundException
312
+	 */
313
+	protected function _assemble_data()
314
+	{
315
+		// verify that reg_objs is set
316
+		if (
317
+			! is_array($this->reg_objs)
318
+			&& ! reset($this->reg_objs) instanceof EE_Registration
319
+		) {
320
+			throw new EE_Error(
321
+				esc_html__(
322
+					'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects',
323
+					'event_espresso'
324
+				)
325
+			);
326
+		}
327
+
328
+		// get all attendee and events associated with the registrations in this transaction
329
+		$events             = $event_setup = $evtcache = $tickets = $datetimes = array();
330
+		$answers            = $questions = $attendees = $line_items = $registrations = array();
331
+		$total_ticket_count = 0;
332
+
333
+		if (! empty($this->reg_objs)) {
334
+			$event_attendee_count = array();
335
+			/** @var EE_Registration $reg */
336
+			foreach ($this->reg_objs as $reg) {
337
+				if (
338
+					$this->_skip_registration_for_processing($reg)
339
+				) {
340
+					continue;
341
+				}
342
+
343
+				$evt_id = $reg->event_ID();
344
+				/** @type EE_Ticket $ticket */
345
+				$ticket          = $reg->get_first_related('Ticket');
346
+				$attendee = $reg->attendee();
347
+				$event = $reg->event();
348
+				// if none of the following entities are available, then we can't setup other data reliably,
349
+				// so let's just skip.
350
+				if (
351
+					! $ticket instanceof EE_Ticket
352
+					|| ! $attendee instanceof EE_Attendee
353
+					|| ! $event instanceof EE_Event
354
+				) {
355
+					continue;
356
+				}
357
+				$relateddatetime = $ticket->datetimes();
358
+				$total_ticket_count++;
359
+				$tickets[ $ticket->ID() ]['ticket']                        = $ticket;
360
+				$tickets[ $ticket->ID() ]['count']                         = is_array($tickets[ $ticket->ID() ])
361
+																		   && isset($tickets[ $ticket->ID() ]['count'])
362
+					? $tickets[ $ticket->ID() ]['count'] + 1
363
+					: 1;
364
+				$tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee;
365
+				$tickets[ $ticket->ID() ]['dtt_objs']                      = $relateddatetime;
366
+				$tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ]          = $reg;
367
+				$tickets[ $ticket->ID() ]['EE_Event']                      = $event;
368
+				$evtcache[ $evt_id ]                                       = $event;
369
+				$eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ]             = $reg;
370
+				$eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ]          = $ticket;
371
+				$eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ]    = $attendee;
372
+				$event_attendee_count[ $evt_id ]                           = isset($event_attendee_count[ $evt_id ])
373
+					? $event_attendee_count[ $evt_id ] + 1
374
+					: 0;
375
+				$attendees[ $reg->attendee_ID() ]['line_ref'][]            = $evt_id;
376
+				$attendees[ $reg->attendee_ID() ]['att_obj']               = $attendee;
377
+				$attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ]  = $reg;
378
+				// $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
379
+				$attendees[ $reg->attendee_ID() ]['attendee_email']          = $attendee->email();
380
+				$attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
381
+				$attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ]       = $event;
382
+
383
+				// registrations
384
+				$registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
385
+				$registrations[ $reg->ID() ]['evt_obj'] = $event;
386
+				$registrations[ $reg->ID() ]['reg_obj'] = $reg;
387
+				$registrations[ $reg->ID() ]['att_obj'] = $attendee;
388
+
389
+				// set up answer objects
390
+				$rel_ans = $reg->get_many_related('Answer');
391
+				foreach ($rel_ans as $ansid => $answer) {
392
+					if (! isset($questions[ $ansid ])) {
393
+						$questions[ $ansid ] = $answer->get_first_related('Question');
394
+					}
395
+					$answers[ $ansid ]                               = $answer;
396
+					$registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
397
+				}
398
+				/**
399
+				 * @var int $dtt_id
400
+				 * @var EE_Datetime $datetime
401
+				 */
402
+				foreach ($relateddatetime as $dtt_id => $datetime) {
403
+					$eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ]       = $datetime;
404
+					$registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
405
+
406
+					if (isset($datetimes[ $dtt_id ])) {
407
+						continue; // already have this info in the datetimes array.
408
+					}
409
+
410
+					$datetimes[ $dtt_id ]['tkt_objs'][]           = $ticket;
411
+					$datetimes[ $dtt_id ]['datetime']             = $datetime;
412
+					$datetimes[ $dtt_id ]['evt_objs'][ $evt_id ]    = $event;
413
+					$datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
414
+				}
415
+			}
416
+
417
+			// let's loop through the unique event=>reg items and setup data on them
418
+
419
+			if (! empty($eventsetup)) {
420
+				foreach ($eventsetup as $evt_id => $items) {
421
+					$ticket_line_items_for_event = array();
422
+					if ($this->txn instanceof EE_Transaction) {
423
+						$ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
424
+							array(
425
+								array(
426
+									'Ticket.Datetime.EVT_ID' => $evt_id,
427
+									'TXN_ID'                 => $this->txn->ID(),
428
+								),
429
+								'default_where_conditions' => 'none',
430
+							)
431
+						);
432
+					}
433
+					$events[ $evt_id ] = array(
434
+						'ID'              => $evt_id,
435
+						'event'           => $evtcache[ $evt_id ],
436
+						'name'            => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
437
+						'total_attendees' => $event_attendee_count[ $evt_id ],
438
+						'reg_objs'        => $items['reg_objs'],
439
+						'tkt_objs'        => $items['tkt_objs'],
440
+						'att_objs'        => $items['att_objs'],
441
+						'dtt_objs'        => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
442
+						'line_items'      => $ticket_line_items_for_event,
443
+					);
444
+
445
+					// make sure the tickets have the line items setup for them.
446
+					foreach ($ticket_line_items_for_event as $line_id => $line_item) {
447
+						// only add the ticket line items if we already have this ticket in the $tickets array.
448
+						if ($line_item instanceof EE_Line_Item && isset($tickets[ $line_item->ticket()->ID() ])) {
449
+							$tickets[ $line_item->ticket()->ID() ]['line_item']      = $line_item;
450
+							$tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
451
+							$line_items[ $line_item->ID() ]['children']              = $line_item->children();
452
+							$line_items[ $line_item->ID() ]['EE_Ticket']             = $line_item->ticket();
453
+						}
454
+					}
455
+				}
456
+			}
457
+
458
+			$this->grand_total_line_item = $this->txn instanceof EE_Transaction
459
+				? $this->txn->total_line_item()
460
+				: null;
461
+		}
462
+
463
+		// lets set the attendees and events properties
464
+		$this->attendees                = $attendees;
465
+		$this->events                   = $events;
466
+		$this->tickets                  = $tickets;
467
+		$this->line_items_with_children = $line_items;
468
+		$this->datetimes                = $datetimes;
469
+		$this->questions                = $questions;
470
+		$this->answers                  = $answers;
471
+		$this->total_ticket_count       = $total_ticket_count;
472
+		$this->registrations            = $registrations;
473
+
474
+		if ($this->txn instanceof EE_Transaction) {
475
+			$this->tax_line_items        = $this->txn->tax_items();
476
+			$this->additional_line_items = $this->txn->non_ticket_line_items();
477
+			$this->payments              = $this->txn->payments();
478
+
479
+			// setup primary registration if we have a single transaction object to work with
480
+
481
+			// let's get just the primary_attendee_data!  First we get the primary registration object.
482
+			$primary_reg = $this->txn->primary_registration();
483
+			// verify
484
+			if ($primary_reg instanceof EE_Registration) {
485
+				// get attendee object
486
+				if ($primary_reg->attendee() instanceof EE_Attendee) {
487
+					// now we can setup the primary_attendee_data array
488
+					$this->primary_attendee_data = array(
489
+						'registration_id' => $primary_reg->ID(),
490
+						'att_obj'         => $primary_reg->attendee(),
491
+						'reg_obj'         => $primary_reg,
492
+						'primary_att_obj' => $primary_reg->attendee(),
493
+						'primary_reg_obj' => $primary_reg,
494
+					);
495
+				} else {
496
+					EE_Error::add_error(
497
+						esc_html__(
498
+							'Incoming data does not have a valid Attendee object for the primary registrant.',
499
+							'event_espresso'
500
+						),
501
+						__FILE__,
502
+						__FUNCTION__,
503
+						__LINE__
504
+					);
505
+				}
506
+			} else {
507
+				EE_Error::add_error(
508
+					esc_html__(
509
+						'Incoming data does not have a valid Registration object for the primary registrant.',
510
+						'event_espresso'
511
+					),
512
+					__FILE__,
513
+					__FUNCTION__,
514
+					__LINE__
515
+				);
516
+			}
517
+		}
518
+	}
519
+
520
+	/**
521
+	 * This simply considers whether the given registration should be processed or not based on comparison with the
522
+	 * filtered_reg_status property.
523
+	 *
524
+	 * @param EE_Registration $registration
525
+	 * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
526
+	 *               processing
527
+	 */
528
+	protected function _skip_registration_for_processing(EE_Registration $registration)
529
+	{
530
+		if (empty($this->filtered_reg_status)) {
531
+			return false;
532
+		}
533
+
534
+		// if we made it here then we just compare the filtered_reg_status with the registration status and return that
535
+		return $this->filtered_reg_status !== $registration->status_ID();
536
+	}
537 537
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Primary_Registration_List_Shortcodes.lib.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
84 84
     {
85 85
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
86
-        if (! $registration instanceof EE_Registration) {
86
+        if ( ! $registration instanceof EE_Registration) {
87 87
             return '';
88 88
         }
89 89
         // setup valid shortcodes depending on what the status of the $this->_data property is
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 'attendee',
98 98
             );
99 99
             $template = $this->_data['template'];
100
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
100
+            $tkts = array($data->registrations[$registration->ID()]['tkt_obj']);
101 101
             $data = $this->_data;
102 102
         } elseif ($this->_data['data'] instanceof EE_Event) {
103 103
             $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 
128 128
     private function _get_tickets_from_event(EE_Event $event, $reg = null)
129 129
     {
130
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
131
-        ) ]['tkt_objs'] : array();
130
+        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
131
+        )]['tkt_objs'] : array();
132 132
 
133 133
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
134 134
             $adj_tkts = array();
135 135
             // return only tickets for the given attendee
136 136
             foreach ($evt_tkts as $tkt) {
137 137
                 if (
138
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
139
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
138
+                    isset($this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'])
139
+                    && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID()
140 140
                 ) {
141 141
                     $adj_tkts[] = $tkt;
142 142
                 }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
     private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
173 173
     {
174 174
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
175
-        if (! $registration instanceof EE_Registration) {
175
+        if ( ! $registration instanceof EE_Registration) {
176 176
             return '';
177 177
         }
178 178
         // setup valid shortcodes depending on what the status of the $this->_data property is
179 179
         if ($this->_data['data'] instanceof EE_Messages_Addressee) {
180 180
             $valid_shortcodes = array('datetime', 'attendee');
181 181
             $template = $this->_data['template'];
182
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
+            $dtts = $data->registrations[$registration->ID()]['dtt_objs'];
183 183
             $data = $this->_data;
184 184
         } elseif ($this->_data['data'] instanceof EE_Event) {
185 185
             $valid_shortcodes = array('datetime', 'attendee');
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 
207 207
     private function _get_datetimes_from_event(EE_Event $event, $reg = null)
208 208
     {
209
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
210
-        ) ]['dtt_objs'] : array();
209
+        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
210
+        )]['dtt_objs'] : array();
211 211
 
212 212
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
213 213
             $adj_dtts = array();
214 214
             // return only dtts for the given attendee
215 215
             foreach ($evt_dtts as $dtt) {
216
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
+                if (isset($this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()])) {
217 217
                     $adj_dtts[] = $dtt;
218 218
                 }
219 219
             }
Please login to merge, or discard this patch.
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -18,204 +18,204 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Primary_Registration_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    public function __construct()
22
-    {
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-    protected function _init_props()
28
-    {
29
-        $this->label = esc_html__('Primary Registrant List Shortcodes', 'event_espresso');
30
-        $this->description = esc_html__(
31
-            'All shortcodes specific primary registrant recipients list type data.',
32
-            'event_espresso'
33
-        );
34
-        $this->_shortcodes = array(
35
-            '[PRIMARY_REGISTRANT_TICKET_LIST]' => esc_html__(
36
-                'Will output a list of tickets that the primary registration received.',
37
-                'event_espresso'
38
-            ),
39
-            '[PRIMARY_REGISTRANT_DATETIME_LIST]' => esc_html__(
40
-                'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
41
-                'event_espresso'
42
-            ),
43
-        );
44
-    }
45
-
46
-
47
-    protected function _parser($shortcode)
48
-    {
49
-        switch ($shortcode) {
50
-            case '[PRIMARY_REGISTRANT_TICKET_LIST]':
51
-                return $this->_get_recipient_ticket_list(true);
52
-
53
-            case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
54
-                return $this->_get_recipient_datetime_list(true);
55
-        }
56
-        return '';
57
-    }
58
-
59
-
60
-    /**
61
-     * figure out what the incoming data is and then return the appropriate parsed value
62
-     *
63
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
64
-     * @return string
65
-     */
66
-    private function _get_recipient_ticket_list($primary = false)
67
-    {
68
-        $this->_validate_list_requirements();
69
-
70
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
71
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
72
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
73
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
74
-        } else {
75
-            return '';
76
-        }
77
-    }
78
-
79
-
80
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
81
-    {
82
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
83
-        if (! $registration instanceof EE_Registration) {
84
-            return '';
85
-        }
86
-        // setup valid shortcodes depending on what the status of the $this->_data property is
87
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
88
-            $valid_shortcodes = array(
89
-                'ticket',
90
-                'event_list',
91
-                'attendee_list',
92
-                'datetime_list',
93
-                'registration_details',
94
-                'attendee',
95
-            );
96
-            $template = $this->_data['template'];
97
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
98
-            $data = $this->_data;
99
-        } elseif ($this->_data['data'] instanceof EE_Event) {
100
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
101
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
102
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
103
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
104
-            $template = str_replace('[EVENT_LIST]', '', $template);
105
-            // data will be tickets for this event for this recipient.
106
-            $tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
107
-            $data = $this->_extra_data;
108
-        } else {
109
-            return '';
110
-        }
111
-
112
-        $tktparsed = '';
113
-        foreach ($tkts as $ticket) {
114
-            $tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
115
-                $template,
116
-                $ticket,
117
-                $valid_shortcodes,
118
-                $data
119
-            );
120
-        }
121
-        return $tktparsed;
122
-    }
123
-
124
-
125
-    private function _get_tickets_from_event(EE_Event $event, $reg = null)
126
-    {
127
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
128
-        ) ]['tkt_objs'] : array();
129
-
130
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
131
-            $adj_tkts = array();
132
-            // return only tickets for the given attendee
133
-            foreach ($evt_tkts as $tkt) {
134
-                if (
135
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
136
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
137
-                ) {
138
-                    $adj_tkts[] = $tkt;
139
-                }
140
-            }
141
-            $evt_tkts = $adj_tkts;
142
-        }
143
-        return $evt_tkts;
144
-    }
145
-
146
-
147
-    /**
148
-     * figure out what the incoming data is and then return the appropriate parsed value
149
-     *
150
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
151
-     * @return string
152
-     */
153
-    private function _get_recipient_datetime_list($primary = false)
154
-    {
155
-        $this->_validate_list_requirements();
156
-
157
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
158
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
159
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
160
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
161
-        } else {
162
-            return '';
163
-        }
164
-
165
-        return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
166
-    }
167
-
168
-
169
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
170
-    {
171
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
172
-        if (! $registration instanceof EE_Registration) {
173
-            return '';
174
-        }
175
-        // setup valid shortcodes depending on what the status of the $this->_data property is
176
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
177
-            $valid_shortcodes = array('datetime', 'attendee');
178
-            $template = $this->_data['template'];
179
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
180
-            $data = $this->_data;
181
-        } elseif ($this->_data['data'] instanceof EE_Event) {
182
-            $valid_shortcodes = array('datetime', 'attendee');
183
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
184
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
185
-            $dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
186
-            $data = $this->_extra_data;
187
-        } else {
188
-            return '';
189
-        }
190
-
191
-        $dtt_parsed = '';
192
-        foreach ($dtts as $datetime) {
193
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
194
-                $template,
195
-                $datetime,
196
-                $valid_shortcodes,
197
-                $this->_extra_data
198
-            );
199
-        }
200
-        return $dtt_parsed;
201
-    }
202
-
203
-
204
-    private function _get_datetimes_from_event(EE_Event $event, $reg = null)
205
-    {
206
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
207
-        ) ]['dtt_objs'] : array();
208
-
209
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
210
-            $adj_dtts = array();
211
-            // return only dtts for the given attendee
212
-            foreach ($evt_dtts as $dtt) {
213
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
214
-                    $adj_dtts[] = $dtt;
215
-                }
216
-            }
217
-            $evt_dtts = $adj_dtts;
218
-        }
219
-        return $evt_dtts;
220
-    }
21
+	public function __construct()
22
+	{
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+	protected function _init_props()
28
+	{
29
+		$this->label = esc_html__('Primary Registrant List Shortcodes', 'event_espresso');
30
+		$this->description = esc_html__(
31
+			'All shortcodes specific primary registrant recipients list type data.',
32
+			'event_espresso'
33
+		);
34
+		$this->_shortcodes = array(
35
+			'[PRIMARY_REGISTRANT_TICKET_LIST]' => esc_html__(
36
+				'Will output a list of tickets that the primary registration received.',
37
+				'event_espresso'
38
+			),
39
+			'[PRIMARY_REGISTRANT_DATETIME_LIST]' => esc_html__(
40
+				'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
41
+				'event_espresso'
42
+			),
43
+		);
44
+	}
45
+
46
+
47
+	protected function _parser($shortcode)
48
+	{
49
+		switch ($shortcode) {
50
+			case '[PRIMARY_REGISTRANT_TICKET_LIST]':
51
+				return $this->_get_recipient_ticket_list(true);
52
+
53
+			case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
54
+				return $this->_get_recipient_datetime_list(true);
55
+		}
56
+		return '';
57
+	}
58
+
59
+
60
+	/**
61
+	 * figure out what the incoming data is and then return the appropriate parsed value
62
+	 *
63
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
64
+	 * @return string
65
+	 */
66
+	private function _get_recipient_ticket_list($primary = false)
67
+	{
68
+		$this->_validate_list_requirements();
69
+
70
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
71
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
72
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
73
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
74
+		} else {
75
+			return '';
76
+		}
77
+	}
78
+
79
+
80
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
81
+	{
82
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
83
+		if (! $registration instanceof EE_Registration) {
84
+			return '';
85
+		}
86
+		// setup valid shortcodes depending on what the status of the $this->_data property is
87
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
88
+			$valid_shortcodes = array(
89
+				'ticket',
90
+				'event_list',
91
+				'attendee_list',
92
+				'datetime_list',
93
+				'registration_details',
94
+				'attendee',
95
+			);
96
+			$template = $this->_data['template'];
97
+			$tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
98
+			$data = $this->_data;
99
+		} elseif ($this->_data['data'] instanceof EE_Event) {
100
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
101
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
102
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
103
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
104
+			$template = str_replace('[EVENT_LIST]', '', $template);
105
+			// data will be tickets for this event for this recipient.
106
+			$tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
107
+			$data = $this->_extra_data;
108
+		} else {
109
+			return '';
110
+		}
111
+
112
+		$tktparsed = '';
113
+		foreach ($tkts as $ticket) {
114
+			$tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
115
+				$template,
116
+				$ticket,
117
+				$valid_shortcodes,
118
+				$data
119
+			);
120
+		}
121
+		return $tktparsed;
122
+	}
123
+
124
+
125
+	private function _get_tickets_from_event(EE_Event $event, $reg = null)
126
+	{
127
+		$evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
128
+		) ]['tkt_objs'] : array();
129
+
130
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
131
+			$adj_tkts = array();
132
+			// return only tickets for the given attendee
133
+			foreach ($evt_tkts as $tkt) {
134
+				if (
135
+					isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
136
+					&& $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
137
+				) {
138
+					$adj_tkts[] = $tkt;
139
+				}
140
+			}
141
+			$evt_tkts = $adj_tkts;
142
+		}
143
+		return $evt_tkts;
144
+	}
145
+
146
+
147
+	/**
148
+	 * figure out what the incoming data is and then return the appropriate parsed value
149
+	 *
150
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
151
+	 * @return string
152
+	 */
153
+	private function _get_recipient_datetime_list($primary = false)
154
+	{
155
+		$this->_validate_list_requirements();
156
+
157
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
158
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
159
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
160
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
161
+		} else {
162
+			return '';
163
+		}
164
+
165
+		return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
166
+	}
167
+
168
+
169
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
170
+	{
171
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
172
+		if (! $registration instanceof EE_Registration) {
173
+			return '';
174
+		}
175
+		// setup valid shortcodes depending on what the status of the $this->_data property is
176
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
177
+			$valid_shortcodes = array('datetime', 'attendee');
178
+			$template = $this->_data['template'];
179
+			$dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
180
+			$data = $this->_data;
181
+		} elseif ($this->_data['data'] instanceof EE_Event) {
182
+			$valid_shortcodes = array('datetime', 'attendee');
183
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
184
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
185
+			$dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
186
+			$data = $this->_extra_data;
187
+		} else {
188
+			return '';
189
+		}
190
+
191
+		$dtt_parsed = '';
192
+		foreach ($dtts as $datetime) {
193
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
194
+				$template,
195
+				$datetime,
196
+				$valid_shortcodes,
197
+				$this->_extra_data
198
+			);
199
+		}
200
+		return $dtt_parsed;
201
+	}
202
+
203
+
204
+	private function _get_datetimes_from_event(EE_Event $event, $reg = null)
205
+	{
206
+		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
207
+		) ]['dtt_objs'] : array();
208
+
209
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
210
+			$adj_dtts = array();
211
+			// return only dtts for the given attendee
212
+			foreach ($evt_dtts as $dtt) {
213
+				if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
214
+					$adj_dtts[] = $dtt;
215
+				}
216
+			}
217
+			$evt_dtts = $adj_dtts;
218
+		}
219
+		return $evt_dtts;
220
+	}
221 221
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Select_Reveal_Input.input.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
             if (empty($sibling_section_name)) {
46 46
                 continue;
47 47
             }
48
-            $sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
+            $sibling_section = $this->find_section_from_path('../'.$sibling_section_name);
49 49
             if (
50 50
                 $sibling_section instanceof EE_Form_Section_Base
51 51
                 && ! empty($sibling_section_name)
52 52
             ) {
53
-                $sibling_sections[ $sibling_section_name ] = $sibling_section;
53
+                $sibling_sections[$sibling_section_name] = $sibling_section;
54 54
             }
55 55
         }
56 56
         return $sibling_sections;
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
     public function get_other_js_data($form_other_js_data = array())
67 67
     {
68 68
         $form_other_js_data = parent::get_other_js_data($form_other_js_data);
69
-        if (! isset($form_other_js_data['select_reveal_inputs'])) {
69
+        if ( ! isset($form_other_js_data['select_reveal_inputs'])) {
70 70
             $form_other_js_data['select_reveal_inputs'] = array();
71 71
         }
72 72
         $sibling_input_to_html_id_map = array();
73 73
         foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
74
-            $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
74
+            $sibling_input_to_html_id_map[$sibling_section_path] = $sibling_section->html_id();
75 75
         }
76
-        $form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
76
+        $form_other_js_data['select_reveal_inputs'][$this->html_id()] = $sibling_input_to_html_id_map;
77 77
         return $form_other_js_data;
78 78
     }
79 79
 }
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -14,65 +14,65 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Select_Reveal_Input extends EE_Select_Input
16 16
 {
17
-    /**
18
-     * @param array $answer_options Array keys which match a sibling section's name
19
-     *              will show/unhide that sibling subsection. Otherwise, siblings whose names
20
-     *              match array keys of $answer_options are hidden.
21
-     *              Note: internally each array key is considered a relative form input path
22
-     *              (see EE_Form_Section_Base::find_section_from_path) but relative
23
-     *              to THIS INPUT's PARENT section, not this input itself. ie,
24
-     *              a '../' is automatically added onto each each array key, to produce
25
-     *              the relative form input path.
26
-     *              Note however: array keys which are an EMPTY STRING are left as-is
27
-     *
28
-     * @param array $input_settings
29
-     */
30
-    public function __construct($answer_options, $input_settings = array())
31
-    {
32
-        parent::__construct($answer_options, $input_settings);
33
-    }
17
+	/**
18
+	 * @param array $answer_options Array keys which match a sibling section's name
19
+	 *              will show/unhide that sibling subsection. Otherwise, siblings whose names
20
+	 *              match array keys of $answer_options are hidden.
21
+	 *              Note: internally each array key is considered a relative form input path
22
+	 *              (see EE_Form_Section_Base::find_section_from_path) but relative
23
+	 *              to THIS INPUT's PARENT section, not this input itself. ie,
24
+	 *              a '../' is automatically added onto each each array key, to produce
25
+	 *              the relative form input path.
26
+	 *              Note however: array keys which are an EMPTY STRING are left as-is
27
+	 *
28
+	 * @param array $input_settings
29
+	 */
30
+	public function __construct($answer_options, $input_settings = array())
31
+	{
32
+		parent::__construct($answer_options, $input_settings);
33
+	}
34 34
 
35
-    /**
36
-     * Gets all the sibling sections controlled by this reveal select input
37
-     * @return \EE_Form_Section_Base[] keys are their form section paths
38
-     */
39
-    public function sibling_sections_controlled()
40
-    {
41
-        $sibling_sections = array();
42
-        foreach ($this->options() as $sibling_section_name => $sibling_section) {
43
-            // if it's an empty string just leave it alone
44
-            if (empty($sibling_section_name)) {
45
-                continue;
46
-            }
47
-            $sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
-            if (
49
-                $sibling_section instanceof EE_Form_Section_Base
50
-                && ! empty($sibling_section_name)
51
-            ) {
52
-                $sibling_sections[ $sibling_section_name ] = $sibling_section;
53
-            }
54
-        }
55
-        return $sibling_sections;
56
-    }
35
+	/**
36
+	 * Gets all the sibling sections controlled by this reveal select input
37
+	 * @return \EE_Form_Section_Base[] keys are their form section paths
38
+	 */
39
+	public function sibling_sections_controlled()
40
+	{
41
+		$sibling_sections = array();
42
+		foreach ($this->options() as $sibling_section_name => $sibling_section) {
43
+			// if it's an empty string just leave it alone
44
+			if (empty($sibling_section_name)) {
45
+				continue;
46
+			}
47
+			$sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
+			if (
49
+				$sibling_section instanceof EE_Form_Section_Base
50
+				&& ! empty($sibling_section_name)
51
+			) {
52
+				$sibling_sections[ $sibling_section_name ] = $sibling_section;
53
+			}
54
+		}
55
+		return $sibling_sections;
56
+	}
57 57
 
58
-    /**
59
-     * Adds an entry of 'select_reveal_inputs' to the js data, which is an array
60
-     * whose top-level keys are select reveal input html ids; values are arrays
61
-     * whose keys are select option values and values are the sections they reveal
62
-     * @param array $form_other_js_data
63
-     * @return array
64
-     */
65
-    public function get_other_js_data($form_other_js_data = array())
66
-    {
67
-        $form_other_js_data = parent::get_other_js_data($form_other_js_data);
68
-        if (! isset($form_other_js_data['select_reveal_inputs'])) {
69
-            $form_other_js_data['select_reveal_inputs'] = array();
70
-        }
71
-        $sibling_input_to_html_id_map = array();
72
-        foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
73
-            $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
74
-        }
75
-        $form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
76
-        return $form_other_js_data;
77
-    }
58
+	/**
59
+	 * Adds an entry of 'select_reveal_inputs' to the js data, which is an array
60
+	 * whose top-level keys are select reveal input html ids; values are arrays
61
+	 * whose keys are select option values and values are the sections they reveal
62
+	 * @param array $form_other_js_data
63
+	 * @return array
64
+	 */
65
+	public function get_other_js_data($form_other_js_data = array())
66
+	{
67
+		$form_other_js_data = parent::get_other_js_data($form_other_js_data);
68
+		if (! isset($form_other_js_data['select_reveal_inputs'])) {
69
+			$form_other_js_data['select_reveal_inputs'] = array();
70
+		}
71
+		$sibling_input_to_html_id_map = array();
72
+		foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
73
+			$sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
74
+		}
75
+		$form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
76
+		return $form_other_js_data;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Form_Input_With_Options_Base.input.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $all_ints = true;
116 116
             array_walk_recursive(
117 117
                 $this->_options,
118
-                function ($value, $key) use (&$all_ints) {
118
+                function($value, $key) use (&$all_ints) {
119 119
                     // is this a top-level key? ignore it
120 120
                     if (
121 121
                         ! is_array($value)
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
         if (EEH_Array::is_multi_dimensional_array($arr)) {
178 178
             foreach ($arr as $sub_array) {
179 179
                 foreach ((array) $sub_array as $key => $value) {
180
-                    $flat_array[ $key ] = $value;
180
+                    $flat_array[$key] = $value;
181 181
                     $this->_set_label_size($value);
182 182
                 }
183 183
             }
184 184
         } else {
185 185
             foreach ($arr as $key => $value) {
186
-                $flat_array[ $key ] = $value;
186
+                $flat_array[$key] = $value;
187 187
                 $this->_set_label_size($value);
188 188
             }
189 189
         }
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
                 $desc = '';
205 205
                 if ($this->_use_desc_in_label) {
206 206
                     $desc = $question_option->desc();
207
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
207
+                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : '';
208 208
                 }
209 209
                 $value = $question_option->value();
210 210
                 // add value even if it's empty
211
-                $flat_array[ $value ] = $value;
211
+                $flat_array[$value] = $value;
212 212
                 // if both value and desc are not empty, then separate with a dash
213
-                if (! empty($value) && ! empty($desc)) {
214
-                    $flat_array[ $value ] .= ' - ' . $desc;
213
+                if ( ! empty($value) && ! empty($desc)) {
214
+                    $flat_array[$value] .= ' - '.$desc;
215 215
                 } else {
216 216
                     // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
217
-                    $flat_array[ $value ] .= $desc;
217
+                    $flat_array[$value] .= $desc;
218 218
                 }
219 219
             } elseif (is_array($question_option)) {
220 220
                 $flat_array += $this->_flatten_select_options($question_option);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public function set_label_sizes()
234 234
     {
235 235
         // did the input settings specifically say to NOT set the label size dynamically ?
236
-        if (! $this->_enforce_label_size) {
236
+        if ( ! $this->_enforce_label_size) {
237 237
             foreach ($this->_options as $option) {
238 238
                 // calculate the strlen of the label
239 239
                 $this->_set_label_size($option);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     private function _set_label_size($value = '')
253 253
     {
254 254
         // don't change label size if it has already been set and is being enforced
255
-        if ($this->_enforce_label_size && $this->_label_size >  0) {
255
+        if ($this->_enforce_label_size && $this->_label_size > 0) {
256 256
             return;
257 257
         }
258 258
         // determine length of option value
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
     {
300 300
         $options = $this->flat_options();
301 301
         $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
302
-        if (! $this->_multiple_selections) {
302
+        if ( ! $this->_multiple_selections) {
303 303
             $unnormalized_value_choices = array($unnormalized_value_choices);
304 304
         }
305 305
         $pretty_strings = array();
306 306
         foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
307
-            if (isset($options[ $unnormalized_value_choice ])) {
308
-                $pretty_strings[] = $options[ $unnormalized_value_choice ];
307
+            if (isset($options[$unnormalized_value_choice])) {
308
+                $pretty_strings[] = $options[$unnormalized_value_choice];
309 309
             } else {
310 310
                 $pretty_strings[] = $this->normalized_value();
311 311
             }
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -11,324 +11,324 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base
13 13
 {
14
-    /**
15
-     * array of available options to choose as an answer
16
-     *
17
-     * @var array
18
-     */
19
-    protected $_options = array();
20
-
21
-    /**
22
-     * whether to display the html_label_text above the checkbox/radio button options
23
-     *
24
-     * @var boolean
25
-     */
26
-    protected $_display_html_label_text = true;
27
-
28
-    /**
29
-     * whether to display an question option description as part of the input label
30
-     *
31
-     * @var boolean
32
-     */
33
-    protected $_use_desc_in_label = true;
34
-
35
-    /**
36
-     * strlen() result for the longest input value (what gets displayed in the label)
37
-     * this is used to apply a css class to the input label
38
-     *
39
-     * @var int
40
-     */
41
-    protected $_label_size = 0;
42
-
43
-    /**
44
-     * whether to enforce the label size value passed in the constructor
45
-     *
46
-     * @var boolean
47
-     */
48
-    protected $_enforce_label_size = false;
49
-
50
-    /**
51
-     * whether to allow multiple selections (ie, the value of this input should be an array)
52
-     * or not (ie, the value should be a simple int, string, etc)
53
-     *
54
-     * @var boolean
55
-     */
56
-    protected $_multiple_selections = false;
57
-
58
-
59
-
60
-    /**
61
-     * @param array     $answer_options
62
-     * @param array     $input_settings {
63
-     * @type int|string $label_size
64
-     * @type boolean    $display_html_label_text
65
-     *                                  }
66
-     *                                  And all the options accepted by EE_Form_Input_Base
67
-     */
68
-    public function __construct($answer_options = array(), $input_settings = array())
69
-    {
70
-        if (isset($input_settings['label_size'])) {
71
-            $this->_set_label_size($input_settings['label_size']);
72
-            if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
73
-                $this->_enforce_label_size = true;
74
-            }
75
-        }
76
-        if (isset($input_settings['display_html_label_text'])) {
77
-            $this->set_display_html_label_text($input_settings['display_html_label_text']);
78
-        }
79
-        $this->set_select_options($answer_options);
80
-        parent::__construct($input_settings);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     * Sets the allowed options for this input. Also has the side-effect of
87
-     * updating the normalization strategy to match the keys provided in the array
88
-     *
89
-     * @param array $answer_options
90
-     * @return void  just has the side-effect of setting the options for this input
91
-     */
92
-    public function set_select_options($answer_options = array())
93
-    {
94
-        $answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
95
-        // get the first item in the select options and check it's type
96
-        $this->_options = reset($answer_options) instanceof EE_Question_Option
97
-            ? $this->_process_question_options($answer_options)
98
-            : $answer_options;
99
-        // d( $this->_options );
100
-        $select_option_keys = array_keys($this->_options);
101
-        // attempt to determine data type for values in order to set normalization type
102
-        // purposefully only
103
-        if (
104
-            count($this->_options) === 2
105
-            && (
106
-                (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
107
-                || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
108
-            )
109
-        ) {
110
-            // values appear to be boolean, like TRUE, FALSE, 1, 0
111
-            $normalization = new EE_Boolean_Normalization();
112
-        } else {
113
-            // are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
114
-            $all_ints = true;
115
-            array_walk_recursive(
116
-                $this->_options,
117
-                function ($value, $key) use (&$all_ints) {
118
-                    // is this a top-level key? ignore it
119
-                    if (
120
-                        ! is_array($value)
121
-                        && ! is_int($key)
122
-                        && $key !== ''
123
-                        && $key !== null
124
-                    ) {
125
-                        $all_ints = false;
126
-                    }
127
-                }
128
-            );
129
-            if ($all_ints) {
130
-                $normalization = new EE_Int_Normalization();
131
-            } else {
132
-                $normalization = new EE_Text_Normalization();
133
-            }
134
-        }
135
-        // does input type have multiple options ?
136
-        if ($this->_multiple_selections) {
137
-            $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
138
-        } else {
139
-            $this->_set_normalization_strategy($normalization);
140
-        }
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * @return array
147
-     */
148
-    public function options()
149
-    {
150
-        return $this->_options;
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * Returns an array which is guaranteed to not be multidimensional
157
-     *
158
-     * @return array
159
-     */
160
-    public function flat_options()
161
-    {
162
-        return $this->_flatten_select_options($this->options());
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Makes sure $arr is a flat array, not a multidimensional one
169
-     *
170
-     * @param array $arr
171
-     * @return array
172
-     */
173
-    protected function _flatten_select_options($arr)
174
-    {
175
-        $flat_array = array();
176
-        if (EEH_Array::is_multi_dimensional_array($arr)) {
177
-            foreach ($arr as $sub_array) {
178
-                foreach ((array) $sub_array as $key => $value) {
179
-                    $flat_array[ $key ] = $value;
180
-                    $this->_set_label_size($value);
181
-                }
182
-            }
183
-        } else {
184
-            foreach ($arr as $key => $value) {
185
-                $flat_array[ $key ] = $value;
186
-                $this->_set_label_size($value);
187
-            }
188
-        }
189
-        return $flat_array;
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * @param EE_Question_Option[] $question_options_array
196
-     * @return array
197
-     */
198
-    protected function _process_question_options($question_options_array = array())
199
-    {
200
-        $flat_array = array();
201
-        foreach ($question_options_array as $question_option) {
202
-            if ($question_option instanceof EE_Question_Option) {
203
-                $desc = '';
204
-                if ($this->_use_desc_in_label) {
205
-                    $desc = $question_option->desc();
206
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
207
-                }
208
-                $value = $question_option->value();
209
-                // add value even if it's empty
210
-                $flat_array[ $value ] = $value;
211
-                // if both value and desc are not empty, then separate with a dash
212
-                if (! empty($value) && ! empty($desc)) {
213
-                    $flat_array[ $value ] .= ' - ' . $desc;
214
-                } else {
215
-                    // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
216
-                    $flat_array[ $value ] .= $desc;
217
-                }
218
-            } elseif (is_array($question_option)) {
219
-                $flat_array += $this->_flatten_select_options($question_option);
220
-            }
221
-        }
222
-        return $flat_array;
223
-    }
224
-
225
-
226
-
227
-    /**
228
-     *    set_label_sizes
229
-     *
230
-     * @return void
231
-     */
232
-    public function set_label_sizes()
233
-    {
234
-        // did the input settings specifically say to NOT set the label size dynamically ?
235
-        if (! $this->_enforce_label_size) {
236
-            foreach ($this->_options as $option) {
237
-                // calculate the strlen of the label
238
-                $this->_set_label_size($option);
239
-            }
240
-        }
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     *    _set_label_size_class
247
-     *
248
-     * @param int|string $value
249
-     * @return void
250
-     */
251
-    private function _set_label_size($value = '')
252
-    {
253
-        // don't change label size if it has already been set and is being enforced
254
-        if ($this->_enforce_label_size && $this->_label_size >  0) {
255
-            return;
256
-        }
257
-        // determine length of option value
258
-        $val_size = is_int($value) ? $value : strlen($value);
259
-        // use new value if bigger than existing
260
-        $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     *    get_label_size_class
267
-     *
268
-     * @return string
269
-     */
270
-    public function get_label_size_class()
271
-    {
272
-        $size = ' medium-lbl';
273
-        // use maximum option value length to determine label size
274
-        if ($this->_label_size < 3) {
275
-            $size = ' nano-lbl';
276
-        } elseif ($this->_label_size < 6) {
277
-            $size = ' micro-lbl';
278
-        } elseif ($this->_label_size < 12) {
279
-            $size = ' tiny-lbl';
280
-        } elseif ($this->_label_size < 25) {
281
-            $size = ' small-lbl';
282
-        } elseif ($this->_label_size < 50) {
283
-            $size = ' medium-lbl';
284
-        } elseif ($this->_label_size >= 100) {
285
-            $size = ' big-lbl';
286
-        }
287
-        return $size;
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * Returns the pretty value for the normalized value
294
-     *
295
-     * @return string
296
-     */
297
-    public function pretty_value()
298
-    {
299
-        $options = $this->flat_options();
300
-        $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
301
-        if (! $this->_multiple_selections) {
302
-            $unnormalized_value_choices = array($unnormalized_value_choices);
303
-        }
304
-        $pretty_strings = array();
305
-        foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
306
-            if (isset($options[ $unnormalized_value_choice ])) {
307
-                $pretty_strings[] = $options[ $unnormalized_value_choice ];
308
-            } else {
309
-                $pretty_strings[] = $this->normalized_value();
310
-            }
311
-        }
312
-        return implode(', ', $pretty_strings);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     * @return boolean
319
-     */
320
-    public function display_html_label_text()
321
-    {
322
-        return $this->_display_html_label_text;
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * @param boolean $display_html_label_text
329
-     */
330
-    public function set_display_html_label_text($display_html_label_text)
331
-    {
332
-        $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
333
-    }
14
+	/**
15
+	 * array of available options to choose as an answer
16
+	 *
17
+	 * @var array
18
+	 */
19
+	protected $_options = array();
20
+
21
+	/**
22
+	 * whether to display the html_label_text above the checkbox/radio button options
23
+	 *
24
+	 * @var boolean
25
+	 */
26
+	protected $_display_html_label_text = true;
27
+
28
+	/**
29
+	 * whether to display an question option description as part of the input label
30
+	 *
31
+	 * @var boolean
32
+	 */
33
+	protected $_use_desc_in_label = true;
34
+
35
+	/**
36
+	 * strlen() result for the longest input value (what gets displayed in the label)
37
+	 * this is used to apply a css class to the input label
38
+	 *
39
+	 * @var int
40
+	 */
41
+	protected $_label_size = 0;
42
+
43
+	/**
44
+	 * whether to enforce the label size value passed in the constructor
45
+	 *
46
+	 * @var boolean
47
+	 */
48
+	protected $_enforce_label_size = false;
49
+
50
+	/**
51
+	 * whether to allow multiple selections (ie, the value of this input should be an array)
52
+	 * or not (ie, the value should be a simple int, string, etc)
53
+	 *
54
+	 * @var boolean
55
+	 */
56
+	protected $_multiple_selections = false;
57
+
58
+
59
+
60
+	/**
61
+	 * @param array     $answer_options
62
+	 * @param array     $input_settings {
63
+	 * @type int|string $label_size
64
+	 * @type boolean    $display_html_label_text
65
+	 *                                  }
66
+	 *                                  And all the options accepted by EE_Form_Input_Base
67
+	 */
68
+	public function __construct($answer_options = array(), $input_settings = array())
69
+	{
70
+		if (isset($input_settings['label_size'])) {
71
+			$this->_set_label_size($input_settings['label_size']);
72
+			if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
73
+				$this->_enforce_label_size = true;
74
+			}
75
+		}
76
+		if (isset($input_settings['display_html_label_text'])) {
77
+			$this->set_display_html_label_text($input_settings['display_html_label_text']);
78
+		}
79
+		$this->set_select_options($answer_options);
80
+		parent::__construct($input_settings);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 * Sets the allowed options for this input. Also has the side-effect of
87
+	 * updating the normalization strategy to match the keys provided in the array
88
+	 *
89
+	 * @param array $answer_options
90
+	 * @return void  just has the side-effect of setting the options for this input
91
+	 */
92
+	public function set_select_options($answer_options = array())
93
+	{
94
+		$answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
95
+		// get the first item in the select options and check it's type
96
+		$this->_options = reset($answer_options) instanceof EE_Question_Option
97
+			? $this->_process_question_options($answer_options)
98
+			: $answer_options;
99
+		// d( $this->_options );
100
+		$select_option_keys = array_keys($this->_options);
101
+		// attempt to determine data type for values in order to set normalization type
102
+		// purposefully only
103
+		if (
104
+			count($this->_options) === 2
105
+			&& (
106
+				(in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
107
+				|| (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
108
+			)
109
+		) {
110
+			// values appear to be boolean, like TRUE, FALSE, 1, 0
111
+			$normalization = new EE_Boolean_Normalization();
112
+		} else {
113
+			// are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
114
+			$all_ints = true;
115
+			array_walk_recursive(
116
+				$this->_options,
117
+				function ($value, $key) use (&$all_ints) {
118
+					// is this a top-level key? ignore it
119
+					if (
120
+						! is_array($value)
121
+						&& ! is_int($key)
122
+						&& $key !== ''
123
+						&& $key !== null
124
+					) {
125
+						$all_ints = false;
126
+					}
127
+				}
128
+			);
129
+			if ($all_ints) {
130
+				$normalization = new EE_Int_Normalization();
131
+			} else {
132
+				$normalization = new EE_Text_Normalization();
133
+			}
134
+		}
135
+		// does input type have multiple options ?
136
+		if ($this->_multiple_selections) {
137
+			$this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
138
+		} else {
139
+			$this->_set_normalization_strategy($normalization);
140
+		}
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * @return array
147
+	 */
148
+	public function options()
149
+	{
150
+		return $this->_options;
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * Returns an array which is guaranteed to not be multidimensional
157
+	 *
158
+	 * @return array
159
+	 */
160
+	public function flat_options()
161
+	{
162
+		return $this->_flatten_select_options($this->options());
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Makes sure $arr is a flat array, not a multidimensional one
169
+	 *
170
+	 * @param array $arr
171
+	 * @return array
172
+	 */
173
+	protected function _flatten_select_options($arr)
174
+	{
175
+		$flat_array = array();
176
+		if (EEH_Array::is_multi_dimensional_array($arr)) {
177
+			foreach ($arr as $sub_array) {
178
+				foreach ((array) $sub_array as $key => $value) {
179
+					$flat_array[ $key ] = $value;
180
+					$this->_set_label_size($value);
181
+				}
182
+			}
183
+		} else {
184
+			foreach ($arr as $key => $value) {
185
+				$flat_array[ $key ] = $value;
186
+				$this->_set_label_size($value);
187
+			}
188
+		}
189
+		return $flat_array;
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * @param EE_Question_Option[] $question_options_array
196
+	 * @return array
197
+	 */
198
+	protected function _process_question_options($question_options_array = array())
199
+	{
200
+		$flat_array = array();
201
+		foreach ($question_options_array as $question_option) {
202
+			if ($question_option instanceof EE_Question_Option) {
203
+				$desc = '';
204
+				if ($this->_use_desc_in_label) {
205
+					$desc = $question_option->desc();
206
+					$desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
207
+				}
208
+				$value = $question_option->value();
209
+				// add value even if it's empty
210
+				$flat_array[ $value ] = $value;
211
+				// if both value and desc are not empty, then separate with a dash
212
+				if (! empty($value) && ! empty($desc)) {
213
+					$flat_array[ $value ] .= ' - ' . $desc;
214
+				} else {
215
+					// otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
216
+					$flat_array[ $value ] .= $desc;
217
+				}
218
+			} elseif (is_array($question_option)) {
219
+				$flat_array += $this->_flatten_select_options($question_option);
220
+			}
221
+		}
222
+		return $flat_array;
223
+	}
224
+
225
+
226
+
227
+	/**
228
+	 *    set_label_sizes
229
+	 *
230
+	 * @return void
231
+	 */
232
+	public function set_label_sizes()
233
+	{
234
+		// did the input settings specifically say to NOT set the label size dynamically ?
235
+		if (! $this->_enforce_label_size) {
236
+			foreach ($this->_options as $option) {
237
+				// calculate the strlen of the label
238
+				$this->_set_label_size($option);
239
+			}
240
+		}
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 *    _set_label_size_class
247
+	 *
248
+	 * @param int|string $value
249
+	 * @return void
250
+	 */
251
+	private function _set_label_size($value = '')
252
+	{
253
+		// don't change label size if it has already been set and is being enforced
254
+		if ($this->_enforce_label_size && $this->_label_size >  0) {
255
+			return;
256
+		}
257
+		// determine length of option value
258
+		$val_size = is_int($value) ? $value : strlen($value);
259
+		// use new value if bigger than existing
260
+		$this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 *    get_label_size_class
267
+	 *
268
+	 * @return string
269
+	 */
270
+	public function get_label_size_class()
271
+	{
272
+		$size = ' medium-lbl';
273
+		// use maximum option value length to determine label size
274
+		if ($this->_label_size < 3) {
275
+			$size = ' nano-lbl';
276
+		} elseif ($this->_label_size < 6) {
277
+			$size = ' micro-lbl';
278
+		} elseif ($this->_label_size < 12) {
279
+			$size = ' tiny-lbl';
280
+		} elseif ($this->_label_size < 25) {
281
+			$size = ' small-lbl';
282
+		} elseif ($this->_label_size < 50) {
283
+			$size = ' medium-lbl';
284
+		} elseif ($this->_label_size >= 100) {
285
+			$size = ' big-lbl';
286
+		}
287
+		return $size;
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * Returns the pretty value for the normalized value
294
+	 *
295
+	 * @return string
296
+	 */
297
+	public function pretty_value()
298
+	{
299
+		$options = $this->flat_options();
300
+		$unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
301
+		if (! $this->_multiple_selections) {
302
+			$unnormalized_value_choices = array($unnormalized_value_choices);
303
+		}
304
+		$pretty_strings = array();
305
+		foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
306
+			if (isset($options[ $unnormalized_value_choice ])) {
307
+				$pretty_strings[] = $options[ $unnormalized_value_choice ];
308
+			} else {
309
+				$pretty_strings[] = $this->normalized_value();
310
+			}
311
+		}
312
+		return implode(', ', $pretty_strings);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 * @return boolean
319
+	 */
320
+	public function display_html_label_text()
321
+	{
322
+		return $this->_display_html_label_text;
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * @param boolean $display_html_label_text
329
+	 */
330
+	public function set_display_html_label_text($display_html_label_text)
331
+	{
332
+		$this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
333
+	}
334 334
 }
Please login to merge, or discard this patch.
sensitive_data_removal/EE_CCV_Sensitive_Data_Removal.strategy.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class EE_CCV_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        // Get the ccv Length
17
-        $ccv_lenght = strlen($normalized_value);
18
-        // Replace all characters of credit card except the last four and dashes
19
-        for ($i = 0; $i < $ccv_lenght; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
21
-                continue;
22
-            }
23
-            $normalized_value[ $i ] = 'X';
24
-        }
25
-        // Return the masked Credit Card #
26
-        return $normalized_value;
27
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		// Get the ccv Length
17
+		$ccv_lenght = strlen($normalized_value);
18
+		// Replace all characters of credit card except the last four and dashes
19
+		for ($i = 0; $i < $ccv_lenght; $i++) {
20
+			if ($normalized_value[ $i ] == '-') {
21
+				continue;
22
+			}
23
+			$normalized_value[ $i ] = 'X';
24
+		}
25
+		// Return the masked Credit Card #
26
+		return $normalized_value;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@
 block discarded – undo
17 17
         $ccv_lenght = strlen($normalized_value);
18 18
         // Replace all characters of credit card except the last four and dashes
19 19
         for ($i = 0; $i < $ccv_lenght; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
20
+            if ($normalized_value[$i] == '-') {
21 21
                 continue;
22 22
             }
23
-            $normalized_value[ $i ] = 'X';
23
+            $normalized_value[$i] = 'X';
24 24
         }
25 25
         // Return the masked Credit Card #
26 26
         return $normalized_value;
Please login to merge, or discard this patch.
sensitive_data_removal/EE_Credit_Card_Sensitive_Data_Removal.strategy.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Credit_Card_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        // Get the cc Length
17
-        $cc_length = strlen($normalized_value);
18
-        // Replace all characters of credit card except the last four and dashes
19
-        for ($i = 0; $i < $cc_length - 4; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
21
-                continue;
22
-            }
23
-            $normalized_value[ $i ] = 'X';
24
-        }
25
-        // Return the masked Credit Card #
26
-        return $normalized_value;
27
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		// Get the cc Length
17
+		$cc_length = strlen($normalized_value);
18
+		// Replace all characters of credit card except the last four and dashes
19
+		for ($i = 0; $i < $cc_length - 4; $i++) {
20
+			if ($normalized_value[ $i ] == '-') {
21
+				continue;
22
+			}
23
+			$normalized_value[ $i ] = 'X';
24
+		}
25
+		// Return the masked Credit Card #
26
+		return $normalized_value;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@
 block discarded – undo
17 17
         $cc_length = strlen($normalized_value);
18 18
         // Replace all characters of credit card except the last four and dashes
19 19
         for ($i = 0; $i < $cc_length - 4; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
20
+            if ($normalized_value[$i] == '-') {
21 21
                 continue;
22 22
             }
23
-            $normalized_value[ $i ] = 'X';
23
+            $normalized_value[$i] = 'X';
24 24
         }
25 25
         // Return the masked Credit Card #
26 26
         return $normalized_value;
Please login to merge, or discard this patch.
strategies/validation/EE_Max_Length_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     public function get_jquery_validation_rule_array()
45 45
     {
46 46
         if ($this->_max_length !== EE_INF) {
47
-            return array( 'maxlength' => $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
47
+            return array('maxlength' => $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message()));
48 48
         } else {
49 49
             return array();
50 50
         }
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,41 +11,41 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14
-    protected $_max_length;
14
+	protected $_max_length;
15 15
 
16
-    public function __construct($validation_error_message = null, $max_length = EE_INF)
17
-    {
18
-        $this->_max_length = $max_length;
19
-        if ($validation_error_message === null) {
20
-            $validation_error_message = sprintf(esc_html__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
21
-        }
22
-        parent::__construct($validation_error_message);
23
-    }
16
+	public function __construct($validation_error_message = null, $max_length = EE_INF)
17
+	{
18
+		$this->_max_length = $max_length;
19
+		if ($validation_error_message === null) {
20
+			$validation_error_message = sprintf(esc_html__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
21
+		}
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25
-    /**
26
-     * @param $normalized_value
27
-     */
28
-    public function validate($normalized_value)
29
-    {
30
-        if (
31
-            $this->_max_length !== EE_INF &&
32
-                $normalized_value &&
33
-                is_string($normalized_value) &&
34
-                 strlen($normalized_value) > $this->_max_length
35
-        ) {
36
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
37
-        }
38
-    }
25
+	/**
26
+	 * @param $normalized_value
27
+	 */
28
+	public function validate($normalized_value)
29
+	{
30
+		if (
31
+			$this->_max_length !== EE_INF &&
32
+				$normalized_value &&
33
+				is_string($normalized_value) &&
34
+				 strlen($normalized_value) > $this->_max_length
35
+		) {
36
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
37
+		}
38
+	}
39 39
 
40
-    /**
41
-     * @return array
42
-     */
43
-    public function get_jquery_validation_rule_array()
44
-    {
45
-        if ($this->_max_length !== EE_INF) {
46
-            return array( 'maxlength' => $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
47
-        } else {
48
-            return array();
49
-        }
50
-    }
40
+	/**
41
+	 * @return array
42
+	 */
43
+	public function get_jquery_validation_rule_array()
44
+	{
45
+		if ($this->_max_length !== EE_INF) {
46
+			return array( 'maxlength' => $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
47
+		} else {
48
+			return array();
49
+		}
50
+	}
51 51
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Min_Length_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,6 +40,6 @@
 block discarded – undo
40 40
      */
41 41
     public function get_jquery_validation_rule_array()
42 42
     {
43
-        return array( 'minlength' => $this->_min_length, 'messages' => array( 'minlength' => $this->get_validation_error_message() ) );
43
+        return array('minlength' => $this->_min_length, 'messages' => array('minlength' => $this->get_validation_error_message()));
44 44
     }
45 45
 }
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,34 +11,34 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Min_Length_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14
-    protected $_min_length;
14
+	protected $_min_length;
15 15
 
16
-    public function __construct($validation_error_message = null, $min_length = 0)
17
-    {
18
-        $this->_min_length = $min_length;
19
-        parent::__construct($validation_error_message);
20
-    }
16
+	public function __construct($validation_error_message = null, $min_length = 0)
17
+	{
18
+		$this->_min_length = $min_length;
19
+		parent::__construct($validation_error_message);
20
+	}
21 21
 
22
-    /**
23
-     * @param $normalized_value
24
-     */
25
-    public function validate($normalized_value)
26
-    {
27
-        if (
28
-            $this->_min_length > 0 &&
29
-                $normalized_value &&
30
-                is_string($normalized_value) &&
31
-                strlen($normalized_value) < $this->_min_length
32
-        ) {
33
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'minlength');
34
-        }
35
-    }
22
+	/**
23
+	 * @param $normalized_value
24
+	 */
25
+	public function validate($normalized_value)
26
+	{
27
+		if (
28
+			$this->_min_length > 0 &&
29
+				$normalized_value &&
30
+				is_string($normalized_value) &&
31
+				strlen($normalized_value) < $this->_min_length
32
+		) {
33
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'minlength');
34
+		}
35
+	}
36 36
 
37
-    /**
38
-     * @return array
39
-     */
40
-    public function get_jquery_validation_rule_array()
41
-    {
42
-        return array( 'minlength' => $this->_min_length, 'messages' => array( 'minlength' => $this->get_validation_error_message() ) );
43
-    }
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function get_jquery_validation_rule_array()
41
+	{
42
+		return array( 'minlength' => $this->_min_length, 'messages' => array( 'minlength' => $this->get_validation_error_message() ) );
43
+	}
44 44
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Text_Validation_Strategy.strategy.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
     public function validate($normalized_value)
30 30
     {
31 31
         $string_normalized_value = (string) $normalized_value;
32
-        if ($this->_regex &&  $string_normalized_value) {
33
-            if (! preg_match($this->_regex, $string_normalized_value)) {
32
+        if ($this->_regex && $string_normalized_value) {
33
+            if ( ! preg_match($this->_regex, $string_normalized_value)) {
34 34
                 throw new EE_Validation_Error($this->get_validation_error_message(), 'regex');
35 35
             }
36 36
         }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function get_jquery_validation_rule_array()
43 43
     {
44 44
         if ($this->_regex !== null) {
45
-            return array( 'regex' => $this->regex_js(), 'messages' => array( 'regex' => $this->get_validation_error_message() ) );
45
+            return array('regex' => $this->regex_js(), 'messages' => array('regex' => $this->get_validation_error_message()));
46 46
         } else {
47 47
             return array();
48 48
         }
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -10,53 +10,53 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Text_Validation_Strategy extends EE_Validation_Strategy_Base
12 12
 {
13
-    protected $_regex = null;
14
-    /**
15
-     *
16
-     * @param string $validation_error_message
17
-     * @param string $regex a PHP regex; the javascript regex will be derived from this
18
-     */
19
-    public function __construct($validation_error_message = null, $regex = null)
20
-    {
21
-        $this->_regex = $regex;
22
-        parent::__construct($validation_error_message);
23
-    }
13
+	protected $_regex = null;
14
+	/**
15
+	 *
16
+	 * @param string $validation_error_message
17
+	 * @param string $regex a PHP regex; the javascript regex will be derived from this
18
+	 */
19
+	public function __construct($validation_error_message = null, $regex = null)
20
+	{
21
+		$this->_regex = $regex;
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25
-    /**
26
-     * @param $normalized_value
27
-     */
28
-    public function validate($normalized_value)
29
-    {
30
-        $string_normalized_value = (string) $normalized_value;
31
-        if ($this->_regex &&  $string_normalized_value) {
32
-            if (! preg_match($this->_regex, $string_normalized_value)) {
33
-                throw new EE_Validation_Error($this->get_validation_error_message(), 'regex');
34
-            }
35
-        }
36
-    }
25
+	/**
26
+	 * @param $normalized_value
27
+	 */
28
+	public function validate($normalized_value)
29
+	{
30
+		$string_normalized_value = (string) $normalized_value;
31
+		if ($this->_regex &&  $string_normalized_value) {
32
+			if (! preg_match($this->_regex, $string_normalized_value)) {
33
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'regex');
34
+			}
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @return array
40
-     */
41
-    public function get_jquery_validation_rule_array()
42
-    {
43
-        if ($this->_regex !== null) {
44
-            return array( 'regex' => $this->regex_js(), 'messages' => array( 'regex' => $this->get_validation_error_message() ) );
45
-        } else {
46
-            return array();
47
-        }
48
-    }
38
+	/**
39
+	 * @return array
40
+	 */
41
+	public function get_jquery_validation_rule_array()
42
+	{
43
+		if ($this->_regex !== null) {
44
+			return array( 'regex' => $this->regex_js(), 'messages' => array( 'regex' => $this->get_validation_error_message() ) );
45
+		} else {
46
+			return array();
47
+		}
48
+	}
49 49
 
50 50
 /**
51 51
  * Translates a PHP regex into a javscript regex (eg, PHP needs separate delimieters, whereas
52 52
  * javscript does not
53 53
  * @return string
54 54
  */
55
-    public function regex_js()
56
-    {
57
-        // first character must be the delimiter
58
-        $delimeter = $this->_regex[0];
59
-        $last_occurence_of_delimieter = strrpos($this->_regex, $delimeter);
60
-        return substr($this->_regex, 1, $last_occurence_of_delimieter - 1);
61
-    }
55
+	public function regex_js()
56
+	{
57
+		// first character must be the delimiter
58
+		$delimeter = $this->_regex[0];
59
+		$last_occurence_of_delimieter = strrpos($this->_regex, $delimeter);
60
+		return substr($this->_regex, 1, $last_occurence_of_delimieter - 1);
61
+	}
62 62
 }
Please login to merge, or discard this patch.