3 Star 24 Fork 5

辰星恒奥 / TypechoInvitationCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Console.php 2.34 KB
一键复制 编辑 原始数据 按行查看 历史
 ̄□ ̄|| 提交于 2019-08-01 14:56 . 修复一些问题
<?php
/**
* 邀请码注册 控制台
*
*/
class InvitationCode_Console extends Typecho_Widget
{
/**
* 邀请码注册
* @return Typecho_Widget_Helper_Form
*/
public function generateCodeForm()
{
/** 构建表单 */
$options = Typecho_Widget::widget('Widget_Options');
$form = new Typecho_Widget_Helper_Form(Typecho_Common::url('/action/' . InvitationCode_Plugin::$action, $options->index),
Typecho_Widget_Helper_Form::POST_METHOD);
/** 生成数量 */
$num = new Typecho_Widget_Helper_Form_Element_Text('toNum_cxa', NULL, '10',
_t('邀请码生成数量'), _t('邀请码生成数量,默认为10次。'));
$num->input->setAttribute('class', 'mini');
$form->addInput($num->addRule('required', _t('必须填写邀请码生成数量'))
->addRule('isInteger', _t('生成数量必须是纯数字')));
/** 有效期 */
$duration = new Typecho_Widget_Helper_Form_Element_Text('duration_cxa', NULL, '0',
_t('邀请码有效期'), _t('邀请码有效期(单位:小时),默认为0永久,如果为1就是1小时。'));
$duration->input->setAttribute('class', 'mini');
$form->addInput($duration->addRule('isInteger', _t('有效期必须是纯数字')));
/** 前缀 */
$prefix = new Typecho_Widget_Helper_Form_Element_Text('prefix_cxa', NULL, 'cxa',
_t('邀请码前缀'), _t('邀请码附带的前缀'));
$prefix->input->setAttribute('class', 'mini');
$form->addInput($prefix);
/** 使用次数 */
$num = new Typecho_Widget_Helper_Form_Element_Text('num_cxa', NULL, '1',
_t('邀请码可使用次数'), _t('邀请码可使用次数,默认为1次,最大5000次。'));
$num->input->setAttribute('class', 'mini');
$form->addInput($num->addRule('isInteger', _t('使用次数必须是纯数字')));
/** 动作 */
$do = new Typecho_Widget_Helper_Form_Element_Hidden('do');
$form->addInput($do);
/** 提交按钮 */
$submit = new Typecho_Widget_Helper_Form_Element_Submit();
$submit->input->setAttribute('class', 'btn primary');
$form->addItem($submit);
/** 设置值 */
$do->value('generateCode');
$submit->value('生成邀请码');
return $form;
}
}
PHP
1
https://gitee.com/cx-a/TypechoInvitationCode.git
git@gitee.com:cx-a/TypechoInvitationCode.git
cx-a
TypechoInvitationCode
TypechoInvitationCode
master

搜索帮助