/**
  *    format - output formatted EE object address information
  *
  * @access public
  * @param         object      EEI_Address $obj_with_address
  * @param string  $type       how the address is formatted. for example: 'multiline' or 'inline'
  * @param boolean $use_schema whether to apply schema.org formatting to the address
  * @param bool    $add_wrapper
  * @return string
  */
 public static function format($obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true)
 {
     // check that incoming object implements the EEI_Address interface
     if (!$obj_with_address instanceof EEI_Address) {
         $msg = __('The address could not be formatted.', 'event_espresso');
         $dev_msg = __('The Address Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso');
         EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     // obtain an address formatter
     $formatter = EEH_Address::_get_formatter($type);
     // apply schema.org formatting ?
     $use_schema = !is_admin() ? $use_schema : false;
     $formatted_address = $use_schema ? EEH_Address::_schema_formatting($formatter, $obj_with_address) : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
     $formatted_address = $add_wrapper && !$use_schema ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' : $formatted_address;
     // return the formatted address
     return $formatted_address;
 }
 function column_PER_address($item)
 {
     EE_Registry::instance()->load_helper('Formatter');
     $content = EEH_Address::format($item);
     return $content;
 }
 /**
  *    venue_gmap
  *
  * @access    public
  * @param int $VNU_ID
  * @param bool|string $map_ID a unique identifier for this map
  * @param    array $gmap map options
  * @return string
  */
 public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array())
 {
     $venue = EEH_Venue_View::get_venue($VNU_ID);
     if ($venue instanceof EE_Venue) {
         // check for global espresso_events post and use it's ID if no map_ID is set
         global $post;
         $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
         // grab map settings
         $map_cfg = EE_Registry::instance()->CFG->map_settings;
         // are maps enabled ?
         if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
             EE_Registry::instance()->load_helper('Maps');
             EE_Registry::instance()->load_helper('Formatter');
             $details_page = is_single();
             $options = array();
             $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID() : $venue->ID();
             $options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE);
             $options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
             $options['ee_map_width'] = isset($gmap['ee_map_width']) && !empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
             $options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
             $options['ee_map_height'] = isset($gmap['ee_map_height']) && !empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
             $options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
             $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && !empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
             $options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
             $options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && !empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display'];
             $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
             $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && !empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
             $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
             $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && !empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
             $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
             $options['ee_map_align'] = isset($gmap['ee_map_align']) && !empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align'];
             $options['ee_static_url'] = isset($gmap['ee_static_url']) && !empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
             return EEH_Maps::google_map($options);
         }
     }
     return '';
 }
 /**
  * 		generates HTML for the Edit Registration side meta box
  *		@access public
  *		@return void
  */
 public function _reg_registrant_side_meta_box()
 {
     /*@var $attendee EE_Attendee */
     $att_check = $this->_registration->attendee();
     $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
     //now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show cereate button or not)
     if (!$this->_registration->is_primary_registrant()) {
         $primary_registration = $this->_registration->get_primary_registration();
         $primary_attendee = $primary_registration->attendee();
         if (!$primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
             //in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
             $primary_registration = NULL;
         }
     } else {
         $primary_registration = NULL;
     }
     $this->_template_args['ATT_ID'] = $attendee->ID();
     $this->_template_args['fname'] = $attendee->fname();
     //$this->_registration->ATT_fname;
     $this->_template_args['lname'] = $attendee->lname();
     //$this->_registration->ATT_lname;
     $this->_template_args['email'] = $attendee->email();
     //$this->_registration->ATT_email;
     $this->_template_args['phone'] = $attendee->phone();
     EE_Registry::instance()->load_helper('Formatter');
     $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
     //edit link
     $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $attendee->ID()), REG_ADMIN_URL);
     $this->_template_args['att_edit_label'] = __('View/Edit Contact');
     //create link
     $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : '';
     $this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
     $this->_template_args['att_check'] = $att_check;
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * txn_registrant_side_meta_box
  * generates HTML for the Edit Transaction side meta box
  *
  * @access public
  * @throws \EE_Error
  * @return void
  */
 public function txn_registrant_side_meta_box()
 {
     $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
     if (!$primary_att instanceof EE_Attendee) {
         $this->_template_args['no_attendee_message'] = __('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.', 'event_espresso');
         $primary_att = EEM_Attendee::instance()->create_default_object();
     }
     $this->_template_args['ATT_ID'] = $primary_att->ID();
     $this->_template_args['prime_reg_fname'] = $primary_att->fname();
     $this->_template_args['prime_reg_lname'] = $primary_att->lname();
     $this->_template_args['prime_reg_email'] = $primary_att->email();
     $this->_template_args['prime_reg_phone'] = $primary_att->phone();
     $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL);
     // get formatted address for registrant
     EE_Registry::instance()->load_helper('Formatter');
     $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
     echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE);
 }
 /**
  * espresso_organization_address
  * @param string $type
  * @return string
  */
 function espresso_organization_address($type = 'inline')
 {
     if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
         EE_Registry::instance()->load_helper('Formatter');
         $address = new EE_Generic_Address(EE_Registry::instance()->CFG->organization->address_1, EE_Registry::instance()->CFG->organization->address_2, EE_Registry::instance()->CFG->organization->city, EE_Registry::instance()->CFG->organization->STA_ID, EE_Registry::instance()->CFG->organization->zip, EE_Registry::instance()->CFG->organization->CNT_ISO);
         return EEH_Address::format($address, $type);
     }
     return '';
 }
        ?>
						<tr class="venue-details">
							<td class="venue-details-part venue-address-dv">
								<h3><a href='<?php 
        echo $venue->get_permalink();
        ?>
