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

class CiyunPublisher_Plugin implements Typecho_Plugin_Interface
{
    public static function activate()
    {
        return _t('CiyunPublisher 已启用，请在插件设置中生成 API Token。');
    }

    public static function deactivate()
    {
    }

    public static function config(Typecho_Widget_Helper_Form $form)
    {
        $token = new Typecho_Widget_Helper_Form_Element_Text(
            'token',
            null,
            '',
            _t('API Token'),
            _t('请填写至少 32 位随机 Token，客户端发布时使用。')
        );
        $form->addInput($token);

        $whitelistIps = new Typecho_Widget_Helper_Form_Element_Textarea(
            'whitelist_ips',
            null,
            '',
            _t('白名单 IP'),
            _t('可选，多个 IP 用逗号或换行分隔。留空表示不限制。')
        );
        $form->addInput($whitelistIps);

        $forceDraft = new Typecho_Widget_Helper_Form_Element_Radio(
            'force_draft',
            ['1' => _t('强制草稿'), '0' => _t('按客户端状态发布')],
            '1',
            _t('发布安全策略')
        );
        $form->addInput($forceDraft);
    }

    public static function personalConfig(Typecho_Widget_Helper_Form $form)
    {
    }
}
