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

root/Chameleon/trunk/Chameleon/ExtractSR/ExtractSR.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * ExtractSR Widget Class
4  *
5  * @project     WIX
6  * @revision    $Id: ExtractSR.widget.php,v 1.5 2005/03/22 17:20:12 pspencer Exp $
7  * @purpose     Display a dialog box to extract the contents of a SharedResource
8  * @author      DM Solutions Group (pspencer@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 include_once(dirname(__FILE__)."/../Widget.php");
32 include_once(dirname(__FILE__)."/../Button.php");
33 include_once(dirname(__FILE__).'/../Popup.php');
34
35 /**
36  * ExtractSR
37  *
38  * @desc a widget that converts data in a SharedResource into a CSV file and
39  * downloads it to the user
40  */
41 class ExtractSR extends CWCWidget
42 {
43     var $moButton;
44     var $moPopup;
45     
46     var $mszSharedResource;
47
48     /**
49      * ExtractSR
50      *
51      * Constructor method for the ExtractSR
52      */
53     function ExtractSR()
54     {
55         $this->mszLanguageResource = str_replace("\\","/",dirname(__FILE__))."/ExtractSR.dbf";
56         parent::CWCWidget();
57
58         $this->moButton = new CWCButton( $this );
59         
60         $this->moPopup = new CWCPopup( $this );
61         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/ExtractSR/ExtractSR.phtml";
62
63         // set the description for this widget
64         $this->szWidgetDescription = <<<EOT
65 The ExtractSRWidget displays a popup dialog box that allows the user
66 download query results as a CSV file.
67 EOT;
68
69         $this->maAttributes['SHAREDRESOURCE'] = new StringAttribute( 'SHAREDRESOURCE', true );
70         
71         $this->mnMaturityLevel = MATURITY_BETA;
72     }
73
74     function InitDefaults()
75     {
76         parent::InitDefaults();
77         
78         //this widget should never belong to a toolset
79         $this->maParams["TOOLSET"] = "";
80         $this->moButton->InitDefaults();
81         $this->moButton->SetOnClick('clickExtractSR');
82         
83         if (isset($this->maParams['SHAREDRESOURCE']))
84             $this->mszSharedResource = $this->maParams['SHAREDRESOURCE'];
85     }
86
87     function GetJavascriptInitFunctions()
88     {
89         return $this->moButton->GetJavascriptInitFunctions();
90     }
91
92     function GetJavascriptVariables()
93     {
94         return $this->moButton->GetJavascriptVariables();
95     }
96
97     function GetJavascriptOnLoadFunctions()
98     {
99         return $this->moButton->GetJavascriptOnLoadFunctions();
100     }
101
102     function GetJavascriptIncludeFunctions()
103     {
104         return $this->moButton->GetJavascriptIncludeFunctions();
105     }
106
107     /**
108      * GetHTMLHiddenVariables
109      *
110      * return the NAV_CMD varaiable.
111      */
112     function GetHTMLHiddenVariables()
113     {
114         $aReturn = $this->moButton->GetHTMLHiddenVariables();
115         
116         return $aReturn;
117     }
118
119     /**
120      * ParseURL
121      */
122     function  ParseURL()
123     {
124         $this->moButton->ParseURL();
125         
126         return true;
127     }
128
129     /**
130      * GetJavascriptFunctions
131      *
132      * Build and return the array of functions needed in the
133      * widget.
134      */
135     function GetJavascriptFunctions()
136     {
137         $aReturn = $this->moButton->GetJavascriptFunctions();
138         $this->moPopup->mszParam = "&srname=".$this->mszSharedResource;
139         
140         $szJsFunctionName = "clickExtractSR";
141         
142         if (isset($this->maSharedResourceWidgets[$this->mszSharedResource]) &&
143             count($this->maSharedResourceWidgets[$this->mszSharedResource]) > 0)
144         {
145             $szButtonJS = $this->moPopup->DrawPublish();
146             if (is_array($this->maSharedResourceWidgets[$this->mszSharedResource]))
147             {
148                 $_SESSION['EXTRACTSR_DATA_'.$this->mszSharedResource] = $this->maSharedResourceWidgets[$this->mszSharedResource];
149             }
150             else
151             {
152                 $_SESSION['EXTRACTSR_DATA_'.$this->mszSharedResource] = $this->maSharedResourceWidgets[$this->mszSharedResource]->maszContents;
153             }
154         }
155         else
156         {
157             $szButtonJS = 'alert( "no data to extract." ); ';
158             $_SESSION['EXTRACTSR_DATA_'.$this->mszSharedResource] = array();
159         }
160         $szFunction = <<<EOT
161 /**
162  * {$szJsFunctionName}
163  * popup a ExtractSR dialog
164  */
165 function {$szJsFunctionName}()
166 {
167     {$szButtonJS}
168     return;
169 }
170 EOT;
171         $aReturn[$szJsFunctionName] = $szFunction;
172
173         return $aReturn;
174     }
175
176     /**
177      * DrawPublish
178      *
179      * Return the HTML code using the name in the map file and the
180      * parameters of the CWC tag.
181      */
182     function DrawPublish()
183     {
184         if (!$this->mbVisible)
185             return "<!-- ExtractSR widget hidden -->";
186         
187         $szResult = $this->moButton->DrawPublish();
188
189         return $szResult;
190     }
191 }
192 ?>
193
Note: See TracBrowser for help on using the browser.