1 |
<?php |
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
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 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
class UploadSLD extends CWCWidget |
---|
39 |
{ |
---|
40 |
var $mszTemplate; |
---|
41 |
|
---|
42 |
var $moButton; |
---|
43 |
var $moPopup; |
---|
44 |
|
---|
45 |
var $mszLink = 'widgets/UploadSLD.phtml'; |
---|
46 |
var $mszParam = '&szCallbackFunc=OpenSLDCB'; |
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
function UploadSLD() |
---|
54 |
{ |
---|
55 |
|
---|
56 |
parent::CWCWidget(); |
---|
57 |
|
---|
58 |
|
---|
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 |
|
---|
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 |
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
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 |
|
---|
196 |
|
---|
197 |
|
---|
198 |
|
---|
199 |
|
---|
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 |
|
---|