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.

152 lines
5.1 KiB

13 years ago
  1. <?php
  2. // Include to load Quasi and Qcodo
  3. require('../core/Quasi.class.php');
  4. // Security check for ALLOW_REMOTE_ADMIN
  5. // To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
  6. QApplication::CheckRemoteAdmin();
  7. // Let's "magically" determine the list of genereated Class Panel Drafts by
  8. // just traversing through this directory, looking for "*ListPanel.class.php" and "*EditPanel.class.php"
  9. // Obviously, if you are wanting to make your own dashbaord, you should change this and use more
  10. // hard-coded means to determine which classes' paneldrafts you want to include/use in your dashboard.
  11. $objDirectory = opendir(dirname(__FILE__));
  12. $strClassNameArray = array();
  13. while ($strFile = readdir($objDirectory))
  14. {
  15. if(false !== strpos($strFile,'~') )
  16. continue;
  17. if ($intPosition = strpos($strFile, 'ListPanel.class.php'))
  18. {
  19. $strClassName = substr($strFile, 0, $intPosition);
  20. $strClassNameArray[$strClassName] = $strClassName . 'ListPanel';
  21. require($strClassName . 'ListPanel.class.php');
  22. if(file_exists('./' . $strClassName . 'EditPanel.class.php') )
  23. require($strClassName . 'EditPanel.class.php');
  24. }
  25. }
  26. natsort($strClassNameArray);
  27. class Dashboard extends QForm {
  28. protected $pnlClassNames;
  29. protected $pnlTitle;
  30. protected $pnlList;
  31. protected $pnlEdit;
  32. protected function Form_Create() {
  33. $this->pnlTitle = new QPanel($this);
  34. $this->pnlTitle->Text = 'AJAX Dashboard';
  35. $this->pnlList = new QPanel($this, 'pnlList');
  36. $this->pnlList->AutoRenderChildren = true;
  37. $this->pnlEdit = new QPanel($this, 'pnlEdit');
  38. $this->pnlEdit->AutoRenderChildren = true;
  39. $this->pnlEdit->Visible = false;
  40. $this->pnlClassNames = new QPanel($this, "classNames");
  41. $this->pnlClassNames->AutoRenderChildren = true;
  42. $this->pnlClassNames->Visible = true;
  43. // Use the strClassNameArray as magically determined above to aggregate the listbox of classes
  44. // Obviously, this should be modified if you want to make a custom dashboard
  45. global $strClassNameArray;
  46. foreach ($strClassNameArray as $strClassName)
  47. {
  48. $strMenuLabel = substr( $strClassName, 0 , strpos( $strClassName, "ListPanel" ) );
  49. $pnlClassName = new QPanel($this->pnlClassNames);
  50. $pnlClassName->Text = $strMenuLabel;
  51. $pnlClassName->CssClass = 'className';
  52. $pnlClassName->ActionParameter = $strClassName;
  53. $pnlClassName->AddAction(New QClickEvent(), new QAjaxAction('pnlClassNames_Change'));
  54. }
  55. $this->objDefaultWaitIcon = new QWaitIcon($this);
  56. }
  57. /**
  58. * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  59. * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  60. */
  61. protected function Form_Validate() {
  62. // By default, we report that Custom Validations passed
  63. $blnToReturn = true;
  64. // Custom Validation Rules
  65. // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
  66. $blnFocused = false;
  67. foreach ($this->GetErrorControls() as $objControl) {
  68. // Set Focus to the top-most invalid control
  69. if (!$blnFocused) {
  70. $objControl->Focus();
  71. $blnFocused = true;
  72. }
  73. // Blink on ALL invalid controls
  74. $objControl->Blink();
  75. }
  76. return $blnToReturn;
  77. }
  78. protected function pnlClassNames_Change($strFormId, $strControlId, $strParameter)
  79. {
  80. // Get rid of all child controls for list and edit panels
  81. $this->pnlList->RemoveChildControls(true);
  82. $this->pnlEdit->RemoveChildControls(true);
  83. $this->pnlEdit->Visible = false;
  84. $this->pnlList->Visible = true;
  85. if ($strClassName = $strParameter)
  86. {
  87. // We've selected a Class Name
  88. $objNewPanel = new $strClassName($this->pnlList, 'SetEditPane', 'CloseEditPane');
  89. $this->pnlTitle->Text = $strMenuLabel = substr( $strParameter, 0 , strpos( $strParameter, "ListPanel" ) );
  90. $this->pnlTitle->Text .= ' List';
  91. } else {
  92. $this->pnlTitle->Text = 'AJAX Dashboard';
  93. }
  94. }
  95. public function SetListPane(QPanel $objPanel)
  96. {
  97. $this->pnlEdit->RemoveChildControls(true);
  98. $this->pnlEdit->Visible = false;
  99. $this->pnlList->RemoveChildControls(true);
  100. $objPanel->SetParentControl($this->pnlList);
  101. $this->pnlList->Visible = true;
  102. }
  103. public function CloseEditPane($blnUpdatesMade) {
  104. // Close the Edit Pane
  105. $this->pnlEdit->RemoveChildControls(true);
  106. $this->pnlEdit->Visible = false;
  107. // If updates were made, let's "brute force" the updates to the screen by just refreshing the list pane altogether
  108. if ($blnUpdatesMade)
  109. $this->pnlList->Refresh();
  110. $this->pnlList->Visible = true;
  111. }
  112. public function SetEditPane(QPanel $objPanel = null)
  113. {
  114. $this->pnlList->Visible = false;
  115. $this->pnlEdit->RemoveChildControls(true);
  116. if ($objPanel) {
  117. $objPanel->SetParentControl($this->pnlEdit);
  118. $this->pnlEdit->Visible = true;
  119. } else {
  120. $this->pnlEdit->Visible = false;
  121. }
  122. }
  123. }
  124. Dashboard::Run('Dashboard');
  125. ?>