1: <?php
2: /**
3: * This file contains the QWaitIcon class.
4: *
5: * @package Controls
6: * @filesource
7: */
8:
9: /**
10: * @package Controls
11: *
12: * @property string $Text
13: * @property string $TagName
14: * @property string $Padding
15: * @property string $HorizontalAlign
16: * @property string $VerticalAlign
17: */
18: class QWaitIcon extends QControl {
19: ///////////////////////////
20: // Private Member Variables
21: ///////////////////////////
22:
23: // APPEARANCE
24: /** @var null|string String to be displayed (e.g. "Please wait") (can be HTML) */
25: protected $strText = null;
26: /** @var null|string Padding for the rendered element */
27: protected $strPadding = null;
28: /** @var string HTML tag name to be used for rendering the text */
29: protected $strTagName = 'span';
30: /** @var bool */
31: protected $blnDisplay = false;
32:
33:
34: // LAYOUT
35: /** @var string Horizontal alignment for the text of the wait icon */
36: protected $strHorizontalAlign = QHorizontalAlign::NotSet;
37: /** @var string Vertical alignment for the wait icon */
38: protected $strVerticalAlign = QVerticalAlign::NotSet;
39:
40: /**
41: * Constructor
42: *
43: * @param QControl|QControlBase|QForm $objParentObject Parent control/form of this wait icon
44: * @param null|string $strControlId Control ID to be set for the wait icon
45: *
46: * @throws Exception|QCallerException
47: */
48: public function __construct($objParentObject, $strControlId = null) {
49: parent::__construct($objParentObject, $strControlId);
50:
51: $this->strText = sprintf('<img src="%s/spinner_14.gif" width="14" height="14" alt="Please Wait..."/>', __VIRTUAL_DIRECTORY__ . __IMAGE_ASSETS__);
52: }
53:
54: /**
55: * Returns the styles attributes for the wait icon
56: *
57: * @return string CSS style attributes as one string
58: */
59: public function GetStyleAttributes() {
60: $strStyle = parent::GetStyleAttributes();
61:
62: if ($this->strPadding)
63: $strStyle .= sprintf('padding:%s;', $this->strPadding);
64:
65: if (($this->strHorizontalAlign) && ($this->strHorizontalAlign != QHorizontalAlign::NotSet))
66: $strStyle .= sprintf('text-align:%s;', $this->strHorizontalAlign);
67:
68: if (($this->strVerticalAlign) && ($this->strVerticalAlign != QVerticalAlign::NotSet))
69: $strStyle .= sprintf('vertical-align:%s;', $this->strVerticalAlign);
70:
71: return $strStyle;
72: }
73:
74: //////////
75: // Methods
76: //////////
77: public function ParsePostData() {}
78:
79: /**
80: * Validates the wait icon (for now it just returns true)
81: *
82: * @return bool
83: */
84: public function Validate() {return true;}
85:
86: /**
87: * Returns the HTML we have to send to the browser to render this wait icon
88: * @return string HTML to be returned
89: */
90: protected function GetControlHtml() {
91: $strStyle = $this->GetStyleAttributes();
92:
93: if ($strStyle)
94: $strStyle = sprintf('style="%s"', $strStyle);
95:
96: $strToReturn = sprintf('<%s id="%s" %s%s>%s</%s>',
97: $this->strTagName,
98: $this->strControlId,
99: $this->GetAttributes(),
100: $strStyle,
101: $this->strText,
102: $this->strTagName);
103:
104: return $strToReturn;
105: }
106:
107: /////////////////////////
108: // Public Properties: GET
109: /////////////////////////
110: /**
111: * PHP magic method
112: *
113: * @param string $strName Property name
114: *
115: * @return mixed|null|string
116: * @throws Exception|QCallerException
117: */
118: public function __get($strName) {
119: switch ($strName) {
120: // APPEARANCE
121: case "Text": return $this->strText;
122: case "TagName": return $this->strTagName;
123: case "Padding": return $this->strPadding;
124:
125: // LAYOUT
126: case "HorizontalAlign": return $this->strHorizontalAlign;
127: case "VerticalAlign": return $this->strVerticalAlign;
128:
129: default:
130: try {
131: return parent::__get($strName);
132: } catch (QCallerException $objExc) {
133: $objExc->IncrementOffset();
134: throw $objExc;
135: }
136: }
137: }
138:
139: /////////////////////////
140: // Public Properties: SET
141: /////////////////////////
142: /**
143: * PHP magic method
144: *
145: * @param string $strName Property name
146: * @param string $mixValue Property value
147: *
148: * @return mixed|void
149: * @throws Exception|QCallerException|QInvalidCastException
150: */
151: public function __set($strName, $mixValue) {
152: $this->blnModified = true;
153:
154: switch ($strName) {
155: // APPEARANCE
156: case "Text":
157: try {
158: $this->strText = QType::Cast($mixValue, QType::String);
159: break;
160: } catch (QInvalidCastException $objExc) {
161: $objExc->IncrementOffset();
162: throw $objExc;
163: }
164:
165: case "TagName":
166: try {
167: $this->strTagName = QType::Cast($mixValue, QType::String);
168: break;
169: } catch (QInvalidCastException $objExc) {
170: $objExc->IncrementOffset();
171: throw $objExc;
172: }
173:
174: case "Padding":
175: try {
176: $this->strPadding = QType::Cast($mixValue, QType::String);
177: break;
178: } catch (QInvalidCastException $objExc) {
179: $objExc->IncrementOffset();
180: throw $objExc;
181: }
182:
183: case "HorizontalAlign":
184: try {
185: $this->strHorizontalAlign = QType::Cast($mixValue, QType::String);
186: break;
187: } catch (QInvalidCastException $objExc) {
188: $objExc->IncrementOffset();
189: throw $objExc;
190: }
191:
192: case "VerticalAlign":
193: try {
194: $this->strVerticalAlign = QType::Cast($mixValue, QType::String);
195: break;
196: } catch (QInvalidCastException $objExc) {
197: $objExc->IncrementOffset();
198: throw $objExc;
199: }
200:
201: default:
202: try {
203: parent::__set($strName, $mixValue);
204: } catch (QCallerException $objExc) {
205: $objExc->IncrementOffset();
206: throw $objExc;
207: }
208: break;
209: }
210: }
211: }