v1.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace zin;
  3. requireWg('thinkModel');
  4. /**
  5. * 思引师4P模型部件类。
  6. * thinmory 4P model widget class.
  7. */
  8. class think4p extends thinkModel
  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, $config;
  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. $blockColor = $config->thinkbackground->blockColor[$order];
  33. $descSize = $mode === 'preview' ? 'text-sm' : 'text-2xl';
  34. return div
  35. (
  36. setClass('relative col justify-between py-2 px-2.5 bg-canvas border border-canvas border-2 model-block', "bg-$blockColor-100", "block-$order"),
  37. setStyle($blockStyle),
  38. div
  39. (
  40. setClass('h-full'),
  41. div(setClass('item-step-title text-center text-clip', "text-$blockColor"), set::title($blockTitle), $blockTitle),
  42. !isset($block->steps) ? null : div(setClass('py-3 flex flex-wrap gap-2.5 relative z-10'), $this->buildQuestion($block->steps))
  43. ),
  44. div(setClass('item-desc text-center leading-tight text-canvas', $descSize), $lang->thinkwizard->blockDescOf4p[$order])
  45. );
  46. }
  47. /**
  48. * @param int $key
  49. */
  50. protected function buildRow($key)
  51. {
  52. global $app, $lang;
  53. $app->loadLang('thinkwizard');
  54. list($blocks, $mode) = $this->prop(array('blocks', 'mode'));
  55. return div
  56. (
  57. setClass('col items-center'),
  58. $mode == 'preview' ? div(setClass('w-full flex items-center justify-between mt-1.5 mb-1 text-gray-400'), span($lang->thinkwizard->block . $lang->thinkwizard->blockList[$key]), span($lang->thinkwizard->block . $lang->thinkwizard->blockList[$key + 1])) : null,
  59. div
  60. (
  61. setClass('w-full flex items-stretch'),
  62. $this->buildItem($key, $blocks[$key]),
  63. $this->buildItem($key + 1, $blocks[$key + 1])
  64. )
  65. );
  66. }
  67. protected function buildBody()
  68. {
  69. $blocks = $this->prop('blocks');
  70. $modelItems = array();
  71. foreach($blocks as $key => $block)
  72. {
  73. if($key % 2 == 0) $modelItems[] = $this->buildRow($key);
  74. }
  75. return $modelItems;
  76. }
  77. protected function build()
  78. {
  79. $mode = $this->prop('mode');
  80. $style = $mode == 'preview' ? setStyle(array('min-height' => '254px')) : setStyle(array('min-height' => '254px', 'min-width' => '2156px'));
  81. return div
  82. (
  83. setClass('model-4p my-1 flex col flex-wrap justify-between'),
  84. $style,
  85. $this->buildBody()
  86. );
  87. }
  88. }