NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/LegendTemplateLM/LegendTemplateLM.widget.php

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3 * LegendTemplateLM Widget class
4 *
5 * @project     CWC2
6 * @revision    $Id:
7 * @purpose     Legend Template Widget class  ESPECIALY CODED FOR LAYERMANAGER widget
8 * @author      DM Solutions Group (sfournier@dmsolutions.ca)
9 * @copyright
10 * <b>Copyright (c) 2002, DM Solutions Group Inc.</b>
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 */
29
30 include_once(dirname(__FILE__)."/../LegendTemplate/LegendTemplate.widget.php");
31
32 /**
33 * LegendTemplateLM
34 *
35 * @desc LegendTemplate widget class
36 */
37 class LegendTemplateLM extends LegendTemplate
38 {
39     var $moTmpMapObject;
40    
41     /**
42     * LegendTemplateLM
43     *
44     * Constctor method for the LegendPopup widget.
45     */
46     function LegendTemplateLM()
47     {
48         // invoke constructor of parent
49         parent::LegendTemplate();
50        
51         // set the description for this widget
52         $this->szWidgetDescription = <<<EOT
53 The Legend widget allows the user display a legend based on a legend template.
54 The Legend can either be embedded in the same page or displayed in a separate window.
55 This widget was coded especialy for LayerManager widget. It use a different MapObject.
56 EOT;
57         $this->mnMaturityLevel = MATURITY_BETA;
58     }
59    
60     function parseURL()
61     {
62         // create a new map session object
63         $oNewMapSession = new MapSession_RW;
64        
65         // set the temp directory for the map session
66         $oNewMapSession->setTempDir( $_SESSION['gszTmpPath'] );
67        
68         if (!$this->isVarSet("LAYERMANAGER_CURRENT_STATE"))
69         {
70             $oNewMapSession->restoreState( $_SESSION["gszCurrentState"],
71             $_SESSION['gszMapName'],
72             dirname($_SESSION['gszMapName'] ) );
73         }
74         else
75         {
76             $oNewMapSession->restoreState( $this->getVar("LAYERMANAGER_CURRENT_STATE"),
77             $_SESSION['gszMapName'],
78             dirname($_SESSION['gszMapName'] ) );
79            
80             // restore projection, extent and mapsize
81             $oNewMapSession->oMap->setProjection($this->moMapObject->oMap->getProjection(),
82             true);
83             $oNewMapSession->oMap->setextent($this->moMapObject->oMap->extent->minx,
84             $this->moMapObject->oMap->extent->miny,
85             $this->moMapObject->oMap->extent->maxx,
86             $this->moMapObject->oMap->extent->maxy);
87             $oNewMapSession->oMap->set("width", $this->moMapObject->oMap->width);
88             $oNewMapSession->oMap->set("height", $this->moMapObject->oMap->height);
89         }
90        
91         // Make sure the imageurl and imagepath are set to chameleon configuration
92         $oNewMapSession->oMap->web->set("imageurl", $_SESSION['gszTmpWebPath']);
93         $oNewMapSession->oMap->web->set("imagepath", $_SESSION['gszTmpImgPath']);
94         $oNewMapSession->oMap->selectOutputFormat($_SESSION['gszImgType']);
95        
96         $oTmpMapObj = $this->moMapObject;
97         $this->moMapObject = $oNewMapSession;
98         parent::parseURL();
99         $this->moMapObject = $oTmpMapObj;
100         $this->moTmpMapObject = $oNewMapSession;
101         return true;
102     }
103    
104     function GetJavascriptFunctions()
105     {
106         $oTmpMapObj = $this->moMapObject;
107         $this->moMapObject = $this->moTmpMapObject;
108         $aReturn = parent::GetJavascriptFunctions();
109         $this->moMapObject = $oTmpMapObj;
110        
111         $szLayer = $this->getVar('LAYERMANAGER_LAYER');
112         $szJsFunctionName = "SelectSelectedLayer";
113         if ($this->isVarSet('LAYERMANAGER_LAYER'))
114         {
115             $szFunction = <<<EOT
116 function {$szJsFunctionName}()
117 {
118   var i;
119   var bFind = false;
120
121   if({$this->mszHTMLForm}['LAYERMANAGER_LAYER'][0] == null)
122   {
123     {$this->mszHTMLForm}['LAYERMANAGER_LAYER'].checked = true;
124   }
125   else
126   {
127     for(var i=0;i<{$this->mszHTMLForm}['LAYERMANAGER_LAYER'].length;i++)
128     {
129       if ({$this->mszHTMLForm}['LAYERMANAGER_LAYER'][i].value == '{$szLayer}')
130       {
131         bFind = true;
132         {$this->mszHTMLForm}['LAYERMANAGER_LAYER'][i].checked = true;
133       }
134     }
135
136     // just in case.
137     if (!bFind)
138       {$this->mszHTMLForm}['LAYERMANAGER_LAYER'][0].checked = true;
139   }
140 }
141 EOT;
142 }
143 else
144 {
145     $szFunction = <<<EOT
146 function {$szJsFunctionName}()
147 {
148     {$this->mszHTMLForm}['LAYERMANAGER_LAYER'][0].checked = true;
149 }
150 EOT;
151 }
152
153 $aReturn[$szJsFunctionName] = $szFunction;
154
155 return $aReturn;
156     }
157    
158     function GetJavascriptOnLoadFunctions()
159     {
160         $aReturn = parent::GetJavascriptOnLoadFunctions();
161        
162         $aReturn['SelectSelectedLayer'] = "SelectSelectedLayer();";
163        
164         return $aReturn;
165     }
166    
167     function drawPublish()
168     {
169         $oTmpMapObj = $this->moMapObject;
170         $this->moMapObject = $this->moTmpMapObject;
171         $aReturn = parent::drawPublish();
172         $this->moMapObject = $oTmpMapObj;
173        
174         return $aReturn;
175     }
176 }
177 ?>
Note: See TracBrowser for help on using the browser.