1: <?php
2: 3: 4: 5: 6:
7:
8: 9: 10: 11: 12: 13: 14: 15:
16: class QImageRollover extends QControl {
17:
18:
19:
20:
21:
22: protected $mixImageStandard;
23: protected $mixImageHover;
24: protected $strLinkUrl;
25: protected $strCustomLinkStyleArray = array();
26:
27: protected $objLinkStyler;
28:
29:
30:
31:
32: public function ParsePostData() {}
33:
34: 35: 36: 37:
38: public function GetLinkStyler() {
39: if (!$this->objLinkStyler) {
40: $this->objLinkStyler = new QTagStyler();
41: }
42: return $this->objLinkStyler;
43: }
44:
45: 46: 47: 48: 49: 50:
51: public function SetCustomLinkStyle($strName, $strValue) {
52: if ($this->GetLinkStyler()->SetCssStyle($strName, $strValue)) {
53: $this->blnModified = true;
54: }
55: }
56:
57: public function GetCustomLinkStyle($strName) {
58: return $this->GetLinkStyler()->GetCssStyle($strName);
59: }
60:
61: public function RemoveCustomLinkStyle($strName) {
62: if ($this->RemoveCssStyle($strName)) {
63: $this->blnModified = true;
64: }
65: }
66:
67: protected function GetControlHtml() {
68: $attrOverrides['id'] = ($this->strLinkUrl) ? $this->strControlId . '_img' : $this->strControlId;
69: $attrOverrides['src'] = ($this->mixImageStandard instanceof QImageBase) ? $this->mixImageStandard->RenderAsImgSrc(false) : $this->mixImageStandard;
70: if (!$this->AltText) {
71: $attrOverrides['alt'] = $this->ToolTip;
72: }
73: $strHtml = $this->RenderTag ('img', $attrOverrides, null, null, true);
74:
75: if ($this->strLinkUrl) {
76: $linkOverrides['href'] = $this->strLinkUrl;
77: $linkOverrides['id'] = $this->strControlId;
78: $linkOverrides['name'] = $this->strControlId;
79: $this->GetLinkStyler()->ToolTip = $this->ToolTip;
80: $strLinkAttributes = $this->GetLinkStyler()->RenderHtmlAttributes($linkOverrides);
81: $strHtml = QHtml::RenderTag('a', $strLinkAttributes, $strHtml);
82: }
83: return $strHtml;
84: }
85:
86: public function GetEndScript() {
87: $strToReturn = parent::GetEndScript();
88: $strControlId = ($this->strLinkUrl) ? $this->strControlId . '_img' : $this->strControlId;
89: if ($this->blnVisible && $this->mixImageHover) {
90: $strToReturn .= sprintf('$j("#%s").hover(function(){$j("#%s").attr("src", "%s"); }, function(){$j("#%s").attr("src", "%s"); });', $strControlId,
91: $strControlId,
92: ($this->mixImageHover instanceof QImageBase) ? $this->mixImageHover->RenderAsImgSrc(false) : $this->mixImageHover,
93: $strControlId,
94: ($this->mixImageStandard instanceof QImageBase) ? $this->mixImageStandard->RenderAsImgSrc(false) : $this->mixImageStandard
95: );
96: }
97: return $strToReturn;
98: }
99:
100: public function Validate() {return true;}
101:
102:
103:
104:
105: public function __get($strName) {
106: switch ($strName) {
107:
108: case "ImageStandard": return $this->mixImageStandard;
109: case "ImageHover": return $this->mixImageHover;
110: case "LinkUrl": return $this->strLinkUrl;
111:
112: default:
113: try {
114: return parent::__get($strName);
115: } catch (QCallerException $objExc) {
116: $objExc->IncrementOffset();
117: throw $objExc;
118: }
119: }
120: }
121:
122:
123:
124:
125: public function __set($strName, $mixValue) {
126: $this->blnModified = true;
127:
128: switch ($strName) {
129: case "ImageStandard":
130: try {
131: if ($mixValue instanceof QImageBase)
132: $this->mixImageStandard = $mixValue;
133: else
134: $this->mixImageStandard = QType::Cast($mixValue, QType::String);
135: break;
136: } catch (QInvalidCastException $objExc) {
137: $objExc->IncrementOffset();
138: throw $objExc;
139: }
140: case "ImageHover":
141: try {
142: if ($mixValue instanceof QImageBase)
143: $this->mixImageHover = $mixValue;
144: else
145: $this->mixImageHover = QType::Cast($mixValue, QType::String);
146: break;
147: } catch (QInvalidCastException $objExc) {
148: $objExc->IncrementOffset();
149: throw $objExc;
150: }
151:
152: case "LinkUrl":
153: try {
154: $this->strLinkUrl = QType::Cast($mixValue, QType::String);
155: break;
156: } catch (QInvalidCastException $objExc) {
157: $objExc->IncrementOffset();
158: throw $objExc;
159: }
160:
161: default:
162: try {
163: parent::__set($strName, $mixValue);
164: } catch (QCallerException $objExc) {
165: $objExc->IncrementOffset();
166: throw $objExc;
167: }
168: break;
169: }
170: }
171: }