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.9 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 ContentBlock class. It uses the code-generated
  5. * ContentBlockMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a ContentBlock 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 content_block_edit.php AND
  13. * content_block_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class ContentBlockEditPanel extends QPanel {
  19. // Local instance of the ContentBlockMetaControl
  20. protected $mctContentBlock;
  21. // Controls for ContentBlock's Data Fields
  22. public $lblId;
  23. public $txtName;
  24. public $txtCssclass;
  25. public $txtTitle;
  26. public $txtDescription;
  27. public $chkShowTitle;
  28. public $chkShowDescription;
  29. public $chkCollapsable;
  30. public $txtSortOrder;
  31. public $lstParentContentBlock;
  32. public $lstLocation;
  33. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  34. public $lstPages;
  35. public $lstContentItems;
  36. public $lstMenus;
  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 = 'ContentBlockEditPanel.tpl.php';
  53. $this->strClosePanelMethod = $strClosePanelMethod;
  54. // Construct the ContentBlockMetaControl
  55. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  56. $this->mctContentBlock = ContentBlockMetaControl::Create($this, $intId);
  57. // Call MetaControl's methods to create qcontrols based on ContentBlock's data fields
  58. $this->lblId = $this->mctContentBlock->lblId_Create();
  59. $this->txtName = $this->mctContentBlock->txtName_Create();
  60. $this->txtCssclass = $this->mctContentBlock->txtCssclass_Create();
  61. $this->txtTitle = $this->mctContentBlock->txtTitle_Create();
  62. $this->txtDescription = $this->mctContentBlock->txtDescription_Create();
  63. $this->chkShowTitle = $this->mctContentBlock->chkShowTitle_Create();
  64. $this->chkShowDescription = $this->mctContentBlock->chkShowDescription_Create();
  65. $this->chkCollapsable = $this->mctContentBlock->chkCollapsable_Create();
  66. $this->txtSortOrder = $this->mctContentBlock->txtSortOrder_Create();
  67. $this->lstParentContentBlock = $this->mctContentBlock->lstParentContentBlock_Create();
  68. $this->lstLocation = $this->mctContentBlock->lstLocation_Create();
  69. $this->lstPages = $this->mctContentBlock->lstPages_Create();
  70. $this->lstContentItems = $this->mctContentBlock->lstContentItems_Create();
  71. $this->lstMenus = $this->mctContentBlock->lstMenus_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('ContentBlock') . '?'));
  83. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  84. $this->btnDelete->Visible = $this->mctContentBlock->EditMode;
  85. }
  86. // Control AjaxAction Event Handlers
  87. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  88. // Delegate "Save" processing to the ContentBlockMetaControl
  89. $this->mctContentBlock->SaveContentBlock();
  90. $this->CloseSelf(true);
  91. }
  92. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  93. // Delegate "Delete" processing to the ContentBlockMetaControl
  94. $this->mctContentBlock->DeleteContentBlock();
  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. ?>