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.

114 lines
4.2 KiB

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