Completed
Branch rest-authorization (c7240a)
by
unknown
13:01 queued 10:45
created
core/libraries/shortcodes/EE_Event_Shortcodes.lib.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
         // If there is no event objecdt by now then get out.
137
-        if (! $this->_event instanceof EE_Event) {
137
+        if ( ! $this->_event instanceof EE_Event) {
138 138
             return '';
139 139
         }
140 140
 
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
                 $image = $this->_event->feature_image_url(array(600, 300));
188 188
                 // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189 189
                 return ! empty($image)
190
-                    ? '<img src="' . $image . '" alt="'
190
+                    ? '<img src="'.$image.'" alt="'
191 191
                       . sprintf(
192 192
                           esc_attr__('%s Feature Image', 'event_espresso'),
193 193
                           $this->_event->get('EVT_name')
194
-                      ) . '" />'
194
+                      ).'" />'
195 195
                     : '';
196 196
                 break;
197 197
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
254 254
             if (
255 255
                 apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
256
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
256
+                || ! empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
257 257
             ) {
258 258
                 return do_shortcode($event_meta);
259 259
             }
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 
272 272
         if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
273 273
             $attrs = $this->_get_shortcode_attrs($shortcode);
274
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
275
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
274
+            $width = empty($attrs['width']) ? '' : ' width="'.$attrs['width'].'"';
275
+            $height = empty($attrs['height']) ? '' : ' height="'.$attrs['height'].'"';
276 276
 
277 277
             // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
278
-            if (! empty($attrs['size'])) {
278
+            if ( ! empty($attrs['size'])) {
279 279
                 $size = explode(',', $attrs['size']);
280 280
                 if (count($size) === 1) {
281 281
                     $size = $size[0];
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
             $image = $this->_event->feature_image_url($size);
288 288
 
289 289
             return ! empty($image)
290
-                ? '<img src="' . $image . '" alt="'
290
+                ? '<img src="'.$image.'" alt="'
291 291
                   . sprintf(
292 292
                       esc_attr__('%s Feature Image', 'event_espresso'),
293 293
                       $this->_event->get('EVT_name')
294
-                  ) . '"' . $width . $height . '/>'
294
+                  ).'"'.$width.$height.'/>'
295 295
                 : '';
296 296
         }
297 297
 
@@ -310,6 +310,6 @@  discard block
 block discarded – undo
310 310
     {
311 311
         $url = get_permalink($event->ID());
312 312
 
313
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
313
+        return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url;
314 314
     }
315 315
 }
