|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_integration/pathumthani_drug/plugins/content/google/ |
Upload File : |
<?php
require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_google'.DS.'helpers'.DS.'configuration.php');
global $mainframe;
$document =& JFactory::getDocument();
//split language tag up so I can decide how google should be displayed
$lang =& JFactory::getLanguage();
$lang_tag = $lang->getTag();
$current_language = split('-',$lang_tag);
$current_language = $current_language[0];
$direction_language = $current_language . '_' . strtoupper($current_language);
//api key
$split_homepage = explode(",",$homepage_url_temp);
$split_api = explode(",",$google_api_temp);
$curr_homepage = str_replace("www.","",$_SERVER['SERVER_NAME']);
$counter = 0;
foreach ($split_homepage as $homepage){
$uri = trim($homepage);
$u =& JURI::getInstance( $uri );
$temp_homepage = str_replace("www.","",$u->getHost());
if ($temp_homepage==$curr_homepage) {
$google_api = $split_api[$counter];
break;
}
$counter++;
}
//google params
$width = $google_params->width;
if(!$width){$width='100%';}
$height = $google_params->height;
if(!$height){$height='400px';}
$zoomlevel = $google_params->zoomlevel;
if(!$zoomlevel){$zoomlevel=7;}
$routing = $google_params->routing;
if(!$routing){$routing=0;}
$maptype = $google_params->maptype;
if($maptype=='normal' || $maptype==''){
$maptype='G_NORMAL_MAP';
}elseif ($maptype=='satellite'){
$maptype='G_SATELLITE_MAP';
}elseif ($maptype=='hybrid'){
$maptype='G_HYBRID_MAP';
}elseif ($maptype=='terrain'){
$maptype='G_PHYSICAL_MAP';
}
//google data
$dest_address = $google->address;
$dest_zipcode = $google->zipcode;
$dest_town = $google->town;
$dest_lat = $google->lat;
$dest_long = $google->long;
$dest_icon = $google->icon_type;
$dest_picture = $google->picture;
$dest_txt = $google->txt;
static $HeaderAdded;
if(!$HeaderAdded) {
$HeaderAdded=1;
$header .= '
window.addEvent(\'load\', function() {
load();
});
window.addEvent(\'onunload\', function(){
GUnload();
});
var marker;
var overlayInstance = null;
var map;
var panoClient;
var myPano;
var info = [];
var gmarkers = [];
var htmls = [];
var i = 0;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("googlemap"));
map.setCenter(new GLatLng("'.$dest_lat.'","'.$dest_long.'"), '.$zoomlevel.');
map.setUIToDefault();
map.setMapType('.$maptype.');
';
$header .='
var baseIcon = new GIcon();
baseIcon.shadow = "'.JURI::base().'components/com_google/icons/map_shadow.png";
baseIcon.shadowSize = new GSize(35, 45);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);
function createMarker(point, tekst, type, index) {
var icon = new GIcon(baseIcon);
icon.image = "'.JURI::base().'components/com_google/icons/"+type;
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(tekst);
});
gmarkers[i] = marker;
info[i] = tekst;
i++;
return marker;
}
';
$txt = str_replace(chr(13),'<br />',$dest_txt);
$txt = str_replace(chr(10),'',$txt);
$txt = str_replace(chr(34),chr(39),$txt);
$google_html = "<div class='google_html'>";
$google_html = $google_html . "<b>" . $google->name . "</b>";
if($dest_picture){
$imgSizeInfo=getimagesize('images/google/'.$dest_picture);
$google_html = $google_html . "<br /><br />" ."<img src='".JURI::root()."images/google/".$dest_picture."' border='0' width='".$imgSizeInfo[0]."' height='".$imgSizeInfo[1]."'/>";
}
if($dest_address || $dest_zipcode || $dest_town)
{
$google_html = $google_html . "<br /><br /><strong>". JText::_( 'GOOGLE_ADDRESS') ."</strong><br />" .$dest_address;
$google_html = $google_html . "<br />" .$dest_zipcode;
$google_html = $google_html . " -- " .$dest_town;
}
if($txt){$google_html = $google_html . "<br /><br /><strong>". JText::_( 'GOOGLE_DESCRIPTION')."</strong><br />".$txt;}
$google_html = $google_html . "</div>";
$header .= "var point = new GLatLng(\"$dest_lat\",\"$dest_long\");\n";
$header .= "map.addOverlay(createMarker(point,\"$google_html\",\"$dest_icon\"));\n";
$header .= '
}
}
';
if($routing==1){
$header .='
function resetmap() {
document.getElementById("directions").innerHTML = "";
document.getElementById("direction_feedback").innerHTML = "";
}
//route
var geocoder;
function map_start() {
var map;
var gdir = null;
var geocoder = null;
var addressMarker;
var from_address = document.getElementById("from_address").value;
var from_zipcode = document.getElementById("from_zipcode").value;
var from_town = document.getElementById("from_town").value;
var to_address = document.getElementById("to_address").value;
var from_start = "";
if(from_address=="'.JText::_( 'GOOGLE_INPUT_FIELDSET').'") from_address="";
if(from_zipcode=="'.JText::_( 'GOOGLE_INPUT_FIELDSET_AREA').'") from_zipcode="";
if(from_town=="'.JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN').'") from_town="";
if(from_address) from_start = from_address + ","+"";
if(from_zipcode) from_start += from_zipcode+ ","+"";
if(from_town) from_start += from_town;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("googlemap"));
map.setUIToDefault();
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
setDirections(from_start, to_address, "'.$direction_language.'");
}
}
function setDirections(fromAddress, toAddress, locale) {
gdir.load("from: " + fromAddress + " to: " + toAddress,{ "locale": locale });
}
function handleErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS){
alert("'.JText::_( 'GOOGLE_INITIALIZE_ERROR1').'");
load();
}else{
alert("'.JText::_( 'GOOGLE_INITIALIZE_ERROR2').'");
load();
}
}
function onGDirectionsLoad(){
';
$header .= 'document.getElementById("direction_feedback").innerHTML= "<input type=\"button\" value=\"'.JText::_( 'GOOGLE_DIRECTION_PRINT').'\" onClick=\"printSpecial()\" class=\"print_btn\"/>"+"<a href=\"javascript: load();resetmap();\" id=\"direction_started\">'.JText::_( 'GOOGLE_DIRECTION_FEEDBACK').'</a>";';
$header .='
document.getElementById("directions").innerHTML = "";
}
initialize();
}
//print
var gAutoPrint = false;
function printSpecial()
{
if (document.getElementById != null)
{
var html = "<HTML>\n<HEAD>\n";
html += "\n</HE" + "AD>\n<BODY>\n";
var printReadyElem = document.getElementById("directions");
if (printReadyElem != null)
{
html += "<button onclick=window.print()>'.JText::_( 'GOOGLE_DIRECTION_PRINT').'</button><br /><br/>";
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady section in the HTML");
return;
}
html += "\n</BO" + "DY>\n</HT" + "ML>";
var printWin = window.open("","printSpecial", "width = 600");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("'.JText::_( 'GOOGLE_DIRECTION_OK').'");
}
}
';
}
$document->addscript("http://maps.google.com/maps?file=api&v=2&hl=$current_language&key=$google_api");
$document->addScriptDeclaration($header);
$document->addStyleSheet(JURI::root().'components'.DS.'com_google'.DS.'css'.DS.'google.css');
}
$html = '<div id="googlemap" style="width: '.$width.'; height: '.$height.'; clear: both;"></div>';
if ($routing==1) :
$html .= '
<fieldset id="google_select">
<legend>'.JText::_( 'GOOGLE_ROUTEPLANNING').'</legend>
<form action="" onsubmit="map_start(); return false" method="post">
';
$html .= "<label>".JText::_( 'GOOGLE_FROM')."</label>";
$html .= "<input type='text' name='from_address' id='from_address' value='".JText::_( 'GOOGLE_INPUT_FIELDSET')."' onfocus=\"if (this.value=='".JText::_( 'GOOGLE_INPUT_FIELDSET')."') {this.value='';}\" onblur=\"if (this.value=='') {this.value='". JText::_( 'GOOGLE_INPUT_FIELDSET')."';}\" />";
$html .= "<input type='text' name='from_zipcode' id='from_zipcode' value='".JText::_( 'GOOGLE_INPUT_FIELDSET_AREA')."' onfocus=\"if (this.value=='".JText::_( 'GOOGLE_INPUT_FIELDSET_AREA')."') {this.value='';}\" onblur=\"if (this.value=='') {this.value='". JText::_( 'GOOGLE_INPUT_FIELDSET_AREA')."';}\" />";
$html .= "<input type='text' name='from_town' id='from_town' value='".JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN')."' onfocus=\"if (this.value=='".JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN')."') {this.value='';}\" onblur=\"if (this.value=='') {this.value='". JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN')."';}\" />";
$html .= '<input type="hidden" name="to_address" id="to_address" value="'.$dest_lat.','.$dest_long.'" />';
$html .= '
<label></label>
<input type="submit" value="'. JText::_( 'GOOGLE_SELECT_BUTTON').'" class="btn" />
</form>
</fieldset>
<div class="clear"></div>
';
$html .= "<div id='directions' style='width:$width;height: auto;'></div>";
$html .= "<div id='direction_feedback'></div>";
endif;
return $html;
?>