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.

140 lines
5.8 KiB

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