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(CHAMELEON_PATH."/widgets/NavTool.php"); |
---|
31 |
include_once(COMMON."wrapper/map_query.php" ); |
---|
32 |
include_once(CHAMELEON_PATH."/widgets/Popup.php"); |
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
class LinkQuery extends NavTool |
---|
38 |
{ |
---|
39 |
var $moPopup; |
---|
40 |
var $mszImagePath = "images/tool_query_off.gif"; |
---|
41 |
var $mszSelectedImagePath = "images/tool_query_on.gif"; |
---|
42 |
var $mszHoverImagePath = "images/tool_query_hover.gif"; |
---|
43 |
var $mszImageTip = "Zoom In"; |
---|
44 |
var $mszResultScript = ''; |
---|
45 |
var $mszEmptyResultScript = ''; |
---|
46 |
var $mszLinkQueryLayer = ''; |
---|
47 |
var $mbCallPopup = false; |
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
function LinkQuery() |
---|
53 |
{ |
---|
54 |
|
---|
55 |
parent::NavTool(); |
---|
56 |
|
---|
57 |
$this->SetNavCommand("LINKQUERY"); |
---|
58 |
$this->moPopup = new CWCPopup($this); |
---|
59 |
|
---|
60 |
$this->maAttributes["RESULTSCRIPT"] = new StringAttribute("RESULTSCRIPT", true); |
---|
61 |
$this->maAttributes["EMPTYRESULTSCRIPT"] = new StringAttribute( "EMPTYRESULTSCRIPT", false ); |
---|
62 |
$this->maAttributes["LINKQUERYLAYER"] = new StringAttribute("LINKQUERYLAYER", true); |
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 |
$this->szWidgetDescription = <<<EOT |
---|
67 |
The Query widget displays a GetFeatureInfo query result for each visible layer |
---|
68 |
at the point the user clicks. |
---|
69 |
EOT; |
---|
70 |
|
---|
71 |
$this->mnMaturityLevel = MATURITY_BETA; |
---|
72 |
} |
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
function InitDefaults() |
---|
78 |
{ |
---|
79 |
parent::InitDefaults(); |
---|
80 |
if (isset($this->maParams["RESULTSCRIPT"])) |
---|
81 |
$this->mszResultScript = $this->maParams["RESULTSCRIPT"]; |
---|
82 |
if (isset($this->maParams["EMPTYRESULTSCRIPT"])) |
---|
83 |
$this->mszEmptyResultScript = $this->maParams["EMPTYRESULTSCRIPT"]; |
---|
84 |
if (isset($this->maParams["LINKQUERYLAYER"])) |
---|
85 |
$this->mszLinkQueryLayer = $this->maParams["LINKQUERYLAYER"]; |
---|
86 |
} |
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
function ParseURL() |
---|
94 |
{ |
---|
95 |
$szCmd = ""; |
---|
96 |
$szNavInputCoord = ""; |
---|
97 |
|
---|
98 |
if ($this->isVarSet( "NAV_CMD" )) |
---|
99 |
$szCmd = $this->getVar( "NAV_CMD" ); |
---|
100 |
if ($this->isVarSet( "NAV_INPUT_COORDINATES" )) |
---|
101 |
$szNavInputCoord = $this->getVar( "NAV_INPUT_COORDINATES" ); |
---|
102 |
|
---|
103 |
|
---|
104 |
if($szCmd == "LINKQUERY") |
---|
105 |
{ |
---|
106 |
$aszMinMax = explode(";", $szNavInputCoord ); |
---|
107 |
$adMin = explode(",", $aszMinMax[0]); |
---|
108 |
$aszLayers = array(); |
---|
109 |
$oMap = $this->moMapObject->oMap; |
---|
110 |
$bQueryable = false; |
---|
111 |
|
---|
112 |
|
---|
113 |
$oLayer = $oMap->getLayerByName( $this->mszLinkQueryLayer ); |
---|
114 |
if($oLayer) |
---|
115 |
{ |
---|
116 |
if ($oLayer->status == MS_ON || $oLayer->status == MS_DEFAULT) |
---|
117 |
{ |
---|
118 |
if ($oLayer->template != "") |
---|
119 |
{ |
---|
120 |
$bQueryable = true; |
---|
121 |
} |
---|
122 |
else |
---|
123 |
{ |
---|
124 |
for( $j=0; $j < $oLayer->numclasses; $j++) |
---|
125 |
{ |
---|
126 |
$oClass = $oLayer->getClass($j); |
---|
127 |
if ($oClass->template != "") |
---|
128 |
{ |
---|
129 |
$bQueryable = true; |
---|
130 |
break; |
---|
131 |
} |
---|
132 |
} |
---|
133 |
} |
---|
134 |
} |
---|
135 |
} |
---|
136 |
|
---|
137 |
|
---|
138 |
if ( $bQueryable ) |
---|
139 |
{ |
---|
140 |
array_push( $aszLayers, $oLayer->name ); |
---|
141 |
$szName = $oLayer->name; |
---|
142 |
} |
---|
143 |
|
---|
144 |
|
---|
145 |
if(count($aszLayers) >= 1) |
---|
146 |
{ |
---|
147 |
$oMapQuery = new MapQuery( $this->moMapObject ); |
---|
148 |
|
---|
149 |
|
---|
150 |
$oMapQuery->setQueryLayersByName( $aszLayers ); |
---|
151 |
|
---|
152 |
|
---|
153 |
if ( is_numeric($adMin[0]) ) |
---|
154 |
$oResultSet = $oMapQuery->executePointQuery( $adMin[0], |
---|
155 |
$adMin[1] ); |
---|
156 |
|
---|
157 |
if($oResultSet) |
---|
158 |
{ |
---|
159 |
$nCount = $oResultSet->nNumResults; |
---|
160 |
|
---|
161 |
|
---|
162 |
for($i=0; $i<$nCount; $i++) |
---|
163 |
{ |
---|
164 |
$aRows = $oResultSet->getResultSet( $i ); |
---|
165 |
if(is_array($aRows)) |
---|
166 |
{ |
---|
167 |
foreach ($aRows[0] as $key => $value) |
---|
168 |
{ |
---|
169 |
$this->mszResultScript = str_replace( |
---|
170 |
"%$key%", $value, $this->mszResultScript); |
---|
171 |
} |
---|
172 |
|
---|
173 |
$this->mbCallPopup = true; |
---|
174 |
break; |
---|
175 |
} |
---|
176 |
} |
---|
177 |
} |
---|
178 |
if(!$this->mbCallPopup && $this->mszEmptyResultScript) |
---|
179 |
{ |
---|
180 |
$this->mszResultScript = $this->mszEmptyResultScript; |
---|
181 |
$this->mbCallPopup = true; |
---|
182 |
} |
---|
183 |
} |
---|
184 |
} |
---|
185 |
|
---|
186 |
return parent::ParseURL(); |
---|
187 |
} |
---|
188 |
|
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 |
function GetJavascriptOnMouseMoveFunctions() |
---|
193 |
{ |
---|
194 |
$aReturn = array(); |
---|
195 |
$szJsFunctionName = "QueryWMouseMove"; |
---|
196 |
$szFunction = "$szJsFunctionName(e);\n"; |
---|
197 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
198 |
|
---|
199 |
return $aReturn; |
---|
200 |
} |
---|
201 |
|
---|
202 |
function GetJavascriptInitFunctions() |
---|
203 |
{ |
---|
204 |
$aResult = parent::GetJavascriptInitFunctions(); |
---|
205 |
|
---|
206 |
$aResult['QueryRegisterEvent'] = "goEventManager.registerEventID( 'ON_QUERY' );\n"; |
---|
207 |
|
---|
208 |
if($this->mbCallPopup) |
---|
209 |
$aResult['LinkQueryCallPopup'] = "LinkQueryCallPopup();"; |
---|
210 |
|
---|
211 |
return $aResult; |
---|
212 |
} |
---|
213 |
|
---|
214 |
|
---|
215 |
|
---|
216 |
|
---|
217 |
function GetJavascriptFunctions() |
---|
218 |
{ |
---|
219 |
$aReturn = parent::GetJavascriptFunctions(); |
---|
220 |
|
---|
221 |
$this->moPopup->mszLink = $this->mszResultScript; |
---|
222 |
$szPopupName = $this->moPopup->GetPopupName(); |
---|
223 |
$szPopupURL = $this->moPopup->GetPopupURL(); |
---|
224 |
$szPopupOptions = $this->moPopup->GetPopupOptions(); |
---|
225 |
|
---|
226 |
$szJsFunctionName = "LinkQueryCallPopup"; |
---|
227 |
$szFunction = <<<EOT |
---|
228 |
/** |
---|
229 |
* {$szJsFunctionName} |
---|
230 |
* called when the CallPopup is true. |
---|
231 |
*/ |
---|
232 |
function {$szJsFunctionName}(e) |
---|
233 |
{ |
---|
234 |
szPopupURL = "{$szPopupURL}"; |
---|
235 |
szPopupName = "{$szPopupName}"; |
---|
236 |
szPopupOptions = "{$szPopupOptions}"; |
---|
237 |
|
---|
238 |
window.open( szPopupURL, szPopupName, szPopupOptions ); |
---|
239 |
} |
---|
240 |
EOT; |
---|
241 |
|
---|
242 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
243 |
|
---|
244 |
$szJsFunctionName = "QueryWMouseClick"; |
---|
245 |
$szFunction = <<<EOT |
---|
246 |
/** |
---|
247 |
* {$szJsFunctionName} |
---|
248 |
* called when the mouse moves for the Query widget. |
---|
249 |
*/ |
---|
250 |
function {$szJsFunctionName}() |
---|
251 |
{ |
---|
252 |
if ({$this->mszHTMLForm}.NAV_CMD.value != "{$this->mszCmd}") |
---|
253 |
return true; |
---|
254 |
|
---|
255 |
MapWgetMouse(e); |
---|
256 |
if ( !MapWinsideMap() ) |
---|
257 |
return true; |
---|
258 |
|
---|
259 |
nX = {$this->mszHTMLForm}.MAP_CURSOR_POS_X.value; |
---|
260 |
nY = {$this->mszHTMLForm}.MAP_CURSOR_POS_Y.value; |
---|
261 |
szNav = "NAV_INPUT_COORDINATES=" + nX + "," + nY; |
---|
262 |
|
---|
263 |
{$this->mszHTMLForm}.submit(); |
---|
264 |
|
---|
265 |
goEventManager.triggerEvent( 'ON_QUERY', nX, nY ); |
---|
266 |
return true; |
---|
267 |
} |
---|
268 |
EOT; |
---|
269 |
|
---|
270 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
271 |
|
---|
272 |
$szJsFunctionName = "QueryWMouseMove"; |
---|
273 |
$szFunction = <<<EOT |
---|
274 |
/** |
---|
275 |
* {$szJsFunctionName} |
---|
276 |
* called when the mouse moves for the Query widget. |
---|
277 |
*/ |
---|
278 |
function {$szJsFunctionName}(e) |
---|
279 |
{ |
---|
280 |
|
---|
281 |
//make sure that the forms varaibales are initialized. |
---|
282 |
//It seems like that in IE, the mouse move may be called before. |
---|
283 |
if({$this->mszHTMLForm} == null || |
---|
284 |
{$this->mszHTMLForm}.NAV_CMD == null || |
---|
285 |
{$this->mszHTMLForm}.NAV_CMD.value != "QUERY") |
---|
286 |
return true; |
---|
287 |
|
---|
288 |
//document.onmousedown = QueryWMouseClick; |
---|
289 |
document.onmouseup = QueryWMouseClick; |
---|
290 |
|
---|
291 |
var x = (navigator.appName == "Netscape")? e.pageX : event.x+document.body.scrollLeft; |
---|
292 |
var y = (navigator.appName == "Netscape")? e.pageY : event.y+document.body.scrollTop; |
---|
293 |
if ((navigator.appName == "Netscape") && e.target!=document) |
---|
294 |
routeEvent(e); |
---|
295 |
|
---|
296 |
return true; |
---|
297 |
|
---|
298 |
} |
---|
299 |
EOT; |
---|
300 |
|
---|
301 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
302 |
|
---|
303 |
|
---|
304 |
return $aReturn; |
---|
305 |
} |
---|
306 |
|
---|
307 |
} |
---|
308 |
?> |
---|
309 |
|
---|
310 |
|
---|