dashlet.class.inc.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. abstract class Dashlet
  3. {
  4. public function __construct()
  5. {
  6. }
  7. public function FromDOMNode($oDOMNode)
  8. {
  9. }
  10. public function FromXml($sXml)
  11. {
  12. }
  13. public function FromParams($aParams)
  14. {
  15. }
  16. abstract public function Render($oPage, $bEditMode = false, $aExtraParams = array());
  17. public function ToXml(DOMNode $oContainerNode)
  18. {
  19. }
  20. public function GetForm()
  21. {
  22. }
  23. public function OnFieldUpdate($aParams, $sUpdatedFieldCode)
  24. {
  25. }
  26. static public function GetInfo()
  27. {
  28. return array(
  29. 'label' => '',
  30. 'icon' => '',
  31. 'description' => '',
  32. );
  33. }
  34. }
  35. class DashletHelloWorld extends Dashlet
  36. {
  37. public function __construct()
  38. {
  39. }
  40. public function FromDOMNode($oDOMNode)
  41. {
  42. }
  43. public function FromXml($sXml)
  44. {
  45. }
  46. public function FromParams($aParams)
  47. {
  48. }
  49. public function Render($oPage, $bEditMode = false, $aExtraParams = array())
  50. {
  51. $oPage->add('<div class="dashlet">');
  52. $oPage->add('<div style="text-align:center; line-height:5em" class="dashlet-content"><span>Hello World!</span></div>');
  53. $oPage->add('</div>');
  54. }
  55. public function ToXml(DOMNode $oContainerNode)
  56. {
  57. $oNewNodeNode = $oContainerNode->ownerDocument->createElement('hello_world', 'test');
  58. $oContainerNode->appendChild($oNewNodeNode);
  59. }
  60. public function GetForm()
  61. {
  62. }
  63. public function OnFieldUpdate($aParams, $sUpdatedFieldCode)
  64. {
  65. return array(
  66. 'status_ok' => true,
  67. 'redraw' => false,
  68. 'fields' => array(),
  69. );
  70. }
  71. static public function GetInfo()
  72. {
  73. return array(
  74. 'label' => 'Hello World',
  75. 'icon' => 'images/dashlet-text.png',
  76. 'description' => 'Hello World test Dashlet',
  77. );
  78. }
  79. }
  80. class DashletFakeBarChart extends Dashlet
  81. {
  82. public function __construct()
  83. {
  84. }
  85. public function FromDOMNode($oDOMNode)
  86. {
  87. }
  88. public function FromXml($sXml)
  89. {
  90. }
  91. public function FromParams($aParams)
  92. {
  93. }
  94. public function Render($oPage, $bEditMode = false, $aExtraParams = array())
  95. {
  96. $oPage->add('<div class="dashlet">');
  97. $oPage->add('<div style="text-align:center" class="dashlet-content"><div>Fake Bar Chart</div><divp><img src="../images/fake-bar-chart.png"/></div></div>');
  98. $oPage->add('</div>');
  99. }
  100. public function ToXml(DOMNode $oContainerNode)
  101. {
  102. $oNewNodeNode = $oContainerNode->ownerDocument->createElement('fake_bar_chart', 'test');
  103. $oContainerNode->appendChild($oNewNodeNode);
  104. }
  105. public function GetForm()
  106. {
  107. }
  108. public function OnFieldUpdate($aParams, $sUpdatedFieldCode)
  109. {
  110. return array(
  111. 'status_ok' => true,
  112. 'redraw' => false,
  113. 'fields' => array(),
  114. );
  115. }
  116. static public function GetInfo()
  117. {
  118. return array(
  119. 'label' => 'Bar Chart',
  120. 'icon' => 'images/dashlet-bar-chart.png',
  121. 'description' => 'Fake Bar Chart (for testing)',
  122. );
  123. }
  124. }
  125. class DashletFakePieChart extends Dashlet
  126. {
  127. public function __construct()
  128. {
  129. }
  130. public function FromDOMNode($oDOMNode)
  131. {
  132. }
  133. public function FromXml($sXml)
  134. {
  135. }
  136. public function FromParams($aParams)
  137. {
  138. }
  139. public function Render($oPage, $bEditMode = false, $aExtraParams = array())
  140. {
  141. $oPage->add('<div class="dashlet">');
  142. $oPage->add('<div style="text-align:center" class="dashlet-content"><div>Fake Pie Chart</div><div><img src="../images/fake-pie-chart.png"/></div></div>');
  143. $oPage->add('</div>');
  144. }
  145. public function ToXml(DOMNode $oContainerNode)
  146. {
  147. $oNewNodeNode = $oContainerNode->ownerDocument->createElement('fake_pie_chart', 'test');
  148. $oContainerNode->appendChild($oNewNodeNode);
  149. }
  150. public function GetForm()
  151. {
  152. }
  153. public function OnFieldUpdate($aParams, $sUpdatedFieldCode)
  154. {
  155. return array(
  156. 'status_ok' => true,
  157. 'redraw' => false,
  158. 'fields' => array(),
  159. );
  160. }
  161. static public function GetInfo()
  162. {
  163. return array(
  164. 'label' => 'Pie Chart',
  165. 'icon' => 'images/dashlet-pie-chart.png',
  166. 'description' => 'Fake Pie Chart (for testing)',
  167. );
  168. }
  169. }