Copyright (c) 2002, DM Solutions Group Inc. * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ include_once(dirname(__FILE__)."/../Widget.php"); /** * MapImageWidget * * @desc Map image widget. Provides a single click on the map and * updates the NAV_INPUT_COORD parameter. */ class MapImageWidget extends CWCWidget { var $msMapImageName = "DEFAULT_MAP"; var $mszDrawMapParams = ""; var $mszWaitImage = ""; var $mnWaitImageWidth; var $mnWaitImageHeight; var $mbBorder = false; var $mbAllowResize = true; var $mbNavigable = false; var $mbTransparent = false; var $mnWidth = ""; var $mnHeight = ""; var $mnMinxx = ""; var $mnMinxy = ""; var $mnMaxxx = ""; var $mnMaxxy = ""; var $mszImageType = ""; function MapImageWidget() { // invoke constructor of parent parent::CWCWidget(); // set the description for this widget $this->szWidgetDescription = "No description available. Please set ". "this description in the constructor of this class."; $this->maAttributes["WAITIMAGE"] = new StringAttribute( "WAITIMAGE", false); $this->maAttributes["WAITIMAGEWIDTH"] = new IntegerAttribute( "WAITIMAGEWIDTH", false, 0 ); $this->maAttributes["WAITIMAGEHEIGHT"] = new IntegerAttribute( "WAITIMAGEHEIGHT", false, 0 ); $this->maAttributes["BORDER"] = new BooleanAttribute( "BORDER", false); $this->maAttributes["ID"] = new StringAttribute("ID", false); $this->maAttributes["SRS"] = new StringAttribute("SRS", false); $this->maAttributes["MINX"] = new IntegerAttribute("MINX", false); $this->maAttributes["MINY"] = new IntegerAttribute("MINY", false); $this->maAttributes["MAXX"] = new IntegerAttribute("MAXX", false); $this->maAttributes["MAXY"] = new IntegerAttribute("MAXY", false); $this->maAttributes["WIDTH"] = new IntegerAttribute("WIDTH", false); $this->maAttributes["HEIGHT"] = new IntegerAttribute("HEIGHT", false); $this->maAttributes["ALLOWRESIZE"] = new BooleanAttribute( "ALLOWRESIZE", false); $this->maAttributes["NAVIGABLE"] = new BooleanAttribute( "NAVIGABLE", false); $this->maAttributes["TRANSPARENT"] = new BooleanAttribute( "TRANSPARENT", false); $this->maAttributes["IMAGETYPE"] = new StringAttribute( "IMAGETYPE", false, array("PNG", "PNG24", "JPEG", "GIF", "SWF")); $this->mnPriority = PRIORITY_HIGH; $this->mnMaturityLevel = MATURITY_BETA; } function InitDefaults() { //now check the widget attributes to see if it is overridden if (isset($this->maParams["WAITIMAGE"])) { $this->mszWaitImage = $this->maParams["WAITIMAGE"]; } if (isset($this->maParams["WAITIMAGEWIDTH"])) $this->mnWaitImageWidth = $this->maParams["WAITIMAGEWIDTH"]; if (isset($this->maParams["WAITIMAGEHEIGHT"])) $this->mnWaitImageHeight = $this->maParams["WAITIMAGEHEIGHT"]; if (isset($this->maParams["WIDTH"])) $this->mnWidth = $this->maParams["WIDTH"]; if (isset($this->maParams["HEIGHT"])) $this->mnHeight = $this->maParams["HEIGHT"]; if (isset($this->maParams["BORDER"])) $this->mbBorder = ((strcasecmp($this->maParams["BORDER"],"true")==0)?true:false); if (isset($this->maParams["ALLOWRESIZE"])) { if (strcasecmp( $this->maParams["ALLOWRESIZE"] , "true" ) == 0) $this->mbAllowResize = true; else $this->mbAllowResize = false; } if (isset($this->maParams["NAVIGABLE"])) { if (strcasecmp( $this->maParams["NAVIGABLE"] , "true" ) == 0) $this->mbNavigable = true; else $this->mbNavigable = false; } if (isset($this->maParams["TRANSPARENT"])) $this->mbTransparent = ((strtoupper($this->maParams["TRANSPARENT"]) == "TRUE") ? true : false); if (isset($this->maParams["IMAGETYPE"])) $this->mszImageType = $this->maParams["IMAGETYPE"]; parent::InitDefaults(); } /** * DrawPublish * * Draw the map and return the HTML. */ function DrawPublish() { $oMap =& $this->moMapObject->oMap; // Get a copy of width and height $nOldWidth = $oMap->width+0; $nOldHeight = $oMap->height+0; // Get a copy of map extents $nOldMinX = $oMap->extent->minx+0; $nOldMinY = $oMap->extent->miny+0; $nOldMaxX = $oMap->extent->maxx+0; $nOldMaxY = $oMap->extent->maxy+0; $oMap->width = $this->mnWidth; $oMap->height = $this->mnHeight; $nWidth = $oMap->width; $nHeight = $oMap->height; // reproject the extent specified in cwc tag to map projection if ($oMap->getProjection() != "" && $this->GetValue("srs") != "" && strstr($oMap->getProjection(), $this->GetValue("srs")) === false) { // Get map rojection as output $szTmpMapProj = $oMap->getProjection(); // Get projection specified in cwc tag $projOutObj = ms_newprojectionobj( $szTmpMapProj ); $projInObj = ms_newprojectionobj("init=".strtolower($this->GetValue("srs"))); $poRect = ms_newrectobj(); $poRect->setextent($this->GetValue("minx", $nOldMinX), $this->GetValue("miny", $nOldMinY), $this->GetValue("maxx", $nOldMaxX), $this->GetValue("maxy", $nOldMaxY)); $poRect->project($projInObj, $projOutObj); $this->mszDrawMapParams .= "&nMinX=".$poRect->minx. "&nMinY=".$poRect->miny. "&nMaxX=".$poRect->maxx. "&nMaxY=".$poRect->maxy; } else { $this->mszDrawMapParams .= "&nMinX=".$this->GetValue("minx", $nOldMinX). "&nMinY=".$this->GetValue("miny", $nOldMinY). "&nMaxX=".$this->GetValue("maxx", $nOldMaxX). "&nMaxY=".$this->GetValue("maxy", $nOldMaxY); } if ($this->mbTransparent != "") $this->mszDrawMapParams .= "&bTransparent=".$this->mbTransparent; if ($this->mszImageType != "") $this->mszDrawMapParams .= "&gszImgType=".$this->mszImageType; if($this->GetValue("id", $this->GetValue("name")) != "") $this->mszDrawMapParams .= "&gszMapId=".$this->GetValue("id", $this->GetValue("name")); $this->mnWidth = $this->GetValue("width", $nOldWidth); $this->mnHeight = $this->GetValue("height", $nOldHeight); $this->mszDrawMapParams .= "&nWidth=".$this->GetValue("width", $nOldWidth); $this->mszDrawMapParams .= "&nHeight=".$this->GetValue("height", $nOldHeight); $bNetscape4 = false; if (isset($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'])) { if (stristr($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'], "Mozilla/4") && (!(stristr($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'], "compatible")))) $bNetscape4 = true; } else $bNetscape4 = true; if (!$this->mbNavigable) $szImgType = "img"; else $szImgType = "input type=image onclick=\"if (!bPageLoaded) return false;\""; $szReturn = "