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.

116 lines
4.5 KiB

  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 Quinta
  16. * @subpackage AdminUI
  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 $lstStatus;
  31. public $lstType;
  32. public $lstPage;
  33. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  34. public $lstMenus;
  35. // Other Controls
  36. public $btnSave;
  37. public $btnDelete;
  38. public $btnCancel;
  39. // Callback
  40. protected $strClosePanelMethod;
  41. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  42. // Call the Parent
  43. try {
  44. parent::__construct($objParentObject, $strControlId);
  45. } catch (QCallerException $objExc) {
  46. $objExc->IncrementOffset();
  47. throw $objExc;
  48. }
  49. // Setup Callback and Template
  50. $this->strTemplate = 'MenuItemEditPanel.tpl.php';
  51. $this->strClosePanelMethod = $strClosePanelMethod;
  52. // Construct the MenuItemMetaControl
  53. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  54. $this->mctMenuItem = MenuItemMetaControl::Create($this, $intId);
  55. // Call MetaControl's methods to create qcontrols based on MenuItem's data fields
  56. $this->lblId = $this->mctMenuItem->lblId_Create();
  57. $this->txtName = $this->mctMenuItem->txtName_Create();
  58. $this->txtCssClass = $this->mctMenuItem->txtCssClass_Create();
  59. $this->txtLabel = $this->mctMenuItem->txtLabel_Create();
  60. $this->txtUri = $this->mctMenuItem->txtUri_Create();
  61. $this->chkIsLocal = $this->mctMenuItem->chkIsLocal_Create();
  62. $this->chkIsSsl = $this->mctMenuItem->chkIsSsl_Create();
  63. $this->txtSortOrder = $this->mctMenuItem->txtSortOrder_Create();
  64. $this->lstStatus = $this->mctMenuItem->lstStatus_Create();
  65. $this->lstType = $this->mctMenuItem->lstType_Create();
  66. $this->lstPage = $this->mctMenuItem->lstPage_Create();
  67. $this->lstMenus = $this->mctMenuItem->lstMenus_Create();
  68. // Create Buttons and Actions on this Form
  69. $this->btnSave = new QButton($this);
  70. $this->btnSave->Text = QApplication::Translate('Save');
  71. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  72. $this->btnSave->CausesValidation = $this;
  73. $this->btnCancel = new QButton($this);
  74. $this->btnCancel->Text = QApplication::Translate('Cancel');
  75. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  76. $this->btnDelete = new QButton($this);
  77. $this->btnDelete->Text = QApplication::Translate('Delete');
  78. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('MenuItem') . '?'));
  79. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  80. $this->btnDelete->Visible = $this->mctMenuItem->EditMode;
  81. }
  82. // Control AjaxAction Event Handlers
  83. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  84. // Delegate "Save" processing to the MenuItemMetaControl
  85. $this->mctMenuItem->SaveMenuItem();
  86. $this->CloseSelf(true);
  87. }
  88. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  89. // Delegate "Delete" processing to the MenuItemMetaControl
  90. $this->mctMenuItem->DeleteMenuItem();
  91. $this->CloseSelf(true);
  92. }
  93. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  94. $this->CloseSelf(false);
  95. }
  96. // Close Myself and Call ClosePanelMethod Callback
  97. protected function CloseSelf($blnChangesMade) {
  98. $strMethod = $this->strClosePanelMethod;
  99. $this->objForm->$strMethod($blnChangesMade);
  100. }
  101. }
  102. ?>