Completed
Branch barista (01af75)
by
unknown
60:31 queued 51:15
created
Paypal_Pro/help_tabs/payment_methods_overview_paypalpro.help_tab.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 <p><?php esc_html_e('Adjust the settings for the PayPal Pro payment gateway.', 'event_espresso'); ?></p>
3 3
 <p>
4 4
     <?php
5
-    printf(
6
-        esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'),
7
-        "<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>",
8
-        "</a>"
9
-    );
10
-    ?>
5
+	printf(
6
+		esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'),
7
+		"<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>",
8
+		"</a>"
9
+	);
10
+	?>
11 11
 </p>
12 12
 <p><strong><?php esc_html_e('PayPal Pro Settings', 'event_espresso'); ?></strong></p>
13 13
 <ul>
@@ -18,48 +18,48 @@  discard block
 block discarded – undo
18 18
     <li>
19 19
         <strong><?php esc_html_e('PayPal API Username', 'event_espresso'); ?></strong><br/>
20 20
         <?php
21
-        printf(
22
-            esc_html__(
23
-                'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.',
24
-                'event_espresso'
25
-            ),
26
-            '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
27
-            '</a>'
28
-        );
29
-        ?>
21
+		printf(
22
+			esc_html__(
23
+				'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.',
24
+				'event_espresso'
25
+			),
26
+			'<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
27
+			'</a>'
28
+		);
29
+		?>
30 30
     </li>
31 31
     <li>
32 32
         <strong><?php esc_html_e('PayPal API Password', 'event_espresso'); ?></strong><br/>
33 33
         <?php
34
-        printf(
35
-            esc_html__(
36
-                'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.',
37
-                'event_espresso'
38
-            ),
39
-            '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
40
-            '</a>'
41
-        );
42
-        ?>
34
+		printf(
35
+			esc_html__(
36
+				'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.',
37
+				'event_espresso'
38
+			),
39
+			'<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
40
+			'</a>'
41
+		);
42
+		?>
43 43
     </li>
44 44
     <li>
45 45
         <strong><?php esc_html_e('PayPal API Signature', 'event_espresso'); ?></strong><br/>
46 46
         <?php
47
-        printf(
48
-            esc_html__(
49
-                'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.',
50
-                'event_espresso'
51
-            ),
52
-            '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
53
-            '</a>'
54
-        );
55
-        ?>
47
+		printf(
48
+			esc_html__(
49
+				'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.',
50
+				'event_espresso'
51
+			),
52
+			'<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
53
+			'</a>'
54
+		);
55
+		?>
56 56
     </li>
57 57
     <li>
58 58
         <strong><?php esc_html_e('Country Currency', 'event_espresso'); ?></strong><br/>
59 59
         <?php esc_html_e(
60
-            'Select the currency for your country. Payments will be accepted in this currency.',
61
-            'event_espresso'
62
-        ); ?>
60
+			'Select the currency for your country. Payments will be accepted in this currency.',
61
+			'event_espresso'
62
+		); ?>
63 63
     </li>
64 64
     <li>
65 65
         <strong><?php esc_html_e('Accepted Card Types', 'event_espresso'); ?></strong><br/>
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
     <li>
69 69
         <strong><?php esc_html_e('Use the Debugging Feature and the PayPal Sandbox', 'event_espresso'); ?></strong><br/>
70 70
         <?php esc_html_e(
71
-            'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.',
72
-            'event_espresso'
73
-        ); ?>
71
+			'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.',
72
+			'event_espresso'
73
+		); ?>
74 74
     </li>
75 75
     <li>
76 76
         <strong><?php esc_html_e('Button Image URL', 'event_espresso'); ?></strong><br/>
Please login to merge, or discard this patch.
payment_methods/Aim/help_tabs/payment_methods_overview_aim.help_tab.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -4,82 +4,82 @@
 block discarded – undo
4 4
 </p>
5 5
 <p>
6 6
     <?php
7
-    printf(
8
-        esc_html__(
9
-            'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.',
10
-            'event_espresso'
11
-        ),
12
-        "<a href='https://support.authorize.net/s/article/Which-Currencies-Does-Authorize-Net-Support/' target='_blank' rel='noopener noreferrer'>",
13
-        "</a>"
14
-    );
15
-    ?>
7
+	printf(
8
+		esc_html__(
9
+			'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.',
10
+			'event_espresso'
11
+		),
12
+		"<a href='https://support.authorize.net/s/article/Which-Currencies-Does-Authorize-Net-Support/' target='_blank' rel='noopener noreferrer'>",
13
+		"</a>"
14
+	);
15
+	?>
16 16
 </p>
17 17
 <p><strong><?php esc_html_e('Authorize.net AIM Settings', 'event_espresso'); ?></strong></p>
18 18
 <ul>
19 19
     <li>
20 20
         <strong><?php esc_html_e('Authorize.net API Login ID', 'event_espresso'); ?></strong><br/>
21 21
         <?php
22
-        printf(
23
-            esc_html__(
24
-                'Enter your API Login ID for Authorize.net. Learn how to find your %1$sAPI Login%2$s ID.',
25
-                'event_espresso'
26
-            ),
27
-            '<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
28
-            '</a>'
29
-        );
30
-        ?>
22
+		printf(
23
+			esc_html__(
24
+				'Enter your API Login ID for Authorize.net. Learn how to find your %1$sAPI Login%2$s ID.',
25
+				'event_espresso'
26
+			),
27
+			'<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
28
+			'</a>'
29
+		);
30
+		?>
31 31
     </li>
32 32
     <li>
33 33
         <strong><?php esc_html_e('Authorize.net Transaction Key', 'event_espresso'); ?></strong><br/>
34 34
         <?php
35
-        printf(
36
-            esc_html__(
37
-                'Enter your Transaction Key for Authorize.net. Learn how to find your %1$sTransaction Key%2$s.',
38
-                'event_espresso'
39
-            ),
40
-            '<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
41
-            '</a>'
42
-        );
43
-        ?>
35
+		printf(
36
+			esc_html__(
37
+				'Enter your Transaction Key for Authorize.net. Learn how to find your %1$sTransaction Key%2$s.',
38
+				'event_espresso'
39
+			),
40
+			'<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
41
+			'</a>'
42
+		);
43
+		?>
44 44
     </li>
45 45
     <li>
46 46
         <strong>
47 47
             <?php esc_html_e(
48
-                'Is this an account on the Authorize.net development server?',
49
-                'event_espresso'
50
-            ); ?>
48
+				'Is this an account on the Authorize.net development server?',
49
+				'event_espresso'
50
+			); ?>
51 51
         </strong><br/>
52 52
         <?php esc_html_e(
53
-            'Specify whether this is a live/production account or a test account on the Authorize.net development server.',
54
-            'event_espresso'
55
-        ); ?>
53
+			'Specify whether this is a live/production account or a test account on the Authorize.net development server.',
54
+			'event_espresso'
55
+		); ?>
56 56
     </li>
57 57
     <li>
58 58
         <strong><?php esc_html_e('Do you want to submit a test transaction?', 'event_espresso'); ?></strong><br/>
59 59
         <?php esc_html_e(
60
-            'Specify if you want to test the Authorize.net AIM payment gateway by submitting a test transaction. Be sure to turn this setting off when you are done testing.',
61
-            'event_espresso'
62
-        ); ?>
60
+			'Specify if you want to test the Authorize.net AIM payment gateway by submitting a test transaction. Be sure to turn this setting off when you are done testing.',
61
+			'event_espresso'
62
+		); ?>
63 63
     </li>
64 64
     <li>
65 65
         <strong><?php esc_html_e('Excluded and Required Payment Form Fields', 'event_espresso'); ?></strong><br/>
66 66
         <?php esc_html_e(
67
-            'By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.',
68
-            'event_espresso'
69
-        ); ?>
67
+			'By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.',
68
+			'event_espresso'
69
+		); ?>
70 70
         <br>
71 71
         <?php
72
-        printf(
73
-            esc_html__(
74
-                'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.',
75
-                'event_espresso'
76
-            ),
77
-            '<a href="http://authorize.net" target="_blank" rel="noopener noreferrer">',
78
-            '</a>',
79
-            '<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank" rel="noopener noreferrer">',
80
-            '<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank" rel="noopener noreferrer">',
81
-            '<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank" rel="noopener noreferrer">'
82
-        ); ?>
72
+		printf(
73
+			esc_html__(
74
+				'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.',
75
+				'event_espresso'
76
+			),
77
+			'<a href="http://authorize.net" target="_blank" rel="noopener noreferrer">',
78
+			'</a>',
79
+			'<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank" rel="noopener noreferrer">',
80
+			'<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank" rel="noopener noreferrer">',
81
+			'<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank" rel="noopener noreferrer">'
82
+		); ?>
83 83
     </li>
84 84
     <li>
85 85
         <strong><?php esc_html_e('Button Image URL', 'event_espresso'); ?></strong><br/>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
         <?php esc_html_e('Change the image that is used for this payment gateway.', 'event_espresso'); ?>
87 87
     </li>
88 88
     <li>
89
-        <strong><?php esc_html_e('Note About Special Characters', 'event_espresso');?></strong>
90
-        <?php esc_html_e('If your event name, ticket name or ticket description contain special characters (eg emojis, foreign language characters, or curly quotes) they will be removed when sent to Authorize.net. This is because Authorize.net doesn\'t support them.', 'event_espresso');?>
89
+        <strong><?php esc_html_e('Note About Special Characters', 'event_espresso'); ?></strong>
90
+        <?php esc_html_e('If your event name, ticket name or ticket description contain special characters (eg emojis, foreign language characters, or curly quotes) they will be removed when sent to Authorize.net. This is because Authorize.net doesn\'t support them.', 'event_espresso'); ?>
91 91
     </li>
92 92
 </ul>
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Question_List_Shortcodes.lib.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -16,95 +16,95 @@
 block discarded – undo
16 16
 class EE_Question_List_Shortcodes extends EE_Shortcodes
17 17
 {
18 18
 
19
-    protected function _init_props()
20
-    {
21
-        $this->label = __('Questions and Answers Shortcodes', 'event_espresso');
22
-        $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso');
23
-        $this->_shortcodes = array(
24
-            '[QUESTION_LIST]' => __(
25
-                'This is used to indicate where you want the list of questions and answers to show for the registrant.  You place this within the "[attendee_list]" field.',
26
-                'event_espresso'
27
-            ),
28
-        );
29
-    }
19
+	protected function _init_props()
20
+	{
21
+		$this->label = __('Questions and Answers Shortcodes', 'event_espresso');
22
+		$this->description = __('All shortcodes related to custom questions and answers', 'event_espresso');
23
+		$this->_shortcodes = array(
24
+			'[QUESTION_LIST]' => __(
25
+				'This is used to indicate where you want the list of questions and answers to show for the registrant.  You place this within the "[attendee_list]" field.',
26
+				'event_espresso'
27
+			),
28
+		);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param string $shortcode
34
-     * @return string
35
-     * @throws EE_Error
36
-     * @throws ReflectionException
37
-     */
38
-    protected function _parser($shortcode)
39
-    {
40
-        switch ($shortcode) {
41
-            case '[QUESTION_LIST]':
42
-                return $this->_get_question_list();
43
-                break;
44
-        }
32
+	/**
33
+	 * @param string $shortcode
34
+	 * @return string
35
+	 * @throws EE_Error
36
+	 * @throws ReflectionException
37
+	 */
38
+	protected function _parser($shortcode)
39
+	{
40
+		switch ($shortcode) {
41
+			case '[QUESTION_LIST]':
42
+				return $this->_get_question_list();
43
+				break;
44
+		}
45 45
 
46
-        return '';
47
-    }
46
+		return '';
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @return string
52
-     * @throws EE_Error
53
-     * @throws ReflectionException
54
-     */
55
-    protected function _get_question_list()
56
-    {
57
-        $this->_validate_list_requirements();
50
+	/**
51
+	 * @return string
52
+	 * @throws EE_Error
53
+	 * @throws ReflectionException
54
+	 */
55
+	protected function _get_question_list()
56
+	{
57
+		$this->_validate_list_requirements();
58 58
 
59
-        if ($this->_data['data'] instanceof EE_Registration) {
60
-            // for when [QUESTION_LIST] is used in the [attendee_list] field.
61
-            return $this->_get_question_answer_list_for_attendee();
62
-        } elseif ($this->_data['data'] instanceof EE_Messages_Addressee
63
-            && $this->_data['data']->reg_obj instanceof EE_Registration
64
-        ) {
65
-            // for when [QUESTION_LIST] is used in the main content field.
66
-            return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj);
67
-        }
68
-        return '';
69
-    }
59
+		if ($this->_data['data'] instanceof EE_Registration) {
60
+			// for when [QUESTION_LIST] is used in the [attendee_list] field.
61
+			return $this->_get_question_answer_list_for_attendee();
62
+		} elseif ($this->_data['data'] instanceof EE_Messages_Addressee
63
+			&& $this->_data['data']->reg_obj instanceof EE_Registration
64
+		) {
65
+			// for when [QUESTION_LIST] is used in the main content field.
66
+			return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj);
67
+		}
68
+		return '';
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of
74
-     * answers for that attendee since that is what we really need (we can derive the questions from the answers);
75
-     *
76
-     * @param null $reg_obj
77
-     * @return string parsed template.
78
-     * @throws EE_Error
79
-     * @throws ReflectionException
80
-     */
81
-    private function _get_question_answer_list_for_attendee($reg_obj = null)
82
-    {
83
-        $valid_shortcodes = array('question');
84
-        $reg_obj = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data'];
85
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['question_list'])
86
-            ? $this->_data['template']['question_list'] : '';
87
-        $template = empty($template) && isset($this->_extra_data['template']['question_list'])
88
-            ? $this->_extra_data['template']['question_list'] : $template;
89
-        $ans_result = '';
90
-        $answers = ! empty($this->_extra_data['data']->registrations[ $reg_obj->ID() ]['ans_objs'])
91
-            ? $this->_extra_data['data']->registrations[ $reg_obj->ID() ]['ans_objs'] : array();
92
-        $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
93
-        foreach ($answers as $answer) {
94
-            // first see if the question is in our $questions array.  If not then try to get from answer object
95
-            $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
96
-            $question = ! $question instanceof EE_Question ? $answer->question() : $question;
97
-            if ($question instanceof EE_Question and $question->admin_only()) {
98
-                continue;
99
-            }
100
-            $ans_result .= $this->_shortcode_helper->parse_question_list_template(
101
-                $template,
102
-                $answer,
103
-                $valid_shortcodes,
104
-                $this->_extra_data
105
-            );
106
-        }
72
+	/**
73
+	 * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of
74
+	 * answers for that attendee since that is what we really need (we can derive the questions from the answers);
75
+	 *
76
+	 * @param null $reg_obj
77
+	 * @return string parsed template.
78
+	 * @throws EE_Error
79
+	 * @throws ReflectionException
80
+	 */
81
+	private function _get_question_answer_list_for_attendee($reg_obj = null)
82
+	{
83
+		$valid_shortcodes = array('question');
84
+		$reg_obj = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data'];
85
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['question_list'])
86
+			? $this->_data['template']['question_list'] : '';
87
+		$template = empty($template) && isset($this->_extra_data['template']['question_list'])
88
+			? $this->_extra_data['template']['question_list'] : $template;
89
+		$ans_result = '';
90
+		$answers = ! empty($this->_extra_data['data']->registrations[ $reg_obj->ID() ]['ans_objs'])
91
+			? $this->_extra_data['data']->registrations[ $reg_obj->ID() ]['ans_objs'] : array();
92
+		$questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
93
+		foreach ($answers as $answer) {
94
+			// first see if the question is in our $questions array.  If not then try to get from answer object
95
+			$question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
96
+			$question = ! $question instanceof EE_Question ? $answer->question() : $question;
97
+			if ($question instanceof EE_Question and $question->admin_only()) {
98
+				continue;
99
+			}
100
+			$ans_result .= $this->_shortcode_helper->parse_question_list_template(
101
+				$template,
102
+				$answer,
103
+				$valid_shortcodes,
104
+				$this->_extra_data
105
+			);
106
+		}
107 107
 
108
-        return $ans_result;
109
-    }
108
+		return $ans_result;
109
+	}
110 110
 }