'><?php 
        echo $venue->name();
        ?>
</a></h3>
								<p><?php 
        echo $venue->description();
        ?>
</p>
								<?php 
        echo EEH_Address::format($venue);
        ?>
</td>
							<?php 
        if ($venue->enable_for_gmap()) {
            ?>
								<td class="venue-details-part venue-image-dv"><?php 
            echo EEH_Venue_View::espresso_google_static_map($venue);
            ?>
</td>
							<?php 
        }
        ?>
						</tr>
					<?php 
    }
 /**
  * espresso_organization_address
  * @param string $type
  * @return string
  */
 function espresso_organization_address($type = 'inline')
 {
     if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
         $address = new EventEspresso\core\entities\GenericAddress(EE_Registry::instance()->CFG->organization->address_1, EE_Registry::instance()->CFG->organization->address_2, EE_Registry::instance()->CFG->organization->city, EE_Registry::instance()->CFG->organization->STA_ID, EE_Registry::instance()->CFG->organization->zip, EE_Registry::instance()->CFG->organization->CNT_ISO);
         return EEH_Address::format($address, $type);
     }
     return '';
 }
 /**
  * This retrieves the specified venue information
  * @param  string $what What to retrieve from database
  * @return string       What was retrieved!
  */
 private function _venue($db_ref)
 {
     //we need the EE_Event object to get the venue.
     $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
     //if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
     if (empty($this->_event)) {
         $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL;
         $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
         $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : NULL;
         //if still empty do we have a ticket data item?
         $this->_event = empty($this->_event) && $this->_data instanceof EE_Ticket && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] : $this->_event;
         //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee and use that.
         $event = $aee instanceof EE_Messages_Addressee ? reset($aee->events) : array();
         $this->_event = empty($this->_event) && !empty($events) ? $event : $this->_event;
     }
     //If there is no event objecdt by now then get out.
     if (!$this->_event instanceof EE_Event) {
         return '';
     }
     $venue = $this->_event->get_first_related('Venue');
     if (empty($venue)) {
         return '';
     }
     //no venue so get out.
     switch ($db_ref) {
         case 'title':
             return $venue->get('VNU_name');
             break;
         case 'description':
             return $venue->get('VNU_desc');
             break;
         case 'url':
             $url = $venue->get('VNU_url');
             return empty($url) ? $venue->get_permalink() : $url;
             break;
         case 'image':
             return '<img src="' . $venue->feature_image_url(array(200, 200)) . '" alt="' . sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $venue->get('VNU_name')) . '" />';
             break;
         case 'phone':
             return $venue->get('VNU_phone');
             break;
         case 'address':
             return $venue->get('VNU_address');
             break;
         case 'address2':
             return $venue->get('VNU_address2');
             break;
         case 'city':
             return $venue->get('VNU_city');
             break;
         case 'state':
             $state = $venue->state_obj();
             return is_object($state) ? $state->get('STA_name') : '';
             break;
         case 'country':
             $country = $venue->country_obj();
             return is_object($country) ? $country->get('CNT_name') : '';
             break;
         case 'zip':
             return $venue->get('VNU_zip');
             break;
         case 'formatted_address':
             return EEH_Address::format($venue);
             break;
         case 'gmap_link':
         case 'gmap_link_img':
             $state = $venue->state_obj();
             $country = $venue->country_obj();
             $atts = array('id' => $venue->ID(), 'address' => $venue->get('VNU_address'), 'city' => $venue->get('VNU_city'), 'state' => is_object($state) ? $state->get('STA_name') : '', 'zip' => $venue->get('VNU_zip'), 'country' => is_object($country) ? $country->get('CNT_name') : '', 'type' => $db_ref == 'gmap_link' ? 'url' : 'map', 'map_w' => 200, 'map_h' => 200);
             return EEH_Maps::google_map_link($atts);
             break;
     }
 }