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.

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