Please login to merge, or discard this patch.
core/domain/services/admin/privacy/policy/privacy_policy.template.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 ?>
8 8
 <h2><?php esc_html_e('Event Registration Data', 'event_espresso'); ?></h2>
9 9
 <p><?php
10
-    esc_html_e(
11
-        'We collect information about you during event registration. This information may include but is not limited to:',
12
-        'event_espresso'
13
-    ); ?></p>
10
+	esc_html_e(
11
+		'We collect information about you during event registration. This information may include but is not limited to:',
12
+		'event_espresso'
13
+	); ?></p>
14 14
 <ul>
15 15
     <li><?php esc_html_e('Your names', 'event_espresso'); ?></li>
16 16
     <li><?php esc_html_e('Billing address', 'event_espresso'); ?></li>
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
     <li><?php esc_html_e('Phone number', 'event_espresso'); ?></li>
20 20
     <li><?php esc_html_e('Location and traffic data (including partial IP address and browser type)', 'event_espresso'); ?></li>
21 21
     <li><?php
22
-        esc_html_e(
23
-            'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase',
24
-            'event_espresso'
25
-        ); ?></li>
22
+		esc_html_e(
23
+			'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase',
24
+			'event_espresso'
25
+		); ?></li>
26 26
 </ul>
27 27
 
28 28
 <p><?php esc_html_e('Handling this data also allows us to:', 'event_espresso'); ?></p>
@@ -30,101 +30,101 @@  discard block
 block discarded – undo
30 30
     <li><?php esc_html_e('Send you important account/purchase/service information.', 'event_espresso'); ?></li>
31 31
     <li><?php esc_html_e('Respond to your queries, refund requests, or complaints.', 'event_espresso'); ?></li>
32 32
     <li><?php
33
-        esc_html_e(
34
-            'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.',
35
-            'event_espresso'
36
-        ); ?></li>
33
+		esc_html_e(
34
+			'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.',
35
+			'event_espresso'
36
+		); ?></li>
37 37
     <li><?php
38
-        esc_html_e(
39
-            'Set up and administer your account, provide technical and customer support, and to verify your identity.',
40
-            'event_espresso'
41
-        ); ?></li>
38
+		esc_html_e(
39
+			'Set up and administer your account, provide technical and customer support, and to verify your identity.',
40
+			'event_espresso'
41
+		); ?></li>
42 42
 </ul>
43 43
 
44 44
 <?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?>
45 45
     <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2>
46 46
     <?php
47 47
 // if onsite or offsite payment methods are active
48
-    if (! empty($active_onsite_payment_methods)) { ?>
48
+	if (! empty($active_onsite_payment_methods)) { ?>
49 49
         <p><?php
50
-            esc_html_e(
51
-                'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.',
52
-                'event_espresso'
53
-            ); ?></p>
50
+			esc_html_e(
51
+				'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.',
52
+				'event_espresso'
53
+			); ?></p>
54 54
         <p><?php
55
-            printf(
56
-                esc_html_x(
57
-                    'Please see the privacy policy of %1$s.',
58
-                    'Please see the privacy policy of PayPal Pro',
59
-                    'event_espresso'
60
-                ),
61
-                implode(
62
-                    ', ',
63
-                    array_merge(
64
-                        $active_onsite_payment_methods,
65
-                        $active_offsite_payment_methods
66
-                    )
67
-                )
68
-            ); ?></p>
55
+			printf(
56
+				esc_html_x(
57
+					'Please see the privacy policy of %1$s.',
58
+					'Please see the privacy policy of PayPal Pro',
59
+					'event_espresso'
60
+				),
61
+				implode(
62
+					', ',
63
+					array_merge(
64
+						$active_onsite_payment_methods,
65
+						$active_offsite_payment_methods
66
+					)
67
+				)
68
+			); ?></p>
69 69
         <p><?php
70
-            esc_html_e(
71
-                'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).',
72
-                'event_espresso'
73
-            ); ?></p>
70
+			esc_html_e(
71
+				'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).',
72
+				'event_espresso'
73
+			); ?></p>
74 74
     <?php } elseif (! empty($active_offsite_payment_methods)) { // IF OFFSITE PAYMENT METHOD ACTIVE ?>
75 75
         <p><?php
76
-            printf(
77
-                esc_html_x(
78
-                    'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.',
79
-                    'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.',
80
-                    'event_espresso'
81
-                ),
82
-                implode(', ', $active_offsite_payment_methods)
83
-            ); ?></p>
76
+			printf(
77
+				esc_html_x(
78
+					'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.',
79
+					'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.',
80
+					'event_espresso'
81
+				),
82
+				implode(', ', $active_offsite_payment_methods)
83
+			); ?></p>
84 84
     <?php } ?>
85 85
     <h2><?php esc_html_e('Payment Logging', 'event_espresso'); ?></h2>
86 86
     <p><?php
87
-        esc_html_e(
88
-            'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.',
89
-            'event_espresso'
90
-        ); ?></p>
87
+		esc_html_e(
88
+			'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.',
89
+			'event_espresso'
90
+		); ?></p>
91 91
 <?php } ?>
92 92
 
93 93
 <h2><?php esc_html_e('Event Registration Cookies', 'event_espresso'); ?></h2>
94 94
 <p><?php
95
-    printf(
96
-        esc_html_x(
97
-            'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.',
98
-            'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.',
99
-            'event_espresso'
100
-        ),
101
-        $session_lifespan
102
-    ); ?></p>
95
+	printf(
96
+		esc_html_x(
97
+			'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.',
98
+			'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.',
99
+			'event_espresso'
100
+		),
101
+		$session_lifespan
102
+	); ?></p>
103 103
 
104 104
 <h2><?php esc_html_e('Email History Data', 'event_espresso'); ?></h2>
105 105
 <p><?php
106
-    esc_html_e(
107
-        'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.',
108
-        'event_espresso'
109
-    ); ?></p>
106
+	esc_html_e(
107
+		'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.',
108
+		'event_espresso'
109
+	); ?></p>
110 110
 
111 111
 <h2><?php esc_html_e('Event Check-In Record', 'event_espresso'); ?></h2>
112 112
 <p><?php
113
-    esc_html_e(
114
-        'When you attend an event, an event manager may record the time you check in or out of the event.',
115
-        'event_espresso'
116
-    ); ?></p>
113
+	esc_html_e(
114
+		'When you attend an event, an event manager may record the time you check in or out of the event.',
115
+		'event_espresso'
116
+	); ?></p>
117 117
 
118 118
 <h2><?php esc_html_e('Event Registration Data Retention', 'event_espresso'); ?></h2>
119 119
 <p><?php
120
-    esc_html_e(
121
-        'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.',
122
-        'event_espresso'
123
-    ); ?></p>
120
+	esc_html_e(
121
+		'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.',
122
+		'event_espresso'
123
+	); ?></p>
124 124
 
125 125
 <h2><?php esc_html_e('Event Registration Data Erasure and Export', 'event_espresso'); ?></h2>
126 126
 <p><?php
127
-    esc_html_e(
128
-        'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.',
129
-        'event_espresso'
130
-    ); ?></p>
127
+	esc_html_e(
128
+		'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.',
129
+		'event_espresso'
130
+	); ?></p>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
         ); ?></li>
42 42
 </ul>
43 43
 
44
-<?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?>
44
+<?php if ( ! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?>
45 45
     <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2>
46 46
     <?php
47 47
 // if onsite or offsite payment methods are active
48
-    if (! empty($active_onsite_payment_methods)) { ?>
48
+    if ( ! empty($active_onsite_payment_methods)) { ?>
49 49
         <p><?php
50 50
             esc_html_e(
51 51
                 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.',
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                 'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).',
72 72
                 'event_espresso'
73 73
             ); ?></p>
74
-    <?php } elseif (! empty($active_offsite_payment_methods)) { // IF OFFSITE PAYMENT METHOD ACTIVE ?>
74
+    <?php } elseif ( ! empty($active_offsite_payment_methods)) { // IF OFFSITE PAYMENT METHOD ACTIVE ?>
75 75
         <p><?php
76 76
             printf(
77 77
                 esc_html_x(
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Datetime_List_Shortcodes.lib.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -22,141 +22,141 @@
 block discarded – undo
22 22
 {
23 23
 
24 24
 
25
-    protected function _init_props()
26
-    {
27
-        $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso');
28
-        $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso');
29
-        $this->_shortcodes = array(
30
-            '[DATETIME_LIST]' => esc_html__(
31
-                'Will output a list of datetimes according to the layout specified in the datetime list field.',
32
-                'event_espresso'
33
-            ),
34
-        );
35
-    }
36
-
37
-
38
-    /**
39
-     * @param string $shortcode
40
-     * @return string
41
-     * @throws EE_Error
42
-     */
43
-    protected function _parser($shortcode)
44
-    {
45
-        switch ($shortcode) {
46
-            case '[DATETIME_LIST]':
47
-                return $this->_get_datetime_list();
48
-        }
49
-        return '';
50
-    }
51
-
52
-
53
-    /**
54
-     * figure out what the incoming data is and then return the appropriate parsed value.
55
-     *
56
-     * @return string
57
-     * @throws EE_Error
58
-     */
59
-    private function _get_datetime_list()
60
-    {
61
-        $this->_validate_list_requirements();
62
-
63
-        if ($this->_data['data'] instanceof EE_Ticket) {
64
-            return $this->_get_datetime_list_for_ticket();
65
-        } elseif ($this->_data['data'] instanceof EE_Event) {
66
-            return $this->_get_datetime_list_for_event();
67
-        } elseif ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) {
68
-            return $this->_get_datetime_list_for_registration();
69
-        }
70
-        // prevent recursive loop
71
-        return '';
72
-    }
73
-
74
-
75
-    /**
76
-     * return parsed list of datetimes for an event
77
-     *
78
-     * @return string
79
-     */
80
-    private function _get_datetime_list_for_event()
81
-    {
82
-        $valid_shortcodes = array('datetime', 'attendee');
83
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
84
-            ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
85
-        $event = $this->_data['data'];
86
-
87
-        // here we're setting up the datetimes for the datetime list template for THIS event.
88
-        $dtt_parsed = '';
89
-        $datetimes = $this->_get_datetimes_from_event($event);
90
-
91
-        // each datetime in this case should be an datetime object.
92
-        foreach ($datetimes as $datetime) {
93
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
94
-                $template,
95
-                $datetime,
96
-                $valid_shortcodes,
97
-                $this->_extra_data
98
-            );
99
-        }
100
-
101
-        return $dtt_parsed;
102
-    }
103
-
104
-
105
-    /**
106
-     * return parsed list of datetimes for an ticket
107
-     *
108
-     * @return string
109
-     */
110
-    private function _get_datetime_list_for_ticket()
111
-    {
112
-        $valid_shortcodes = array('datetime', 'attendee');
113
-
114
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
115
-            ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
116
-        $ticket = $this->_data['data'];
117
-
118
-        // here we're setting up the datetimes for the datetime list template for THIS ticket.
119
-        $dtt_parsed = '';
120
-        $datetimes = $this->_get_datetimes_from_ticket($ticket);
121
-
122
-        // each datetime in this case should be an datetime object.
123
-        foreach ($datetimes as $datetime) {
124
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
125
-                $template,
126
-                $datetime,
127
-                $valid_shortcodes,
128
-                $this->_extra_data
129
-            );
130
-        }
131
-
132
-        return $dtt_parsed;
133
-    }
134
-
135
-
136
-    /**
137
-     * return parsed list of datetimes from a given registration.
138
-     *
139
-     * @return string
140
-     */
141
-    private function _get_datetime_list_for_registration()
142
-    {
143
-        $registration = $this->_data['data']->reg_obj;
144
-
145
-        // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket();
146
-        $this->_data['data'] = $registration->ticket();
147
-        return $this->_get_datetime_list_for_ticket();
148
-    }
149
-
150
-
151
-    private function _get_datetimes_from_event(EE_Event $event, $att = null)
152
-    {
153
-        return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
154
-        ) ]['dtt_objs'] : array();
155
-    }
156
-
157
-    private function _get_datetimes_from_ticket(EE_Ticket $ticket, $att = null)
158
-    {
159
-        return isset($this->_extra_data['data']->tickets) ? $this->_extra_data['data']->tickets[ $ticket->ID(
160
-        ) ]['dtt_objs'] : array();
161
-    }
25
+	protected function _init_props()
26
+	{
27
+		$this->label = esc_html__('Datetime List Shortcodes', 'event_espresso');
28
+		$this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso');
29
+		$this->_shortcodes = array(
30
+			'[DATETIME_LIST]' => esc_html__(
31
+				'Will output a list of datetimes according to the layout specified in the datetime list field.',
32
+				'event_espresso'
33
+			),
34
+		);
35
+	}
36
+
37
+
38
+	/**
39
+	 * @param string $shortcode
40
+	 * @return string
41
+	 * @throws EE_Error
42
+	 */
43
+	protected function _parser($shortcode)
44
+	{
45
+		switch ($shortcode) {
46
+			case '[DATETIME_LIST]':
47
+				return $this->_get_datetime_list();
48
+		}
49
+		return '';
50
+	}
51
+
52
+
53
+	/**
54
+	 * figure out what the incoming data is and then return the appropriate parsed value.
55
+	 *
56
+	 * @return string
57
+	 * @throws EE_Error
58
+	 */
59
+	private function _get_datetime_list()
60
+	{
61
+		$this->_validate_list_requirements();
62
+
63
+		if ($this->_data['data'] instanceof EE_Ticket) {
64
+			return $this->_get_datetime_list_for_ticket();
65
+		} elseif ($this->_data['data'] instanceof EE_Event) {
66
+			return $this->_get_datetime_list_for_event();
67
+		} elseif ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) {
68
+			return $this->_get_datetime_list_for_registration();
69
+		}
70
+		// prevent recursive loop
71
+		return '';
72
+	}
73
+
74
+
75
+	/**
76
+	 * return parsed list of datetimes for an event
77
+	 *
78
+	 * @return string
79
+	 */
80
+	private function _get_datetime_list_for_event()
81
+	{
82
+		$valid_shortcodes = array('datetime', 'attendee');
83
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
84
+			? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
85
+		$event = $this->_data['data'];
86
+
87
+		// here we're setting up the datetimes for the datetime list template for THIS event.
88
+		$dtt_parsed = '';
89
+		$datetimes = $this->_get_datetimes_from_event($event);
90
+
91
+		// each datetime in this case should be an datetime object.
92
+		foreach ($datetimes as $datetime) {
93
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
94
+				$template,
95
+				$datetime,
96
+				$valid_shortcodes,
97
+				$this->_extra_data
98
+			);
99
+		}
100
+
101
+		return $dtt_parsed;
102
+	}
103
+
104
+
105
+	/**
106
+	 * return parsed list of datetimes for an ticket
107
+	 *
108
+	 * @return string
109
+	 */
110
+	private function _get_datetime_list_for_ticket()
111
+	{
112
+		$valid_shortcodes = array('datetime', 'attendee');
113
+
114
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
115
+			? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
116
+		$ticket = $this->_data['data'];
117
+
118
+		// here we're setting up the datetimes for the datetime list template for THIS ticket.
119
+		$dtt_parsed = '';
120
+		$datetimes = $this->_get_datetimes_from_ticket($ticket);
121
+
122
+		// each datetime in this case should be an datetime object.
123
+		foreach ($datetimes as $datetime) {
124
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
125
+				$template,
126
+				$datetime,
127
+				$valid_shortcodes,
128
+				$this->_extra_data
129
+			);
130
+		}
131
+
132
+		return $dtt_parsed;
133
+	}
134
+
135
+
136
+	/**
137
+	 * return parsed list of datetimes from a given registration.
138
+	 *
139
+	 * @return string
140
+	 */
141
+	private function _get_datetime_list_for_registration()
142
+	{
143
+		$registration = $this->_data['data']->reg_obj;
144
+
145
+		// now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket();
146
+		$this->_data['data'] = $registration->ticket();
147
+		return $this->_get_datetime_list_for_ticket();
148
+	}
149
+
150
+
151
+	private function _get_datetimes_from_event(EE_Event $event, $att = null)
152
+	{
153
+		return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
154
+		) ]['dtt_objs'] : array();
155
+	}
156
+
157
+	private function _get_datetimes_from_ticket(EE_Ticket $ticket, $att = null)
158
+	{
159
+		return isset($this->_extra_data['data']->tickets) ? $this->_extra_data['data']->tickets[ $ticket->ID(
160
+		) ]['dtt_objs'] : array();
161
+	}
162 162
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Event_List_Shortcodes.lib.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -19,153 +19,153 @@
 block discarded – undo
