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.

118 lines
4.7 KiB

12 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 Module class. It uses the code-generated
  5. * ModuleMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a Module 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 module_edit.php AND
  13. * module_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class ModuleEditPanel extends QPanel {
  19. // Local instance of the ModuleMetaControl
  20. protected $mctModule;
  21. // Controls for Module's Data Fields
  22. public $lblId;
  23. public $txtName;
  24. public $txtCssclass;
  25. public $txtTitle;
  26. public $txtDescription;
  27. public $txtClassName;
  28. public $chkShowTitle;
  29. public $chkShowDescription;
  30. public $lstContentBlock;
  31. public $lstParentModule;
  32. public $lstPublicPermissions;
  33. public $lstUserPermissions;
  34. public $lstGroupPermissions;
  35. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  36. // Other Controls
  37. public $btnSave;
  38. public $btnDelete;
  39. public $btnCancel;
  40. // Callback
  41. protected $strClosePanelMethod;
  42. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  43. // Call the Parent
  44. try {
  45. parent::__construct($objParentObject, $strControlId);
  46. } catch (QCallerException $objExc) {
  47. $objExc->IncrementOffset();
  48. throw $objExc;
  49. }
  50. // Setup Callback and Template
  51. $this->strTemplate = 'ModuleEditPanel.tpl.php';
  52. $this->strClosePanelMethod = $strClosePanelMethod;
  53. // Construct the ModuleMetaControl
  54. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  55. $this->mctModule = ModuleMetaControl::Create($this, $intId);
  56. // Call MetaControl's methods to create qcontrols based on Module's data fields
  57. $this->lblId = $this->mctModule->lblId_Create();
  58. $this->txtName = $this->mctModule->txtName_Create();
  59. $this->txtCssclass = $this->mctModule->txtCssclass_Create();
  60. $this->txtTitle = $this->mctModule->txtTitle_Create();
  61. $this->txtDescription = $this->mctModule->txtDescription_Create();
  62. $this->txtClassName = $this->mctModule->txtClassName_Create();
  63. $this->chkShowTitle = $this->mctModule->chkShowTitle_Create();
  64. $this->chkShowDescription = $this->mctModule->chkShowDescription_Create();
  65. $this->lstContentBlock = $this->mctModule->lstContentBlock_Create();
  66. $this->lstParentModule = $this->mctModule->lstParentModule_Create();
  67. $this->lstPublicPermissions = $this->mctModule->lstPublicPermissions_Create();
  68. $this->lstUserPermissions = $this->mctModule->lstUserPermissions_Create();
  69. $this->lstGroupPermissions = $this->mctModule->lstGroupPermissions_Create();
  70. // Create Buttons and Actions on this Form
  71. $this->btnSave = new QButton($this);
  72. $this->btnSave->Text = QApplication::Translate('Save');
  73. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  74. $this->btnSave->CausesValidation = $this;
  75. $this->btnCancel = new QButton($this);
  76. $this->btnCancel->Text = QApplication::Translate('Cancel');
  77. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  78. $this->btnDelete = new QButton($this);
  79. $this->btnDelete->Text = QApplication::Translate('Delete');
  80. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Module') . '?'));
  81. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  82. $this->btnDelete->Visible = $this->mctModule->EditMode;
  83. }
  84. // Control AjaxAction Event Handlers
  85. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  86. // Delegate "Save" processing to the ModuleMetaControl
  87. $this->mctModule->SaveModule();
  88. $this->CloseSelf(true);
  89. }
  90. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  91. // Delegate "Delete" processing to the ModuleMetaControl
  92. $this->mctModule->DeleteModule();
  93. $this->CloseSelf(true);
  94. }
  95. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  96. $this->CloseSelf(false);
  97. }
  98. // Close Myself and Call ClosePanelMethod Callback
  99. protected function CloseSelf($blnChangesMade) {
  100. $strMethod = $this->strClosePanelMethod;
  101. $this->objForm->$strMethod($blnChangesMade);
  102. }
  103. }
  104. ?>