v1.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace zin;
  3. requireWg('thinkModel');
  4. /**
  5. * 思引师PESTEL模型部件类。
  6. * thinmory PESTEL model widget class.
  7. */
  8. class thinkPestel extends thinkModel
  9. {
  10. public static function getPageCSS()
  11. {
  12. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  13. }
  14. /**
  15. * @param object $block
  16. */
  17. protected function buildItem($block)
  18. {
  19. $cards = array();
  20. foreach($block->steps as &$step) $cards[] = div(setClass('w-64 bg-canvas p-2 shadow relative', "card-{$step->options->questionType}"), $this->buildQuestionItem($step));
  21. return $cards;
  22. }
  23. protected function buildBody()
  24. {
  25. global $lang, $config;
  26. list($blocks, $mode) = $this->prop(array('blocks', 'mode'));
  27. $modelItems = array();
  28. $defaultTitle = $mode === 'preview' ? $lang->thinkwizard->unAssociated : '';
  29. $style = $mode === 'preview' ? null : setStyle(array('min-width' => '544px'));
  30. foreach($blocks as $blockIndex => $block)
  31. {
  32. $blockColor = $config->thinkbackground->blockColor[$blockIndex];
  33. $modelItems[] = div
  34. (
  35. setClass('relative w-1/' . count($blocks), 'block-' . $blockIndex),
  36. $style,
  37. $mode === 'preview' ? div(setClass('w-full text-center text-sm leading-tight text-gray-400'), $lang->thinkwizard->block . $lang->thinkwizard->blockList[$blockIndex]) : null,
  38. div
  39. (
  40. setClass('h-full mt-1 mx-px model-block bg-' . $blockColor . '-100'),
  41. div
  42. (
  43. setClass('h-16 px-2 py-3 w-full relative z-10 flex justify-center', 'text-' . $blockColor),
  44. span
  45. (
  46. setClass('item-step-title overflow-hidden'),
  47. setStyle(array('max-height' => '40px')),
  48. set::title($block->text ? $block->text : $defaultTitle),
  49. $block->text ? $block->text : $defaultTitle
  50. )
  51. ),
  52. isset($block->steps) ? div(setClass('py-2 px-2.5 relative z-10 flex flex-wrap gap-2.5'), $this->buildItem($block)) : null
  53. )
  54. );
  55. }
  56. return $modelItems;
  57. }
  58. protected function build()
  59. {
  60. $mode = $this->prop('mode');
  61. $className = $mode == 'preview' ? 'pb-4' : '';
  62. return div
  63. (
  64. setClass('flex model-pestel', $className),
  65. setStyle(array('min-height' => '256px')),
  66. $this->buildBody()
  67. );
  68. }
  69. }