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.

102 lines
4.0 KiB

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