Please login to merge, or discard this patch.
Indentation   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -17,297 +17,297 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Event_Shortcodes extends EE_Shortcodes
19 19
 {
20
-    /**
21
-     * Will hold the EE_Event if available
22
-     *
23
-     * @var EE_Event
24
-     */
25
-    protected $_event;
26
-
27
-
28
-    public function __construct()
29
-    {
30
-        parent::__construct();
31
-    }
32
-
33
-
34
-    protected function _init_props()
35
-    {
36
-        $this->label = esc_html__('Event Shortcodes', 'event_espresso');
37
-        $this->description = esc_html__('All shortcodes specific to event related data', 'event_espresso');
38
-        $this->_shortcodes = array(
39
-            '[EVENT_ID]'                              => esc_html__(
40
-                'Will be replaced by the event ID of an event',
41
-                'event_espresso'
42
-            ),
43
-            '[EVENT]'                                 => esc_html__('The name of the event', 'event_espresso'),
44
-            '[EVENT_NAME]'                            => esc_html__(
45
-                "This also can be used for the name of the event",
46
-                'event_espresso'
47
-            ),
48
-            '[EVENT_PHONE]'                           => esc_html__(
49
-                'The phone number for the event (usually an info number)',
50
-                'event_espresso'
51
-            ),
52
-            '[EVENT_DESCRIPTION]'                     => esc_html__('The description of the event', 'event_espresso'),
53
-            '[EVENT_EXCERPT]'                         => esc_html__(
54
-                'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.',
55
-                'event_espresso'
56
-            ),
57
-            '[EVENT_LINK]'                            => esc_html__('A link associated with the event', 'event_espresso'),
58
-            '[EVENT_URL]'                             => esc_html__(
59
-                'A link to the event set up on the host site.',
60
-                'event_espresso'
61
-            ),
62
-            '[VIRTUAL_URL]'                           => esc_html__(
63
-                'What was used for the "URL of Event" field in the Venue settings',
64
-                'event_espresso'
65
-            ),
66
-            '[VIRTUAL_PHONE]'                         => esc_html__(
67
-                'An alternate phone number for the event. Typically used as a "call-in" number',
68
-                'event_espresso'
69
-            ),
70
-            '[EVENT_IMAGE]'                           => esc_html__(
71
-                'This will parse to the Feature image for the event.',
72
-                'event_espresso'
73
-            ),
74
-            '[EVENT_IMAGE_*]'                         => sprintf(
75
-                esc_html__(
76
-                    'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.',
77
-                    'event_espresso'
78
-                ),
79
-                '<code>',
80
-                '</code>'
81
-            ),
82
-            '[EVENT_TOTAL_AVAILABLE_SPACES_*]'        => sprintf(
83
-                esc_html__(
84
-                    'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.',
85
-                    'event_espresso'
86
-                ),
87
-                '<code>',
88
-                '</code>'
89
-            ),
90
-            '[EVENT_TOTAL_SPOTS_TAKEN]'               => esc_html__(
91
-                'This shortcode will parse to the output the total approved registrations for this event',
92
-                'event_espresso'
93
-            ),
94
-            '[EVENT_FACEBOOK_URL]'                    => esc_html__(
95
-                'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.',
96
-                'event_espresso'
97
-            ),
98
-            '[EVENT_TWITTER_URL]'                     => esc_html__(
99
-                'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url',
100
-                'event_espresso'
101
-            ),
102
-            '[EVENT_META_*]'                          => sprintf(
103
-                esc_html__(
104
-                    'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ',
105
-                    'event_espresso'
106
-                ),
107
-                '<code>',
108
-                '</code>'
109
-            ),
110
-            '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => esc_html__(
111
-                'This parses to the url for the registration list table filtered by registrations for this event.',
112
-                'event_espresso'
113
-            ),
114
-        );
115
-    }
116
-
117
-
118
-    protected function _parser($shortcode)
119
-    {
120
-
121
-
122
-        $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
123
-
124
-        // if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
125
-        if (empty($this->_event)) {
126
-            $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
127
-            $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
128
-
129
-            $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
130
-                ? $aee->reg_obj->event() : null;
131
-        }
132
-
133
-
134
-        // If there is no event objecdt by now then get out.
135
-        if (! $this->_event instanceof EE_Event) {
136
-            return '';
137
-        }
138
-
139
-        switch ($shortcode) {
140
-            case '[EVENT_ID]':
141
-                return $this->_event->ID();
142
-                break;
143
-
144
-            case '[EVENT]':
145
-            case '[EVENT_NAME]':
146
-                return $this->_event->get('EVT_name');
147
-                break;
148
-
149
-            case '[EVENT_PHONE]':
150
-                return $this->_event->get('EVT_phone');
151
-                break;
152
-
153
-            case '[EVENT_DESCRIPTION]':
154
-                return $this->_event->get('EVT_desc');
155
-                break;
156
-
157
-            case '[EVENT_EXCERPT]':
158
-                return $this->_event->get('EVT_short_desc');
159
-                break;
160
-
161
-            case '[EVENT_LINK]':
162
-                return $this->_get_event_link($this->_event);
163
-                break;
164
-
165
-            case '[EVENT_URL]':
166
-                return $this->_get_event_link($this->_event, false);
167
-                break;
168
-
169
-            case '[VIRTUAL_URL]':
170
-                $venue = $this->_event->get_first_related('Venue');
171
-                if (empty($venue)) {
172
-                    return '';
173
-                }
174
-                return $venue->get('VNU_virtual_url');
175
-
176
-            case '[VIRTUAL_PHONE]':
177
-                $venue = $this->_event->get_first_related('Venue');
178
-                if (empty($venue)) {
179
-                    return '';
180
-                }
181
-                return $venue->get('VNU_virtual_phone');
182
-                break;
183
-
184
-            case '[EVENT_IMAGE]':
185
-                $image = $this->_event->feature_image_url(array(600, 300));
186
-                // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
187
-                return ! empty($image)
188
-                    ? '<img src="' . $image . '" alt="'
189
-                      . sprintf(
190
-                          esc_attr__('%s Feature Image', 'event_espresso'),
191
-                          $this->_event->get('EVT_name')
192
-                      ) . '" />'
193
-                    : '';
194
-                break;
195
-
196
-            case '[EVENT_FACEBOOK_URL]':
197
-                $facebook_url = $this->_event->get_post_meta('event_facebook', true);
198
-                return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
199
-                    : $facebook_url;
200
-                break;
201
-
202
-            case '[EVENT_TWITTER_URL]':
203
-                $twitter_url = $this->_event->get_post_meta('event_twitter', true);
204
-                return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
205
-                    : $twitter_url;
206
-                break;
207
-
208
-            case '[EVENT_AUTHOR_EMAIL]':
209
-                $author_id = $this->_event->get('EVT_wp_user');
210
-                $user_data = get_userdata((int) $author_id);
211
-                return $user_data->user_email;
212
-                break;
213
-
214
-            case '[EVENT_TOTAL_SPOTS_TAKEN]':
215
-                return EEM_Registration::instance()->count(
216
-                    array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
217
-                    'REG_ID',
218
-                    true
219
-                );
220
-                break;
221
-
222
-            case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
223
-                return EEH_URL::add_query_args_and_nonce(
224
-                    array(
225
-                        'event_id' => $this->_event->ID(),
226
-                        'page'     => 'espresso_registrations',
227
-                        'action'   => 'default',
228
-                    ),
229
-                    admin_url('admin.php'),
230
-                    true
231
-                );
232
-                break;
233
-        }
234
-
235
-        if (strpos($shortcode, '[EVENT_META_*') !== false) {
236
-            // Strip the shortcode itself from $shortcode leaving any attributes set.
237
-            // Removing the * is correct here as _* is used to indiciate a dynamic shortcode.
238
-            $shortcode = str_replace('[EVENT_META_*', '', $shortcode);
239
-            $shortcode = trim(str_replace(']', '', $shortcode));
240
-            // Get any attributes set on this shortcode.
241
-            $attrs = $this->_get_shortcode_attrs($shortcode);
242
-            // The meta_key set on the shortcode should always be the first value in the array.
243
-            $meta_key = $attrs[0];
244
-            // Pull the meta value from the event post.
245
-            $event_meta = $this->_event->get_post_meta($meta_key, true);
246
-            // If we have no event_meta, just return an empty string.
247
-            if (empty($event_meta)) {
248
-                return '';
249
-            }
250
-            // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
251
-            // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
252
-            if (
253
-                apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
254
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
255
-            ) {
256
-                return do_shortcode($event_meta);
257
-            }
258
-            // Still here? We just need to return the event_meta value as is.
259
-            return $event_meta;
260
-        }
261
-
262
-        if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
263
-            $attrs = $this->_get_shortcode_attrs($shortcode);
264
-            $method = empty($attrs['method']) ? 'current' : $attrs['method'];
265
-            $method = $method === 'current';
266
-            $available = $this->_event->total_available_spaces($method);
267
-            return $available === EE_INF ? '&infin;' : $available;
268
-        }
269
-
270
-        if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
271
-            $attrs = $this->_get_shortcode_attrs($shortcode);
272
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
273
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
274
-
275
-            // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
276
-            if (! empty($attrs['size'])) {
277
-                $size = explode(',', $attrs['size']);
278
-                if (count($size) === 1) {
279
-                    $size = $size[0];
280
-                }
281
-            } else {
282
-                $size = 'thumbnail';
283
-            }
284
-
285
-            $image = $this->_event->feature_image_url($size);
286
-
287
-            return ! empty($image)
288
-                ? '<img src="' . $image . '" alt="'
289
-                  . sprintf(
290
-                      esc_attr__('%s Feature Image', 'event_espresso'),
291
-                      $this->_event->get('EVT_name')
292
-                  ) . '"' . $width . $height . '/>'
293
-                : '';
294
-        }
295
-
296
-        return '';
297
-    }
298
-
299
-
300
-    /**
301
-     * returns the link to the event
302
-     *
303
-     * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
304
-     *                            Otherwise we just return the url of the event.
305
-     * @return string
306
-     */
307
-    private function _get_event_link($event, $full_link = true)
308
-    {
309
-        $url = get_permalink($event->ID());
310
-
311
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
312
-    }
20
+	/**
21
+	 * Will hold the EE_Event if available
22
+	 *
23
+	 * @var EE_Event
24
+	 */
25
+	protected $_event;
26
+
27
+
28
+	public function __construct()
29
+	{
30
+		parent::__construct();
31
+	}
32
+
33
+
34
+	protected function _init_props()
35
+	{
36
+		$this->label = esc_html__('Event Shortcodes', 'event_espresso');
37
+		$this->description = esc_html__('All shortcodes specific to event related data', 'event_espresso');
38
+		$this->_shortcodes = array(
39
+			'[EVENT_ID]'                              => esc_html__(
40
+				'Will be replaced by the event ID of an event',
41
+				'event_espresso'
42
+			),
43
+			'[EVENT]'                                 => esc_html__('The name of the event', 'event_espresso'),
44
+			'[EVENT_NAME]'                            => esc_html__(
45
+				"This also can be used for the name of the event",
46
+				'event_espresso'
47
+			),
48
+			'[EVENT_PHONE]'                           => esc_html__(
49
+				'The phone number for the event (usually an info number)',
50
+				'event_espresso'
51
+			),
52
+			'[EVENT_DESCRIPTION]'                     => esc_html__('The description of the event', 'event_espresso'),
53
+			'[EVENT_EXCERPT]'                         => esc_html__(
54
+				'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.',
55
+				'event_espresso'
56
+			),
57
+			'[EVENT_LINK]'                            => esc_html__('A link associated with the event', 'event_espresso'),
58
+			'[EVENT_URL]'                             => esc_html__(
59
+				'A link to the event set up on the host site.',
60
+				'event_espresso'
61
+			),
62
+			'[VIRTUAL_URL]'                           => esc_html__(
63
+				'What was used for the "URL of Event" field in the Venue settings',
64
+				'event_espresso'
65
+			),
66
+			'[VIRTUAL_PHONE]'                         => esc_html__(
67
+				'An alternate phone number for the event. Typically used as a "call-in" number',
68
+				'event_espresso'
69
+			),
70
+			'[EVENT_IMAGE]'                           => esc_html__(
71
+				'This will parse to the Feature image for the event.',
72
+				'event_espresso'
73
+			),
74
+			'[EVENT_IMAGE_*]'                         => sprintf(
75
+				esc_html__(
76
+					'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.',
77
+					'event_espresso'
78
+				),
79
+				'<code>',
80
+				'</code>'
81
+			),
82
+			'[EVENT_TOTAL_AVAILABLE_SPACES_*]'        => sprintf(
83
+				esc_html__(
84
+					'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.',
85
+					'event_espresso'
86
+				),
87
+				'<code>',
88
+				'</code>'
89
+			),
90
+			'[EVENT_TOTAL_SPOTS_TAKEN]'               => esc_html__(
91
+				'This shortcode will parse to the output the total approved registrations for this event',
92
+				'event_espresso'
93
+			),
94
+			'[EVENT_FACEBOOK_URL]'                    => esc_html__(
95
+				'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.',
96
+				'event_espresso'
97
+			),
98
+			'[EVENT_TWITTER_URL]'                     => esc_html__(
99
+				'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url',
100
+				'event_espresso'
101
+			),
102
+			'[EVENT_META_*]'                          => sprintf(
103
+				esc_html__(
104
+					'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ',
105
+					'event_espresso'
106
+				),
107
+				'<code>',
108
+				'</code>'
109
+			),
110
+			'[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => esc_html__(
111
+				'This parses to the url for the registration list table filtered by registrations for this event.',
112
+				'event_espresso'
113
+			),
114
+		);
115
+	}
116
+
117
+
118
+	protected function _parser($shortcode)
119
+	{
120
+
121
+
122
+		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
123
+
124
+		// if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
125
+		if (empty($this->_event)) {
126
+			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
127
+			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
128
+
129
+			$this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
130
+				? $aee->reg_obj->event() : null;
131
+		}
132
+
133
+
134
+		// If there is no event objecdt by now then get out.
135
+		if (! $this->_event instanceof EE_Event) {
136
+			return '';
137
+		}
138
+
139
+		switch ($shortcode) {
140
+			case '[EVENT_ID]':
141
+				return $this->_event->ID();
142
+				break;
143
+
144
+			case '[EVENT]':
145
+			case '[EVENT_NAME]':
146
+				return $this->_event->get('EVT_name');
147
+				break;
148
+
149
+			case '[EVENT_PHONE]':
150
+				return $this->_event->get('EVT_phone');
151
+				break;
152
+
153
+			case '[EVENT_DESCRIPTION]':
154
+				return $this->_event->get('EVT_desc');
155
+				break;
156
+
157
+			case '[EVENT_EXCERPT]':
158
+				return $this->_event->get('EVT_short_desc');
159
+				break;
160
+
161
+			case '[EVENT_LINK]':
162
+				return $this->_get_event_link($this->_event);
163
+				break;
164
+
165
+			case '[EVENT_URL]':
166
+				return $this->_get_event_link($this->_event, false);
167
+				break;
168
+
169
+			case '[VIRTUAL_URL]':
170
+				$venue = $this->_event->get_first_related('Venue');
171
+				if (empty($venue)) {
172
+					return '';
173
+				}
174
+				return $venue->get('VNU_virtual_url');
175
+
176
+			case '[VIRTUAL_PHONE]':
177
+				$venue = $this->_event->get_first_related('Venue');
178
+				if (empty($venue)) {
179
+					return '';
180
+				}
181
+				return $venue->get('VNU_virtual_phone');
182
+				break;
183
+
184
+			case '[EVENT_IMAGE]':
185
+				$image = $this->_event->feature_image_url(array(600, 300));
186
+				// @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
187
+				return ! empty($image)
188
+					? '<img src="' . $image . '" alt="'
189
+					  . sprintf(
190
+						  esc_attr__('%s Feature Image', 'event_espresso'),
191
+						  $this->_event->get('EVT_name')
192
+					  ) . '" />'
193
+					: '';
194
+				break;
195
+
196
+			case '[EVENT_FACEBOOK_URL]':
197
+				$facebook_url = $this->_event->get_post_meta('event_facebook', true);
198
+				return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
199
+					: $facebook_url;
200
+				break;
201
+
202
+			case '[EVENT_TWITTER_URL]':
203
+				$twitter_url = $this->_event->get_post_meta('event_twitter', true);
204
+				return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
205
+					: $twitter_url;
206
+				break;
207
+
208
+			case '[EVENT_AUTHOR_EMAIL]':
209
+				$author_id = $this->_event->get('EVT_wp_user');
210
+				$user_data = get_userdata((int) $author_id);
211
+				return $user_data->user_email;
212
+				break;
213
+
214
+			case '[EVENT_TOTAL_SPOTS_TAKEN]':
215
+				return EEM_Registration::instance()->count(
216
+					array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
217
+					'REG_ID',
218
+					true
219
+				);
220
+				break;
221
+
222
+			case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
223
+				return EEH_URL::add_query_args_and_nonce(
224
+					array(
225
+						'event_id' => $this->_event->ID(),
226
+						'page'     => 'espresso_registrations',
227
+						'action'   => 'default',
228
+					),
229
+					admin_url('admin.php'),
230
+					true
231
+				);
232
+				break;
233
+		}
234
+
235
+		if (strpos($shortcode, '[EVENT_META_*') !== false) {
236
+			// Strip the shortcode itself from $shortcode leaving any attributes set.
237
+			// Removing the * is correct here as _* is used to indiciate a dynamic shortcode.
238
+			$shortcode = str_replace('[EVENT_META_*', '', $shortcode);
239
+			$shortcode = trim(str_replace(']', '', $shortcode));
240
+			// Get any attributes set on this shortcode.
241
+			$attrs = $this->_get_shortcode_attrs($shortcode);
242
+			// The meta_key set on the shortcode should always be the first value in the array.
243
+			$meta_key = $attrs[0];
244
+			// Pull the meta value from the event post.
245
+			$event_meta = $this->_event->get_post_meta($meta_key, true);
246
+			// If we have no event_meta, just return an empty string.
247
+			if (empty($event_meta)) {
248
+				return '';
249
+			}
250
+			// Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
251
+			// Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
252
+			if (
253
+				apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
254
+				|| !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
255
+			) {
256
+				return do_shortcode($event_meta);
257
+			}
258
+			// Still here? We just need to return the event_meta value as is.
259
+			return $event_meta;
260
+		}
261
+
262
+		if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
263
+			$attrs = $this->_get_shortcode_attrs($shortcode);
264
+			$method = empty($attrs['method']) ? 'current' : $attrs['method'];
265
+			$method = $method === 'current';
266
+			$available = $this->_event->total_available_spaces($method);
267
+			return $available === EE_INF ? '&infin;' : $available;
268
+		}
269
+
270
+		if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
271
+			$attrs = $this->_get_shortcode_attrs($shortcode);
272
+			$width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
273
+			$height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
274
+
275
+			// Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
276
+			if (! empty($attrs['size'])) {
277
+				$size = explode(',', $attrs['size']);
278
+				if (count($size) === 1) {
279
+					$size = $size[0];
280
+				}
281
+			} else {
282
+				$size = 'thumbnail';
283
+			}
284
+
285
+			$image = $this->_event->feature_image_url($size);
286
+
287
+			return ! empty($image)
288
+				? '<img src="' . $image . '" alt="'
289
+				  . sprintf(
290
+					  esc_attr__('%s Feature Image', 'event_espresso'),
291
+					  $this->_event->get('EVT_name')
292
+				  ) . '"' . $width . $height . '/>'
293
+				: '';
294
+		}
295
+
296
+		return '';
297
+	}
298
+
299
+
300
+	/**
301
+	 * returns the link to the event
302
+	 *
303
+	 * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
304
+	 *                            Otherwise we just return the url of the event.
305
+	 * @return string
306
+	 */
307
+	private function _get_event_link($event, $full_link = true)
308
+	{
309
+		$url = get_permalink($event->ID());
310
+
311
+		return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
312
+	}
313 313
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Primary_Registration_List_Shortcodes.lib.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
84 84
     {
85 85
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
86
-        if (! $registration instanceof EE_Registration) {
86
+        if ( ! $registration instanceof EE_Registration) {
87 87
             return '';
88 88
         }
89 89
         // setup valid shortcodes depending on what the status of the $this->_data property is
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 'attendee',
98 98
             );
99 99
             $template = $this->_data['template'];
100
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
100
+            $tkts = array($data->registrations[$registration->ID()]['tkt_obj']);
101 101
             $data = $this->_data;
102 102
         } elseif ($this->_data['data'] instanceof EE_Event) {
103 103
             $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 
128 128
     private function _get_tickets_from_event(EE_Event $event, $reg = null)
129 129
     {
130
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
131
-        ) ]['tkt_objs'] : array();
130
+        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
131
+        )]['tkt_objs'] : array();
132 132
 
133 133
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
134 134
             $adj_tkts = array();
135 135
             // return only tickets for the given attendee
