1 |
<?php |
---|
2 |
/** |
---|
3 |
* ClearPoints Widget class |
---|
4 |
* |
---|
5 |
* @project CWC2 |
---|
6 |
* @revision $Id: |
---|
7 |
* @purpose ClearPoints Widget class |
---|
8 |
* @author DM Solutions Group (sfournier@dmsolutions.ca) |
---|
9 |
* @copyright |
---|
10 |
* <b>Copyright (c) 2002, DM Solutions Group Inc.</b> |
---|
11 |
* Permission is hereby granted, free of charge, to any person obtaining a |
---|
12 |
* copy of this software and associated documentation files (the "Software"), |
---|
13 |
* to deal in the Software without restriction, including without limitation |
---|
14 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
15 |
* and/or sell copies of the Software, and to permit persons to whom the |
---|
16 |
* Software is furnished to do so, subject to the following conditions: |
---|
17 |
* |
---|
18 |
* The above copyright notice and this permission notice shall be included |
---|
19 |
* in all copies or substantial portions of the Software. |
---|
20 |
* |
---|
21 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
22 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
23 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
24 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
25 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
---|
26 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
27 |
* DEALINGS IN THE SOFTWARE. |
---|
28 |
*/ |
---|
29 |
include_once(dirname(__FILE__)."/../Widget.php"); |
---|
30 |
include_once(dirname(__FILE__)."/../Button.php"); |
---|
31 |
|
---|
32 |
/** |
---|
33 |
* ClearPoints |
---|
34 |
* |
---|
35 |
* @desc Display a clickable image that will clear all points from map |
---|
36 |
*/ |
---|
37 |
class ClearPoints extends CWCWidget |
---|
38 |
{ |
---|
39 |
|
---|
40 |
/** |
---|
41 |
* ClearPoints |
---|
42 |
* |
---|
43 |
* Constructor for the ClearPointsWidget |
---|
44 |
*/ |
---|
45 |
function ClearPoints( ) |
---|
46 |
{ |
---|
47 |
// invoke constructor of parent |
---|
48 |
parent::CWCWidget(); |
---|
49 |
|
---|
50 |
// set the description for this widget |
---|
51 |
$this->szWidgetDescription = <<<EOT |
---|
52 |
The ClearPoints widget allows the user to clear all user created points |
---|
53 |
and refresh the current page without performing any other navigation. |
---|
54 |
EOT; |
---|
55 |
|
---|
56 |
$this->moButton = new CWCButton($this); |
---|
57 |
$this->mnMaturityLevel = MATURITY_BETA; |
---|
58 |
} |
---|
59 |
|
---|
60 |
function InitDefaults() |
---|
61 |
{ |
---|
62 |
parent::InitDefaults(); |
---|
63 |
//this widget should never belong to a toolset |
---|
64 |
$this->maParams["TOOLSET"] = ""; |
---|
65 |
$this->moButton->InitDefaults(); |
---|
66 |
$this->moButton->SetOnClick( "clickClearPoints" ); |
---|
67 |
} |
---|
68 |
|
---|
69 |
function GetJavascriptVariables() |
---|
70 |
{ |
---|
71 |
if ($this->mbVisible) |
---|
72 |
return $this->moButton->GetJavascriptVariables(); |
---|
73 |
else return array(); |
---|
74 |
} |
---|
75 |
|
---|
76 |
function GetJavascriptInitFunctions() |
---|
77 |
{ |
---|
78 |
if ($this->mbVisible) |
---|
79 |
return $this->moButton->GetJavascriptInitFunctions(); |
---|
80 |
else return array(); |
---|
81 |
} |
---|
82 |
|
---|
83 |
function GetJavascriptOnLoadFunctions() |
---|
84 |
{ |
---|
85 |
if ($this->mbVisible) |
---|
86 |
$aReturn = $this->moButton->GetJavascriptOnLoadFunctions(); |
---|
87 |
else |
---|
88 |
$aReturn = array(); |
---|
89 |
return $aReturn; |
---|
90 |
} |
---|
91 |
|
---|
92 |
function GetJavascriptIncludeFunctions() |
---|
93 |
{ |
---|
94 |
if ($this->mbVisible) |
---|
95 |
$aReturn = $this->moButton->GetJavascriptIncludeFunctions(); |
---|
96 |
else |
---|
97 |
$aReturn = array(); |
---|
98 |
return $aReturn; |
---|
99 |
} |
---|
100 |
/** |
---|
101 |
* ParseURL |
---|
102 |
* |
---|
103 |
* Look for the CLEAR_POINTS command and if found clear all |
---|
104 |
* user created points. |
---|
105 |
*/ |
---|
106 |
function ParseURL() |
---|
107 |
{ |
---|
108 |
parent::ParseURL(); |
---|
109 |
|
---|
110 |
if ($this->isVarSet("CLEAR_POINTS") && |
---|
111 |
$this->getVar("CLEAR_POINTS") == "1") |
---|
112 |
{ |
---|
113 |
$oMap = $this->moMapObject->oMap; |
---|
114 |
|
---|
115 |
// First step, clearr all point from shape file |
---|
116 |
if (file_exists($_SESSION['gszTmpPath'].session_id().".dbf")) |
---|
117 |
{ |
---|
118 |
unlink($_SESSION['gszTmpPath'].session_id().".dbf"); |
---|
119 |
} |
---|
120 |
|
---|
121 |
// Then, clear point layer from current map file |
---|
122 |
$oLayer = @$oMap->getlayerbyname("cwc_tmp_point"); |
---|
123 |
|
---|
124 |
if ($oLayer !== false) |
---|
125 |
{ |
---|
126 |
$oLayer->set("status", MS_DELETE); |
---|
127 |
|
---|
128 |
$_SESSION["gszCurrentState"] = $this->moMapObject->saveState(); |
---|
129 |
} |
---|
130 |
// Then, clear point layer from current map file |
---|
131 |
$oLayer = @$oMap->getlayerbyname("cwc_tmp_line"); |
---|
132 |
|
---|
133 |
if ($oLayer !== false) |
---|
134 |
{ |
---|
135 |
$oLayer->set("status", MS_DELETE); |
---|
136 |
|
---|
137 |
$_SESSION["gszCurrentState"] = $this->moMapObject->saveState(); |
---|
138 |
} |
---|
139 |
|
---|
140 |
} |
---|
141 |
|
---|
142 |
// return success |
---|
143 |
return true; |
---|
144 |
} |
---|
145 |
|
---|
146 |
/** |
---|
147 |
* GetHTMLHiddenVariables |
---|
148 |
* |
---|
149 |
* Return HTML hidden variables. |
---|
150 |
*/ |
---|
151 |
function GetHTMLHiddenVariables() |
---|
152 |
{ |
---|
153 |
$aReturn = $this->moButton->GetHTMLHiddenVariables(); |
---|
154 |
|
---|
155 |
$szVariable = "CLEAR_POINTS"; |
---|
156 |
$szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"0\">"; |
---|
157 |
$aReturn[$szVariable] = $szValue; |
---|
158 |
return $aReturn; |
---|
159 |
} |
---|
160 |
|
---|
161 |
/** |
---|
162 |
* GetJavascriptFunctions |
---|
163 |
* |
---|
164 |
* Return the Javacriptfunctions needed by the widget. |
---|
165 |
*/ |
---|
166 |
function GetJavascriptFunctions() |
---|
167 |
{ |
---|
168 |
$aReturn = array(); |
---|
169 |
|
---|
170 |
$szJsFunctionName = "clickClearPoints"; |
---|
171 |
$szFunction = <<<EOT |
---|
172 |
/** |
---|
173 |
* {$szJsFunctionName} |
---|
174 |
* called when the user clicks the ClearPoints icon |
---|
175 |
*/ |
---|
176 |
function {$szJsFunctionName}() |
---|
177 |
{ |
---|
178 |
{$this->mszHTMLForm}.CLEAR_POINTS.value = "1"; |
---|
179 |
{$this->mszHTMLForm}.submit(); |
---|
180 |
return; |
---|
181 |
} |
---|
182 |
EOT; |
---|
183 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
184 |
|
---|
185 |
return $aReturn; |
---|
186 |
} |
---|
187 |
|
---|
188 |
/** |
---|
189 |
* DrawPublish |
---|
190 |
* |
---|
191 |
* Return the HTML code using the name in the map file and the |
---|
192 |
* parameters of the CWC tag. |
---|
193 |
*/ |
---|
194 |
function DrawPublish() |
---|
195 |
{ |
---|
196 |
if (!$this->mbVisible) |
---|
197 |
return "<!-- ClearPoints widget hidden -->"; |
---|
198 |
return $this->moButton->DrawPublish(); |
---|
199 |
} |
---|
200 |
} |
---|
201 |
?> |
---|