$pos = strrpos($newSiteSettings, $search); if ($pos !== false) { $newSiteSettings = substr_replace($newSiteSettings, $replace, $pos, strlen($search)); } update_option('bapi_sitesettings', $newSiteSettings); echo 'settings.propdetailratestable = "BAPI.config().hideratestable=false;";'; } if (strpos($sitesettings, 'BAPI.config().amenity.enabled') == false) { echo 'settings.amenitysearch = "BAPI.config().amenity.enabled=false;";'; } if (strpos($sitesettings, 'BAPI.config().sleeps.enabled') == false) { echo 'settings.sleepsearch = "BAPI.config().sleeps.enabled=false;";'; } } else { /* this is the data from the app, this is in the database, the bizrules */ $bapiSolutionData = BAPISync::getSolutionData(); $bapiSolutionDataConfig = $bapiSolutionData["ConfigObj"]; $maxratesearch = $bapiSolutionDataConfig["rate"]["enabled"] ? 'true' : 'false'; $amenitysearch = $bapiSolutionDataConfig["amenity"]["enabled"] ? 'true' : 'false'; $devsearch = $bapiSolutionDataConfig["dev"]["enabled"] ? 'true' : 'false'; $adultsearch = $bapiSolutionDataConfig["adults"]["enabled"] ? 'true' : 'false'; $childsearch = $bapiSolutionDataConfig["children"]["enabled"] ? 'true' : 'false'; $headlinesearch = $bapiSolutionDataConfig["headline"]["enabled"] ? 'true' : 'false'; $propdetailavailcal = $bapiSolutionDataConfig["displayavailcalendar"] ? 'true' : 'false'; $availcalendarmonths = $bapiSolutionDataConfig["availcalendarmonths"]; $propdetailreviewtab = $bapiSolutionDataConfig["hasreviews"] ? 'true' : 'false'; $propdetailrateavailtab = $bapiSolutionDataConfig["hideratesandavailabilitytab"] ? 'true' : 'false'; $propdetailratestable = $bapiSolutionDataConfig["hideratestable"] ? 'true' : 'false'; $poitypefilter = $bapiSolutionDataConfig["haspoitypefilter"] ? 'true' : 'false'; $checkin = $bapiSolutionDataConfig["checkin"]["enabled"] ? 'true' : 'false'; $checkout = $bapiSolutionDataConfig["checkout"]["enabled"] ? 'true' : 'false';
function kigo_get_site_language() { if (!is_array($solution_data = BAPISync::getSolutionData()) || !is_array($solution_data['Site']) || !is_string($solution_data['Site']['Language'])) { Loggly_logs::log(array('msg' => 'Unable to retrieve site language from solution data.', 'blog_id' => get_current_blog_id())); return 'en-US'; } return $solution_data['Site']['Language']; }
public static function getMustache($entity, $pkid) { $bapi = getBAPIObj(); if (!$bapi->isvalid()) { return false; } $pkid = array(intval($pkid)); // Set the options for get call switch ($entity) { case "property": $options = array("seo" => 1, "descrip" => 1, "avail" => 1, "rates" => 1, "reviews" => 1, "poi" => 1); break; case "poi": $options = array("nearbyprops" => 1, "seo" => 1); break; default: $options = null; break; } if (!is_array($c = $bapi->get($entity, $pkid, $options))) { if ($c === true) { return false; } else { wp_die('This page is temporarily unavailable. Please try again later.'); } } // when rendering a template, get() must result in at least one element if (count($c['result']) < 1 || !is_array($c['result'][0]) || $entity === 'property' && isset($c['result'][0]['AvailableOnline']) && !$c['result'][0]['AvailableOnline']) { return false; } $c["config"] = BAPISync::getSolutionData(); $c["config"] = $c["config"]["ConfigObj"]; /* we get the sitesettings */ global $bapi_all_options; $sitesettings = json_decode($bapi_all_options['bapi_sitesettings'], TRUE); if (!empty($sitesettings)) { /* we get the review value from the sitesettings*/ $hasreviews = $sitesettings["propdetail-reviewtab"]; if (!empty($hasreviews)) { /* we make an array using = and ; as delimiters */ $hasreviews = split('[=;]', $hasreviews); /* we assign the value to var in the config array - reviews*/ $hasreviews = $hasreviews[1]; $c["config"]["hasreviews"] = $hasreviews === 'true'; } /* the same as review but for the availability calendar */ $displayavailcalendar = $sitesettings["propdetail-availcal"]; if (!empty($displayavailcalendar)) { $displayavailcalendar = split('[=;]', $displayavailcalendar); $availcalendarmonths = (int) $displayavailcalendar[3]; $displayavailcalendar = $displayavailcalendar[1]; $c["config"]["displayavailcalendar"] = $displayavailcalendar === 'true'; $c["config"]["availcalendarmonths"] = $availcalendarmonths; } /* the same as review but for the rates and availability tab */ $hiderateavailtab = $sitesettings["propdetailrateavailtab"]; if (!empty($hiderateavailtab)) { $hiderateavailtab = split('[=;]', $hiderateavailtab); /* we assign the value to var in the config array */ $hiderateavailtab = $hiderateavailtab[1]; $c["config"]["hideratesandavailabilitytab"] = $hiderateavailtab === 'true'; } /* the same as review but for star reviews */ $hidestarsreviews = $sitesettings["averagestarsreviews"]; if (!empty($hidestarsreviews)) { $hidestarsreviews = split('[=;]', $hidestarsreviews); /* we assign the value to var in the config array */ $hidestarsreviews = $hidestarsreviews[1]; $c["config"]["hidestarsreviews"] = $hidestarsreviews === 'true'; } /* the same as review but for the rates table */ $hideratestable = $sitesettings["propdetailratestable"]; if (!empty($hideratestable)) { $hideratestable = split('[=;]', $hideratestable); /* we assign the value to var in the config array */ $hideratestable = $hideratestable[1]; $c["config"]["hideratestable"] = $hideratestable === 'true'; } } $c["textdata"] = kigo_I18n::get_translations(kigo_get_site_language()); // Load bapisync global $bapisync; if (is_a($bapisync, 'BAPISync')) { $bapisync = new BAPISync(); $bapisync->init(); } $mustache_loader = new Kigo_Mustache_Loader_By_Name($bapisync->get_templates()); $m = new Mustache_Engine(array('partials_loader' => $mustache_loader)); return str_replace(array("\t", "\n", "\r"), '', $m->render($bapisync->getMustacheTemplateByEntity($entity, $mustache_loader), $c)); }