v1.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace zin;
  3. requireWg('thinkModel');
  4. class thinkAnsoff extends thinkModel
  5. {
  6. public static function getPageCSS()
  7. {
  8. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  9. }
  10. /**
  11. * @param int $order
  12. */
  13. protected function buildAreaCard($order)
  14. {
  15. $blocks = $this->prop('blocks');
  16. $area = array();
  17. foreach($blocks as $block)
  18. {
  19. if($order == $block->id && !empty($block->steps)) $area[] = $this->buildResultCard($block->steps, $block->id + 1);
  20. }
  21. return $area;
  22. }
  23. /**
  24. * @param string|object $block
  25. * @param int $order
  26. */
  27. protected function buildItem($order, $block)
  28. {
  29. $mode = $this->prop('mode');
  30. $blockStyle = $mode == 'preview' ? array('min-height' => '200px', 'width' => '50%') : array('min-height' => '200px', 'width' => '1078px');
  31. $blockName = is_string($block) ? $block : $block->text;
  32. return div
  33. (
  34. setClass('relative col justify-between py-2 px-2.5 bg-canvas model-block', "block-$order"),
  35. setStyle($blockStyle),
  36. div(setClass('flex flex-wrap gap-2.5'), $mode == 'view' ? $this->buildAreaCard($order) : null),
  37. div(setClass('item-step-title text-center'), $blockName)
  38. );
  39. }
  40. /**
  41. * @param int $key
  42. * @param bool $showTitle
  43. */
  44. protected function buildRow($key, $showTitle = false)
  45. {
  46. global $app, $lang;
  47. $app->loadLang('thinkwizard');
  48. list($blocks, $mode) = $this->prop(array('blocks', 'mode'));
  49. $titleKey = $key == 0 ? 2 : 3;
  50. $rowContent = div
  51. (
  52. setClass('col items-center mt-4'),
  53. div
  54. (
  55. setClass('w-full flex items-stretch gap-4'),
  56. div
  57. (
  58. setClass('flex items-center justify-center text-gray-400 font-medium item-step-title item-vertical-title'),
  59. setStyle(array('writing-mode' => 'vertical-rl')),
  60. $lang->thinkwizard->ansoff->titles[$titleKey]
  61. ),
  62. $this->buildItem($key, $blocks[$key]),
  63. $this->buildItem($key + 1, $blocks[$key + 1])
  64. )
  65. );
  66. $paddingLeft = $mode == 'preview' ? '36px' : '60px';
  67. return $showTitle ? div
  68. (
  69. div(setClass('w-full flex mb-4 gap-4'), setStyle(array('padding-left' => $paddingLeft)), div(setClass('flex-1 flex items-center justify-center text-gray-400 font-medium item-step-title'), $lang->thinkwizard->ansoff->titles[0]), div(setClass('flex-1 flex items-center justify-center text-gray-400 font-medium item-step-title'), $lang->thinkwizard->ansoff->titles[1])),
  70. $rowContent
  71. ) : $rowContent;
  72. }
  73. protected function buildBody()
  74. {
  75. $blocks = $this->prop('blocks');
  76. $modelItems = array();
  77. foreach($blocks as $key => $block)
  78. {
  79. if($key % 2 == 0) $modelItems[] = $this->buildRow($key, $key == 0);
  80. }
  81. return $modelItems;
  82. }
  83. protected function build()
  84. {
  85. $mode = $this->prop('mode');
  86. $style = $mode == 'preview' ? setStyle(array('min-height' => '254px')) : setStyle(array('min-height' => '254px', 'min-width' => '2200px'));
  87. return div
  88. (
  89. setClass('model-ansoff my-1'),
  90. $style,
  91. $this->buildBody()
  92. );
  93. }
  94. }