19 19
 class EE_Event_List_Shortcodes extends EE_Shortcodes
20 20
 {
21 21
 
22
-    public function __construct()
23
-    {
24
-        parent::__construct();
25
-    }
26
-
27
-
28
-    protected function _init_props()
29
-    {
30
-        $this->label = esc_html__('Event List Shortcodes', 'event_espresso');
31
-        $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso');
32
-        $this->_shortcodes = array(
33
-            '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'),
34
-        );
35
-    }
36
-
37
-
38
-    /**
39
-     * @param string $shortcode
40
-     * @return string
41
-     * @throws EE_Error
42
-     * @throws ReflectionException
43
-     */
44
-    protected function _parser($shortcode)
45
-    {
46
-        switch ($shortcode) {
47
-            case '[EVENT_LIST]':
48
-                return $this->_get_event_list();
49
-        }
50
-        return '';
51
-    }
52
-
53
-
54
-    /**
55
-     * figure out what the incoming data is and then return the appropriate parsed value.
56
-     *
57
-     * @return string
58
-     * @throws EE_Error
59
-     * @throws ReflectionException
60
-     */
61
-    private function _get_event_list()
62
-    {
63
-        $this->_validate_list_requirements();
64
-
65
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
66
-            return $this->_get_event_list_for_main();
67
-        } elseif ($this->_data['data'] instanceof EE_Registration) {
68
-            return $this->_get_event_list_for_registration();
69
-        }
70
-        // prevent recursive loop
71
-        return '';
72
-    }
73
-
74
-
75
-    /**
76
-     * This returns the parsed event list for main template
77
-     *
78
-     * @return string
79
-     */
80
-    private function _get_event_list_for_main()
81
-    {
82
-
83
-        $valid_shortcodes = array(
84
-            'event',
85
-            'attendee_list',
86
-            'ticket_list',
87
-            'datetime_list',
88
-            'venue',
89
-            'attendee',
90
-            'recipient_list',
91
-            'recipient_details',
92
-            'primary_registration_list',
93
-            'primary_registration_details',
94
-            'event_author',
95
-            'organization',
96
-        );
97
-        $template = $this->_data['template'];
98
-        $data = $this->_data['data'];
99
-        $events = '';
100
-
101
-        // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper.
102
-        foreach ($data->events as $event) {
103
-            $events .= $this->_shortcode_helper->parse_event_list_template(
104
-                $template,
105
-                $event['event'],
106
-                $valid_shortcodes,
107
-                $this->_extra_data
108
-            );
109
-        }
110
-        return $events;
111
-    }
112
-
113
-
114
-    /**
115
-     * This returns the parsed event list for an attendee
116
-     *
117
-     * @return string
118
-     * @throws EE_Error
119
-     * @throws ReflectionException
120
-     */
121
-    private function _get_event_list_for_registration()
122
-    {
123
-        $valid_shortcodes = array(
124
-            'event',
125
-            'ticket_list',
126
-            'datetime_list',
127
-            'attendee',
128
-            'event_author',
129
-            'recipient_details',
130
-            'recipient_list',
131
-            'venue',
132
-            'organization',
133
-        );
134
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list'])
135
-            ? $this->_data['template']['event_list'] : $this->_extra_data['template']['event_list'];
136
-        $registration = $this->_data['data'];
137
-
138
-        // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion.
139
-        $template = str_replace('[ATTENDEE_LIST]', '', $template);
140
-
141
-        // here we're setting up the events for the event_list template for THIS registration.
142
-        $all_events = $this->_get_events_from_registration($registration);
143
-
144
-        // we're NOT going to prepare a list of attendees this time around
145
-        $events = '';
146
-
147
-        foreach ((array) $all_events as $event) {
148
-            $events .= $this->_shortcode_helper->parse_event_list_template(
149
-                $template,
150
-                $event,
151
-                $valid_shortcodes,
152
-                $this->_extra_data
153
-            );
154
-        }
155
-
156
-        return $events;
157
-    }
158
-
159
-
160
-    /**
161
-     * @param EE_Registration $registration
162
-     * @return array
163
-     * @throws EE_Error
164
-     * @throws ReflectionException
165
-     */
166
-    private function _get_events_from_registration(EE_Registration $registration)
167
-    {
168
-        return isset($this->_extra_data['data']->registrations)
169
-            ? array($this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']) : array();
170
-    }
22
+	public function __construct()
23
+	{
24
+		parent::__construct();
25
+	}
26
+
27
+
28
+	protected function _init_props()
29
+	{
30
+		$this->label = esc_html__('Event List Shortcodes', 'event_espresso');
31
+		$this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso');
32
+		$this->_shortcodes = array(
33
+			'[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'),
34
+		);
35
+	}
36
+
37
+
38
+	/**
39
+	 * @param string $shortcode
40
+	 * @return string
41
+	 * @throws EE_Error
42
+	 * @throws ReflectionException
43
+	 */
44
+	protected function _parser($shortcode)
45
+	{
46
+		switch ($shortcode) {
47
+			case '[EVENT_LIST]':
48
+				return $this->_get_event_list();
49
+		}
50
+		return '';
51
+	}
52
+
53
+
54
+	/**
55
+	 * figure out what the incoming data is and then return the appropriate parsed value.
56
+	 *
57
+	 * @return string
58
+	 * @throws EE_Error
59
+	 * @throws ReflectionException
60
+	 */
61
+	private function _get_event_list()
62
+	{
63
+		$this->_validate_list_requirements();
64
+
65
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
66
+			return $this->_get_event_list_for_main();
67
+		} elseif ($this->_data['data'] instanceof EE_Registration) {
68
+			return $this->_get_event_list_for_registration();
69
+		}
70
+		// prevent recursive loop
71
+		return '';
72
+	}
73
+
74
+
75
+	/**
76
+	 * This returns the parsed event list for main template
77
+	 *
78
+	 * @return string
79
+	 */
80
+	private function _get_event_list_for_main()
81
+	{
82
+
83
+		$valid_shortcodes = array(
84
+			'event',
85
+			'attendee_list',
86
+			'ticket_list',
87
+			'datetime_list',
88
+			'venue',
89
+			'attendee',
90
+			'recipient_list',
91
+			'recipient_details',
92
+			'primary_registration_list',
93
+			'primary_registration_details',
94
+			'event_author',
95
+			'organization',
96
+		);
97
+		$template = $this->_data['template'];
98
+		$data = $this->_data['data'];
99
+		$events = '';
100
+
101
+		// now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper.
102
+		foreach ($data->events as $event) {
103
+			$events .= $this->_shortcode_helper->parse_event_list_template(
104
+				$template,
105
+				$event['event'],
106
+				$valid_shortcodes,
107
+				$this->_extra_data
108
+			);
109
+		}
110
+		return $events;
111
+	}
112
+
113
+
114
+	/**
115
+	 * This returns the parsed event list for an attendee
116
+	 *
117
+	 * @return string
118
+	 * @throws EE_Error
119
+	 * @throws ReflectionException
120
+	 */
121
+	private function _get_event_list_for_registration()
122
+	{
123
+		$valid_shortcodes = array(
124
+			'event',
125
+			'ticket_list',
126
+			'datetime_list',
127
+			'attendee',
128
+			'event_author',
129
+			'recipient_details',
130
+			'recipient_list',
131
+			'venue',
132
+			'organization',
133
+		);
134
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['event_list'])
135
+			? $this->_data['template']['event_list'] : $this->_extra_data['template']['event_list'];
136
+		$registration = $this->_data['data'];
137
+
138
+		// let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion.
139
+		$template = str_replace('[ATTENDEE_LIST]', '', $template);
140
+
141
+		// here we're setting up the events for the event_list template for THIS registration.
142
+		$all_events = $this->_get_events_from_registration($registration);
143
+
144
+		// we're NOT going to prepare a list of attendees this time around
145
+		$events = '';
146
+
147
+		foreach ((array) $all_events as $event) {
148
+			$events .= $this->_shortcode_helper->parse_event_list_template(
149
+				$template,
150
+				$event,
151
+				$valid_shortcodes,
152
+				$this->_extra_data
153
+			);
154
+		}
155
+
156
+		return $events;
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param EE_Registration $registration
162
+	 * @return array
163
+	 * @throws EE_Error
164
+	 * @throws ReflectionException
165
+	 */
166
+	private function _get_events_from_registration(EE_Registration $registration)
167
+	{
168
+		return isset($this->_extra_data['data']->registrations)
169
+			? array($this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']) : array();
170
+	}
171 171
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Attendee_List_Shortcodes.lib.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -20,150 +20,150 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    protected function _init_props()
24
-    {
25
-        $this->label = esc_html__('Attendee List Shortcodes', 'event_espresso');
26
-        $this->description = esc_html__('All shortcodes specific to attendee lists', 'event_espresso');
27
-        $this->_shortcodes = array(
28
-            '[ATTENDEE_LIST]' => esc_html__('Will output a list of attendees', 'event_espresso'),
29
-        );
30
-    }
31
-
32
-
33
-    /**
34
-     * @param string $shortcode
35
-     * @return string
36
-     * @throws EE_Error
37
-     */
38
-    protected function _parser($shortcode)
39
-    {
40
-        switch ($shortcode) {
41
-            case '[ATTENDEE_LIST]':
42
-                return $this->_get_attendee_list();
43
-        }
44
-        return '';
45
-    }
46
-
47
-
48
-    /**
49
-     * figure out what the incoming data is and then return the appropriate parsed value.
50
-     *
51
-     * @return string
52
-     * @throws EE_Error
53
-     */
54
-    private function _get_attendee_list()
55
-    {
56
-        $this->_validate_list_requirements();
57
-
58
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
59
-            return $this->_get_attendee_list_for_main();
60
-        } elseif ($this->_data['data'] instanceof EE_Event) {
61
-            return $this->_get_attendee_list_for_event();
62
-        } elseif ($this->_data['data'] instanceof EE_Ticket) {
63
-            return $this->_get_registration_list_for_ticket();
64
-        }
65
-        // prevent recursive loop
66
-        return '';
67
-    }
68
-
69
-
70
-    /**
71
-     * This returns the parsed attendee list for main template;
72
-     */
73
-    private function _get_attendee_list_for_main()
74
-    {
75
-        $valid_shortcodes = array('attendee', 'event_list', 'ticket_list', 'question_list', 'recipient_details');
76
-        $template = $this->_data['template'];
77
-        $data = $this->_data['data'];
78
-        $attnds = '';
79
-
80
-
81
-        // now we need to loop through the attendee list and send data to the EE_Parser helper.
82
-        foreach ($data->reg_objs as $registration) {
83
-            $attnds .= $this->_shortcode_helper->parse_attendee_list_template(
84
-                $template,
85
-                $registration,
86
-                $valid_shortcodes,
87
-                $this->_extra_data
88
-            );
89
-        }
90
-
91
-        return $attnds;
92
-    }
93
-
94
-
95
-    /**
96
-     * return parsed list of attendees for an event
97
-     *
98
-     * @return string
99
-     */
100
-    private function _get_attendee_list_for_event()
101
-    {
102
-        $valid_shortcodes = array('attendee', 'ticket_list', 'question_list', 'recipient_details');
103
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['attendee_list'])
104
-            ? $this->_data['template']['attendee_list'] : $this->_extra_data['template']['attendee_list'];
105
-        $event = $this->_data['data'];
106
-
107
-        // let's remove any existing [EVENT_LIST] shortcode from the attendee list template so that we don't get recursion.
108
-        $template = str_replace('[EVENT_LIST]', '', $template);
109
-
110
-        // here we're setting up the attendees for the attendee_list template for THIS event.
111
-        $att_result = '';
112
-        $registrations = $this->_get_registrations_from_event($event);
113
-
114
-        // each attendee in this case should be an attendee object.
115
-        foreach ($registrations as $registration) {
116
-            $att_result .= $this->_shortcode_helper->parse_attendee_list_template(
117
-                $template,
118
-                $registration,
119
-                $valid_shortcodes,
120
-                $this->_extra_data
121
-            );
122
-        }
123
-
124
-        return $att_result;
125
-    }
126
-
127
-
128
-    /**
129
-     * return parsed list of attendees for a ticket
130
-     *
131
-     * @return string
132
-     */
133
-    private function _get_registration_list_for_ticket()
134
-    {
135
-        $valid_shortcodes = array('attendee', 'event_list', 'question_list', 'recipient_details');
136
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['attendee_list'])
137
-            ? $this->_data['template']['attendee_list'] : $this->_extra_data['template']['attendee_list'];
138
-        $ticket = $this->_data['data'];
139
-
140
-        // let's remove any existing [TICKET_LIST] (or related) shortcode from the attendee list template so that we don't get recursion.
141
-        $template = str_replace('[TICKET_LIST]', '', $template);
142
-        $template = str_replace('[RECIPIENT_TICKET_LIST]', '', $template);
143
-        $template = str_replace('[PRIMARY_REGISTRANT_TICKET_LIST]', '', $template);
144
-
145
-        // here we're setting up the attendees for the attendee_list template for THIS ticket.
146
-        $att_result = '';
147
-        $registrations = isset($this->_extra_data['data']->tickets) ? $this->_extra_data['data']->tickets[ $ticket->ID(
148
-        ) ]['reg_objs'] : array();
149
-
150
-        // each attendee in this case should be an attendee object.
151
-        foreach ($registrations as $registration) {
152
-            $att_result .= $this->_shortcode_helper->parse_attendee_list_template(
153
-                $template,
154
-                $registration,
155
-                $valid_shortcodes,
156
-                $this->_extra_data
157
-            );
158
-        }
159
-
160
-        return $att_result;
161
-    }
162
-
163
-
164
-    private function _get_registrations_from_event(EE_Event $event)
165
-    {
166
-        return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
167
-        ) ]['reg_objs'] : array();
168
-    }
23
+	protected function _init_props()
24
+	{
25
+		$this->label = esc_html__('Attendee List Shortcodes', 'event_espresso');
26
+		$this->description = esc_html__('All shortcodes specific to attendee lists', 'event_espresso');
27
+		$this->_shortcodes = array(
28
+			'[ATTENDEE_LIST]' => esc_html__('Will output a list of attendees', 'event_espresso'),
29
+		);
30
+	}
31
+
32
+
33
+	/**
34
+	 * @param string $shortcode
35
+	 * @return string
36
+	 * @throws EE_Error
37
+	 */
38
+	protected function _parser($shortcode)
39
+	{
40
+		switch ($shortcode) {
41
+			case '[ATTENDEE_LIST]':
42
+				return $this->_get_attendee_list();
43
+		}
44
+		return '';
45
+	}
46
+
47
+
48
+	/**
49
+	 * figure out what the incoming data is and then return the appropriate parsed value.
50
+	 *
51
+	 * @return string
52
+	 * @throws EE_Error
53
+	 */
54
+	private function _get_attendee_list()
55
+	{
56
+		$this->_validate_list_requirements();
57
+
58
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
59
+			return $this->_get_attendee_list_for_main();
60
+		} elseif ($this->_data['data'] instanceof EE_Event) {
61
+			return $this->_get_attendee_list_for_event();
62
+		} elseif ($this->_data['data'] instanceof EE_Ticket) {
63
+			return $this->_get_registration_list_for_ticket();
64
+		}
65
+		// prevent recursive loop
66
+		return '';
67
+	}
68
+
69
+
70
+	/**
71
+	 * This returns the parsed attendee list for main template;
72
+	 */
73
+	private function _get_attendee_list_for_main()
74
+	{
75
+		$valid_shortcodes = array('attendee', 'event_list', 'ticket_list', 'question_list', 'recipient_details');
76
+		$template = $this->_data['template'];
77
+		$data = $this->_data['data'];
78
+		$attnds = '';
79
+
80
+
81
+		// now we need to loop through the attendee list and send data to the EE_Parser helper.
82
+		foreach ($data->reg_objs as $registration) {
83
+			$attnds .= $this->_shortcode_helper->parse_attendee_list_template(
84
+				$template,
85
+				$registration,
86
+				$valid_shortcodes,
87
+				$this->_extra_data
88
+			);
89
+		}
90
+
91
+		return $attnds;
92
+	}
93
+
94
+
95
+	/**
96
+	 * return parsed list of attendees for an event
97
+	 *
98
+	 * @return string
99
+	 */
100
+	private function _get_attendee_list_for_event()
101
+	{
102
+		$valid_shortcodes = array('attendee', 'ticket_list', 'question_list', 'recipient_details');
103
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['attendee_list'])
104
+			? $this->_data['template']['attendee_list'] : $this->_extra_data['template']['attendee_list'];
105
+		$event = $this->_data['data'];
106
+
107
+		// let's remove any existing [EVENT_LIST] shortcode from the attendee list template so that we don't get recursion.
108
+		$template = str_replace('[EVENT_LIST]', '', $template);
109
+
110
+		// here we're setting up the attendees for the attendee_list template for THIS event.
111
+		$att_result = '';
112
+		$registrations = $this->_get_registrations_from_event($event);
113
+
114
+		// each attendee in this case should be an attendee object.
115
+		foreach ($registrations as $registration) {
116
+			$att_result .= $this->_shortcode_helper->parse_attendee_list_template(
117
+				$template,
118
+				$registration,
119
+				$valid_shortcodes,
120
+				$this->_extra_data
121
+			);
122
+		}
123
+
124
+		return $att_result;
125
+	}
126
+
127
+
128
+	/**
129
+	 * return parsed list of attendees for a ticket
130
+	 *
131
+	 * @return string
132
+	 */
133
+	private function _get_registration_list_for_ticket()
134
+	{
135
+		$valid_shortcodes = array('attendee', 'event_list', 'question_list', 'recipient_details');
136
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['attendee_list'])
137
+			? $this->_data['template']['attendee_list'] : $this->_extra_data['template']['attendee_list'];
138
+		$ticket = $this->_data['data'];
139
+
140
+		// let's remove any existing [TICKET_LIST] (or related) shortcode from the attendee list template so that we don't get recursion.
141
+		$template = str_replace('[TICKET_LIST]', '', $template);
142
+		$template = str_replace('[RECIPIENT_TICKET_LIST]', '', $template);
143
+		$template = str_replace('[PRIMARY_REGISTRANT_TICKET_LIST]', '', $template);
144
+
145
+		// here we're setting up the attendees for the attendee_list template for THIS ticket.
146
+		$att_result = '';
147
+		$registrations = isset($this->_extra_data['data']->tickets) ? $this->_extra_data['data']->tickets[ $ticket->ID(
148
+		) ]['reg_objs'] : array();
149
+
150
+		// each attendee in this case should be an attendee object.
151
+		foreach ($registrations as $registration) {
152
+			$att_result .= $this->_shortcode_helper->parse_attendee_list_template(
153
+				$template,
154
+				$registration,
155
+				$valid_shortcodes,
156
+				$this->_extra_data
157
+			);
158
+		}
159
+
160
+		return $att_result;
161
+	}
162
+
163
+
164
+	private function _get_registrations_from_event(EE_Event $event)
165
+	{
166
+		return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
167
+		) ]['reg_objs'] : array();
168
+	}
169 169
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Ticket_List_Shortcodes.lib.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -20,195 +20,195 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    protected function _init_props()
24
-    {
25
-        $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso');
26
-        $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso');
27
-        $this->_shortcodes = array(
28
-            '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'),
29
-        );
30
-    }
31
-
32
-
33
-    /**
34
-     * @param string $shortcode
35
-     * @return string
36
-     * @throws EE_Error
37
-     * @throws ReflectionException
38
-     */
39
-    protected function _parser($shortcode)
40
-    {
41
-        switch ($shortcode) {
42
-            case '[TICKET_LIST]':
43
-                return $this->_get_ticket_list();
44
-        }
45
-        return '';
46
-    }
47
-
48
-
49
-    /**
50
-     * figure out what the incoming data is and then return the appropriate parsed value.
51
-     *
52
-     * @return string
53
-     * @throws EE_Error
54
-     * @throws ReflectionException
55
-     */
56
-    private function _get_ticket_list()
57
-    {
58
-        $this->_validate_list_requirements();
59
-
60
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
61
-            return $this->_get_ticket_list_for_main();
62
-        } elseif ($this->_data['data'] instanceof EE_Registration) {
63
-            return $this->_get_ticket_list_for_attendee();
64
-        } elseif ($this->_data['data'] instanceof EE_Event) {
65
-            return $this->_get_ticket_list_for_event();
66
-        }
67
-        // prevent recursive loop
68
-        return '';
69
-    }
70
-
71
-
72
-    /**
73
-     * This returns the parsed ticket list for main template;
74
-     */
75
-    private function _get_ticket_list_for_main()
76
-    {
77
-        $valid_shortcodes = array(
78
-            'ticket',
79
-            'event_list',
80
-            'attendee_list',
81
-            'datetime_list',
82
-            'attendee',
83
-            'line_item_list',
84
-            'primary_registration_details',
85
-            'recipient_details',
86
-        );
87
-        $template = $this->_data['template'];
88
-        $data = $this->_data['data'];
89
-        $tktparsed = '';
90
-
91
-
92
-        // now we need to loop through the ticket list and send data to the EE_Parser helper.
93
-        foreach ($data->tickets as $ticket) {
94
-            $tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
95
-                $template,
96
-                $ticket['ticket'],
97
-                $valid_shortcodes,
98
-                $this->_extra_data
99
-            );
100
-        }
101
-
102
-        return $tktparsed;
103
-    }
104
-
105
-
106
-    /**
107
-     * return parsed list of tickets for an event
108
-     *
109
-     * @return string
110
-     */
111
-    private function _get_ticket_list_for_event()
112
-    {
113
-        $valid_shortcodes = array(
114
-            'ticket',
115
-            'attendee_list',
116
-            'datetime_list',
117
-            'attendee',
118
-            'venue',
119
-            'line_item_list',
120
-            'primary_registration_details',
121
-            'recipient_details',
122
-        );
123
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
124
-            ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
125
-        $event = $this->_data['data'];
126
-
127
-        // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion.
128
-        $template = str_replace('[EVENT_LIST]', '', $template);
129
-
130
-        // here we're setting up the tickets for the ticket list template for THIS event.
131
-        $tkt_parsed = '';
132
-        $tickets = $this->_get_tickets_from_event($event);
133
-
134
-        // each ticket in this case should be an ticket object.
135
-        foreach ($tickets as $ticket) {
136
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
137
-                $template,
138
-                $ticket,
139
-                $valid_shortcodes,
140
-                $this->_extra_data
141
-            );
142
-        }
143
-
144
-        return $tkt_parsed;
145
-    }
146
-
147
-
148
-    /**
149
-     * return parsed list of tickets for an attendee
150
-     *
151
-     * @return string
152
-     * @throws EE_Error
153
-     * @throws ReflectionException
154
-     */
155
-    private function _get_ticket_list_for_attendee()
156
-    {
157
-        $valid_shortcodes = array(
158
-            'ticket',
159
-            'event_list',
160
-            'datetime_list',
161
-            'attendee',
162
-            'primary_registration_details',
163
-            'recipient_details',
164
-        );
165
-
166
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
167
-            ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
168
-        $registration = $this->_data['data'];
169
-
170
-        // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion.
171
-        $template = str_replace('[ATTENDEE_LIST]', '', $template);
172
-
173
-        // here we're setting up the tickets for the ticket list template for THIS attendee.
174
-        $tkt_parsed = '';
175
-        $tickets = $this->_get_ticket_list_from_registration($registration);
176
-
177
-        // each ticket in this case should be an ticket object.
178
-        foreach ($tickets as $ticket) {
179
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
180
-                $template,
181
-                $ticket,
182
-                $valid_shortcodes,
183
-                $this->_extra_data
184
-            );
185
-        }
186
-
187
-        return $tkt_parsed;
188
-    }
189
-
190
-
191
-    /**
192
-     * @param EE_Event $event
193
-     * @return array|mixed
194
-     */
195
-    private function _get_tickets_from_event(EE_Event $event)
196
-    {
197
-        return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
198
-        ) ]['tkt_objs'] : array();
199
-    }
200
-
201
-
202
-    /**
203
-     * @param EE_Registration $registration
204
-     * @param null            $att
205
-     * @return array
206
-     * @throws EE_Error
207
-     * @throws ReflectionException
208
-     */
209
-    private function _get_ticket_list_from_registration(EE_Registration $registration, $att = null)
210
-    {
211
-        return isset($this->_extra_data['data']->registrations)
212
-            ? array($this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']) : array();
213
-    }
23
+	protected function _init_props()
24
+	{
25
+		$this->label = esc_html__('Ticket List Shortcodes', 'event_espresso');
26
+		$this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso');
27
+		$this->_shortcodes = array(
28
+			'[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'),
29
+		);
30
+	}
31
+
32
+
33
+	/**
34
+	 * @param string $shortcode
35
+	 * @return string
36
+	 * @throws EE_Error
37
+	 * @throws ReflectionException
38
+	 */
39
+	protected function _parser($shortcode)
40
+	{
41
+		switch ($shortcode) {
42
+			case '[TICKET_LIST]':
43
+				return $this->_get_ticket_list();
44
+		}
45
+		return '';
46
+	}
47
+
48
+
49
+	/**
50
+	 * figure out what the incoming data is and then return the appropriate parsed value.
51
+	 *
52
+	 * @return string
53
+	 * @throws EE_Error
54
+	 * @throws ReflectionException
55
+	 */
56
+	private function _get_ticket_list()
57
+	{
58
+		$this->_validate_list_requirements();
59
+
60
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
61
+			return $this->_get_ticket_list_for_main();
62
+		} elseif ($this->_data['data'] instanceof EE_Registration) {
63
+			return $this->_get_ticket_list_for_attendee();
64
+		} elseif ($this->_data['data'] instanceof EE_Event) {
65
+			return $this->_get_ticket_list_for_event();
66
+		}
67
+		// prevent recursive loop
68
+		return '';
69
+	}
70
+
71
+
72
+	/**
73
+	 * This returns the parsed ticket list for main template;
74
+	 */
75
+	private function _get_ticket_list_for_main()
76
+	{
77
+		$valid_shortcodes = array(
78
+			'ticket',
79
+			'event_list',
80
+			'attendee_list',
81
+			'datetime_list',
82
+			'attendee',
83
+			'line_item_list',
84
+			'primary_registration_details',
85
+			'recipient_details',
86
+		);
87
+		$template = $this->_data['template'];
88
+		$data = $this->_data['data'];
89
+		$tktparsed = '';
90
+
91
+
92
+		// now we need to loop through the ticket list and send data to the EE_Parser helper.
93
+		foreach ($data->tickets as $ticket) {
94
+			$tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
95
+				$template,
96
+				$ticket['ticket'],
97
+				$valid_shortcodes,
98
+				$this->_extra_data
99
+			);
100
+		}
101
+
102
+		return $tktparsed;
103
+	}
104
+
105
+
106
+	/**
107
+	 * return parsed list of tickets for an event
108
+	 *
109
+	 * @return string
110
+	 */
111
+	private function _get_ticket_list_for_event()
112
+	{
113
+		$valid_shortcodes = array(
114
+			'ticket',
115
+			'attendee_list',
116
+			'datetime_list',
117
+			'attendee',
118
+			'venue',
119
+			'line_item_list',
120
+			'primary_registration_details',
121
+			'recipient_details',
122
+		);
123
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
124
+			? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
125
+		$event = $this->_data['data'];
126
+
127
+		// let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion.
128
+		$template = str_replace('[EVENT_LIST]', '', $template);
129
+
130
+		// here we're setting up the tickets for the ticket list template for THIS event.
131
+		$tkt_parsed = '';
132
+		$tickets = $this->_get_tickets_from_event($event);
133
+
134
+		// each ticket in this case should be an ticket object.
135
+		foreach ($tickets as $ticket) {
136
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
137
+				$template,
138
+				$ticket,
139
+				$valid_shortcodes,
140
+				$this->_extra_data
141
+			);
142
+		}
143
+
144
+		return $tkt_parsed;
145
+	}
146
+
147
+
148
+	/**
149
+	 * return parsed list of tickets for an attendee
150
+	 *
151
+	 * @return string
152
+	 * @throws EE_Error
153
+	 * @throws ReflectionException
154
+	 */
155
+	private function _get_ticket_list_for_attendee()
156
+	{
157
+		$valid_shortcodes = array(
158
+			'ticket',
159
+			'event_list',
160
+			'datetime_list',
161
+			'attendee',
162
+			'primary_registration_details',
163
+			'recipient_details',
164
+		);
165
+
166
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
167
+			? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
168
+		$registration = $this->_data['data'];
169
+
170
+		// let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion.
171
+		$template = str_replace('[ATTENDEE_LIST]', '', $template);
172
+
173
+		// here we're setting up the tickets for the ticket list template for THIS attendee.
174
+		$tkt_parsed = '';
175
+		$tickets = $this->_get_ticket_list_from_registration($registration);
176
+
177
+		// each ticket in this case should be an ticket object.
178
+		foreach ($tickets as $ticket) {
179
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
180
+				$template,
181
+				$ticket,
182
+				$valid_shortcodes,
183
+				$this->_extra_data
184
+			);
185
+		}
186
+
187
+		return $tkt_parsed;
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param EE_Event $event
193
+	 * @return array|mixed
194
+	 */
195
+	private function _get_tickets_from_event(EE_Event $event)
196
+	{
197
+		return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
198
+		) ]['tkt_objs'] : array();
199
+	}
200
+
201
+
202
+	/**
203
+	 * @param EE_Registration $registration
204
+	 * @param null            $att
205
+	 * @return array
206
+	 * @throws EE_Error
207
+	 * @throws ReflectionException
208
+	 */
209
+	private function _get_ticket_list_from_registration(EE_Registration $registration, $att = null)
210
+	{
211
+		return isset($this->_extra_data['data']->registrations)
212
+			? array($this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']) : array();
213
+	}
214 214
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
      */
195 195
     private function _get_tickets_from_event(EE_Event $event)
196 196
     {
197
-        return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
198
-        ) ]['tkt_objs'] : array();
197
+        return isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
198
+        )]['tkt_objs'] : array();
199 199
     }
