NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/LegendTemplate/LegendTemplatePopup.phtml

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * CWC2 application
4  *
5  * @project     CWC2
6  * @revision    $Id: LegendTemplatePopup.phtml,v 1.11 2004/12/03 03:31:54 pspencer Exp $
7  * @purpose     Legend Template popup
8  * @author      Assefa Yewondwossen (assefa@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
30 /*****************************************************************************/
31
32 // include the supporting php code
33 define("LOAD_MAPSESSION", "1");
34
35 //set the language resource file
36 $szLanguageResource = str_replace("\\","/",dirname(__FILE__))."/LegendTemplate.dbf";
37
38
39 include_once("../session.inc.php");
40 include_once(COMMON."/phpwms/dbf.php");
41 include_once("../CWC2ButtonCache.php");
42
43 //for convenience
44 $oMap =& $oMapSession->oMap;
45
46 /*
47  * hack for wms layers to make an icon available through metadata if possible\
48  */
49 for ($i=0; $i<$oMap->numlayers; $i++)
50 {
51     $oLayer = $oMap->getLayer( $i );
52     if ($oLayer->connectiontype == MS_WMS)
53     {
54         if ($oLayer->getMetadata( "cwc2_legendurl" ) == "")
55         {
56             $szStyle = $oLayer->getMetadata( "wms_style" );
57             $szLegendURL = $oLayer->getMetadata( "wms_style_".$szStyle."_legendurl_href" );
58             $oLayer->setMetadata( "cwc2_legendurl", $szLegendURL );
59         }
60     }
61 }
62
63
64 /* -------------------------------------------------------------------- */
65 /*      check if the set_layer is set and then update the status of     */
66 /*      the layers.                                                     */
67 /* -------------------------------------------------------------------- */
68 if (isset($http_form_vars["set_layer"]) &&
69     $http_form_vars["set_layer"] != "" &&
70     ((isset($http_form_vars['controlvisibility']) &&
71       $http_form_vars['controlvisibility'] != 0) ||
72       !isset($http_form_vars['controlvisibility'])))
73 {
74     if (isset( $http_form_vars['legendlayername'] ))
75     {
76         for ($i=0; $i<$oMap->numlayers; $i++)
77         {
78             $oLayer = $oMap->getlayer($i);
79             if (in_array($oLayer->name, $http_form_vars['legendlayername'] ) )
80             {
81                 $oLayer->set("status", MS_ON);
82             }
83             else
84             {
85                 $oLayer->set("status", MS_OFF);
86             }
87         }
88     }
89     else
90     {
91         $_SESSION['gErrorManager']->setError(ERR_WARNING,
92             trim($oMLT->get("2", "The legend template has no inputs named legendlayername[].")));
93     }
94 }
95 $_SESSION['gszCurrentState'] = $oMapSession->saveState();
96 /* -------------------------------------------------------------------- */
97 /*      Get the ouput using the template. If template is not            */
98 /*      available fall back on mapserver legend.                        */
99 /* -------------------------------------------------------------------- */
100
101 if (isset($_GET['widgetId']) && isset($_SESSION['LEGENDTEMPLATE'.$_GET['widgetId']]))
102 {
103     $oMap->legend->set("template",$_SESSION['LEGENDTEMPLATE'.$_GET['widgetId']]);
104 }
105 $szLegendTemplate = $oMap->processLegendTemplate( array() );
106 ?>
107
108 <html>
109 <head><title><?php echo $oMLT->get("0", "Legend");?></title></head>
110 <link href="<?php echo $szCSSFile; ?>" rel="stylesheet" type="text/css">
111 <script language="JavaScript" src="<?php echo $_SESSION['gszCoreWebPath']; ?>/widgets/js/cwc_dhtml.js" type="text/javascript"></script>
112 <script language="JavaScript" src="<?php echo $_SESSION['gszCoreWebPath']; ?>/widgets/js/cwc_button.js" type="text/javascript"></script>
113 <script language="JavaScript" type="text/javascript">
114
115
116 function LegendTemplateLayerInfo(layername)
117 {
118   window.open( "./LegendInfo.phtml?layerName=" + layername + "&<?php echo SID ?>", "legendinfo", "width=600,height=400,toolbar=no,menubar=no,status=no,resizable=yes,scrollbars=yes,locationbar=no,location=no");
119 }
120
121 function OkButtonClicked()
122 {
123     document.forms[0].OkClicked.value = "1";
124     applyChanges();
125
126 }
127
128 function applyChanges()
129 {
130     document.forms[0].ApplyClicked.value = "1";
131     document.forms[0].submit();
132 }
133
134 function CloseWindow()
135 {
136     window.close();
137 }
138
139 function OnLoadFunc()
140 {
141     <?php
142         if (isset($http_form_vars["ApplyClicked"]) &&
143               $http_form_vars["ApplyClicked"] == 1)
144         {
145             if (isset($http_form_vars["szCallbackFunc"]) &&
146                 $http_form_vars["szCallbackFunc"] != "")
147             {
148                 $szEcho = "opener." . $http_form_vars["szCallbackFunc"] . "();\n";
149                 echo $szEcho;
150             }
151             else
152             {
153               $szEcho = "opener.document.forms[0].submit();\n";
154               echo $szEcho;
155             }
156
157             if (isset($http_form_vars["OkClicked"]) &&
158               $http_form_vars["OkClicked"] == 1)
159             {
160                 echo "window.close() \n";
161             }
162         }
163     ?>
164 }
165 </script>
166 <body class="page" onLoad="self.focus();OnLoadFunc();">
167
168 <form  method="POST" action="LegendTemplatePopup.phtml?<?php echo SID; ?>">
169 <input type="hidden" name="szCallbackFunc" value="<?php if (isset($http_form_vars['szCallbackFunc'])) echo $http_form_vars['szCallbackFunc']; ?>">
170 <input type="hidden" name="set_layer" value="1">
171 <input type="hidden" name="OkClicked" value="">
172 <input type="hidden" name="ApplyClicked" value="">
173
174 <table border="0" cellpadding="1" cellspacing="10">
175     <tr>
176         <td class="layoutTable">
177           <table class="titleArea" width="100%" border="0" cellpadding="4" cellspacing="0">
178             <tr>
179               <td><span class="title"><?php echo $oMLT->get("0", "Legend");?></span></td>
180             </tr>
181           </table>
182           <table class="contentArea" width="100%" border="0" cellpadding="4" cellspacing="0">
183             <tr>
184               <td align="center"><p class="helpArea"><?php echo $oMLT->get("1", "The legend displays the layers in your map.");?></p></td>
185             </tr>
186           </table>
187           <table class="contentArea" border="0" cellspacing="0" cellpadding="4" width="100%">
188                 <?php echo $szLegendTemplate; ?>
189           </table>
190          </td>
191      </tr>
192     <tr>
193       <td align="right">
194         <table border="0" cellspacing="0" cellpadding="0">
195           <tr>
196             <td><?php echo makeButton( 'OkButtonClicked', '', 'LegendTemplate', "images/icon_update.png", $oCommonMLT->get( "Ok", "Ok" ), "Apply and Close", array( 'width' => 75 ) ); ?></td>
197             <td>&nbsp;&nbsp;</td>
198             <td><?php echo makeButton('applyChanges', '', 'LegendTemplate', "images/icon_update.png", $oCommonMLT->get( "Apply", "Apply" ), "Apply", array( 'width' => 75 ) ); ?></td>
199             <td>&nbsp;&nbsp;</td>
200             <td><?php echo makeButton('CloseWindow', '', 'LegendTemplate', "images/icon_cancel.png", $oCommonMLT->get( "Cancel", "Cancel" ), "Close Dialog", array( 'width' => 75 ) ); ?></td>
201           </tr>
202         </table>
203       </td>
204    </tr>
205 </table>
206 <input type="hidden" name="controlvisibility" value="<?php echo (isset($http_form_vars['controlvisibility']) ? $http_form_vars['controlvisibility'] : '1' ) ?>">
207 </form>
208 </body>
209 </html>
Note: See TracBrowser for help on using the browser.