1: <?php
2:
3: class QSliderBase_CodeGenerator extends QControl_CodeGenerator {
4: public function __construct($strControlClassName = 'QSlider') {
5: parent::__construct($strControlClassName);
6: }
7:
8: 9: 10: 11:
12: public function VarName($strPropName) {
13: return 'sld' . $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: $strClassName = $objTable->ClassName;
29: $strControlVarName = $objCodeGen->ModelConnectorVariableName($objColumn);
30: $strLabelName = addslashes(QCodeGen::ModelConnectorControlName($objColumn));
31:
32:
33: $strControlType = $objCodeGen->GetControlCodeGenerator($objColumn)->GetControlClass();
34:
35: $strRet = <<<TMPL
36: /**
37: * Create and setup a $strControlType $strControlVarName
38: * @param string \$strControlId optional ControlId to use
39: * @return $strControlType
40: */
41: public function {$strControlVarName}_Create(\$strControlId = null) {
42:
43: TMPL;
44: $strControlIdOverride = $objCodeGen->GenerateControlId($objTable, $objColumn);
45:
46: if ($strControlIdOverride) {
47: $strRet .= <<<TMPL
48: if (!\$strControlId) {
49: \$strControlId = '$strControlIdOverride';
50: }
51:
52: TMPL;
53: }
54: $strRet .= <<<TMPL
55: \$this->{$strControlVarName} = new $strControlType(\$this->objParentObject, \$strControlId);
56: \$this->{$strControlVarName}->Name = QApplication::Translate('$strLabelName');
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: $strRet .= $this->ConnectorRefresh($objCodeGen, $objTable, $objColumn, true);
68:
69: $strRet .= <<<TMPL
70: return \$this->{$strControlVarName};
71: }
72:
73:
74: TMPL;
75:
76: return $strRet;
77: }
78:
79: 80: 81: 82: 83: 84: 85: 86: 87:
88: public function ConnectorRefresh(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn, $blnInit = false) {
89: $strObjectName = $objCodeGen->ModelVariableName($objTable->Name);
90: $strPropName = $objColumn->Reference ? $objColumn->Reference->PropertyName : $objColumn->PropertyName;
91: $strControlVarName = $this->VarName($strPropName);
92:
93: if ($blnInit) {
94: $strRet = "\t\t\t\$this->{$strControlVarName}->Value = \$this->{$strObjectName}->{$strPropName};";
95: } else {
96: $strRet = "\t\t\tif (\$this->{$strControlVarName}) \$this->{$strControlVarName}->Value = \$this->{$strObjectName}->{$strPropName};";
97: }
98: return $strRet . "\n";
99: }
100:
101: 102: 103: 104: 105: 106:
107: public function ConnectorUpdate(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn) {
108: $strObjectName = $objCodeGen->ModelVariableName($objTable->Name);
109: $strPropName = $objColumn->Reference ? $objColumn->Reference->PropertyName : $objColumn->PropertyName;
110: $strControlVarName = $this->VarName($strPropName);
111: $strRet = <<<TMPL
112: if (\$this->{$strControlVarName}) \$this->{$strObjectName}->{$strPropName} = \$this->{$strControlVarName}->Value;
113:
114: TMPL;
115: return $strRet;
116: }
117: }