1: <?php
2:
3: class QCheckBoxBase_CodeGenerator extends QControl_CodeGenerator {
4: public function __construct($strControlClassName = 'QCheckBox') {
5: parent::__construct($strControlClassName);
6: }
7:
8: 9: 10: 11:
12: public function VarName($strPropName) {
13: return 'chk' . $strPropName;
14: }
15:
16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: public function ConnectorCreate(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn) {
27: $strObjectName = $objCodeGen->ModelVariableName($objTable->Name);
28: $strControlVarName = $objCodeGen->ModelConnectorVariableName($objColumn);
29: $strLabelName = addslashes(QCodeGen::ModelConnectorControlName($objColumn));
30:
31:
32: $strControlType = $objCodeGen->GetControlCodeGenerator($objColumn)->GetControlClass();
33:
34: $strRet = <<<TMPL
35: /**
36: * Create and setup a $strControlType $strControlVarName
37: * @param string \$strControlId optional ControlId to use
38: * @return $strControlType
39: */
40: public function {$strControlVarName}_Create(\$strControlId = null) {
41:
42: TMPL;
43: $strControlIdOverride = $objCodeGen->GenerateControlId($objTable, $objColumn);
44:
45: if ($strControlIdOverride) {
46: $strRet .= <<<TMPL
47: if (!\$strControlId) {
48: \$strControlId = '$strControlIdOverride';
49: }
50:
51: TMPL;
52: }
53: $strRet .= <<<TMPL
54: \$this->{$strControlVarName} = new $strControlType(\$this->objParentObject, \$strControlId);
55: \$this->{$strControlVarName}->Name = QApplication::Translate('$strLabelName');
56: \$this->{$strControlVarName}->Checked = \$this->{$strObjectName}->{$objColumn->PropertyName};
57:
58: TMPL;
59:
60: if ($strMethod = QCodeGen::$PreferredRenderMethod) {
61: $strRet .= <<<TMPL
62: \$this->{$strControlVarName}->PreferredRenderMethod = '$strMethod';
63:
64: TMPL;
65: }
66: $strRet .= $this->ConnectorCreateOptions($objCodeGen, $objTable, $objColumn, $strControlVarName);
67:
68: $strRet .= <<<TMPL
69: return \$this->{$strControlVarName};
70: }
71:
72:
73: TMPL;
74:
75: return $strRet;
76: }
77:
78: 79: 80: 81: 82: 83: 84: 85: 86:
87: public function ConnectorRefresh(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn, $blnInit = false) {
88: $strObjectName = $objCodeGen->ModelVariableName($objTable->Name);
89: $strPropName = $objColumn->Reference ? $objColumn->Reference->PropertyName : $objColumn->PropertyName;
90: $strControlVarName = $this->VarName($strPropName);
91:
92: $strRet = "\t\t\tif (\$this->{$strControlVarName}) \$this->{$strControlVarName}->Checked = \$this->{$strObjectName}->{$strPropName};";
93: return $strRet . "\n";
94: }
95:
96: 97: 98: 99: 100: 101:
102: public function ConnectorUpdate(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn) {
103: $strObjectName = $objCodeGen->ModelVariableName($objTable->Name);
104: $strPropName = $objColumn->Reference ? $objColumn->Reference->PropertyName : $objColumn->PropertyName;
105: $strControlVarName = $this->VarName($strPropName);
106: $strRet = <<<TMPL
107: if (\$this->{$strControlVarName}) \$this->{$strObjectName}->{$objColumn->PropertyName} = \$this->{$strControlVarName}->Checked;
108:
109: TMPL;
110: return $strRet;
111: }
112: }