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

root/Chameleon/trunk/Chameleon/DownloadSLD/DownloadSLD.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * SLDDownload Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id: DownloadSLD.widget.php,v 1.8 2005/01/20 04:32:02 zjames Exp $
7  * @purpose     SLDDownload Popup Widget class
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 include_once(dirname(__FILE__)."/../Widget.php");
30 include_once(dirname(__FILE__)."/../Button.php");
31 include_once(dirname(__FILE__)."/../Popup.php");
32 include_once(dirname(__FILE__)."/../Label.php");
33
34 /**
35  * SLDDownload
36  *
37  * @desc SLDDownload widget class
38  */
39 class DownloadSLD extends CWCWidget
40 {
41     var $mszTemplate;      // [string]
42
43     var $moButton;         // Button object
44     var $moPopup;          // Popup object
45
46     var $mbSingleLayer = "false"; //whether to export a selected layer or
47                                   //or entire map.
48     /**
49      * SLDDownload
50      *
51      * Constctor method for the SLDDownload widget.
52      */
53     function DownloadSLD()
54     {
55         // invoke constructor of parent
56         parent::CWCWidget();
57
58         // set the description for this widget
59         $this->szWidgetDescription = <<<EOT
60 The SLDDownloadWidget allows the user to download the current layers or layer of
61 the map as an SLD document.
62 EOT;
63         $this->maAttributes['SINGLELAYER'] = new BooleanAttribute( 'SINGLELAYER', false );
64
65         $this->moLabel = new CWCLabel($this);
66
67         $this->moButton = new CWCButton($this);
68         $this->moPopup = new CWCPopup($this);
69         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/DownloadSLD/DownloadSLD.phtml";
70         $this->mnMaturityLevel = MATURITY_BETA;
71     }
72
73     function InitDefaults()
74     {
75         parent::InitDefaults();
76         //this widget should never belong to a toolset
77         $this->maParams["TOOLSET"] = "";
78         $this->moButton->InitDefaults();
79         $this->moButton->SetOnClick("clickSLDDownload");
80         if (isset($this->maParams["singlelayer"]))
81             $this->mbSingleLayer =
82                 $this->maParams["singlelayer"];
83         $this->moPopup->InitDefaults();
84     }
85
86     function GetJavascriptVariables()
87     {
88         if ($this->mbVisible)
89             return $this->moButton->GetJavascriptVariables();
90         else return array();
91     }
92
93     function GetJavascriptInitFunctions()
94     {
95         if ($this->mbVisible)
96             return $this->moButton->GetJavascriptInitFunctions();
97         else return array();
98     }
99
100     function GetJavascriptOnLoadFunctions()
101     {
102         if ($this->mbVisible)
103             $aReturn = $this->moButton->GetJavascriptOnLoadFunctions();
104         else
105             $aReturn = array();
106         return $aReturn;
107     }
108
109     function GetJavascriptIncludeFunctions()
110     {
111         if ($this->mbVisible)
112             $aReturn = $this->moButton->GetJavascriptIncludeFunctions();
113         else
114             $aReturn = array();
115         return $aReturn;
116     }
117     /**
118      * GetJavascriptFunctions
119      *
120      * Build and return the array of functions needed in the
121      * widget.
122      */
123     function GetJavascriptFunctions()
124     {
125         if (isset($this->maAttributes['singlelayer']) &&
126             $this->isVarSet('nlayerindex'))
127         {
128             $this->moPopup->mszParam .= "&szlayerindex=".
129                   $this->getVar('nlayerindex');
130         }
131
132         $aReturn = array();
133
134         $szJsFunctionName = "clickSLDDownload";
135         $szFunction = "function $szJsFunctionName()\n" .
136          "{\n".
137           $this->moPopup->DrawPublish()."\n".
138         "return;\n" .
139         "}\n";
140         $aReturn[$szJsFunctionName] = $szFunction;
141
142         return $aReturn;
143     }
144    
145     function GetHTMLHiddenVariables()
146     {
147         $aReturn = $this->moButton->GetHTMLHiddenVariables();
148        
149         return $aReturn;
150     }
151
152     /**
153      * DrawPublish
154      *
155      * Return the HTML code to display the link to the legend popup
156      */
157     function DrawPublish()
158     {
159        
160         $szReturn = $this->moButton->DrawPublish(  );
161
162         return $szReturn;
163     }
164 }
165
166 if ((function_exists( "RegisterWidget" )))
167     RegisterWidget( "DownloadSLD", "DownloadSLD" );
168 ?>
Note: See TracBrowser for help on using the browser.