<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;

$cls = function (string $tab): string {
    return 'typecho-option mirai-option mirai-tab-' . $tab;
};

$pointsEnable = new \Typecho\Widget\Helper\Form\Element\Select(
    'pointsEnable',
    ['1' => '启用', '0' => '禁用'],
    '0',
    _t('启用积分系统'),
    _t('开启后用户可通过任务获取积分，积分可用于购买内容、兑换VIP等')
);
$pointsEnable->setAttribute('class', $cls('points'));
$pointsEnable->input->setAttribute('data-toggle-targets', 'pointsName,pointsRate,pointsPurchaseMin,pointsPurchaseMax,pointsDailyLimit,pointsTask_sign_up,pointsTask_sign_in,pointsTask_post_new,pointsTask_post_like,pointsTask_post_collect,pointsTask_comment_new,pointsVipExchangeEnable');
$pointsEnable->input->setAttribute('data-toggle-value', '1');
$form->addInput($pointsEnable);

$pointsName = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsName',
    null,
    '积分',
    _t('积分名称'),
    _t('自定义积分显示名称，如"金币"、"钻石"等')
);
$pointsName->setAttribute('class', $cls('points'));
$form->addInput($pointsName);

$pointsRate = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsRate',
    null,
    '30',
    _t('购买汇率'),
    _t('1元=N积分，默认30')
);
$pointsRate->setAttribute('class', $cls('points'));
$pointsRate->input->setAttribute('type', 'number');
$pointsRate->input->setAttribute('min', '1');
$form->addInput($pointsRate);

$pointsPurchaseMin = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsPurchaseMin',
    null,
    '300',
    _t('最小购买量'),
    _t('单次购买积分的最小数量')
);
$pointsPurchaseMin->setAttribute('class', $cls('points'));
$pointsPurchaseMin->input->setAttribute('type', 'number');
$pointsPurchaseMin->input->setAttribute('min', '1');
$form->addInput($pointsPurchaseMin);

$pointsPurchaseMax = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsPurchaseMax',
    null,
    '50000',
    _t('最大购买量'),
    _t('单次购买积分的最大数量')
);
$pointsPurchaseMax->setAttribute('class', $cls('points'));
$pointsPurchaseMax->input->setAttribute('type', 'number');
$pointsPurchaseMax->input->setAttribute('min', '1');
$form->addInput($pointsPurchaseMax);

$pointsDailyLimit = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsDailyLimit',
    null,
    '100',
    _t('每日免费获取上限'),
    _t('用户每日通过免费任务最多可获取的积分数量')
);
$pointsDailyLimit->setAttribute('class', $cls('points'));
$pointsDailyLimit->input->setAttribute('type', 'number');
$pointsDailyLimit->input->setAttribute('min', '0');
$form->addInput($pointsDailyLimit);

$pointsTaskSignUp = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsTask_sign_up',
    null,
    '20',
    _t('注册奖励'),
    _t('新用户注册时奖励的积分数量')
);
$pointsTaskSignUp->setAttribute('class', $cls('points'));
$pointsTaskSignUp->input->setAttribute('type', 'number');
$pointsTaskSignUp->input->setAttribute('min', '0');
$form->addInput($pointsTaskSignUp);

$pointsTaskSignIn = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsTask_sign_in',
    null,
    '5',
    _t('每日登录'),
    _t('每日首次登录奖励的积分数量')
);
$pointsTaskSignIn->setAttribute('class', $cls('points'));
$pointsTaskSignIn->input->setAttribute('type', 'number');
$pointsTaskSignIn->input->setAttribute('min', '0');
$form->addInput($pointsTaskSignIn);

$pointsTaskPostNew = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsTask_post_new',
    null,
    '5',
    _t('发布文章'),
    _t('发布文章奖励的积分数量')
);
$pointsTaskPostNew->setAttribute('class', $cls('points'));
$pointsTaskPostNew->input->setAttribute('type', 'number');
$pointsTaskPostNew->input->setAttribute('min', '0');
$form->addInput($pointsTaskPostNew);

$pointsTaskPostLike = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsTask_post_like',
    null,
    '1',
    _t('文章获赞'),
    _t('文章被点赞时作者获得的积分数量')
);
$pointsTaskPostLike->setAttribute('class', $cls('points'));
$pointsTaskPostLike->input->setAttribute('type', 'number');
$pointsTaskPostLike->input->setAttribute('min', '0');
$form->addInput($pointsTaskPostLike);

$pointsTaskPostCollect = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsTask_post_collect',
    null,
    '2',
    _t('文章被收藏'),
    _t('文章被收藏时作者获得的积分数量')
);
$pointsTaskPostCollect->setAttribute('class', $cls('points'));
$pointsTaskPostCollect->input->setAttribute('type', 'number');
$pointsTaskPostCollect->input->setAttribute('min', '0');
$form->addInput($pointsTaskPostCollect);

$pointsTaskCommentNew = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsTask_comment_new',
    null,
    '2',
    _t('发表评论'),
    _t('发表评论奖励的积分数量')
);
$pointsTaskCommentNew->setAttribute('class', $cls('points'));
$pointsTaskCommentNew->input->setAttribute('type', 'number');
$pointsTaskCommentNew->input->setAttribute('min', '0');
$form->addInput($pointsTaskCommentNew);

$pointsVipExchangeEnable = new \Typecho\Widget\Helper\Form\Element\Select(
    'pointsVipExchangeEnable',
    ['1' => '启用', '0' => '禁用'],
    '0',
    _t('启用积分兑换VIP'),
    _t('允许用户使用积分兑换VIP会员')
);
$pointsVipExchangeEnable->setAttribute('class', $cls('points'));
$pointsVipExchangeEnable->input->setAttribute('data-toggle-targets', 'pointsVipExchange_1,pointsVipExchange_2,pointsVipExchange_3');
$pointsVipExchangeEnable->input->setAttribute('data-toggle-value', '1');
$form->addInput($pointsVipExchangeEnable);

$pointsVipExchange_1 = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsVipExchange_1',
    null,
    '3000',
    _t('兑换VIP1所需积分'),
    _t('使用积分兑换30天VIP1所需的积分数量，0表示不支持兑换该等级')
);
$pointsVipExchange_1->setAttribute('class', $cls('points') . ' vip-level-1');
$pointsVipExchange_1->input->setAttribute('type', 'number');
$pointsVipExchange_1->input->setAttribute('min', '0');
$form->addInput($pointsVipExchange_1);

$pointsVipExchange_2 = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsVipExchange_2',
    null,
    '5000',
    _t('兑换VIP2所需积分'),
    _t('使用积分兑换30天VIP2所需的积分数量，0表示不支持兑换该等级')
);
$pointsVipExchange_2->setAttribute('class', $cls('points') . ' vip-level-2');
$pointsVipExchange_2->input->setAttribute('type', 'number');
$pointsVipExchange_2->input->setAttribute('min', '0');
$form->addInput($pointsVipExchange_2);

$pointsVipExchange_3 = new \Typecho\Widget\Helper\Form\Element\Text(
    'pointsVipExchange_3',
    null,
    '8000',
    _t('兑换VIP3所需积分'),
    _t('使用积分兑换30天VIP3所需的积分数量，0表示不支持兑换该等级')
);
$pointsVipExchange_3->setAttribute('class', $cls('points') . ' vip-level-3');
$pointsVipExchange_3->input->setAttribute('type', 'number');
$pointsVipExchange_3->input->setAttribute('min', '0');
$form->addInput($pointsVipExchange_3);
