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.

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