1: <?php
2: 3: 4: 5: 6:
7:
8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18: class QDialogBox extends QPanel {
19: protected $strTitle = "";
20: protected $strJavaScripts = __JQUERY_EFFECTS__;
21: protected $strStyleSheets = __JQUERY_CSS__;
22:
23:
24: protected $strMatteColor = '#000000';
25: protected $intMatteOpacity = 50;
26: protected $strDialogWidth = '350';
27:
28:
29:
30: protected $blnMatteClickable = true;
31: protected $blnAnyKeyCloses = false;
32:
33: protected $blnModal = true;
34:
35: public function __construct($objParentObject, $strControlId = null) {
36: parent::__construct($objParentObject, $strControlId);
37: $this->blnDisplay = false;
38: }
39:
40: public function GetShowDialogJavaScript() {
41: $strOptions = 'autoOpen: false';
42: $strOptions .= ', modal: '.($this->blnModal ? 'true' : 'false');
43: if ($this->strTitle)
44: $strOptions .= ', title: "'.$this->strTitle.'"';
45: if ($this->strCssClass)
46: $strOptions .= ', dialogClass: "'.$this->strCssClass.'"';
47: if (null === $this->strDialogWidth)
48: $strOptions .= ", width: 'auto'";
49: else if ($this->strDialogWidth)
50: $strOptions .= ', width: '. $this->strDialogWidth;
51: if (null === $this->strHeight)
52: $strOptions .= ", height: 'auto'";
53: else if ($this->strHeight)
54: $strOptions .= ', height: '. $this->strHeight;
55:
56: $strOptions .= ', open: function() { $j(this).parent().appendTo($j("form:first")); }';
57:
58: return sprintf('$j(qc.getW("%s")).dialog({%s}).dialog("open");', $this->strControlId, $strOptions, $this->strControlId);
59: }
60:
61: public function GetHideDialogJavaScript() {
62: return sprintf('var $dlg = $j(qc.getW("%s")); if($dlg.is(":ui-dialog")) { $dlg.dialog("close"); }', $this->strControlId);
63: }
64:
65: public function ShowDialogBox() {
66: if (!$this->blnVisible)
67: $this->Visible = true;
68: if (!$this->blnDisplay)
69: $this->Display = true;
70: QApplication::ExecuteJavaScript($this->GetShowDialogJavaScript());
71: $this->blnWrapperModified = false;
72: }
73:
74: public function HideDialogBox() {
75: $this->blnDisplay = false;
76: QApplication::ExecuteJavaScript($this->GetHideDialogJavaScript());
77: $this->blnWrapperModified = false;
78: }
79:
80: public function GetEndScript() {
81: $strToReturn = parent::GetEndScript();
82: if ($this->Visible && $this->Display) {
83: $strToReturn .= "; ". $this->GetShowDialogJavaScript();
84: }
85: return $strToReturn;
86: }
87:
88:
89:
90:
91: 92: 93: 94: 95: 96: 97: 98:
99: public function __get($strName) {
100: switch ($strName) {
101:
102: case "Width": return $this->strDialogWidth;
103: case "Title": return $this->strTitle;
104: case "MatteColor": return $this->strMatteColor;
105: case "MatteOpacity": return $this->intMatteOpacity;
106:
107:
108: case "MatteClickable": return $this->blnMatteClickable;
109: case "AnyKeyCloses": return $this->blnAnyKeyCloses;
110: case "Modal": return $this->blnModal;
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: 126: 127: 128: 129: 130:
131: public function __set($strName, $mixValue) {
132: $this->blnModified = true;
133:
134: switch ($strName) {
135: case "Title":
136: try {
137: $this->strTitle = QType::Cast($mixValue, QType::String);
138: break;
139: } catch (QInvalidCastException $objExc) {
140: $objExc->IncrementOffset();
141: throw $objExc;
142: }
143:
144: case "MatteColor":
145: try {
146: $this->strMatteColor = QType::Cast($mixValue, QType::String);
147: break;
148: } catch (QInvalidCastException $objExc) {
149: $objExc->IncrementOffset();
150: throw $objExc;
151: }
152:
153: case "MatteOpacity":
154: try {
155: $this->intMatteOpacity = QType::Cast($mixValue, QType::Integer);
156: break;
157: } catch (QInvalidCastException $objExc) {
158: $objExc->IncrementOffset();
159: throw $objExc;
160: }
161:
162: case "MatteClickable":
163: try {
164: $this->blnMatteClickable = QType::Cast($mixValue, QType::Boolean);
165: break;
166: } catch (QInvalidCastException $objExc) {
167: $objExc->IncrementOffset();
168: throw $objExc;
169: }
170:
171: case "AnyKeyCloses":
172: try {
173: $this->blnAnyKeyCloses = QType::Cast($mixValue, QType::Boolean);
174: break;
175: } catch (QInvalidCastException $objExc) {
176: $objExc->IncrementOffset();
177: throw $objExc;
178: }
179:
180: case "Modal":
181: try {
182: $this->blnModal = QType::Cast($mixValue, QType::Boolean);
183: break;
184: } catch (QInvalidCastException $objExc) {
185: $objExc->IncrementOffset();
186: throw $objExc;
187: }
188:
189: case "Width":
190: try {
191: if (null === $mixValue || 'auto' === $mixValue) {
192: $this->strDialogWidth = null;
193: } else {
194: $mixValue = str_replace("px", "", strtolower($mixValue));
195:
196:
197: $this->strDialogWidth = QType::Cast($mixValue, QType::Integer);
198: }
199: break;
200: } catch (QInvalidCastException $objExc) {
201: $objExc->IncrementOffset();
202: throw $objExc;
203: }
204:
205: case "Height":
206: try {
207: if (null === $mixValue || 'auto' === $mixValue) {
208: $this->strHeight = null;
209: } else {
210: $mixValue = str_replace("px", "", strtolower($mixValue));
211:
212:
213: $this->strHeight = QType::Cast($mixValue, QType::Integer);
214: }
215: break;
216: } catch (QInvalidCastException $objExc) {
217: $objExc->IncrementOffset();
218: throw $objExc;
219: }
220:
221: default:
222: try {
223: parent::__set($strName, $mixValue);
224: } catch (QCallerException $objExc) {
225: $objExc->IncrementOffset();
226: throw $objExc;
227: }
228: break;
229: }
230: }
231: }