baserproject / basercms

baserCMS : Based Website Development Project
http://basercms.net
Other
165 stars 126 forks source link

【メール】リファクタリング #1577

Open yama opened 3 years ago

yama commented 3 years ago

概要

メール送信フォームプラグインに関して、段階的なリファクタリングを行ないます。

現状のスクリプトは <th class="col-head" width="150"> のような決め打ち記述もあったりして、 汎用性に弱い構造になっていると思います。これをすっきりと最適化したいと思います。

baserCMS version : 4.4.x

yama commented 3 years ago
<tr id="{%row_id%}"{%display%}><th>{%title%}<span class="{%required_class%}">{%required_word%}</span></th>

こんな感じで考え中です。

yama commented 3 years ago
$template = [
    'row' => '<tr id="{%row_id%}"{%display%}><th class="col-head" width="150">{%title%}</th><td class="col-input">{%form%}</td></tr>',
    'title' => '{%title%}<span class="{%required_class%}">{%required_word%}</span>',
    'form' => [
        'wrap'        => '<span id="{%row_id%}">{%description%}{%before%}{%form%}{%after%}{%attention%}{%error%}{%group-error%}</span>',
        'description' => '<span class="mail-description">{%description%}</span>',
        'before'      => '<span class="mail-before-attachment">{%before%}</span>',
        'after'       => '<span class="mail-after-attachment">{%after%}</span>',
        'attention'   => '<span class="mail-attention">{%attention%}</span>'
    ]
];

だいたいできました。これをelement()の第2引数で渡せばカスタマイズしやすいと思います。