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

root/Chameleon/trunk/Chameleon/PrintProduction/PrintProduction.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * PrintPopup Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id: PrintProduction.widget.php,v 1.10 2004/11/16 15:23:40 pspencer Exp $
7  * @purpose     PrintProduction 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 include_once(dirname(__FILE__)."/../Popup.php");
32
33 /**
34  * PrintPopup
35  *
36  * @desc PrintProduction widget class
37  */
38 class PrintProduction extends CWCWidget
39 {
40     var $mszTemplate;      /// [string]
41
42     var $moButton;     /// Button object
43     var $moPopup;          /// Popup object
44
45
46     /**
47      * PrintProduction
48      *
49      * Constctor method for the PrintPopup widget.
50      */
51     function PrintProduction()
52     {
53         $this->mszLanguageResource = str_replace("\\","/",dirname(__FILE__))."/Print.dbf";
54
55         // invoke constructor of parent
56         parent::CWCWidget();
57
58         // set the description for this widget
59         $this->szWidgetDescription = <<<EOT
60 The PrintPopup widget displays a popup dialog that allows the user to
61 create a printable version of the map with some additional cartographic
62 annotations.
63 EOT;
64
65         $this->moButton = new CWCButton($this);
66         $this->moPopup = new CWCPopup($this);
67         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/PrintProduction/production.phtml";
68
69         $this->maAttributes["TEMPLATE"] = new StringAttribute( "TEMPLATE", false );
70         $this->mnMaturityLevel = MATURITY_BETA;
71     }
72
73     function InitDefaults()
74     {
75         parent::InitDefaults();
76         //this widget should never belong to a toolset
77         $this->maParams["TOOLSET"] = "";
78         $this->moButton->InitDefaults();
79         $this->moPopup->InitDefaults();
80         $szTemplate = $this->GetValue("Template");
81         if ($szTemplate != "")
82         {
83             $this->moButton->SetOnClick("clickPrintPopup");
84         }
85         else
86         {
87             $this->moButton->SetOnClick("errorPrintPopup", trim($this->moMLT->get("0", "ERROR: No legend template specified.")));
88         }
89     }
90
91     function GetJavascriptVariables()
92     {
93         if ($this->mbVisible)
94             return $this->moButton->GetJavascriptVariables();
95         else return array();
96     }
97
98     function GetJavascriptInitFunctions()
99     {
100         if ($this->mbVisible)
101             return $this->moButton->GetJavascriptInitFunctions();
102         else return array();
103     }
104
105     function GetJavascriptOnLoadFunctions()
106     {
107         if ($this->mbVisible)
108             $aReturn = $this->moButton->GetJavascriptOnLoadFunctions();
109         else
110             $aReturn = array();
111         return $aReturn;
112     }
113
114     function GetJavascriptIncludeFunctions()
115     {
116         if ($this->mbVisible)
117             $aReturn = $this->moButton->GetJavascriptIncludeFunctions();
118         else
119             $aReturn = array();
120         return $aReturn;
121     }
122
123     function GetHTMLHiddenVariables()
124     {
125         $aReturn = $this->moButton->GetHTMLHiddenVariables();
126        
127         return $aReturn;
128     }
129    
130     /**
131      * GetJavascriptFunctions
132      *
133      * Build and return the array of functions needed in the
134      * widget.
135      */
136     function GetJavascriptFunctions()
137     {
138         $aReturn = array();
139
140         $szTemplate = "";
141         if (isset($this->maParams["TEMPLATE"]))
142             $this->maParams["TEMPLATE"];
143
144         if ($szTemplate != "")
145         {
146             $this->moPopup->mszParam = "&szTemplate=".urlencode($szTemplate);
147         }
148
149         $this->moPopup->mszParam .= "&MapWidth=".$this->moMapObject->oMap->width;
150         $this->moPopup->mszParam .= "&MapHeight=".$this->moMapObject->oMap->height;
151
152         $szJsFunctionName = "clickPrintPopup";
153         $szFunction = "function $szJsFunctionName()\n" .
154          "{\n".
155           $this->moPopup->DrawPublish()."\n".
156         "return;\n" .
157         "}\n";
158         $aReturn[$szJsFunctionName] = $szFunction;
159
160         $szJsFunctionName = "errorPrintPopup";
161         $szFunction = "function $szJsFunctionName(obj, szError)\n" .
162          "{\n".
163           "    alert(szError);"."\n".
164         "    return;\n" .
165         "}\n";
166         $aReturn[$szJsFunctionName] = $szFunction;
167
168         return $aReturn;
169     }
170
171     /**
172      * DrawPublish
173      *
174      * Return the HTML code to display the link to the legend popup
175      */
176     function DrawPublish()
177     {
178         //if a wait image is specified, set it in the session for the popup
179         if (!isset($_SESSION['WAITIMAGE']))
180         {
181             $oApp = GetChameleonApplication();
182             if (isset($this->maSharedResourceWidgets["WaitImage"]->maszContents["WAITIMAGE"]))
183             {
184                 foreach($this->maSharedResourceWidgets["WaitImage"]->maszContents["WAITIMAGE"] as $aWaitImage)
185                 {
186                     if (isset($aWaitImage["LANGUAGE"]) && $aWaitImage["LANGUAGE"] == $_SESSION["gszCurrentLanguage"])
187                     {
188                         if (isset($aWaitImage["WAITIMAGE"]))
189                         {
190                             $wait = $aWaitImage["WAITIMAGE"];
191                             if (strcasecmp( "http://", substr($wait, 0, 7)) == 0 ||
192                                 strcasecmp( "/", substr($wait, 0, 1)) == 0 ||
193                                 strcasecmp( ":", substr($wait, 1, 1)) == 0 )
194                                 $_SESSION["WAITIMAGE"] = $aWaitImage["WAITIMAGE"];
195                             else
196                                 $_SESSION["WAITIMAGE"] = $oApp->findFile($aWaitImage["WAITIMAGE"]);
197                                 $_SESSION["WAITIMAGE"] = $oApp->fileSystemToURL( $_SESSION['WAITIMAGE'] );
198                         }
199                         if (isset($aWaitImage["WAITIMAGEWIDTH"]))
200                             $_SESSION["WAITIMAGEWIDTH"] = $aWaitImage["WAITIMAGEWIDTH"];
201                         if (isset($aWaitImage["WAITIMAGEHEIGHT"]))
202                             $_SESSION["WAITIMAGEHEIGHT"] = $aWaitImage["WAITIMAGEHEIGHT"];
203                     }
204                 }
205             }
206         }
207
208
209         $szReturn = parent::DrawPublish();
210
211         $szReturn = $this->moButton->DrawPublish();
212
213         return $szReturn;
214     }
215 }
216 ?>
Note: See TracBrowser for help on using the browser.