v1.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * The mindmap widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author sunhao<sunhao@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. /**
  13. * 脑图(mindmap)部件。
  14. * The mindmap widget class.
  15. */
  16. class mindmap extends wg
  17. {
  18. /**
  19. * @var mixed[]
  20. */
  21. protected static $defineProps = array
  22. (
  23. 'data?: array',
  24. 'width?: string|number="100%"',
  25. 'height?: string|number="300px"',
  26. 'hotkeyEnable?: bool',
  27. 'hotkeys?: array',
  28. 'lang?: string',
  29. 'langs?: array',
  30. 'nodeTeamplate?: string',
  31. 'hSpace?: number',
  32. 'vSpace?: number',
  33. 'canvasPadding?: number',
  34. 'removingNodeTip?: string',
  35. 'lineCurvature?: number',
  36. 'subLineWidth?: number',
  37. 'lineColor?: string',
  38. 'lineOpacity?: number',
  39. 'lineSaturation?: number',
  40. 'lineLightness?: number',
  41. 'nodeLineWidth?: number',
  42. 'showToggleButton?: bool',
  43. 'readonly?: bool',
  44. 'minimap?: bool',
  45. 'toolbar?: bool',
  46. 'zoom?: number',
  47. 'zoomMax?: number',
  48. 'zoomMin?: number',
  49. 'minimapHeight?: number',
  50. 'enableDrag?: bool',
  51. 'manual?: bool',
  52. 'afterNodeLoad?: function'
  53. );
  54. protected function build()
  55. {
  56. global $app;
  57. list($width, $height) = $this->prop(array('width', 'height'));
  58. $dataVarName = "_mindmap_$this->gid";
  59. $mindmapPath = $app->getWebRoot() . 'js/mindmap/index.html?options=' . $dataVarName;
  60. $options = $this->props->pick(array('hotkeyEnable', 'hotkeys', 'lang', 'langs', 'data', 'nodeTeamplate', 'hSpace', 'vSpace', 'canvasPadding', 'removingNodeTip', 'lineCurvature', 'subLineWidth', 'lineColor', 'lineOpacity', 'lineSaturation', 'lineLightness', 'nodeLineWidth', 'showToggleButton', 'readonly', 'minimap', 'toolbar', 'zoom', 'zoomMax', 'zoomMin', 'minimapHeight', 'enableDrag', 'manual', 'afterNodeLoad'));
  61. return array
  62. (
  63. h::iframe
  64. (
  65. set::className('mindmap-iframe'),
  66. set::src($mindmapPath),
  67. set::allowfullscreen(true),
  68. set::allowtransparency(true),
  69. set::frameborder('no'),
  70. set::scrolling('auto'),
  71. set::style(array('width' => $width, 'height' => $height)),
  72. set($this->getRestProps())
  73. ),
  74. h::jsVar("window.$dataVarName", $options)
  75. );
  76. }
  77. }