136 136
             foreach ($evt_tkts as $tkt) {
137 137
                 if (
138
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
139
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
138
+                    isset($this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'])
139
+                    && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID()
140 140
                 ) {
141 141
                     $adj_tkts[] = $tkt;
142 142
                 }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
     private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
173 173
     {
174 174
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
175
-        if (! $registration instanceof EE_Registration) {
175
+        if ( ! $registration instanceof EE_Registration) {
176 176
             return '';
177 177
         }
178 178
         // setup valid shortcodes depending on what the status of the $this->_data property is
179 179
         if ($this->_data['data'] instanceof EE_Messages_Addressee) {
180 180
             $valid_shortcodes = array('datetime', 'attendee');
181 181
             $template = $this->_data['template'];
182
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
+            $dtts = $data->registrations[$registration->ID()]['dtt_objs'];
183 183
             $data = $this->_data;
184 184
         } elseif ($this->_data['data'] instanceof EE_Event) {
185 185
             $valid_shortcodes = array('datetime', 'attendee');
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 
207 207
     private function _get_datetimes_from_event(EE_Event $event, $reg = null)
208 208
     {
209
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
210
-        ) ]['dtt_objs'] : array();
209
+        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
210
+        )]['dtt_objs'] : array();
211 211
 
212 212
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
213 213
             $adj_dtts = array();
214 214
             // return only dtts for the given attendee
215 215
             foreach ($evt_dtts as $dtt) {
216
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
+                if (isset($this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()])) {
217 217
                     $adj_dtts[] = $dtt;
218 218
                 }
219 219
             }
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -18,206 +18,206 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Primary_Registration_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    public function __construct()
22
-    {
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-    protected function _init_props()
28
-    {
29
-        $this->label = esc_html__('Primary Registrant List Shortcodes', 'event_espresso');
30
-        $this->description = esc_html__(
31
-            'All shortcodes specific primary registrant recipients list type data.',
32
-            'event_espresso'
33
-        );
34
-        $this->_shortcodes = array(
35
-            '[PRIMARY_REGISTRANT_TICKET_LIST]' => esc_html__(
36
-                'Will output a list of tickets that the primary registration received.',
37
-                'event_espresso'
38
-            ),
39
-            '[PRIMARY_REGISTRANT_DATETIME_LIST]' => esc_html__(
40
-                'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
41
-                'event_espresso'
42
-            ),
43
-        );
44
-    }
45
-
46
-
47
-    protected function _parser($shortcode)
48
-    {
49
-        switch ($shortcode) {
50
-            case '[PRIMARY_REGISTRANT_TICKET_LIST]':
51
-                return $this->_get_recipient_ticket_list(true);
52
-                break;
53
-
54
-            case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
55
-                return $this->_get_recipient_datetime_list(true);
56
-                break;
57
-        }
58
-        return '';
59
-    }
60
-
61
-
62
-    /**
63
-     * figure out what the incoming data is and then return the appropriate parsed value
64
-     *
65
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
66
-     * @return string
67
-     */
68
-    private function _get_recipient_ticket_list($primary = false)
69
-    {
70
-        $this->_validate_list_requirements();
71
-
72
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
73
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
74
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
75
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
76
-        } else {
77
-            return '';
78
-        }
79
-    }
80
-
81
-
82
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
83
-    {
84
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
85
-        if (! $registration instanceof EE_Registration) {
86
-            return '';
87
-        }
88
-        // setup valid shortcodes depending on what the status of the $this->_data property is
89
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
90
-            $valid_shortcodes = array(
91
-                'ticket',
92
-                'event_list',
93
-                'attendee_list',
94
-                'datetime_list',
95
-                'registration_details',
96
-                'attendee',
97
-            );
98
-            $template = $this->_data['template'];
99
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
100
-            $data = $this->_data;
101
-        } elseif ($this->_data['data'] instanceof EE_Event) {
102
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
103
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
104
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
105
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
106
-            $template = str_replace('[EVENT_LIST]', '', $template);
107
-            // data will be tickets for this event for this recipient.
108
-            $tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
109
-            $data = $this->_extra_data;
110
-        } else {
111
-            return '';
112
-        }
113
-
114
-        $tktparsed = '';
115
-        foreach ($tkts as $ticket) {
116
-            $tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
117
-                $template,
118
-                $ticket,
119
-                $valid_shortcodes,
120
-                $data
121
-            );
122
-        }
123
-        return $tktparsed;
124
-    }
125
-
126
-
127
-    private function _get_tickets_from_event(EE_Event $event, $reg = null)
128
-    {
129
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
130
-        ) ]['tkt_objs'] : array();
131
-
132
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
133
-            $adj_tkts = array();
134
-            // return only tickets for the given attendee
135
-            foreach ($evt_tkts as $tkt) {
136
-                if (
137
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
138
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
139
-                ) {
140
-                    $adj_tkts[] = $tkt;
141
-                }
142
-            }
143
-            $evt_tkts = $adj_tkts;
144
-        }
145
-        return $evt_tkts;
146
-    }
147
-
148
-
149
-    /**
150
-     * figure out what the incoming data is and then return the appropriate parsed value
151
-     *
152
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
153
-     * @return string
154
-     */
155
-    private function _get_recipient_datetime_list($primary = false)
156
-    {
157
-        $this->_validate_list_requirements();
158
-
159
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
161
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
163
-        } else {
164
-            return '';
165
-        }
166
-
167
-        return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
168
-    }
169
-
170
-
171
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
172
-    {
173
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
174
-        if (! $registration instanceof EE_Registration) {
175
-            return '';
176
-        }
177
-        // setup valid shortcodes depending on what the status of the $this->_data property is
178
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
179
-            $valid_shortcodes = array('datetime', 'attendee');
180
-            $template = $this->_data['template'];
181
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
-            $data = $this->_data;
183
-        } elseif ($this->_data['data'] instanceof EE_Event) {
184
-            $valid_shortcodes = array('datetime', 'attendee');
185
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
186
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
187
-            $dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
188
-            $data = $this->_extra_data;
189
-        } else {
190
-            return '';
191
-        }
192
-
193
-        $dtt_parsed = '';
194
-        foreach ($dtts as $datetime) {
195
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
196
-                $template,
197
-                $datetime,
198
-                $valid_shortcodes,
199
-                $this->_extra_data
200
-            );
201
-        }
202
-        return $dtt_parsed;
203
-    }
204
-
205
-
206
-    private function _get_datetimes_from_event(EE_Event $event, $reg = null)
207
-    {
208
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
209
-        ) ]['dtt_objs'] : array();
210
-
211
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
212
-            $adj_dtts = array();
213
-            // return only dtts for the given attendee
214
-            foreach ($evt_dtts as $dtt) {
215
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
-                    $adj_dtts[] = $dtt;
217
-                }
218
-            }
219
-            $evt_dtts = $adj_dtts;
220
-        }
221
-        return $evt_dtts;
222
-    }
21
+	public function __construct()
22
+	{
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+	protected function _init_props()
28
+	{
29
+		$this->label = esc_html__('Primary Registrant List Shortcodes', 'event_espresso');
30
+		$this->description = esc_html__(
31
+			'All shortcodes specific primary registrant recipients list type data.',
32
+			'event_espresso'
33
+		);
34
+		$this->_shortcodes = array(
35
+			'[PRIMARY_REGISTRANT_TICKET_LIST]' => esc_html__(
36
+				'Will output a list of tickets that the primary registration received.',
37
+				'event_espresso'
38
+			),
39
+			'[PRIMARY_REGISTRANT_DATETIME_LIST]' => esc_html__(
40
+				'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
41
+				'event_espresso'
42
+			),
43
+		);
44
+	}
45
+
46
+
47
+	protected function _parser($shortcode)
48
+	{
49
+		switch ($shortcode) {
50
+			case '[PRIMARY_REGISTRANT_TICKET_LIST]':
51
+				return $this->_get_recipient_ticket_list(true);
52
+				break;
53
+
54
+			case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
55
+				return $this->_get_recipient_datetime_list(true);
56
+				break;
57
+		}
58
+		return '';
59
+	}
60
+
61
+
62
+	/**
63
+	 * figure out what the incoming data is and then return the appropriate parsed value
64
+	 *
65
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
66
+	 * @return string
67
+	 */
68
+	private function _get_recipient_ticket_list($primary = false)
69
+	{
70
+		$this->_validate_list_requirements();
71
+
72
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
73
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
74
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
75
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
76
+		} else {
77
+			return '';
78
+		}
79
+	}
80
+
81
+
82
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
83
+	{
84
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
85
+		if (! $registration instanceof EE_Registration) {
86
+			return '';
87
+		}
88
+		// setup valid shortcodes depending on what the status of the $this->_data property is
89
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
90
+			$valid_shortcodes = array(
91
+				'ticket',
92
+				'event_list',
93
+				'attendee_list',
94
+				'datetime_list',
95
+				'registration_details',
96
+				'attendee',
97
+			);
98
+			$template = $this->_data['template'];
99
+			$tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
100
+			$data = $this->_data;
101
+		} elseif ($this->_data['data'] instanceof EE_Event) {
102
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
103
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
104
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
105
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
106
+			$template = str_replace('[EVENT_LIST]', '', $template);
107
+			// data will be tickets for this event for this recipient.
108
+			$tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
109
+			$data = $this->_extra_data;
110
+		} else {
111
+			return '';
112
+		}
113
+
114
+		$tktparsed = '';
115
+		foreach ($tkts as $ticket) {
116
+			$tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
117
+				$template,
118
+				$ticket,
119
+				$valid_shortcodes,
120
+				$data
121
+			);
122
+		}
123
+		return $tktparsed;
124
+	}
125
+
126
+
127
+	private function _get_tickets_from_event(EE_Event $event, $reg = null)
128
+	{
129
+		$evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
130
+		) ]['tkt_objs'] : array();
131
+
132
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
133
+			$adj_tkts = array();
134
+			// return only tickets for the given attendee
135
+			foreach ($evt_tkts as $tkt) {
136
+				if (
137
+					isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
138
+					&& $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
139
+				) {
140
+					$adj_tkts[] = $tkt;
141
+				}
142
+			}
143
+			$evt_tkts = $adj_tkts;
144
+		}
145
+		return $evt_tkts;
146
+	}
147
+
148
+
149
+	/**
150
+	 * figure out what the incoming data is and then return the appropriate parsed value
151
+	 *
152
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
153
+	 * @return string
154
+	 */
155
+	private function _get_recipient_datetime_list($primary = false)
156
+	{
157
+		$this->_validate_list_requirements();
158
+
159
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
161
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
163
+		} else {
164
+			return '';
165
+		}
166
+
167
+		return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
168
+	}
169
+
170
+
171
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
172
+	{
173
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
174
+		if (! $registration instanceof EE_Registration) {
175
+			return '';
176
+		}
177
+		// setup valid shortcodes depending on what the status of the $this->_data property is
178
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
179
+			$valid_shortcodes = array('datetime', 'attendee');
180
+			$template = $this->_data['template'];
181
+			$dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
+			$data = $this->_data;
183
+		} elseif ($this->_data['data'] instanceof EE_Event) {
184
+			$valid_shortcodes = array('datetime', 'attendee');
185
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
186
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
187
+			$dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
188
+			$data = $this->_extra_data;
189
+		} else {
190
+			return '';
191
+		}
192
+
193
+		$dtt_parsed = '';
194
+		foreach ($dtts as $datetime) {
195
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
196
+				$template,
197
+				$datetime,
198
+				$valid_shortcodes,
199
+				$this->_extra_data
200
+			);
201
+		}
202
+		return $dtt_parsed;
203
+	}
204
+
205
+
206
+	private function _get_datetimes_from_event(EE_Event $event, $reg = null)
207
+	{
208
+		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
209
+		) ]['dtt_objs'] : array();
210
+
211
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
212
+			$adj_dtts = array();
213
+			// return only dtts for the given attendee
214
+			foreach ($evt_dtts as $dtt) {
215
+				if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
+					$adj_dtts[] = $dtt;
217
+				}
218
+			}
219
+			$evt_dtts = $adj_dtts;
220
+		}
221
+		return $evt_dtts;
222
+	}
223 223
 }
