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.

146 lines
6.2 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 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 Quasi
  16. * @subpackage Drafts
  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 $lstPublicPermissions;
  39. public $lstUserPermissions;
  40. public $lstGroupPermissions;
  41. public $lstType;
  42. public $lstStatus;
  43. // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
  44. public $lstContentBlocks;
  45. public $lstContentCategories;
  46. public $lstUsergroups;
  47. // Other Controls
  48. public $btnSave;
  49. public $btnDelete;
  50. public $btnCancel;
  51. // Callback
  52. protected $strClosePanelMethod;
  53. public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
  54. // Call the Parent
  55. try {
  56. parent::__construct($objParentObject, $strControlId);
  57. } catch (QCallerException $objExc) {
  58. $objExc->IncrementOffset();
  59. throw $objExc;
  60. }
  61. // Setup Callback and Template
  62. $this->strTemplate = 'ContentItemEditPanel.tpl.php';
  63. $this->strClosePanelMethod = $strClosePanelMethod;
  64. // Construct the ContentItemMetaControl
  65. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  66. $this->mctContentItem = ContentItemMetaControl::Create($this, $intId);
  67. // Call MetaControl's methods to create qcontrols based on ContentItem's data fields
  68. $this->lblId = $this->mctContentItem->lblId_Create();
  69. $this->txtName = $this->mctContentItem->txtName_Create();
  70. $this->txtCssclass = $this->mctContentItem->txtCssclass_Create();
  71. $this->txtTitle = $this->mctContentItem->txtTitle_Create();
  72. $this->txtDescription = $this->mctContentItem->txtDescription_Create();
  73. $this->txtText = $this->mctContentItem->txtText_Create();
  74. $this->txtSortOrder = $this->mctContentItem->txtSortOrder_Create();
  75. $this->chkShowTitle = $this->mctContentItem->chkShowTitle_Create();
  76. $this->chkShowDescription = $this->mctContentItem->chkShowDescription_Create();
  77. $this->chkShowCreator = $this->mctContentItem->chkShowCreator_Create();
  78. $this->chkShowCreationDate = $this->mctContentItem->chkShowCreationDate_Create();
  79. $this->chkShowLastModification = $this->mctContentItem->chkShowLastModification_Create();
  80. $this->lblCreatorId = $this->mctContentItem->lblCreatorId_Create();
  81. $this->txtCopyrightNotice = $this->mctContentItem->txtCopyrightNotice_Create();
  82. $this->lblCreationDate = $this->mctContentItem->lblCreationDate_Create();
  83. $this->lblLastModification = $this->mctContentItem->lblLastModification_Create();
  84. $this->lstPublicPermissions = $this->mctContentItem->lstPublicPermissions_Create();
  85. $this->lstUserPermissions = $this->mctContentItem->lstUserPermissions_Create();
  86. $this->lstGroupPermissions = $this->mctContentItem->lstGroupPermissions_Create();
  87. $this->lstType = $this->mctContentItem->lstType_Create();
  88. $this->lstStatus = $this->mctContentItem->lstStatus_Create();
  89. $this->lstContentBlocks = $this->mctContentItem->lstContentBlocks_Create();
  90. $this->lstContentCategories = $this->mctContentItem->lstContentCategories_Create();
  91. $this->lstUsergroups = $this->mctContentItem->lstUsergroups_Create();
  92. // Create Buttons and Actions on this Form
  93. $this->btnSave = new QButton($this);
  94. $this->btnSave->Text = QApplication::Translate('Save');
  95. $this->btnSave->AddAction(new QClickEvent(), new QJavaScriptAction('tinyMCE.triggerSave();'));
  96. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  97. $this->btnSave->CausesValidation = $this;
  98. $this->btnCancel = new QButton($this);
  99. $this->btnCancel->Text = QApplication::Translate('Cancel');
  100. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));
  101. $this->btnDelete = new QButton($this);
  102. $this->btnDelete->Text = QApplication::Translate('Delete');
  103. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('ContentItem') . '?'));
  104. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
  105. $this->btnDelete->Visible = $this->mctContentItem->EditMode;
  106. QApplication::ExecuteJavaScript('tinyMCE.init({
  107. mode : "textareas",
  108. theme : "advanced",
  109. });');
  110. }
  111. // Control AjaxAction Event Handlers
  112. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  113. // Delegate "Save" processing to the ContentItemMetaControl
  114. $this->mctContentItem->SaveContentItem();
  115. $this->CloseSelf(true);
  116. }
  117. public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
  118. // Delegate "Delete" processing to the ContentItemMetaControl
  119. $this->mctContentItem->DeleteContentItem();
  120. $this->CloseSelf(true);
  121. }
  122. public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
  123. $this->CloseSelf(false);
  124. }
  125. // Close Myself and Call ClosePanelMethod Callback
  126. protected function CloseSelf($blnChangesMade) {
  127. $strMethod = $this->strClosePanelMethod;
  128. $this->objForm->$strMethod($blnChangesMade);
  129. }
  130. }
  131. ?>