function getHTML($which) { global $path, $leftPath, $rightPath, $rightExporting, $leftExporting; $bogus = md5('bogus'); // No idea why file_get_contents doesn't work here... ob_start(); include "{$path}/demo.html"; $s = ob_get_clean(); $s = cachify($s); $s = str_replace('cache.php?file=http://code.highcharts.com/mapdata', $bogus, $s); if ($which == 'left') { $s = str_replace('cache.php?file=http://code.highcharts.com', $leftPath, $s); $exporting = $rightExporting; } else { $s = str_replace('cache.php?file=http://code.highcharts.com', $rightPath, $s); $exporting = $leftExporting; } $s = str_replace($bogus, 'cache.php?file=http://code.highcharts.com/mapdata', $s); if (strlen($s) > 0 && strpos($s, 'exporting.js') === false) { $s .= '<script src="' . $exporting . '"></script>'; } return $s; }
function getHTML($which) { global $path, $leftPath, $rightPath, $rightExporting, $leftExporting, $isUnitTest; $bogus = md5('bogus'); // No idea why file_get_contents doesn't work here... ob_start(); include "{$path}/demo.html"; $s = ob_get_clean(); if (strstr($s, 'http://')) { $s .= '<script>console.warn("Do not use http in demo.html. Use secure https.")</script>'; } if (strstr($s, '.src.js')) { $s .= '<script>console.warn("Do not use src.js files in demos. Use .js compiled files.")</script>'; } $s = cachify($s); $s = str_replace('cache.php?file=https://code.highcharts.com/mapdata', $bogus, $s); if ($which == 'left') { $s = str_replace('cache.php?file=https://code.highcharts.com', $leftPath, $s); $exporting = $leftExporting; } else { // These are the files we want to test. Append a time stamp to ensure we're not loading // from browser cache. $s = preg_replace_callback('/cache\\.php\\?file=https:\\/\\/code\\.highcharts\\.com([a-z\\/\\-\\.]+)/', function ($matches) { global $rightPath; $src = $rightPath . $matches[1]; $src = str_replace('.js', '.js?' . mktime(), $src); return $src; }, $s); $exporting = $rightExporting; } $s = str_replace($bogus, 'cache.php?file=https://code.highcharts.com/mapdata', $s); // If the export module is not loaded, add it so we can run compare if (strlen($s) > 0 && strpos($s, 'exporting.js') === false && !$isUnitTest) { $s .= '<script src="' . $exporting . '"></script>'; } return $s; }
function getHTML($which) { global $path, $leftPath, $rightPath, $rightExporting, $leftExporting, $isUnitTest; $bogus = md5('bogus'); // No idea why file_get_contents doesn't work here... ob_start(); include "{$path}/demo.html"; $s = ob_get_clean(); // for issue-by-commit $issueHTML = $s; $issueHTML = str_replace('https://code.highcharts.com/stock/', 'http://github.highcharts.com/%s/', $issueHTML); $issueHTML = str_replace('https://code.highcharts.com/maps/', 'http://github.highcharts.com/%s/', $issueHTML); $issueHTML = str_replace('https://code.highcharts.com/mapdata/', $bogus, $issueHTML); $issueHTML = str_replace('https://code.highcharts.com/', 'http://github.highcharts.com/%s/', $issueHTML); $issueHTML = str_replace($bogus, 'https://code.highcharts.com/mapdata/', $issueHTML); $issueHTML = "<script src=\"http://code.jquery.com/jquery-1.11.0.js\"></script>\n" . $issueHTML; $_SESSION['html'] = $issueHTML; if (strstr($s, 'http://code.highcharts.com') || strstr($s, 'http://www.highcharts.com')) { $s .= "<script>throw 'Do not use http in demo.html. Use secure https. ({$path})';</script>"; } if (strstr($s, '.src.js')) { $s .= "<script>throw 'Do not use src.js files in demos. Use .js compiled files. ({$path})';</script>"; } $s = cachify($s); $s = str_replace('cache.php?file=https://code.highcharts.com/mapdata', $bogus, $s); if ($which == 'left') { $s = str_replace('cache.php?file=https://code.highcharts.com', $leftPath, $s); $exporting = $leftExporting; } else { if (strstr($rightPath, 'github') !== false) { $s = str_replace('cache.php?file=https://code.highcharts.com', $rightPath, $s); } else { // These are the files we want to test. Append a time stamp to ensure we're not loading // from browser cache. $s = preg_replace_callback('/cache\\.php\\?file=https:\\/\\/code\\.highcharts\\.com([a-z\\/\\-\\.]+)/', function ($matches) { global $rightPath; $src = $rightPath . $matches[1]; $src = str_replace('.js', '.js?' . time(), $src); return $src; }, $s); } $exporting = $rightExporting; } $s = str_replace($bogus, 'cache.php?file=https://code.highcharts.com/mapdata', $s); // If the export module is not loaded, add it so we can run compare if (strlen($s) > 0 && strpos($s, 'exporting.js') === false && !$isUnitTest) { $s .= '<script src="' . $exporting . '"></script>'; } return $s; }
function getHTML($which) { global $path, $leftPath, $rightPath, $rightExporting, $leftExporting, $isUnitTest, $githubServer; $bogus = md5('bogus'); // No idea why file_get_contents doesn't work here... ob_start(); if (is_file("{$path}/demo.html")) { include "{$path}/demo.html"; } elseif ($which === 'right') { echo "\n\t\t\t<div style='padding: 2em; text-align: center'>\n\t\t\t\t<span style='color:red'>Missing file:</span><br>\n\t\t\t\t<code style='line-height: 3em'>{$path}/demo.html</code><br>\n\t\t\t\tProbably the sample has been deleted but the folder structure \n\t\t\t\tremains. This happens when deleting files from Git. The\n\t\t\t\tremaining folders can safely be removed.\n\t\t\t</div>\n\t\t"; } $s = ob_get_clean(); // Highchart 5 preview $s = str_replace("code.highcharts.com/5/", "code.highcharts.com/", $s); // for issue-by-commit $issueHTML = $s; $issueHTML = str_replace('https://code.highcharts.com/stock/', $githubServer . '/%s/', $issueHTML); $issueHTML = str_replace('https://code.highcharts.com/maps/', $githubServer . '/%s/', $issueHTML); $issueHTML = str_replace('https://code.highcharts.com/mapdata/', $bogus, $issueHTML); $issueHTML = str_replace('https://code.highcharts.com/', $githubServer . '/%s/', $issueHTML); $issueHTML = str_replace($bogus, 'https://code.highcharts.com/mapdata/', $issueHTML); $issueHTML = "<script src=\"http://code.jquery.com/jquery-1.11.0.js\"></script>\n" . $issueHTML; $_SESSION['html'] = $issueHTML; if (strstr($s, 'http://code.highcharts.com') || strstr($s, 'http://www.highcharts.com')) { $s .= "\n\t\t<script>\n\t\twindow.demoError = 'Do not use http in demo.html. Use secure https. ({$path})';\n\t\tthrow window.demoError;\n\t\t</script>"; } if (strstr($s, '.src.js')) { $s .= "\n\t\t<script>\n\t\twindow.demoError = 'Do not use src.js files in demos. Use .js compiled files, and add rewrite in .htaccess ({$path})';\n\t\tthrow window.demoError;\n\t\t</script>"; } $s = cachify($s); $s = str_replace('cache.php?file=https://code.highcharts.com/mapdata', $bogus, $s); if ($which == 'left') { $s = str_replace('cache.php?file=https://code.highcharts.com', $leftPath, $s); $exporting = $leftExporting; } else { if (strstr($rightPath, 'github') !== false) { $s = str_replace('cache.php?file=https://code.highcharts.com', $rightPath, $s); } else { // These are the files we want to test. Append a time stamp to ensure we're not loading // from browser cache. $s = preg_replace_callback('/cache\\.php\\?file=https:\\/\\/code\\.highcharts\\.com([a-z\\/\\-\\.]+)/', function ($matches) { global $rightPath; $src = $rightPath . $matches[1]; $src = str_replace('.js', '.js?' . time(), $src); return $src; }, $s); } $exporting = $rightExporting; } $s = str_replace($bogus, 'cache.php?file=https://code.highcharts.com/mapdata', $s); // If the export module is not loaded, add it so we can run compare if (strlen($s) > 0 && strpos($s, 'exporting.js') === false && !$isUnitTest) { $s .= '<script src="' . $exporting . '"></script>'; } return $s; }
function getHTML($which) { global $path, $leftPath, $rightPath, $rightExporting, $leftExporting, $isUnitTest; $bogus = md5('bogus'); // No idea why file_get_contents doesn't work here... ob_start(); include "{$path}/demo.html"; $s = ob_get_clean(); if (strstr($s, 'http://')) { $s .= '<script>console.warn("Do not use http in demo.html. Use secure https.")</script>'; } if (strstr($s, '.src.js')) { $s .= '<script>console.warn("Do not use src.js files in demos. Use .js compiled files.")</script>'; } $s = cachify($s); $s = str_replace('cache.php?file=https://code.highcharts.com/mapdata', $bogus, $s); if ($which == 'left') { $s = str_replace('cache.php?file=https://code.highcharts.com', $leftPath, $s); $exporting = $leftExporting; } else { $s = str_replace('cache.php?file=https://code.highcharts.com', $rightPath, $s); $s = str_replace('.js"', '.js?' . mktime() . '"', $s); $exporting = $rightExporting; } $s = str_replace($bogus, 'cache.php?file=https://code.highcharts.com/mapdata', $s); // If the export module is not loaded, add it so we can run compare if (strlen($s) > 0 && strpos($s, 'exporting.js') === false && !$isUnitTest) { $s .= '<script src="' . $exporting . '"></script>'; } return $s; }