@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | 'priority' => 'high', |
38 | 38 | 'context' => 'normal', |
39 | 39 | ), |
40 | - );/**/ |
|
40 | + ); /**/ |
|
41 | 41 | |
42 | 42 | $this->_scripts_styles = array( |
43 | 43 | 'registers' => array( |
44 | 44 | 'ee_event_venues' => array( |
45 | 45 | 'type' => 'js', |
46 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
46 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.js', |
|
47 | 47 | 'depends' => array('jquery'), |
48 | 48 | ), |
49 | 49 | 'ee_event_venues_css' => array( |
50 | 50 | 'type' => 'css', |
51 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
51 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.css', |
|
52 | 52 | ), |
53 | 53 | ), |
54 | 54 | 'enqueues' => array( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // first remove default venue callback |
75 | 75 | foreach ($callbacks as $key => $callback) { |
76 | 76 | if ($callback[1] == '_default_venue_update') { |
77 | - unset($callbacks[ $key ]); |
|
77 | + unset($callbacks[$key]); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | // cap checks |
105 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
105 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | 106 | $vnu_where['VNU_wp_user'] = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | $ven_select[0] = __('Select a Venue', 'event_espresso'); |
114 | 114 | // setup venues for selector |
115 | 115 | foreach ($venues as $venue) { |
116 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
116 | + $ven_select[$venue->ID()] = $venue->name(); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
120 | 120 | // show existing attached venues even if it's trashed (or some other restricted status). |
121 | 121 | |
122 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
122 | + if ($evt_venue_id && ! isset($ven_select[$evt_venue_id])) { |
|
123 | + $ven_select[$evt_venue_id] = $evt_venue->name(); |
|
124 | 124 | $venues = array_merge($venues, array($evt_venue)); |
125 | 125 | } |
126 | 126 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ); |
185 | 185 | |
186 | 186 | $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
187 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
187 | + : EE_VENUES_TEMPLATE_PATH.'event_venues_metabox_content_from_manager.template.php'; |
|
188 | 188 | |
189 | 189 | // Allow events venue metabox template args filtering. |
190 | 190 | $template_args = apply_filters( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $evt_venue = $evtobj->venues(); |
208 | 208 | $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
209 | 209 | |
210 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
210 | + if ( ! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | 211 | $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
212 | 212 | } |
213 | 213 |
@@ -16,207 +16,207 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - protected $_event; |
|
20 | - |
|
21 | - |
|
22 | - public function __construct(EE_Admin_Page $admin_page) |
|
23 | - { |
|
24 | - parent::__construct($admin_page); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _set_hooks_properties() |
|
29 | - { |
|
30 | - $this->_name = 'venues'; |
|
31 | - |
|
32 | - $this->_metaboxes = array( |
|
33 | - 0 => array( |
|
34 | - 'page_route' => array('edit', 'create_new'), |
|
35 | - 'func' => 'venue_metabox', |
|
36 | - 'label' => __('Venue Details', 'event_espresso'), |
|
37 | - 'priority' => 'high', |
|
38 | - 'context' => 'normal', |
|
39 | - ), |
|
40 | - );/**/ |
|
41 | - |
|
42 | - $this->_scripts_styles = array( |
|
43 | - 'registers' => array( |
|
44 | - 'ee_event_venues' => array( |
|
45 | - 'type' => 'js', |
|
46 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
47 | - 'depends' => array('jquery'), |
|
48 | - ), |
|
49 | - 'ee_event_venues_css' => array( |
|
50 | - 'type' => 'css', |
|
51 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
52 | - ), |
|
53 | - ), |
|
54 | - 'enqueues' => array( |
|
55 | - 'ee_event_venues' => array('edit', 'create_new'), |
|
56 | - 'ee_event_venues_css' => array('edit', 'create_new'), |
|
57 | - ), |
|
58 | - ); |
|
59 | - |
|
60 | - // hook into the handler for saving venue |
|
61 | - add_filter( |
|
62 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
63 | - array($this, 'modify_callbacks'), |
|
64 | - 10 |
|
65 | - ); |
|
66 | - |
|
67 | - // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
68 | - add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - public function modify_callbacks($callbacks) |
|
73 | - { |
|
74 | - // first remove default venue callback |
|
75 | - foreach ($callbacks as $key => $callback) { |
|
76 | - if ($callback[1] == '_default_venue_update') { |
|
77 | - unset($callbacks[ $key ]); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - // now let's add the caf version |
|
82 | - $callbacks[] = array($this, 'caf_venue_update'); |
|
83 | - return $callbacks; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - public function venue_metabox() |
|
88 | - { |
|
89 | - $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
90 | - $evt_id = $evt_obj->ID(); |
|
91 | - |
|
92 | - // first let's see if we have a venue already |
|
93 | - $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
94 | - $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
95 | - $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
96 | - |
|
97 | - // possibly private venues. |
|
98 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
99 | - $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
100 | - } else { |
|
101 | - $vnu_where['status'] = 'publish'; |
|
102 | - } |
|
103 | - |
|
104 | - // cap checks |
|
105 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | - $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
107 | - } |
|
108 | - |
|
109 | - $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
110 | - $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
111 | - |
|
112 | - $ven_select = array(); |
|
113 | - $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
114 | - // setup venues for selector |
|
115 | - foreach ($venues as $venue) { |
|
116 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
117 | - } |
|
118 | - |
|
119 | - // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
120 | - // show existing attached venues even if it's trashed (or some other restricted status). |
|
121 | - |
|
122 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
124 | - $venues = array_merge($venues, array($evt_venue)); |
|
125 | - } |
|
126 | - |
|
127 | - $template_args['venues'] = $venues; |
|
128 | - $template_args['evt_venue_id'] = $evt_venue_id; |
|
129 | - $venue_selector = new EE_Select_Input( |
|
130 | - $ven_select, |
|
131 | - array( |
|
132 | - 'html_name' => 'venue_id', |
|
133 | - 'html_id' => 'venue_id', |
|
134 | - 'html_class' => 'wide', |
|
135 | - 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
136 | - ) |
|
137 | - ); |
|
138 | - $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
139 | - $enable_for_gmap = new EE_Yes_No_Input( |
|
140 | - array( |
|
141 | - 'html_name' => 'enable_for_gmap', |
|
142 | - 'html_id' => 'enable_for_gmap', |
|
143 | - 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
144 | - ) |
|
145 | - ); |
|
146 | - $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
147 | - $template_args['new_venue_link'] = EEH_HTML::link( |
|
148 | - EE_Admin_Page::add_query_args_and_nonce( |
|
149 | - array('action' => 'create_new'), |
|
150 | - EE_VENUES_ADMIN_URL |
|
151 | - ), |
|
152 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
153 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
154 | - 'ev_new_venue_link', |
|
155 | - 'button', |
|
156 | - 'margin-left:10px;', |
|
157 | - 'target="_blank"' |
|
158 | - ); |
|
159 | - |
|
160 | - // Decide on an info text when there are no venues to display. |
|
161 | - $no_venues_info_txt = esc_html_x( |
|
162 | - 'You have not created any venues yet.', |
|
163 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
164 | - 'event_espresso' |
|
165 | - ); |
|
166 | - if (empty($venues)) { |
|
167 | - $unpublished_where = $vnu_where; |
|
168 | - $unpublished_where['status'] = 'draft'; |
|
169 | - $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
170 | - if (count($unpublished_venues) > 0) { |
|
171 | - $no_venues_info_txt = esc_html_x( |
|
172 | - // @codingStandardsIgnoreStart |
|
173 | - 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
174 | - // @codingStandardsIgnoreEnd |
|
175 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
176 | - 'event_espresso' |
|
177 | - ); |
|
178 | - } |
|
179 | - } |
|
180 | - $template_args['no_venues_info'] = EEH_HTML::p( |
|
181 | - EEH_HTML::strong($no_venues_info_txt), |
|
182 | - 'no_venues_info', |
|
183 | - 'info' |
|
184 | - ); |
|
185 | - |
|
186 | - $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
187 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
188 | - |
|
189 | - // Allow events venue metabox template args filtering. |
|
190 | - $template_args = apply_filters( |
|
191 | - 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
192 | - $template_args, |
|
193 | - $template_path |
|
194 | - ); |
|
195 | - |
|
196 | - EEH_Template::display_template($template_path, $template_args); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - public function caf_venue_update($evtobj, $data) |
|
201 | - { |
|
202 | - EE_Registry::instance()->load_model('Venue'); |
|
203 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
204 | - |
|
205 | - |
|
206 | - // first let's check if the selected venue matches any existing venue attached to the event |
|
207 | - $evt_venue = $evtobj->venues(); |
|
208 | - $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
209 | - |
|
210 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | - $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
212 | - } |
|
213 | - |
|
214 | - if (empty($venue_id)) { |
|
215 | - return true; |
|
216 | - } //no venue to attach |
|
217 | - |
|
218 | - // this should take care of adding to revisions as well as main post object |
|
219 | - $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
220 | - return ! empty($success) ? true : false; |
|
221 | - } |
|
19 | + protected $_event; |
|
20 | + |
|
21 | + |
|
22 | + public function __construct(EE_Admin_Page $admin_page) |
|
23 | + { |
|
24 | + parent::__construct($admin_page); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _set_hooks_properties() |
|
29 | + { |
|
30 | + $this->_name = 'venues'; |
|
31 | + |
|
32 | + $this->_metaboxes = array( |
|
33 | + 0 => array( |
|
34 | + 'page_route' => array('edit', 'create_new'), |
|
35 | + 'func' => 'venue_metabox', |
|
36 | + 'label' => __('Venue Details', 'event_espresso'), |
|
37 | + 'priority' => 'high', |
|
38 | + 'context' => 'normal', |
|
39 | + ), |
|
40 | + );/**/ |
|
41 | + |
|
42 | + $this->_scripts_styles = array( |
|
43 | + 'registers' => array( |
|
44 | + 'ee_event_venues' => array( |
|
45 | + 'type' => 'js', |
|
46 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
47 | + 'depends' => array('jquery'), |
|
48 | + ), |
|
49 | + 'ee_event_venues_css' => array( |
|
50 | + 'type' => 'css', |
|
51 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
52 | + ), |
|
53 | + ), |
|
54 | + 'enqueues' => array( |
|
55 | + 'ee_event_venues' => array('edit', 'create_new'), |
|
56 | + 'ee_event_venues_css' => array('edit', 'create_new'), |
|
57 | + ), |
|
58 | + ); |
|
59 | + |
|
60 | + // hook into the handler for saving venue |
|
61 | + add_filter( |
|
62 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
63 | + array($this, 'modify_callbacks'), |
|
64 | + 10 |
|
65 | + ); |
|
66 | + |
|
67 | + // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
68 | + add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + public function modify_callbacks($callbacks) |
|
73 | + { |
|
74 | + // first remove default venue callback |
|
75 | + foreach ($callbacks as $key => $callback) { |
|
76 | + if ($callback[1] == '_default_venue_update') { |
|
77 | + unset($callbacks[ $key ]); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + // now let's add the caf version |
|
82 | + $callbacks[] = array($this, 'caf_venue_update'); |
|
83 | + return $callbacks; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + public function venue_metabox() |
|
88 | + { |
|
89 | + $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
90 | + $evt_id = $evt_obj->ID(); |
|
91 | + |
|
92 | + // first let's see if we have a venue already |
|
93 | + $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
94 | + $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
95 | + $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
96 | + |
|
97 | + // possibly private venues. |
|
98 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
99 | + $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
100 | + } else { |
|
101 | + $vnu_where['status'] = 'publish'; |
|
102 | + } |
|
103 | + |
|
104 | + // cap checks |
|
105 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | + $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
107 | + } |
|
108 | + |
|
109 | + $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
110 | + $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
111 | + |
|
112 | + $ven_select = array(); |
|
113 | + $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
114 | + // setup venues for selector |
|
115 | + foreach ($venues as $venue) { |
|
116 | + $ven_select[ $venue->ID() ] = $venue->name(); |
|
117 | + } |
|
118 | + |
|
119 | + // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
120 | + // show existing attached venues even if it's trashed (or some other restricted status). |
|
121 | + |
|
122 | + if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | + $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
124 | + $venues = array_merge($venues, array($evt_venue)); |
|
125 | + } |
|
126 | + |
|
127 | + $template_args['venues'] = $venues; |
|
128 | + $template_args['evt_venue_id'] = $evt_venue_id; |
|
129 | + $venue_selector = new EE_Select_Input( |
|
130 | + $ven_select, |
|
131 | + array( |
|
132 | + 'html_name' => 'venue_id', |
|
133 | + 'html_id' => 'venue_id', |
|
134 | + 'html_class' => 'wide', |
|
135 | + 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
136 | + ) |
|
137 | + ); |
|
138 | + $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
139 | + $enable_for_gmap = new EE_Yes_No_Input( |
|
140 | + array( |
|
141 | + 'html_name' => 'enable_for_gmap', |
|
142 | + 'html_id' => 'enable_for_gmap', |
|
143 | + 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
144 | + ) |
|
145 | + ); |
|
146 | + $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
147 | + $template_args['new_venue_link'] = EEH_HTML::link( |
|
148 | + EE_Admin_Page::add_query_args_and_nonce( |
|
149 | + array('action' => 'create_new'), |
|
150 | + EE_VENUES_ADMIN_URL |
|
151 | + ), |
|
152 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
153 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
154 | + 'ev_new_venue_link', |
|
155 | + 'button', |
|
156 | + 'margin-left:10px;', |
|
157 | + 'target="_blank"' |
|
158 | + ); |
|
159 | + |
|
160 | + // Decide on an info text when there are no venues to display. |
|
161 | + $no_venues_info_txt = esc_html_x( |
|
162 | + 'You have not created any venues yet.', |
|
163 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
164 | + 'event_espresso' |
|
165 | + ); |
|
166 | + if (empty($venues)) { |
|
167 | + $unpublished_where = $vnu_where; |
|
168 | + $unpublished_where['status'] = 'draft'; |
|
169 | + $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
170 | + if (count($unpublished_venues) > 0) { |
|
171 | + $no_venues_info_txt = esc_html_x( |
|
172 | + // @codingStandardsIgnoreStart |
|
173 | + 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
174 | + // @codingStandardsIgnoreEnd |
|
175 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
176 | + 'event_espresso' |
|
177 | + ); |
|
178 | + } |
|
179 | + } |
|
180 | + $template_args['no_venues_info'] = EEH_HTML::p( |
|
181 | + EEH_HTML::strong($no_venues_info_txt), |
|
182 | + 'no_venues_info', |
|
183 | + 'info' |
|
184 | + ); |
|
185 | + |
|
186 | + $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
187 | + : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
188 | + |
|
189 | + // Allow events venue metabox template args filtering. |
|
190 | + $template_args = apply_filters( |
|
191 | + 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
192 | + $template_args, |
|
193 | + $template_path |
|
194 | + ); |
|
195 | + |
|
196 | + EEH_Template::display_template($template_path, $template_args); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + public function caf_venue_update($evtobj, $data) |
|
201 | + { |
|
202 | + EE_Registry::instance()->load_model('Venue'); |
|
203 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
204 | + |
|
205 | + |
|
206 | + // first let's check if the selected venue matches any existing venue attached to the event |
|
207 | + $evt_venue = $evtobj->venues(); |
|
208 | + $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
209 | + |
|
210 | + if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | + $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
212 | + } |
|
213 | + |
|
214 | + if (empty($venue_id)) { |
|
215 | + return true; |
|
216 | + } //no venue to attach |
|
217 | + |
|
218 | + // this should take care of adding to revisions as well as main post object |
|
219 | + $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
220 | + return ! empty($success) ? true : false; |
|
221 | + } |
|
222 | 222 | } |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | <?php echo $venue_selector; ?> |
6 | 6 | <?php echo $new_venue_link; ?> |
7 | 7 | <?php foreach ($venues as $venue) : |
8 | - $selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"'; |
|
9 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
10 | - array('action' => 'edit', 'post' => $venue->ID()), |
|
11 | - EE_VENUES_ADMIN_URL |
|
12 | - ); |
|
13 | - $state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null; |
|
14 | - $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null; |
|
15 | - ?> |
|
8 | + $selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"'; |
|
9 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
10 | + array('action' => 'edit', 'post' => $venue->ID()), |
|
11 | + EE_VENUES_ADMIN_URL |
|
12 | + ); |
|
13 | + $state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null; |
|
14 | + $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null; |
|
15 | + ?> |
|
16 | 16 | <fieldset id="eebox_<?php echo $venue->ID(); ?>" class="eebox"<?php echo $selected; ?>> |
17 | 17 | <ul class="address-view"> |
18 | 18 | <li> |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | <br/></p> |
28 | 28 | <a href="<?php echo $edit_url; ?>" target="_blank"> |
29 | 29 | <?php _e( |
30 | - 'Edit this Venue', |
|
31 | - 'event_espresso' |
|
32 | - ); ?></a> |
|
30 | + 'Edit this Venue', |
|
31 | + 'event_espresso' |
|
32 | + ); ?></a> |
|
33 | 33 | </li> |
34 | 34 | </ul> |
35 | 35 | </fieldset> |
@@ -15,9 +15,9 @@ |
||
15 | 15 | interface RequestTypeContextFactoryInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param string $slug |
|
20 | - * @return RequestTypeContext |
|
21 | - */ |
|
22 | - public function create($slug); |
|
18 | + /** |
|
19 | + * @param string $slug |
|
20 | + * @return RequestTypeContext |
|
21 | + */ |
|
22 | + public function create($slug); |
|
23 | 23 | } |
@@ -5,9 +5,9 @@ |
||
5 | 5 | <?php echo $no_venues_info; ?> |
6 | 6 | <p><a href="admin.php?page=espresso_venues" target="_blank"> |
7 | 7 | <?php echo __( |
8 | - 'Add venues to the Venue Manager', |
|
9 | - 'event_espresso' |
|
10 | - ) ?></a></p> |
|
8 | + 'Add venues to the Venue Manager', |
|
9 | + 'event_espresso' |
|
10 | + ) ?></a></p> |
|
11 | 11 | </fieldset> |
12 | 12 | </td> |
13 | 13 | </tr> |
@@ -14,80 +14,80 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Country_Select_Input extends EE_Select_Input |
16 | 16 | { |
17 | - /** |
|
18 | - * $input_settings key used for detecting the "get" option |
|
19 | - */ |
|
20 | - const OPTION_GET_KEY = 'get'; |
|
17 | + /** |
|
18 | + * $input_settings key used for detecting the "get" option |
|
19 | + */ |
|
20 | + const OPTION_GET_KEY = 'get'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * indicates that ALL countries should be retrieved from the db for the input |
|
24 | - */ |
|
25 | - const OPTION_GET_ALL = 'all'; |
|
22 | + /** |
|
23 | + * indicates that ALL countries should be retrieved from the db for the input |
|
24 | + */ |
|
25 | + const OPTION_GET_ALL = 'all'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
29 | - */ |
|
30 | - const OPTION_GET_ACTIVE = 'active'; |
|
27 | + /** |
|
28 | + * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
29 | + */ |
|
30 | + const OPTION_GET_ACTIVE = 'active'; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param array $country_options |
|
35 | - * @param array $input_settings |
|
36 | - * @throws EE_Error |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - * @throws ReflectionException |
|
41 | - */ |
|
42 | - public function __construct($country_options = null, $input_settings = array()) |
|
43 | - { |
|
44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
46 | - : self::OPTION_GET_ACTIVE; |
|
47 | - $country_options = apply_filters( |
|
48 | - 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
49 | - $this->get_country_answer_options($country_options, $get), |
|
50 | - $this, |
|
51 | - $get |
|
52 | - ); |
|
53 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
55 | - : 'ee-country-select-js'; |
|
56 | - parent::__construct($country_options, $input_settings); |
|
57 | - } |
|
33 | + /** |
|
34 | + * @param array $country_options |
|
35 | + * @param array $input_settings |
|
36 | + * @throws EE_Error |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + * @throws ReflectionException |
|
41 | + */ |
|
42 | + public function __construct($country_options = null, $input_settings = array()) |
|
43 | + { |
|
44 | + $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | + ? $input_settings[ self::OPTION_GET_KEY ] |
|
46 | + : self::OPTION_GET_ACTIVE; |
|
47 | + $country_options = apply_filters( |
|
48 | + 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
49 | + $this->get_country_answer_options($country_options, $get), |
|
50 | + $this, |
|
51 | + $get |
|
52 | + ); |
|
53 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
54 | + ? $input_settings['html_class'] . ' ee-country-select-js' |
|
55 | + : 'ee-country-select-js'; |
|
56 | + parent::__construct($country_options, $input_settings); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * get_country_answer_options |
|
62 | - * |
|
63 | - * @param array $country_options |
|
64 | - * @param string $get |
|
65 | - * @return array |
|
66 | - * @throws EE_Error |
|
67 | - * @throws InvalidArgumentException |
|
68 | - * @throws ReflectionException |
|
69 | - * @throws InvalidDataTypeException |
|
70 | - * @throws InvalidInterfaceException |
|
71 | - */ |
|
72 | - public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
73 | - { |
|
74 | - // if passed something that is NOT an array |
|
75 | - if (! is_array($country_options)) { |
|
76 | - // get possibly cached list of countries |
|
77 | - $countries = $get === self::OPTION_GET_ALL |
|
78 | - ? EEM_Country::instance()->get_all_countries() |
|
79 | - : EEM_Country::instance()->get_all_active_countries(); |
|
80 | - if (! empty($countries)) { |
|
81 | - $country_options[''] = ''; |
|
82 | - foreach ($countries as $country) { |
|
83 | - if ($country instanceof EE_Country) { |
|
84 | - $country_options[ $country->ID() ] = $country->name(); |
|
85 | - } |
|
86 | - } |
|
87 | - } else { |
|
88 | - $country_options = array(); |
|
89 | - } |
|
90 | - } |
|
91 | - return $country_options; |
|
92 | - } |
|
60 | + /** |
|
61 | + * get_country_answer_options |
|
62 | + * |
|
63 | + * @param array $country_options |
|
64 | + * @param string $get |
|
65 | + * @return array |
|
66 | + * @throws EE_Error |
|
67 | + * @throws InvalidArgumentException |
|
68 | + * @throws ReflectionException |
|
69 | + * @throws InvalidDataTypeException |
|
70 | + * @throws InvalidInterfaceException |
|
71 | + */ |
|
72 | + public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
73 | + { |
|
74 | + // if passed something that is NOT an array |
|
75 | + if (! is_array($country_options)) { |
|
76 | + // get possibly cached list of countries |
|
77 | + $countries = $get === self::OPTION_GET_ALL |
|
78 | + ? EEM_Country::instance()->get_all_countries() |
|
79 | + : EEM_Country::instance()->get_all_active_countries(); |
|
80 | + if (! empty($countries)) { |
|
81 | + $country_options[''] = ''; |
|
82 | + foreach ($countries as $country) { |
|
83 | + if ($country instanceof EE_Country) { |
|
84 | + $country_options[ $country->ID() ] = $country->name(); |
|
85 | + } |
|
86 | + } |
|
87 | + } else { |
|
88 | + $country_options = array(); |
|
89 | + } |
|
90 | + } |
|
91 | + return $country_options; |
|
92 | + } |
|
93 | 93 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct($country_options = null, $input_settings = array()) |
43 | 43 | { |
44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
44 | + $get = isset($input_settings[self::OPTION_GET_KEY]) |
|
45 | + ? $input_settings[self::OPTION_GET_KEY] |
|
46 | 46 | : self::OPTION_GET_ACTIVE; |
47 | 47 | $country_options = apply_filters( |
48 | 48 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $get |
52 | 52 | ); |
53 | 53 | $input_settings['html_class'] = isset($input_settings['html_class']) |
54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
54 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
55 | 55 | : 'ee-country-select-js'; |
56 | 56 | parent::__construct($country_options, $input_settings); |
57 | 57 | } |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
73 | 73 | { |
74 | 74 | // if passed something that is NOT an array |
75 | - if (! is_array($country_options)) { |
|
75 | + if ( ! is_array($country_options)) { |
|
76 | 76 | // get possibly cached list of countries |
77 | 77 | $countries = $get === self::OPTION_GET_ALL |
78 | 78 | ? EEM_Country::instance()->get_all_countries() |
79 | 79 | : EEM_Country::instance()->get_all_active_countries(); |
80 | - if (! empty($countries)) { |
|
80 | + if ( ! empty($countries)) { |
|
81 | 81 | $country_options[''] = ''; |
82 | 82 | foreach ($countries as $country) { |
83 | 83 | if ($country instanceof EE_Country) { |
84 | - $country_options[ $country->ID() ] = $country->name(); |
|
84 | + $country_options[$country->ID()] = $country->name(); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } else { |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function isValid($file, $func, $line) |
34 | 34 | { |
35 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
35 | + if ( ! defined('JSON_ERROR_RECURSION')) { |
|
36 | 36 | define('JSON_ERROR_RECURSION', 6); |
37 | 37 | } |
38 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
38 | + if ( ! defined('JSON_ERROR_INF_OR_NAN')) { |
|
39 | 39 | define('JSON_ERROR_INF_OR_NAN', 7); |
40 | 40 | } |
41 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
41 | + if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
42 | 42 | define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
43 | 43 | } |
44 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
44 | + if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
45 | 45 | define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
46 | 46 | } |
47 | - if (! defined('JSON_ERROR_UTF16')) { |
|
47 | + if ( ! defined('JSON_ERROR_UTF16')) { |
|
48 | 48 | define('JSON_ERROR_UTF16', 10); |
49 | 49 | } |
50 | 50 | switch (json_last_error()) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $error = ': Unknown error'; |
85 | 85 | break; |
86 | 86 | } |
87 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
87 | + EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line); |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | } |
@@ -18,76 +18,76 @@ |
||
18 | 18 | class JsonValidator |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Call this method IMMEDIATELY after json_decode() and |
|
23 | - * it will will return true if the decoded JSON was valid, |
|
24 | - * or return false after adding an error if not valid. |
|
25 | - * The actual JSON file does not need to be supplied, |
|
26 | - * but details re: code execution location are required. |
|
27 | - * ex: |
|
28 | - * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
29 | - * |
|
30 | - * @param string $file |
|
31 | - * @param string $func |
|
32 | - * @param string $line |
|
33 | - * @return boolean |
|
34 | - * @since 4.9.70.p |
|
35 | - */ |
|
36 | - public function isValid($file, $func, $line) |
|
37 | - { |
|
38 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
39 | - define('JSON_ERROR_RECURSION', 6); |
|
40 | - } |
|
41 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
42 | - define('JSON_ERROR_INF_OR_NAN', 7); |
|
43 | - } |
|
44 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
45 | - define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
46 | - } |
|
47 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
48 | - define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
49 | - } |
|
50 | - if (! defined('JSON_ERROR_UTF16')) { |
|
51 | - define('JSON_ERROR_UTF16', 10); |
|
52 | - } |
|
53 | - switch (json_last_error()) { |
|
54 | - case JSON_ERROR_NONE: |
|
55 | - return true; |
|
56 | - case JSON_ERROR_DEPTH: |
|
57 | - $error = ': Maximum stack depth exceeded'; |
|
58 | - break; |
|
59 | - case JSON_ERROR_STATE_MISMATCH: |
|
60 | - $error = ': Invalid or malformed JSON'; |
|
61 | - break; |
|
62 | - case JSON_ERROR_CTRL_CHAR: |
|
63 | - $error = ': Control character error, possible malformed JSON'; |
|
64 | - break; |
|
65 | - case JSON_ERROR_SYNTAX: |
|
66 | - $error = ': Syntax error, malformed JSON'; |
|
67 | - break; |
|
68 | - case JSON_ERROR_UTF8: |
|
69 | - $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
70 | - break; |
|
71 | - case JSON_ERROR_RECURSION: |
|
72 | - $error = ': One or more recursive references in the value to be encoded'; |
|
73 | - break; |
|
74 | - case JSON_ERROR_INF_OR_NAN: |
|
75 | - $error = ': One or more NAN or INF values in the value to be encoded'; |
|
76 | - break; |
|
77 | - case JSON_ERROR_UNSUPPORTED_TYPE: |
|
78 | - $error = ': A value of a type that cannot be encoded was given'; |
|
79 | - break; |
|
80 | - case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
81 | - $error = ': A property name that cannot be encoded was given'; |
|
82 | - break; |
|
83 | - case JSON_ERROR_UTF16: |
|
84 | - $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
85 | - break; |
|
86 | - default: |
|
87 | - $error = ': Unknown error'; |
|
88 | - break; |
|
89 | - } |
|
90 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
91 | - return false; |
|
92 | - } |
|
21 | + /** |
|
22 | + * Call this method IMMEDIATELY after json_decode() and |
|
23 | + * it will will return true if the decoded JSON was valid, |
|
24 | + * or return false after adding an error if not valid. |
|
25 | + * The actual JSON file does not need to be supplied, |
|
26 | + * but details re: code execution location are required. |
|
27 | + * ex: |
|
28 | + * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
29 | + * |
|
30 | + * @param string $file |
|
31 | + * @param string $func |
|
32 | + * @param string $line |
|
33 | + * @return boolean |
|
34 | + * @since 4.9.70.p |
|
35 | + */ |
|
36 | + public function isValid($file, $func, $line) |
|
37 | + { |
|
38 | + if (! defined('JSON_ERROR_RECURSION')) { |
|
39 | + define('JSON_ERROR_RECURSION', 6); |
|
40 | + } |
|
41 | + if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
42 | + define('JSON_ERROR_INF_OR_NAN', 7); |
|
43 | + } |
|
44 | + if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
45 | + define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
46 | + } |
|
47 | + if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
48 | + define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
49 | + } |
|
50 | + if (! defined('JSON_ERROR_UTF16')) { |
|
51 | + define('JSON_ERROR_UTF16', 10); |
|
52 | + } |
|
53 | + switch (json_last_error()) { |
|
54 | + case JSON_ERROR_NONE: |
|
55 | + return true; |
|
56 | + case JSON_ERROR_DEPTH: |
|
57 | + $error = ': Maximum stack depth exceeded'; |
|
58 | + break; |
|
59 | + case JSON_ERROR_STATE_MISMATCH: |
|
60 | + $error = ': Invalid or malformed JSON'; |
|
61 | + break; |
|
62 | + case JSON_ERROR_CTRL_CHAR: |
|
63 | + $error = ': Control character error, possible malformed JSON'; |
|
64 | + break; |
|
65 | + case JSON_ERROR_SYNTAX: |
|
66 | + $error = ': Syntax error, malformed JSON'; |
|
67 | + break; |
|
68 | + case JSON_ERROR_UTF8: |
|
69 | + $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
70 | + break; |
|
71 | + case JSON_ERROR_RECURSION: |
|
72 | + $error = ': One or more recursive references in the value to be encoded'; |
|
73 | + break; |
|
74 | + case JSON_ERROR_INF_OR_NAN: |
|
75 | + $error = ': One or more NAN or INF values in the value to be encoded'; |
|
76 | + break; |
|
77 | + case JSON_ERROR_UNSUPPORTED_TYPE: |
|
78 | + $error = ': A value of a type that cannot be encoded was given'; |
|
79 | + break; |
|
80 | + case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
81 | + $error = ': A property name that cannot be encoded was given'; |
|
82 | + break; |
|
83 | + case JSON_ERROR_UTF16: |
|
84 | + $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
85 | + break; |
|
86 | + default: |
|
87 | + $error = ': Unknown error'; |
|
88 | + break; |
|
89 | + } |
|
90 | + EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
91 | + return false; |
|
92 | + } |
|
93 | 93 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $template_args['attributes'] = $attributes; |
47 | 47 | $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
48 | 48 | return EEH_Template::display_template( |
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
49 | + $this->templateRootPath().'event-attendees.php', |
|
50 | 50 | $template_args, |
51 | 51 | true |
52 | 52 | ); |
@@ -20,133 +20,133 @@ |
||
20 | 20 | class EventAttendeesBlockRenderer extends BlockRenderer |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EEM_Attendee |
|
25 | - */ |
|
26 | - private $attendee_model; |
|
23 | + /** |
|
24 | + * @var EEM_Attendee |
|
25 | + */ |
|
26 | + private $attendee_model; |
|
27 | 27 | |
28 | - public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
29 | - { |
|
30 | - $this->attendee_model = $attendee_model; |
|
31 | - parent::__construct($domain); |
|
32 | - } |
|
28 | + public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
29 | + { |
|
30 | + $this->attendee_model = $attendee_model; |
|
31 | + parent::__construct($domain); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Renders the block. |
|
37 | - * |
|
38 | - * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
39 | - * query and the template output. |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - * @throws EE_Error |
|
43 | - */ |
|
44 | - public function render(array $attributes) |
|
45 | - { |
|
46 | - $attributes = $this->parseGlobalIDs($attributes); |
|
47 | - $template_args['attributes'] = $attributes; |
|
48 | - $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
49 | - return EEH_Template::display_template( |
|
50 | - $this->templateRootPath() . 'event-attendees.php', |
|
51 | - $template_args, |
|
52 | - true |
|
53 | - ); |
|
54 | - } |
|
35 | + /** |
|
36 | + * Renders the block. |
|
37 | + * |
|
38 | + * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
39 | + * query and the template output. |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + * @throws EE_Error |
|
43 | + */ |
|
44 | + public function render(array $attributes) |
|
45 | + { |
|
46 | + $attributes = $this->parseGlobalIDs($attributes); |
|
47 | + $template_args['attributes'] = $attributes; |
|
48 | + $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
49 | + return EEH_Template::display_template( |
|
50 | + $this->templateRootPath() . 'event-attendees.php', |
|
51 | + $template_args, |
|
52 | + true |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Get query parameters for model query. |
|
59 | - * |
|
60 | - * @param array $attributes |
|
61 | - * @return array |
|
62 | - */ |
|
63 | - private function parseGlobalIDs(array $attributes) |
|
64 | - { |
|
65 | - // if ticket ID is set, then that's all we need to run the query |
|
66 | - $ticket = isset($attributes['ticket']) ? $attributes['ticket'] : ''; |
|
67 | - $datetime = isset($attributes['datetime']) ? $attributes['datetime'] : ''; |
|
68 | - $event = isset($attributes['event']) ? $attributes['event'] : ''; |
|
69 | - if ($ticket !== '') { |
|
70 | - $ticketId = $this->parseGUID($ticket); |
|
71 | - $attributes['ticketId'] = $ticketId; |
|
72 | - } elseif ($datetime !== '') { |
|
73 | - $datetimeId = $this->parseGUID($datetime); |
|
74 | - $attributes['datetimeId'] = $datetimeId; |
|
75 | - } elseif ($event !== '') { |
|
76 | - $eventId = $this->parseGUID($event); |
|
77 | - $attributes['eventId'] = $eventId; |
|
78 | - } |
|
79 | - // remove unnecessary data so it doesn't get added to the query vars |
|
80 | - unset($attributes['ticket'], $attributes['datetime'], $attributes['event']); |
|
81 | - return $attributes; |
|
82 | - } |
|
57 | + /** |
|
58 | + * Get query parameters for model query. |
|
59 | + * |
|
60 | + * @param array $attributes |
|
61 | + * @return array |
|
62 | + */ |
|
63 | + private function parseGlobalIDs(array $attributes) |
|
64 | + { |
|
65 | + // if ticket ID is set, then that's all we need to run the query |
|
66 | + $ticket = isset($attributes['ticket']) ? $attributes['ticket'] : ''; |
|
67 | + $datetime = isset($attributes['datetime']) ? $attributes['datetime'] : ''; |
|
68 | + $event = isset($attributes['event']) ? $attributes['event'] : ''; |
|
69 | + if ($ticket !== '') { |
|
70 | + $ticketId = $this->parseGUID($ticket); |
|
71 | + $attributes['ticketId'] = $ticketId; |
|
72 | + } elseif ($datetime !== '') { |
|
73 | + $datetimeId = $this->parseGUID($datetime); |
|
74 | + $attributes['datetimeId'] = $datetimeId; |
|
75 | + } elseif ($event !== '') { |
|
76 | + $eventId = $this->parseGUID($event); |
|
77 | + $attributes['eventId'] = $eventId; |
|
78 | + } |
|
79 | + // remove unnecessary data so it doesn't get added to the query vars |
|
80 | + unset($attributes['ticket'], $attributes['datetime'], $attributes['event']); |
|
81 | + return $attributes; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * Get query parameters for model query. |
|
87 | - * |
|
88 | - * @param array $attributes |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - private function getQueryParams(array $attributes) |
|
92 | - { |
|
93 | - return array( |
|
94 | - 0 => $this->getWhereQueryPart($attributes), |
|
95 | - 'default_where_conditions' => 'this_model_only', |
|
96 | - 'limit' => $attributes['limit'], |
|
97 | - 'group_by' => array('ATT_ID'), |
|
98 | - 'order_by' => $this->getOrderByQueryPart($attributes) |
|
99 | - ); |
|
100 | - } |
|
85 | + /** |
|
86 | + * Get query parameters for model query. |
|
87 | + * |
|
88 | + * @param array $attributes |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + private function getQueryParams(array $attributes) |
|
92 | + { |
|
93 | + return array( |
|
94 | + 0 => $this->getWhereQueryPart($attributes), |
|
95 | + 'default_where_conditions' => 'this_model_only', |
|
96 | + 'limit' => $attributes['limit'], |
|
97 | + 'group_by' => array('ATT_ID'), |
|
98 | + 'order_by' => $this->getOrderByQueryPart($attributes) |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Get where query part for query parameters for model query. |
|
105 | - * |
|
106 | - * @param array $attributes |
|
107 | - * @return array |
|
108 | - */ |
|
109 | - private function getWhereQueryPart(array $attributes) |
|
110 | - { |
|
111 | - $where = array(); |
|
112 | - if ($attributes['ticketId'] > 0) { |
|
113 | - $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
114 | - } elseif ($attributes['datetimeId'] > 0) { |
|
115 | - $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
116 | - } else { |
|
117 | - $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
118 | - } |
|
119 | - $where['Registration.STS_ID'] = $attributes['status']; |
|
120 | - return $where; |
|
121 | - } |
|
103 | + /** |
|
104 | + * Get where query part for query parameters for model query. |
|
105 | + * |
|
106 | + * @param array $attributes |
|
107 | + * @return array |
|
108 | + */ |
|
109 | + private function getWhereQueryPart(array $attributes) |
|
110 | + { |
|
111 | + $where = array(); |
|
112 | + if ($attributes['ticketId'] > 0) { |
|
113 | + $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
114 | + } elseif ($attributes['datetimeId'] > 0) { |
|
115 | + $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
116 | + } else { |
|
117 | + $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
118 | + } |
|
119 | + $where['Registration.STS_ID'] = $attributes['status']; |
|
120 | + return $where; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Get order by query part for query parameters for model query. |
|
126 | - * |
|
127 | - * @param array $attributes |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - private function getOrderByQueryPart(array $attributes) |
|
131 | - { |
|
132 | - $order = $attributes['order']; |
|
133 | - switch ($attributes['orderBy']) { |
|
134 | - case 'id': |
|
135 | - $order_by = array('ATT_ID' => $order); |
|
136 | - break; |
|
137 | - case 'lastNameOnly': |
|
138 | - $order_by = array('ATT_lname' => $order); |
|
139 | - break; |
|
140 | - case 'firstNameOnly': |
|
141 | - $order_by = array('ATT_fname' => $order); |
|
142 | - break; |
|
143 | - case 'firstThenLastName': |
|
144 | - $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
145 | - break; |
|
146 | - default: |
|
147 | - $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
148 | - break; |
|
149 | - } |
|
150 | - return $order_by; |
|
151 | - } |
|
124 | + /** |
|
125 | + * Get order by query part for query parameters for model query. |
|
126 | + * |
|
127 | + * @param array $attributes |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + private function getOrderByQueryPart(array $attributes) |
|
131 | + { |
|
132 | + $order = $attributes['order']; |
|
133 | + switch ($attributes['orderBy']) { |
|
134 | + case 'id': |
|
135 | + $order_by = array('ATT_ID' => $order); |
|
136 | + break; |
|
137 | + case 'lastNameOnly': |
|
138 | + $order_by = array('ATT_lname' => $order); |
|
139 | + break; |
|
140 | + case 'firstNameOnly': |
|
141 | + $order_by = array('ATT_fname' => $order); |
|
142 | + break; |
|
143 | + case 'firstThenLastName': |
|
144 | + $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
145 | + break; |
|
146 | + default: |
|
147 | + $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
148 | + break; |
|
149 | + } |
|
150 | + return $order_by; |
|
151 | + } |
|
152 | 152 | } |
@@ -14,11 +14,11 @@ |
||
14 | 14 | interface BlockRendererInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * This receives an array of attributes and returns rendered content for the block using those attributes. |
|
19 | - * |
|
20 | - * @param array $attributes |
|
21 | - * @return string Rendered Content |
|
22 | - */ |
|
23 | - public function render(array $attributes); |
|
17 | + /** |
|
18 | + * This receives an array of attributes and returns rendered content for the block using those attributes. |
|
19 | + * |
|
20 | + * @param array $attributes |
|
21 | + * @return string Rendered Content |
|
22 | + */ |
|
23 | + public function render(array $attributes); |
|
24 | 24 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | private function setTemplateRootPath() |
44 | 44 | { |
45 | - $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/'; |
|
45 | + $this->template_root_path = $this->domain->pluginPath().'ui/blocks/'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -15,57 +15,57 @@ |
||
15 | 15 | abstract class BlockRenderer implements BlockRendererInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var DomainInterface |
|
20 | - */ |
|
21 | - protected $domain; |
|
18 | + /** |
|
19 | + * @var DomainInterface |
|
20 | + */ |
|
21 | + protected $domain; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - private $template_root_path; |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + private $template_root_path; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * BlockRenderer constructor. |
|
31 | - * |
|
32 | - * @param DomainInterface $domain |
|
33 | - */ |
|
34 | - public function __construct(DomainInterface $domain) |
|
35 | - { |
|
36 | - $this->domain = $domain; |
|
37 | - $this->setTemplateRootPath(); |
|
38 | - } |
|
29 | + /** |
|
30 | + * BlockRenderer constructor. |
|
31 | + * |
|
32 | + * @param DomainInterface $domain |
|
33 | + */ |
|
34 | + public function __construct(DomainInterface $domain) |
|
35 | + { |
|
36 | + $this->domain = $domain; |
|
37 | + $this->setTemplateRootPath(); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Sets the root path to the main block template. |
|
43 | - */ |
|
44 | - private function setTemplateRootPath() |
|
45 | - { |
|
46 | - $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/'; |
|
47 | - } |
|
41 | + /** |
|
42 | + * Sets the root path to the main block template. |
|
43 | + */ |
|
44 | + private function setTemplateRootPath() |
|
45 | + { |
|
46 | + $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/'; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Exposes the root path for the main block template. |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function templateRootPath() |
|
55 | - { |
|
56 | - return $this->template_root_path; |
|
57 | - } |
|
50 | + /** |
|
51 | + * Exposes the root path for the main block template. |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function templateRootPath() |
|
55 | + { |
|
56 | + return $this->template_root_path; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * converts GraphQL GUID into EE DB ID |
|
62 | - * |
|
63 | - * @param string $GUID |
|
64 | - * @return int |
|
65 | - */ |
|
66 | - protected function parseGUID($GUID) |
|
67 | - { |
|
68 | - $parts = Relay::fromGlobalId($GUID); |
|
69 | - return ! empty($parts['id']) ? $parts['id'] : 0; |
|
70 | - } |
|
60 | + /** |
|
61 | + * converts GraphQL GUID into EE DB ID |
|
62 | + * |
|
63 | + * @param string $GUID |
|
64 | + * @return int |
|
65 | + */ |
|
66 | + protected function parseGUID($GUID) |
|
67 | + { |
|
68 | + $parts = Relay::fromGlobalId($GUID); |
|
69 | + return ! empty($parts['id']) ? $parts['id'] : 0; |
|
70 | + } |
|
71 | 71 | } |