1: <?php
2: 3: 4: 5: 6:
7:
8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19: class QImageButton extends QActionControl {
20:
21:
22:
23:
24:
25: protected $strAlternateText = null;
26: protected $strImageUrl = null;
27:
28:
29: protected $blnPrimaryButton = false;
30: protected $intClickX;
31: protected $intClickY;
32:
33:
34: protected $blnActionsMustTerminate = true;
35:
36:
37:
38:
39:
40: public function GetAttributes() {
41: $strToReturn = parent::GetAttributes();
42:
43: if ($this->strAlternateText)
44: $strToReturn .= sprintf('alt="%s" ', $this->strAlternateText);
45: if ($this->strImageUrl)
46: $strToReturn .= sprintf('src="%s" ', $this->strImageUrl);
47:
48: return $strToReturn;
49: }
50:
51: public function ParsePostData() {
52: $strKeyX = sprintf('%s_x', $this->strControlId);
53: $strKeyY = sprintf('%s_y', $this->strControlId);
54: if (isset ($strKeyX) && $_POST[$strKeyX] !== '') {
55: $this->intClickX = $_POST[$strKeyX];
56: $this->intClickY = $_POST[$strKeyY];
57: }
58: 59: 60: 61: 62:
63: }
64:
65: protected function GetControlHtml() {
66: $strStyle = $this->GetStyleAttributes();
67: if ($strStyle)
68: $strStyle = sprintf('style="%s"', $strStyle);
69:
70: if ($this->blnPrimaryButton) {
71: $strToReturn = sprintf('<input type="image" name="%s" %s%s />',
72: $this->strControlId,
73: $this->GetAttributes(),
74: $strStyle);
75: } else {
76: $strToReturn = sprintf('<img %s%s />',
77: $this->GetAttributes(),
78: $strStyle);
79: }
80:
81: $strToReturn .= sprintf('<input type="hidden" name="%s_x" id="%s_x" value=""/><input type="hidden" name="%s_y" id="%s_y" value=""/>',
82: $this->strControlId,
83: $this->strControlId,
84: $this->strControlId,
85: $this->strControlId);
86:
87: return $strToReturn;
88: }
89:
90:
91:
92:
93: public function __get($strName) {
94: switch ($strName) {
95:
96: case "AlternateText": return $this->strAlternateText;
97: case "ImageUrl": return $this->strImageUrl;
98:
99:
100: case "PrimaryButton": return $this->blnPrimaryButton;
101: case "ClickX": return $this->intClickX;
102: case "ClickY": return $this->intClickY;
103:
104: default:
105: try {
106: return parent::__get($strName);
107: } catch (QCallerException $objExc) {
108: $objExc->IncrementOffset();
109: throw $objExc;
110: }
111: }
112: }
113:
114:
115:
116:
117: public function __set($strName, $mixValue) {
118: $this->blnModified = true;
119:
120: switch ($strName) {
121:
122: case "AlternateText":
123: try {
124: $this->strAlternateText = QType::Cast($mixValue, QType::String);
125: break;
126: } catch (QInvalidCastException $objExc) {
127: $objExc->IncrementOffset();
128: throw $objExc;
129: }
130: case "ImageUrl":
131: try {
132: $this->strImageUrl = QType::Cast($mixValue, QType::String);
133: break;
134: } catch (QInvalidCastException $objExc) {
135: $objExc->IncrementOffset();
136: throw $objExc;
137: }
138:
139:
140: case "PrimaryButton":
141: try {
142: $this->blnPrimaryButton = QType::Cast($mixValue, QType::Boolean);
143: break;
144: } catch (QInvalidCastException $objExc) {
145: $objExc->IncrementOffset();
146: throw $objExc;
147: }
148:
149: default:
150: try {
151: parent::__set($strName, $mixValue);
152: } catch (QCallerException $objExc) {
153: $objExc->IncrementOffset();
154: throw $objExc;
155: }
156: break;
157: }
158: }
159: }