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"); include_once(dirname(__FILE__)."/../Button.php"); include_once(dirname(__FILE__)."/../Popup.php"); include_once(dirname(__FILE__)."/../Label.php"); //ekg /** * MapSize is an embeddable widget that can be used to modify the * current map size (context window) */ class MapSize extends CWCWidget { var $moButton; var $moPopup; var $mszWidgetClass = ''; var $moLabel; //ekg /** * constructor */ function MapSize() { $this->mszLanguageresource = str_replace("\\","/",dirname(__FILE__))."/MapSize.dbf"; // invoke constructor of parent parent::CWCWidget(); $this->moPopup = new CWCPopup($this); $this->moButton = new CWCButton($this); $this->moLabel = new CWCLabel( $this ); // set the description for this widget $this->szWidgetDescription = <<maAttributes["WIDGETCLASS"] = new StringAttribute("WIDGETCLASS", false); $this->maAttributes['EMBEDDED'] = new BooleanAttribute( 'EMBEDDED', false ); $this->mnMaturityLevel = MATURITY_BETA; } function InitDefaults() { parent::InitDefaults(); //this widget should never belong to a toolset $this->maParams["TOOLSET"] = ""; if (isset($this->maParams["EMBEDDED"]) && strcasecmp(trim($this->maParams["EMBEDDED"]), "FALSE") == 0) $this->mbEmbedded = false; else $this->mbEmbedded = true; // set the embedded attribute $this->maAttributes['EMBEDDED'] = $this->mbEmbedded; if (!$this->mbEmbedded) { $this->moButton->SetOnClick("clickMapSizePopup"); $this->moButton->InitDefaults(); } $this->moPopup->InitDefaults(); $this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/MapSize/MapSizePopup.phtml"; if(isset($this->maParams["WIDGETCLASS"]) && $this->maParams["WIDGETCLASS"] != "") $this->mszWidgetClass = $this->maParams["WIDGETCLASS"]; } /** * inspect URL parameters for map size changes */ function ParseURL() { if (!$this->isVarSet( "SET_MAP_HEIGHT" ) && !$this->isVarSet( "SET_MAP_WIDTH" )) return true; $oMap = $this->moMapObject->oMap; /* ==================================================================== */ /* only update the width,height id SET_MAP_HEIGHT && */ /* SET_MAP_WIDTH are defined. Other wise the width and height */ /* management would pass through the mapdhtml widget. (Note : There is*/ /* a duplication of code between this widget and the mapdhtml */ /* widget that should be removed at one point) */ /* ==================================================================== */ if ($this->isVarSet( "SET_MAP_HEIGHT" ) && $this->getVar( "SET_MAP_HEIGHT" ) != "" && $this->getVar( "SET_MAP_HEIGHT" ) > 0 && $this->isVarSet( "SET_MAP_WIDTH" ) && $this->getVar( "SET_MAP_WIDTH" ) != "" && $this->getVar( "SET_MAP_WIDTH" ) > 0) { $nHeight = intval($this->getVar( "SET_MAP_HEIGHT" )); $nWidth = intval($this->getVar( "SET_MAP_WIDTH" )); $this->moMapObject->oMap->set( "width", $nWidth ); $this->moMapObject->oMap->set( "height", $nHeight ); } return true; } /** * GetHTMLHiddenVariables * * return the map size variables. */ function GetHTMLHiddenVariables() { $aReturn = $this->moButton->GetHTMLHiddenVariables(); $szVariable = "SET_MAP_WIDTH"; $szValue = "\n"; $aReturn[$szVariable] = $szValue; $szVariable = "SET_MAP_HEIGHT"; $szValue = "\n"; $aReturn[$szVariable] = $szValue; return $aReturn; } function GetJavascriptVariables() { if ($this->mbVisible) return $this->moButton->GetJavascriptVariables(); else return array(); } function GetJavascriptInitFunctions() { if ($this->mbVisible) return $this->moButton->GetJavascriptInitFunctions(); else return array(); } function GetJavascriptOnLoadFunctions() { if ($this->mbVisible) $aReturn = $this->moButton->GetJavascriptOnLoadFunctions(); else $aReturn = array(); return $aReturn; } function GetJavascriptIncludeFunctions() { if ($this->mbVisible) $aReturn = $this->moButton->GetJavascriptIncludeFunctions(); else $aReturn = array(); return $aReturn; } /** * GetJavascriptFunctions * * Build and return the array of functions needed in the * widget. */ function GetJavascriptFunctions() { $aReturn = array(); $szBaseLink = $this->moPopup->mszLink."?"; if (isset( $this->maszContents["MAPSIZE"] )) { $szQueryString = "MAPSIZE="; $szSep = ""; foreach( $this->maszContents["MAPSIZE"] as $aMapSize ) { if (isset($aMapSize["LABEL"]) && isset($aMapSize["WIDTH"]) && isset($aMapSize["HEIGHT"])) { if (((int)$aMapSize["WIDTH"] > 0) && ((int)$aMapSize["HEIGHT"] > 0)) { $szQueryString .= $szSep.$aMapSize["LABEL"].",".$aMapSize["WIDTH"].",".$aMapSize["HEIGHT"]; $szSep = "|"; } } else { $_SESSION['gErrorManager']->setError(ERR_WARNING, trim($this->moMLT->get("0", "ERROR: Invalid MAPSIZE tag definition in MapSize Tag"))); } } $szBaseLink .= $szQueryString; } $this->moPopup->mszLink = $szBaseLink; $szJsFunctionName = "clickMapSizePopup"; $szButtonJS = $this->moPopup->DrawPublish(); $szFunction = <<mszHTMLForm}.SET_MAP_WIDTH.value=nWidth; {$this->mszHTMLForm}.SET_MAP_HEIGHT.value=nHeight; {$this->mszHTMLForm}.submit(); return; } EOT; $aReturn[$szJsFunctionName] = $szFunction; $szJsFunctionName = "cancelMapSize"; $szFunction = <<mszHTMLForm}.MAP_SIZE; aMapSize = getMapSize(); szMapSize = aMapSize[0] + "," + aMapSize[1]; for (i=0; imoMapObject->oMap->width; $nHeight = $this->moMapObject->oMap->height; $szJsFunctionName = "getMapSize"; $szFunction = <<mszHTMLForm}.SET_MAP_WIDTH.value = width; {$this->mszHTMLForm}.SET_MAP_HEIGHT.value = height; {$this->mszHTMLForm}.submit(); } } return; } EOT; $aReturn[$szJsFunctionName] = $szFunction; return $aReturn; } /** * Draw the widget */ function DrawPublish() { if (!$this->mbVisible) return ""; $nHeight = $this->moMapObject->oMap->height; $nWidth = $this->moMapObject->oMap->width; $szWidgetClass = ''; if ($this->mszWidgetClass != '') { $szWidgetClass = " class='".$this->mszWidgetClass."'"; } if ($this->mbEmbedded) { $szResult = "\n"; if (isset( $this->maszContents["MAPSIZE"] )) { $bCustom = true; foreach( $this->maszContents["MAPSIZE"] as $aMapSize ) { if (isset($aMapSize["LABEL"]) && isset($aMapSize["WIDTH"]) && isset($aMapSize["HEIGHT"])) { $szMapSize = $aMapSize["WIDTH"].",".$aMapSize["HEIGHT"]; $szResult .= "\n"; } } $szResult .= "\n"; $szResult = $this->moLabel->DrawPublish( $szResult ); //EKG } else { $szResult = $this->moButton->DrawPublish(); } return $szResult; } } ?>