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

root/Chameleon/trunk/Chameleon/ExtractWFSData/ExtractWFSData.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * ExtractWFSData Widget Class
4  *
5  * @project     Chameleon
6  * @revision    $Id: ExtractWFSData.widget.php,v 1.9 2004/10/14 18:19:13 pspencer Exp $
7  * @purpose     Widget to extract WFS data given an AOI.
8  * @author      DM Solutions Group (dev@dmsolutions.ca)
9  * @copyright
10  * <b>Copyright (c) 2003, 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
31 include_once(dirname(__FILE__)."/../Widget.php");
32 include_once(dirname(__FILE__)."/../Button.php");
33 include_once(dirname(__FILE__)."/../Popup.php");
34
35 /**
36  * ExtractWFSData
37  *
38  * @desc Display a widget that pops up a projection selection widget.
39  */
40 class ExtractWFSData extends CWCWidget
41 {
42     var $moButton;
43     var $moPopup;
44
45     /**
46      * ExtractWFSData
47      *
48      * Constuctor method for the ExtractWFSData
49      */
50     function ExtractWFSData()
51     {
52         parent::CWCWidget();
53
54         $this->moButton = new CWCButton( $this );
55         $this->moPopup = new CWCPopup( $this );
56         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath'].
57                                     "/widgets/ExtractWFSData/ExtractWFSData.phtml";
58
59         // set the description for this widget
60         $this->szWidgetDescription = <<<EOT
61 The Extract WFS Data widget allows the user to extract data based on the current
62 selected layer and ROI.  Currently the following formats are supported:
63 GML
64 Shape
65 EOT;
66         $this->mnMaturityLevel = MATURITY_BETA;
67
68     }
69
70     function InitDefaults()
71     {
72         parent::InitDefaults();
73         //this widget should never belong to a toolset
74         $this->maParams["TOOLSET"] = "";
75         $this->moButton->InitDefaults();
76         $this->moButton->SetOnClick('clickExtractWFSData');
77     }
78
79     /**
80      * SetMap
81      *
82      * Set the map session and create a navigation tool.
83      */
84     function SetMap($oMapSession)
85     {
86         $this->moMapObject = $oMapSession;
87     }
88
89
90     function GetJavascriptInitFunctions()
91     {
92         return $this->moButton->GetJavascriptInitFunctions();
93     }
94
95     function GetJavascriptVariables()
96     {
97         return $this->moButton->GetJavascriptVariables();
98     }
99
100     function GetJavascriptOnLoadFunctions()
101     {
102         return $this->moButton->GetJavascriptOnLoadFunctions();
103     }
104
105     function GetJavascriptIncludeFunctions()
106     {
107         return $this->moButton->GetJavascriptIncludeFunctions();
108     }
109
110     /**
111      * GetHTMLHiddenVariables
112      */
113     function GetHTMLHiddenVariables()
114     {
115         // initialize return array
116         $aReturn = $this->moButton->GetHTMLHiddenVariables();
117
118         // return array of hidden variables
119         return $aReturn;
120     }
121
122     /**
123      * ParseURL
124      *
125      */
126     function  ParseURL()
127     {
128         // return success
129         return true;
130     }
131
132     /**
133      * GetJavascriptFunctions
134      *
135      * Build and return the array of functions needed in the
136      * widget.
137      */
138     function GetJavascriptFunctions()
139     {
140         // Compression formats
141         if (isset($this->maszContents["COMPRESSIONFORMAT"]))
142             {
143               $aszCompressionFormat = array();
144               foreach ($this->maszContents["COMPRESSIONFORMAT"] as $aCompressionFormat)
145               {
146                 if (isset($aCompressionFormat["VALUE"]))
147               array_push($aszCompressionFormat, $aCompressionFormat["VALUE"]);
148               }
149           if (count($aszCompressionFormat) > 0)
150           {
151                 $this->moPopup->mszParam .= "&szCompressionFormat=".
152                           urlencode(implode("|", $aszCompressionFormat));
153               }
154             }
155         else // default value
156         {
157           $this->moPopup->mszParam .= "&szCompressionFormat=".urlencode("TGZ|ZIP");
158         }
159
160         // Output formats
161         if (isset($this->maszContents["OUTPUTFORMAT"]))
162             {
163               $aszOutputFormat = array();
164               foreach ($this->maszContents["OUTPUTFORMAT"] as $aOutputFormat)
165               {
166                 if (isset($aOutputFormat["VALUE"]))
167               array_push($aszOutputFormat, $aOutputFormat["VALUE"]);
168               }
169           if (count($aszOutputFormat) > 0)
170           {
171                 $this->moPopup->mszParam .= "&szOutputFormat=".
172                           urlencode(implode("|", $aszOutputFormat));
173               }
174             }
175         else // default value
176         {
177           $this->moPopup->mszParam .= "&szOutputFormat=".urlencode("Shape|GML");
178         }
179
180         if (isset($this->maSharedResourceWidgets["CWCJSAPI"]))
181           $bCWCJSAPI = 1;
182         else
183           $bCWCJSAPI = 0;
184
185         $aReturn = $this->moButton->GetJavascriptFunctions();//array();
186         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/ExtractWFSData/ExtractWFSData.phtml?".
187                                "&chkCompress=1".
188                                "&selectedlayers=' + szSelectedLayers + ' ";
189         $szJsFunctionName = "clickExtractWFSData";
190         $szButtonJS = $this->moPopup->DrawPublish();
191         $szFunction = <<<EOT
192 /**
193  * {$szJsFunctionName}
194  * popup a extract wfs data dialog
195  */
196 function {$szJsFunctionName}()
197 {
198     var szSelectedLayers = "";
199     // set the var
200     if ( {$this->mszHTMLForm}.SELECTED_LAYERS )
201     {
202         szSelectedLayers = {$this->mszHTMLForm}.SELECTED_LAYERS.value;
203     }
204     //alert( szSelectedLayers );
205     {$szButtonJS}
206     return;
207 }
208 EOT;
209         $aReturn[$szJsFunctionName] = $szFunction;
210
211         // return the array of functions
212         return $aReturn;
213     }
214
215     /**
216      * DrawPublish
217      *
218      * Return the HTML code using the name in the map file and the
219      * parameters of the CWC tag.
220      */
221     function DrawPublish()
222     {
223         if (!$this->mbVisible)
224             return "<!-- ExtractWFSData popup widget hidden -->";
225
226         $szResult = $this->moButton->DrawPublish();
227         return $szResult;
228     }
229 }
230 ?>
Note: See TracBrowser for help on using the browser.