本文整理汇总了PHP中CRM_Event_BAO_Event::getMapInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event::getMapInfo方法的具体用法?PHP CRM_Event_BAO_Event::getMapInfo怎么用?PHP CRM_Event_BAO_Event::getMapInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Event
的用法示例。
在下文中一共展示了CRM_Event_BAO_Event::getMapInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMapXML
/**
* Assign smarty variables to the template that will be used by google api to plot the contacts.
*
* @param array $ids
* @param int $locationId
* Location_id.
* @param CRM_Core_Page $page
* @param bool $addBreadCrumb
* @param string $type
*/
public static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $type = 'Contact')
{
$config = CRM_Core_Config::singleton();
CRM_Utils_System::setTitle(ts('Map Location(s)'));
$page->assign('query', 'CiviCRM Search Query');
$page->assign('mapProvider', $config->mapProvider);
$page->assign('mapKey', urlencode($config->mapAPIKey));
if ($type == 'Contact') {
$imageUrlOnly = FALSE;
// google needs image url, CRM-6564
if ($config->mapProvider == 'Google' || $config->mapProvider == 'OpenStreetMaps') {
$imageUrlOnly = TRUE;
}
$locations = CRM_Contact_BAO_Contact_Location::getMapInfo($ids, $locationId, $imageUrlOnly);
} else {
$locations = CRM_Event_BAO_Event::getMapInfo($ids);
}
if (empty($locations)) {
CRM_Core_Error::statusBounce(ts('This address does not contain latitude/longitude information and cannot be mapped.'));
}
if (empty($config->mapProvider)) {
CRM_Core_Error::statusBounce(ts('You need to configure a Mapping Provider before using this feature (Administer > System Settings > Mapping and Geocoding).'));
}
if ($addBreadCrumb) {
$session = CRM_Core_Session::singleton();
$redirect = $session->readUserContext();
if ($type == 'Contact') {
$bcTitle = ts('Contact');
} else {
$bcTitle = ts('Event Info');
$action = CRM_Utils_Request::retrieve('action', 'String', $page, FALSE);
if ($action) {
$args = 'reset=1&action=preview&id=';
} else {
$args = 'reset=1&id=';
}
$session->pushUserContext(CRM_Utils_System::url('civicrm/event/info', "{$args}{$ids}"));
}
CRM_Utils_System::appendBreadCrumb($bcTitle, $redirect);
}
$page->assign_by_ref('locations', $locations);
// only issue a javascript warning if we know we will not
// mess the poor user with too many warnings
if (count($locations) <= 3) {
$page->assign('geoCodeWarn', TRUE);
} else {
$page->assign('geoCodeWarn', FALSE);
}
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = 400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
}
}
$center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
$span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
$page->assign_by_ref('center', $center);
$page->assign_by_ref('span', $span);
}
示例2: createMapXML
/**
* assign smarty variables to the template that will be used by google api to plot the contacts
*
* @param array $contactIds list of contact ids that we need to plot
* @param int $locationId location_id
*
* @return string the location of the file we have created
* @access protected
*/
static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $type = 'Contact')
{
$config =& CRM_Core_Config::singleton();
CRM_Utils_System::setTitle(ts('Map Location(s)'));
$page->assign('query', 'CiviCRM Search Query');
$page->assign('mapProvider', $config->mapProvider);
$page->assign('mapKey', $config->mapAPIKey);
if ($type == 'Contact') {
require_once 'CRM/Contact/BAO/Contact/Location.php';
$locations =& CRM_Contact_BAO_Contact_Location::getMapInfo($ids, $locationId);
} else {
require_once 'CRM/Event/BAO/Event.php';
$locations =& CRM_Event_BAO_Event::getMapInfo($ids);
}
if (empty($locations)) {
CRM_Core_Error::statusBounce(ts('This address does not contain latitude/longitude information and cannot be mapped.'));
}
if ($addBreadCrumb) {
$session =& CRM_Core_Session::singleton();
$redirect = $session->readUserContext();
if ($type == 'Contact') {
$bcTitle = ts('Contact');
} else {
$bcTitle = ts('Event Info');
$action = CRM_Utils_Request::retrieve('action', 'String', $page, false);
if ($action) {
$args = 'reset=1&action=preview&id=';
} else {
$args = 'reset=1&id=';
}
$session->pushUserContext(CRM_Utils_System::url('civicrm/event/info', "{$args}{$ids}"));
}
CRM_Utils_System::appendBreadCrumb($bcTitle, $redirect);
}
$page->assign_by_ref('locations', $locations);
// only issue a javascript warning if we know we will not
// mess the poor user with too many warnings
if (count($locations) <= 3) {
$page->assign('geoCodeWarn', true);
} else {
$page->assign('geoCodeWarn', false);
}
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = +400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
}
}
$center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
$span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
$page->assign_by_ref('center', $center);
$page->assign_by_ref('span', $span);
}
示例3: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
* @access public
*
*/
function run()
{
//get the event id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$config =& CRM_Core_Config::singleton();
require_once 'CRM/Event/BAO/Event.php';
// ensure that the user has permission to see this page
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id)) {
CRM_Core_Error::fatal(ts('You do not have permission to view this event'));
}
$action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
$context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'register');
$this->assign('context', $context);
// Sometimes we want to suppress the Event Full msg
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, false, 'false');
// set breadcrumb to append to 2nd layer pages
$breadCrumbPath = CRM_Utils_System::url("civicrm/event/info", "id={$this->_id}&reset=1");
$additionalBreadCrumb = "<a href=\"{$breadCrumbPath}\">" . ts('Events') . '</a>';
//retrieve event information
$params = array('id' => $this->_id);
CRM_Event_BAO_Event::retrieve($params, $values['event']);
if (!$values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
$this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
// show event fees.
require_once 'CRM/Price/BAO/Set.php';
if ($this->_id && CRM_Utils_Array::value('is_monetary', $values['event'])) {
// get price set options, - CRM-5209
if ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $this->_id)) {
$setDetails = CRM_Price_BAO_Set::getSetDetail($priceSetId);
eval("\$priceSetFields = \$setDetails[{$priceSetId}][fields];");
if (is_array($priceSetFields)) {
$fieldCnt = 1;
foreach ($priceSetFields as $fid => $fieldValues) {
if (!is_array($fieldValues['options']) || empty($fieldValues['options'])) {
continue;
}
foreach ($fieldValues['options'] as $optionId => $optionVal) {
$values['feeBlock']['value'][$fieldCnt] = $optionVal['value'];
$values['feeBlock']['label'][$fieldCnt] = $optionVal['description'];
$fieldCnt++;
}
}
}
} else {
//retrieve event fee block.
require_once 'CRM/Core/OptionGroup.php';
require_once 'CRM/Core/BAO/Discount.php';
$discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
if ($discountId) {
CRM_Core_OptionGroup::getAssoc(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id'), $values['feeBlock'], false, 'id');
} else {
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$this->_id}", $values['feeBlock']);
}
}
}
$params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
$values['location'] = CRM_Core_BAO_Location::getValues($params, true);
//retrieve custom field information
require_once 'CRM/Core/BAO/CustomGroup.php';
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Event", $this, $this->_id, 0, $values['event']['event_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('action', CRM_Core_Action::VIEW);
//To show the event location on maps directly on event info page
$locations =& CRM_Event_BAO_Event::getMapInfo($this->_id);
if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
$this->assign('locations', $locations);
$this->assign('mapProvider', $config->mapProvider);
$this->assign('mapKey', $config->mapAPIKey);
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = +400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
//.........这里部分代码省略.........
示例4: run
//.........这里部分代码省略.........
if ($invoicing && isset($optionVal['tax_amount'])) {
$values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm);
$values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount'];
} else {
$values['feeBlock']['value'][$fieldCnt] = $optionVal['amount'];
}
$values['feeBlock']['label'][$fieldCnt] = $optionVal['label'];
$values['feeBlock']['lClass'][$fieldCnt] = $labelClass;
$fieldCnt++;
}
}
}
// Tell tpl we have price set fee data and whether it's a quick_config price set
$this->assign('isPriceSet', 1);
$this->assign('isQuickConfig', $setDetails[$priceSetId]['is_quick_config']);
}
}
$params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
$values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
// fix phone type labels
if (!empty($values['location']['phone'])) {
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
foreach ($values['location']['phone'] as &$val) {
if (!empty($val['phone_type_id'])) {
$val['phone_type_display'] = $phoneTypes[$val['phone_type_id']];
}
}
}
//retrieve custom field information
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_id, 0, $values['event']['event_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
$this->assign('action', CRM_Core_Action::VIEW);
//To show the event location on maps directly on event info page
$locations = CRM_Event_BAO_Event::getMapInfo($this->_id);
if (!empty($locations) && !empty($values['event']['is_map'])) {
$this->assign('locations', $locations);
$this->assign('mapProvider', $config->mapProvider);
$this->assign('mapKey', $config->mapAPIKey);
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = 400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
}
}
$center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
$span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
$this->assign_by_ref('center', $center);
$this->assign_by_ref('span', $span);
if ($action == CRM_Core_Action::PREVIEW) {
$mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
} else {
$mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1", TRUE, NULL, TRUE, TRUE);
}