1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: class QModelConnectorParam extends QBaseClass {
18:
19: const SelectionList = 'list';
20:
21: const GeneralCategory = 'General';
22:
23: protected $strCategory;
24: protected $strName;
25: protected $strDescription;
26: protected $controlType;
27: protected $options;
28:
29:
30: protected $objControl;
31:
32: public function __construct($strCategory, $strName, $strDescription, $controlType, $options = null) {
33: $this->strCategory = QApplication::Translate($strCategory);
34: $this->strName = QApplication::Translate($strName);
35: $this->strDescription = QApplication::Translate($strDescription);
36: $this->controlType = $controlType;
37:
38: $this->options = $options;
39:
40: if ($controlType == QModelConnectorParam::SelectionList && !$options) {
41: throw new QCallerException ('Selection list without a list of items to select.');
42: }
43:
44: }
45:
46: 47: 48: 49: 50: 51: 52:
53: public function GetControl ($objParent = null) {
54: if ($this->objControl) {
55: if ($objParent) {
56: $this->objControl->SetParentControl($objParent);
57: }
58: return $this->objControl;
59: } elseif ($objParent) {
60: $this->objControl = $this->CreateControl($objParent);
61: return $this->objControl;
62: }
63: return null;
64: }
65:
66: 67: 68: 69: 70: 71:
72: protected function CreateControl(QControl $objParent) {
73: switch ($this->controlType) {
74: case QType::Boolean:
75: $ctl = new QRadioButtonList($objParent);
76: $ctl->AddItem('True', true);
77: $ctl->AddItem('False', false);
78: $ctl->AddItem('None', null);
79: $ctl->RepeatColumns = 3;
80: break;
81:
82: case QType::String:
83: $ctl = new QTextBox($objParent);
84: break;
85:
86: case QType::Integer:
87: $ctl = new QIntegerTextBox($objParent);
88: break;
89:
90: case QType::ArrayType:
91: $ctl = new QTextBox($objParent);
92: break;
93:
94: case QModelConnectorParam::SelectionList:
95: $ctl = new QListBox($objParent);
96:
97: foreach ($this->options as $key=>$val) {
98: $ctl->AddItem ($val, $key === '' ? null : $key);
99: }
100: break;
101:
102: default:
103: $ctl = new QTextBox($objParent);
104: break;
105:
106: }
107:
108: $ctl->Name = $this->strName;
109: $ctl->ToolTip = $this->strDescription;
110: return $ctl;
111:
112: }
113:
114: public function __get ($strName) {
115: switch ($strName) {
116: case 'Name':
117: return $this->strName;
118: break;
119:
120: case 'Category':
121: return $this->strCategory;
122: break;
123:
124: default:
125: try {
126: return parent::__get($strName);
127: } catch (QCallerException $objExc) {
128: $objExc->IncrementOffset();
129: throw $objExc;
130: }
131: }
132: }
133:
134: }
135:
136: