A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.7 KiB

13 years ago
  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the ProductCategory class. It uses the code-generated
  5. * ProductCategoryMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a ProductCategory columns.
  7. *
  8. * Any display customizations and presentation-tier logic can be implemented
  9. * here by overriding existing or implementing new methods, properties and variables.
  10. *
  11. * NOTE: This file is overwritten on any code regenerations. If you want to make
  12. * permanent changes, it is STRONGLY RECOMMENDED to move both product_category_edit.php AND
  13. * product_category_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class ProductCategoryEditPanel extends QPanel {
  19. // Local instance of the ProductCategoryMetaControl
  20. protected $mctProductCategory;
  21. // Controls for ProductCategory's Data Fields
  22. public $lblId;
  23. public $txtName;
  24. public $txtTitle;
  25. public $txtDescription;
  26. public $txtImageUri;
  27. public $lstParentProductCategory;
  28. public $lstPublicPermissions;
  29. public $lstUserPermissions;
  30. public $lstGroupPermissions;
  31. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  32. public $lstProducts;
  33. // Other Controls
  34. public $btnSave;
  35. public $btnDelete;
  36. public $btnCancel;
  37. // Callback
  38. protected $strClosePanelMethod;
  39. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  40. // Call the Parent
  41. try {
  42. parent::__construct($objParentObject, $strControlId);
  43. } catch (QCallerException $objExc) {
  44. $objExc->IncrementOffset();
  45. throw $objExc;
  46. }
  47. // Setup Callback and Template
  48. $this->strTemplate = 'ProductCategoryEditPanel.tpl.php';
  49. $this->strClosePanelMethod = $strClosePanelMethod;
  50. // Construct the ProductCategoryMetaControl
  51. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  52. $this->mctProductCategory = ProductCategoryMetaControl::Create($this, $intId);
  53. // Call MetaControl's methods to create qcontrols based on ProductCategory's data fields
  54. $this->lblId = $this->mctProductCategory->lblId_Create();
  55. $this->txtName = $this->mctProductCategory->txtName_Create();
  56. $this->txtTitle = $this->mctProductCategory->txtTitle_Create();
  57. $this->txtDescription = $this->mctProductCategory->txtDescription_Create();
  58. $this->txtImageUri = $this->mctProductCategory->txtImageUri_Create();
  59. $this->lstParentProductCategory = $this->mctProductCategory->lstParentProductCategory_Create();
  60. $this->lstPublicPermissions = $this->mctProductCategory->lstPublicPermissions_Create();
  61. $this->lstUserPermissions = $this->mctProductCategory->lstUserPermissions_Create();
  62. $this->lstGroupPermissions = $this->mctProductCategory->lstGroupPermissions_Create();
  63. $this->lstProducts = $this->mctProductCategory->lstProducts_Create();
  64. // Create Buttons and Actions on this Form
  65. $this->btnSave = new QButton($this);
  66. $this->btnSave->Text = QApplication::Translate('Save');
  67. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  68. $this->btnSave->CausesValidation = $this;
  69. $this->btnCancel = new QButton($this);
  70. $this->btnCancel->Text = QApplication::Translate('Cancel');
  71. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  72. $this->btnDelete = new QButton($this);
  73. $this->btnDelete->Text = QApplication::Translate('Delete');
  74. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('ProductCategory') . '?'));
  75. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  76. $this->btnDelete->Visible = $this->mctProductCategory->EditMode;
  77. }
  78. // Control AjaxAction Event Handlers
  79. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  80. // Delegate "Save" processing to the ProductCategoryMetaControl
  81. $this->mctProductCategory->SaveProductCategory();
  82. $this->CloseSelf(true);
  83. }
  84. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  85. // Delegate "Delete" processing to the ProductCategoryMetaControl
  86. $this->mctProductCategory->DeleteProductCategory();
  87. $this->CloseSelf(true);
  88. }
  89. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  90. $this->CloseSelf(false);
  91. }
  92. // Close Myself and Call ClosePanelMethod Callback
  93. protected function CloseSelf($blnChangesMade) {
  94. $strMethod = $this->strClosePanelMethod;
  95. $this->objForm->$strMethod($blnChangesMade);
  96. }
  97. }
  98. ?>