Skip to content

Instantly share code, notes, and snippets.

@kdoran
Created March 27, 2012 20:51
Show Gist options
  • Save kdoran/2220146 to your computer and use it in GitHub Desktop.
Save kdoran/2220146 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Advanced</title>
<script type="text/javascript"
src="//sheridan.ugc.bazaarvoice.com/bvstaging/static/9516-en_au/bvapi.js">
</script>
<script type="text/javascript">
$BV.configure("global", {
submissionContainerUrl: "http://gavinhealy.com/bv/advanced.php?"
});
</script>
<script type="text/javascript">
// $BV.ui("rr", "show_reviews", {
// productId: "test1"
// });
</script>
</head>
<body>
<div id="BVRRContainer">
<?php
$CONFIG = array(
"DISPLAY_CODE" => "9516-en_au",
"PRODUCT_ID" => "test1",
"PRODUCT_URL" => "http://www.gavinhealy.com/bv/advanced.php?",
"REVIEWS_SMARTSEO_PARAM" => "bvrrp",
"SMART_SEO_PATH_PREFIX" => "seo/",
"CHARACTER_SET" => "ISO-8859-1"
);
if (isset($CONFIG["REVIEWS_SMARTSEO_PARAM"])) {
$bvrrpValue = $CONFIG["REVIEWS_SMARTSEO_PARAM"];
}
$reviewsSmartSEOFileName = bvGetSourceSVIFile($bvrrpValue, $CONFIG);
if (!is_null($reviewsSmartSEOFileName)) {
$indexableContent = bvURLTokenReplace($reviewsSmartSEOFileName, $CONFIG["PRODUCT_URL"]);
print mb_convert_encoding($indexableContent, $CONFIG["CHARACTER_SET"], 'UTF-8');
}
function bvURLTokenReplace($filename, $url) {
return str_replace('{INSERT_PAGE_URI}', $url, file_get_contents($filename));
}
function bvGetSourceSVIFile($rrPage, $CONFIG) {
if ($rrPage) {
$sourceFile = realpath($CONFIG["SMART_SEO_PATH_PREFIX"] . $rrPage);
if (strpos($sourceFile, $CONFIG["SMART_SEO_PATH_PREFIX"] . $CONFIG["DISPLAY_CODE"]) == 0 && is_file($sourceFile)) {
return $sourceFile;
}
}
$firstPageContent = $CONFIG["SMART_SEO_PATH_PREFIX"] . $CONFIG["DISPLAY_CODE"] . '/reviews/product/1/' . rawurlencode($CONFIG["PRODUCT_ID"]) . '.htm';
if (is_file($firstPageContent)) {
return $firstPageContent;
}
return NULL;
}
?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment