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 |
$szLanguageResource = str_replace("\\","/",dirname(__FILE__))."/ExpressionBuilder.dbf"; |
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 |
if ( !defined("LOAD_MAPSESSION") ) |
---|
34 |
define("LOAD_MAPSESSION", 1); |
---|
35 |
|
---|
36 |
|
---|
37 |
include_once(dirname(__FILE__)."/../session.inc.php"); |
---|
38 |
include_once(dirname(__FILE__)."/../CWC2ButtonCache.php"); |
---|
39 |
|
---|
40 |
|
---|
41 |
include( dirname(__FILE__)."/../LayerAttributes.php" ); |
---|
42 |
|
---|
43 |
|
---|
44 |
$_FORM = array_merge( $_GET, $_POST ); |
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 |
define( "LIKE_WILDCARD", urldecode( $_FORM["wildcard"] ) ); |
---|
50 |
define( "LIKE_SINGLECHAR", urldecode( $_FORM["singlechar"] ) ); |
---|
51 |
define( "LIKE_ESCAPECHAR", urldecode( $_FORM["escape"] ) ); |
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
$nCount = 0; |
---|
58 |
$nSelectedLayer = ""; |
---|
59 |
$szSelectedLayerName = ""; |
---|
60 |
$szSelectedLayerConnType = ""; |
---|
61 |
$aszAttributes = array(); |
---|
62 |
$szErrorNotice = ""; |
---|
63 |
$szWFSConnection = ""; |
---|
64 |
$nLayerCount = $oMapSession->oMap->numlayers; |
---|
65 |
$szWFSTypeName = ''; |
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 |
|
---|
71 |
$aszLayers = array(); |
---|
72 |
if ( isset( $_FORM["selectedlayers"] ) && |
---|
73 |
strlen( trim( $_FORM["selectedlayers"] ) ) > 0 ) |
---|
74 |
{ |
---|
75 |
|
---|
76 |
$aszLayers = explode( ',', $_FORM["selectedlayers"] ); |
---|
77 |
$nTmpCount = count( $aszLayers ); |
---|
78 |
for( $i=0; $i<$nTmpCount; $i++ ) |
---|
79 |
$aszLayers[$i] = trim( $aszLayers[$i] ); |
---|
80 |
|
---|
81 |
} |
---|
82 |
|
---|
83 |
|
---|
84 |
if ( count( $aszLayers ) > 0 ) |
---|
85 |
{ |
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 |
for( $i=0; $i<count($aszLayers); $i++ ) |
---|
91 |
{ |
---|
92 |
for ($j=0; $j<$nLayerCount; $j++) |
---|
93 |
{ |
---|
94 |
$oLayer = $oMapSession->oMap->getLayer($j); |
---|
95 |
if ($oLayer->connectiontype == MS_WMS) |
---|
96 |
{ |
---|
97 |
if ($aszLayers[$i] == $oLayer->getMetadata( "WMS_TITLE" )) |
---|
98 |
{ |
---|
99 |
$aszLayers[$i] = $oLayer->getMetadata( "WMS_NAME" ); |
---|
100 |
} |
---|
101 |
} |
---|
102 |
} |
---|
103 |
} |
---|
104 |
} |
---|
105 |
else |
---|
106 |
{ |
---|
107 |
|
---|
108 |
for ( $i=0; $i<$nLayerCount; $i++ ) |
---|
109 |
{ |
---|
110 |
|
---|
111 |
$oLayer = $oMapSession->oMap->getLayer( $i ); |
---|
112 |
|
---|
113 |
|
---|
114 |
if ( $oLayer->getmetadata("selected") == 1 ) |
---|
115 |
{ |
---|
116 |
|
---|
117 |
array_push( $aszLayers, $oLayer->name ); |
---|
118 |
} |
---|
119 |
} |
---|
120 |
} |
---|
121 |
|
---|
122 |
|
---|
123 |
if ( $aszLayers[0] == '' ) |
---|
124 |
array_shift( $aszLayers ); |
---|
125 |
|
---|
126 |
|
---|
127 |
$nCount = count( $aszLayers ); |
---|
128 |
|
---|
129 |
|
---|
130 |
for ( $i=0; $i<$nCount; $i++ ) |
---|
131 |
{ |
---|
132 |
|
---|
133 |
$oLayer = $oMapSession->oMap->getLayerbyName( $aszLayers[$i] ); |
---|
134 |
if ($oLayer == null) |
---|
135 |
{ |
---|
136 |
|
---|
137 |
for ($j=0; $j<$oMapSession->oMap->numlayers; $j++) |
---|
138 |
{ |
---|
139 |
$oLayer = $oMapSession->oMap->getLayer( $j ); |
---|
140 |
if ($oLayer->getMetaData( "WMS_NAME" ) == $aszLayers[$i] || |
---|
141 |
$oLayer->getMetaData( "WMS_TITLE" ) == $aszLayers[$i] ) |
---|
142 |
{ |
---|
143 |
break; |
---|
144 |
} |
---|
145 |
} |
---|
146 |
} |
---|
147 |
|
---|
148 |
if ( $oLayer->connectiontype == MS_WFS || |
---|
149 |
$oLayer->connectiontype == MS_WMS ) |
---|
150 |
{ |
---|
151 |
|
---|
152 |
$nSelectedLayer = $oLayer->index; |
---|
153 |
|
---|
154 |
|
---|
155 |
$szSelectedLayerName = $oLayer->name; |
---|
156 |
|
---|
157 |
|
---|
158 |
$szSelectedLayerConnType = $oLayer->connectiontype; |
---|
159 |
|
---|
160 |
|
---|
161 |
switch( $oLayer->connectiontype ) |
---|
162 |
{ |
---|
163 |
case MS_WFS: |
---|
164 |
|
---|
165 |
$szWFSConnection = $oLayer->connection; |
---|
166 |
break; |
---|
167 |
case MS_WMS: |
---|
168 |
|
---|
169 |
$szSelectedLayerName = $oLayer->getMetadata( "WMS_NAME" ); |
---|
170 |
|
---|
171 |
$aszWFSInfo = getWFSConnection( $oLayer->connection, |
---|
172 |
$szSelectedLayerName ); |
---|
173 |
|
---|
174 |
|
---|
175 |
if ($aszWFSInfo != false) |
---|
176 |
{ |
---|
177 |
$szWFSConnection = $aszWFSInfo['wfs']; |
---|
178 |
|
---|
179 |
|
---|
180 |
foreach( $aszWFSInfo['typename'] as $szTypeName ) |
---|
181 |
{ |
---|
182 |
$szWFSTypeName .= $szTypeName.','; |
---|
183 |
} |
---|
184 |
|
---|
185 |
|
---|
186 |
if ( substr( $szWFSTypeName, -1, 1 ) == ',' ) |
---|
187 |
{ |
---|
188 |
$szWFSTypeName = substr( $szWFSTypeName, 0, -1 ); |
---|
189 |
} |
---|
190 |
|
---|
191 |
|
---|
192 |
if ( $szWFSConnection === false ) |
---|
193 |
{ |
---|
194 |
|
---|
195 |
$szErrorNotice = $oMLT->get("30", 'An invalid WMS layer was '. |
---|
196 |
'selected. A WMS layer must have a WFS associated with '. |
---|
197 |
'it in order to be filtered.' ); |
---|
198 |
|
---|
199 |
|
---|
200 |
$szWFSConnection = ''; |
---|
201 |
$nSelectedLayer = ''; |
---|
202 |
$szSelectedLayerName = ''; |
---|
203 |
} |
---|
204 |
} |
---|
205 |
else |
---|
206 |
{ |
---|
207 |
|
---|
208 |
$szErrorNotice = $oMLT->get("30", 'An invalid WMS layer was '. |
---|
209 |
'selected. A WMS layer must have a WFS associated with '. |
---|
210 |
'it in order to be filtered.' ); |
---|
211 |
|
---|
212 |
|
---|
213 |
|
---|
214 |
$szWFSConnection = ''; |
---|
215 |
$nSelectedLayer = ''; |
---|
216 |
$szSelectedLayerName = ''; |
---|
217 |
} |
---|
218 |
break; |
---|
219 |
} |
---|
220 |
|
---|
221 |
|
---|
222 |
if ( isset( $_FORM['txtSaveExpressions'] ) && |
---|
223 |
$_FORM['txtSaveExpressions'] == 1 ) |
---|
224 |
{ |
---|
225 |
|
---|
226 |
$oLayer = $oMapSession->oMap->getLayer( $nSelectedLayer ); |
---|
227 |
$oLayer->setMetadata( 'cham_x_build_expressions', |
---|
228 |
$_FORM['txtExpressions'] ); |
---|
229 |
} |
---|
230 |
|
---|
231 |
|
---|
232 |
$_FORM['txtExpressions'] = |
---|
233 |
$oLayer->getMetadata( 'cham_x_build_expressions' ); |
---|
234 |
|
---|
235 |
|
---|
236 |
break; |
---|
237 |
} |
---|
238 |
|
---|
239 |
|
---|
240 |
} |
---|
241 |
|
---|
242 |
|
---|
243 |
|
---|
244 |
|
---|
245 |
if ( isset( $_FORM['txtExpressions'] ) && strlen( $_FORM['txtExpressions'] ) > 0 ) |
---|
246 |
{ |
---|
247 |
$szJavascriptExpressions = |
---|
248 |
buildJavascriptExpressions( $_FORM['txtExpressions'] ); |
---|
249 |
} |
---|
250 |
|
---|
251 |
|
---|
252 |
|
---|
253 |
|
---|
254 |
if ( strlen( trim( $szWFSConnection ) ) > 0 ) |
---|
255 |
{ |
---|
256 |
|
---|
257 |
|
---|
258 |
$szWFSConnection = fixWFSURL( $szWFSConnection, $szWFSTypeName ); |
---|
259 |
|
---|
260 |
|
---|
261 |
$aszAttributes = getAttributeTypes( $szWFSConnection. |
---|
262 |
'request=describefeaturetype', $szSelectedLayerName ); |
---|
263 |
|
---|
264 |
|
---|
265 |
$szAttributeOptions = ''; |
---|
266 |
$szLayerType = ''; |
---|
267 |
foreach( $aszAttributes as $key=>$value ) |
---|
268 |
{ |
---|
269 |
|
---|
270 |
if ( $key == 'LayerType' ) |
---|
271 |
{ |
---|
272 |
$szLayerType = $value; |
---|
273 |
continue; |
---|
274 |
} |
---|
275 |
|
---|
276 |
|
---|
277 |
$szTmpAttribute = $key." (".$value.")"; |
---|
278 |
|
---|
279 |
|
---|
280 |
$szAttributeOptions .= "<option value=\"".$key."\">". |
---|
281 |
$szTmpAttribute."</option>\n"; |
---|
282 |
} |
---|
283 |
} |
---|
284 |
else |
---|
285 |
{ |
---|
286 |
|
---|
287 |
$szErrorNotice = $oMLT->get("20", "Invalid layer or none selected. ". |
---|
288 |
"Please ensure that the selected layer is a WFS or WMS layer." ); |
---|
289 |
} |
---|
290 |
|
---|
291 |
|
---|
292 |
|
---|
293 |
|
---|
294 |
if ( isset($_FORM['styles'] ) && strlen( $_FORM['styles'] ) > 0 ) |
---|
295 |
{ |
---|
296 |
|
---|
297 |
$szTmpTitle = $oMLT->get("28", "Select SLD"); |
---|
298 |
|
---|
299 |
|
---|
300 |
$aszStyles = explode( '|', $_FORM['styles'] ); |
---|
301 |
$nSLDCount = count( $aszStyles ); |
---|
302 |
$szStyleOptions = ''; |
---|
303 |
for ( $i=0; $i<$nSLDCount; $i++ ) |
---|
304 |
{ |
---|
305 |
|
---|
306 |
|
---|
307 |
|
---|
308 |
|
---|
309 |
|
---|
310 |
$aszSplit = explode( '@', $aszStyles[$i] ); |
---|
311 |
if (!isset($szLayerType) || strcasecmp($szLayerType, 'MS_LAYER_'.$aszSplit[3] ) == 0) |
---|
312 |
{ |
---|
313 |
$szStyleOptions .= '<option value="'.$aszStyles[$i].'">'.$aszSplit[0]. |
---|
314 |
'</option>'; |
---|
315 |
} |
---|
316 |
} |
---|
317 |
|
---|
318 |
|
---|
319 |
$szStyleForm = <<<EOT |
---|
320 |
<tr> |
---|
321 |
<td colspan="2" class="layoutTable"> |
---|
322 |
<table class="titleArea" width="100%" border="0" cellpadding="4" cellspacing="0"> |
---|
323 |
<tr> |
---|
324 |
<td><span class="title">{$szTmpTitle}</span></td> |
---|
325 |
</tr> |
---|
326 |
</table> |
---|
327 |
<table class="contentArea" width="100%" border="0" cellpadding="4" cellspacing="0"> |
---|
328 |
<tr> |
---|
329 |
<td><select name="selSLD" class="inputList"> |
---|
330 |
{$szStyleOptions} |
---|
331 |
</select></td> |
---|
332 |
</tr> |
---|
333 |
</table> |
---|
334 |
</td> |
---|
335 |
</tr> |
---|
336 |
EOT; |
---|
337 |
|
---|
338 |
|
---|
339 |
|
---|
340 |
|
---|
341 |
if ( !isset( $szLayerType ) || strlen( $szLayerType ) <= 0 ) |
---|
342 |
{ |
---|
343 |
$szLayerTypeHTML = '<td valign="middle" rowspan="2"><p class="helpArea">'. |
---|
344 |
$oMLT->get('33', 'Unable to determine layer data type. Please specify the underlying data type for this layer.'). |
---|
345 |
'</p></td>'. |
---|
346 |
'</tr>'. |
---|
347 |
'<tr>'. |
---|
348 |
'<td valign="top"><span class="label">'. |
---|
349 |
$oMLT->get("31", "Type"). |
---|
350 |
': </span><select name="selLayerType" class="inputList">'. |
---|
351 |
'<option value="MS_LAYER_POINT">Point</option>'. |
---|
352 |
'<option value="MS_LAYER_LINE">Line</option>'. |
---|
353 |
'<option value="MS_LAYER_POLYGON">Polygon</option></select></td>'; |
---|
354 |
} |
---|
355 |
else |
---|
356 |
{ |
---|
357 |
if ( !isset( $szLayerType ) ) $szLayerType = ''; |
---|
358 |
$szLayerTypeHTML = '<input type="hidden" name="selLayerType" value="'. |
---|
359 |
$szLayerType.'">'; |
---|
360 |
} |
---|
361 |
} |
---|
362 |
|
---|
363 |
function buildJavascriptExpressions( $szExpressionsString ) |
---|
364 |
{ |
---|
365 |
|
---|
366 |
|
---|
367 |
$aszExpressions = explode( '|@|', $szExpressionsString ); |
---|
368 |
|
---|
369 |
|
---|
370 |
$szJavascriptExpressions = ""; |
---|
371 |
|
---|
372 |
|
---|
373 |
foreach( $aszExpressions as $szExpression ) |
---|
374 |
{ |
---|
375 |
|
---|
376 |
if ( strlen( trim( $szExpression ) ) <= 0 ) |
---|
377 |
continue; |
---|
378 |
|
---|
379 |
|
---|
380 |
$aszExpComponents = explode( '|', $szExpression ); |
---|
381 |
|
---|
382 |
|
---|
383 |
$szJavascriptExpressions .= 'addExpression( "'. |
---|
384 |
$aszExpComponents[0].'", "'. |
---|
385 |
$aszExpComponents[1].'", "'. |
---|
386 |
$aszExpComponents[2].'", "'. |
---|
387 |
$aszExpComponents[4].'", "'. |
---|
388 |
$aszExpComponents[5].'", "'. |
---|
389 |
$aszExpComponents[2].'", "'. |
---|
390 |
$aszExpComponents[3].'", "'. |
---|
391 |
$aszExpComponents[4].'", "'. |
---|
392 |
$aszExpComponents[5].'" );'; |
---|
393 |
} |
---|
394 |
|
---|
395 |
|
---|
396 |
return $szJavascriptExpressions; |
---|
397 |
} |
---|
398 |
|
---|
399 |
?> |
---|
400 |
|
---|