/** * @param QCodeGenBase $objCodeGen * @param QSqlColumn|QReverseReference| QManyToManyReference $objColumn * @throws Exception * @return string */ public function ConnectorVariableDeclaration(QCodeGenBase $objCodeGen, $objColumn) { $strPropName = $objCodeGen->ModelConnectorPropertyName($objColumn); $strControlVarName = $this->VarName($strPropName); $strRet = <<<TMPL \t\t/** \t\t * @var QLabel {$strControlVarName} \t\t * @access protected \t\t */ \t\tprotected \${$strControlVarName}; TMPL; if ($objColumn->VariableType == 'QDateTime') { $strRet .= <<<TMPL \t\t/** \t\t* @var str{$strPropName}DateTimeFormat \t\t* @access protected \t\t*/ \t\tprotected \$str{$strPropName}DateTimeFormat; TMPL; } return $strRet; }
/** * Generates an alternate create columns function that could be used by the list panel to create the columns directly. * This is designed to be added as commented out code in the list panel override class that the user can choose to use. * * @param QCodeGenBase $objCodeGen * @param QSqlTable $objTable * @return string */ public function DataListSubclassOverrides(QCodeGenBase $objCodeGen, QSqlTable $objTable) { $strVarName = $objCodeGen->DataListVarName($objTable); $strPropertyName = QCodeGen::DataListPropertyName($objTable); $strCode = <<<TMPL /* \t Uncomment this block to directly create the columns here, rather than creating them in the {$strPropertyName}List connector. \t You can then modify the column creation process by editing the function below. Or, you can instead call the parent function \t and modify the columns after the {$strPropertyName}List creates the default columns. \tprotected function {$strVarName}_CreateColumns() { TMPL; foreach ($objTable->ColumnArray as $objColumn) { if (isset($objColumn->Options['FormGen']) && $objColumn->Options['FormGen'] == QFormGen::None) { continue; } if (isset($objColumn->Options['NoColumn']) && $objColumn->Options['NoColumn']) { continue; } $strCode .= <<<TMPL \t\t\$col = \$this->{$strVarName}->CreateNodeColumn("{$objCodeGen->ModelConnectorControlName($objColumn)}", QQN::{$objTable->ClassName}()->{$objCodeGen->ModelConnectorPropertyName($objColumn)}); TMPL; } foreach ($objTable->ReverseReferenceArray as $objReverseReference) { if ($objReverseReference->Unique) { $strCode .= <<<TMPL \t\t\$col = \$this->{$strVarName}->CreateNodeColumn("{$objCodeGen->ModelConnectorControlName($objReverseReference)}", QQN::{$objTable->ClassName}()->{$objReverseReference->ObjectDescription}); TMPL; } } $strCode .= <<<TMPL \t} */\t TMPL; $strCode .= <<<TMPL \t\t /* \t Uncomment this block to use an Edit column instead of clicking on a highlighted row in order to edit an item. \t\tprotected \$pxyEditRow; \t\tprotected function {$strVarName}_MakeEditable () { \t\t\t\$pxyEditRow = new QControlProxy(\$this); \t\t\t\$pxyEditRow->AddAction(new QClickEvent(), new QAjaxControlAction(\$this, '{$strVarName}_EditClick')); \t\t\t\$this->{$strVarName}->CreateLinkColumn(QApplication::Translate('Edit'), QApplication::Translate('Edit'), \$pxyEditRow, QQN::{$objTable->ClassName}()->Id, null, false, 0); \t\t} \t\tprotected function {$strVarName}_EditClick(\$strFormId, \$strControlId, \$param) { \t\t\t\$this->EditItem(\$param); \t\t} */\t TMPL; return $strCode; }
/** * @param QCodeGenBase $objCodeGen * @param QSqlColumn|QReverseReference| QManyToManyReference $objColumn * @return string */ public function ConnectorVariableDeclaration(QCodeGenBase $objCodeGen, $objColumn) { $strClassName = $objCodeGen->GetControlCodeGenerator($objColumn)->GetControlClass(); $strPropName = $objCodeGen->ModelConnectorPropertyName($objColumn); $strControlVarName = $this->VarName($strPropName); $strRet = <<<TMPL \t\t/** \t\t * @var {$strClassName} {$strControlVarName} \t\t * @access protected \t\t */ \t\tprotected \${$strControlVarName}; \t\t/** \t\t* @var obj{$strPropName}Condition \t\t* @access protected \t\t*/ \t\tprotected \$obj{$strPropName}Condition; \t\t/** \t\t* @var obj{$strPropName}Clauses \t\t* @access protected \t\t*/ \t\tprotected \$obj{$strPropName}Clauses; TMPL; return $strRet; }
/** * @param QCodeGenBase $objCodeGen * @param QTable $objTable * @param QColumn|\QReverseReference $objColumn * @return string */ public function ConnectorUpdate(\QCodeGenBase $objCodeGen, \QSqlTable $objTable, $objColumn) { $strObjectName = $objCodeGen->ModelVariableName($objTable->Name); $strPropName = $objCodeGen->ModelConnectorPropertyName($objColumn); $strControlVarName = static::VarName($strPropName); $strRet = <<<TMPL \t\t\t\tif (\$this->{$strControlVarName}) \$this->{$strObjectName}->{$objColumn->PropertyName} = \$this->{$strControlVarName}->DateTime; TMPL; return $strRet; }