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

root/Chameleon/trunk/Chameleon/VarURL/VarURL.widget.php

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

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * VarURL Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id:
7  * @purpose     VarURL 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
30
31 include_once(dirname(__FILE__)."/../Widget.php");
32
33 /**
34  * VarURLWidget
35  *
36  * @desc Widget That return the value of a URL variable
37  */
38 class VarURL extends CWCWidget
39 {
40     var $mbKeepState = false;
41
42     /**
43      * VarURLWidget
44      *
45      * Constructor method for the VarURL widget.
46      */
47     function VarURL()
48     {
49         // invoke constructor of parent
50         parent::CWCWidget();
51
52         // set the description for this widget
53         $this->szWidgetDescription = <<<EOT
54 VarURLWidget is a simple widget that simply return the value from a URL variable.
55 EOT;
56         $this->maAttributes["URLVAR"] =
57                  new StringAttribute( "URLVAR", true );
58
59         $this->maAttributes["PREFIX"] =
60                  new StringAttribute( "PREFIX", false );
61
62         $this->maAttributes["SUFIX"] =
63                  new StringAttribute( "SUFIX", false );
64
65         $this->maAttributes["KEEPSTATE"] =
66                  new BooleanAttribute( "KEEPSTATE", false );
67         $this->mnMaturityLevel = MATURITY_BETA;
68     }
69
70     /**
71      * initialize respectable defaults
72      */
73     function InitDefaults()
74     {
75         parent::InitDefaults();
76         $this->mbKeepState = false;
77         $szKeepState = "false";
78         if (isset($this->maParams["KEEPSTATE"]))
79             $szKeepState = $this->maParams["KEEPSTATE"];
80         if (strcasecmp( $szKeepState , "true" ) == 0)
81         {
82             $this->mbKeepState = true;
83         }
84     }
85
86     /**
87      * DrawPublish
88      *
89      * Return the HTML code using the name in the map file and the
90      * parameters of the CWC tag.
91      */
92     function DrawPublish()
93     {
94         $szReturn = "";
95
96         if($this->isVarSet( strtoupper($this->maParams["URLVAR"]) ) &&
97            $this->getVar( strtoupper($this->maParams["URLVAR"]) ) != "")
98         {
99             if(isset($this->maParams["PREFIX"]))
100                 $szReturn .= urldecode($this->maParams["PREFIX"]);
101
102             $szReturn .= stripslashes(urldecode($this->getVar( strtoupper($this->maParams["URLVAR"]) )));
103
104             if(isset($this->maParams["SUFIX"]))
105                 $szReturn .= urldecode($this->maParams["SUFIX"]);
106         }
107
108         return $szReturn;
109     }
110
111     /**
112      * GetHTMLHiddenVariables
113      *
114      * Returnrs an empty  string. Should be redefined for Widgets
115      * returning hidden variables
116      */
117     function GetHTMLHiddenVariables()
118     {
119         if ($this->mbKeepState)
120         {
121             $szVariable = strtoupper($this->maParams["URLVAR"]);
122             if($this->isVarSet( $this->maParams["URLVAR"] ))
123                 $szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"".
124                     $this->getVar( $this->maParams["URLVAR"] )."\">";
125             else
126                 $szValue = "";
127
128             return array($szVariable => $szValue);
129         }
130
131         return array();
132     }
133 }
134 ?>
Note: See TracBrowser for help on using the browser.