+ [task#124953] add think4p think model of thinmory.

This commit is contained in:
wangzemei
2024-08-06 15:28:06 +08:00
committed by 刘刚
parent 616a46ab0a
commit 37c679f51e
3 changed files with 90 additions and 1 deletions
+1
View File
@@ -215,6 +215,7 @@ function thinkCover(): thinkCover {return createWg('thinkCover', func_get_args()
function affected(): affected {return createWg('affected', func_get_args());}
function thinkPffa(): thinkPffa {return createWg('thinkPffa', func_get_args());}
function thinkPestel(): thinkPestel {return createWg('thinkPestel', func_get_args());}
function think4p(): think4p {return createWg('think4p', func_get_args());}
if(is_dir(__DIR__ . DS . 'wg' . DS . 'boardeditor'))
{
+88
View File
@@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
namespace zin;
requireWg('thinkModel');
/**
* 思引师4P模型部件类。
* thinmory 4P model widget class.
*/
class think4p extends thinkModel
{
protected function buildQuestion(array $steps): array
{
$questionList = array();
foreach($steps as &$step) $questionList[] = div(setClass('w-64 bg-canvas p-2 shadow'), $this->buildQuestionItem($step));
return $questionList;
}
protected function buildItem(int $order, object $block): node|array
{
global $app, $lang, $config;
$app->loadLang('thinkwizard');
$mode = $this->prop('mode');
$defaultTitle = $mode == 'preview' ? $lang->thinkwizard->unAssociated : '';
$blockTitle = $block->text ?: $defaultTitle;
$blockStyle = $mode == 'preview' ? array('min-height' => '200px', 'width' => '50%') : array('min-height' => '200px', 'width' => '1078px');
$blockColor = $config->thinkbackground->blockColor[$order];
$descSize = $mode === 'preview' ? 'text-sm' : 'text-2xl';
return div
(
setClass('relative col justify-between py-2 bg-canvas border border-canvas border-2 model-block', "bg-$blockColor-100", "block-$order"),
setStyle($blockStyle),
div
(
setClass('h-full'),
div(setClass('item-step-title text-center text-clip', "text-$blockColor"), set::title($blockTitle), $blockTitle),
!isset($block->steps) ? null : div(setClass('py-3 flex flex-wrap gap-2.5 relative z-10'), $this->buildQuestion($block->steps))
),
div(setClass('item-desc text-center leading-tight text-canvas', $descSize), $lang->thinkwizard->fourpDesc[$order])
);
}
protected function buildRow(int $key): node
{
global $app, $lang;
$app->loadLang('thinkwizard');
$blocks = $this->prop('blocks');
return div
(
setClass('px-2.5 col items-center'),
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])),
div
(
setClass('w-full flex items-center'),
$this->buildItem($key, $blocks[$key]),
$this->buildItem($key + 1, $blocks[$key + 1])
)
);
}
protected function buildBody(): array
{
$blocks = $this->prop('blocks');
$modelItems = array();
foreach($blocks as $key => $block)
{
if($key % 2 == 0) $modelItems[] = $this->buildRow($key);
}
return $modelItems;
}
protected function build(): node
{
$mode = $this->prop('mode');
$style = $mode == 'preview' ? setStyle(array('min-height' => '254px')) : setStyle(array('min-height' => '254px', 'width' => '2156px'));
return div
(
setClass('model-4p my-1 flex col flex-wrap justify-between'),
$style,
$this->buildBody()
);
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ class thinkResult extends wg
list($wizard, $mode, $blocks) = $this->prop(array('wizard', 'mode', 'blocks'));
$model = $wizard->model;
$wgMap = array('swot' => 'thinkSwot', 'pffa' => 'thinkPffa', 'pestel' => 'thinkPestel');
$wgMap = array('swot' => 'thinkSwot', 'pffa' => 'thinkPffa', 'pestel' => 'thinkPestel', '4p' => 'think4p');
if(!isset($wgMap[$model])) return array();
return createWg($wgMap[$model], array(set::mode($mode), set::blocks($blocks)));