Please login to merge, or discard this patch.
libraries/shortcodes/EE_Primary_Registration_Details_Shortcodes.lib.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
         $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
100 100
             ? $this->_extra_data['data'] : $primary_registration;
101 101
 
102
-        if (! $primary_registration instanceof EE_Messages_Addressee) {
102
+        if ( ! $primary_registration instanceof EE_Messages_Addressee) {
103 103
             return '';
104 104
         }
105 105
 
106 106
         $attendee = $primary_registration->primary_att_obj;
107 107
         $primary_reg = $primary_registration->primary_reg_obj;
108 108
 
109
-        if (! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration) {
109
+        if ( ! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration) {
110 110
             return '';
111 111
         }
112 112
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                 break;
163 163
 
164 164
             case '[PRIMARY_REGISTRANT_REGISTRATION_DATE]':
165
-                if (! $primary_registration->primary_reg_obj instanceof EE_Registration) {
165
+                if ( ! $primary_registration->primary_reg_obj instanceof EE_Registration) {
166 166
                     return '';
167 167
                 }
168 168
                 return $primary_registration->primary_reg_obj->get_i18n_datetime('REG_date', get_option('date_format'));
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
                 if (
188 188
                     $question instanceof EE_Question
189 189
                     && trim($question->get('QST_display_text')) === trim($shortcode)
190
-                    && isset($primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ])
190
+                    && isset($primary_registration->registrations[$primary_reg->ID()]['ans_objs'][$ansid])
191 191
                 ) {
192
-                    $primary_reg_ansid = $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ];
192
+                    $primary_reg_ansid = $primary_registration->registrations[$primary_reg->ID()]['ans_objs'][$ansid];
193 193
 
194 194
                     // what we show for the answer depends on the question type!
195 195
                     switch ($question->get('QST_type')) {
Please login to merge, or discard this patch.
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -17,201 +17,201 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Primary_Registration_Details_Shortcodes extends EE_Shortcodes
19 19
 {
20
-    protected function _init_props()
21
-    {
22
-        $this->label = esc_html__('Primary_Registration Details Shortcodes', 'event_espresso');
23
-        $this->description = esc_html__('All shortcodes specific primary registrant data', 'event_espresso');
24
-        $this->_shortcodes = array(
25
-            '[PRIMARY_REGISTRANT_FNAME]'                  => esc_html__(
26
-                'Parses to the first name of the primary registration for the transaction.',
27
-                'event_espresso'
28
-            ),
29
-            '[PRIMARY_REGISTRANT_LNAME]'                  => esc_html__(
30
-                'Parses to the last name of the primary registration for the transaction.',
31
-                'event_espresso'
32
-            ),
33
-            '[PRIMARY_REGISTRANT_EMAIL]'                  => esc_html__(
34
-                'Parses to the email address of the primary registration for the transaction.',
35
-                'event_espresso'
36
-            ),
37
-            '[PRIMARY_REGISTRANT_REGISTRATION_ID]'        => esc_html__(
38
-                'Parses to the registration ID of the primary registrant for the transaction.',
39
-                'event_espresso'
40
-            ),
41
-            '[PRIMARY_REGISTRANT_REGISTRATION_CODE]'      => esc_html__(
42
-                'Parses to the registration code of the primary registrant for the transaction.',
43
-                'event_espresso'
44
-            ),
45
-            '[PRIMARY_REGISTRANT_PHONE_NUMBER]'           => esc_html__(
46
-                'The Phone Number for the primary registrant for the transaction.',
47
-                'event_espresso'
48
-            ),
49
-            '[PRIMARY_REGISTRANT_ADDRESS]'                => esc_html__(
50
-                'The Address for the primary registrant for the transaction.',
51
-                'event_espresso'
52
-            ),
53
-            '[PRIMARY_REGISTRANT_ADDRESS2]'               => esc_html__(
54
-                'Whatever was in the address 2 field for the primary registrant for the transaction.',
55
-                'event_espresso'
56
-            ),
57
-            '[PRIMARY_REGISTRANT_CITY]'                   => esc_html__(
58
-                'The city for the primary registrant for the transaction.',
59
-                'event_espresso'
60
-            ),
61
-            '[PRIMARY_REGISTRANT_ZIP_PC]'                 => esc_html__(
62
-                'The ZIP (or Postal) Code for the primary registrant for the transaction.',
63
-                'event_espresso'
64
-            ),
65
-            '[PRIMARY_REGISTRANT_ADDRESS_STATE]'          => esc_html__(
66
-                'The state/province for the primary registrant for the transaction.',
67
-                'event_espresso'
68
-            ),
69
-            '[PRIMARY_REGISTRANT_COUNTRY]'                => esc_html__(
70
-                'The country for the primary registrant for the transaction.',
71
-                'event_espresso'
72
-            ),
73
-            '[PRIMARY_REGISTRANT_REGISTRATION_DATE]'      => esc_html__(
74
-                'The date the registration occured for the primary registration.',
75
-                'event_espresso'
76
-            ),
77
-            '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]' => esc_html__(
78
-                'Generates a link for the given registration to edit this registration details on the frontend.',
79
-                'event_espresso'
80
-            ),
81
-            '[PRIMARY_REGISTRANT_ANSWER_*]'               => esc_html__(
82
-                'This is a special dynamic shortcode.  After the "*", add the exact text of an existing question, and if there is an answer for that question for this primary registrant, then it will be output in place of this shortcode.',
83
-                'event_espresso'
84
-            ),
85
-        );
86
-    }
87
-
88
-
89
-    protected function _parser($shortcode)
90
-    {
91
-        // make sure we end up with a copy of the EE_Messages_Addressee object
92
-        $primary_registration = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
93
-        $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && is_array(
94
-            $this->_data
95
-        ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data']
96
-            : $primary_registration;
97
-        $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
98
-            ? $this->_extra_data['data'] : $primary_registration;
99
-
100
-        if (! $primary_registration instanceof EE_Messages_Addressee) {
101
-            return '';
102
-        }
103
-
104
-        $attendee = $primary_registration->primary_att_obj;
105
-        $primary_reg = $primary_registration->primary_reg_obj;
106
-
107
-        if (! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration) {
108
-            return '';
109
-        }
110
-
111
-        switch ($shortcode) {
112
-            case '[PRIMARY_REGISTRANT_FNAME]':
113
-                return $attendee->fname();
114
-                break;
115
-
116
-            case '[PRIMARY_REGISTRANT_LNAME]':
117
-                return $attendee->lname();
118
-                break;
119
-
120
-            case '[PRIMARY_REGISTRANT_EMAIL]':
121
-                return $attendee->email();
122
-                break;
123
-
124
-            case '[PRIMARY_REGISTRANT_REGISTRATION_ID]':
125
-                return $primary_reg->ID();
126
-                break;
127
-
128
-            case '[PRIMARY_REGISTRANT_REGISTRATION_CODE]':
129
-                return $primary_reg->reg_code();
130
-                break;
131
-
132
-            case '[PRIMARY_REGISTRANT_PHONE_NUMBER]':
133
-                return $attendee->phone();
134
-                break;
135
-
136
-            case '[PRIMARY_REGISTRANT_ADDRESS]':
137
-                return $attendee->address();
138
-                break;
139
-
140
-            case '[PRIMARY_REGISTRANT_ADDRESS2]':
141
-                return $attendee->address2();
142
-                break;
143
-
144
-            case '[PRIMARY_REGISTRANT_CITY]':
145
-                return $attendee->city();
146
-                break;
147
-
148
-            case '[PRIMARY_REGISTRANT_ZIP_PC]':
149
-                return $attendee->zip();
150
-                break;
151
-
152
-            case '[PRIMARY_REGISTRANT_ADDRESS_STATE]':
153
-                $state_obj = $attendee->state_obj();
154
-                return $state_obj instanceof EE_State ? $state_obj->name() : '';
155
-                break;
156
-
157
-            case '[PRIMARY_REGISTRANT_COUNTRY]':
158
-                $country_obj = $attendee->country_obj();
159
-                return $country_obj instanceof EE_Country ? $country_obj->name() : '';
160
-                break;
161
-
162
-            case '[PRIMARY_REGISTRANT_REGISTRATION_DATE]':
163
-                if (! $primary_registration->primary_reg_obj instanceof EE_Registration) {
164
-                    return '';
165
-                }
166
-                return $primary_registration->primary_reg_obj->get_i18n_datetime('REG_date', get_option('date_format'));
167
-                break;
168
-
169
-            case '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]':
170
-                return $primary_reg->edit_attendee_information_url();
171
-                break;
172
-        }
173
-
174
-        if (strpos($shortcode, '[PRIMARY_REGISTRANT_ANSWER_*') !== false) {
175
-            $shortcode = str_replace('[PRIMARY_REGISTRANT_ANSWER_*', '', $shortcode);
176
-            $shortcode = trim(str_replace(']', '', $shortcode));
177
-
178
-
179
-            // now let's figure out what question has this text
180
-            if (empty($primary_registration->questions)) {
181
-                return '';
182
-            }
183
-
184
-            foreach ($primary_registration->questions as $ansid => $question) {
185
-                if (
186
-                    $question instanceof EE_Question
187
-                    && trim($question->get('QST_display_text')) === trim($shortcode)
188
-                    && isset($primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ])
189
-                ) {
190
-                    $primary_reg_ansid = $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ];
191
-
192
-                    // what we show for the answer depends on the question type!
193
-                    switch ($question->get('QST_type')) {
194
-                        case EEM_Question::QST_type_state:
195
-                            $state = EEM_State::instance()->get_one_by_ID($primary_reg_ansid->get('ANS_value'));
196
-                            $answer = $state instanceof EE_State ? $state->name() : '';
197
-                            break;
198
-
199
-                        case EEM_Question::QST_type_country:
200
-                            $country = EEM_Country::instance()->get_one_by_ID($primary_reg_ansid->get('ANS_value'));
201
-                            $answer = $country instanceof EE_Country ? $country->name() : '';
202
-                            break;
203
-
204
-                        default:
205
-                            $answer = $primary_reg_ansid->get_pretty('ANS_value', 'no_wpautop');
206
-                            break;
207
-                    }
208
-
209
-                    return $answer;
210
-                    break;
211
-                }
212
-            }
213
-        }
214
-
215
-        return '';
216
-    }
20
+	protected function _init_props()
21
+	{
22
+		$this->label = esc_html__('Primary_Registration Details Shortcodes', 'event_espresso');
23
+		$this->description = esc_html__('All shortcodes specific primary registrant data', 'event_espresso');
24
+		$this->_shortcodes = array(
25
+			'[PRIMARY_REGISTRANT_FNAME]'                  => esc_html__(
26
+				'Parses to the first name of the primary registration for the transaction.',
27
+				'event_espresso'
28
+			),
29
+			'[PRIMARY_REGISTRANT_LNAME]'                  => esc_html__(
30
+				'Parses to the last name of the primary registration for the transaction.',
31
+				'event_espresso'
32
+			),
33
+			'[PRIMARY_REGISTRANT_EMAIL]'                  => esc_html__(
34
+				'Parses to the email address of the primary registration for the transaction.',
35
+				'event_espresso'
36
+			),
37
+			'[PRIMARY_REGISTRANT_REGISTRATION_ID]'        => esc_html__(
38
+				'Parses to the registration ID of the primary registrant for the transaction.',
39
+				'event_espresso'
40
+			),
41
+			'[PRIMARY_REGISTRANT_REGISTRATION_CODE]'      => esc_html__(
42
+				'Parses to the registration code of the primary registrant for the transaction.',
43
+				'event_espresso'
44
+			),
45
+			'[PRIMARY_REGISTRANT_PHONE_NUMBER]'           => esc_html__(
46
+				'The Phone Number for the primary registrant for the transaction.',
47
+				'event_espresso'
48
+			),
49
+			'[PRIMARY_REGISTRANT_ADDRESS]'                => esc_html__(
50
+				'The Address for the primary registrant for the transaction.',
51
+				'event_espresso'
52
+			),
53
+			'[PRIMARY_REGISTRANT_ADDRESS2]'               => esc_html__(
54
+				'Whatever was in the address 2 field for the primary registrant for the transaction.',
55
+				'event_espresso'
56
+			),
57
+			'[PRIMARY_REGISTRANT_CITY]'                   => esc_html__(
58
+				'The city for the primary registrant for the transaction.',
59
+				'event_espresso'
60
+			),
61
+			'[PRIMARY_REGISTRANT_ZIP_PC]'                 => esc_html__(
62
+				'The ZIP (or Postal) Code for the primary registrant for the transaction.',
63
+				'event_espresso'
64
+			),
65
+			'[PRIMARY_REGISTRANT_ADDRESS_STATE]'          => esc_html__(
66
+				'The state/province for the primary registrant for the transaction.',
67
+				'event_espresso'
68
+			),
69
+			'[PRIMARY_REGISTRANT_COUNTRY]'                => esc_html__(
70
+				'The country for the primary registrant for the transaction.',
71
+				'event_espresso'
72
+			),
73
+			'[PRIMARY_REGISTRANT_REGISTRATION_DATE]'      => esc_html__(
74
+				'The date the registration occured for the primary registration.',
75
+				'event_espresso'
76
+			),
77
+			'[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]' => esc_html__(
78
+				'Generates a link for the given registration to edit this registration details on the frontend.',
79
+				'event_espresso'
80
+			),
81
+			'[PRIMARY_REGISTRANT_ANSWER_*]'               => esc_html__(
82
+				'This is a special dynamic shortcode.  After the "*", add the exact text of an existing question, and if there is an answer for that question for this primary registrant, then it will be output in place of this shortcode.',
83
+				'event_espresso'
84
+			),
85
+		);
86
+	}
87
+
88
+
89
+	protected function _parser($shortcode)
90
+	{
91
+		// make sure we end up with a copy of the EE_Messages_Addressee object
92
+		$primary_registration = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
93
+		$primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && is_array(
94
+			$this->_data
95
+		) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data']
96
+			: $primary_registration;
97
+		$primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
98
+			? $this->_extra_data['data'] : $primary_registration;
99
+
100
+		if (! $primary_registration instanceof EE_Messages_Addressee) {
101
+			return '';
102
+		}
103
+
104
+		$attendee = $primary_registration->primary_att_obj;
105
+		$primary_reg = $primary_registration->primary_reg_obj;
106
+
107
+		if (! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration) {
108
+			return '';
109
+		}
110
+
111
+		switch ($shortcode) {
112
+			case '[PRIMARY_REGISTRANT_FNAME]':
113
+				return $attendee->fname();
114
+				break;
115
+
116
+			case '[PRIMARY_REGISTRANT_LNAME]':
117
+				return $attendee->lname();
118
+				break;
119
+
120
+			case '[PRIMARY_REGISTRANT_EMAIL]':
121
+				return $attendee->email();
122
+				break;
123
+
124
+			case '[PRIMARY_REGISTRANT_REGISTRATION_ID]':
125
+				return $primary_reg->ID();
126
+				break;
127
+
128
+			case '[PRIMARY_REGISTRANT_REGISTRATION_CODE]':
129
+				return $primary_reg->reg_code();
130
+				break;
131
+
132
+			case '[PRIMARY_REGISTRANT_PHONE_NUMBER]':
133
+				return $attendee->phone();
134
+				break;
135
+
136
+			case '[PRIMARY_REGISTRANT_ADDRESS]':
137
+				return $attendee->address();
138
+				break;
139
+
140
+			case '[PRIMARY_REGISTRANT_ADDRESS2]':
141
+				return $attendee->address2();
142
+				break;
143
+
144
+			case '[PRIMARY_REGISTRANT_CITY]':
145
+				return $attendee->city();
146
+				break;
147
+
148
+			case '[PRIMARY_REGISTRANT_ZIP_PC]':
149
+				return $attendee->zip();
150
+				break;
151
+
152
+			case '[PRIMARY_REGISTRANT_ADDRESS_STATE]':
153
+				$state_obj = $attendee->state_obj();
154
+				return $state_obj instanceof EE_State ? $state_obj->name() : '';
155
+				break;
156
+
157
+			case '[PRIMARY_REGISTRANT_COUNTRY]':
158
+				$country_obj = $attendee->country_obj();
159
+				return $country_obj instanceof EE_Country ? $country_obj->name() : '';
160
+				break;
161
+
162
+			case '[PRIMARY_REGISTRANT_REGISTRATION_DATE]':
163
+				if (! $primary_registration->primary_reg_obj instanceof EE_Registration) {
164
+					return '';
165
+				}
166
+				return $primary_registration->primary_reg_obj->get_i18n_datetime('REG_date', get_option('date_format'));
167
+				break;
168
+
169
+			case '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]':
170
+				return $primary_reg->edit_attendee_information_url();
171
+				break;
172
+		}
173
+
174
+		if (strpos($shortcode, '[PRIMARY_REGISTRANT_ANSWER_*') !== false) {
175
+			$shortcode = str_replace('[PRIMARY_REGISTRANT_ANSWER_*', '', $shortcode);
176
+			$shortcode = trim(str_replace(']', '', $shortcode));
177
+
178
+
179
+			// now let's figure out what question has this text
180
+			if (empty($primary_registration->questions)) {
181
+				return '';
182
+			}
183
+
184
+			foreach ($primary_registration->questions as $ansid => $question) {
185
+				if (
186
+					$question instanceof EE_Question
187
+					&& trim($question->get('QST_display_text')) === trim($shortcode)
188
+					&& isset($primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ])
189
+				) {
190
+					$primary_reg_ansid = $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ];
191
+
192
+					// what we show for the answer depends on the question type!
193
+					switch ($question->get('QST_type')) {
194
+						case EEM_Question::QST_type_state:
195
+							$state = EEM_State::instance()->get_one_by_ID($primary_reg_ansid->get('ANS_value'));
196
+							$answer = $state instanceof EE_State ? $state->name() : '';
197
+							break;
198
+
199
+						case EEM_Question::QST_type_country:
200
+							$country = EEM_Country::instance()->get_one_by_ID($primary_reg_ansid->get('ANS_value'));
201
+							$answer = $country instanceof EE_Country ? $country->name() : '';
202
+							break;
203
+
204
+						default:
205
+							$answer = $primary_reg_ansid->get_pretty('ANS_value', 'no_wpautop');
206
+							break;
207
+					}
208
+
209
+					return $answer;
210
+					break;
211
+				}
212
+			}
213
+		}
214
+
215
+		return '';
216
+	}
217 217
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Currency_Input.input.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
     {
22 22
         $query_params = array('order_by' => array('CNT_name' => 'asc'));
23 23
         if ($only_specific_currency_codes) {
24
-            $query_params[0]['CNT_cur_code'] = array('IN',$only_specific_currency_codes);
24
+            $query_params[0]['CNT_cur_code'] = array('IN', $only_specific_currency_codes);
25 25
         }
26 26
         $all_countries = EEM_Country::instance()->get_all($query_params);
27 27
         $country_options = array();
28 28
         foreach ($all_countries as $country) {
29 29
             /* @var $country EE_Country */
30
-            $country_options[ $country->currency_code() ] = $country->name() . ": " . $country->currency_name_single() . " (" . $country->currency_sign() . ")";
30
+            $country_options[$country->currency_code()] = $country->name().": ".$country->currency_name_single()." (".$country->currency_sign().")";
31 31
         }
32 32
         parent::__construct($country_options, 'int', $input_settings);
33 33
     }
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Currency_Input extends EE_Select_Input
13 13
 {
14
-    /**
15
-     *
16
-     * @param array $only_specific_currency_codes numerically-indexed array of allowed currency codes. By default, all are allowed
17
-     * @param array $input_settings
18
-     */
19
-    public function __construct($only_specific_currency_codes = array(), $input_settings = array())
20
-    {
21
-        $query_params = array('order_by' => array('CNT_name' => 'asc'));
22
-        if ($only_specific_currency_codes) {
23
-            $query_params[0]['CNT_cur_code'] = array('IN',$only_specific_currency_codes);
24
-        }
25
-        $all_countries = EEM_Country::instance()->get_all($query_params);
26
-        $country_options = array();
27
-        foreach ($all_countries as $country) {
28
-            /* @var $country EE_Country */
29
-            $country_options[ $country->currency_code() ] = $country->name() . ": " . $country->currency_name_single() . " (" . $country->currency_sign() . ")";
30
-        }
31
-        parent::__construct($country_options, 'int', $input_settings);
32
-    }
14
+	/**
15
+	 *
16
+	 * @param array $only_specific_currency_codes numerically-indexed array of allowed currency codes. By default, all are allowed
17
+	 * @param array $input_settings
18
+	 */
19
+	public function __construct($only_specific_currency_codes = array(), $input_settings = array())
20
+	{
21
+		$query_params = array('order_by' => array('CNT_name' => 'asc'));
22
+		if ($only_specific_currency_codes) {
23
+			$query_params[0]['CNT_cur_code'] = array('IN',$only_specific_currency_codes);
24
+		}
25
+		$all_countries = EEM_Country::instance()->get_all($query_params);
26
+		$country_options = array();
27
+		foreach ($all_countries as $country) {
28
+			/* @var $country EE_Country */
29
+			$country_options[ $country->currency_code() ] = $country->name() . ": " . $country->currency_name_single() . " (" . $country->currency_sign() . ")";
30
+		}
31
+		parent::__construct($country_options, 'int', $input_settings);
32
+	}
33 33
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Select_Reveal_Input.input.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
             if (empty($sibling_section_name)) {
46 46
                 continue;
47 47
             }
48
-            $sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
+            $sibling_section = $this->find_section_from_path('../'.$sibling_section_name);
49 49
             if (
50 50
                 $sibling_section instanceof EE_Form_Section_Base
51 51
                 && ! empty($sibling_section_name)
52 52
             ) {
53
-                $sibling_sections[ $sibling_section_name ] = $sibling_section;
53
+                $sibling_sections[$sibling_section_name] = $sibling_section;
54 54
             }
55 55
         }
56 56
         return $sibling_sections;
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
     public function get_other_js_data($form_other_js_data = array())
67 67
     {
68 68
         $form_other_js_data = parent::get_other_js_data($form_other_js_data);
69
-        if (! isset($form_other_js_data['select_reveal_inputs'])) {
69
+        if ( ! isset($form_other_js_data['select_reveal_inputs'])) {
70 70
             $form_other_js_data['select_reveal_inputs'] = array();
71 71
         }
72 72
         $sibling_input_to_html_id_map = array();
73 73
         foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
74
-            $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
74
+            $sibling_input_to_html_id_map[$sibling_section_path] = $sibling_section->html_id();
75 75
         }
76
-        $form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
76
+        $form_other_js_data['select_reveal_inputs'][$this->html_id()] = $sibling_input_to_html_id_map;
77 77
         return $form_other_js_data;
78 78
     }
79 79
 }
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -14,65 +14,65 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Select_Reveal_Input extends EE_Select_Input
16 16
 {
17
-    /**
18
-     * @param array $answer_options Array keys which match a sibling section's name
19
-     *              will show/unhide that sibling subsection. Otherwise, siblings whose names
20
-     *              match array keys of $answer_options are hidden.
21
-     *              Note: internally each array key is considered a relative form input path
22
-     *              (see EE_Form_Section_Base::find_section_from_path) but relative
23
-     *              to THIS INPUT's PARENT section, not this input itself. ie,
24
-     *              a '../' is automatically added onto each each array key, to produce
25
-     *              the relative form input path.
26
-     *              Note however: array keys which are an EMPTY STRING are left as-is
27
-     *
28
-     * @param array $input_settings
29
-     */
30
-    public function __construct($answer_options, $input_settings = array())
31
-    {
32
-        parent::__construct($answer_options, $input_settings);
33
-    }
17
+	/**
18
+	 * @param array $answer_options Array keys which match a sibling section's name
19
+	 *              will show/unhide that sibling subsection. Otherwise, siblings whose names
20
+	 *              match array keys of $answer_options are hidden.
21
+	 *              Note: internally each array key is considered a relative form input path
22
+	 *              (see EE_Form_Section_Base::find_section_from_path) but relative
23
+	 *              to THIS INPUT's PARENT section, not this input itself. ie,
24
+	 *              a '../' is automatically added onto each each array key, to produce
25
+	 *              the relative form input path.
26
+	 *              Note however: array keys which are an EMPTY STRING are left as-is
27
+	 *
28
+	 * @param array $input_settings
29
+	 */
30
+	public function __construct($answer_options, $input_settings = array())
31
+	{
32
+		parent::__construct($answer_options, $input_settings);
33
+	}
34 34
 
35
-    /**
36
-     * Gets all the sibling sections controlled by this reveal select input
37
-     * @return \EE_Form_Section_Base[] keys are their form section paths
38
-     */
39
-    public function sibling_sections_controlled()
40
-    {
41
-        $sibling_sections = array();
42
-        foreach ($this->options() as $sibling_section_name => $sibling_section) {
43
-            // if it's an empty string just leave it alone
44
-            if (empty($sibling_section_name)) {
45
-                continue;
46
-            }
47
-            $sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
-            if (
49
-                $sibling_section instanceof EE_Form_Section_Base
50
-                && ! empty($sibling_section_name)
51
-            ) {
52
-                $sibling_sections[ $sibling_section_name ] = $sibling_section;
53
-            }
54
-        }
55
-        return $sibling_sections;
56
-    }
35
+	/**
36
+	 * Gets all the sibling sections controlled by this reveal select input
37
+	 * @return \EE_Form_Section_Base[] keys are their form section paths
38
+	 */
39
+	public function sibling_sections_controlled()
40
+	{
41
+		$sibling_sections = array();
42
+		foreach ($this->options() as $sibling_section_name => $sibling_section) {
43
+			// if it's an empty string just leave it alone
44
+			if (empty($sibling_section_name)) {
45
+				continue;
46
+			}
47
+			$sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
+			if (
49
+				$sibling_section instanceof EE_Form_Section_Base
50
+				&& ! empty($sibling_section_name)
51
+			) {
52
+				$sibling_sections[ $sibling_section_name ] = $sibling_section;
53
+			}
54
+		}
55
+		return $sibling_sections;
56
+	}
57 57
 
58
-    /**
59
-     * Adds an entry of 'select_reveal_inputs' to the js data, which is an array
60
-     * whose top-level keys are select reveal input html ids; values are arrays
61
-     * whose keys are select option values and values are the sections they reveal
62
-     * @param array $form_other_js_data
63
-     * @return array
64
-     */
65
-    public function get_other_js_data($form_other_js_data = array())
66
-    {
67
-        $form_other_js_data = parent::get_other_js_data($form_other_js_data);
68
-        if (! isset($form_other_js_data['select_reveal_inputs'])) {
69
-            $form_other_js_data['select_reveal_inputs'] = array();
70
-        }
71
-        $sibling_input_to_html_id_map = array();
72
-        foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
73
-            $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
74
-        }
75
-        $form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
76
-        return $form_other_js_data;
77
-    }
58
+	/**
59
+	 * Adds an entry of 'select_reveal_inputs' to the js data, which is an array
60
+	 * whose top-level keys are select reveal input html ids; values are arrays
61
+	 * whose keys are select option values and values are the sections they reveal
62
+	 * @param array $form_other_js_data
63
+	 * @return array
64
+	 */
65
+	public function get_other_js_data($form_other_js_data = array())
66
+	{
67
+		$form_other_js_data = parent::get_other_js_data($form_other_js_data);
68
+		if (! isset($form_other_js_data['select_reveal_inputs'])) {
69
+			$form_other_js_data['select_reveal_inputs'] = array();
70
+		}
71
+		$sibling_input_to_html_id_map = array();
72
+		foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
73
+			$sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
74
+		}
75
+		$form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
76
+		return $form_other_js_data;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_CVV_Input.input.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         $this->_add_validation_strategy(
24 24
             new EE_Text_Validation_Strategy(
25 25
                 isset($input_settings['validation_error_message'])
26
-                    ?  $input_settings['validation_error_message']
26
+                    ? $input_settings['validation_error_message']
27 27
                     : esc_html__(
28 28
                         'The CVV is either a 3 digit number on the back of your card, or 4 digit number on the front',
29 29
                         'event_espresso'
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -11,43 +11,43 @@
 block discarded – undo
11 11
  */
12 12
 class EE_CVV_Input extends EE_Text_Input
13 13
 {
14
-    /**
15
-     * @param array $input_settings {
16
-     *  @type boolean $include_whats_this_link defaults to true
17
-     * }
18
-     */
19
-    public function __construct($input_settings = array())
20
-    {
21
-        $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal());
22
-        $this->_add_validation_strategy(
23
-            new EE_Text_Validation_Strategy(
24
-                isset($input_settings['validation_error_message'])
25
-                    ?  $input_settings['validation_error_message']
26
-                    : esc_html__(
27
-                        'The CVV is either a 3 digit number on the back of your card, or 4 digit number on the front',
28
-                        'event_espresso'
29
-                    ),
30
-                '~^\d{3,4}$~'
31
-            )
32
-        );
33
-        parent::__construct($input_settings);
34
-        if (
35
-            ! isset($input_settings['include_whats_this_link'])
36
-            || (
37
-                isset($input_settings['include_whats_this_link'])
38
-                 && $input_settings['include_whats_this_link'] === true
39
-            )
40
-        ) {
41
-            $this->_html_label_text = sprintf(
42
-                esc_html_x(
43
-                    '%1$s %2$s(What\'s this?)%3$s',
44
-                    'CVV (What\'s this?)',
45
-                    'event_espresso'
46
-                ),
47
-                $this->_html_label_text,
48
-                '<a href="https://www.cvvnumber.com/" target="_blank" rel="noopener noreferrer">',
49
-                '</a>'
50
-            );
51
-        }
52
-    }
14
+	/**
15
+	 * @param array $input_settings {
16
+	 *  @type boolean $include_whats_this_link defaults to true
17
+	 * }
18
+	 */
19
+	public function __construct($input_settings = array())
20
+	{
21
+		$this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal());
22
+		$this->_add_validation_strategy(
23
+			new EE_Text_Validation_Strategy(
24
+				isset($input_settings['validation_error_message'])
25
+					?  $input_settings['validation_error_message']
26
+					: esc_html__(
27
+						'The CVV is either a 3 digit number on the back of your card, or 4 digit number on the front',
28
+						'event_espresso'
29
+					),
30
+				'~^\d{3,4}$~'
31
+			)
32
+		);
33
+		parent::__construct($input_settings);
34
+		if (
35
+			! isset($input_settings['include_whats_this_link'])
36
+			|| (
37
+				isset($input_settings['include_whats_this_link'])
38
+				 && $input_settings['include_whats_this_link'] === true
39
+			)
40
+		) {
41
+			$this->_html_label_text = sprintf(
42
+				esc_html_x(
43
+					'%1$s %2$s(What\'s this?)%3$s',
44
+					'CVV (What\'s this?)',
45
+					'event_espresso'
46
+				),
47
+				$this->_html_label_text,
48
+				'<a href="https://www.cvvnumber.com/" target="_blank" rel="noopener noreferrer">',
49
+				'</a>'
50
+			);
51
+		}
52
+	}
53 53
 }
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Form_Input_With_Options_Base.input.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $all_ints = true;
116 116
             array_walk_recursive(
117 117
                 $this->_options,
118
-                function ($value, $key) use (&$all_ints) {
118
+                function($value, $key) use (&$all_ints) {
119 119
                     // is this a top-level key? ignore it
120 120
                     if (
121 121
                         ! is_array($value)
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
         if (EEH_Array::is_multi_dimensional_array($arr)) {
178 178
             foreach ($arr as $sub_array) {
179 179
                 foreach ((array) $sub_array as $key => $value) {
180
-                    $flat_array[ $key ] = $value;
180
+                    $flat_array[$key] = $value;
181 181
                     $this->_set_label_size($value);
182 182
                 }
183 183
             }
184 184
         } else {
185 185
             foreach ($arr as $key => $value) {
186
-                $flat_array[ $key ] = $value;
186
+                $flat_array[$key] = $value;
187 187
                 $this->_set_label_size($value);
188 188
             }
189 189
         }
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
                 $desc = '';
205 205
                 if ($this->_use_desc_in_label) {
206 206
                     $desc = $question_option->desc();
207
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
207
+                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : '';
208 208
                 }
209 209
                 $value = $question_option->value();
210 210
                 // add value even if it's empty
211
-                $flat_array[ $value ] = $value;
211
+                $flat_array[$value] = $value;
212 212
                 // if both value and desc are not empty, then separate with a dash
213
-                if (! empty($value) && ! empty($desc)) {
214
-                    $flat_array[ $value ] .= ' - ' . $desc;
213
+                if ( ! empty($value) && ! empty($desc)) {
214
+                    $flat_array[$value] .= ' - '.$desc;
215 215
                 } else {
216 216
                     // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
217
-                    $flat_array[ $value ] .= $desc;
217
+                    $flat_array[$value] .= $desc;
218 218
                 }
219 219
             } elseif (is_array($question_option)) {
220 220
                 $flat_array += $this->_flatten_select_options($question_option);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public function set_label_sizes()
234 234
     {
235 235
         // did the input settings specifically say to NOT set the label size dynamically ?
236
-        if (! $this->_enforce_label_size) {
236
+        if ( ! $this->_enforce_label_size) {
237 237
             foreach ($this->_options as $option) {
238 238
                 // calculate the strlen of the label
239 239
                 $this->_set_label_size($option);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     private function _set_label_size($value = '')
253 253
     {
254 254
         // don't change label size if it has already been set and is being enforced
255
-        if ($this->_enforce_label_size && $this->_label_size >  0) {
255
+        if ($this->_enforce_label_size && $this->_label_size > 0) {
256 256
             return;
257 257
         }
258 258
         // determine length of option value
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
     {
300 300
         $options = $this->flat_options();
301 301
         $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
302
-        if (! $this->_multiple_selections) {
302
+        if ( ! $this->_multiple_selections) {
303 303
             $unnormalized_value_choices = array($unnormalized_value_choices);
304 304
         }
305 305
         $pretty_strings = array();
306 306
         foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
307
-            if (isset($options[ $unnormalized_value_choice ])) {
308
-                $pretty_strings[] = $options[ $unnormalized_value_choice ];
307
+            if (isset($options[$unnormalized_value_choice])) {
308
+                $pretty_strings[] = $options[$unnormalized_value_choice];
309 309
             } else {
310 310
                 $pretty_strings[] = $this->normalized_value();
311 311
             }
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -11,324 +11,324 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base
13 13
 {
14
-    /**
15
-     * array of available options to choose as an answer
16
-     *
17
-     * @var array
18
-     */
19
-    protected $_options = array();
20
-
21
-    /**
22
-     * whether to display the html_label_text above the checkbox/radio button options
23
-     *
24
-     * @var boolean
25
-     */
26
-    protected $_display_html_label_text = true;
27
-
28
-    /**
29
-     * whether to display an question option description as part of the input label
30
-     *
31
-     * @var boolean
32
-     */
33
-    protected $_use_desc_in_label = true;
34
-
35
-    /**
36
-     * strlen() result for the longest input value (what gets displayed in the label)
37
-     * this is used to apply a css class to the input label
38
-     *
39
-     * @var int
40
-     */
41
-    protected $_label_size = 0;
42
-
43
-    /**
44
-     * whether to enforce the label size value passed in the constructor
45
-     *
46
-     * @var boolean
47
-     */
48
-    protected $_enforce_label_size = false;
49
-
50
-    /**
51
-     * whether to allow multiple selections (ie, the value of this input should be an array)
52
-     * or not (ie, the value should be a simple int, string, etc)
53
-     *
54
-     * @var boolean
55
-     */
56
-    protected $_multiple_selections = false;
57
-
58
-
59
-
60
-    /**
61
-     * @param array     $answer_options
62
-     * @param array     $input_settings {
63
-     * @type int|string $label_size
64
-     * @type boolean    $display_html_label_text
65
-     *                                  }
66
-     *                                  And all the options accepted by EE_Form_Input_Base
67
-     */
68
-    public function __construct($answer_options = array(), $input_settings = array())
69
-    {
70
-        if (isset($input_settings['label_size'])) {
71
-            $this->_set_label_size($input_settings['label_size']);
72
-            if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
73
-                $this->_enforce_label_size = true;
74
-            }
75
-        }
76
-        if (isset($input_settings['display_html_label_text'])) {
77
-            $this->set_display_html_label_text($input_settings['display_html_label_text']);
78
-        }
79
-        $this->set_select_options($answer_options);
80
-        parent::__construct($input_settings);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     * Sets the allowed options for this input. Also has the side-effect of
87
-     * updating the normalization strategy to match the keys provided in the array
88
-     *
89
-     * @param array $answer_options
90
-     * @return void  just has the side-effect of setting the options for this input
91
-     */
92
-    public function set_select_options($answer_options = array())
93
-    {
94
-        $answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
95
-        // get the first item in the select options and check it's type
96
-        $this->_options = reset($answer_options) instanceof EE_Question_Option
97
-            ? $this->_process_question_options($answer_options)
98
-            : $answer_options;
99
-        // d( $this->_options );
100
-        $select_option_keys = array_keys($this->_options);
101
-        // attempt to determine data type for values in order to set normalization type
102
-        // purposefully only
103
-        if (
104
-            count($this->_options) === 2
105
-            && (
106
-                (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
107
-                || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
108
-            )
109
-        ) {
110
-            // values appear to be boolean, like TRUE, FALSE, 1, 0
111
-            $normalization = new EE_Boolean_Normalization();
112
-        } else {
113
-            // are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
114
-            $all_ints = true;
115
-            array_walk_recursive(
116
-                $this->_options,
117
-                function ($value, $key) use (&$all_ints) {
118
-                    // is this a top-level key? ignore it
119
-                    if (
120
-                        ! is_array($value)
121
-                        && ! is_int($key)
122
-                        && $key !== ''
123
-                        && $key !== null
124
-                    ) {
125
-                        $all_ints = false;
126
-                    }
127
-                }
128
-            );
129
-            if ($all_ints) {
130
-                $normalization = new EE_Int_Normalization();
131
-            } else {
132
-                $normalization = new EE_Text_Normalization();
133
-            }
134
-        }
135
-        // does input type have multiple options ?
136
-        if ($this->_multiple_selections) {
137
-            $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
138
-        } else {
139
-            $this->_set_normalization_strategy($normalization);
140
-        }
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * @return array
147
-     */
148
-    public function options()
149
-    {
150
-        return $this->_options;
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * Returns an array which is guaranteed to not be multidimensional
157
-     *
158
-     * @return array
159
-     */
160
-    public function flat_options()
161
-    {
162
-        return $this->_flatten_select_options($this->options());
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Makes sure $arr is a flat array, not a multidimensional one
169
-     *
170
-     * @param array $arr
171
-     * @return array
172
-     */
173
-    protected function _flatten_select_options($arr)
174
-    {
175
-        $flat_array = array();
176
-        if (EEH_Array::is_multi_dimensional_array($arr)) {
177
-            foreach ($arr as $sub_array) {
178
-                foreach ((array) $sub_array as $key => $value) {
179
-                    $flat_array[ $key ] = $value;
180
-                    $this->_set_label_size($value);
181
-                }
182
-            }
183
-        } else {
184
-            foreach ($arr as $key => $value) {
185
-                $flat_array[ $key ] = $value;
186
-                $this->_set_label_size($value);
187
-            }
188
-        }
189
-        return $flat_array;
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * @param EE_Question_Option[] $question_options_array
196
-     * @return array
197
-     */
198
-    protected function _process_question_options($question_options_array = array())
199
-    {
200
-        $flat_array = array();
201
-        foreach ($question_options_array as $question_option) {
202
-            if ($question_option instanceof EE_Question_Option) {
203
-                $desc = '';
204
-                if ($this->_use_desc_in_label) {
205
-                    $desc = $question_option->desc();
206
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
207
-                }
208
-                $value = $question_option->value();
209
-                // add value even if it's empty
210
-                $flat_array[ $value ] = $value;
211
-                // if both value and desc are not empty, then separate with a dash
212
-                if (! empty($value) && ! empty($desc)) {
213
-                    $flat_array[ $value ] .= ' - ' . $desc;
214
-                } else {
215
-                    // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
216
-                    $flat_array[ $value ] .= $desc;
217
-                }
218
-            } elseif (is_array($question_option)) {
219
-                $flat_array += $this->_flatten_select_options($question_option);
220
-            }
221
-        }
222
-        return $flat_array;
223
-    }
224
-
225
-
226
-
227
-    /**
228
-     *    set_label_sizes
229
-     *
230
-     * @return void
231
-     */
232
-    public function set_label_sizes()
233
-    {
234
-        // did the input settings specifically say to NOT set the label size dynamically ?
235
-        if (! $this->_enforce_label_size) {
236
-            foreach ($this->_options as $option) {
237
-                // calculate the strlen of the label
238
-                $this->_set_label_size($option);
239
-            }
240
-        }
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     *    _set_label_size_class
247
-     *
248
-     * @param int|string $value
249
-     * @return void
250
-     */
251
-    private function _set_label_size($value = '')
252
-    {
253
-        // don't change label size if it has already been set and is being enforced
254
-        if ($this->_enforce_label_size && $this->_label_size >  0) {
255
-            return;
256
-        }
257
-        // determine length of option value
258
-        $val_size = is_int($value) ? $value : strlen($value);
259
-        // use new value if bigger than existing
260
-        $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     *    get_label_size_class
267
-     *
268
-     * @return string
269
-     */
270
-    public function get_label_size_class()
271
-    {
272
-        $size = ' medium-lbl';
273
-        // use maximum option value length to determine label size
274
-        if ($this->_label_size < 3) {
275
-            $size = ' nano-lbl';
276
-        } elseif ($this->_label_size < 6) {
277
-            $size = ' micro-lbl';
278
-        } elseif ($this->_label_size < 12) {
279
-            $size = ' tiny-lbl';
280
-        } elseif ($this->_label_size < 25) {
281
-            $size = ' small-lbl';
282
-        } elseif ($this->_label_size < 50) {
283
-            $size = ' medium-lbl';
284
-        } elseif ($this->_label_size >= 100) {
285
-            $size = ' big-lbl';
286
-        }
287
-        return $size;
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * Returns the pretty value for the normalized value
294
-     *
295
-     * @return string
296
-     */
297
-    public function pretty_value()
298
-    {
299
-        $options = $this->flat_options();
300
-        $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
301
-        if (! $this->_multiple_selections) {
302
-            $unnormalized_value_choices = array($unnormalized_value_choices);
303
-        }
304
-        $pretty_strings = array();
305
-        foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
306
-            if (isset($options[ $unnormalized_value_choice ])) {
307
-                $pretty_strings[] = $options[ $unnormalized_value_choice ];
308
-            } else {
309
-                $pretty_strings[] = $this->normalized_value();
310
-            }
311
-        }
312
-        return implode(', ', $pretty_strings);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     * @return boolean
319
-     */
320
-    public function display_html_label_text()
321
-    {
322
-        return $this->_display_html_label_text;
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * @param boolean $display_html_label_text
329
-     */
330
-    public function set_display_html_label_text($display_html_label_text)
331
-    {
332
-        $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
333
-    }
14
+	/**
15
+	 * array of available options to choose as an answer
16
+	 *
17
+	 * @var array
18
+	 */
19
+	protected $_options = array();
20
+
21
+	/**
22
+	 * whether to display the html_label_text above the checkbox/radio button options
23
+	 *
24
+	 * @var boolean
25
+	 */
26
+	protected $_display_html_label_text = true;
27
+
28
+	/**
29
+	 * whether to display an question option description as part of the input label
30
+	 *
31
+	 * @var boolean
32
+	 */
33
+	protected $_use_desc_in_label = true;
34
+
35
+	/**
36
+	 * strlen() result for the longest input value (what gets displayed in the label)
37
+	 * this is used to apply a css class to the input label
38
+	 *
39
+	 * @var int
40
+	 */
41
+	protected $_label_size = 0;
42
+
43
+	/**
44
+	 * whether to enforce the label size value passed in the constructor
45
+	 *
46
+	 * @var boolean
47
+	 */
48
+	protected $_enforce_label_size = false;
49
+
50
+	/**
51
+	 * whether to allow multiple selections (ie, the value of this input should be an array)
52
+	 * or not (ie, the value should be a simple int, string, etc)
53
+	 *
54
+	 * @var boolean
55
+	 */
56
+	protected $_multiple_selections = false;
57
+
58
+
59
+
60
+	/**
61
+	 * @param array     $answer_options
62
+	 * @param array     $input_settings {
63
+	 * @type int|string $label_size
64
+	 * @type boolean    $display_html_label_text
65
+	 *                                  }
66
+	 *                                  And all the options accepted by EE_Form_Input_Base
67
+	 */
68
+	public function __construct($answer_options = array(), $input_settings = array())
69
+	{
70
+		if (isset($input_settings['label_size'])) {
71
+			$this->_set_label_size($input_settings['label_size']);
72
+			if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
73
+				$this->_enforce_label_size = true;
74
+			}
75
+		}
76
+		if (isset($input_settings['display_html_label_text'])) {
77
+			$this->set_display_html_label_text($input_settings['display_html_label_text']);
78
+		}
79
+		$this->set_select_options($answer_options);
80
+		parent::__construct($input_settings);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 * Sets the allowed options for this input. Also has the side-effect of
87
+	 * updating the normalization strategy to match the keys provided in the array
88
+	 *
89
+	 * @param array $answer_options
90
+	 * @return void  just has the side-effect of setting the options for this input
91
+	 */
92
+	public function set_select_options($answer_options = array())
93
+	{
94
+		$answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
95
+		// get the first item in the select options and check it's type
96
+		$this->_options = reset($answer_options) instanceof EE_Question_Option
97
+			? $this->_process_question_options($answer_options)
98
+			: $answer_options;
99
+		// d( $this->_options );
100
+		$select_option_keys = array_keys($this->_options);
101
+		// attempt to determine data type for values in order to set normalization type
102
+		// purposefully only
103
+		if (
104
+			count($this->_options) === 2
105
+			&& (
106
+				(in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
107
+				|| (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
108
+			)
109
+		) {
110
+			// values appear to be boolean, like TRUE, FALSE, 1, 0
111
+			$normalization = new EE_Boolean_Normalization();
112
+		} else {
113
+			// are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
114
+			$all_ints = true;
115
+			array_walk_recursive(
116
+				$this->_options,
117
+				function ($value, $key) use (&$all_ints) {
118
+					// is this a top-level key? ignore it
119
+					if (
120
+						! is_array($value)
121
+						&& ! is_int($key)
122
+						&& $key !== ''
123
+						&& $key !== null
124
+					) {
125
+						$all_ints = false;
126
+					}
127
+				}
128
+			);
129
+			if ($all_ints) {
130
+				$normalization = new EE_Int_Normalization();
131
+			} else {
132
+				$normalization = new EE_Text_Normalization();
133
+			}
134
+		}
135
+		// does input type have multiple options ?
136
+		if ($this->_multiple_selections) {
137
+			$this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
138
+		} else {
139
+			$this->_set_normalization_strategy($normalization);
140
+		}
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * @return array
147
+	 */
148
+	public function options()
149
+	{
150
+		return $this->_options;
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * Returns an array which is guaranteed to not be multidimensional
157
+	 *
158
+	 * @return array
159
+	 */
160
+	public function flat_options()
161
+	{
162
+		return $this->_flatten_select_options($this->options());
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Makes sure $arr is a flat array, not a multidimensional one
169
+	 *
170
+	 * @param array $arr
171
+	 * @return array
172
+	 */
173
+	protected function _flatten_select_options($arr)
174
+	{
175
+		$flat_array = array();
176
+		if (EEH_Array::is_multi_dimensional_array($arr)) {
177
+			foreach ($arr as $sub_array) {
178
+				foreach ((array) $sub_array as $key => $value) {
179
+					$flat_array[ $key ] = $value;
180
+					$this->_set_label_size($value);
181
+				}
182
+			}
183
+		} else {
184
+			foreach ($arr as $key => $value) {
185
+				$flat_array[ $key ] = $value;
186
+				$this->_set_label_size($value);
187
+			}
188
+		}
189
+		return $flat_array;
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * @param EE_Question_Option[] $question_options_array
196
+	 * @return array
197
+	 */
198
+	protected function _process_question_options($question_options_array = array())
199
+	{
200
+		$flat_array = array();
201
+		foreach ($question_options_array as $question_option) {
202
+			if ($question_option instanceof EE_Question_Option) {
203
+				$desc = '';
204
+				if ($this->_use_desc_in_label) {
205
+					$desc = $question_option->desc();
206
+					$desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
207
+				}
208
+				$value = $question_option->value();
209
+				// add value even if it's empty
210
+				$flat_array[ $value ] = $value;
211
+				// if both value and desc are not empty, then separate with a dash
212
+				if (! empty($value) && ! empty($desc)) {
213
+					$flat_array[ $value ] .= ' - ' . $desc;
214
+				} else {
215
+					// otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
216
+					$flat_array[ $value ] .= $desc;
217
+				}
218
+			} elseif (is_array($question_option)) {
219
+				$flat_array += $this->_flatten_select_options($question_option);
220
+			}
221
+		}
222
+		return $flat_array;
223
+	}
224
+
225
+
226
+
227
+	/**
228
+	 *    set_label_sizes
229
+	 *
230
+	 * @return void
231
+	 */
232
+	public function set_label_sizes()
233
+	{
234
+		// did the input settings specifically say to NOT set the label size dynamically ?
235
+		if (! $this->_enforce_label_size) {
236
+			foreach ($this->_options as $option) {
237
+				// calculate the strlen of the label
238
+				$this->_set_label_size($option);
239
+			}
240
+		}
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 *    _set_label_size_class
247
+	 *
248
+	 * @param int|string $value
249
+	 * @return void
250
+	 */
251
+	private function _set_label_size($value = '')
252
+	{
253
+		// don't change label size if it has already been set and is being enforced
254
+		if ($this->_enforce_label_size && $this->_label_size >  0) {
255
+			return;
256
+		}
257
+		// determine length of option value
258
+		$val_size = is_int($value) ? $value : strlen($value);
259
+		// use new value if bigger than existing
260
+		$this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 *    get_label_size_class
267
+	 *
268
+	 * @return string
269
+	 */
270
+	public function get_label_size_class()
271
+	{
272
+		$size = ' medium-lbl';
273
+		// use maximum option value length to determine label size
274
+		if ($this->_label_size < 3) {
275
+			$size = ' nano-lbl';
276
+		} elseif ($this->_label_size < 6) {
277
+			$size = ' micro-lbl';
278
+		} elseif ($this->_label_size < 12) {
279
+			$size = ' tiny-lbl';
280
+		} elseif ($this->_label_size < 25) {
281
+			$size = ' small-lbl';
282
+		} elseif ($this->_label_size < 50) {
283
+			$size = ' medium-lbl';
284
+		} elseif ($this->_label_size >= 100) {
285
+			$size = ' big-lbl';
286
+		}
287
+		return $size;
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * Returns the pretty value for the normalized value
294
+	 *
295
+	 * @return string
296
+	 */
297
+	public function pretty_value()
298
+	{
299
+		$options = $this->flat_options();
300
+		$unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
301
+		if (! $this->_multiple_selections) {
302
+			$unnormalized_value_choices = array($unnormalized_value_choices);
303
+		}
304
+		$pretty_strings = array();
305
+		foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
306
+			if (isset($options[ $unnormalized_value_choice ])) {
307
+				$pretty_strings[] = $options[ $unnormalized_value_choice ];
308
+			} else {
309
+				$pretty_strings[] = $this->normalized_value();
310
+			}
311
+		}
312
+		return implode(', ', $pretty_strings);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 * @return boolean
319
+	 */
320
+	public function display_html_label_text()
321
+	{
322
+		return $this->_display_html_label_text;
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * @param boolean $display_html_label_text
329
+	 */
330
+	public function set_display_html_label_text($display_html_label_text)
331
+	{
332
+		$this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
333
+	}
334 334
 }
Please login to merge, or discard this patch.
strategies/display/EE_Text_Input_Display_Strategy.strategy.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -14,59 +14,59 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base
16 16
 {
17
-    /**
18
-     * The html "type" attribute value. default is "text"
19
-     * @var string
20
-     */
21
-    protected $_type;
17
+	/**
18
+	 * The html "type" attribute value. default is "text"
19
+	 * @var string
20
+	 */
21
+	protected $_type;
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * @param string $type
27
-     */
28
-    public function __construct($type = 'text')
29
-    {
30
-        $this->_type = $type;
31
-        parent::__construct();
32
-    }
25
+	/**
26
+	 * @param string $type
27
+	 */
28
+	public function __construct($type = 'text')
29
+	{
30
+		$this->_type = $type;
31
+		parent::__construct();
32
+	}
33 33
 
34 34
 
35 35
 
36
-    /**
37
-     * Gets the html "type" attribute's value
38
-     * @return string
39
-     */
40
-    public function get_type()
41
-    {
42
-        if (
43
-            $this->_type === 'email'
44
-            && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false)
45
-        ) {
46
-            return 'text';
47
-        }
48
-        return $this->_type;
49
-    }
36
+	/**
37
+	 * Gets the html "type" attribute's value
38
+	 * @return string
39
+	 */
40
+	public function get_type()
41
+	{
42
+		if (
43
+			$this->_type === 'email'
44
+			&& ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false)
45
+		) {
46
+			return 'text';
47
+		}
48
+		return $this->_type;
49
+	}
50 50
 
51 51
 
52 52
 
53
-    /**
54
-     *
55
-     * @return string of html to display the field
56
-     */
57
-    public function display()
58
-    {
59
-        $input = '<input type="' . $this->get_type() . '"';
60
-        $input .= ' name="' . $this->_input->html_name() . '"';
61
-        $input .= ' id="' . $this->_input->html_id() . '"';
62
-        $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
63
-        $input .= ' class="' . $class . '"';
64
-        // add html5 required
65
-        $input .= $this->_input->required() ? ' required' : '';
66
-        $input .= ' value="' . $this->_input->raw_value_in_form() . '"';
67
-        $input .= ' style="' . $this->_input->html_style() . '"';
68
-        $input .= $this->_input->other_html_attributes();
69
-        $input .= '/>';
70
-        return $input;
71
-    }
53
+	/**
54
+	 *
55
+	 * @return string of html to display the field
56
+	 */
57
+	public function display()
58
+	{
59
+		$input = '<input type="' . $this->get_type() . '"';
60
+		$input .= ' name="' . $this->_input->html_name() . '"';
61
+		$input .= ' id="' . $this->_input->html_id() . '"';
62
+		$class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
63
+		$input .= ' class="' . $class . '"';
64
+		// add html5 required
65
+		$input .= $this->_input->required() ? ' required' : '';
66
+		$input .= ' value="' . $this->_input->raw_value_in_form() . '"';
67
+		$input .= ' style="' . $this->_input->html_style() . '"';
68
+		$input .= $this->_input->other_html_attributes();
69
+		$input .= '/>';
70
+		return $input;
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,15 +56,15 @@
 block discarded – undo
56 56
      */
57 57
     public function display()
58 58
     {
59
-        $input = '<input type="' . $this->get_type() . '"';
60
-        $input .= ' name="' . $this->_input->html_name() . '"';
61
-        $input .= ' id="' . $this->_input->html_id() . '"';
62
-        $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
63
-        $input .= ' class="' . $class . '"';
59
+        $input = '<input type="'.$this->get_type().'"';
60
+        $input .= ' name="'.$this->_input->html_name().'"';
61
+        $input .= ' id="'.$this->_input->html_id().'"';
62
+        $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class();
63
+        $input .= ' class="'.$class.'"';
64 64
         // add html5 required
65 65
         $input .= $this->_input->required() ? ' required' : '';
66
-        $input .= ' value="' . $this->_input->raw_value_in_form() . '"';
67
-        $input .= ' style="' . $this->_input->html_style() . '"';
66
+        $input .= ' value="'.$this->_input->raw_value_in_form().'"';
67
+        $input .= ' style="'.$this->_input->html_style().'"';
68 68
         $input .= $this->_input->other_html_attributes();
69 69
         $input .= '/>';
70 70
         return $input;
Please login to merge, or discard this patch.
sensitive_data_removal/EE_CCV_Sensitive_Data_Removal.strategy.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class EE_CCV_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        // Get the ccv Length
17
-        $ccv_lenght = strlen($normalized_value);
18
-        // Replace all characters of credit card except the last four and dashes
19
-        for ($i = 0; $i < $ccv_lenght; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
21
-                continue;
22
-            }
23
-            $normalized_value[ $i ] = 'X';
24
-        }
25
-        // Return the masked Credit Card #
26
-        return $normalized_value;
27
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		// Get the ccv Length
17
+		$ccv_lenght = strlen($normalized_value);
18
+		// Replace all characters of credit card except the last four and dashes
19
+		for ($i = 0; $i < $ccv_lenght; $i++) {
20
+			if ($normalized_value[ $i ] == '-') {
21
+				continue;
22
+			}
23
+			$normalized_value[ $i ] = 'X';
24
+		}
25
+		// Return the masked Credit Card #
26
+		return $normalized_value;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@
 block discarded – undo
17 17
         $ccv_lenght = strlen($normalized_value);
18 18
         // Replace all characters of credit card except the last four and dashes
19 19
         for ($i = 0; $i < $ccv_lenght; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
20
+            if ($normalized_value[$i] == '-') {
21 21
                 continue;
22 22
             }
23
-            $normalized_value[ $i ] = 'X';
23
+            $normalized_value[$i] = 'X';
24 24
         }
25 25
         // Return the masked Credit Card #
26 26
         return $normalized_value;
Please login to merge, or discard this patch.