v1.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace zin;
  3. requireWg('thinkModel');
  4. /**
  5. * 思引波特五力模型部件类。
  6. * thinmory porter's five forces model widget class.
  7. */
  8. class thinkPffa extends thinkModel
  9. {
  10. public static function getPageCSS()
  11. {
  12. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  13. }
  14. /**
  15. * @param mixed[] $steps
  16. */
  17. protected function buildQuestion($steps)
  18. {
  19. $questionList = array();
  20. foreach($steps as $step) $questionList[] = div(setClass('w-64 bg-canvas p-2 shadow', "card-{$step->options->questionType}"), $this->buildQuestionItem($step));
  21. return $questionList;
  22. }
  23. protected function buildCards($blockIndex)
  24. {
  25. global $lang, $config;
  26. $blocks = $this->prop('blocks');
  27. $mode = $this->prop('mode');
  28. $blockColor = $config->thinkbackground->blockColor[$blockIndex];
  29. $defaultTitle = $mode === 'preview' ? $lang->thinkwizard->unAssociated : '';
  30. $descFontSize = $mode === 'preview' ? 'text-sm' : 'text-2xl';
  31. return div
  32. (
  33. setClass('w-full h-full p-2.5 outline overflow-auto col justify-between gap-2 bg-' . $blockColor . '-100', $blockColor . '-outline'),
  34. div(setClass('block-content col items-center gap-2'), div
  35. (
  36. setClass('item-step-title text-clip', 'text-' . $blockColor),
  37. set::title(!empty($blocks[$blockIndex]->text) ? $blocks[$blockIndex]->text : null),
  38. !empty($blocks[$blockIndex]->text) ? $blocks[$blockIndex]->text : $defaultTitle
  39. ), div(setClass('w-full flex flex-wrap gap-2.5'), !isset($blocks[$blockIndex]->steps) ? null : $this->buildQuestion($blocks[$blockIndex]->steps))),
  40. div(setClass('item-desc text-center leading-tight text-canvas', $descFontSize), $lang->thinkwizard->pffaGroundText[$blockIndex])
  41. );
  42. }
  43. /**
  44. * @param int $blockIndex
  45. * @param string $blockClass
  46. * @param string $contentClass
  47. * @param string $direction
  48. */
  49. protected function buildBlock($blockIndex, $blockClass, $contentClass, $direction = '')
  50. {
  51. global $lang;
  52. $mode = $this->prop('mode');
  53. $blockWidth = in_array($blockIndex, array(1, 2)) ? '1108px' : '1078px';
  54. $blockStyle = $mode === 'preview' ? null : setStyle(array('width' => $blockWidth));
  55. $titleClass = 'text-gray-400 text-sm';
  56. if($blockIndex == 3) $titleClass .= ' absolute';
  57. if($blockIndex == 2) $titleClass .= ' ml-4';
  58. $blockTitle = $mode === 'preview' ? span(setClass($titleClass), $lang->thinkwizard->block . $lang->thinkwizard->blockList[$blockIndex]) : null;
  59. $triangle = $direction ? div(setClass('triangle triangle-' . $direction)) : null;
  60. $contentClass .= ' mt-1 flex';
  61. return div
  62. (
  63. setClass($blockClass, $mode === 'preview' ? 'w-1/3' : ''),
  64. $blockStyle,
  65. $blockTitle,
  66. div
  67. (
  68. setClass($contentClass),
  69. in_array($blockIndex, array(2, 3)) ? $triangle : null,
  70. $this->buildCards($blockIndex),
  71. in_array($blockIndex, array(2, 3)) ? null : $triangle
  72. )
  73. );
  74. }
  75. protected function build()
  76. {
  77. return div
  78. (
  79. setClass('col justify-center items-center gap-3.5 model-pffa'),
  80. $this->buildBlock(0, 'block-0', 'justify-center flex-wrap', 'down'),
  81. div
  82. (
  83. setClass('w-full h-full flex items-stretch justify-center pffa-middle'),
  84. $this->buildBlock(1, 'col justify-stretch pr-3.5 block-1', 'h-full items-center', 'right'),
  85. $this->buildBlock(4, 'col justify-stretch block-4', 'h-full justify-center flex-wrap'),
  86. $this->buildBlock(2, 'col justify-stretch pl-3.5 block-2', 'h-full items-center', 'left')
  87. ),
  88. $this->buildBlock(3, 'relative block-3', 'justify-center flex-wrap', 'up')
  89. );
  90. }
  91. }