public static function config(Typecho_Widget_Helper_Form $form) { /** * 节点 */ $endpointList = array("" => _t('请选择所属地域'), "oss-cn-beijing.aliyuncs.com" => _t('北京'), "oss-cn-qingdao.aliyuncs.com" => _t('青岛'), "oss-cn-shenzhen.aliyuncs.com" => _t('深圳'), "oss-cn-hangzhou.aliyuncs.com" => _t('杭州'), "oss-cn-shanghai.aliyuncs.com" => _t('上海')); $endpoint = new Typecho_Widget_Helper_Form_Element_Select('endpoint', $endpointList, 'oss-cn-beijing.aliyuncs.com', _t('所属地域'), _t('请选择<strong style="color:#C33;">bucket对应节点</strong>,否则无法使用,默认为北京!')); $form->addInput($endpoint->addRule('required', _t('所属地域 不能为空!'))); $bucket = new Typecho_Widget_Helper_Form_Element_Text('bucket', null, null, _t('Bucket名称:')); $form->addInput($bucket->addRule('required', _t('“空间名称”不能为空!'))); $accessid = new Typecho_Widget_Helper_Form_Element_Text('accessid', null, null, _t('Access Key ID'), _t('点击<a href="https://ak-console.aliyun.com/#/accesskey">这里</a>查看Access Key ID&Access Key Secret')); $form->addInput($accessid->addRule('required', _t('AccessID 不能为空!'))); $accesskey = new Typecho_Widget_Helper_Form_Element_Text('accesskey', null, null, _t('Access Key Secret:')); $form->addInput($accesskey->addRule('required', _t('AccessKey 不能为空!'))); $domain = new Typecho_Widget_Helper_Form_Element_Text('domain', null, null, _t('图片HTTP访问前缀:'), _t('OSS可供外网访问的域名前缀,比如https://cdn.mydomain.com')); $form->addInput($domain->addRule('required', _t('请填写OSS图片服务的域名前缀!'))); $savepath = new Typecho_Widget_Helper_Form_Element_Text('savepath', null, 'img/{year}/{month}/', _t('图片保存路径格式:'), _t('图片附件保存路径的格式<br />可选参数:{year} 年份、{month} 月份、{day} 日期。<br /><strong style="color:#C33;">因为阿里云图片处理服务不支持故而GIF视为非图片</strong>')); $form->addInput($savepath->addRule('required', _t('请填写图片保存路径格式!'))); $style = new Typecho_Widget_Helper_Form_Element_Text('style', null, null, _t('图片样式后缀:'), _t('阿里云图片处理服务的后缀,比如@600w.webp')); $form->addInput($style); $nonimg_domain = new Typecho_Widget_Helper_Form_Element_Text('nonimg_domain', null, null, _t('非图片HTTP访问前缀:'), _t('OSS可供外网访问的域名前缀,比如https://oss.mydomain.com')); $form->addInput($nonimg_domain->addRule('required', _t('请填写OSS的域名前缀!'))); $nonimg_savepath = new Typecho_Widget_Helper_Form_Element_Text('nonimg_savepath', null, 'atta/{year}/{month}/', _t('非图片保存路径格式:'), _t('非图片附件保存路径的格式<br />可选参数:{year} 年份、{month} 月份、{day} 日期')); $form->addInput($nonimg_savepath->addRule('required', _t('请填写非图片保存路径格式!'))); }
/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { $compatibilityMode = new Typecho_Widget_Helper_Form_Element_Radio('compatibilityMode', array(0 => _t('不启用'), 1 => _t('启用')), 0, _t('兼容模式'), _t('兼容模式一般用于对以前没有使用Markdown语法解析的文章')); $form->addInput($compatibilityMode->addRule('enum', _t('必须选择一个模式'), array(0, 1))); $styles = array_map('basename', glob(dirname(__FILE__) . '/res/styles/*.css')); $styles = array_combine($styles, $styles); $style = new Typecho_Widget_Helper_Form_Element_Select('style', $styles, 'default.css', _t('代码配色样式')); $form->addInput($style->addRule('enum', _t('必须选择配色样式'), $styles)); }
public static function config(Typecho_Widget_Helper_Form $form) { $themes = array_map('basename', glob(dirname(__FILE__) . '/themes/*.css')); $themes = array_combine($themes, $themes); $theme = new Typecho_Widget_Helper_Form_Element_Select('theme', $themes, 'prism-coy.css', _t('代码样式')); $form->addInput($theme->addRule('enum', _t('必须选择样式'), $themes)); $showLineNumber = new Typecho_Widget_Helper_Form_Element_Checkbox('showln', array('showln' => _t('显示行号')), array('showln'), _t('是否在大段代码左侧显示行号')); $form->addInput($showLineNumber); $showLang = new Typecho_Widget_Helper_Form_Element_Checkbox('showlang', array('showlang' => _t('显示语言标签')), array('showlang'), _t('是否在大段代码右上角显示语言')); $form->addInput($showLang); }
/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { //设置代码风格样式 $styles = array_map('basename', glob(dirname(__FILE__) . '/markdown/styles/*.css')); $styles = array_combine($styles, $styles); $name = new Typecho_Widget_Helper_Form_Element_Select('code_style', $styles, 'segmentfault.css', _t('选择你的代码风格')); $form->addInput($name->addRule('enum', _t('必须选择配色样式'), $styles)); /*$jq_import = new Typecho_Widget_Helper_Form_Element_Radio('jq_import', array( 0 => _t('不引入'), 1 => _t('引入') ), 1, _t('是否引入jQuery'), _t('此插件需要jQuery,如已有选择不引入避免引入多余jQuery')); $form->addInput($jq_import->addRule('enum', _t('必须选择一个模式'), array(0, 1)));*/ }
public static function config(Typecho_Widget_Helper_Form $form) { $help = new Typecho_Widget_Helper_Layout('div', array('style' => 'color: #999; background-color: #eee; border-radius: 10px; padding: 10px;')); $help->html("<strong>使用方法</strong><pre><small>```c#\nConsole.Write(\"Hello World!\");\n```\n或行内代码\n`js console.log(\"Hi!\");`</small></pre>"); $form->addItem($help); $themes = array_map('basename', glob(dirname(__FILE__) . '/themes/*.css')); $themes = array_combine($themes, $themes); $theme = new Typecho_Widget_Helper_Form_Element_Select('theme', $themes, 'prism-coy.css', _t('代码样式')); $form->addInput($theme->addRule('enum', _t('必须选择样式'), $themes)); $showLineNumber = new Typecho_Widget_Helper_Form_Element_Checkbox('showln', array('showln' => _t('显示行号')), array('showln'), _t('是否在大段代码左侧显示行号')); $form->addInput($showLineNumber); $forceWrap = new Typecho_Widget_Helper_Form_Element_Checkbox('forceWrap', array('forceWrap' => _t('强制换行')), array('forceWrap'), _t('是否强制换行')); $form->addInput($forceWrap); $showLang = new Typecho_Widget_Helper_Form_Element_Checkbox('showlang', array('showlang' => _t('显示语言标签')), array('showlang'), _t('是否在大段代码右上角显示语言')); $form->addInput($showLang); }
/** * 输出表单结构 * * @access public * @return Typecho_Widget_Helper_Form */ public function form() { /** 构建表格 */ $form = new Typecho_Widget_Helper_Form($this->security->getIndex('/action/options-general'), Typecho_Widget_Helper_Form::POST_METHOD); /** 站点名称 */ $title = new Typecho_Widget_Helper_Form_Element_Text('title', NULL, $this->options->title, _t('站点名称'), _t('站点的名称将显示在网页的标题处.')); $title->input->setAttribute('class', 'w-100'); $form->addInput($title->addRule('required', _t('请填写站点名称'))->addRule('xssCheck', _t('请不要在站点名称中使用特殊字符'))); /** 站点地址 */ if (!defined('__TYPECHO_SITE_URL__')) { $siteUrl = new Typecho_Widget_Helper_Form_Element_Text('siteUrl', NULL, $this->options->originalSiteUrl, _t('站点地址'), _t('站点地址主要用于生成内容的永久链接.') . ($this->options->originalSiteUrl == $this->options->rootUrl ? '' : '</p><p class="message notice mono">' . _t('当前地址 <strong>%s</strong> 与上述设定值不一致', $this->options->rootUrl))); $siteUrl->input->setAttribute('class', 'w-100 mono'); $form->addInput($siteUrl->addRule('required', _t('请填写站点地址'))->addRule('url', _t('请填写一个合法的URL地址'))); } /** 站点描述 */ $description = new Typecho_Widget_Helper_Form_Element_Text('description', NULL, $this->options->description, _t('站点描述'), _t('站点描述将显示在网页代码的头部.')); $form->addInput($description->addRule('xssCheck', _t('请不要在站点描述中使用特殊字符'))); /** 关键词 */ $keywords = new Typecho_Widget_Helper_Form_Element_Text('keywords', NULL, $this->options->keywords, _t('关键词'), _t('请以半角逗号 "," 分割多个关键字.')); $form->addInput($keywords->addRule('xssCheck', _t('请不要在关键词中使用特殊字符'))); /** 注册 */ $allowRegister = new Typecho_Widget_Helper_Form_Element_Radio('allowRegister', array('0' => _t('不允许'), '1' => _t('允许')), $this->options->allowRegister, _t('是否允许注册'), _t('允许访问者注册到你的网站, 默认的注册用户不享有任何写入权限.')); $form->addInput($allowRegister); /** 语言项 */ // hack 语言扫描 _t('lang'); $langs = self::getLangs(); if (count($langs) > 1) { $lang = new Typecho_Widget_Helper_Form_Element_Select('lang', $langs, $this->options->lang, _t('语言')); $form->addInput($lang->addRule(array($this, 'checkLang'), _t('所选择的语言包不存在'))); } /** 时区 */ $timezoneList = array("0" => _t('格林威治(子午线)标准时间 (GMT)'), "3600" => _t('中欧标准时间 阿姆斯特丹,荷兰,法国 (GMT +1)'), "7200" => _t('东欧标准时间 布加勒斯特,塞浦路斯,希腊 (GMT +2)'), "10800" => _t('莫斯科时间 伊拉克,埃塞俄比亚,马达加斯加 (GMT +3)'), "14400" => _t('第比利斯时间 阿曼,毛里塔尼亚,留尼汪岛 (GMT +4)'), "18000" => _t('新德里时间 巴基斯坦,马尔代夫 (GMT +5)'), "21600" => _t('科伦坡时间 孟加拉 (GMT +6)'), "25200" => _t('曼谷雅加达 柬埔寨,苏门答腊,老挝 (GMT +7)'), "28800" => _t('北京时间 香港,新加坡,越南 (GMT +8)'), "32400" => _t('东京平壤时间 西伊里安,摩鹿加群岛 (GMT +9)'), "36000" => _t('悉尼关岛时间 塔斯马尼亚岛,新几内亚 (GMT +10)'), "39600" => _t('所罗门群岛 库页岛 (GMT +11)'), "43200" => _t('惠灵顿时间 新西兰,斐济群岛 (GMT +12)'), "-3600" => _t('佛德尔群岛 亚速尔群岛,葡属几内亚 (GMT -1)'), "-7200" => _t('大西洋中部时间 格陵兰 (GMT -2)'), "-10800" => _t('布宜诺斯艾利斯 乌拉圭,法属圭亚那 (GMT -3)'), "-14400" => _t('智利巴西 委内瑞拉,玻利维亚 (GMT -4)'), "-18000" => _t('纽约渥太华 古巴,哥伦比亚,牙买加 (GMT -5)'), "-21600" => _t('墨西哥城时间 洪都拉斯,危地马拉,哥斯达黎加 (GMT -6)'), "-25200" => _t('美国丹佛时间 (GMT -7)'), "-28800" => _t('美国旧金山时间 (GMT -8)'), "-32400" => _t('阿拉斯加时间 (GMT -9)'), "-36000" => _t('夏威夷群岛 (GMT -10)'), "-39600" => _t('东萨摩亚群岛 (GMT -11)'), "-43200" => _t('艾尼威托克岛 (GMT -12)')); $timezone = new Typecho_Widget_Helper_Form_Element_Select('timezone', $timezoneList, $this->options->timezone, _t('时区')); $form->addInput($timezone); /** 扩展名 */ $attachmentTypesOptionsResult = NULL != trim($this->options->attachmentTypes) ? array_map('trim', explode(',', $this->options->attachmentTypes)) : array(); $attachmentTypesOptionsValue = array(); if (in_array('@image@', $attachmentTypesOptionsResult)) { $attachmentTypesOptionsValue[] = '@image@'; } if (in_array('@media@', $attachmentTypesOptionsResult)) { $attachmentTypesOptionsValue[] = '@media@'; } if (in_array('@doc@', $attachmentTypesOptionsResult)) { $attachmentTypesOptionsValue[] = '@doc@'; } $attachmentTypesOther = array_diff($attachmentTypesOptionsResult, $attachmentTypesOptionsValue); $attachmentTypesOtherValue = ''; if (!empty($attachmentTypesOther)) { $attachmentTypesOptionsValue[] = '@other@'; $attachmentTypesOtherValue = implode(',', $attachmentTypesOther); } $attachmentTypesOptions = array('@image@' => _t('图片文件') . ' <code>(gif jpg jpeg png tiff bmp)</code>', '@media@' => _t('多媒体文件') . ' <code>(mp3 wmv wma rmvb rm avi flv)</code>', '@doc@' => _t('常用档案文件') . ' <code>(txt doc docx xls xlsx ppt pptx zip rar pdf)</code>', '@other@' => _t('其他格式 %s', ' <input type="text" class="w-50 text-s mono" name="attachmentTypesOther" value="' . htmlspecialchars($attachmentTypesOtherValue) . '" />')); $attachmentTypes = new Typecho_Widget_Helper_Form_Element_Checkbox('attachmentTypes', $attachmentTypesOptions, $attachmentTypesOptionsValue, _t('允许上传的文件类型'), _t('用逗号 "," 将后缀名隔开, 例如: %s', '<code>cpp, h, mak</code>')); $form->addInput($attachmentTypes->multiMode()); /** 提交按钮 */ $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置')); $submit->input->setAttribute('class', 'btn primary'); $form->addItem($submit); return $form; }