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 |
|
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
include_once("Widget.php"); |
---|
48 |
include_once("Button.php"); |
---|
49 |
include_once( COMMON."wrapper/map_navigator.php" ); |
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
class NavTool extends CWCWidget |
---|
56 |
{ |
---|
57 |
var $moButton; |
---|
58 |
var $mszCmd = ""; |
---|
59 |
var $moMapNavigator; |
---|
60 |
var $mnAllowRectangle = 0; |
---|
61 |
var $mbSubmitOnClick = 0; |
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 |
var $mbNavSubmit = true; |
---|
67 |
var $mszMapId = "DEFAULT_MAP"; |
---|
68 |
var $mszCursorType = "AUTO"; |
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 |
function NavTool() |
---|
74 |
{ |
---|
75 |
if($this->mszLanguageResource == "") |
---|
76 |
$this->mszLanguageResource = str_replace("\\","/",dirname(__FILE__))."/NavTool.dbf"; |
---|
77 |
|
---|
78 |
|
---|
79 |
parent::CWCWidget(); |
---|
80 |
|
---|
81 |
|
---|
82 |
$this->szWidgetDescription = "No description available. Please set ". |
---|
83 |
"this description in the constructor of this class."; |
---|
84 |
|
---|
85 |
$this->moButton =& new CWCButton($this); |
---|
86 |
$this->maAttributes["WIDGETSTYLE"] = new StringAttribute( "WIDGETSTYLE", false ); |
---|
87 |
$this->maAttributes["MAPID"] = new StringAttribute( "MAPID", false ); |
---|
88 |
$this->maAttributes["CURSORTYPE"] = new StringAttribute( "CURSORTYPE", false ); |
---|
89 |
$this->maAttributes['SUBMITONCLICK'] = new BooleanAttribute( 'SUBMITONCLICK', false ); |
---|
90 |
|
---|
91 |
$this->mnPriority = PRIORITY_LOW; |
---|
92 |
} |
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 |
function InitDefaults() |
---|
98 |
{ |
---|
99 |
parent::InitDefaults(); |
---|
100 |
|
---|
101 |
if ($this->mbVisible) |
---|
102 |
{ |
---|
103 |
$this->moButton->InitDefaults(); |
---|
104 |
} |
---|
105 |
else |
---|
106 |
$this->maParams["IMAGE"] = "DUMMY"; |
---|
107 |
|
---|
108 |
if (isset($this->maParams["MAPID"])) |
---|
109 |
$this->maszMapId = $this->maParams["MAPID"]; |
---|
110 |
|
---|
111 |
if (isset($this->maParams["CURSORTYPE"])) |
---|
112 |
$this->mszCursorType = $this->maParams["CURSORTYPE"]; |
---|
113 |
|
---|
114 |
if (isset($this->maParams['SUBMITONCLICK'])) |
---|
115 |
{ |
---|
116 |
$this->mbSubmitOnClick = strcasecmp($this->maParams['SUBMITONCLICK'], 'true') == 0?true:false; |
---|
117 |
} |
---|
118 |
|
---|
119 |
if ($this->mbSubmitOnClick) |
---|
120 |
$this->moButton->mszToolset = ''; |
---|
121 |
} |
---|
122 |
|
---|
123 |
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
127 |
function SetNavCommand($szNavCmd) |
---|
128 |
{ |
---|
129 |
$this->mszCmd = $szNavCmd; |
---|
130 |
} |
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 |
function SetMap(&$oMapSession) |
---|
137 |
{ |
---|
138 |
$this->moMapObject =& $oMapSession; |
---|
139 |
|
---|
140 |
$this->moMapNavigator = new MapNavigator( $oMapSession ); |
---|
141 |
} |
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 |
function GetJavascriptFunctions() |
---|
148 |
{ |
---|
149 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
150 |
$bCWCJSAPI = 1; |
---|
151 |
else |
---|
152 |
$bCWCJSAPI = 0; |
---|
153 |
|
---|
154 |
if ($this->mbVisible) |
---|
155 |
$aReturn = $this->moButton->GetJavascriptFunctions(); |
---|
156 |
else |
---|
157 |
$aReturn = array(); |
---|
158 |
|
---|
159 |
$szJsFunctionName = "NavSetActiveTool"; |
---|
160 |
$szFunction = <<<EOT |
---|
161 |
/** |
---|
162 |
* set the active navigation tool |
---|
163 |
*/ |
---|
164 |
function {$szJsFunctionName}( oButton, aVals ) |
---|
165 |
{ |
---|
166 |
var nTool = aVals[0]; |
---|
167 |
var sTool = aVals[1]; |
---|
168 |
var bAllowRectangle = (aVals[2] == 0 || aVals[2] == "0") ? false : true; |
---|
169 |
var bAutoSubmit = (aVals[3] == 0 || aVals[3] == "0") ? false : true; |
---|
170 |
var szCursorType = aVals[4]; |
---|
171 |
var nNavSubmit = (aVals[5] != undefined) ? aVals[5] : 1; |
---|
172 |
|
---|
173 |
{$this->mszHTMLForm}.NAV_CMD.value = sTool; |
---|
174 |
{$this->mszHTMLForm}.NAV_ALLOW_RECTANGLE.value=bAllowRectangle; |
---|
175 |
{$this->mszHTMLForm}.NAV_SUBMIT.value=nNavSubmit; |
---|
176 |
|
---|
177 |
if ({$bCWCJSAPI}) |
---|
178 |
{ |
---|
179 |
goCWCJSAPI.NAV_CMD = sTool; |
---|
180 |
} |
---|
181 |
|
---|
182 |
if (bAutoSubmit) |
---|
183 |
{ |
---|
184 |
if ({$bCWCJSAPI}) |
---|
185 |
{ |
---|
186 |
goCWCJSAPI.UpdateNavTools(); |
---|
187 |
} |
---|
188 |
else |
---|
189 |
{ |
---|
190 |
{$this->mszHTMLForm}.submit(); |
---|
191 |
} |
---|
192 |
} |
---|
193 |
|
---|
194 |
if ({$this->mszHTMLForm}.CURSOR_TYPE != null) |
---|
195 |
{ |
---|
196 |
{$this->mszHTMLForm}.CURSOR_TYPE.value = szCursorType; |
---|
197 |
} |
---|
198 |
|
---|
199 |
goEventManager.triggerEvent( 'NAV_TOOL_CHANGED', sTool ); |
---|
200 |
} |
---|
201 |
EOT; |
---|
202 |
|
---|
203 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
204 |
|
---|
205 |
return $aReturn; |
---|
206 |
} |
---|
207 |
|
---|
208 |
function GetJavascriptVariables() |
---|
209 |
{ |
---|
210 |
if ($this->mbVisible) |
---|
211 |
return $this->moButton->GetJavascriptVariables(); |
---|
212 |
else return array(); |
---|
213 |
} |
---|
214 |
|
---|
215 |
function GetJavascriptInitFunctions() |
---|
216 |
{ |
---|
217 |
$aResult = array(); |
---|
218 |
if ($this->mbVisible) |
---|
219 |
{ |
---|
220 |
$aResult = $this->moButton->GetJavascriptInitFunctions(); |
---|
221 |
} |
---|
222 |
|
---|
223 |
$aResult['NavToolRegisterEvent'] = "goEventManager.registerEventID( 'NAV_TOOL_CHANGED' );\n"; |
---|
224 |
|
---|
225 |
return $aResult; |
---|
226 |
} |
---|
227 |
|
---|
228 |
function GetJavascriptOnLoadFunctions() |
---|
229 |
{ |
---|
230 |
if ($this->mbVisible) |
---|
231 |
$aReturn = $this->moButton->GetJavascriptOnLoadFunctions(); |
---|
232 |
else |
---|
233 |
$aReturn = array(); |
---|
234 |
|
---|
235 |
return $aReturn; |
---|
236 |
} |
---|
237 |
|
---|
238 |
function GetJavascriptIncludeFunctions() |
---|
239 |
{ |
---|
240 |
$aReturn = $this->moButton->GetJavascriptIncludeFunctions(); |
---|
241 |
|
---|
242 |
$szVar = "cwc_events.js"; |
---|
243 |
$aReturn[$szVar] = '<script src="'.$_SESSION['gszCoreWebPath']. |
---|
244 |
'/widgets/js/cwc_events.js" type="text/javascript"></script>'; |
---|
245 |
|
---|
246 |
return $aReturn; |
---|
247 |
} |
---|
248 |
|
---|
249 |
|
---|
250 |
|
---|
251 |
|
---|
252 |
function ParseURL() |
---|
253 |
{ |
---|
254 |
$aVals = array(); |
---|
255 |
array_push( $aVals, $this->mnId ); |
---|
256 |
array_push( $aVals, $this->mszCmd ); |
---|
257 |
array_push( $aVals, $this->mnAllowRectangle ); |
---|
258 |
array_push( $aVals, $this->mbSubmitOnClick ? 1 : 0); |
---|
259 |
array_push( $aVals, $this->mszCursorType ); |
---|
260 |
array_push( $aVals, $this->mbNavSubmit ? 1 : 0 ); |
---|
261 |
|
---|
262 |
$this->moButton->SetOnClick('NavSetActiveTool', $aVals); |
---|
263 |
|
---|
264 |
|
---|
265 |
if ($this->isVarSet( strtoupper($this->mszMapId)."_X" ) && |
---|
266 |
$this->isVarSet( strtoupper($this->mszMapId)."_Y" )) |
---|
267 |
{ |
---|
268 |
$this->setVar( "NAV_INPUT_COORDINATES" , |
---|
269 |
$this->getVar( strtoupper($this->mszMapId)."_X" ).",". |
---|
270 |
$this->getVar( strtoupper($this->mszMapId)."_Y" ) ); |
---|
271 |
} |
---|
272 |
|
---|
273 |
$this->moButton->ParseURL(); |
---|
274 |
|
---|
275 |
return true; |
---|
276 |
} |
---|
277 |
|
---|
278 |
|
---|
279 |
|
---|
280 |
|
---|
281 |
function GetHTMLHiddenVariables() |
---|
282 |
{ |
---|
283 |
$aReturn = $this->moButton->GetHTMLHiddenVariables(); |
---|
284 |
|
---|
285 |
$szVariable = "NAV_CMD"; |
---|
286 |
$szTool = ''; |
---|
287 |
if ($this->isVarSet( 'NAV_CMD' )) |
---|
288 |
$szTool = $this->getVar( 'NAV_CMD' ); |
---|
289 |
|
---|
290 |
$szValue = "<INPUT TYPE='HIDDEN' NAME='$szVariable' VALUE='$szTool'>"; |
---|
291 |
$aReturn[$szVariable] = $szValue; |
---|
292 |
|
---|
293 |
$szAllowRect = ""; |
---|
294 |
if ($this->isVarSet( "NAV_ALLOW_RECTANGLE" )) |
---|
295 |
$szAllowRect = $this->getVar( "NAV_ALLOW_RECTANGLE" ); |
---|
296 |
|
---|
297 |
$szVariable = "NAV_ALLOW_RECTANGLE"; |
---|
298 |
$szValue = "<INPUT TYPE='HIDDEN' NAME='$szVariable' VALUE='$szAllowRect'>"; |
---|
299 |
$aReturn[$szVariable] = $szValue; |
---|
300 |
|
---|
301 |
$szNavSubmit = "1"; |
---|
302 |
if ($this->isVarSet( "NAV_SUBMIT" )) |
---|
303 |
$szNavSubmit = $this->getVar( "NAV_SUBMIT" ); |
---|
304 |
|
---|
305 |
$szVariable = "NAV_SUBMIT"; |
---|
306 |
$szValue = "<INPUT TYPE='HIDDEN' NAME='$szVariable' VALUE='$szNavSubmit'>"; |
---|
307 |
$aReturn[$szVariable] = $szValue; |
---|
308 |
|
---|
309 |
return $aReturn; |
---|
310 |
} |
---|
311 |
|
---|
312 |
|
---|
313 |
|
---|
314 |
|
---|
315 |
|
---|
316 |
function DrawPublish() |
---|
317 |
{ |
---|
318 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
319 |
$bCWCJSAPI = 1; |
---|
320 |
else |
---|
321 |
$bCWCJSAPI = 0; |
---|
322 |
|
---|
323 |
if (!$this->mbVisible) |
---|
324 |
return "<!-- NavTool hidden -->"; |
---|
325 |
|
---|
326 |
$szReturn = $this->moButton->DrawPublish(); |
---|
327 |
|
---|
328 |
return $szReturn; |
---|
329 |
} |
---|
330 |
} |
---|
331 |
|
---|