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.

130 lines
5.1 KiB

  1. <?php
  2. /**
  3. * This is a quick-and-dirty draft QPanel object to do Create, Edit, and Delete functionality
  4. * of the Page class. It uses the code-generated
  5. * PageMetaControl class, which has meta-methods to help with
  6. * easily creating/defining controls to modify the fields of a Page 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 page_edit.php AND
  13. * page_edit.tpl.php out of this Form Drafts directory.
  14. *
  15. * @package Quinta
  16. * @subpackage AdminUI
  17. */
  18. class PageEditPanel extends QPanel {
  19. // Local instance of the PageMetaControl
  20. protected $mctPage;
  21. // Controls for Page's Data Fields
  22. public $lblId;
  23. public $lblCreationDate;
  24. public $lblLastModification;
  25. public $txtName;
  26. public $txtTitle;
  27. public $txtUri;
  28. public $chkHasHeader;
  29. public $chkHasLeftColumn;
  30. public $chkHasRightColumn;
  31. public $chkHasFooter;
  32. public $lstType;
  33. public $lstDocType;
  34. public $lstStatus;
  35. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  36. public $lstContentBlocks;
  37. public $lstContentCategories;
  38. public $lstHtmlMetaTags;
  39. public $lstJavaScripts;
  40. public $lstStyleSheets;
  41. public $lstUsergroups;
  42. // Other Controls
  43. public $btnSave;
  44. public $btnDelete;
  45. public $btnCancel;
  46. // Callback
  47. protected $strClosePanelMethod;
  48. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  49. // Call the Parent
  50. try {
  51. parent::__construct($objParentObject, $strControlId);
  52. } catch (QCallerException $objExc) {
  53. $objExc->IncrementOffset();
  54. throw $objExc;
  55. }
  56. // Setup Callback and Template
  57. $this->strTemplate = 'PageEditPanel.tpl.php';
  58. $this->strClosePanelMethod = $strClosePanelMethod;
  59. // Construct the PageMetaControl
  60. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  61. $this->mctPage = PageMetaControl::Create($this, $intId);
  62. // Call MetaControl's methods to create qcontrols based on Page's data fields
  63. $this->lblId = $this->mctPage->lblId_Create();
  64. $this->lblCreationDate = $this->mctPage->lblCreationDate_Create();
  65. $this->lblLastModification = $this->mctPage->lblLastModification_Create();
  66. $this->txtName = $this->mctPage->txtName_Create();
  67. $this->txtTitle = $this->mctPage->txtTitle_Create();
  68. $this->txtUri = $this->mctPage->txtUri_Create();
  69. $this->chkHasHeader = $this->mctPage->chkHasHeader_Create();
  70. $this->chkHasLeftColumn = $this->mctPage->chkHasLeftColumn_Create();
  71. $this->chkHasRightColumn = $this->mctPage->chkHasRightColumn_Create();
  72. $this->chkHasFooter = $this->mctPage->chkHasFooter_Create();
  73. $this->lstType = $this->mctPage->lstType_Create();
  74. $this->lstDocType = $this->mctPage->lstDocType_Create();
  75. $this->lstStatus = $this->mctPage->lstStatus_Create();
  76. $this->lstContentBlocks = $this->mctPage->lstContentBlocks_Create();
  77. $this->lstContentCategories = $this->mctPage->lstContentCategories_Create();
  78. $this->lstHtmlMetaTags = $this->mctPage->lstHtmlMetaTags_Create();
  79. $this->lstJavaScripts = $this->mctPage->lstJavaScripts_Create();
  80. $this->lstStyleSheets = $this->mctPage->lstStyleSheets_Create();
  81. $this->lstUsergroups = $this->mctPage->lstUsergroups_Create();
  82. // Create Buttons and Actions on this Form
  83. $this->btnSave = new QButton($this);
  84. $this->btnSave->Text = QApplication::Translate('Save');
  85. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  86. $this->btnSave->CausesValidation = $this;
  87. $this->btnCancel = new QButton($this);
  88. $this->btnCancel->Text = QApplication::Translate('Cancel');
  89. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  90. $this->btnDelete = new QButton($this);
  91. $this->btnDelete->Text = QApplication::Translate('Delete');
  92. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Page') . '?'));
  93. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  94. $this->btnDelete->Visible = $this->mctPage->EditMode;
  95. }
  96. // Control AjaxAction Event Handlers
  97. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  98. // Delegate "Save" processing to the PageMetaControl
  99. $this->mctPage->SavePage();
  100. $this->CloseSelf(true);
  101. }
  102. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  103. // Delegate "Delete" processing to the PageMetaControl
  104. $this->mctPage->DeletePage();
  105. $this->CloseSelf(true);
  106. }
  107. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  108. $this->CloseSelf(false);
  109. }
  110. // Close Myself and Call ClosePanelMethod Callback
  111. protected function CloseSelf($blnChangesMade) {
  112. $strMethod = $this->strClosePanelMethod;
  113. $this->objForm->$strMethod($blnChangesMade);
  114. }
  115. }
  116. ?>