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(dirname(__FILE__)."/../LegendTemplate/LegendTemplate.widget.php"); |
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
class LegendTemplateLM extends LegendTemplate |
---|
38 |
{ |
---|
39 |
var $moTmpMapObject; |
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
function LegendTemplateLM() |
---|
47 |
{ |
---|
48 |
|
---|
49 |
parent::LegendTemplate(); |
---|
50 |
|
---|
51 |
|
---|
52 |
$this->szWidgetDescription = <<<EOT |
---|
53 |
The Legend widget allows the user display a legend based on a legend template. |
---|
54 |
The Legend can either be embedded in the same page or displayed in a separate window. |
---|
55 |
This widget was coded especialy for LayerManager widget. It use a different MapObject. |
---|
56 |
EOT; |
---|
57 |
$this->mnMaturityLevel = MATURITY_BETA; |
---|
58 |
} |
---|
59 |
|
---|
60 |
function parseURL() |
---|
61 |
{ |
---|
62 |
|
---|
63 |
$oNewMapSession = new MapSession_RW; |
---|
64 |
|
---|
65 |
|
---|
66 |
$oNewMapSession->setTempDir( $_SESSION['gszTmpPath'] ); |
---|
67 |
|
---|
68 |
if (!$this->isVarSet("LAYERMANAGER_CURRENT_STATE")) |
---|
69 |
{ |
---|
70 |
$oNewMapSession->restoreState( $_SESSION["gszCurrentState"], |
---|
71 |
$_SESSION['gszMapName'], |
---|
72 |
dirname($_SESSION['gszMapName'] ) ); |
---|
73 |
} |
---|
74 |
else |
---|
75 |
{ |
---|
76 |
$oNewMapSession->restoreState( $this->getVar("LAYERMANAGER_CURRENT_STATE"), |
---|
77 |
$_SESSION['gszMapName'], |
---|
78 |
dirname($_SESSION['gszMapName'] ) ); |
---|
79 |
|
---|
80 |
|
---|
81 |
$oNewMapSession->oMap->setProjection($this->moMapObject->oMap->getProjection(), |
---|
82 |
true); |
---|
83 |
$oNewMapSession->oMap->setextent($this->moMapObject->oMap->extent->minx, |
---|
84 |
$this->moMapObject->oMap->extent->miny, |
---|
85 |
$this->moMapObject->oMap->extent->maxx, |
---|
86 |
$this->moMapObject->oMap->extent->maxy); |
---|
87 |
$oNewMapSession->oMap->set("width", $this->moMapObject->oMap->width); |
---|
88 |
$oNewMapSession->oMap->set("height", $this->moMapObject->oMap->height); |
---|
89 |
} |
---|
90 |
|
---|
91 |
|
---|
92 |
$oNewMapSession->oMap->web->set("imageurl", $_SESSION['gszTmpWebPath']); |
---|
93 |
$oNewMapSession->oMap->web->set("imagepath", $_SESSION['gszTmpImgPath']); |
---|
94 |
$oNewMapSession->oMap->selectOutputFormat($_SESSION['gszImgType']); |
---|
95 |
|
---|
96 |
$oTmpMapObj = $this->moMapObject; |
---|
97 |
$this->moMapObject = $oNewMapSession; |
---|
98 |
parent::parseURL(); |
---|
99 |
$this->moMapObject = $oTmpMapObj; |
---|
100 |
$this->moTmpMapObject = $oNewMapSession; |
---|
101 |
return true; |
---|
102 |
} |
---|
103 |
|
---|
104 |
function GetJavascriptFunctions() |
---|
105 |
{ |
---|
106 |
$oTmpMapObj = $this->moMapObject; |
---|
107 |
$this->moMapObject = $this->moTmpMapObject; |
---|
108 |
$aReturn = parent::GetJavascriptFunctions(); |
---|
109 |
$this->moMapObject = $oTmpMapObj; |
---|
110 |
|
---|
111 |
$szLayer = $this->getVar('LAYERMANAGER_LAYER'); |
---|
112 |
$szJsFunctionName = "SelectSelectedLayer"; |
---|
113 |
if ($this->isVarSet('LAYERMANAGER_LAYER')) |
---|
114 |
{ |
---|
115 |
$szFunction = <<<EOT |
---|
116 |
function {$szJsFunctionName}() |
---|
117 |
{ |
---|
118 |
var i; |
---|
119 |
var bFind = false; |
---|
120 |
|
---|
121 |
if({$this->mszHTMLForm}['LAYERMANAGER_LAYER'][0] == null) |
---|
122 |
{ |
---|
123 |
{$this->mszHTMLForm}['LAYERMANAGER_LAYER'].checked = true; |
---|
124 |
} |
---|
125 |
else |
---|
126 |
{ |
---|
127 |
for(var i=0;i<{$this->mszHTMLForm}['LAYERMANAGER_LAYER'].length;i++) |
---|
128 |
{ |
---|
129 |
if ({$this->mszHTMLForm}['LAYERMANAGER_LAYER'][i].value == '{$szLayer}') |
---|
130 |
{ |
---|
131 |
bFind = true; |
---|
132 |
{$this->mszHTMLForm}['LAYERMANAGER_LAYER'][i].checked = true; |
---|
133 |
} |
---|
134 |
} |
---|
135 |
|
---|
136 |
// just in case. |
---|
137 |
if (!bFind) |
---|
138 |
{$this->mszHTMLForm}['LAYERMANAGER_LAYER'][0].checked = true; |
---|
139 |
} |
---|
140 |
} |
---|
141 |
EOT; |
---|
142 |
} |
---|
143 |
else |
---|
144 |
{ |
---|
145 |
$szFunction = <<<EOT |
---|
146 |
function {$szJsFunctionName}() |
---|
147 |
{ |
---|
148 |
{$this->mszHTMLForm}['LAYERMANAGER_LAYER'][0].checked = true; |
---|
149 |
} |
---|
150 |
EOT; |
---|
151 |
} |
---|
152 |
|
---|
153 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
154 |
|
---|
155 |
return $aReturn; |
---|
156 |
} |
---|
157 |
|
---|
158 |
function GetJavascriptOnLoadFunctions() |
---|
159 |
{ |
---|
160 |
$aReturn = parent::GetJavascriptOnLoadFunctions(); |
---|
161 |
|
---|
162 |
$aReturn['SelectSelectedLayer'] = "SelectSelectedLayer();"; |
---|
163 |
|
---|
164 |
return $aReturn; |
---|
165 |
} |
---|
166 |
|
---|
167 |
function drawPublish() |
---|
168 |
{ |
---|
169 |
$oTmpMapObj = $this->moMapObject; |
---|
170 |
$this->moMapObject = $this->moTmpMapObject; |
---|
171 |
$aReturn = parent::drawPublish(); |
---|
172 |
$this->moMapObject = $oTmpMapObj; |
---|
173 |
|
---|
174 |
return $aReturn; |
---|
175 |
} |
---|
176 |
} |
---|
177 |
?> |
---|
178 |
|
---|