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

root/Chameleon/trunk/Chameleon/ErrorReport/ErrorReport.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * ErrorReport Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id:
7  * @purpose     ErrorReport 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  * ErrorReport
35  *
36  * @desc ErrorReport widget class
37  */
38 class ErrorReport extends CWCWidget
39 {
40     var $moButton;
41     var $moPopup;          /// Popup object
42
43     /**
44      * ErrorReport
45      *
46      * Constctor method for the ErrorReport widget.
47      */
48     function ErrorReport()
49     {
50         parent::CWCWidget();
51
52         // set the description for this widget
53         $this->szWidgetDescription = <<<EOT
54 This is a utility widget used to display errors that have occurred during
55 processing.  Normally the errors are non-fatal, but could be useful in
56 debugging widgets or a new template.
57 EOT;
58
59         $this->mnPriority = PRIORITY_LAST;
60
61         $this->moPopup = new CWCPopup($this);
62         $this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/ErrorReport/ErrorReportPopup.phtml";
63         $this->moButton = new CWCButton($this);
64         $this->mnMaturityLevel = MATURITY_TECHNICALRELEASE;
65     }
66
67     /**
68      * initialize default values from tag
69      */
70     function InitDefaults()
71     {
72         parent::InitDefaults();
73         //this widget should never belong to a toolset
74         $this->maParams["TOOLSET"] = "";
75
76         if ($this->mbVisible)
77         {
78             $this->moButton->InitDefaults();
79             $this->moButton->SetOnClick( "DisplayErrors" );
80         }
81         $this->moPopup->InitDefaults();
82     }
83    
84     function GetJavascriptVariables()
85     {
86         if ($this->mbVisible)
87             return $this->moButton->GetJavascriptVariables();
88         else return array();
89     }
90
91     function GetJavascriptInitFunctions()
92     {
93         if ($this->mbVisible)
94             return $this->moButton->GetJavascriptInitFunctions();
95         else return array();
96     }
97
98     function GetJavascriptIncludeFunctions()
99     {
100         if ($this->mbVisible)
101             $aReturn = $this->moButton->GetJavascriptIncludeFunctions();
102         else
103             $aReturn = array();
104         return $aReturn;
105     }
106
107     /**
108      * GetJavascriptFunctions
109      *
110      * Build and return the array of functions needed in the
111      * widget.
112      */
113     function GetJavascriptFunctions()
114     {
115         $aReturn = array();
116
117         if ($this->mbVisible)
118             $this->moPopup->mszParam .= "&bOpenedManualy=1";
119
120         $szJsFunctionName = "DisplayErrors";
121         $szFunction = "function $szJsFunctionName()\n" .
122         "{\n".
123           $this->moPopup->DrawPublish()."\n".
124         "return;\n" .
125         "}\n";
126
127         $aReturn[$szJsFunctionName] = $szFunction;
128
129         return $aReturn;
130     }
131
132     /**
133      * GetJavascriptOnLoadFunctions
134      *
135      * Should be redefined for Widgets returning Javascript code.
136      *
137      * @returns An empty  string.
138      */
139     function GetJavascriptOnLoadFunctions()
140     {
141         if ($this->mbVisible)
142                     $aReturn = $this->moButton->GetJavascriptOnLoadFunctions();
143                 else
144             $aReturn = array();
145            
146         if ($_SESSION['gErrorManager']->nErrorCount > 0)
147         {
148             $szJsFunctionName = "DisplayErrors";
149             $szFunction = "$szJsFunctionName();\n";
150             $aReturn[$szJsFunctionName] = $szFunction;
151         }
152
153         return $aReturn;
154     }
155
156     function GetHTMLHiddenVariables()
157     {
158         $aReturn = $this->moButton->GetHTMLHiddenVariables();
159        
160         return $aReturn;
161     }
162
163     /**
164      * DrawPublish
165      *
166      * Return the HTML code to display the link to the legend popup
167      */
168     function DrawPublish()
169     {
170         $szReturn = "";
171
172         //this would normally be done by Popup.php in it's draw publish.
173         $this->moPopup->SetStyleResource();
174
175         if (!$this->mbVisible)
176         {
177             return "<!-- ErrorReport widget hidden -->";
178         }
179        
180         $szReturn = $this->moButton->DrawPublish();
181
182         return $szReturn;
183     }
184 }
185 ?>
Note: See TracBrowser for help on using the browser.