A QCodo powered CMS
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.3 KiB

  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 Quinta
  16. * @subpackage AdminUI
  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. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  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 = 'ModuleEditPanel.tpl.php';
  49. $this->strClosePanelMethod = $strClosePanelMethod;
  50. // Construct the ModuleMetaControl
  51. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  52. $this->mctModule = ModuleMetaControl::Create($this, $intId);
  53. // Call MetaControl's methods to create qcontrols based on Module's data fields
  54. $this->lblId = $this->mctModule->lblId_Create();
  55. $this->txtName = $this->mctModule->txtName_Create();
  56. $this->txtCssclass = $this->mctModule->txtCssclass_Create();
  57. $this->txtTitle = $this->mctModule->txtTitle_Create();
  58. $this->txtDescription = $this->mctModule->txtDescription_Create();
  59. $this->txtClassName = $this->mctModule->txtClassName_Create();
  60. $this->chkShowTitle = $this->mctModule->chkShowTitle_Create();
  61. $this->chkShowDescription = $this->mctModule->chkShowDescription_Create();
  62. $this->lstContentBlock = $this->mctModule->lstContentBlock_Create();
  63. $this->lstParentModule = $this->mctModule->lstParentModule_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('Module') . '?'));
  75. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  76. $this->btnDelete->Visible = $this->mctModule->EditMode;
  77. }
  78. // Control AjaxAction Event Handlers
  79. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  80. // Delegate "Save" processing to the ModuleMetaControl
  81. $this->mctModule->SaveModule();
  82. $this->CloseSelf(true);
  83. }
  84. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  85. // Delegate "Delete" processing to the ModuleMetaControl
  86. $this->mctModule->DeleteModule();
  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. ?>