v1.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace zin;
  3. requireWg('thinkModel');
  4. class thinkSwot extends thinkModel
  5. {
  6. public static function getPageCSS()
  7. {
  8. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  9. }
  10. /**
  11. * @param mixed[] $steps
  12. */
  13. protected function buildQuestion($steps)
  14. {
  15. $questionList = array();
  16. foreach($steps as &$step) $questionList[] = div(setClass('w-64 bg-canvas p-2 shadow', "card-{$step->options->questionType}"), $this->buildQuestionItem($step));
  17. return $questionList;
  18. }
  19. /**
  20. * @return \zin\node|mixed[]
  21. * @param object $block
  22. * @param int $order
  23. */
  24. protected function buildItem($order, $block)
  25. {
  26. global $app, $lang;
  27. $app->loadLang('thinkwizard');
  28. $mode = $this->prop('mode');
  29. $defaultTitle = $mode == 'preview' ? $lang->thinkwizard->unAssociated : '';
  30. $blockTitle = $block->text ?: $defaultTitle;
  31. $blockStyle = $mode == 'preview' ? array('min-height' => '200px', 'width' => '50%') : array('min-height' => '200px', 'width' => '1078px');
  32. return div
  33. (
  34. setClass('relative py-1 px-2.5 bg-canvas border border-canvas border-2 model-block', "block-$order"),
  35. setStyle($blockStyle),
  36. div
  37. (
  38. setClass('h-full'),
  39. div(setClass('item-step-title text-center text-clip'), set::title($blockTitle), $blockTitle),
  40. !isset($block->steps) ? null : div(setClass('py-3 flex flex-wrap gap-2.5 relative z-10'), $this->buildQuestion($block->steps))
  41. )
  42. );
  43. }
  44. /**
  45. * @param int $key
  46. */
  47. protected function buildRow($key)
  48. {
  49. $blocks = $this->prop('blocks');
  50. return div
  51. (
  52. setClass('w-full flex items-stretch'),
  53. $this->buildItem($key, $blocks[$key]),
  54. $this->buildItem($key + 1, $blocks[$key + 1])
  55. );
  56. }
  57. protected function buildBody()
  58. {
  59. $blocks = $this->prop('blocks');
  60. $modelItems = array();
  61. foreach($blocks as $key => $block)
  62. {
  63. if($key % 2 == 0) $modelItems[] = $this->buildRow($key);
  64. }
  65. return $modelItems;
  66. }
  67. protected function build()
  68. {
  69. global $app, $lang;
  70. $app->loadLang('thinkwizard');
  71. $mode = $this->prop('mode');
  72. $style = $mode == 'preview' ? setStyle(array('min-height' => '254px')) : setStyle(array('min-height' => '254px', 'min-width' => '2156px'));
  73. $model = array(
  74. div
  75. (
  76. setClass('model-swot my-1 flex flex-wrap justify-between'),
  77. $style,
  78. $this->buildBody()
  79. )
  80. );
  81. if($mode == 'preview')
  82. {
  83. array_unshift($model, div(setClass('flex justify-between text-gray-400'), span($lang->thinkwizard->block . $lang->thinkwizard->blockList[0]), span($lang->thinkwizard->block . $lang->thinkwizard->blockList[1])));
  84. $model[] = div(setClass('flex justify-between text-gray-400'), span($lang->thinkwizard->block . $lang->thinkwizard->blockList[2]), span($lang->thinkwizard->block . $lang->thinkwizard->blockList[3]));
  85. }
  86. return $model;
  87. }
  88. }