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

root/Chameleon/trunk/Chameleon/ClearQueryResults/ClearQueryResults.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * ClearQueryResults Widget class
4  *
5  * @project     Flanders
6  * @revision    $Id: ClearQueryResults.widget.php,v 1.2 2004/10/14 18:19:09 pspencer Exp $
7  * @purpose     ClearQueryResults 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
32 /**
33  * ClearQueryResults
34  *
35  * @desc Display a clickable image that will clear all query results from map
36  */
37 class ClearQueryResults extends CWCWidget
38 {
39
40     /**
41      * ClearQueryResults
42      *
43      * Constructor for the ClearQueryResultsWidget
44      */
45     function ClearQueryResults( )
46     {
47         // invoke constructor of parent
48         parent::CWCWidget();
49
50         // set the description for this widget
51         $this->szWidgetDescription = <<<EOT
52 The ClearQueryResults widget allows the user to clear query results on
53 the current page without performing any other navigation.
54 EOT;
55
56         $this->moButton = new CWCButton($this);
57         $this->mnMaturityLevel = MATURITY_BETA;
58         
59     }
60
61     function InitDefaults()
62     {
63         parent::InitDefaults();
64         //this widget should never belong to a toolset
65         $this->maParams["TOOLSET"] = "";
66         $this->moButton->InitDefaults();
67         $this->moButton->SetOnClick( "clickClearQueryResults" );
68     }
69     
70     function GetJavascriptVariables()
71     {
72         if ($this->mbVisible)
73             return $this->moButton->GetJavascriptVariables();
74         else return array();
75     }
76
77     function GetJavascriptInitFunctions()
78     {
79         if ($this->mbVisible)
80             return $this->moButton->GetJavascriptInitFunctions();
81         else return array();
82     }
83
84     function GetJavascriptOnLoadFunctions()
85     {
86         if ($this->mbVisible)
87             $aReturn = $this->moButton->GetJavascriptOnLoadFunctions();
88         else
89             $aReturn = array();
90         return $aReturn;
91     }
92
93     function GetJavascriptIncludeFunctions()
94     {
95         if ($this->mbVisible)
96             $aReturn = $this->moButton->GetJavascriptIncludeFunctions();
97         else
98             $aReturn = array();
99         return $aReturn;
100     }
101     /**
102      * ParseURL
103      *
104      * Look for the CLEAR_POINTS command and if found clear all
105      * user created points.
106      */
107     function  ParseURL()
108     {
109         parent::ParseURL();
110
111         // return success
112         return true;
113     }
114
115     /**
116      * GetHTMLHiddenVariables
117      *
118      * Return HTML hidden variables.
119      */
120     function GetHTMLHiddenVariables()
121     {
122         $aReturn = $this->moButton->GetHTMLHiddenVariables();
123         
124         return $aReturn;
125     }
126
127     /**
128      * GetJavascriptFunctions
129      *
130      * Return the Javacriptfunctions needed by the widget.
131      */
132     function GetJavascriptFunctions()
133     {
134         $aReturn = array();
135
136         $szJsFunctionName = "clickClearQueryResults";
137         $szFunction = <<<EOT
138 /**
139  * {$szJsFunctionName}
140  * called when the user clicks the ClearQueryResults icon
141  */
142 function {$szJsFunctionName}()
143 {
144     var img = CWCDHTML_GetImage( 'MapLayerDivImg' );
145     var url = gMapDHTMLURL;
146     var d = new Date();
147     var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
148     url = url + "&UniqId="+unique;
149     img.src = url + "&gszPersistentQuery=false";
150     return true;
151 }
152 EOT;
153         $aReturn[$szJsFunctionName] = $szFunction;
154
155         return $aReturn;
156     }
157
158     /**
159      * DrawPublish
160      *
161      * Return the HTML code using the name in the map file and the
162      * parameters of the CWC tag.
163      */
164     function DrawPublish()
165     {
166         if (!$this->mbVisible)
167             return "<!-- ClearQueryResults widget hidden -->";
168         return $this->moButton->DrawPublish();
169     }
170 }
171 ?>
172
Note: See TracBrowser for help on using the browser.