@@ -62,7 +62,7 @@ |
||
62 | 62 | */ |
63 | 63 | protected function _get_subject($custom_subject = '') |
64 | 64 | { |
65 | - if (! empty($custom_subject)) { |
|
65 | + if ( ! empty($custom_subject)) { |
|
66 | 66 | return $custom_subject; |
67 | 67 | } |
68 | 68 | $this->queue->get_message_repository()->rewind(); |
@@ -12,90 +12,90 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Message_To_Generate_From_Queue extends EE_Message_To_Generate |
14 | 14 | { |
15 | - /** |
|
16 | - * Will hold an EE_Messages_Queue object |
|
17 | - * @type EE_Messages_Queue |
|
18 | - */ |
|
19 | - public $queue = array(); |
|
15 | + /** |
|
16 | + * Will hold an EE_Messages_Queue object |
|
17 | + * @type EE_Messages_Queue |
|
18 | + */ |
|
19 | + public $queue = array(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param string $messenger_name The messenger being used to send the message |
|
23 | - * @param string $message_type_name The message type being used to grab variations etc. |
|
24 | - * @param EE_Messages_Queue $queue |
|
25 | - * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
|
26 | - */ |
|
27 | - public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') |
|
28 | - { |
|
29 | - $this->queue = $queue; |
|
30 | - parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
31 | - if ($this->valid()) { |
|
32 | - $this->_message->set_content($this->_get_content()); |
|
33 | - $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
34 | - $this->_message->set_GRP_ID($this->getGroupIdFromMessageRepo()); |
|
35 | - } |
|
36 | - } |
|
21 | + /** |
|
22 | + * @param string $messenger_name The messenger being used to send the message |
|
23 | + * @param string $message_type_name The message type being used to grab variations etc. |
|
24 | + * @param EE_Messages_Queue $queue |
|
25 | + * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
|
26 | + */ |
|
27 | + public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') |
|
28 | + { |
|
29 | + $this->queue = $queue; |
|
30 | + parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
31 | + if ($this->valid()) { |
|
32 | + $this->_message->set_content($this->_get_content()); |
|
33 | + $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
34 | + $this->_message->set_GRP_ID($this->getGroupIdFromMessageRepo()); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Uses the EE_Messages_Queue currently set on this object to generate the content |
|
42 | - * for the single EE_Message aggregate object returned by get_EE_Message |
|
43 | - * @return string; |
|
44 | - */ |
|
45 | - protected function _get_content() |
|
46 | - { |
|
47 | - $content = ''; |
|
48 | - $this->queue->get_message_repository()->rewind(); |
|
49 | - while ($this->queue->get_message_repository()->valid()) { |
|
50 | - $content .= $this->queue->get_message_repository()->current()->content(); |
|
51 | - $this->queue->get_message_repository()->next(); |
|
52 | - } |
|
53 | - return $content; |
|
54 | - } |
|
40 | + /** |
|
41 | + * Uses the EE_Messages_Queue currently set on this object to generate the content |
|
42 | + * for the single EE_Message aggregate object returned by get_EE_Message |
|
43 | + * @return string; |
|
44 | + */ |
|
45 | + protected function _get_content() |
|
46 | + { |
|
47 | + $content = ''; |
|
48 | + $this->queue->get_message_repository()->rewind(); |
|
49 | + while ($this->queue->get_message_repository()->valid()) { |
|
50 | + $content .= $this->queue->get_message_repository()->current()->content(); |
|
51 | + $this->queue->get_message_repository()->next(); |
|
52 | + } |
|
53 | + return $content; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Return a subject string to use for `MSG_Subject` in the aggregate EE_Message object. |
|
59 | - * @param string $custom_subject |
|
60 | - * |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - protected function _get_subject($custom_subject = '') |
|
64 | - { |
|
65 | - if (! empty($custom_subject)) { |
|
66 | - return $custom_subject; |
|
67 | - } |
|
68 | - $this->queue->get_message_repository()->rewind(); |
|
69 | - $count_of_items = $this->queue->get_message_repository()->count(); |
|
57 | + /** |
|
58 | + * Return a subject string to use for `MSG_Subject` in the aggregate EE_Message object. |
|
59 | + * @param string $custom_subject |
|
60 | + * |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + protected function _get_subject($custom_subject = '') |
|
64 | + { |
|
65 | + if (! empty($custom_subject)) { |
|
66 | + return $custom_subject; |
|
67 | + } |
|
68 | + $this->queue->get_message_repository()->rewind(); |
|
69 | + $count_of_items = $this->queue->get_message_repository()->count(); |
|
70 | 70 | |
71 | - // if $count of items in queue == 1, then let's just return the subject for that item. |
|
72 | - if ($count_of_items === 1) { |
|
73 | - return $this->queue->get_message_repository()->current()->subject(); |
|
74 | - } |
|
75 | - // phpcs:disable WordPress.WP.I18n.MissingSingularPlaceholder |
|
76 | - return sprintf( |
|
77 | - _n( |
|
78 | - 'Showing Aggregate output for 1 result', |
|
79 | - 'Showing Aggregate output for %d items', |
|
80 | - $count_of_items, |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - $count_of_items |
|
84 | - ); |
|
85 | - // phpcs:enable |
|
86 | - } |
|
71 | + // if $count of items in queue == 1, then let's just return the subject for that item. |
|
72 | + if ($count_of_items === 1) { |
|
73 | + return $this->queue->get_message_repository()->current()->subject(); |
|
74 | + } |
|
75 | + // phpcs:disable WordPress.WP.I18n.MissingSingularPlaceholder |
|
76 | + return sprintf( |
|
77 | + _n( |
|
78 | + 'Showing Aggregate output for 1 result', |
|
79 | + 'Showing Aggregate output for %d items', |
|
80 | + $count_of_items, |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + $count_of_items |
|
84 | + ); |
|
85 | + // phpcs:enable |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * Uses the EE_Messages_Queue currently set on this object to set the GRP_ID |
|
91 | - * for the single EE_Message aggregate object returned by get_EE_Message |
|
92 | - * @return int; |
|
93 | - */ |
|
94 | - protected function getGroupIdFromMessageRepo() |
|
95 | - { |
|
96 | - $this->queue->get_message_repository()->rewind(); |
|
97 | - if ($this->queue->get_message_repository()->valid()) { |
|
98 | - return $this->queue->get_message_repository()->current()->GRP_ID(); |
|
99 | - } |
|
100 | - } |
|
89 | + /** |
|
90 | + * Uses the EE_Messages_Queue currently set on this object to set the GRP_ID |
|
91 | + * for the single EE_Message aggregate object returned by get_EE_Message |
|
92 | + * @return int; |
|
93 | + */ |
|
94 | + protected function getGroupIdFromMessageRepo() |
|
95 | + { |
|
96 | + $this->queue->get_message_repository()->rewind(); |
|
97 | + if ($this->queue->get_message_repository()->valid()) { |
|
98 | + return $this->queue->get_message_repository()->current()->GRP_ID(); |
|
99 | + } |
|
100 | + } |
|
101 | 101 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $this->_venue = $this->_get_venue(); |
90 | 90 | // If there is no venue object by now then get out. |
91 | - if (! $this->_venue instanceof EE_Venue) { |
|
91 | + if ( ! $this->_venue instanceof EE_Venue) { |
|
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | // 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 |
186 | 186 | // reg_obj instead. |
187 | - if (! $this->_event instanceof EE_Event) { |
|
187 | + if ( ! $this->_event instanceof EE_Event) { |
|
188 | 188 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
189 | 189 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
190 | 190 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->_event = ! $this->_event instanceof EE_Event |
197 | 197 | && $this->_data instanceof EE_Ticket |
198 | 198 | && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
199 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
199 | + ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
200 | 200 | : $this->_event; |
201 | 201 | |
202 | 202 | // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | private function _venue($field) |
226 | 226 | { |
227 | 227 | |
228 | - if (! $this->_venue instanceof EE_Venue) { |
|
228 | + if ( ! $this->_venue instanceof EE_Venue) { |
|
229 | 229 | return ''; |
230 | 230 | } //no venue so get out. |
231 | 231 | |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'image': |
251 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
252 | - . '" alt="' . sprintf( |
|
251 | + return '<img src="'.$this->_venue->feature_image_url(array(200, 200,)) |
|
252 | + . '" alt="'.sprintf( |
|
253 | 253 | esc_attr__('%s Feature Image', 'event_espresso'), |
254 | 254 | $this->_venue->get('VNU_name') |
255 | - ) . '" />'; |
|
255 | + ).'" />'; |
|
256 | 256 | break; |
257 | 257 | |
258 | 258 | case 'phone': |
@@ -15,299 +15,299 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_Venue_Shortcodes extends EE_Shortcodes |
17 | 17 | { |
18 | - /** |
|
19 | - * Will hold the EE_Event if available |
|
20 | - * |
|
21 | - * @var EE_Event |
|
22 | - */ |
|
23 | - protected $_event; |
|
24 | - |
|
25 | - /** |
|
26 | - * Will hold the EE_Venue if available |
|
27 | - * |
|
28 | - * @var EE_Venue |
|
29 | - */ |
|
30 | - protected $_venue; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Initialize properties |
|
35 | - */ |
|
36 | - protected function _init_props() |
|
37 | - { |
|
38 | - $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
39 | - $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
40 | - $this->_shortcodes = array( |
|
41 | - '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
42 | - '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
43 | - '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
44 | - '[VENUE_DETAILS_URL]' => sprintf( |
|
45 | - esc_html__( |
|
46 | - 'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.', |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - '[VENUE_URL]' |
|
50 | - ), |
|
51 | - '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
52 | - '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
53 | - '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
54 | - '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
55 | - '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
56 | - '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
57 | - '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
58 | - '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
59 | - 'This just outputs the venue address in a semantic address format.', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
63 | - '[VENUE_META_*]' => esc_html__( |
|
64 | - '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 venue then it will be output in place of this shortcode.', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - '[GOOGLE_MAP_URL]' => esc_html__( |
|
68 | - 'URL for the google map associated with the venue.', |
|
69 | - 'event_espresso' |
|
70 | - ), |
|
71 | - '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
72 | - '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
73 | - ); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Parse incoming shortcode |
|
79 | - * |
|
80 | - * @param string $shortcode |
|
81 | - * @return string |
|
82 | - * @throws EE_Error |
|
83 | - * @throws EntityNotFoundException |
|
84 | - */ |
|
85 | - protected function _parser($shortcode) |
|
86 | - { |
|
87 | - $this->_venue = $this->_get_venue(); |
|
88 | - // If there is no venue object by now then get out. |
|
89 | - if (! $this->_venue instanceof EE_Venue) { |
|
90 | - return ''; |
|
91 | - } |
|
92 | - |
|
93 | - switch ($shortcode) { |
|
94 | - case '[VENUE_TITLE]': |
|
95 | - return $this->_venue('title'); |
|
96 | - |
|
97 | - case '[VENUE_DESCRIPTION]': |
|
98 | - return $this->_venue('description'); |
|
99 | - |
|
100 | - case '[VENUE_URL]': |
|
101 | - return $this->_venue('url'); |
|
102 | - |
|
103 | - case '[VENUE_IMAGE]': |
|
104 | - return $this->_venue('image'); |
|
105 | - |
|
106 | - case '[VENUE_PHONE]': |
|
107 | - return $this->_venue('phone'); |
|
108 | - |
|
109 | - case '[VENUE_ADDRESS]': |
|
110 | - return $this->_venue('address'); |
|
111 | - |
|
112 | - case '[VENUE_ADDRESS2]': |
|
113 | - return $this->_venue('address2'); |
|
114 | - |
|
115 | - case '[VENUE_CITY]': |
|
116 | - return $this->_venue('city'); |
|
117 | - |
|
118 | - case '[VENUE_COUNTRY]': |
|
119 | - return $this->_venue('country'); |
|
120 | - |
|
121 | - case '[VENUE_STATE]': |
|
122 | - return $this->_venue('state'); |
|
123 | - |
|
124 | - case '[VENUE_ZIP]': |
|
125 | - return $this->_venue('zip'); |
|
126 | - |
|
127 | - case '[VENUE_FORMATTED_ADDRESS]': |
|
128 | - return $this->_venue('formatted_address'); |
|
129 | - |
|
130 | - case '[GOOGLE_MAP_URL]': |
|
131 | - return $this->_venue('gmap_url'); |
|
132 | - |
|
133 | - case '[GOOGLE_MAP_LINK]': |
|
134 | - return $this->_venue('gmap_link'); |
|
135 | - |
|
136 | - case '[GOOGLE_MAP_IMAGE]': |
|
137 | - return $this->_venue('gmap_link_img'); |
|
138 | - |
|
139 | - case '[VENUE_DETAILS_URL]': |
|
140 | - return $this->_venue('permalink'); |
|
141 | - } |
|
142 | - |
|
143 | - if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
144 | - $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
145 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
146 | - |
|
147 | - // pull the meta value from the venue post |
|
148 | - $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
149 | - |
|
150 | - return ! empty($venue_meta) ? $venue_meta : ''; |
|
151 | - } |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * This retrieves the EE_Venue from the available data object. |
|
156 | - * |
|
157 | - * @return EE_Venue|null |
|
158 | - * @throws EE_Error |
|
159 | - * @throws EntityNotFoundException |
|
160 | - */ |
|
161 | - private function _get_venue() |
|
162 | - { |
|
163 | - |
|
164 | - // we need the EE_Event object to get the venue. |
|
165 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
166 | - |
|
167 | - // 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 |
|
168 | - // reg_obj instead. |
|
169 | - if (! $this->_event instanceof EE_Event) { |
|
170 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
171 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
172 | - |
|
173 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
174 | - ? $aee->reg_obj->event() |
|
175 | - : null; |
|
176 | - |
|
177 | - // if still empty do we have a ticket data item? |
|
178 | - $this->_event = ! $this->_event instanceof EE_Event |
|
179 | - && $this->_data instanceof EE_Ticket |
|
180 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
181 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
182 | - : $this->_event; |
|
183 | - |
|
184 | - // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
185 | - // and use that. |
|
186 | - $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
187 | - ? reset($aee->events) |
|
188 | - : $this->_event; |
|
189 | - } |
|
190 | - |
|
191 | - // If we have an event object use it to pull the venue. |
|
192 | - if ($this->_event instanceof EE_Event) { |
|
193 | - return $this->_event->get_first_related('Venue'); |
|
194 | - } |
|
195 | - |
|
196 | - return null; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * This retrieves the specified venue information |
|
201 | - * |
|
202 | - * @param string $field What Venue field to retrieve |
|
203 | - * @return string What was retrieved! |
|
204 | - * @throws EE_Error |
|
205 | - * @throws EntityNotFoundException |
|
206 | - */ |
|
207 | - private function _venue($field) |
|
208 | - { |
|
209 | - |
|
210 | - if (! $this->_venue instanceof EE_Venue) { |
|
211 | - return ''; |
|
212 | - } //no venue so get out. |
|
213 | - |
|
214 | - switch ($field) { |
|
215 | - case 'title': |
|
216 | - return $this->_venue->get('VNU_name'); |
|
217 | - break; |
|
218 | - |
|
219 | - case 'description': |
|
220 | - return $this->_venue->get('VNU_desc'); |
|
221 | - break; |
|
222 | - |
|
223 | - case 'url': |
|
224 | - $url = $this->_venue->get('VNU_url'); |
|
225 | - return empty($url) ? $this->_venue->get_permalink() : $url; |
|
226 | - break; |
|
227 | - |
|
228 | - case 'permalink': |
|
229 | - return $this->_venue->get_permalink(); |
|
230 | - break; |
|
231 | - |
|
232 | - case 'image': |
|
233 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
234 | - . '" alt="' . sprintf( |
|
235 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
236 | - $this->_venue->get('VNU_name') |
|
237 | - ) . '" />'; |
|
238 | - break; |
|
239 | - |
|
240 | - case 'phone': |
|
241 | - return $this->_venue->get('VNU_phone'); |
|
242 | - break; |
|
243 | - |
|
244 | - case 'address': |
|
245 | - return $this->_venue->get('VNU_address'); |
|
246 | - break; |
|
247 | - |
|
248 | - case 'address2': |
|
249 | - return $this->_venue->get('VNU_address2'); |
|
250 | - break; |
|
251 | - |
|
252 | - case 'city': |
|
253 | - return $this->_venue->get('VNU_city'); |
|
254 | - break; |
|
255 | - |
|
256 | - case 'state': |
|
257 | - $state = $this->_venue->state_obj(); |
|
258 | - return is_object($state) ? $state->get('STA_name') : ''; |
|
259 | - break; |
|
260 | - |
|
261 | - case 'country': |
|
262 | - $country = $this->_venue->country_obj(); |
|
263 | - return is_object($country) ? $country->get('CNT_name') : ''; |
|
264 | - break; |
|
265 | - |
|
266 | - case 'zip': |
|
267 | - return $this->_venue->get('VNU_zip'); |
|
268 | - break; |
|
269 | - |
|
270 | - case 'formatted_address': |
|
271 | - return EEH_Address::format($this->_venue); |
|
272 | - break; |
|
273 | - |
|
274 | - case 'gmap_link': |
|
275 | - case 'gmap_url': |
|
276 | - case 'gmap_link_img': |
|
277 | - $atts = $this->get_map_attributes($this->_venue, $field); |
|
278 | - return EEH_Maps::google_map_link($atts); |
|
279 | - break; |
|
280 | - } |
|
281 | - return ''; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * Generates the attributes for retrieving a google_map artifact. |
|
287 | - * |
|
288 | - * @param EE_Venue $venue |
|
289 | - * @param string $field |
|
290 | - * @return array |
|
291 | - * @throws EE_Error |
|
292 | - */ |
|
293 | - protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
294 | - { |
|
295 | - $state = $venue->state_obj(); |
|
296 | - $country = $venue->country_obj(); |
|
297 | - $atts = array( |
|
298 | - 'id' => $venue->ID(), |
|
299 | - 'address' => $venue->get('VNU_address'), |
|
300 | - 'city' => $venue->get('VNU_city'), |
|
301 | - 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
302 | - 'zip' => $venue->get('VNU_zip'), |
|
303 | - 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
304 | - 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
305 | - 'map_w' => 200, |
|
306 | - 'map_h' => 200, |
|
307 | - ); |
|
308 | - if ($field === 'gmap_url') { |
|
309 | - $atts['type'] = 'url_only'; |
|
310 | - } |
|
311 | - return $atts; |
|
312 | - } |
|
18 | + /** |
|
19 | + * Will hold the EE_Event if available |
|
20 | + * |
|
21 | + * @var EE_Event |
|
22 | + */ |
|
23 | + protected $_event; |
|
24 | + |
|
25 | + /** |
|
26 | + * Will hold the EE_Venue if available |
|
27 | + * |
|
28 | + * @var EE_Venue |
|
29 | + */ |
|
30 | + protected $_venue; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Initialize properties |
|
35 | + */ |
|
36 | + protected function _init_props() |
|
37 | + { |
|
38 | + $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
39 | + $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
40 | + $this->_shortcodes = array( |
|
41 | + '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
42 | + '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
43 | + '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
44 | + '[VENUE_DETAILS_URL]' => sprintf( |
|
45 | + esc_html__( |
|
46 | + 'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.', |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + '[VENUE_URL]' |
|
50 | + ), |
|
51 | + '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
52 | + '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
53 | + '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
54 | + '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
55 | + '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
56 | + '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
57 | + '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
58 | + '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
59 | + 'This just outputs the venue address in a semantic address format.', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
63 | + '[VENUE_META_*]' => esc_html__( |
|
64 | + '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 venue then it will be output in place of this shortcode.', |
|
65 | + 'event_espresso' |
|
66 | + ), |
|
67 | + '[GOOGLE_MAP_URL]' => esc_html__( |
|
68 | + 'URL for the google map associated with the venue.', |
|
69 | + 'event_espresso' |
|
70 | + ), |
|
71 | + '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
72 | + '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
73 | + ); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Parse incoming shortcode |
|
79 | + * |
|
80 | + * @param string $shortcode |
|
81 | + * @return string |
|
82 | + * @throws EE_Error |
|
83 | + * @throws EntityNotFoundException |
|
84 | + */ |
|
85 | + protected function _parser($shortcode) |
|
86 | + { |
|
87 | + $this->_venue = $this->_get_venue(); |
|
88 | + // If there is no venue object by now then get out. |
|
89 | + if (! $this->_venue instanceof EE_Venue) { |
|
90 | + return ''; |
|
91 | + } |
|
92 | + |
|
93 | + switch ($shortcode) { |
|
94 | + case '[VENUE_TITLE]': |
|
95 | + return $this->_venue('title'); |
|
96 | + |
|
97 | + case '[VENUE_DESCRIPTION]': |
|
98 | + return $this->_venue('description'); |
|
99 | + |
|
100 | + case '[VENUE_URL]': |
|
101 | + return $this->_venue('url'); |
|
102 | + |
|
103 | + case '[VENUE_IMAGE]': |
|
104 | + return $this->_venue('image'); |
|
105 | + |
|
106 | + case '[VENUE_PHONE]': |
|
107 | + return $this->_venue('phone'); |
|
108 | + |
|
109 | + case '[VENUE_ADDRESS]': |
|
110 | + return $this->_venue('address'); |
|
111 | + |
|
112 | + case '[VENUE_ADDRESS2]': |
|
113 | + return $this->_venue('address2'); |
|
114 | + |
|
115 | + case '[VENUE_CITY]': |
|
116 | + return $this->_venue('city'); |
|
117 | + |
|
118 | + case '[VENUE_COUNTRY]': |
|
119 | + return $this->_venue('country'); |
|
120 | + |
|
121 | + case '[VENUE_STATE]': |
|
122 | + return $this->_venue('state'); |
|
123 | + |
|
124 | + case '[VENUE_ZIP]': |
|
125 | + return $this->_venue('zip'); |
|
126 | + |
|
127 | + case '[VENUE_FORMATTED_ADDRESS]': |
|
128 | + return $this->_venue('formatted_address'); |
|
129 | + |
|
130 | + case '[GOOGLE_MAP_URL]': |
|
131 | + return $this->_venue('gmap_url'); |
|
132 | + |
|
133 | + case '[GOOGLE_MAP_LINK]': |
|
134 | + return $this->_venue('gmap_link'); |
|
135 | + |
|
136 | + case '[GOOGLE_MAP_IMAGE]': |
|
137 | + return $this->_venue('gmap_link_img'); |
|
138 | + |
|
139 | + case '[VENUE_DETAILS_URL]': |
|
140 | + return $this->_venue('permalink'); |
|
141 | + } |
|
142 | + |
|
143 | + if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
144 | + $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
145 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
146 | + |
|
147 | + // pull the meta value from the venue post |
|
148 | + $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
149 | + |
|
150 | + return ! empty($venue_meta) ? $venue_meta : ''; |
|
151 | + } |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * This retrieves the EE_Venue from the available data object. |
|
156 | + * |
|
157 | + * @return EE_Venue|null |
|
158 | + * @throws EE_Error |
|
159 | + * @throws EntityNotFoundException |
|
160 | + */ |
|
161 | + private function _get_venue() |
|
162 | + { |
|
163 | + |
|
164 | + // we need the EE_Event object to get the venue. |
|
165 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
166 | + |
|
167 | + // 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 |
|
168 | + // reg_obj instead. |
|
169 | + if (! $this->_event instanceof EE_Event) { |
|
170 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
171 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
172 | + |
|
173 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
174 | + ? $aee->reg_obj->event() |
|
175 | + : null; |
|
176 | + |
|
177 | + // if still empty do we have a ticket data item? |
|
178 | + $this->_event = ! $this->_event instanceof EE_Event |
|
179 | + && $this->_data instanceof EE_Ticket |
|
180 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
181 | + ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
182 | + : $this->_event; |
|
183 | + |
|
184 | + // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
185 | + // and use that. |
|
186 | + $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
187 | + ? reset($aee->events) |
|
188 | + : $this->_event; |
|
189 | + } |
|
190 | + |
|
191 | + // If we have an event object use it to pull the venue. |
|
192 | + if ($this->_event instanceof EE_Event) { |
|
193 | + return $this->_event->get_first_related('Venue'); |
|
194 | + } |
|
195 | + |
|
196 | + return null; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * This retrieves the specified venue information |
|
201 | + * |
|
202 | + * @param string $field What Venue field to retrieve |
|
203 | + * @return string What was retrieved! |
|
204 | + * @throws EE_Error |
|
205 | + * @throws EntityNotFoundException |
|
206 | + */ |
|
207 | + private function _venue($field) |
|
208 | + { |
|
209 | + |
|
210 | + if (! $this->_venue instanceof EE_Venue) { |
|
211 | + return ''; |
|
212 | + } //no venue so get out. |
|
213 | + |
|
214 | + switch ($field) { |
|
215 | + case 'title': |
|
216 | + return $this->_venue->get('VNU_name'); |
|
217 | + break; |
|
218 | + |
|
219 | + case 'description': |
|
220 | + return $this->_venue->get('VNU_desc'); |
|
221 | + break; |
|
222 | + |
|
223 | + case 'url': |
|
224 | + $url = $this->_venue->get('VNU_url'); |
|
225 | + return empty($url) ? $this->_venue->get_permalink() : $url; |
|
226 | + break; |
|
227 | + |
|
228 | + case 'permalink': |
|
229 | + return $this->_venue->get_permalink(); |
|
230 | + break; |
|
231 | + |
|
232 | + case 'image': |
|
233 | + return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
234 | + . '" alt="' . sprintf( |
|
235 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
236 | + $this->_venue->get('VNU_name') |
|
237 | + ) . '" />'; |
|
238 | + break; |
|
239 | + |
|
240 | + case 'phone': |
|
241 | + return $this->_venue->get('VNU_phone'); |
|
242 | + break; |
|
243 | + |
|
244 | + case 'address': |
|
245 | + return $this->_venue->get('VNU_address'); |
|
246 | + break; |
|
247 | + |
|
248 | + case 'address2': |
|
249 | + return $this->_venue->get('VNU_address2'); |
|
250 | + break; |
|
251 | + |
|
252 | + case 'city': |
|
253 | + return $this->_venue->get('VNU_city'); |
|
254 | + break; |
|
255 | + |
|
256 | + case 'state': |
|
257 | + $state = $this->_venue->state_obj(); |
|
258 | + return is_object($state) ? $state->get('STA_name') : ''; |
|
259 | + break; |
|
260 | + |
|
261 | + case 'country': |
|
262 | + $country = $this->_venue->country_obj(); |
|
263 | + return is_object($country) ? $country->get('CNT_name') : ''; |
|
264 | + break; |
|
265 | + |
|
266 | + case 'zip': |
|
267 | + return $this->_venue->get('VNU_zip'); |
|
268 | + break; |
|
269 | + |
|
270 | + case 'formatted_address': |
|
271 | + return EEH_Address::format($this->_venue); |
|
272 | + break; |
|
273 | + |
|
274 | + case 'gmap_link': |
|
275 | + case 'gmap_url': |
|
276 | + case 'gmap_link_img': |
|
277 | + $atts = $this->get_map_attributes($this->_venue, $field); |
|
278 | + return EEH_Maps::google_map_link($atts); |
|
279 | + break; |
|
280 | + } |
|
281 | + return ''; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * Generates the attributes for retrieving a google_map artifact. |
|
287 | + * |
|
288 | + * @param EE_Venue $venue |
|
289 | + * @param string $field |
|
290 | + * @return array |
|
291 | + * @throws EE_Error |
|
292 | + */ |
|
293 | + protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
294 | + { |
|
295 | + $state = $venue->state_obj(); |
|
296 | + $country = $venue->country_obj(); |
|
297 | + $atts = array( |
|
298 | + 'id' => $venue->ID(), |
|
299 | + 'address' => $venue->get('VNU_address'), |
|
300 | + 'city' => $venue->get('VNU_city'), |
|
301 | + 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
302 | + 'zip' => $venue->get('VNU_zip'), |
|
303 | + 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
304 | + 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
305 | + 'map_w' => 200, |
|
306 | + 'map_h' => 200, |
|
307 | + ); |
|
308 | + if ($field === 'gmap_url') { |
|
309 | + $atts['type'] = 'url_only'; |
|
310 | + } |
|
311 | + return $atts; |
|
312 | + } |
|
313 | 313 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | protected function _parser($shortcode) |
50 | 50 | { |
51 | 51 | // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
52 | - if (! $this->_data instanceof EE_Payment) { |
|
52 | + if ( ! $this->_data instanceof EE_Payment) { |
|
53 | 53 | return ''; |
54 | 54 | } |
55 | 55 |
@@ -16,87 +16,87 @@ |
||
16 | 16 | */ |
17 | 17 | class EE_Payment_Shortcodes extends EE_Shortcodes |
18 | 18 | { |
19 | - protected function _init_props() |
|
20 | - { |
|
21 | - $this->label = esc_html__('Payment Shortcodes', 'event_espresso'); |
|
22 | - $this->description = esc_html__('All shortcodes specific to payments.', 'event_espresso'); |
|
23 | - $this->_shortcodes = array( |
|
24 | - '[PAYMENT_TIMESTAMP]' => esc_html__( |
|
25 | - 'Outputs the date of the payment (using the default date format).', |
|
26 | - 'event_espresso' |
|
27 | - ), |
|
28 | - '[PAYMENT_METHOD]' => esc_html__('Outputs a the payment method.', 'event_espresso'), |
|
29 | - '[PAYMENT_AMOUNT]' => esc_html__('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
30 | - '[PAYMENT_GATEWAY]' => esc_html__('Outputs the gateway used for the payment.', 'event_espresso'), |
|
31 | - '[PAYMENT_GATEWAY_RESPONSE]' => esc_html__('Outputs the payment gateway response.', 'event_espresso'), |
|
32 | - '[PAYMENT_GATEWAY_TXN_ID]' => esc_html__( |
|
33 | - 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - '[PAYMENT_PO_NUMBER]' => esc_html__('Purchase Order number (if present)', 'event_espresso'), |
|
37 | - '[PAYMENT_EXTRA_ACCOUNTING]' => esc_html__( |
|
38 | - 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
39 | - 'event_espresso' |
|
40 | - ), |
|
41 | - '[PAYMENT_STATUS]' => esc_html__('The status of the payment.', 'event_espresso'), |
|
42 | - // '[PAYMENT_STATUS_WITH_ICONS]' => esc_html__('The status of the payment including icons representing the status.', 'event_espresso') |
|
43 | - ); |
|
44 | - } |
|
19 | + protected function _init_props() |
|
20 | + { |
|
21 | + $this->label = esc_html__('Payment Shortcodes', 'event_espresso'); |
|
22 | + $this->description = esc_html__('All shortcodes specific to payments.', 'event_espresso'); |
|
23 | + $this->_shortcodes = array( |
|
24 | + '[PAYMENT_TIMESTAMP]' => esc_html__( |
|
25 | + 'Outputs the date of the payment (using the default date format).', |
|
26 | + 'event_espresso' |
|
27 | + ), |
|
28 | + '[PAYMENT_METHOD]' => esc_html__('Outputs a the payment method.', 'event_espresso'), |
|
29 | + '[PAYMENT_AMOUNT]' => esc_html__('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
30 | + '[PAYMENT_GATEWAY]' => esc_html__('Outputs the gateway used for the payment.', 'event_espresso'), |
|
31 | + '[PAYMENT_GATEWAY_RESPONSE]' => esc_html__('Outputs the payment gateway response.', 'event_espresso'), |
|
32 | + '[PAYMENT_GATEWAY_TXN_ID]' => esc_html__( |
|
33 | + 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + '[PAYMENT_PO_NUMBER]' => esc_html__('Purchase Order number (if present)', 'event_espresso'), |
|
37 | + '[PAYMENT_EXTRA_ACCOUNTING]' => esc_html__( |
|
38 | + 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
39 | + 'event_espresso' |
|
40 | + ), |
|
41 | + '[PAYMENT_STATUS]' => esc_html__('The status of the payment.', 'event_espresso'), |
|
42 | + // '[PAYMENT_STATUS_WITH_ICONS]' => esc_html__('The status of the payment including icons representing the status.', 'event_espresso') |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @param string $shortcode |
|
49 | - * @throws EE_Error |
|
50 | - * @throws ReflectionException |
|
51 | - */ |
|
52 | - protected function _parser($shortcode) |
|
53 | - { |
|
54 | - // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
55 | - if (! $this->_data instanceof EE_Payment) { |
|
56 | - return ''; |
|
57 | - } |
|
47 | + /** |
|
48 | + * @param string $shortcode |
|
49 | + * @throws EE_Error |
|
50 | + * @throws ReflectionException |
|
51 | + */ |
|
52 | + protected function _parser($shortcode) |
|
53 | + { |
|
54 | + // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
55 | + if (! $this->_data instanceof EE_Payment) { |
|
56 | + return ''; |
|
57 | + } |
|
58 | 58 | |
59 | - $payment = $this->_data; |
|
59 | + $payment = $this->_data; |
|
60 | 60 | |
61 | - switch ($shortcode) { |
|
62 | - case '[PAYMENT_TIMESTAMP]': |
|
63 | - return $payment->timestamp(); |
|
61 | + switch ($shortcode) { |
|
62 | + case '[PAYMENT_TIMESTAMP]': |
|
63 | + return $payment->timestamp(); |
|
64 | 64 | |
65 | - case '[PAYMENT_METHOD]': |
|
66 | - // previously the column 'PAY_source' was known as 'PAY_method' |
|
67 | - return $payment->source(); |
|
65 | + case '[PAYMENT_METHOD]': |
|
66 | + // previously the column 'PAY_source' was known as 'PAY_method' |
|
67 | + return $payment->source(); |
|
68 | 68 | |
69 | - case '[PAYMENT_AMOUNT]': |
|
70 | - return $payment->amount_no_code(); |
|
69 | + case '[PAYMENT_AMOUNT]': |
|
70 | + return $payment->amount_no_code(); |
|
71 | 71 | |
72 | - case '[PAYMENT_GATEWAY]': |
|
73 | - // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
74 | - if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
75 | - return $payment->payment_method()->name(); |
|
76 | - } else { |
|
77 | - return esc_html__('Unknown', 'event_espresso'); |
|
78 | - } |
|
72 | + case '[PAYMENT_GATEWAY]': |
|
73 | + // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
74 | + if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
75 | + return $payment->payment_method()->name(); |
|
76 | + } else { |
|
77 | + return esc_html__('Unknown', 'event_espresso'); |
|
78 | + } |
|
79 | 79 | |
80 | - case '[PAYMENT_GATEWAY_RESPONSE]': |
|
81 | - return $payment->gateway_response(); |
|
80 | + case '[PAYMENT_GATEWAY_RESPONSE]': |
|
81 | + return $payment->gateway_response(); |
|
82 | 82 | |
83 | - case '[PAYMENT_GATEWAY_TXN_ID]': |
|
84 | - return $payment->txn_id_chq_nmbr(); |
|
83 | + case '[PAYMENT_GATEWAY_TXN_ID]': |
|
84 | + return $payment->txn_id_chq_nmbr(); |
|
85 | 85 | |
86 | - case '[PAYMENT_PO_NUMBER]': |
|
87 | - return $payment->po_number(); |
|
86 | + case '[PAYMENT_PO_NUMBER]': |
|
87 | + return $payment->po_number(); |
|
88 | 88 | |
89 | - case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
90 | - return $payment->extra_accntng(); |
|
89 | + case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
90 | + return $payment->extra_accntng(); |
|
91 | 91 | |
92 | - case '[PAYMENT_STATUS]': |
|
93 | - return $payment->pretty_status(); |
|
92 | + case '[PAYMENT_STATUS]': |
|
93 | + return $payment->pretty_status(); |
|
94 | 94 | |
95 | - case '[PAYMENT_STATUS_WITH_ICONS]': |
|
96 | - return $payment->pretty_status(true); |
|
95 | + case '[PAYMENT_STATUS_WITH_ICONS]': |
|
96 | + return $payment->pretty_status(true); |
|
97 | 97 | |
98 | - default: |
|
99 | - return ''; |
|
100 | - } |
|
101 | - } |
|
98 | + default: |
|
99 | + return ''; |
|
100 | + } |
|
101 | + } |
|
102 | 102 | } |
@@ -19,10 +19,10 @@ |
||
19 | 19 | $key_begin_range = $january_is_month_1 ? 1 : 0; |
20 | 20 | $key_range = range($key_begin_range, $key_begin_range + 11); |
21 | 21 | if ($leading_zero) { |
22 | - array_walk($key_range, array( $this, '_zero_pad' )); |
|
22 | + array_walk($key_range, array($this, '_zero_pad')); |
|
23 | 23 | } |
24 | 24 | $value_range = range(1, 12); |
25 | - array_walk($value_range, array( $this, '_zero_pad' )); |
|
25 | + array_walk($value_range, array($this, '_zero_pad')); |
|
26 | 26 | parent::__construct( |
27 | 27 | array_combine( |
28 | 28 | $key_range, |
@@ -9,36 +9,36 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Month_Input extends EE_Select_Input |
11 | 11 | { |
12 | - /** |
|
13 | - * @param bool $leading_zero |
|
14 | - * @param array $input_settings |
|
15 | - * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
|
16 | - */ |
|
17 | - public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) |
|
18 | - { |
|
19 | - $key_begin_range = $january_is_month_1 ? 1 : 0; |
|
20 | - $key_range = range($key_begin_range, $key_begin_range + 11); |
|
21 | - if ($leading_zero) { |
|
22 | - array_walk($key_range, array( $this, '_zero_pad' )); |
|
23 | - } |
|
24 | - $value_range = range(1, 12); |
|
25 | - array_walk($value_range, array( $this, '_zero_pad' )); |
|
26 | - parent::__construct( |
|
27 | - array_combine( |
|
28 | - $key_range, |
|
29 | - $value_range |
|
30 | - ), |
|
31 | - $input_settings |
|
32 | - ); |
|
33 | - } |
|
12 | + /** |
|
13 | + * @param bool $leading_zero |
|
14 | + * @param array $input_settings |
|
15 | + * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
|
16 | + */ |
|
17 | + public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) |
|
18 | + { |
|
19 | + $key_begin_range = $january_is_month_1 ? 1 : 0; |
|
20 | + $key_range = range($key_begin_range, $key_begin_range + 11); |
|
21 | + if ($leading_zero) { |
|
22 | + array_walk($key_range, array( $this, '_zero_pad' )); |
|
23 | + } |
|
24 | + $value_range = range(1, 12); |
|
25 | + array_walk($value_range, array( $this, '_zero_pad' )); |
|
26 | + parent::__construct( |
|
27 | + array_combine( |
|
28 | + $key_range, |
|
29 | + $value_range |
|
30 | + ), |
|
31 | + $input_settings |
|
32 | + ); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Changes int 1 to 01, etc. Useful with array_walk |
|
37 | - * @param int $input |
|
38 | - * @param mixed $key |
|
39 | - */ |
|
40 | - protected function _zero_pad(&$input, $key) |
|
41 | - { |
|
42 | - $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
43 | - } |
|
35 | + /** |
|
36 | + * Changes int 1 to 01, etc. Useful with array_walk |
|
37 | + * @param int $input |
|
38 | + * @param mixed $key |
|
39 | + */ |
|
40 | + protected function _zero_pad(&$input, $key) |
|
41 | + { |
|
42 | + $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
43 | + } |
|
44 | 44 | } |
@@ -55,11 +55,11 @@ |
||
55 | 55 | $select_options = array(); |
56 | 56 | foreach ($answer_options as $model_obj) { |
57 | 57 | if ($this->_naming_method) { |
58 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
58 | + $display_value = call_user_func(array($model_obj, $this->_naming_method)); |
|
59 | 59 | } else { |
60 | 60 | $display_value = $model_obj->name(); |
61 | 61 | } |
62 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
62 | + $select_options[$model_obj->ID()] = $display_value; |
|
63 | 63 | } |
64 | 64 | parent::set_select_options($select_options); |
65 | 65 | } |
@@ -11,75 +11,75 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Select_Multi_Model_Input extends EE_Select_Multiple_Input |
13 | 13 | { |
14 | - protected $_naming_method; |
|
14 | + protected $_naming_method; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * |
|
20 | - * @param EE_Base_Class[] $answer_options |
|
21 | - * @param array $input_settings { |
|
22 | - * @var EE_Base_Class[] or array $default |
|
23 | - * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
24 | - * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
25 | - * } |
|
26 | - */ |
|
27 | - public function __construct($answer_options = array(), $input_settings = array()) |
|
28 | - { |
|
29 | - if (isset($input_settings['naming_method'])) { |
|
30 | - $this->set_option_naming_method($input_settings['naming_method']); |
|
31 | - } |
|
32 | - parent::__construct($answer_options, $input_settings); |
|
33 | - } |
|
18 | + /** |
|
19 | + * |
|
20 | + * @param EE_Base_Class[] $answer_options |
|
21 | + * @param array $input_settings { |
|
22 | + * @var EE_Base_Class[] or array $default |
|
23 | + * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
24 | + * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
25 | + * } |
|
26 | + */ |
|
27 | + public function __construct($answer_options = array(), $input_settings = array()) |
|
28 | + { |
|
29 | + if (isset($input_settings['naming_method'])) { |
|
30 | + $this->set_option_naming_method($input_settings['naming_method']); |
|
31 | + } |
|
32 | + parent::__construct($answer_options, $input_settings); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Sets the method name which will be called when outputting the options list |
|
37 | - * @param string $method |
|
38 | - */ |
|
39 | - public function set_option_naming_method($method) |
|
40 | - { |
|
41 | - $this->_naming_method = $method; |
|
42 | - } |
|
35 | + /** |
|
36 | + * Sets the method name which will be called when outputting the options list |
|
37 | + * @param string $method |
|
38 | + */ |
|
39 | + public function set_option_naming_method($method) |
|
40 | + { |
|
41 | + $this->_naming_method = $method; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * You CAN pass an array of model objects instead of simple values for teh options |
|
48 | - * @param EE_Base_Class[] $answer_options |
|
49 | - * @return null|void |
|
50 | - */ |
|
51 | - public function set_select_options($answer_options = array()) |
|
52 | - { |
|
53 | - // convert the model objects to select from into normal select options |
|
54 | - $select_options = array(); |
|
55 | - foreach ($answer_options as $model_obj) { |
|
56 | - if ($this->_naming_method) { |
|
57 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
58 | - } else { |
|
59 | - $display_value = $model_obj->name(); |
|
60 | - } |
|
61 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
62 | - } |
|
63 | - parent::set_select_options($select_options); |
|
64 | - } |
|
46 | + /** |
|
47 | + * You CAN pass an array of model objects instead of simple values for teh options |
|
48 | + * @param EE_Base_Class[] $answer_options |
|
49 | + * @return null|void |
|
50 | + */ |
|
51 | + public function set_select_options($answer_options = array()) |
|
52 | + { |
|
53 | + // convert the model objects to select from into normal select options |
|
54 | + $select_options = array(); |
|
55 | + foreach ($answer_options as $model_obj) { |
|
56 | + if ($this->_naming_method) { |
|
57 | + $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
58 | + } else { |
|
59 | + $display_value = $model_obj->name(); |
|
60 | + } |
|
61 | + $select_options[ $model_obj->ID() ] = $display_value; |
|
62 | + } |
|
63 | + parent::set_select_options($select_options); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * if they passed in an array of model objects for the default, convert it |
|
70 | - * into the format EE_Select_Multiple expects |
|
71 | - * @param EE_Base_Class[]|array $values |
|
72 | - */ |
|
73 | - public function set_default($values) |
|
74 | - { |
|
75 | - $defaults_as_simple_ids = array(); |
|
76 | - foreach ($values as $key => $value) { |
|
77 | - if ($value instanceof EE_Base_Class) { |
|
78 | - $defaults_as_simple_ids[] = $value->ID(); |
|
79 | - } else { |
|
80 | - $defaults_as_simple_ids[] = $value; |
|
81 | - } |
|
82 | - } |
|
83 | - parent::set_default($defaults_as_simple_ids); |
|
84 | - } |
|
68 | + /** |
|
69 | + * if they passed in an array of model objects for the default, convert it |
|
70 | + * into the format EE_Select_Multiple expects |
|
71 | + * @param EE_Base_Class[]|array $values |
|
72 | + */ |
|
73 | + public function set_default($values) |
|
74 | + { |
|
75 | + $defaults_as_simple_ids = array(); |
|
76 | + foreach ($values as $key => $value) { |
|
77 | + if ($value instanceof EE_Base_Class) { |
|
78 | + $defaults_as_simple_ids[] = $value->ID(); |
|
79 | + } else { |
|
80 | + $defaults_as_simple_ids[] = $value; |
|
81 | + } |
|
82 | + } |
|
83 | + parent::set_default($defaults_as_simple_ids); |
|
84 | + } |
|
85 | 85 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | public function __construct($answer_options, $input_settings = array()) |
17 | 17 | { |
18 | 18 | $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)))); |
|
20 | 20 | $this->_multiple_selections = true; |
21 | 21 | parent::__construct($answer_options, $input_settings); |
22 | 22 | } |
@@ -9,15 +9,15 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base |
11 | 11 | { |
12 | - /** |
|
13 | - * @param array | EE_Question_Option[] $answer_options |
|
14 | - * @param array $input_settings |
|
15 | - */ |
|
16 | - public function __construct($answer_options, $input_settings = array()) |
|
17 | - { |
|
18 | - $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
20 | - $this->_multiple_selections = true; |
|
21 | - parent::__construct($answer_options, $input_settings); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @param array | EE_Question_Option[] $answer_options |
|
14 | + * @param array $input_settings |
|
15 | + */ |
|
16 | + public function __construct($answer_options, $input_settings = array()) |
|
17 | + { |
|
18 | + $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
20 | + $this->_multiple_selections = true; |
|
21 | + parent::__construct($answer_options, $input_settings); |
|
22 | + } |
|
23 | 23 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | $normalized_array_value = array(); |
45 | 45 | foreach ($items_to_normalize as $key => $individual_item) { |
46 | - $normalized_array_value[ $key ] = $this->normalize_one($individual_item); |
|
46 | + $normalized_array_value[$key] = $this->normalize_one($individual_item); |
|
47 | 47 | } |
48 | 48 | return $normalized_array_value; |
49 | 49 | } |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | if ($normalized_values === null) { |
75 | 75 | $normalized_values = array(); |
76 | 76 | } |
77 | - if (! is_array($normalized_values)) { |
|
77 | + if ( ! is_array($normalized_values)) { |
|
78 | 78 | $normalized_values = array($normalized_values); |
79 | 79 | } |
80 | 80 | $non_normal_values = array(); |
81 | 81 | foreach ($normalized_values as $key => $value) { |
82 | - $non_normal_values[ $key ] = $this->unnormalize_one($value); |
|
82 | + $non_normal_values[$key] = $this->unnormalize_one($value); |
|
83 | 83 | } |
84 | 84 | return $non_normal_values; |
85 | 85 | } |
@@ -9,90 +9,90 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Many_Valued_Normalization extends EE_Normalization_Strategy_Base |
11 | 11 | { |
12 | - protected $_individual_item_normalization_strategy = array(); |
|
13 | - |
|
14 | - |
|
15 | - |
|
16 | - /** |
|
17 | - * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy |
|
18 | - */ |
|
19 | - public function __construct($individual_item_normalization_strategy) |
|
20 | - { |
|
21 | - $this->_individual_item_normalization_strategy = $individual_item_normalization_strategy; |
|
22 | - parent::__construct(); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * Normalizes the input into an array, and normalizes each item according to its |
|
29 | - * individual item normalization strategy |
|
30 | - * |
|
31 | - * @param array | string $value_to_normalize |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - public function normalize($value_to_normalize) |
|
35 | - { |
|
36 | - if (is_array($value_to_normalize)) { |
|
37 | - $items_to_normalize = $value_to_normalize; |
|
38 | - } elseif ($value_to_normalize !== null) { |
|
39 | - $items_to_normalize = array($value_to_normalize); |
|
40 | - } else { |
|
41 | - $items_to_normalize = array(); |
|
42 | - } |
|
43 | - $normalized_array_value = array(); |
|
44 | - foreach ($items_to_normalize as $key => $individual_item) { |
|
45 | - $normalized_array_value[ $key ] = $this->normalize_one($individual_item); |
|
46 | - } |
|
47 | - return $normalized_array_value; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize()) |
|
54 | - * |
|
55 | - * @param string $individual_value_to_normalize but definitely NOT an array |
|
56 | - * @return mixed |
|
57 | - */ |
|
58 | - public function normalize_one($individual_value_to_normalize) |
|
59 | - { |
|
60 | - return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Converts the array of normalized things to an array of raw html values. |
|
67 | - * |
|
68 | - * @param array $normalized_values |
|
69 | - * @return string[] |
|
70 | - */ |
|
71 | - public function unnormalize($normalized_values) |
|
72 | - { |
|
73 | - if ($normalized_values === null) { |
|
74 | - $normalized_values = array(); |
|
75 | - } |
|
76 | - if (! is_array($normalized_values)) { |
|
77 | - $normalized_values = array($normalized_values); |
|
78 | - } |
|
79 | - $non_normal_values = array(); |
|
80 | - foreach ($normalized_values as $key => $value) { |
|
81 | - $non_normal_values[ $key ] = $this->unnormalize_one($value); |
|
82 | - } |
|
83 | - return $non_normal_values; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Unnormalizes an individual item in the array of values |
|
90 | - * |
|
91 | - * @param mixed $individual_value_to_unnormalize but certainly NOT an array |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function unnormalize_one($individual_value_to_unnormalize) |
|
95 | - { |
|
96 | - return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize); |
|
97 | - } |
|
12 | + protected $_individual_item_normalization_strategy = array(); |
|
13 | + |
|
14 | + |
|
15 | + |
|
16 | + /** |
|
17 | + * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy |
|
18 | + */ |
|
19 | + public function __construct($individual_item_normalization_strategy) |
|
20 | + { |
|
21 | + $this->_individual_item_normalization_strategy = $individual_item_normalization_strategy; |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * Normalizes the input into an array, and normalizes each item according to its |
|
29 | + * individual item normalization strategy |
|
30 | + * |
|
31 | + * @param array | string $value_to_normalize |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + public function normalize($value_to_normalize) |
|
35 | + { |
|
36 | + if (is_array($value_to_normalize)) { |
|
37 | + $items_to_normalize = $value_to_normalize; |
|
38 | + } elseif ($value_to_normalize !== null) { |
|
39 | + $items_to_normalize = array($value_to_normalize); |
|
40 | + } else { |
|
41 | + $items_to_normalize = array(); |
|
42 | + } |
|
43 | + $normalized_array_value = array(); |
|
44 | + foreach ($items_to_normalize as $key => $individual_item) { |
|
45 | + $normalized_array_value[ $key ] = $this->normalize_one($individual_item); |
|
46 | + } |
|
47 | + return $normalized_array_value; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize()) |
|
54 | + * |
|
55 | + * @param string $individual_value_to_normalize but definitely NOT an array |
|
56 | + * @return mixed |
|
57 | + */ |
|
58 | + public function normalize_one($individual_value_to_normalize) |
|
59 | + { |
|
60 | + return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Converts the array of normalized things to an array of raw html values. |
|
67 | + * |
|
68 | + * @param array $normalized_values |
|
69 | + * @return string[] |
|
70 | + */ |
|
71 | + public function unnormalize($normalized_values) |
|
72 | + { |
|
73 | + if ($normalized_values === null) { |
|
74 | + $normalized_values = array(); |
|
75 | + } |
|
76 | + if (! is_array($normalized_values)) { |
|
77 | + $normalized_values = array($normalized_values); |
|
78 | + } |
|
79 | + $non_normal_values = array(); |
|
80 | + foreach ($normalized_values as $key => $value) { |
|
81 | + $non_normal_values[ $key ] = $this->unnormalize_one($value); |
|
82 | + } |
|
83 | + return $non_normal_values; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Unnormalizes an individual item in the array of values |
|
90 | + * |
|
91 | + * @param mixed $individual_value_to_unnormalize but certainly NOT an array |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function unnormalize_one($individual_value_to_unnormalize) |
|
95 | + { |
|
96 | + return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize); |
|
97 | + } |
|
98 | 98 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | // loop through incoming options |
53 | 53 | foreach ($template_options as $key => $value) { |
54 | 54 | // add underscore to $key to match property names |
55 | - $_key = '_' . $key; |
|
55 | + $_key = '_'.$key; |
|
56 | 56 | if (property_exists($this, $_key)) { |
57 | 57 | $this->{$_key} = $value; |
58 | 58 | } |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
183 | 183 | if (strpos($subsection_name, '[') !== false) { |
184 | 184 | $sub_name = explode('[', $subsection_name); |
185 | - $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
185 | + $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
186 | 186 | } else { |
187 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
187 | + $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | // d( $this->_template_args ); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | public static function prep_form_subsection_key_name($subsection_name = '') |
204 | 204 | { |
205 | 205 | $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
206 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
206 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 |
@@ -22,200 +22,200 @@ |
||
22 | 22 | */ |
23 | 23 | class EE_Template_Layout extends EE_Div_Per_Section_Layout |
24 | 24 | { |
25 | - protected $_layout_template_file = null; |
|
26 | - |
|
27 | - protected $_layout_begin_template_file = null; |
|
28 | - |
|
29 | - protected $_input_template_file = null; |
|
30 | - |
|
31 | - protected $_subsection_template_file = null; |
|
32 | - |
|
33 | - protected $_layout_end_template_file = null; |
|
34 | - |
|
35 | - protected $_template_args = array(); |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param array $template_options { |
|
41 | - * @type string $_layout_template_file |
|
42 | - * @type string $_begin_template_file |
|
43 | - * @type string $_input_template_file |
|
44 | - * @type string $_subsection_template_file |
|
45 | - * @type string $_end_template_file |
|
46 | - * @type array $_template_args |
|
47 | - * } |
|
48 | - */ |
|
49 | - public function __construct($template_options = array()) |
|
50 | - { |
|
51 | - // loop through incoming options |
|
52 | - foreach ($template_options as $key => $value) { |
|
53 | - // add underscore to $key to match property names |
|
54 | - $_key = '_' . $key; |
|
55 | - if (property_exists($this, $_key)) { |
|
56 | - $this->{$_key} = $value; |
|
57 | - } |
|
58 | - } |
|
59 | - parent::__construct(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * Also has the side effect of enqueuing any needed JS and CSS for |
|
66 | - * this form. |
|
67 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
68 | - * proper subsections. |
|
69 | - * Returns the HTML |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function layout_form() |
|
74 | - { |
|
75 | - if ($this->_layout_template_file) { |
|
76 | - return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
77 | - } else { |
|
78 | - return parent::layout_form(); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * opening div tag for a form |
|
86 | - * |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function layout_form_begin() |
|
90 | - { |
|
91 | - if ($this->_layout_begin_template_file) { |
|
92 | - return EEH_Template::locate_template( |
|
93 | - $this->_layout_begin_template_file, |
|
94 | - $this->template_args(), |
|
95 | - true, |
|
96 | - true |
|
97 | - ); |
|
98 | - } else { |
|
99 | - return parent::layout_form_begin(); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
107 | - * |
|
108 | - * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
109 | - * @param EE_Form_Input_Base $input |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function layout_input($input) |
|
113 | - { |
|
114 | - if ($this->_input_template_file) { |
|
115 | - return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
116 | - } |
|
117 | - return parent::layout_input($input); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
124 | - * |
|
125 | - * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
126 | - * @param EE_Form_Section_Proper $form_section |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public function layout_subsection($form_section) |
|
130 | - { |
|
131 | - if ($this->_subsection_template_file) { |
|
132 | - return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
133 | - } |
|
134 | - return parent::layout_subsection($form_section); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * closing div tag for a form |
|
141 | - * |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function layout_form_end() |
|
145 | - { |
|
146 | - if ($this->_layout_end_template_file) { |
|
147 | - return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
148 | - } else { |
|
149 | - return parent::layout_form_end(); |
|
150 | - } |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @param array $template_args |
|
157 | - */ |
|
158 | - public function set_template_args($template_args = array()) |
|
159 | - { |
|
160 | - $this->_template_args = $template_args; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param array $template_args |
|
167 | - */ |
|
168 | - public function add_template_args($template_args = array()) |
|
169 | - { |
|
170 | - $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * @return array |
|
177 | - */ |
|
178 | - public function template_args() |
|
179 | - { |
|
180 | - foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
181 | - $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
182 | - if (strpos($subsection_name, '[') !== false) { |
|
183 | - $sub_name = explode('[', $subsection_name); |
|
184 | - $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
185 | - } else { |
|
186 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
187 | - } |
|
188 | - } |
|
189 | - // d( $this->_template_args ); |
|
190 | - return $this->_template_args; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * prep_form_section_key_name |
|
197 | - * |
|
198 | - * @access public |
|
199 | - * @param string $subsection_name |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public static function prep_form_subsection_key_name($subsection_name = '') |
|
203 | - { |
|
204 | - $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
205 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * get_subform - just a wrapper for the above method |
|
212 | - * |
|
213 | - * @access public |
|
214 | - * @param string $subsection_name |
|
215 | - * @return string |
|
216 | - */ |
|
217 | - public static function get_subform_name($subsection_name = '') |
|
218 | - { |
|
219 | - return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
220 | - } |
|
25 | + protected $_layout_template_file = null; |
|
26 | + |
|
27 | + protected $_layout_begin_template_file = null; |
|
28 | + |
|
29 | + protected $_input_template_file = null; |
|
30 | + |
|
31 | + protected $_subsection_template_file = null; |
|
32 | + |
|
33 | + protected $_layout_end_template_file = null; |
|
34 | + |
|
35 | + protected $_template_args = array(); |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param array $template_options { |
|
41 | + * @type string $_layout_template_file |
|
42 | + * @type string $_begin_template_file |
|
43 | + * @type string $_input_template_file |
|
44 | + * @type string $_subsection_template_file |
|
45 | + * @type string $_end_template_file |
|
46 | + * @type array $_template_args |
|
47 | + * } |
|
48 | + */ |
|
49 | + public function __construct($template_options = array()) |
|
50 | + { |
|
51 | + // loop through incoming options |
|
52 | + foreach ($template_options as $key => $value) { |
|
53 | + // add underscore to $key to match property names |
|
54 | + $_key = '_' . $key; |
|
55 | + if (property_exists($this, $_key)) { |
|
56 | + $this->{$_key} = $value; |
|
57 | + } |
|
58 | + } |
|
59 | + parent::__construct(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * Also has the side effect of enqueuing any needed JS and CSS for |
|
66 | + * this form. |
|
67 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
68 | + * proper subsections. |
|
69 | + * Returns the HTML |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function layout_form() |
|
74 | + { |
|
75 | + if ($this->_layout_template_file) { |
|
76 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
77 | + } else { |
|
78 | + return parent::layout_form(); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * opening div tag for a form |
|
86 | + * |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function layout_form_begin() |
|
90 | + { |
|
91 | + if ($this->_layout_begin_template_file) { |
|
92 | + return EEH_Template::locate_template( |
|
93 | + $this->_layout_begin_template_file, |
|
94 | + $this->template_args(), |
|
95 | + true, |
|
96 | + true |
|
97 | + ); |
|
98 | + } else { |
|
99 | + return parent::layout_form_begin(); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
107 | + * |
|
108 | + * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
109 | + * @param EE_Form_Input_Base $input |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function layout_input($input) |
|
113 | + { |
|
114 | + if ($this->_input_template_file) { |
|
115 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
116 | + } |
|
117 | + return parent::layout_input($input); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
124 | + * |
|
125 | + * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
126 | + * @param EE_Form_Section_Proper $form_section |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public function layout_subsection($form_section) |
|
130 | + { |
|
131 | + if ($this->_subsection_template_file) { |
|
132 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
133 | + } |
|
134 | + return parent::layout_subsection($form_section); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * closing div tag for a form |
|
141 | + * |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function layout_form_end() |
|
145 | + { |
|
146 | + if ($this->_layout_end_template_file) { |
|
147 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
148 | + } else { |
|
149 | + return parent::layout_form_end(); |
|
150 | + } |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @param array $template_args |
|
157 | + */ |
|
158 | + public function set_template_args($template_args = array()) |
|
159 | + { |
|
160 | + $this->_template_args = $template_args; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param array $template_args |
|
167 | + */ |
|
168 | + public function add_template_args($template_args = array()) |
|
169 | + { |
|
170 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * @return array |
|
177 | + */ |
|
178 | + public function template_args() |
|
179 | + { |
|
180 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
181 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
182 | + if (strpos($subsection_name, '[') !== false) { |
|
183 | + $sub_name = explode('[', $subsection_name); |
|
184 | + $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
185 | + } else { |
|
186 | + $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
187 | + } |
|
188 | + } |
|
189 | + // d( $this->_template_args ); |
|
190 | + return $this->_template_args; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * prep_form_section_key_name |
|
197 | + * |
|
198 | + * @access public |
|
199 | + * @param string $subsection_name |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public static function prep_form_subsection_key_name($subsection_name = '') |
|
203 | + { |
|
204 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
205 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * get_subform - just a wrapper for the above method |
|
212 | + * |
|
213 | + * @access public |
|
214 | + * @param string $subsection_name |
|
215 | + * @return string |
|
216 | + */ |
|
217 | + public static function get_subform_name($subsection_name = '') |
|
218 | + { |
|
219 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
220 | + } |
|
221 | 221 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function __construct($options = array()) |
37 | 37 | { |
38 | 38 | foreach ($options as $key => $value) { |
39 | - $key = '_' . $key; |
|
39 | + $key = '_'.$key; |
|
40 | 40 | if (property_exists($this, $key)) { |
41 | 41 | $this->{$key} = $value; |
42 | 42 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | . '" style="' |
61 | 61 | . $this->_form_section->html_style() |
62 | 62 | . '">'; |
63 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
63 | + $html .= '<legend class="'.$this->legend_class().'">'.$this->legend_text().'</legend>'; |
|
64 | 64 | return $html; |
65 | 65 | } |
66 | 66 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function layout_form_end() |
75 | 75 | { |
76 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
76 | + return EEH_HTML::nl(-1).'</fieldset>'; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 |
@@ -11,107 +11,107 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Fieldset_Section_Layout extends EE_Div_Per_Section_Layout |
13 | 13 | { |
14 | - /** |
|
15 | - * legend_class |
|
16 | - * |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - protected $_legend_class; |
|
20 | - |
|
21 | - /** |
|
22 | - * legend_text |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $_legend_text; |
|
27 | - |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * construct |
|
32 | - * |
|
33 | - * @param array $options |
|
34 | - */ |
|
35 | - public function __construct($options = array()) |
|
36 | - { |
|
37 | - foreach ($options as $key => $value) { |
|
38 | - $key = '_' . $key; |
|
39 | - if (property_exists($this, $key)) { |
|
40 | - $this->{$key} = $value; |
|
41 | - } |
|
42 | - } |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * opening div tag for a form |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function layout_form_begin() |
|
53 | - { |
|
54 | - $html = EEH_HTML::nl(1) |
|
55 | - . '<fieldset id="' |
|
56 | - . $this->_form_section->html_id() |
|
57 | - . '" class="' |
|
58 | - . $this->_form_section->html_class() |
|
59 | - . '" style="' |
|
60 | - . $this->_form_section->html_style() |
|
61 | - . '">'; |
|
62 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
63 | - return $html; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * closing div tag for a form |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function layout_form_end() |
|
74 | - { |
|
75 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $legend_class |
|
82 | - */ |
|
83 | - public function set_legend_class($legend_class) |
|
84 | - { |
|
85 | - $this->_legend_class = $legend_class; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function legend_class() |
|
94 | - { |
|
95 | - return $this->_legend_class; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @param string $legend_text |
|
102 | - */ |
|
103 | - public function set_legend_text($legend_text) |
|
104 | - { |
|
105 | - $this->_legend_text = $legend_text; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function legend_text() |
|
114 | - { |
|
115 | - return $this->_legend_text; |
|
116 | - } |
|
14 | + /** |
|
15 | + * legend_class |
|
16 | + * |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + protected $_legend_class; |
|
20 | + |
|
21 | + /** |
|
22 | + * legend_text |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $_legend_text; |
|
27 | + |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * construct |
|
32 | + * |
|
33 | + * @param array $options |
|
34 | + */ |
|
35 | + public function __construct($options = array()) |
|
36 | + { |
|
37 | + foreach ($options as $key => $value) { |
|
38 | + $key = '_' . $key; |
|
39 | + if (property_exists($this, $key)) { |
|
40 | + $this->{$key} = $value; |
|
41 | + } |
|
42 | + } |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * opening div tag for a form |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function layout_form_begin() |
|
53 | + { |
|
54 | + $html = EEH_HTML::nl(1) |
|
55 | + . '<fieldset id="' |
|
56 | + . $this->_form_section->html_id() |
|
57 | + . '" class="' |
|
58 | + . $this->_form_section->html_class() |
|
59 | + . '" style="' |
|
60 | + . $this->_form_section->html_style() |
|
61 | + . '">'; |
|
62 | + $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
63 | + return $html; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * closing div tag for a form |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function layout_form_end() |
|
74 | + { |
|
75 | + return EEH_HTML::nl(-1) . '</fieldset>'; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $legend_class |
|
82 | + */ |
|
83 | + public function set_legend_class($legend_class) |
|
84 | + { |
|
85 | + $this->_legend_class = $legend_class; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function legend_class() |
|
94 | + { |
|
95 | + return $this->_legend_class; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @param string $legend_text |
|
102 | + */ |
|
103 | + public function set_legend_text($legend_text) |
|
104 | + { |
|
105 | + $this->_legend_text = $legend_text; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function legend_text() |
|
114 | + { |
|
115 | + return $this->_legend_text; |
|
116 | + } |
|
117 | 117 | } |