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.

110 lines
4.4 KiB

  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the ProductImage class. It uses the code-generated
  5. * ProductImageMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a ProductImage 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 product_image_edit.php AND
  13. * product_image_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quinta
  16. * @subpackage AdminUI
  17. */
  18. class ProductImageEditPanel extends QPanel {
  19. // Local instance of the ProductImageMetaControl
  20. protected $mctProductImage;
  21. // Controls for ProductImage's Data Fields
  22. public $lblId;
  23. public $lstProduct;
  24. public $txtTitle;
  25. public $txtAltTag;
  26. public $txtDescription;
  27. public $txtUri;
  28. public $txtXSize;
  29. public $txtYSize;
  30. public $lstSizeTypeObject;
  31. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  32. // Other Controls
  33. public $btnSave;
  34. public $btnDelete;
  35. public $btnCancel;
  36. // Callback
  37. protected $strClosePanelMethod;
  38. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  39. // Call the Parent
  40. try {
  41. parent::__construct($objParentObject, $strControlId);
  42. } catch (QCallerException $objExc) {
  43. $objExc->IncrementOffset();
  44. throw $objExc;
  45. }
  46. // Setup Callback and Template
  47. $this->strTemplate = 'ProductImageEditPanel.tpl.php';
  48. $this->strClosePanelMethod = $strClosePanelMethod;
  49. // Construct the ProductImageMetaControl
  50. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  51. $this->mctProductImage = ProductImageMetaControl::Create($this, $intId);
  52. // Call MetaControl's methods to create qcontrols based on ProductImage's data fields
  53. $this->lblId = $this->mctProductImage->lblId_Create();
  54. $this->lstProduct = $this->mctProductImage->lstProduct_Create();
  55. $this->txtTitle = $this->mctProductImage->txtTitle_Create();
  56. $this->txtAltTag = $this->mctProductImage->txtAltTag_Create();
  57. $this->txtDescription = $this->mctProductImage->txtDescription_Create();
  58. $this->txtUri = $this->mctProductImage->txtUri_Create();
  59. $this->txtXSize = $this->mctProductImage->txtXSize_Create();
  60. $this->txtYSize = $this->mctProductImage->txtYSize_Create();
  61. $this->lstSizeTypeObject = $this->mctProductImage->lstSizeTypeObject_Create();
  62. // Create Buttons and Actions on this Form
  63. $this->btnSave = new QButton($this);
  64. $this->btnSave->Text = QApplication::Translate('Save');
  65. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  66. $this->btnSave->CausesValidation = $this;
  67. $this->btnCancel = new QButton($this);
  68. $this->btnCancel->Text = QApplication::Translate('Cancel');
  69. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  70. $this->btnDelete = new QButton($this);
  71. $this->btnDelete->Text = QApplication::Translate('Delete');
  72. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('ProductImage') . '?'));
  73. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  74. $this->btnDelete->Visible = $this->mctProductImage->EditMode;
  75. }
  76. // Control AjaxAction Event Handlers
  77. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  78. // Delegate "Save" processing to the ProductImageMetaControl
  79. $this->mctProductImage->SaveProductImage();
  80. $this->CloseSelf(true);
  81. }
  82. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  83. // Delegate "Delete" processing to the ProductImageMetaControl
  84. $this->mctProductImage->DeleteProductImage();
  85. $this->CloseSelf(true);
  86. }
  87. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  88. $this->CloseSelf(false);
  89. }
  90. // Close Myself and Call ClosePanelMethod Callback
  91. protected function CloseSelf($blnChangesMade) {
  92. $strMethod = $this->strClosePanelMethod;
  93. $this->objForm->$strMethod($blnChangesMade);
  94. }
  95. }
  96. ?>