providerService();
$serviceCreds = PR()->serviceLogin();
$result = $psc->getActivity(array('serviceLogin' => $serviceCreds,
'activityId' => $activityId));
$this->_soapDebug = print_r($result, true);
$this->_currentActivity = $result->return;
}
public function setCurrentActivityGroup ($groupName) {
$groups = get_option('pr_activity_groups');
$psc = PR()->providerService();
$serviceCreds = PR()->serviceLogin();
if (!$groups[$groupName]) {
return null;
}
$activityIds = $groups[$groupName];
$activities = array();
// Create our activity objects.
foreach ($activityIds as $id) {
$result = $psc->getActivity(array('serviceLogin' => $serviceCreds,
'activityId' => $id));
$activities[] = $result->return;
}
$this->_currentActivityGroup = new PonoRezGroup($groupName, $activities);
// We also set our current activity to the first one in the group.
$this->_currentActivity = $activities[0];
}
public function prLoadActivityShortcode ($atts = array(), $content = null, $tag) {
$a = shortcode_atts(array(
'id' => null
), $atts);
$rval = '';
try {
if (0 < (int)$a['id']) {
$this->setCurrentActivity((int)$a['id']);
}
}
catch (SoapFault $e) {
$rval .= sprintf("
\n
\n%s\n", $this->_soapDebug); } return $rval; } public function prActivityShortcode ($atts = array(), $content = null, $tag) { $a = shortcode_atts(array( 'id' => null, 'template' => $this->defaultTemplate ), $atts); $rval = ''; try { if (0 < (int)$a['id']) { $this->setCurrentActivity((int)$a['id']); } } catch (SoapFault $e) { $rval .= sprintf("
\n%s\n", $this->_soapDebug); } return $rval . PR()->withTransient('pr_activity', $a['id'] . basename($this->defaultTemplate), function () use ($a) { $template_string = file_get_contents($a['template']); return do_shortcode($template_string); }); } public function prActivityNameShortcode ($atts = array(), $content = null, $tag) { $a = shortcode_atts(array( 'id' => null ), $atts); if (isset($this->_currentActivity)) return $this->_currentActivity->name; return ''; } public function prActivityDescriptionShortcode ($atts = array(), $content = null, $tag) { $a = shortcode_atts(array( 'id' => null ), $atts); if (!$this->_currentActivity) return 'No activity selected'; return $this->_currentActivity->description; } public function prDatepickerShortcode ($atts = array(), $content = null, $tag) { $a = shortcode_atts(array( 'id' => null, 'group' => 'on', 'icon' => 'on' ), $atts); // Just trying to be smart. if (!$this->_currentActivity && !$this->_currentActivityGroup) return 'No activity selected'; // If there's no group, or group is turned off, use the single activity style. // if ('off' === $a['group'] || null === $this->_currentActivityGroup) { $rval_template = <<
\n%s\n---\n%s\n\n", $e->faultcode, $e->faultstring); return $rval; } // Build our HTML id tag. This differs if we are in a group setting. $htmlIdTagPart = sprintf('a%d', $this->_currentActivity->id); if (null != $this->_currentActivityGroup) { $htmlIdTagPart = $this->_currentActivityGroup->groupName; } $rval = ''; // Workaround a bug in the A3H SOAP interface. If there's only // one guest type, it returns a single object instead of an // array of guest types. Gotta love inconsistent interfaces, // don't you? $guestTypeList = $result->return; if (!is_array($result->return)) { $guestTypeList = array($result->return); } foreach ($guestTypeList as $guestType) { // Because the A3H SOAP interface can't be trusted sometimes. if (!$guestType) continue; // If no guest types are available, then default to the 'max' setting. $max = (0 >= $guestType->availabilityPerGuest) ? $a['max'] : $guestType->availabilityPerGuest; $html = ''; // Debug //$html .= sprintf("\n", $guestType->availabilityPerGuest, $max); $html .= sprintf('%s "; $rval .= "\n$html\n"; } $this->_soapDebug = print_r($result, true); return $rval; } /* This shortcode automatically prints out an interface for each * guest type. It tries to get smart about guest type maximums to * get around limitations in the SOAP interface. */ public function prGuestTypeShortcode ($atts = array(), $content = null, $tag) { $a = shortcode_atts(array( 'id' => null, 'guest-type-id' => null, 'max' => 20 ), $atts); $rval = ''; $rval .= sprintf('\n"; return $rval; } public function prHotelSelectShortcode ($atts = array(), $content = null, $tag) { $defaultTemplate = <<
\n%s\n", $this->_soapDebug); } // Load our required group functions. wp_enqueue_script('pr_group_functions'); // Now we assemble the JavaScript. $cag = $this->_currentActivityGroup; $javaScript = PR()->withTransient('pr_group', $cag->groupName, function () use ($cag) { return $cag->toJson(true); }); return sprintf("", $javaScript); } /** * Set up transportation for a single activity. * * Requires JS like this: * var routeSelection_a8455_contextData = { * routesContainerSelector: "#transportationRoutesContainer_a8455", * routeSelectorMap: { * '355': "#transportationRouteContainer_a8455_355", * 'null': null * } * }; * */ public function prTransportationShortcode ($atts = array(), $content = null, $tag) { $a = shortcode_atts(array( 'name' => null, 'message' => 'No transportation.', 'template' => $this->defaultTemplate, 'hidden' => true ), $atts); $trans = new PonoRezTransportation($this->_currentActivity->supplierId, $this->_currentActivity->id); $map = $trans->getTransportationMap(); $javaScript = sprintf("var routeSelection_a%d_contextData = %s;", $this->_currentActivity->id, json_encode($map)); $rval = sprintf("\n", $javaScript); // If we're hidden, set our style. $displayStyle = ''; if (true == $a['hidden']) $displayStyle = 'display:none;'; $rval .= sprintf("
\n%s\n\n", print_r($g->activities, true)); foreach ($g->activities as $activity) { $tmp = str_replace( '