1: <?php
2: 3: 4: 5: 6:
7:
8: class QFileAssetDialog extends QDialog {
9: public $lblMessage;
10: public $flcFileAsset;
11: public $lblError;
12: public $btnUpload;
13: public $btnCancel;
14: public $objSpinner;
15: protected $strFileUploadCallback;
16:
17: public function __construct($objParentObject, $strFileUploadCallback, $strControlId = null) {
18:
19: parent::__construct($objParentObject, $strControlId);
20: $this->strFileUploadCallback = $strFileUploadCallback;
21:
22:
23: $this->strTemplate = __DOCROOT__ . __PHP_ASSETS__ . '/QFileAssetDialog.tpl.php';
24:
25:
26: $this->AutoOpen = false;
27:
28: $this->strTitle = QApplication::Translate("Upload a File");
29:
30:
31: $this->lblMessage = new QLabel($this);
32: $this->lblMessage->HtmlEntities = false;
33:
34: $this->lblError = new QLabel($this);
35: $this->lblError->HtmlEntities = false;
36:
37: $this->flcFileAsset = new QFileControl($this);
38: $this->btnUpload = new QButton($this);
39: $this->btnCancel = new QButton($this);
40: $this->objSpinner = new QWaitIcon($this);
41:
42:
43: $this->flcFileAsset->AddAction(new QEnterKeyEvent(), new QTerminateAction());
44:
45: $this->btnUpload->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnUpload));
46: $this->btnUpload->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnCancel));
47: $this->btnUpload->AddAction(new QClickEvent(), new QToggleDisplayAction($this->objSpinner));
48: $this->btnUpload->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnUpload_Click'));
49:
50: $this->btnCancel->AddAction(new QClickEvent(), new QHideDialog($this));
51: }
52:
53: public function btnUpload_Click($strFormId, $strControlId, $strParameter) {
54: $this->btnUpload->Enabled = true;
55: $this->btnCancel->Enabled = true;
56: $this->objSpinner->Display = false;
57:
58: $strFileControlCallback = $this->strFileUploadCallback;
59:
60: if (isset($this->objParentControl)) {
61: $parent = $this->objParentControl;
62: } else {
63: $parent = $this->objForm;
64: }
65: $parent->$strFileControlCallback($strFormId, $strControlId, $strParameter);
66: }
67:
68: public function ShowError($strErrorMessage) {
69: $this->lblError->Text = $strErrorMessage;
70: $this->flcFileAsset->Focus();
71: $this->Blink();
72: }
73: }