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)); }