| 1 |
<?php |
| 2 |
|
| 3 |
require_once 'cge-www-configure.php'; |
| 4 |
|
| 5 |
|
| 6 |
function read_cge_version() |
| 7 |
{ |
| 8 |
$handle = fopen('../../../src/base/castleversion.inc', 'rt'); |
| 9 |
if ($handle == false) { |
| 10 |
throw new Exception('Error: failed to open castleversion.inc'); |
| 11 |
} |
| 12 |
$line = fgets($handle); |
| 13 |
if ($line === false) { |
| 14 |
throw new Exception('Error: cannot read line using fgets()'); |
| 15 |
} |
| 16 |
fclose($handle); |
| 17 |
return trim($line, "\t\n'"); |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
$cgeVersions = array( |
| 22 |
'7.0-alpha.snapshot' => array('url' => CASTLE_PROD_URL . 'apidoc/html/'), |
| 23 |
); |
| 24 |
|
| 25 |
$cgeCurrentVersion = read_cge_version(); |
| 26 |
if (!array_key_exists($cgeCurrentVersion, $cgeVersions)) { |
| 27 |
throw new Exception('Current version ' . $cgeCurrentVersion . ' has no entry in cgeVersions table'); |
| 28 |
} |
| 29 |
?> |
| 30 |
|
| 31 |
</div> <!-- .pasdoc-container --> |
| 32 |
|
| 33 |
</div> <!-- behave like castle_footer when $castle_sidebar is empty --> |
| 34 |
|
| 35 |
<?php |
| 36 |
echo_footer(); |
| 37 |
|
| 38 |
|
| 39 |
?> |
| 40 |
<!-- jQuery (necessary for Bootstrap's JavaScript plugins). |
| 41 |
Used also by colorbox. |
| 42 |
|
| 43 |
For API reference: load jQuery only if not loaded yet, otherwise |
| 44 |
Tipue search results are broken (since they load a duplicate jQuery earlier). |
| 45 |
The code to load jQuery conditionally is from |
| 46 |
http://stackoverflow.com/questions/10371211/include-jquery-if-not-included-already |
| 47 |
--> |
| 48 |
<script type="text/javascript"> |
| 49 |
if(typeof jQuery == 'undefined'){ |
| 50 |
document.write('<script type="text/javascript" src="<?php echo page_requisite('castle-engine-website-base/node_modules/jquery/dist/jquery.min.js'); ?>"></'+'script>'); |
| 51 |
|
| 52 |
/* This looks nicer, but to make it work, also the following colorbox and bootstrap JS |
| 53 |
have to be loaded the same way. Otherwise, colorbox and bootstrap JS are loaded |
| 54 |
too early, and they don't work. |
| 55 |
var oScriptElem = document.createElement("script"); |
| 56 |
oScriptElem.type = "text/javascript"; |
| 57 |
oScriptElem.src = "<?php echo page_requisite('castle-engine-website-base/node_modules/jquery/dist/jquery.min.js'); ?>"; |
| 58 |
document.head.insertBefore(oScriptElem, document.head.getElementsByTagName("script")[0]) |
| 59 |
*/ |
| 60 |
} |
| 61 |
</script> |
| 62 |
<!-- Include colorbox after jQuery is known --> |
| 63 |
<script src="<?php echo page_requisite('castle-engine-website-base/node_modules/jquery-colorbox/jquery.colorbox-min.js'); ?>" type="text/javascript"></script> |
| 64 |
<script type="text/javascript"> |
| 65 |
jQuery('a.screenshot').colorbox({opacity: 0.9, rel:'screenshot', maxWidth:'90%', maxHeight:'90%'}); |
| 66 |
</script> |
| 67 |
<!-- Include all compiled plugins (below), or include individual files as needed --> |
| 68 |
<script src="<?php echo page_requisite('castle-engine-website-base/node_modules/bootstrap/dist/js/bootstrap.min.js'); ?>"></script> |
| 69 |
<!-- JS using jquery --> |
| 70 |
<script type="text/javascript" src="<?php echo page_requisite('castle-engine-website-base/castle-engine.js'); ?>"></script> |
| 71 |
|
| 72 |
<?php |
| 73 |
|
| 74 |
|
| 75 |
echo "<script type='text/javascript'> |
| 76 |
var cgeCurrentVersion = '$cgeCurrentVersion'; |
| 77 |
var cgeVersions = [ |
| 78 |
"; |
| 79 |
$cgeVersionsStr = ''; |
| 80 |
foreach ($cgeVersions as $versionId => $versionInfo) { |
| 81 |
$versionUrl = $versionInfo['url']; |
| 82 |
$cgeVersionsStr .= " {'id': '$versionId', 'url': '$versionUrl'},\n"; |
| 83 |
} |
| 84 |
$cgeVersionsStr = trim($cgeVersionsStr, "\n,"); |
| 85 |
echo $cgeVersionsStr . " |
| 86 |
]; |
| 87 |
</script> |
| 88 |
"; |
| 89 |
?> |
| 90 |
<script type="text/javascript" src="<?php echo page_requisite('cge-pasdoc.js'); ?>"></script> |