public function transportationMap() { if (null == $this->_transportationMap) { $trans = new PonoRezTransportation($this->supplierId, $this->activities[0]->id); $this->_transportationMap = $trans->getTransportationMap(); } return $this->_transportationMap; }
/** * 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("<script type=\"text/javascript\">%s</script>\n", $javaScript); // If we're hidden, set our style. $displayStyle = ''; if (true == $a['hidden']) { $displayStyle = 'display:none;'; } $rval .= sprintf("<div id=\"%s\" style=\"%s\"><strong>Select a transportation route:</strong><br>\n", substr($map['routesContainerSelector'], 1), $displayStyle); $rval .= sprintf("<div><label><input type=\"radio\" name=\"transportationroute_a%d\" value=\"\" /> No Transportation</label></div>\n", $this->_currentActivity->id); $routeNameTag = sprintf('transportationroute_a%d', $this->_currentActivity->id); foreach ($trans->getTransportationOptions() as $id => $routeName) { $tmp = sprintf('<div id="%s"><label><input name="%s" type="radio" value="%d" /> %s</label></div>', $map['routeSelectorMap'][$id], $routeNameTag, $id, $routeName); $rval .= "\n" . $tmp; } return $rval . "</div>"; }