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 |
include_once(dirname(__FILE__)."/../Widget.php"); |
---|
32 |
include_once( dirname(__FILE__)."/../LayerAttributes.php" ); |
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
class LayerAttributes extends CWCWidget |
---|
41 |
{ |
---|
42 |
|
---|
43 |
var $mszSharedResourceName; |
---|
44 |
|
---|
45 |
|
---|
46 |
var $mnAttributeLayerIndex; |
---|
47 |
|
---|
48 |
var $mszSelectedItem = ""; |
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
function LayerAttributes() |
---|
56 |
{ |
---|
57 |
|
---|
58 |
parent::CWCWidget(); |
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
$this->szWidgetDescription = <<<EOT |
---|
63 |
The LayerAttributes widget gets the contents of a mapfile layer and adds an array to |
---|
64 |
a SharedResource widget in a format suitable for feeding a JSList widget. |
---|
65 |
The layer to process must be passed in the url as nlayerindex. |
---|
66 |
EOT; |
---|
67 |
|
---|
68 |
$this->maAttributes["SHAREDRESOURCENAME"] = |
---|
69 |
new StringAttribute( "SHAREDRESOURCENAME", true ); |
---|
70 |
|
---|
71 |
$this->maAttributes["LAYERNAME"] = |
---|
72 |
new StringAttribute( "LAYERNAME", false ); |
---|
73 |
$this->maAttributes["ITEM"] = |
---|
74 |
new StringAttribute( "ITEM", true, array( "CLASSITEM", "LABELITEM", "TILEITEM", "FILTERITEM", "STYLEITEM" ) ); |
---|
75 |
$this->maAttributes["ONCHANGE"] = |
---|
76 |
new StringAttribute( "ONCHANGE", false ); |
---|
77 |
$this->maAttributes["VISIBILITY"] = |
---|
78 |
new BooleanAttribute( "VISIBILITY", false ); |
---|
79 |
|
---|
80 |
$this->mnMaturityLevel = MATURITY_ALPHA; |
---|
81 |
} |
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
function InitDefaults() |
---|
87 |
{ |
---|
88 |
parent::InitDefaults(); |
---|
89 |
|
---|
90 |
if (isset($this->maParams["SHAREDRESOURCENAME"])) |
---|
91 |
{ |
---|
92 |
$this->mszSharedResourceName = |
---|
93 |
$this->maParams["SHAREDRESOURCENAME"]; |
---|
94 |
} |
---|
95 |
if (!isset($this->maParams["ONCHANGE"])) |
---|
96 |
{ |
---|
97 |
$this->maParams["ONCHANGE"] = ''; |
---|
98 |
} |
---|
99 |
} |
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
function GetHTMLHiddenVariables() |
---|
105 |
{ |
---|
106 |
$aReturn = array(); |
---|
107 |
$szVariable = 'nlayerindex'; |
---|
108 |
|
---|
109 |
return $aReturn; |
---|
110 |
} |
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 |
function ParseURL() |
---|
117 |
{ |
---|
118 |
$srName = $this->mszSharedResourceName; |
---|
119 |
|
---|
120 |
$oMap = $this->moMapObject->oMap; |
---|
121 |
|
---|
122 |
if ($this->isVarSet('initlayername')) |
---|
123 |
{ |
---|
124 |
|
---|
125 |
|
---|
126 |
$oLayer = $oMap->getLayerByName( $this->getVar('initlayername') ); |
---|
127 |
$this->mnAttributeLayerIndex = $oLayer->index; |
---|
128 |
} |
---|
129 |
elseif($this->isVarSet('initlayerindex')) |
---|
130 |
{ |
---|
131 |
$oLayer = $oMap->getLayer( $this->getVar('initlayerindex') ); |
---|
132 |
$this->mnAttributeLayerIndex = $oLayer->index; |
---|
133 |
} |
---|
134 |
else |
---|
135 |
{ |
---|
136 |
|
---|
137 |
$oLayer = $oMap->getLayer( $this->getVar('nlayerindex') ); |
---|
138 |
$this->mnAttributeLayerIndex = $oLayer->index; |
---|
139 |
} |
---|
140 |
|
---|
141 |
if ( strcasecmp( $this->maParams['ITEM'], 'classitem' ) == 0 ) |
---|
142 |
$this->mszSelectedItem = $oLayer->classitem; |
---|
143 |
else if ( strcasecmp( $this->maParams['ITEM'], 'labelitem' ) == 0 ) |
---|
144 |
$this->mszSelectedItem = $oLayer->labelitem; |
---|
145 |
else if ( strcasecmp( $this->maParams['ITEM'], 'tileitem' ) == 0 ) |
---|
146 |
$this->mszSelectedItem = $oLayer->tileitem; |
---|
147 |
else if ( strcasecmp( $this->maParams['ITEM'], 'filteritem' ) == 0 ) |
---|
148 |
$this->mszSelectedItem = $oLayer->filteritem; |
---|
149 |
else if ( strcasecmp( $this->maParams['ITEM'], 'styleitem' ) == 0 ) |
---|
150 |
$this->mszSelectedItem = $oLayer->styleitem; |
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 |
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 |
if(!(isset($this->maSharedResourceWidgets[$srName]) && |
---|
160 |
count($this->maSharedResourceWidgets[$srName]->maszContents))) |
---|
161 |
{ |
---|
162 |
if (isset($_SESSION[$srName][$oLayer->name])) |
---|
163 |
{ |
---|
164 |
$this->maSharedResourceWidgets[$srName] = |
---|
165 |
$_SESSION[$srName][$oLayer->name]; |
---|
166 |
} |
---|
167 |
else |
---|
168 |
{ |
---|
169 |
$this->maSharedResourceWidgets[$srName]->maszContents = |
---|
170 |
GetLayerAttributes($oLayer); |
---|
171 |
$_SESSION[$srName][$oLayer->name] = |
---|
172 |
$this->maSharedResourceWidgets[$srName]; |
---|
173 |
} |
---|
174 |
} |
---|
175 |
|
---|
176 |
return true; |
---|
177 |
} |
---|
178 |
|
---|
179 |
function DrawPublish() |
---|
180 |
{ |
---|
181 |
if (!$this->mbVisible) |
---|
182 |
return "<!-- LayerAttributes widget hidden -->"; |
---|
183 |
|
---|
184 |
$srName = $this->mszSharedResourceName; |
---|
185 |
$sr = $this->maSharedResourceWidgets[$srName]; |
---|
186 |
|
---|
187 |
|
---|
188 |
|
---|
189 |
if (!count($sr->maszContents)) |
---|
190 |
{ |
---|
191 |
$szResult = '<input TYPE="text" SIZE="10" NAME="'; |
---|
192 |
$szResult .= $this->maParams['ITEM']. |
---|
193 |
'" ID="' .$this->maParams['ITEM']. |
---|
194 |
'" ONCHANGE="'. |
---|
195 |
$this->maParams['ONCHANGE']; |
---|
196 |
$szResult .= '" >'."\n"; |
---|
197 |
} |
---|
198 |
else |
---|
199 |
{ |
---|
200 |
$szResult = '<SELECT NAME="' .$this->maParams['ITEM']. |
---|
201 |
'" id="' .$this->maParams['ITEM']. |
---|
202 |
'" ONCHANGE="'. |
---|
203 |
$this->maParams['ONCHANGE']. |
---|
204 |
'" >'."\n"; |
---|
205 |
$szResult .= ' <OPTION VALUE="">None'."\n"; |
---|
206 |
foreach(array_keys($sr->maszContents['fields']) as $szFieldName) |
---|
207 |
{ |
---|
208 |
if ($szFieldName != "LayerType") |
---|
209 |
{ |
---|
210 |
$szResult .= ' <OPTION VALUE="'. $szFieldName.'"'; |
---|
211 |
if (strcasecmp( $szFieldName, $this->mszSelectedItem) == 0) |
---|
212 |
$szResult .= ' SELECTED'; |
---|
213 |
$szResult .= '>'. $szFieldName."\n"; |
---|
214 |
} |
---|
215 |
} |
---|
216 |
$szResult .= '</SELECT>'."\n"; |
---|
217 |
} |
---|
218 |
|
---|
219 |
return $szResult; |
---|
220 |
} |
---|
221 |
} |
---|
222 |
?> |
---|