1 |
<?php |
---|
2 |
/** |
---|
3 |
* VarSharedResource Widget class |
---|
4 |
* |
---|
5 |
* @project CWC2 |
---|
6 |
* @revision $Id: |
---|
7 |
* @purpose VarSharedResource Widget class |
---|
8 |
* @author DM Solutions Group (lacroix@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__)."/../SharedResource/SharedResource.widget.php"); |
---|
33 |
|
---|
34 |
/** |
---|
35 |
* VarURLWidget |
---|
36 |
* |
---|
37 |
* @desc Widget That return the value of a URL variable |
---|
38 |
*/ |
---|
39 |
class VarSharedResource extends CWCWidget |
---|
40 |
{ |
---|
41 |
var $mszVar = ""; |
---|
42 |
|
---|
43 |
/** |
---|
44 |
* VarSharedResourceWidget |
---|
45 |
* |
---|
46 |
* Constructor method for the VarSharedResource widget. |
---|
47 |
*/ |
---|
48 |
function VarSharedResource() |
---|
49 |
{ |
---|
50 |
// invoke constructor of parent |
---|
51 |
parent::CWCWidget(); |
---|
52 |
|
---|
53 |
// set the description for this widget |
---|
54 |
$this->szWidgetDescription = <<<EOT |
---|
55 |
VarSharedResourceWidget is a simple widget that simply return the value from a SharedResource variable. |
---|
56 |
EOT; |
---|
57 |
$this->maAttributes["SRVAR"] = |
---|
58 |
new StringAttribute( "SRVAR", true ); |
---|
59 |
|
---|
60 |
$this->maAttributes["PREFIX"] = |
---|
61 |
new StringAttribute( "PREFIX", false ); |
---|
62 |
|
---|
63 |
$this->maAttributes["SUFIX"] = |
---|
64 |
new StringAttribute( "SUFIX", false ); |
---|
65 |
$this->mnMaturityLevel = MATURITY_BETA; |
---|
66 |
} |
---|
67 |
|
---|
68 |
function InitDefaults() |
---|
69 |
{ |
---|
70 |
parent::InitDefaults(); |
---|
71 |
|
---|
72 |
if (isset($this->maParams["SRVAR"])) |
---|
73 |
$this->mszVar = $this->maParams["SRVAR"]; |
---|
74 |
} |
---|
75 |
|
---|
76 |
/** |
---|
77 |
* DrawPublish |
---|
78 |
* |
---|
79 |
* Return the HTML code using the name in the map file and the |
---|
80 |
* parameters of the CWC tag. |
---|
81 |
*/ |
---|
82 |
function DrawPublish() |
---|
83 |
{ |
---|
84 |
$szReturn = ""; |
---|
85 |
$aszSRParams = explode(".", $this->mszVar); |
---|
86 |
$numParams = count($aszSRParams); |
---|
87 |
$oSR =& $this->maSharedResourceWidgets; |
---|
88 |
for($i=0; $i<$numParams; $i++) |
---|
89 |
{ |
---|
90 |
if(isset($oSR[$aszSRParams[$i]]) && $i < $numParams) |
---|
91 |
{ |
---|
92 |
$oSR =& $oSR[$aszSRParams[$i]]; |
---|
93 |
} |
---|
94 |
else |
---|
95 |
{ |
---|
96 |
break; |
---|
97 |
} |
---|
98 |
} |
---|
99 |
|
---|
100 |
$szReturn = ""; |
---|
101 |
if($i == $numParams && $oSR != "") |
---|
102 |
{ |
---|
103 |
if(isset($this->maParams["PREFIX"])) |
---|
104 |
$szReturn .= $this->maParams["PREFIX"]; |
---|
105 |
|
---|
106 |
$szReturn .= $oSR; |
---|
107 |
|
---|
108 |
if(isset($this->maParams["SUFIX"])) |
---|
109 |
$szReturn .= $this->maParams["SUFIX"]; |
---|
110 |
} |
---|
111 |
|
---|
112 |
return $szReturn; |
---|
113 |
} |
---|
114 |
} |
---|
115 |
?> |
---|