Advertisement
eventsmanager

forms/event/location.php template

Apr 10th, 2023
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.16 KB | None | 0 0
  1. <?php
  2.  
  3. global $EM_Event;
  4.  
  5. $required = apply_filters('em_required_html','<i>*</i>');
  6.  
  7.  
  8.  
  9. //determine location types (if neexed)
  10.  
  11. $location_types = array();
  12.  
  13. if( !get_option('dbem_require_location') ){
  14.  
  15. $location_types[0] = array(
  16.  
  17. 'selected' => $EM_Event->location_id === '0' || $EM_Event->location_id === 0,
  18.  
  19. 'description' => esc_html__('No Location','events-manager'),
  20.  
  21. );
  22.  
  23. }
  24.  
  25. if( EM_Locations::is_enabled() ){
  26.  
  27. $location_types['location'] = array(
  28.  
  29. 'selected' => !empty($EM_Event->location_id),
  30.  
  31. 'display-class' => 'em-location-type-place',
  32.  
  33. 'description' => esc_html__('Physical Location','events-manager'),
  34.  
  35. );
  36.  
  37. }
  38.  
  39. foreach( EM_Event_Locations\Event_Locations::get_types() as $event_location_type => $EM_Event_Location_Class ){ /* @var EM_Event_Locations\Event_Location $EM_Event_Location_Class */
  40.  
  41. if( $EM_Event_Location_Class::is_enabled() ){
  42.  
  43. $location_types[$EM_Event_Location_Class::$type] = array(
  44.  
  45. 'display-class' => 'em-event-location-type-'. $EM_Event_Location_Class::$type,
  46.  
  47. 'selected' => $EM_Event_Location_Class::$type == $EM_Event->event_location_type,
  48.  
  49. 'description' => $EM_Event_Location_Class::get_label(),
  50.  
  51. );
  52.  
  53. }
  54.  
  55. }
  56.  
  57. ?>
  58.  
  59. <div class="input em-input-field em-input-field-select em-location-types <?php if( count($location_types) == 1 ) echo 'em-location-types-single'; ?>">
  60.  
  61. <label><?php esc_html_e ( 'Location Type', 'events-manager')?></label>
  62.  
  63. <select name="location_type" class="em-location-types-select" data-active="<?php echo esc_attr($EM_Event->event_location_type); ?>">
  64.  
  65. <?php foreach( $location_types as $location_type => $location_type_option ): ?>
  66.  
  67. <option value="<?php echo esc_attr($location_type); ?>" <?php if( !empty($location_type_option['selected']) ) echo 'selected="selected"'; ?> data-display-class="<?php if( !empty($location_type_option['display-class']) ) echo esc_attr($location_type_option['display-class']); ?>">
  68.  
  69. <?php echo esc_html($location_type_option['description']); ?>
  70.  
  71. </option>
  72.  
  73. <?php endforeach; ?>
  74.  
  75. </select>
  76.  
  77. <?php if( $EM_Event->has_event_location() ): ?>
  78.  
  79. <div class="em-location-type-delete-active-alert em-notice-warning">
  80.  
  81. <div class="warning-bold">
  82.  
  83. <p><em><?php esc_html_e('You are switching location type, if you update this event your event previous location data will be deleted.', 'events-manager'); ?></em></p>
  84.  
  85. </div>
  86.  
  87. <?php $EM_Event->get_event_location()->admin_delete_warning(); ?>
  88.  
  89. </div>
  90.  
  91. <?php endif; ?>
  92.  
  93. </div>
  94.  
  95. <?php if( EM_Locations::is_enabled() ): ?>
  96.  
  97. <div id="em-location-data" class="em-location-data em-location-where em-location-type em-location-type-place <?php if( count($location_types) == 1 ) echo 'em-location-type-single '; em_template_classes('event-editor'); if( get_option( 'dbem_gmap_is_active' ) ) echo ' has-map'; ?>">
  98.  
  99. <div id="location_coordinates" style='display: none;'>
  100.  
  101. <input id='location-latitude' name='location_latitude' type='text' value='<?php echo esc_attr($EM_Event->get_location()->location_latitude); ?>' size='15' >
  102.  
  103. <input id='location-longitude' name='location_longitude' type='text' value='<?php echo esc_attr($EM_Event->get_location()->location_longitude); ?>' size='15' >
  104.  
  105. </div>
  106.  
  107. <div class="em-location-data input">
  108.  
  109. <?php if( get_option('dbem_use_select_for_locations') || !$EM_Event->can_manage('edit_locations','edit_others_locations') ) : ?>
  110.  
  111. <div class="input em-location-data-select">
  112.  
  113. <label for="location-select-id"><?php esc_html_e('Location','events-manager') ?> </label>
  114.  
  115. <select name="location_id" id='location-select-id' class="em-selectize">
  116.  
  117. <?php
  118.  
  119. if ( count($location_types) == 1 && !get_option('dbem_require_location') ){ // we don't consider optional locations as a type for ddm
  120.  
  121. ?>
  122.  
  123. <option value="0"><?php esc_html_e('No Location','events-manager'); ?></option>
  124.  
  125. <?php
  126.  
  127. }elseif( empty(get_option('dbem_default_location')) ){
  128.  
  129. ?>
  130.  
  131. <option value="0"><?php esc_html_e('Select Location','events-manager'); ?></option>
  132.  
  133. <?php
  134.  
  135. }
  136.  
  137. $ddm_args = array('private'=>$EM_Event->can_manage('read_private_locations'));
  138.  
  139. $ddm_args['owner'] = (is_user_logged_in() && !current_user_can('read_others_locations')) ? get_current_user_id() : false;
  140.  
  141. $locations = EM_Locations::get($ddm_args);
  142.  
  143. $selected_location = !empty($EM_Event->location_id) || !empty($EM_Event->event_id) ? $EM_Event->location_id:get_option('dbem_default_location');
  144.  
  145. foreach($locations as $EM_Location) {
  146.  
  147. $selected = ($selected_location == $EM_Location->location_id) ? "selected='selected' " : '';
  148.  
  149. if( $selected ) $found_location = true;
  150.  
  151. ?>
  152.  
  153. <option value="<?php echo esc_attr($EM_Location->location_id) ?>" title="<?php echo esc_attr("{$EM_Location->location_latitude},{$EM_Location->location_longitude}"); ?>" <?php echo $selected ?>><?php echo esc_html($EM_Location->location_name); ?></option>
  154.  
  155. <?php
  156.  
  157. }
  158.  
  159. if( empty($found_location) && !empty($EM_Event->location_id) ){
  160.  
  161. $EM_Location = $EM_Event->get_location();
  162.  
  163. if( $EM_Location->post_id ){
  164.  
  165. ?>
  166.  
  167. <option value="<?php echo esc_attr($EM_Location->location_id) ?>" title="<?php echo esc_attr("{$EM_Location->location_latitude},{$EM_Location->location_longitude}"); ?>" selected="selected"><?php echo esc_html($EM_Location->location_name); ?></option>
  168.  
  169. <?php
  170.  
  171. }
  172.  
  173. }
  174.  
  175. ?>
  176.  
  177. </select>
  178.  
  179. </div>
  180.  
  181. <?php else : ?>
  182.  
  183. <?php
  184.  
  185. global $EM_Location;
  186.  
  187. if( $EM_Event->location_id !== 0 ){
  188.  
  189. $EM_Location = $EM_Event->get_location();
  190.  
  191. }elseif(get_option('dbem_default_location') > 0){
  192.  
  193. $EM_Location = em_get_location(get_option('dbem_default_location'));
  194.  
  195. }else{
  196.  
  197. $EM_Location = new EM_Location();
  198.  
  199. }
  200.  
  201. ?>
  202.  
  203. <div class="em-location-data-name">
  204.  
  205. <label for="location-name"><?php _e ( 'Location Name', 'events-manager')?> <?php echo $required; ?></label>
  206.  
  207. <input id='location-id' name='location_id' type='hidden' value='<?php echo esc_attr($EM_Location->location_id); ?>' size='15' >
  208.  
  209. <input id="location-name" type="text" name="location_name" class="em-selectize-autocomplete em-selectize" value="<?php echo esc_attr($EM_Location->location_name); ?>" >
  210.  
  211. <em id="em-location-search-tip"><?php esc_html_e( 'Create a location or start typing to search a previously created location.', 'events-manager')?></em>
  212.  
  213. <em id="em-location-reset" style="display:none;"><?php esc_html_e('You cannot edit saved locations here.', 'events-manager'); ?> <a href="#"><?php esc_html_e('Reset this form to create a location or search again.', 'events-manager')?></a></em>
  214.  
  215. </div>
  216.  
  217. <div class="input em-location-data-address">
  218.  
  219. <label for="location-address"><?php _e ( 'Address', 'events-manager')?>&nbsp;<?php echo $required; ?></label>
  220.  
  221. <input id="location-address" type="text" name="location_address" value="<?php echo esc_attr($EM_Location->location_address); ; ?>" >
  222.  
  223. </div>
  224.  
  225. <div class="input em-location-data-town">
  226.  
  227. <label for="location-town"><?php _e ( 'City/Town', 'events-manager')?> <?php echo $required; ?></label>
  228.  
  229. <input id="location-town" type="text" name="location_town" value="<?php echo esc_attr($EM_Location->location_town); ?>" >
  230.  
  231. </div>
  232.  
  233. <div class="input em-location-data-state">
  234.  
  235. <label for="location-state"><?php _e ( 'State/County', 'events-manager')?></label>
  236.  
  237. <input id="location-state" type="text" name="location_state" value="<?php echo esc_attr($EM_Location->location_state); ?>" >
  238.  
  239. </div>
  240.  
  241. <div class="input em-location-data-postcode">
  242.  
  243. <label for="location-postcode"><?php _e ( 'Postcode', 'events-manager')?></label>
  244.  
  245. <input id="location-postcode" type="text" name="location_postcode" value="<?php echo esc_attr($EM_Location->location_postcode); ?>" >
  246.  
  247. </div>
  248.  
  249. <div class="input em-location-data-region">
  250.  
  251. <label for="location-region"><?php _e ( 'Region', 'events-manager')?></label>
  252.  
  253. <input id="location-region" type="text" name="location_region" value="<?php echo esc_attr($EM_Location->location_region); ?>" >
  254.  
  255. </div>
  256.  
  257. <div class="input em-location-data-country">
  258.  
  259. <label for="location-country"><?php _e ( 'Country', 'events-manager')?> <?php echo $required; ?></label>
  260.  
  261. <select id="location-country" name="location_country" class="em-selectize">
  262.  
  263. <option value="0" <?php echo ( $EM_Location->location_country == '' && $EM_Location->location_id == '' && get_option('dbem_location_default_country') == '' ) ? 'selected="selected"':''; ?>><?php _e('none selected','events-manager'); ?></option>
  264.  
  265. <?php foreach(em_get_countries() as $country_key => $country_name): ?>
  266.  
  267. <option value="<?php echo esc_attr($country_key); ?>" <?php echo ( $EM_Location->location_country == $country_key || ($EM_Location->location_country == '' && $EM_Location->location_id == '' && get_option('dbem_location_default_country')==$country_key) ) ? 'selected="selected"':''; ?>><?php echo esc_html($country_name); ?></option>
  268.  
  269. <?php endforeach; ?>
  270.  
  271. </select>
  272.  
  273. </div>
  274.  
  275. <div class="input em-location-data-url">
  276.  
  277. <label for="location-url"><?php esc_html_e( 'URL', 'events-manager')?></label>
  278.  
  279. <input id="location-url" type="text" name="location_url" value="<?php echo esc_attr($EM_Location->location_url); ?>" >
  280.  
  281. </div>
  282.  
  283. <?php endif; ?>
  284.  
  285. </div>
  286.  
  287. <?php if ( get_option( 'dbem_gmap_is_active' ) ):?>
  288.  
  289. <?php em_locate_template('forms/map-container.php',true); ?>
  290.  
  291. <?php endif; ?>
  292.  
  293. </div>
  294.  
  295. <?php endif; ?>
  296.  
  297. <div class="em-event-location-data">
  298.  
  299. <?php foreach( EM_Event_Locations\Event_Locations::get_types() as $event_location_type => $EM_Event_Location_Class ): /* @var EM_Event_Locations\Event_Location $EM_Event_Location_Class */ ?>
  300.  
  301. <?php if( $EM_Event_Location_Class::is_enabled() ): ?>
  302.  
  303. <div class="em-location-type em-event-location-type-<?php echo esc_attr($event_location_type); ?> <?php if( count($location_types) == 1 ) echo 'em-location-type-single'; ?> input">
  304.  
  305. <?php $EM_Event_Location_Class::load_admin_template(); ?>
  306.  
  307. </div>
  308.  
  309. <?php endif; ?>
  310.  
  311. <?php endforeach; ?>
  312.  
  313. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement