PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/sgl/includes/qcubed/_core/codegen/templates/db_orm/drafts/_qform_edit_base.tpl

http://logisticsouth.googlecode.com/
Smarty Template | 155 lines | 132 code | 23 blank | 0 comment | 6 complexity | c2d3f6a5167358b2125e93e03dfb69fc MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <template OverwriteFlag="true" DocrootFlag="false" DirectorySuffix="" TargetDirectory="<%= __FORMBASE_CLASSES__ %>" TargetFileName="<%= $objTable->ClassName %>EditFormBase.class.php"/>
  2. <?php
  3. /**
  4. * This is a quick-and-dirty draft QForm object to do Create, Edit, and Delete functionality
  5. * of the <%= $objTable->ClassName %> class. It uses the code-generated
  6. * <%= $objTable->ClassName %>MetaControl class, which has meta-methods to help with
  7. * easily creating/defining controls to modify the fields of a <%= $objTable->ClassName %> columns.
  8. *
  9. * Any display customizations and presentation-tier logic can be implemented
  10. * here by overriding existing or implementing new methods, properties and variables.
  11. *
  12. * NOTE: This file is overwritten on any code regenerations. If you want to make
  13. * permanent changes, it is STRONGLY RECOMMENDED to move both <%= QConvertNotation::UnderscoreFromCamelCase($objTable->ClassName) %>_edit.php AND
  14. * <%= QConvertNotation::UnderscoreFromCamelCase($objTable->ClassName) %>_edit.tpl.php out of this Form Drafts directory.
  15. *
  16. * @package <%= QCodeGen::$ApplicationName; %>
  17. * @subpackage FormBaseObjects
  18. */
  19. abstract class <%= $objTable->ClassName %>EditFormBase extends QForm {
  20. // Local instance of the <%= $objTable->ClassName %>MetaControl
  21. /**
  22. * @var <%= $objTable->ClassName %>MetaControlGen mct<%= $objTable->ClassName %>
  23. */
  24. protected $mct<%= $objTable->ClassName %>;
  25. // Controls for <%= $objTable->ClassName %>'s Data Fields
  26. <% foreach ($objTable->ColumnArray as $objColumn) { %>
  27. protected $<%= $objCodeGen->FormControlVariableNameForColumn($objColumn); %>;
  28. <% } %>
  29. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  30. <% foreach ($objTable->ReverseReferenceArray as $objReverseReference) { %>
  31. <% if ($objReverseReference->Unique) { %>
  32. protected $<%= $objCodeGen->FormControlVariableNameForUniqueReverseReference($objReverseReference); %>;
  33. <% } %>
  34. <% } %>
  35. <% foreach ($objTable->ManyToManyReferenceArray as $objManyToManyReference) { %>
  36. protected $<%= $objCodeGen->FormControlVariableNameForManyToManyReference($objManyToManyReference); %>;
  37. <% } %>
  38. // Other Controls
  39. /**
  40. * @var QButton Save
  41. */
  42. protected $btnSave;
  43. /**
  44. * @var QButton Delete
  45. */
  46. protected $btnDelete;
  47. /**
  48. * @var QButton Cancel
  49. */
  50. protected $btnCancel;
  51. // Create QForm Event Handlers as Needed
  52. // protected function Form_Exit() {}
  53. // protected function Form_Load() {}
  54. // protected function Form_PreRender() {}
  55. protected function Form_Run() {
  56. // Security check for ALLOW_REMOTE_ADMIN
  57. // To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
  58. QApplication::CheckRemoteAdmin();
  59. }
  60. protected function Form_Create() {
  61. parent::Form_Create();
  62. // Use the CreateFromPathInfo shortcut (this can also be done manually using the <%= $objTable->ClassName %>MetaControl constructor)
  63. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  64. $this->mct<%= $objTable->ClassName %> = <%= $objTable->ClassName %>MetaControl::CreateFromPathInfo($this);
  65. // Call MetaControl's methods to create qcontrols based on <%= $objTable->ClassName %>'s data fields
  66. <% foreach ($objTable->ColumnArray as $objColumn) { %>
  67. $this-><%= $objCodeGen->FormControlVariableNameForColumn($objColumn); %> = $this->mct<%= $objTable->ClassName %>-><%= $objCodeGen->FormControlVariableNameForColumn($objColumn); %>_Create();
  68. <% } %>
  69. <% foreach ($objTable->ReverseReferenceArray as $objReverseReference) { %>
  70. <% if ($objReverseReference->Unique) { %>
  71. $this-><%= $objCodeGen->FormControlVariableNameForUniqueReverseReference($objReverseReference); %> = $this->mct<%= $objTable->ClassName %>-><%= $objCodeGen->FormControlVariableNameForUniqueReverseReference($objReverseReference); %>_Create();
  72. <% } %>
  73. <% } %>
  74. <% foreach ($objTable->ManyToManyReferenceArray as $objManyToManyReference) { %>
  75. $this-><%= $objCodeGen->FormControlVariableNameForManyToManyReference($objManyToManyReference); %> = $this->mct<%= $objTable->ClassName %>-><%= $objCodeGen->FormControlVariableNameForManyToManyReference($objManyToManyReference); %>_Create();
  76. <% } %>
  77. // Create Buttons and Actions on this Form
  78. $this->btnSave = new QButton($this);
  79. $this->btnSave->Text = QApplication::Translate('Save');
  80. $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
  81. $this->btnSave->CausesValidation = true;
  82. $this->btnCancel = new QButton($this);
  83. $this->btnCancel->Text = QApplication::Translate('Cancel');
  84. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
  85. $this->btnDelete = new QButton($this);
  86. $this->btnDelete->Text = QApplication::Translate('Delete');
  87. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('<%= $objTable->ClassName %>') . '?'));
  88. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click'));
  89. $this->btnDelete->Visible = $this->mct<%= $objTable->ClassName %>->EditMode;
  90. }
  91. /**
  92. * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  93. * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  94. */
  95. protected function Form_Validate() {
  96. // By default, we report that Custom Validations passed
  97. $blnToReturn = true;
  98. // Custom Validation Rules
  99. // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
  100. <%@ qform_validate_unique('objTable') %>
  101. $blnFocused = false;
  102. foreach ($this->GetErrorControls() as $objControl) {
  103. // Set Focus to the top-most invalid control
  104. if (!$blnFocused) {
  105. $objControl->Focus();
  106. $blnFocused = true;
  107. }
  108. // Blink on ALL invalid controls
  109. $objControl->Blink();
  110. }
  111. return $blnToReturn;
  112. }
  113. // Button Event Handlers
  114. protected function btnSave_Click($strFormId, $strControlId, $strParameter) {
  115. // Delegate "Save" processing to the <%= $objTable->ClassName %>MetaControl
  116. $this->mct<%= $objTable->ClassName %>->Save<%= $objTable->ClassName %>();
  117. $this->RedirectToListPage();
  118. }
  119. protected function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  120. // Delegate "Delete" processing to the <%= $objTable->ClassName %>MetaControl
  121. $this->mct<%= $objTable->ClassName %>->Delete<%= $objTable->ClassName %>();
  122. $this->RedirectToListPage();
  123. }
  124. protected function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  125. $this->RedirectToListPage();
  126. }
  127. // Other Methods
  128. protected function RedirectToListPage() {
  129. QApplication::Redirect(__VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/<%= strtolower($objTable->Name) %>_list.php');
  130. }
  131. }
  132. ?>