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.

138 lines
5.4 KiB

12 years ago
  1. <?php
  2. // Include prepend.inc to load Qcodo
  3. require('../../includes/prepend.inc.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. if(false !== strpos($strFile,'~') )
  15. continue;
  16. if ($intPosition = strpos($strFile, 'ListPanel.class.php')) {
  17. $strClassName = substr($strFile, 0, $intPosition);
  18. $strClassNameArray[$strClassName] = $strClassName . 'ListPanel';
  19. require($strClassName . 'ListPanel.class.php');
  20. if(file_exists('./' . $strClassName . 'EditPanel.class.php') )
  21. require($strClassName . 'EditPanel.class.php');
  22. }
  23. }
  24. natsort($strClassNameArray);
  25. class Dashboard extends QForm {
  26. protected $pnlClassNames;
  27. protected $pnlTitle;
  28. protected $pnlList;
  29. protected $pnlEdit;
  30. protected function Form_Create() {
  31. $this->pnlTitle = new QPanel($this);
  32. $this->pnlTitle->Text = 'AJAX Dashboard';
  33. $this->pnlList = new QPanel($this, 'pnlList');
  34. $this->pnlList->AutoRenderChildren = true;
  35. $this->pnlEdit = new QPanel($this, 'pnlEdit');
  36. $this->pnlEdit->AutoRenderChildren = true;
  37. $this->pnlEdit->Visible = false;
  38. $this->pnlClassNames = new QPanel($this, "classNames");
  39. $this->pnlClassNames->AutoRenderChildren = true;
  40. $this->pnlClassNames->Visible = true;
  41. // Use the strClassNameArray as magically determined above to aggregate the listbox of classes
  42. // Obviously, this should be modified if you want to make a custom dashboard
  43. global $strClassNameArray;
  44. foreach ($strClassNameArray as $strClassName)
  45. {
  46. $pnl_name = substr( $strClassName, 0 , strpos( $strClassName, "ListPanel" ) );
  47. $pnlClassName = new QPanel($this->pnlClassNames);
  48. $pnlClassName->Text =$pnl_name;
  49. $pnlClassName->CssClass = 'className';
  50. $pnlClassName->ActionParameter = $strClassName;
  51. $pnlClassName->AddAction(New QClickEvent(), new QAjaxAction('pnlClassNames_Change'));
  52. }
  53. $this->objDefaultWaitIcon = new QWaitIcon($this);
  54. }
  55. /**
  56. * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  57. * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  58. */
  59. protected function Form_Validate() {
  60. // By default, we report that Custom Validations passed
  61. $blnToReturn = true;
  62. // Custom Validation Rules
  63. // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
  64. $blnFocused = false;
  65. foreach ($this->GetErrorControls() as $objControl) {
  66. // Set Focus to the top-most invalid control
  67. if (!$blnFocused) {
  68. $objControl->Focus();
  69. $blnFocused = true;
  70. }
  71. // Blink on ALL invalid controls
  72. $objControl->Blink();
  73. }
  74. return $blnToReturn;
  75. }
  76. protected function pnlClassNames_Change($strFormId, $strControlId, $strParameter) {
  77. // Get rid of all child controls for list and edit panels
  78. $this->pnlList->RemoveChildControls(true);
  79. $this->pnlEdit->RemoveChildControls(true);
  80. $this->pnlEdit->Visible = false;
  81. if ($strClassName = $strParameter) {
  82. // We've selected a Class Name
  83. $objNewPanel = new $strClassName($this->pnlList, 'SetEditPane', 'CloseEditPane');
  84. $this->pnlTitle->Text = $strParameter;
  85. } else {
  86. $this->pnlTitle->Text = 'AJAX Dashboard';
  87. }
  88. }
  89. /* public function SetListPane(QPanel $objPanel) {
  90. $this->pnlList->RemoveChildControls(true);
  91. $objPanel->SetParentControl($this->pnlList);
  92. }*/
  93. public function CloseEditPane($blnUpdatesMade) {
  94. // Close the Edit Pane
  95. $this->pnlEdit->RemoveChildControls(true);
  96. $this->pnlEdit->Visible = false;
  97. // If updates were made, let's "brute force" the updates to the screen by just refreshing the list pane altogether
  98. if ($blnUpdatesMade)
  99. $this->pnlList->Refresh();
  100. }
  101. public function SetEditPane(QPanel $objPanel = null) {
  102. $this->pnlEdit->RemoveChildControls(true);
  103. if ($objPanel) {
  104. $objPanel->SetParentControl($this->pnlEdit);
  105. $this->pnlEdit->Visible = true;
  106. } else {
  107. $this->pnlEdit->Visible = false;
  108. }
  109. }
  110. }
  111. Dashboard::Run('Dashboard');
  112. ?>