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 |
include_once(dirname(__FILE__)."/../Widget.php"); |
---|
33 |
include_once(dirname(__FILE__)."/../Label.php"); |
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
class ZoomFactor extends CWCWidget |
---|
42 |
{ |
---|
43 |
var $mnDefaultFactor = 2; |
---|
44 |
var $moLabel; |
---|
45 |
var $mnCurrentFactor = ""; |
---|
46 |
var $mnMinimum = ""; |
---|
47 |
var $mnMaximum = ""; |
---|
48 |
var $mnDefaultTextFieldSize = 2; |
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
function ZoomFactor() |
---|
56 |
{ |
---|
57 |
$this->mszLanguageResource = str_replace("\\","/",dirname(__FILE__))."/ZoomFactor.dbf"; |
---|
58 |
|
---|
59 |
|
---|
60 |
parent::CWCWidget(); |
---|
61 |
|
---|
62 |
|
---|
63 |
$this->szWidgetDescription = <<<EOT |
---|
64 |
The ZoomFactor widget allows the user to enter a zoom factor that is used |
---|
65 |
when the user zooms in at a point. This is ignored if the user zooms to |
---|
66 |
a rectangular region. It contains the ability to restrict the zoom factor |
---|
67 |
to a range of values. |
---|
68 |
EOT; |
---|
69 |
|
---|
70 |
$this->moLabel = new CWCLabel( $this ); |
---|
71 |
$this->maAttributes["DEFAULTFACTOR"] = new IntegerAttribute( "DEFAULTFACTOR", false, 2 ); |
---|
72 |
$this->maAttributes["MAXIMUMFACTOR"] = new IntegerAttribute( "MAXIMUMFACTOR", false, 2 ); |
---|
73 |
$this->maAttributes["MINIMUMFACTOR"] = new IntegerAttribute( "MINIMUMFACTOR", false, 2 ); |
---|
74 |
$this->maAttributes["TEXTFIELDSIZE"] = new IntegerAttribute( "TEXTFIELDSIZE", false, 1 ); |
---|
75 |
$this->mnMaturityLevel = MATURITY_TECHNICALRELEASE; |
---|
76 |
} |
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 |
function GetJavascriptFunctions() |
---|
84 |
{ |
---|
85 |
$nMin = $this->mnMinimum; |
---|
86 |
if (isset($this->maParams["MINIMUMFACTOR"])) |
---|
87 |
$nMin = $this->maParams["MINIMUMFACTOR"]; |
---|
88 |
$nMax = $this->mnMaximum; |
---|
89 |
if (isset($this->maParams["MAXIMUMFACTOR"])) |
---|
90 |
$nMax = $this->maParams["MAXIMUMFACTOR"]; |
---|
91 |
|
---|
92 |
$nZoomFactor = $this->mnCurrentFactor; |
---|
93 |
if ($nZoomFactor == "") |
---|
94 |
{ |
---|
95 |
$nZoomFactor = $this->GetValue( "DefaultFactor", |
---|
96 |
$this->mnDefaultFactor ); |
---|
97 |
} |
---|
98 |
|
---|
99 |
$szJsMinimum = ""; |
---|
100 |
if ($nMin != "") |
---|
101 |
{ |
---|
102 |
$szMinMsg = trim($this->moMLT->get("0", "Minimum Zoom Factor is")); |
---|
103 |
$szJsMinimum = <<<EOT |
---|
104 |
// check for Minimum value |
---|
105 |
if (obj.value < {$nMin} ) |
---|
106 |
{ |
---|
107 |
obj.value = {$nMin}; |
---|
108 |
alert( "{$szMinMsg} " + {$nMin} ); |
---|
109 |
} |
---|
110 |
EOT; |
---|
111 |
} |
---|
112 |
|
---|
113 |
$szJsMaximum = ""; |
---|
114 |
if ($nMax != "") |
---|
115 |
{ |
---|
116 |
$szMaxMsg = trim($this->moMLT->get("1", "Maximum Zoom Factor is")); |
---|
117 |
$szJsMaximum = <<<EOT |
---|
118 |
// check for Maximum Value |
---|
119 |
if (obj.value > {$nMax} ) |
---|
120 |
{ |
---|
121 |
obj.value = {$nMax}; |
---|
122 |
alert( "{$szMaxMsg} " + {$nMax} ); |
---|
123 |
} |
---|
124 |
EOT; |
---|
125 |
} |
---|
126 |
|
---|
127 |
$szJsFunctionName = "changeZoomFactor"; |
---|
128 |
$szValueMsg = trim($this->moMLT->get("2", "Value entered is not an integer")); |
---|
129 |
$szFunction = <<<EOT |
---|
130 |
function {$szJsFunctionName}(obj) |
---|
131 |
{ |
---|
132 |
nDefault = {$nZoomFactor}; |
---|
133 |
if (!validateInteger( obj.value )) |
---|
134 |
{ |
---|
135 |
alert( "{$szValueMsg}" ); |
---|
136 |
obj.value = nDefault; |
---|
137 |
} |
---|
138 |
{$szJsMinimum} |
---|
139 |
{$szJsMaximum} |
---|
140 |
} |
---|
141 |
EOT; |
---|
142 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
143 |
|
---|
144 |
$szJsFunctionName = "validateInteger"; |
---|
145 |
$szFunction = <<<EOT |
---|
146 |
function {$szJsFunctionName}( nValue ) |
---|
147 |
{ |
---|
148 |
return !isNaN( Number(nValue) ); |
---|
149 |
} |
---|
150 |
EOT; |
---|
151 |
|
---|
152 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
153 |
return $aReturn; |
---|
154 |
} |
---|
155 |
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 |
|
---|
160 |
|
---|
161 |
|
---|
162 |
function ParseURL() |
---|
163 |
{ |
---|
164 |
if ($this->isVarSet( "ZOOMFACTOR" )) |
---|
165 |
$this->mnCurrentFactor = $this->getVar( "ZOOMFACTOR" ); |
---|
166 |
|
---|
167 |
|
---|
168 |
return true; |
---|
169 |
} |
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 |
|
---|
174 |
|
---|
175 |
|
---|
176 |
|
---|
177 |
function DrawPublish() |
---|
178 |
{ |
---|
179 |
if (!$this->mbVisible) |
---|
180 |
return "<!-- Zoom Factor is hidden -->"; |
---|
181 |
|
---|
182 |
$nSize = $this->mnDefaultTextFieldSize; |
---|
183 |
if (isset($this->maParams["TEXTFIELDSIZE"])) |
---|
184 |
$nSize = intval($this->maParams["TEXTFIELDSIZE"]); |
---|
185 |
|
---|
186 |
$nZoomFactor = $this->mnDefaultFactor; |
---|
187 |
if (isset($this->maParams["DEFAULTFACTOR"])) |
---|
188 |
$nZoomFactor = strtoupper($this->maParams["DEFAULTFACTOR"]); |
---|
189 |
if ($this->isVarSet( "ZOOMFACTOR" )) |
---|
190 |
$nZoomFactor = strtoupper($this->getVar( "ZOOMFACTOR" )); |
---|
191 |
|
---|
192 |
$szResult = "<input type=\"text\" name=\"ZOOMFACTOR\"". |
---|
193 |
" size=\"$nSize\" value=\"$nZoomFactor\"". |
---|
194 |
" onChange=\"changeZoomFactor(this)\">"; |
---|
195 |
$szResult = $this->moLabel->DrawPublish( $szResult ); |
---|
196 |
|
---|
197 |
return $szResult; |
---|
198 |
} |
---|
199 |
} |
---|
200 |
?> |
---|
201 |
|
---|