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.

104 lines
4.1 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 StyleSheet class. It uses the code-generated
  5. * StyleSheetMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a StyleSheet 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 style_sheet_edit.php AND
  13. * style_sheet_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quasi
  16. * @subpackage Drafts
  17. */
  18. class StyleSheetEditPanel extends QPanel {
  19. // Local instance of the StyleSheetMetaControl
  20. protected $mctStyleSheet;
  21. // Controls for StyleSheet's Data Fields
  22. public $lblId;
  23. public $txtName;
  24. public $txtDescription;
  25. public $txtFilename;
  26. public $txtType;
  27. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  28. public $lstPages;
  29. // Other Controls
  30. public $btnSave;
  31. public $btnDelete;
  32. public $btnCancel;
  33. // Callback
  34. protected $strClosePanelMethod;
  35. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  36. // Call the Parent
  37. try {
  38. parent::__construct($objParentObject, $strControlId);
  39. } catch (QCallerException $objExc) {
  40. $objExc->IncrementOffset();
  41. throw $objExc;
  42. }
  43. // Setup Callback and Template
  44. $this->strTemplate = 'StyleSheetEditPanel.tpl.php';
  45. $this->strClosePanelMethod = $strClosePanelMethod;
  46. // Construct the StyleSheetMetaControl
  47. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  48. $this->mctStyleSheet = StyleSheetMetaControl::Create($this, $intId);
  49. // Call MetaControl's methods to create qcontrols based on StyleSheet's data fields
  50. $this->lblId = $this->mctStyleSheet->lblId_Create();
  51. $this->txtName = $this->mctStyleSheet->txtName_Create();
  52. $this->txtDescription = $this->mctStyleSheet->txtDescription_Create();
  53. $this->txtFilename = $this->mctStyleSheet->txtFilename_Create();
  54. $this->txtType = $this->mctStyleSheet->txtType_Create();
  55. $this->lstPages = $this->mctStyleSheet->lstPages_Create();
  56. // Create Buttons and Actions on this Form
  57. $this->btnSave = new QButton($this);
  58. $this->btnSave->Text = QApplication::Translate('Save');
  59. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  60. $this->btnSave->CausesValidation = $this;
  61. $this->btnCancel = new QButton($this);
  62. $this->btnCancel->Text = QApplication::Translate('Cancel');
  63. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  64. $this->btnDelete = new QButton($this);
  65. $this->btnDelete->Text = QApplication::Translate('Delete');
  66. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('StyleSheet') . '?'));
  67. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  68. $this->btnDelete->Visible = $this->mctStyleSheet->EditMode;
  69. }
  70. // Control AjaxAction Event Handlers
  71. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  72. // Delegate "Save" processing to the StyleSheetMetaControl
  73. $this->mctStyleSheet->SaveStyleSheet();
  74. $this->CloseSelf(true);
  75. }
  76. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  77. // Delegate "Delete" processing to the StyleSheetMetaControl
  78. $this->mctStyleSheet->DeleteStyleSheet();
  79. $this->CloseSelf(true);
  80. }
  81. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  82. $this->CloseSelf(false);
  83. }
  84. // Close Myself and Call ClosePanelMethod Callback
  85. protected function CloseSelf($blnChangesMade) {
  86. $strMethod = $this->strClosePanelMethod;
  87. $this->objForm->$strMethod($blnChangesMade);
  88. }
  89. }
  90. ?>