200 200
 
201 201
 
@@ -209,6 +209,6 @@  discard block
 block discarded – undo
209 209
     private function _get_ticket_list_from_registration(EE_Registration $registration, $att = null)
210 210
     {
211 211
         return isset($this->_extra_data['data']->registrations)
212
-            ? array($this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']) : array();
212
+            ? array($this->_extra_data['data']->registrations[$registration->ID()]['tkt_obj']) : array();
213 213
     }
214 214
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/ModelDataTranslator.php 1 patch
Indentation   +648 added lines, -648 removed lines patch added patch discarded remove patch
@@ -39,652 +39,652 @@
 block discarded – undo
39 39
 class ModelDataTranslator
40 40
 {
41 41
 
42
-    /**
43
-     * We used to use -1 for infinity in the rest api, but that's ambiguous for
44
-     * fields that COULD contain -1; so we use null
45
-     */
46
-    const EE_INF_IN_REST = null;
47
-
48
-
49
-    /**
50
-     * Prepares a possible array of input values from JSON for use by the models
51
-     *
52
-     * @param EE_Model_Field_Base $field_obj
53
-     * @param mixed               $original_value_maybe_array
54
-     * @param string              $requested_version
55
-     * @param string              $timezone_string treat values as being in this timezone
56
-     * @return mixed
57
-     * @throws RestException
58
-     * @throws EE_Error
59
-     */
60
-    public static function prepareFieldValuesFromJson(
61
-        $field_obj,
62
-        $original_value_maybe_array,
63
-        $requested_version,
64
-        $timezone_string = 'UTC'
65
-    ) {
66
-        if (is_array($original_value_maybe_array)
67
-            && ! $field_obj instanceof EE_Serialized_Text_Field
68
-        ) {
69
-            $new_value_maybe_array = array();
70
-            foreach ($original_value_maybe_array as $array_key => $array_item) {
71
-                $new_value_maybe_array[ $array_key ] = ModelDataTranslator::prepareFieldValueFromJson(
72
-                    $field_obj,
73
-                    $array_item,
74
-                    $requested_version,
75
-                    $timezone_string
76
-                );
77
-            }
78
-        } else {
79
-            $new_value_maybe_array = ModelDataTranslator::prepareFieldValueFromJson(
80
-                $field_obj,
81
-                $original_value_maybe_array,
82
-                $requested_version,
83
-                $timezone_string
84
-            );
85
-        }
86
-        return $new_value_maybe_array;
87
-    }
88
-
89
-
90
-    /**
91
-     * Prepares an array of field values FOR use in JSON/REST API
92
-     *
93
-     * @param EE_Model_Field_Base $field_obj
94
-     * @param mixed               $original_value_maybe_array
95
-     * @param string              $request_version (eg 4.8.36)
96
-     * @return array
97
-     * @throws EE_Error
98
-     * @throws EE_Error
99
-     */
100
-    public static function prepareFieldValuesForJson($field_obj, $original_value_maybe_array, $request_version)
101
-    {
102
-        if (is_array($original_value_maybe_array)) {
103
-            $new_value = array();
104
-            foreach ($original_value_maybe_array as $key => $value) {
105
-                $new_value[ $key ] = ModelDataTranslator::prepareFieldValuesForJson(
106
-                    $field_obj,
107
-                    $value,
108
-                    $request_version
109
-                );
110
-            }
111
-        } else {
112
-            $new_value = ModelDataTranslator::prepareFieldValueForJson(
113
-                $field_obj,
114
-                $original_value_maybe_array,
115
-                $request_version
116
-            );
117
-        }
118
-        return $new_value;
119
-    }
120
-
121
-
122
-    /**
123
-     * Prepares incoming data from the json or $_REQUEST parameters for the models'
124
-     * "$query_params".
125
-     *
126
-     * @param EE_Model_Field_Base $field_obj
127
-     * @param mixed               $original_value
128
-     * @param string              $requested_version
129
-     * @param string              $timezone_string treat values as being in this timezone
130
-     * @return mixed
131
-     * @throws RestException
132
-     * @throws DomainException
133
-     * @throws EE_Error
134
-     */
135
-    public static function prepareFieldValueFromJson(
136
-        $field_obj,
137
-        $original_value,
138
-        $requested_version,
139
-        $timezone_string = 'UTC' // UTC
140
-    ) {
141
-        // check if they accidentally submitted an error value. If so throw an exception
142
-        if (is_array($original_value)
143
-            && isset($original_value['error_code'], $original_value['error_message'])) {
144
-            throw new RestException(
145
-                'rest_submitted_error_value',
146
-                sprintf(
147
-                    esc_html__(
148
-                        'You tried to submit a JSON error object as a value for %1$s. That\'s not allowed.',
149
-                        'event_espresso'
150
-                    ),
151
-                    $field_obj->get_name()
152
-                ),
153
-                array(
154
-                    'status' => 400,
155
-                )
156
-            );
157
-        }
158
-        // double-check for serialized PHP. We never accept serialized PHP. No way Jose.
159
-        ModelDataTranslator::throwExceptionIfContainsSerializedData($original_value);
160
-        $timezone_string = $timezone_string !== '' ? $timezone_string : get_option('timezone_string', '');
161
-        $new_value = null;
162
-        // walk through the submitted data and double-check for serialized PHP. We never accept serialized PHP. No
163
-        // way Jose.
164
-        ModelDataTranslator::throwExceptionIfContainsSerializedData($original_value);
165
-        if ($field_obj instanceof EE_Infinite_Integer_Field
166
-            && in_array($original_value, array(null, ''), true)
167
-        ) {
168
-            $new_value = EE_INF;
169
-        } elseif ($field_obj instanceof EE_Datetime_Field) {
170
-            $new_value = rest_parse_date(
171
-                self::getTimestampWithTimezoneOffset($original_value, $field_obj, $timezone_string)
172
-            );
173
-            if ($new_value === false) {
174
-                throw new RestException(
175
-                    'invalid_format_for_timestamp',
176
-                    sprintf(
177
-                        esc_html__(
178
-                            'Timestamps received on a request as the value for Date and Time fields must be in %1$s/%2$s format.  The timestamp provided (%3$s) is not that format.',
179
-                            'event_espresso'
180
-                        ),
181
-                        'RFC3339',
182
-                        'ISO8601',
183
-                        $original_value
184
-                    ),
185
-                    array(
186
-                        'status' => 400,
187
-                    )
188
-                );
189
-            }
190
-        } elseif ($field_obj instanceof EE_Boolean_Field) {
191
-            // Interpreted the strings "false", "true", "on", "off" appropriately.
192
-            $new_value = filter_var($original_value, FILTER_VALIDATE_BOOLEAN);
193
-        } else {
194
-            $new_value = $original_value;
195
-        }
196
-        return $new_value;
197
-    }
198
-
199
-
200
-    /**
201
-     * This checks if the incoming timestamp has timezone information already on it and if it doesn't then adds timezone
202
-     * information via details obtained from the host site.
203
-     *
204
-     * @param string            $original_timestamp
205
-     * @param EE_Datetime_Field $datetime_field
206
-     * @param                   $timezone_string
207
-     * @return string
208
-     * @throws DomainException
209
-     */
210
-    private static function getTimestampWithTimezoneOffset(
211
-        $original_timestamp,
212
-        EE_Datetime_Field $datetime_field,
213
-        $timezone_string
214
-    ) {
215
-        // already have timezone information?
216
-        if (preg_match('/Z|(\+|\-)(\d{2}:\d{2})/', $original_timestamp)) {
217
-            // yes, we're ignoring the timezone.
218
-            return $original_timestamp;
219
-        }
220
-        // need to append timezone
221
-        list($offset_sign, $offset_secs) = self::parseTimezoneOffset(
222
-            $datetime_field->get_timezone_offset(
223
-                new \DateTimeZone($timezone_string),
224
-                $original_timestamp
225
-            )
226
-        );
227
-        $offset_string =
228
-            str_pad(
229
-                floor($offset_secs / HOUR_IN_SECONDS),
230
-                2,
231
-                '0',
232
-                STR_PAD_LEFT
233
-            )
234
-            . ':'
235
-            . str_pad(
236
-                ($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS,
237
-                2,
238
-                '0',
239
-                STR_PAD_LEFT
240
-            );
241
-        return $original_timestamp . $offset_sign . $offset_string;
242
-    }
243
-
244
-
245
-    /**
246
-     * Throws an exception if $data is a serialized PHP string (or somehow an actually PHP object, although I don't
247
-     * think that can happen). If $data is an array, recurses into its keys and values
248
-     *
249
-     * @param mixed $data
250
-     * @throws RestException
251
-     * @return void
252
-     */
253
-    public static function throwExceptionIfContainsSerializedData($data)
254
-    {
255
-        if (is_array($data)) {
256
-            foreach ($data as $key => $value) {
257
-                ModelDataTranslator::throwExceptionIfContainsSerializedData($key);
258
-                ModelDataTranslator::throwExceptionIfContainsSerializedData($value);
259
-            }
260
-        } else {
261
-            if (is_serialized($data) || is_object($data)) {
262
-                throw new RestException(
263
-                    'serialized_data_submission_prohibited',
264
-                    esc_html__(
265
-                    // @codingStandardsIgnoreStart
266
-                        'You tried to submit a string of serialized text. Serialized PHP is prohibited over the EE4 REST API.',
267
-                        // @codingStandardsIgnoreEnd
268
-                        'event_espresso'
269
-                    )
270
-                );
271
-            }
272
-        }
273
-    }
274
-
275
-
276
-    /**
277
-     * determines what's going on with them timezone strings
278
-     *
279
-     * @param int $timezone_offset
280
-     * @return array
281
-     */
282
-    private static function parseTimezoneOffset($timezone_offset)
283
-    {
284
-        $first_char = substr((string) $timezone_offset, 0, 1);
285
-        if ($first_char === '+' || $first_char === '-') {
286
-            $offset_sign = $first_char;
287
-            $offset_secs = substr((string) $timezone_offset, 1);
288
-        } else {
289
-            $offset_sign = '+';
290
-            $offset_secs = $timezone_offset;
291
-        }
292
-        return array($offset_sign, $offset_secs);
293
-    }
294
-
295
-
296
-    /**
297
-     * Prepares a field's value for display in the API
298
-     *
299
-     * @param EE_Model_Field_Base $field_obj
300
-     * @param mixed               $original_value
301
-     * @param string              $requested_version
302
-     * @return mixed
303
-     * @throws EE_Error
304
-     * @throws EE_Error
305
-     */
306
-    public static function prepareFieldValueForJson($field_obj, $original_value, $requested_version)
307
-    {
308
-        if ($original_value === EE_INF) {
309
-            $new_value = ModelDataTranslator::EE_INF_IN_REST;
310
-        } elseif ($field_obj instanceof EE_Datetime_Field) {
311
-            if (is_string($original_value)) {
312
-                // did they submit a string of a unix timestamp?
313
-                if (is_numeric($original_value)) {
314
-                    $datetime_obj = new \DateTime();
315
-                    $datetime_obj->setTimestamp((int) $original_value);
316
-                } else {
317
-                    // first, check if its a MySQL timestamp in GMT
318
-                    $datetime_obj = \DateTime::createFromFormat('Y-m-d H:i:s', $original_value);
319
-                }
320
-                if (! $datetime_obj instanceof \DateTime) {
321
-                    // so it's not a unix timestamp or a MySQL timestamp. Maybe its in the field's date/time format?
322
-                    $datetime_obj = $field_obj->prepare_for_set($original_value);
323
-                }
324
-                $original_value = $datetime_obj;
325
-            }
326
-            if ($original_value instanceof \DateTime) {
327
-                $new_value = $original_value->format('Y-m-d H:i:s');
328
-            } elseif (is_int($original_value) || is_float($original_value)) {
329
-                $new_value = date('Y-m-d H:i:s', $original_value);
330
-            } elseif ($original_value === null || $original_value === '') {
331
-                $new_value = null;
332
-            } else {
333
-                // so it's not a datetime object, unix timestamp (as string or int),
334
-                // MySQL timestamp, or even a string in the field object's format. So no idea what it is
335
-                throw new \EE_Error(
336
-                    sprintf(
337
-                        esc_html__(
338
-                        // @codingStandardsIgnoreStart
339
-                            'The value "%1$s" for the field "%2$s" on model "%3$s" could not be understood. It should be a PHP DateTime, unix timestamp, MySQL date, or string in the format "%4$s".',
340
-                            // @codingStandardsIgnoreEnd
341
-                            'event_espresso'
342
-                        ),
343
-                        $original_value,
344
-                        $field_obj->get_name(),
345
-                        $field_obj->get_model_name(),
346
-                        $field_obj->get_time_format() . ' ' . $field_obj->get_time_format()
347
-                    )
348
-                );
349
-            }
350
-            if ($new_value !== null) {
351
-                $new_value = mysql2date('Y-m-d\TH:i:s', $new_value, false);
352
-            }
353
-        } else {
354
-            $new_value = $original_value;
355
-        }
356
-        // are we about to send an object? just don't. We have no good way to represent it in JSON.
357
-        // can't just check using is_object() because that missed PHP incomplete objects
358
-        if (! ModelDataTranslator::isRepresentableInJson($new_value)) {
359
-            $new_value = array(
360
-                'error_code'    => 'php_object_not_return',
361
-                'error_message' => esc_html__(
362
-                    'The value of this field in the database is a PHP object, which can\'t be represented in JSON.',
363
-                    'event_espresso'
364
-                ),
365
-            );
366
-        }
367
-        return apply_filters(
368
-            'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
369
-            $new_value,
370
-            $field_obj,
371
-            $original_value,
372
-            $requested_version
373
-        );
374
-    }
375
-
376
-
377
-    /**
378
-     * Prepares condition-query-parameters (like what's in where and having) from
379
-     * the format expected in the API to use in the models
380
-     *
381
-     * @param array $inputted_query_params_of_this_type
382
-     * @param EEM_Base $model
383
-     * @param string $requested_version
384
-     * @param boolean $writing whether this data will be written to the DB, or if we're just building a query.
385
-     *                          If we're writing to the DB, we don't expect any operators, or any logic query
386
-     *                          parameters, and we also won't accept serialized data unless the current user has
387
-     *                          unfiltered_html.
388
-     * @return array
389
-     * @throws DomainException
390
-     * @throws EE_Error
391
-     * @throws RestException
392
-     * @throws InvalidDataTypeException
393
-     * @throws InvalidInterfaceException
394
-     * @throws InvalidArgumentException
395
-     */
396
-    public static function prepareConditionsQueryParamsForModels(
397
-        $inputted_query_params_of_this_type,
398
-        EEM_Base $model,
399
-        $requested_version,
400
-        $writing = false
401
-    ) {
402
-        $query_param_for_models = array();
403
-        $context = new RestIncomingQueryParamContext($model, $requested_version, $writing);
404
-        foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
405
-            $query_param_meta = new RestIncomingQueryParamMetadata($query_param_key, $query_param_value, $context);
406
-            if ($query_param_meta->getField() instanceof EE_Model_Field_Base) {
407
-                $translated_value = $query_param_meta->determineConditionsQueryParameterValue();
408
-                if ((isset($query_param_for_models[ $query_param_meta->getQueryParamKey() ]) && $query_param_meta->isGmtField())
409
-                    || $translated_value === null
410
-                ) {
411
-                    // they have already provided a non-gmt field, ignore the gmt one. That's what WP core
412
-                    // currently does (they might change it though). See https://core.trac.wordpress.org/ticket/39954
413
-                    // OR we couldn't create a translated value from their input
414
-                    continue;
415
-                }
416
-                $query_param_for_models[ $query_param_meta->getQueryParamKey() ] = $translated_value;
417
-            } else {
418
-                $nested_query_params = $query_param_meta->determineNestedConditionQueryParameters();
419
-                if ($nested_query_params) {
420
-                    $query_param_for_models[ $query_param_meta->getQueryParamKey() ] = $nested_query_params;
421
-                }
422
-            }
423
-        }
424
-        return $query_param_for_models;
425
-    }
426
-
427
-    /**
428
-     * Mostly checks if the last 4 characters are "_gmt", indicating its a
429
-     * gmt date field name
430
-     *
431
-     * @param string $field_name
432
-     * @return boolean
433
-     */
434
-    public static function isGmtDateFieldName($field_name)
435
-    {
436
-        return substr(
437
-            ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey($field_name),
438
-            -4,
439
-            4
440
-        ) === '_gmt';
441
-    }
442
-
443
-
444
-    /**
445
-     * Removes the last "_gmt" part of a field name (and if there is no "_gmt" at the end, leave it alone)
446
-     *
447
-     * @param string $field_name
448
-     * @return string
449
-     */
450
-    public static function removeGmtFromFieldName($field_name)
451
-    {
452
-        if (! ModelDataTranslator::isGmtDateFieldName($field_name)) {
453
-            return $field_name;
454
-        }
455
-        $query_param_sans_stars = ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey(
456
-            $field_name
457
-        );
458
-        $query_param_sans_gmt_and_sans_stars = substr(
459
-            $query_param_sans_stars,
460
-            0,
461
-            strrpos(
462
-                $field_name,
463
-                '_gmt'
464
-            )
465
-        );
466
-        return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name);
467
-    }
468
-
469
-
470
-    /**
471
-     * Takes a field name from the REST API and prepares it for the model querying
472
-     *
473
-     * @param string $field_name
474
-     * @return string
475
-     */
476
-    public static function prepareFieldNameFromJson($field_name)
477
-    {
478
-        if (ModelDataTranslator::isGmtDateFieldName($field_name)) {
479
-            return ModelDataTranslator::removeGmtFromFieldName($field_name);
480
-        }
481
-        return $field_name;
482
-    }
483
-
484
-
485
-    /**
486
-     * Takes array of field names from REST API and prepares for models
487
-     *
488
-     * @param array $field_names
489
-     * @return array of field names (possibly include model prefixes)
490
-     */
491
-    public static function prepareFieldNamesFromJson(array $field_names)
492
-    {
493
-        $new_array = array();
494
-        foreach ($field_names as $key => $field_name) {
495
-            $new_array[ $key ] = ModelDataTranslator::prepareFieldNameFromJson($field_name);
496
-        }
497
-        return $new_array;
498
-    }
499
-
500
-
501
-    /**
502
-     * Takes array where array keys are field names (possibly with model path prefixes)
503
-     * from the REST API and prepares them for model querying
504
-     *
505
-     * @param array $field_names_as_keys
506
-     * @return array
507
-     */
508
-    public static function prepareFieldNamesInArrayKeysFromJson(array $field_names_as_keys)
509
-    {
510
-        $new_array = array();
511
-        foreach ($field_names_as_keys as $field_name => $value) {
512
-            $new_array[ ModelDataTranslator::prepareFieldNameFromJson($field_name) ] = $value;
513
-        }
514
-        return $new_array;
515
-    }
516
-
517
-
518
-    /**
519
-     * Prepares an array of model query params for use in the REST API
520
-     *
521
-     * @param array    $model_query_params
522
-     * @param EEM_Base $model
523
-     * @param string   $requested_version  eg "4.8.36". If null is provided, defaults to the latest release of the EE4
524
-     *                                     REST API
525
-     * @return array which can be passed into the EE4 REST API when querying a model resource
526
-     * @throws EE_Error
527
-     */
528
-    public static function prepareQueryParamsForRestApi(
529
-        array $model_query_params,
530
-        EEM_Base $model,
531
-        $requested_version = null
532
-    ) {
533
-        if ($requested_version === null) {
534
-            $requested_version = EED_Core_Rest_Api::latest_rest_api_version();
535
-        }
536
-        $rest_query_params = $model_query_params;
537
-        if (isset($model_query_params[0])) {
538
-            $rest_query_params['where'] = ModelDataTranslator::prepareConditionsQueryParamsForRestApi(
539
-                $model_query_params[0],
540
-                $model,
541
-                $requested_version
542
-            );
543
-            unset($rest_query_params[0]);
544
-        }
545
-        if (isset($model_query_params['having'])) {
546
-            $rest_query_params['having'] = ModelDataTranslator::prepareConditionsQueryParamsForRestApi(
547
-                $model_query_params['having'],
548
-                $model,
549
-                $requested_version
550
-            );
551
-        }
552
-        return apply_filters(
553
-            'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api',
554
-            $rest_query_params,
555
-            $model_query_params,
556
-            $model,
557
-            $requested_version
558
-        );
559
-    }
560
-
561
-
562
-    /**
563
-     * Prepares all the sub-conditions query parameters (eg having or where conditions) for use in the rest api
564
-     *
565
-     * @param array    $inputted_query_params_of_this_type  eg like the "where" or "having" conditions query params
566
-     *                                                      @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
567
-     * @param EEM_Base $model
568
-     * @param string   $requested_version                   eg "4.8.36"
569
-     * @return array ready for use in the rest api query params
570
-     * @throws EE_Error
571
-     * @throws ObjectDetectedException if somehow a PHP object were in the query params' values,
572
-     *                                                      (which would be really unusual)
573
-     */
574
-    public static function prepareConditionsQueryParamsForRestApi(
575
-        $inputted_query_params_of_this_type,
576
-        EEM_Base $model,
577
-        $requested_version
578
-    ) {
579
-        $query_param_for_models = array();
580
-        foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
581
-            $field = ModelDataTranslator::deduceFieldFromQueryParam(
582
-                ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey($query_param_key),
583
-                $model
584
-            );
585
-            if ($field instanceof EE_Model_Field_Base) {
586
-                // did they specify an operator?
587
-                if (is_array($query_param_value)) {
588
-                    $op = $query_param_value[0];
589
-                    $translated_value = array($op);
590
-                    if (isset($query_param_value[1])) {
591
-                        $value = $query_param_value[1];
592
-                        $translated_value[1] = ModelDataTranslator::prepareFieldValuesForJson(
593
-                            $field,
594
-                            $value,
595
-                            $requested_version
596
-                        );
597
-                    }
598
-                } else {
599
-                    $translated_value = ModelDataTranslator::prepareFieldValueForJson(
600
-                        $field,
601
-                        $query_param_value,
602
-                        $requested_version
603
-                    );
604
-                }
605
-                $query_param_for_models[ $query_param_key ] = $translated_value;
606
-            } else {
607
-                // so it's not for a field, assume it's a logic query param key
608
-                $query_param_for_models[ $query_param_key ] = ModelDataTranslator::prepareConditionsQueryParamsForRestApi(
609
-                    $query_param_value,
610
-                    $model,
611
-                    $requested_version
612
-                );
613
-            }
614
-        }
615
-        return $query_param_for_models;
616
-    }
617
-
618
-
619
-    /**
620
-     * @param $condition_query_param_key
621
-     * @return string
622
-     */
623
-    public static function removeStarsAndAnythingAfterFromConditionQueryParamKey($condition_query_param_key)
624
-    {
625
-        $pos_of_star = strpos($condition_query_param_key, '*');
626
-        if ($pos_of_star === false) {
627
-            return $condition_query_param_key;
628
-        } else {
629
-            $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
630
-            return $condition_query_param_sans_star;
631
-        }
632
-    }
633
-
634
-
635
-    /**
636
-     * Takes the input parameter and finds the model field that it indicates.
637
-     *
638
-     * @param string   $query_param_name like Registration.Transaction.TXN_ID, Event.Datetime.start_time, or REG_ID
639
-     * @param EEM_Base $model
640
-     * @return EE_Model_Field_Base
641
-     * @throws EE_Error
642
-     * @throws \ReflectionException
643
-     */
644
-    public static function deduceFieldFromQueryParam($query_param_name, EEM_Base $model)
645
-    {
646
-        // ok, now proceed with deducing which part is the model's name, and which is the field's name
647
-        // which will help us find the database table and column
648
-        $query_param_parts = explode('.', $query_param_name);
649
-        if (empty($query_param_parts)) {
650
-            throw new EE_Error(
651
-                sprintf(
652
-                    __(
653
-                        '_extract_column_name is empty when trying to extract column and table name from %s',
654
-                        'event_espresso'
655
-                    ),
656
-                    $query_param_name
657
-                )
658
-            );
659
-        }
660
-        $number_of_parts = count($query_param_parts);
661
-        $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
662
-        if ($number_of_parts === 1) {
663
-            $field_name = $last_query_param_part;
664
-        } else {// $number_of_parts >= 2
665
-            // the last part is the column name, and there are only 2parts. therefore...
666
-            $field_name = $last_query_param_part;
667
-            $model = \EE_Registry::instance()->load_model($query_param_parts[ $number_of_parts - 2 ]);
668
-        }
669
-        try {
670
-            return $model->field_settings_for($field_name, false);
671
-        } catch (EE_Error $e) {
672
-            return null;
673
-        }
674
-    }
675
-
676
-
677
-    /**
678
-     * Returns true if $data can be easily represented in JSON.
679
-     * Basically, objects and resources can't be represented in JSON easily.
680
-     *
681
-     * @param mixed $data
682
-     * @return bool
683
-     */
684
-    protected static function isRepresentableInJson($data)
685
-    {
686
-        return is_scalar($data)
687
-               || is_array($data)
688
-               || is_null($data);
689
-    }
42
+	/**
43
+	 * We used to use -1 for infinity in the rest api, but that's ambiguous for
44
+	 * fields that COULD contain -1; so we use null
45
+	 */
46
+	const EE_INF_IN_REST = null;
47
+
48
+
49
+	/**
50
+	 * Prepares a possible array of input values from JSON for use by the models
51
+	 *
52
+	 * @param EE_Model_Field_Base $field_obj
53
+	 * @param mixed               $original_value_maybe_array
54
+	 * @param string              $requested_version
55
+	 * @param string              $timezone_string treat values as being in this timezone
56
+	 * @return mixed
57
+	 * @throws RestException
58
+	 * @throws EE_Error
59
+	 */
60
+	public static function prepareFieldValuesFromJson(
61
+		$field_obj,
62
+		$original_value_maybe_array,
63
+		$requested_version,
64
+		$timezone_string = 'UTC'
65
+	) {
66
+		if (is_array($original_value_maybe_array)
67
+			&& ! $field_obj instanceof EE_Serialized_Text_Field
68
+		) {
69
+			$new_value_maybe_array = array();
70
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
71
+				$new_value_maybe_array[ $array_key ] = ModelDataTranslator::prepareFieldValueFromJson(
72
+					$field_obj,
73
+					$array_item,
74
+					$requested_version,
75
+					$timezone_string
76
+				);
77
+			}
78
+		} else {
79
+			$new_value_maybe_array = ModelDataTranslator::prepareFieldValueFromJson(
80
+				$field_obj,
81
+				$original_value_maybe_array,
82
+				$requested_version,
83
+				$timezone_string
84
+			);
85
+		}
86
+		return $new_value_maybe_array;
87
+	}
88
+
89
+
90
+	/**
91
+	 * Prepares an array of field values FOR use in JSON/REST API
92
+	 *
93
+	 * @param EE_Model_Field_Base $field_obj
94
+	 * @param mixed               $original_value_maybe_array
95
+	 * @param string              $request_version (eg 4.8.36)
96
+	 * @return array
97
+	 * @throws EE_Error
98
+	 * @throws EE_Error
99
+	 */
100
+	public static function prepareFieldValuesForJson($field_obj, $original_value_maybe_array, $request_version)
101
+	{
102
+		if (is_array($original_value_maybe_array)) {
103
+			$new_value = array();
104
+			foreach ($original_value_maybe_array as $key => $value) {
105
+				$new_value[ $key ] = ModelDataTranslator::prepareFieldValuesForJson(
106
+					$field_obj,
107
+					$value,
108
+					$request_version
109
+				);
110
+			}
111
+		} else {
112
+			$new_value = ModelDataTranslator::prepareFieldValueForJson(
113
+				$field_obj,
114
+				$original_value_maybe_array,
115
+				$request_version
116
+			);
117
+		}
118
+		return $new_value;
119
+	}
120
+
121
+
122
+	/**
123
+	 * Prepares incoming data from the json or $_REQUEST parameters for the models'
124
+	 * "$query_params".
125
+	 *
126
+	 * @param EE_Model_Field_Base $field_obj
127
+	 * @param mixed               $original_value
128
+	 * @param string              $requested_version
129
+	 * @param string              $timezone_string treat values as being in this timezone
130
+	 * @return mixed
131
+	 * @throws RestException
132
+	 * @throws DomainException
133
+	 * @throws EE_Error
134
+	 */
135
+	public static function prepareFieldValueFromJson(
136
+		$field_obj,
137
+		$original_value,
138
+		$requested_version,
139
+		$timezone_string = 'UTC' // UTC
140
+	) {
141
+		// check if they accidentally submitted an error value. If so throw an exception
142
+		if (is_array($original_value)
143
+			&& isset($original_value['error_code'], $original_value['error_message'])) {
144
+			throw new RestException(
145
+				'rest_submitted_error_value',
146
+				sprintf(
147
+					esc_html__(
148
+						'You tried to submit a JSON error object as a value for %1$s. That\'s not allowed.',
149
+						'event_espresso'
150
+					),
151
+					$field_obj->get_name()
152
+				),
153
+				array(
154
+					'status' => 400,
155
+				)
156
+			);
157
+		}
158
+		// double-check for serialized PHP. We never accept serialized PHP. No way Jose.
159
+		ModelDataTranslator::throwExceptionIfContainsSerializedData($original_value);
160
+		$timezone_string = $timezone_string !== '' ? $timezone_string : get_option('timezone_string', '');
161
+		$new_value = null;
162
+		// walk through the submitted data and double-check for serialized PHP. We never accept serialized PHP. No
163
+		// way Jose.
164
+		ModelDataTranslator::throwExceptionIfContainsSerializedData($original_value);
165
+		if ($field_obj instanceof EE_Infinite_Integer_Field
166
+			&& in_array($original_value, array(null, ''), true)
167
+		) {
168
+			$new_value = EE_INF;
169
+		} elseif ($field_obj instanceof EE_Datetime_Field) {
170
+			$new_value = rest_parse_date(
171
+				self::getTimestampWithTimezoneOffset($original_value, $field_obj, $timezone_string)
172
+			);
173
+			if ($new_value === false) {
174
+				throw new RestException(
175
+					'invalid_format_for_timestamp',
176
+					sprintf(
177
+						esc_html__(
178
+							'Timestamps received on a request as the value for Date and Time fields must be in %1$s/%2$s format.  The timestamp provided (%3$s) is not that format.',
179
+							'event_espresso'
180
+						),
181
+						'RFC3339',
182
+						'ISO8601',
183
+						$original_value
184
+					),
185
+					array(
186
+						'status' => 400,
187
+					)
188
+				);
189
+			}
190
+		} elseif ($field_obj instanceof EE_Boolean_Field) {
191
+			// Interpreted the strings "false", "true", "on", "off" appropriately.
192
+			$new_value = filter_var($original_value, FILTER_VALIDATE_BOOLEAN);
193
+		} else {
194
+			$new_value = $original_value;
195
+		}
196
+		return $new_value;
197
+	}
198
+
199
+
200
+	/**
201
+	 * This checks if the incoming timestamp has timezone information already on it and if it doesn't then adds timezone
202
+	 * information via details obtained from the host site.
203
+	 *
204
+	 * @param string            $original_timestamp
205
+	 * @param EE_Datetime_Field $datetime_field
206
+	 * @param                   $timezone_string
207
+	 * @return string
208
+	 * @throws DomainException
209
+	 */
210
+	private static function getTimestampWithTimezoneOffset(
211
+		$original_timestamp,
212
+		EE_Datetime_Field $datetime_field,
213
+		$timezone_string
214
+	) {
215
+		// already have timezone information?
216
+		if (preg_match('/Z|(\+|\-)(\d{2}:\d{2})/', $original_timestamp)) {
217
+			// yes, we're ignoring the timezone.
218
+			return $original_timestamp;
219
+		}
220
+		// need to append timezone
221
+		list($offset_sign, $offset_secs) = self::parseTimezoneOffset(
222
+			$datetime_field->get_timezone_offset(
223
+				new \DateTimeZone($timezone_string),
224
+				$original_timestamp
225
+			)
226
+		);
227
+		$offset_string =
228
+			str_pad(
229
+				floor($offset_secs / HOUR_IN_SECONDS),
230
+				2,
231
+				'0',
232
+				STR_PAD_LEFT
233
+			)
234
+			. ':'
235
+			. str_pad(
236
+				($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS,
237
+				2,
238
+				'0',
239
+				STR_PAD_LEFT
240
+			);
241
+		return $original_timestamp . $offset_sign . $offset_string;
242
+	}
243
+
244
+
245
+	/**
246
+	 * Throws an exception if $data is a serialized PHP string (or somehow an actually PHP object, although I don't
247
+	 * think that can happen). If $data is an array, recurses into its keys and values
248
+	 *
249
+	 * @param mixed $data
250
+	 * @throws RestException
251
+	 * @return void
252
+	 */
253
+	public static function throwExceptionIfContainsSerializedData($data)
254
+	{
255
+		if (is_array($data)) {
256
+			foreach ($data as $key => $value) {
257
+				ModelDataTranslator::throwExceptionIfContainsSerializedData($key);
258
+				ModelDataTranslator::throwExceptionIfContainsSerializedData($value);
259
+			}
260
+		} else {
261
+			if (is_serialized($data) || is_object($data)) {
262
+				throw new RestException(
263
+					'serialized_data_submission_prohibited',
264
+					esc_html__(
265
+					// @codingStandardsIgnoreStart
266
+						'You tried to submit a string of serialized text. Serialized PHP is prohibited over the EE4 REST API.',
267
+						// @codingStandardsIgnoreEnd
268
+						'event_espresso'
269
+					)
270
+				);
271
+			}
272
+		}
273
+	}
274
+
275
+
276
+	/**
277
+	 * determines what's going on with them timezone strings
278
+	 *
279
+	 * @param int $timezone_offset
280
+	 * @return array
281
+	 */
282
+	private static function parseTimezoneOffset($timezone_offset)
283
+	{
284
+		$first_char = substr((string) $timezone_offset, 0, 1);
285
+		if ($first_char === '+' || $first_char === '-') {
286
+			$offset_sign = $first_char;
287
+			$offset_secs = substr((string) $timezone_offset, 1);
288
+		} else {
289
+			$offset_sign = '+';
290
+			$offset_secs = $timezone_offset;
291
+		}
292
+		return array($offset_sign, $offset_secs);
293
+	}
294
+
295
+
296
+	/**
297
+	 * Prepares a field's value for display in the API
298
+	 *
299
+	 * @param EE_Model_Field_Base $field_obj
300
+	 * @param mixed               $original_value
301
+	 * @param string              $requested_version
302
+	 * @return mixed
303
+	 * @throws EE_Error
304
+	 * @throws EE_Error
305
+	 */
306
+	public static function prepareFieldValueForJson($field_obj, $original_value, $requested_version)
307
+	{
308
+		if ($original_value === EE_INF) {
309
+			$new_value = ModelDataTranslator::EE_INF_IN_REST;
310
+		} elseif ($field_obj instanceof EE_Datetime_Field) {
311
+			if (is_string($original_value)) {
312
+				// did they submit a string of a unix timestamp?
313
+				if (is_numeric($original_value)) {
314
+					$datetime_obj = new \DateTime();
315
+					$datetime_obj->setTimestamp((int) $original_value);
316
+				} else {
317
+					// first, check if its a MySQL timestamp in GMT
318
+					$datetime_obj = \DateTime::createFromFormat('Y-m-d H:i:s', $original_value);
319
+				}
320
+				if (! $datetime_obj instanceof \DateTime) {
321
+					// so it's not a unix timestamp or a MySQL timestamp. Maybe its in the field's date/time format?
322
+					$datetime_obj = $field_obj->prepare_for_set($original_value);
323
+				}
324
+				$original_value = $datetime_obj;
325
+			}
326
+			if ($original_value instanceof \DateTime) {
327
+				$new_value = $original_value->format('Y-m-d H:i:s');
328
+			} elseif (is_int($original_value) || is_float($original_value)) {
329
+				$new_value = date('Y-m-d H:i:s', $original_value);
330
+			} elseif ($original_value === null || $original_value === '') {
331
+				$new_value = null;
332
+			} else {
333
+				// so it's not a datetime object, unix timestamp (as string or int),
334
+				// MySQL timestamp, or even a string in the field object's format. So no idea what it is
335
+				throw new \EE_Error(
336
+					sprintf(
337
+						esc_html__(
338
+						// @codingStandardsIgnoreStart
339
+							'The value "%1$s" for the field "%2$s" on model "%3$s" could not be understood. It should be a PHP DateTime, unix timestamp, MySQL date, or string in the format "%4$s".',
340
+							// @codingStandardsIgnoreEnd
341
+							'event_espresso'
342
+						),
343
+						$original_value,
344
+						$field_obj->get_name(),
345
+						$field_obj->get_model_name(),
346
+						$field_obj->get_time_format() . ' ' . $field_obj->get_time_format()
347
+					)
348
+				);
349
+			}
350
+			if ($new_value !== null) {
351
+				$new_value = mysql2date('Y-m-d\TH:i:s', $new_value, false);
352
+			}
353
+		} else {
354
+			$new_value = $original_value;
355
+		}
356
+		// are we about to send an object? just don't. We have no good way to represent it in JSON.
357
+		// can't just check using is_object() because that missed PHP incomplete objects
358
+		if (! ModelDataTranslator::isRepresentableInJson($new_value)) {
359
+			$new_value = array(
360
+				'error_code'    => 'php_object_not_return',
361
+				'error_message' => esc_html__(
362
+					'The value of this field in the database is a PHP object, which can\'t be represented in JSON.',
363
+					'event_espresso'
364
+				),
365
+			);
366
+		}
367
+		return apply_filters(
368
+			'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
369
+			$new_value,
370
+			$field_obj,
371
+			$original_value,
372
+			$requested_version
373
+		);
374
+	}
375
+
376
+
377
+	/**
378
+	 * Prepares condition-query-parameters (like what's in where and having) from
379
+	 * the format expected in the API to use in the models
380
+	 *
381
+	 * @param array $inputted_query_params_of_this_type
382
+	 * @param EEM_Base $model
383
+	 * @param string $requested_version
384
+	 * @param boolean $writing whether this data will be written to the DB, or if we're just building a query.
385
+	 *                          If we're writing to the DB, we don't expect any operators, or any logic query
386
+	 *                          parameters, and we also won't accept serialized data unless the current user has
387
+	 *                          unfiltered_html.
388
+	 * @return array
389
+	 * @throws DomainException
390
+	 * @throws EE_Error
391
+	 * @throws RestException
392
+	 * @throws InvalidDataTypeException
393
+	 * @throws InvalidInterfaceException
394
+	 * @throws InvalidArgumentException
395
+	 */
396
+	public static function prepareConditionsQueryParamsForModels(
397
+		$inputted_query_params_of_this_type,
398
+		EEM_Base $model,
399
+		$requested_version,
400
+		$writing = false
401
+	) {
402
+		$query_param_for_models = array();
403
+		$context = new RestIncomingQueryParamContext($model, $requested_version, $writing);
404
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
405
+			$query_param_meta = new RestIncomingQueryParamMetadata($query_param_key, $query_param_value, $context);
406
+			if ($query_param_meta->getField() instanceof EE_Model_Field_Base) {
407
+				$translated_value = $query_param_meta->determineConditionsQueryParameterValue();
408
+				if ((isset($query_param_for_models[ $query_param_meta->getQueryParamKey() ]) && $query_param_meta->isGmtField())
409
+					|| $translated_value === null
410
+				) {
411
+					// they have already provided a non-gmt field, ignore the gmt one. That's what WP core
412
+					// currently does (they might change it though). See https://core.trac.wordpress.org/ticket/39954
413
+					// OR we couldn't create a translated value from their input
414
+					continue;
415
+				}
416
+				$query_param_for_models[ $query_param_meta->getQueryParamKey() ] = $translated_value;
417
+			} else {
418
+				$nested_query_params = $query_param_meta->determineNestedConditionQueryParameters();
419
+				if ($nested_query_params) {
420
+					$query_param_for_models[ $query_param_meta->getQueryParamKey() ] = $nested_query_params;
421
+				}
422
+			}
423
+		}
424
+		return $query_param_for_models;
425
+	}
426
+
427
+	/**
428
+	 * Mostly checks if the last 4 characters are "_gmt", indicating its a
429
+	 * gmt date field name
430
+	 *
431
+	 * @param string $field_name
432
+	 * @return boolean
433
+	 */
434
+	public static function isGmtDateFieldName($field_name)
435
+	{
436
+		return substr(
437
+			ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey($field_name),
438
+			-4,
439
+			4
440
+		) === '_gmt';
441
+	}
442
+
443
+
444
+	/**
445
+	 * Removes the last "_gmt" part of a field name (and if there is no "_gmt" at the end, leave it alone)
446
+	 *
447
+	 * @param string $field_name
448
+	 * @return string
449
+	 */
450
+	public static function removeGmtFromFieldName($field_name)
451
+	{
452
+		if (! ModelDataTranslator::isGmtDateFieldName($field_name)) {
453
+			return $field_name;
454
+		}
455
+		$query_param_sans_stars = ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey(
456
+			$field_name
457
+		);
458
+		$query_param_sans_gmt_and_sans_stars = substr(
459
+			$query_param_sans_stars,
460
+			0,
461
+			strrpos(
462
+				$field_name,
463
+				'_gmt'
464
+			)
465
+		);
466
+		return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name);
467
+	}
468
+
469
+
470
+	/**
471
+	 * Takes a field name from the REST API and prepares it for the model querying
472
+	 *
473
+	 * @param string $field_name
474
+	 * @return string
475
+	 */
476
+	public static function prepareFieldNameFromJson($field_name)
477
+	{
478
+		if (ModelDataTranslator::isGmtDateFieldName($field_name)) {
479
+			return ModelDataTranslator::removeGmtFromFieldName($field_name);
480
+		}
481
+		return $field_name;
482
+	}
483
+
484
+
485
+	/**
486
+	 * Takes array of field names from REST API and prepares for models
487
+	 *
488
+	 * @param array $field_names
489
+	 * @return array of field names (possibly include model prefixes)
490
+	 */
491
+	public static function prepareFieldNamesFromJson(array $field_names)
492
+	{
493
+		$new_array = array();
494
+		foreach ($field_names as $key => $field_name) {
495
+			$new_array[ $key ] = ModelDataTranslator::prepareFieldNameFromJson($field_name);
496
+		}
497
+		return $new_array;
498
+	}
499
+
500
+
501
+	/**
502
+	 * Takes array where array keys are field names (possibly with model path prefixes)
503
+	 * from the REST API and prepares them for model querying
504
+	 *
505
+	 * @param array $field_names_as_keys
506
+	 * @return array
507
+	 */
508
+	public static function prepareFieldNamesInArrayKeysFromJson(array $field_names_as_keys)
509
+	{
510
+		$new_array = array();
511
+		foreach ($field_names_as_keys as $field_name => $value) {
512
+			$new_array[ ModelDataTranslator::prepareFieldNameFromJson($field_name) ] = $value;
513
+		}
514
+		return $new_array;
515
+	}
516
+
517
+
518
+	/**
519
+	 * Prepares an array of model query params for use in the REST API
520
+	 *
521
+	 * @param array    $model_query_params
522
+	 * @param EEM_Base $model
523
+	 * @param string   $requested_version  eg "4.8.36". If null is provided, defaults to the latest release of the EE4
524
+	 *                                     REST API
525
+	 * @return array which can be passed into the EE4 REST API when querying a model resource
526
+	 * @throws EE_Error
527
+	 */
528
+	public static function prepareQueryParamsForRestApi(
529
+		array $model_query_params,
530
+		EEM_Base $model,
531
+		$requested_version = null
532
+	) {
533
+		if ($requested_version === null) {
534
+			$requested_version = EED_Core_Rest_Api::latest_rest_api_version();
535
+		}
536
+		$rest_query_params = $model_query_params;
537
+		if (isset($model_query_params[0])) {
538
+			$rest_query_params['where'] = ModelDataTranslator::prepareConditionsQueryParamsForRestApi(
539
+				$model_query_params[0],
540
+				$model,
541
+				$requested_version
542
+			);
543
+			unset($rest_query_params[0]);
544
+		}
545
+		if (isset($model_query_params['having'])) {
546
+			$rest_query_params['having'] = ModelDataTranslator::prepareConditionsQueryParamsForRestApi(
547
+				$model_query_params['having'],
548
+				$model,
549
+				$requested_version
550
+			);
551
+		}
552
+		return apply_filters(
553
+			'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api',
554
+			$rest_query_params,
555
+			$model_query_params,
556
+			$model,
557
+			$requested_version
558
+		);
559
+	}
560
+
561
+
562
+	/**
563
+	 * Prepares all the sub-conditions query parameters (eg having or where conditions) for use in the rest api
564
+	 *
565
+	 * @param array    $inputted_query_params_of_this_type  eg like the "where" or "having" conditions query params
566
+	 *                                                      @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
567
+	 * @param EEM_Base $model
568
+	 * @param string   $requested_version                   eg "4.8.36"
569
+	 * @return array ready for use in the rest api query params
570
+	 * @throws EE_Error
571
+	 * @throws ObjectDetectedException if somehow a PHP object were in the query params' values,
572
+	 *                                                      (which would be really unusual)
573
+	 */
574
+	public static function prepareConditionsQueryParamsForRestApi(
575
+		$inputted_query_params_of_this_type,
576
+		EEM_Base $model,
577
+		$requested_version
578
+	) {
579
+		$query_param_for_models = array();
580
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
581
+			$field = ModelDataTranslator::deduceFieldFromQueryParam(
582
+				ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey($query_param_key),
583
+				$model
584
+			);
585
+			if ($field instanceof EE_Model_Field_Base) {
586
+				// did they specify an operator?
587
+				if (is_array($query_param_value)) {
588
+					$op = $query_param_value[0];
589
+					$translated_value = array($op);
590
+					if (isset($query_param_value[1])) {
591
+						$value = $query_param_value[1];
592
+						$translated_value[1] = ModelDataTranslator::prepareFieldValuesForJson(
593
+							$field,
594
+							$value,
595
+							$requested_version
596
+						);
597
+					}
598
+				} else {
599
+					$translated_value = ModelDataTranslator::prepareFieldValueForJson(
600
+						$field,
601
+						$query_param_value,
602
+						$requested_version
603
+					);
604
+				}
605
+				$query_param_for_models[ $query_param_key ] = $translated_value;
606
+			} else {
607
+				// so it's not for a field, assume it's a logic query param key
608
+				$query_param_for_models[ $query_param_key ] = ModelDataTranslator::prepareConditionsQueryParamsForRestApi(
609
+					$query_param_value,
610
+					$model,
611
+					$requested_version
612
+				);
613
+			}
614
+		}
615
+		return $query_param_for_models;
616
+	}
617
+
618
+
619
+	/**
620
+	 * @param $condition_query_param_key
621
+	 * @return string
622
+	 */
623
+	public static function removeStarsAndAnythingAfterFromConditionQueryParamKey($condition_query_param_key)
624
+	{
625
+		$pos_of_star = strpos($condition_query_param_key, '*');
626
+		if ($pos_of_star === false) {
627
+			return $condition_query_param_key;
628
+		} else {
629
+			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
630
+			return $condition_query_param_sans_star;
631
+		}
632
+	}
633
+
634
+
635
+	/**
636
+	 * Takes the input parameter and finds the model field that it indicates.
637
+	 *
638
+	 * @param string   $query_param_name like Registration.Transaction.TXN_ID, Event.Datetime.start_time, or REG_ID
639
+	 * @param EEM_Base $model
640
+	 * @return EE_Model_Field_Base
641
+	 * @throws EE_Error
642
+	 * @throws \ReflectionException
643
+	 */
644
+	public static function deduceFieldFromQueryParam($query_param_name, EEM_Base $model)
645
+	{
646
+		// ok, now proceed with deducing which part is the model's name, and which is the field's name
647
+		// which will help us find the database table and column
648
+		$query_param_parts = explode('.', $query_param_name);
649
+		if (empty($query_param_parts)) {
650
+			throw new EE_Error(
651
+				sprintf(
652
+					__(
653
+						'_extract_column_name is empty when trying to extract column and table name from %s',
654
+						'event_espresso'
655
+					),
656
+					$query_param_name
657
+				)
658
+			);
659
+		}
660
+		$number_of_parts = count($query_param_parts);
661
+		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
662
+		if ($number_of_parts === 1) {
663
+			$field_name = $last_query_param_part;
664
+		} else {// $number_of_parts >= 2
665
+			// the last part is the column name, and there are only 2parts. therefore...
666
+			$field_name = $last_query_param_part;
667
+			$model = \EE_Registry::instance()->load_model($query_param_parts[ $number_of_parts - 2 ]);
668
+		}
669
+		try {
670
+			return $model->field_settings_for($field_name, false);
671
+		} catch (EE_Error $e) {
672
+			return null;
673
+		}
674
+	}
675
+
676
+
677
+	/**
678
+	 * Returns true if $data can be easily represented in JSON.
679
+	 * Basically, objects and resources can't be represented in JSON easily.
680
+	 *
681
+	 * @param mixed $data
682
+	 * @return bool
683
+	 */
684
+	protected static function isRepresentableInJson($data)
685
+	{
686
+		return is_scalar($data)
687
+			   || is_array($data)
688
+			   || is_null($data);
689
+	}
690 690
 }
Please login to merge, or discard this patch.