bottom_20 = array('AutoSlug_Plugin', 'ajax');
Typecho_Plugin::factory('admin/write-page.php')->bottom_20 = array('AutoSlug_Plugin', 'ajax');
Helper::addAction('auto-slug', 'AutoSlug_Action');
return _t('请配置此插件的API KEY, 以使您的插件生效');
}
/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate()
{
Helper::removeAction('auto-slug');
}
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
/** 生成模式 */
$mode = new Typecho_Widget_Helper_Form_Element_Radio(
'mode',
array(
'baidu' => _t('百度翻译'),
'youdao' => _t('有道翻译'),
'google' => _t('谷歌翻译'),
'pinyin' => _t('拼音')
),
'baidu',
_t('生成模式'),
_t('默认为百度模式,除了拼音模式,英文翻译模式都需要填写相应的API')
);
$form->addInput($mode);
/** 百度翻译 */
$bdAppid = new Typecho_Widget_Helper_Form_Element_Text(
'bdAppid', NULL, '',
_t('百度翻译 APP ID'),
_t('获取 APP ID')
);
$form->addInput($bdAppid);
$bdKey = new Typecho_Widget_Helper_Form_Element_Text(
'bdKey', NULL, '',
_t('百度翻译密钥'),
_t('获取密钥')
);
$form->addInput($bdKey);
/** 有道翻译 */
$ydKey = new Typecho_Widget_Helper_Form_Element_Text(
'ydKey', NULL, '',
_t('有道翻译 API Key'),
_t('获取 API Key')
);
$form->addInput($ydKey);
$ydFrom = new Typecho_Widget_Helper_Form_Element_Text(
'ydFrom', NULL, '',
_t('有道翻译 keyfrom'),
_t('获取 API Key')
);
$form->addInput($ydFrom);
}
/**
* 个人用户的配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
/**
* ajax执行action
*
* @access public
* @param array $contents 文章输入信息
* @return void
*/
public static function ajax()
{
Typecho_Widget::widget('Widget_Options')->to($options);
?>