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 |
|
---|
30 |
include_once(dirname(__FILE__)."/../Widget.php"); |
---|
31 |
include_once(dirname(__FILE__)."/../Button.php"); |
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
class ClearWFSFilter extends CWCWidget |
---|
39 |
{ |
---|
40 |
var $moButton; |
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
function ClearWFSFilter() |
---|
48 |
{ |
---|
49 |
|
---|
50 |
$this->mszLanguageResource = dirname(__FILE__)."/ClearWFSFilter.dbf"; |
---|
51 |
|
---|
52 |
parent::CWCWidget(); |
---|
53 |
|
---|
54 |
$this->moButton = new CWCButton( $this ); |
---|
55 |
|
---|
56 |
|
---|
57 |
$this->szWidgetDescription = <<<EOT |
---|
58 |
The ClearWFSFilter widget clears the WFS filter from the active layer and deletes |
---|
59 |
the temporary annotation layer. |
---|
60 |
EOT; |
---|
61 |
$this->mnMaturityLevel = MATURITY_BETA; |
---|
62 |
|
---|
63 |
} |
---|
64 |
|
---|
65 |
function InitDefaults() |
---|
66 |
{ |
---|
67 |
parent::InitDefaults(); |
---|
68 |
|
---|
69 |
$this->maParams["TOOLSET"] = ""; |
---|
70 |
$this->moButton->InitDefaults(); |
---|
71 |
$this->moButton->SetOnClick('clickClearWFSFilter'); |
---|
72 |
} |
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 |
function SetMap($oMapSession) |
---|
80 |
{ |
---|
81 |
$this->moMapObject = $oMapSession; |
---|
82 |
} |
---|
83 |
|
---|
84 |
|
---|
85 |
function GetJavascriptInitFunctions() |
---|
86 |
{ |
---|
87 |
return $this->moButton->GetJavascriptInitFunctions(); |
---|
88 |
} |
---|
89 |
|
---|
90 |
function GetJavascriptVariables() |
---|
91 |
{ |
---|
92 |
return $this->moButton->GetJavascriptVariables(); |
---|
93 |
} |
---|
94 |
|
---|
95 |
function GetJavascriptOnLoadFunctions() |
---|
96 |
{ |
---|
97 |
return $this->moButton->GetJavascriptOnLoadFunctions(); |
---|
98 |
} |
---|
99 |
|
---|
100 |
function GetJavascriptIncludeFunctions() |
---|
101 |
{ |
---|
102 |
return $this->moButton->GetJavascriptIncludeFunctions(); |
---|
103 |
} |
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|
107 |
|
---|
108 |
function GetHTMLHiddenVariables() |
---|
109 |
{ |
---|
110 |
|
---|
111 |
$aReturn = $this->moButton->GetHTMLHiddenVariables(); |
---|
112 |
|
---|
113 |
|
---|
114 |
$szFilterSet = ( isset( $_SESSION['expr_build_filter_set'] ) && |
---|
115 |
$_SESSION['expr_build_filter_set'] == '1' ) ? '1' : '0'; |
---|
116 |
|
---|
117 |
|
---|
118 |
$szVariable = "WFS_CLEAR_FILTER"; |
---|
119 |
$szValue = " <INPUT TYPE=hidden NAME=$szVariable VALUE=\"\">\n"; |
---|
120 |
$aReturn[$szVariable] = $szValue; |
---|
121 |
$szVariable = "WFS_CLEAR_FILTER_ISSET"; |
---|
122 |
$szValue = ' <INPUT TYPE=hidden NAME='.$szVariable.' VALUE="'.$szFilterSet."\">\n"; |
---|
123 |
$aReturn[$szVariable] = $szValue; |
---|
124 |
|
---|
125 |
|
---|
126 |
return $aReturn; |
---|
127 |
} |
---|
128 |
|
---|
129 |
|
---|
130 |
|
---|
131 |
|
---|
132 |
|
---|
133 |
function ParseURL() |
---|
134 |
{ |
---|
135 |
$this->moButton->ParseURL(); |
---|
136 |
|
---|
137 |
|
---|
138 |
if ( $this->isVarSet("WFS_CLEAR_FILTER") && |
---|
139 |
$this->getVar("WFS_CLEAR_FILTER") == 1 ) |
---|
140 |
{ |
---|
141 |
|
---|
142 |
$nCount = $this->moMapObject->oMap->numlayers; |
---|
143 |
for ( $i=0; $i<$nCount; $i++ ) |
---|
144 |
{ |
---|
145 |
|
---|
146 |
$oLayer = $this->moMapObject->oMap->getlayer( $i ); |
---|
147 |
|
---|
148 |
|
---|
149 |
if ( $oLayer->getmetadata("selected") == 1 && |
---|
150 |
strlen( trim( $oLayer->getmetadata("wfs_filter" ) ) ) > 0 ) |
---|
151 |
$oLayer->removeMetaData( "wfs_filter" ); |
---|
152 |
|
---|
153 |
|
---|
154 |
if ( $oLayer->name == 'ExpressionBuilderAnnotation' ) |
---|
155 |
{ |
---|
156 |
$oLayer->set( 'status', MS_DELETE ); |
---|
157 |
} |
---|
158 |
|
---|
159 |
|
---|
160 |
$_SESSION['expr_build_filter_set'] = '0'; |
---|
161 |
|
---|
162 |
if( isset($_SESSION['expr_build_origin_layer']) && |
---|
163 |
$oLayer->name == $_SESSION['expr_build_origin_layer'] ) |
---|
164 |
{ |
---|
165 |
$oTmpLayer = $this->moMapObject->oMap->getLayerByName( |
---|
166 |
'ExpressionBuilderAnnotation' ); |
---|
167 |
if( $oTmpLayer && |
---|
168 |
$oTmpLayer->getmetadata('selected') == 1 ) |
---|
169 |
{ |
---|
170 |
$oLayer->setmetadata( 'selected', 1 ); |
---|
171 |
$oTmpLayer->setmetadata( 'selected', 0 ); |
---|
172 |
} |
---|
173 |
} |
---|
174 |
} |
---|
175 |
} |
---|
176 |
|
---|
177 |
|
---|
178 |
return true; |
---|
179 |
} |
---|
180 |
|
---|
181 |
|
---|
182 |
|
---|
183 |
|
---|
184 |
|
---|
185 |
|
---|
186 |
|
---|
187 |
function GetJavascriptFunctions() |
---|
188 |
{ |
---|
189 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
190 |
$bCWCJSAPI = 1; |
---|
191 |
else |
---|
192 |
$bCWCJSAPI = 0; |
---|
193 |
|
---|
194 |
$aReturn = $this->moButton->GetJavascriptFunctions(); |
---|
195 |
|
---|
196 |
|
---|
197 |
$szJsFunctionName = "clickClearWFSFilter"; |
---|
198 |
$szNoFilterMessage = $this->moMLT->get( "1", "There is no filter to clear." ); |
---|
199 |
$szWarningMessage = $this->moMLT->get( "0", "You are about to clear the WFS ". |
---|
200 |
"filter. Do you wish to continue?" ); |
---|
201 |
$szFunction = <<<EOT |
---|
202 |
/** |
---|
203 |
* {$szJsFunctionName} |
---|
204 |
* Clear the WFS filter |
---|
205 |
*/ |
---|
206 |
function {$szJsFunctionName}() |
---|
207 |
{ |
---|
208 |
// give message if there is nothing to delete |
---|
209 |
if ( {$this->mszHTMLForm}.WFS_CLEAR_FILTER_ISSET.value == 1 ) |
---|
210 |
{ |
---|
211 |
|
---|
212 |
// warn the user that they are about to clear the filter |
---|
213 |
if ( confirm( "{$szWarningMessage}" ) ) |
---|
214 |
{ |
---|
215 |
// set the hidden form vars |
---|
216 |
{$this->mszHTMLForm}.WFS_CLEAR_FILTER.value = 1; |
---|
217 |
|
---|
218 |
// submit the form |
---|
219 |
{$this->mszHTMLForm}.submit(); |
---|
220 |
} |
---|
221 |
} |
---|
222 |
else |
---|
223 |
{ |
---|
224 |
alert('{$szNoFilterMessage}'); |
---|
225 |
} |
---|
226 |
|
---|
227 |
// return |
---|
228 |
return; |
---|
229 |
} |
---|
230 |
EOT; |
---|
231 |
|
---|
232 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
233 |
|
---|
234 |
|
---|
235 |
return $aReturn; |
---|
236 |
} |
---|
237 |
|
---|
238 |
|
---|
239 |
|
---|
240 |
|
---|
241 |
|
---|
242 |
|
---|
243 |
|
---|
244 |
function DrawPublish() |
---|
245 |
{ |
---|
246 |
if (!$this->mbVisible) |
---|
247 |
return "<!-- clickClearWFSFilter widget hidden -->"; |
---|
248 |
|
---|
249 |
$szResult = $this->moButton->DrawPublish(); |
---|
250 |
return $szResult; |
---|
251 |
} |
---|
252 |
} |
---|
253 |
|
---|
254 |
|
---|
255 |
?> |
---|
256 |
|
---|