85 lines
2.8 KiB
PHP
85 lines
2.8 KiB
PHP
<?php
|
|
/** \file include\mapview_codegen.php
|
|
* \brief PHP code generator for the map view.
|
|
* \author Bart van Hest, Core|Vision
|
|
* \version 1.0
|
|
* \date xx-xx-xx
|
|
*
|
|
* This file contains the (JavaScript) code generator functions for the map view.
|
|
*
|
|
* Usage:
|
|
* $extra_hdr_HTML = mapview_GenHdrCode (TransTbl);
|
|
*
|
|
* where TransTbl is an associative array with status messages
|
|
*/
|
|
|
|
|
|
//**********************************************
|
|
//* Our Javascript code in some text variables *
|
|
//**********************************************
|
|
|
|
// Some header stuff to begin with
|
|
$hdr_part1 = <<< HDR_PART1
|
|
<link rel="stylesheet" href="html/javascript/OpenLayers/theme/default/style.css" type="text/css">
|
|
|
|
<!--[if lte IE 6]>
|
|
<!-- IE6 workaround???, Otherwhise the rt page is not loaded -->
|
|
<div style="position:absolute;visibility:hidden">
|
|
IE6 Workaround
|
|
</div>
|
|
<![endif]-->
|
|
|
|
<script src="html/javascript/VirtualEarth/mapcontrol.js" type="text/javascript"></script>
|
|
<script src="html/javascript/OpenLayers/OpenLayers.js"></script>
|
|
<script src="html/javascript/mapview.js"></script>
|
|
|
|
HDR_PART1;
|
|
|
|
//**********************************************
|
|
//* Function definition *
|
|
//**********************************************
|
|
|
|
|
|
/*
|
|
* Our HTML 'header generator'. This function generates the code which should be placed
|
|
* between HTML <head> and </head> tags.
|
|
*
|
|
* Usage:
|
|
* $head_html = mapview_GenHdrCode ($translation_tbl);
|
|
*
|
|
* Where
|
|
* - $translation_tbl is an associative array containing parameter<->English text pairs.
|
|
* This is used in popups to do a dynamic translation between a ZKL instance parameter
|
|
* to human readable text.
|
|
*
|
|
* The English strings are fed through i18n, so it is not necessary to do this before
|
|
* entering this function.
|
|
*
|
|
* Example: say we have a parameter called 'gps_lon' for GPS coordinate longitude. To
|
|
* translate this into human readable form, make sure thi sis in the code somewhere:
|
|
* translation_tbl['gps_lon'] = "GPS Longitude:";
|
|
*/
|
|
|
|
function mapview_GenHdrCode($translation_tbl) {
|
|
// Generate JavaScript version of the translation table
|
|
$js_trans_tbl = '<script type="text/javascript">var StatusTranslationTable = {';
|
|
$bFirstEntry = true;
|
|
foreach ($translation_tbl as $key => $value) {
|
|
if ($bFirstEntry) {
|
|
$bFirstEntry = false;
|
|
}
|
|
else {
|
|
// Add comma between entries in the JS object
|
|
$js_trans_tbl .= ',';
|
|
}
|
|
$js_trans_tbl .= "'" . $key . "':'" . ucfirst(_($value)) . "'";
|
|
}
|
|
$js_trans_tbl .= '};</script>'."\n";
|
|
|
|
// Assemble the different parts, and return the assembly
|
|
return "<!-- Begin of mapview_GenHdrCode() generated content -->\n".
|
|
$GLOBALS['hdr_part1'].
|
|
$js_trans_tbl.
|
|
"<!-- End of mapview_GenHdrCode() generated content -->\n";
|
|
}
|
|
?>
|