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

root/Chameleon/trunk/Chameleon/UploadSLD/UploadSLD.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * SLDUpload Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id: UploadSLD.widget.php,v 1.7 2005/01/20 04:31:24 zjames Exp $
7  * @purpose     SLDUpload Popup Widget class
8  * @author      DM Solutions Group (zjames@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 include_once(dirname(__FILE__)."/../Widget.php");
30 include_once(dirname(__FILE__)."/../Button.php");
31 include_once(dirname(__FILE__)."/../Popup.php");
32
33 /**
34  * SLDUpload
35  *
36  * @desc SLDUpload widget class
37  */
38 class UploadSLD extends CWCWidget
39 {
40     var $mszTemplate;      // [string]
41
42     var $moButton;         // Button object
43     var $moPopup;          // Popup object
44
45     var $mszLink = 'widgets/UploadSLD.phtml';
46     var $mszParam = '&szCallbackFunc=OpenSLDCB';
47
48     /**
49      * SLDUpload
50      *
51      * Constctor method for the SLDUpload widget.
52      */
53     function UploadSLD()
54     {
55         // invoke constructor of parent
56         parent::CWCWidget();
57
58         // set the description for this widget
59         $this->szWidgetDescription = <<<EOT
60 The SLDUpload widget allows the user to upload a SLD file from their
61 local hard drive or from a URL to the current application.
62 EOT;
63
64         $this->maAttributes['SINGLELAYER'] = new BooleanAttribute( 'SINGLELAYER', false );
65
66         $this->moButton = new CWCButton($this);
67
68         $this->moPopup = new CWCPopup($this);
69         $this->mnPriority = PRIORITY_MAXIMUM;
70         $this->mnMaturityLevel = MATURITY_BETA;
71     }
72
73
74     function InitDefaults()
75     {
76         parent::InitDefaults();
77         //this widget should never belong to a toolset
78         $this->maParams["TOOLSET"] = "";
79         $this->moButton->InitDefaults();
80         $this->moButton->SetOnClick('clickSLDUpload');
81         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath'].'/widgets/UploadSLD/UploadSLD.phtml';;
82         $this->moPopup->mszParam = $this->mszParam;
83         $this->moPopup->InitDefaults();
84         if (isset($this->maParams["singlelayer"]))
85             $this->mbSingleLayer =
86                 $this->maParams["singlelayer"];
87     }
88
89     function GetJavascriptVariables()
90     {
91         if ($this->mbVisible)
92             return $this->moButton->GetJavascriptVariables();
93         else return array();
94     }
95
96     function GetJavascriptInitFunctions()
97     {
98         if ($this->mbVisible)
99             return $this->moButton->GetJavascriptInitFunctions();
100         else return array();
101     }
102
103     function GetJavascriptOnLoadFunctions()
104     {
105         if ($this->mbVisible)
106             $aReturn = $this->moButton->GetJavascriptOnLoadFunctions();
107         else
108             $aReturn = array();
109         return $aReturn;
110     }
111
112     function GetJavascriptIncludeFunctions()
113     {
114         if ($this->mbVisible)
115             $aReturn = $this->moButton->GetJavascriptIncludeFunctions();
116         else
117             $aReturn = array();
118         return $aReturn;
119     }
120
121
122     /**
123      * GetJavascriptFunctions
124      *
125      * Build and return the array of functions needed in the
126      * widget.
127      */
128     function GetJavascriptFunctions()
129     {
130         $aReturn = array();
131
132         if (isset($this->maAttributes['singlelayer']) &&
133             $this->isVarSet( 'nlayerindex' ))
134         {
135             $this->moPopup->mszParam .= "&szlayerindex=".
136                   $this->getVar( 'nlayerindex' );
137         }
138
139         $szJsFunctionName = "clickSLDUpload";
140         $szFunction = "function $szJsFunctionName()\n" .
141                       "{\n".
142                        $this->moPopup->DrawPublish()."\n".
143                       "return;\n" .
144                       "}\n";
145         $aReturn[$szJsFunctionName] = $szFunction;
146
147         $szJsFunctionName = "OpenSLDCB";
148         $szFunction = <<<EOF
149
150 function {$szJsFunctionName}(actionID, wh)
151 {
152     if (actionID == 0 || actionID == 1) // ok
153     {
154         // The SLD has been loaded into the map session, simply reload
155         // the page.  First we'll need to clear some previous state, though.
156             if ({$this->mszHTMLForm}.MAP_EXTENTS_MINX !=null && {$this->mszHTMLForm}.MAP_EXTENTS_MINX.value != null)
157                 {$this->mszHTMLForm}.MAP_EXTENTS_MINX.value = "";
158             if ({$this->mszHTMLForm}.MAP_EXTENTS_MINY !=null && {$this->mszHTMLForm}.MAP_EXTENTS_MINY.value != null)
159                {$this->mszHTMLForm}.MAP_EXTENTS_MINY.value = "";
160             if ({$this->mszHTMLForm}.MAP_EXTENTS_MAXX !=null && {$this->mszHTMLForm}.MAP_EXTENTS_MAXX.value != null)
161                 {$this->mszHTMLForm}.MAP_EXTENTS_MAXX.value = "";
162             if ({$this->mszHTMLForm}.MAP_EXTENTS_MAXY !=null && {$this->mszHTMLForm}.MAP_EXTENTS_MAXY.value != null)
163                 {$this->mszHTMLForm}.MAP_EXTENTS_MAXY.value = "";
164             if ({$this->mszHTMLForm}.MAP_WIDTH !=null && {$this->mszHTMLForm}.MAP_WIDTH.value != null)
165                 {$this->mszHTMLForm}.MAP_WIDTH.value = "";
166             if ({$this->mszHTMLForm}.MAP_HEIGHT !=null && {$this->mszHTMLForm}.MAP_HEIGHT.value != null)
167                 {$this->mszHTMLForm}.MAP_HEIGHT.value = "";       
168             if ({$this->mszHTMLForm}.LEGENDTEMPLATE_RESET !=null && {$this->mszHTMLForm}.LEGENDTEMPLATE_RESET.value != null)
169                 {$this->mszHTMLForm}.LEGENDTEMPLATE_RESET.value = "1";     
170         wh.close();
171         {$this->mszHTMLForm}.submit();
172     }
173     else if (actionID == 2) // cancel
174     {
175         wh.close();
176     }
177
178     return;
179 }
180
181 EOF;
182         $aReturn[$szJsFunctionName] = $szFunction;
183
184         return $aReturn;
185     }
186
187     function GetHTMLHiddenVariables()
188     {
189         $aReturn = $this->moButton->GetHTMLHiddenVariables();
190         
191         return $aReturn;
192     }
193
194     /**
195      * DrawPublish
196      *
197      * Return the HTML code to display the link to the legend popup
198      *
199      * @return HTML Code
200      */
201     function DrawPublish()
202     {
203         if (!$this->mbVisible)
204             return '<!-- Upload SLD widget hidden -->';
205
206         $szReturn = $this->moButton->DrawPublish();
207
208         return $szReturn;
209     }
210 }
211 ?>
212
Note: See TracBrowser for help on using the browser.