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; }
/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { ?> <script type="text/javascript" src="<?php Helper::options()->adminUrl('js/jquery.js'); ?> "></script> <script type="text/javascript"> $(function() { var full = $('#mode-highslide-full-packed-js'), basic = $('#mode-highslide-packed-js'), adv = $('.advanced'), option = $('#typecho-option-item-align-9,#typecho-option-item-opac-10,#typecho-option-item-slide-11,#typecho-option-item-nextimg-12,#typecho-option-item-cpos-13,#typecho-option-item-wrap-14'), input = option.find('input,select'); if(!full.is(':checked')) { adv.attr('style','color:#999;font-weight:bold'); option.attr('style','color:#999'); } full.click(function() { adv.attr('style','color:#467B96;font-weight:bold'); option.removeAttr('style'); }); basic.click(function() { adv.attr('style','color:#999;font-weight:bold'); option.attr('style','color:#999'); }); }); </script> <?php $mode = new Typecho_Widget_Helper_Form_Element_Radio('mode', array('highslide.packed.js' => _t('基础版 <span style="color:#999;font-size:0.92857em;">(25.2K)支持插图弹窗</span>'), 'highslide-full.packed.js' => _t('全功能版 <span style="color:#999;font-size:0.92857em;">(46.8K)支持插图幻灯/html弹窗/页面相册等</span>')), 'highslide.packed.js', _t('核心选择')); $form->addInput($mode); $rpmode = new Typecho_Widget_Helper_Form_Element_Radio('rpmode', array('ahref' => _t('链接图片'), 'imgsrc' => _t('所有图片')), 'ahref', _t('应用模式'), NULL); $form->addInput($rpmode); $rplist = new Typecho_Widget_Helper_Form_Element_Checkbox('rplist', array('index' => _t('首页'), 'post' => _t('文章页'), 'page' => _t('独立页'), 'archive' => _t('索引页')), array('index', 'post', 'page', 'archive'), _t('应用范围'), NULL); $form->addInput($rplist); $lang = new Typecho_Widget_Helper_Form_Element_Radio('lang', array('chs' => _t('中文'), 'eng' => _t('英文')), 'chs', _t('提示语言')); $form->addInput($lang); $outline = new Typecho_Widget_Helper_Form_Element_Radio('outline', array('' => _t('无边框'), 'rounded-white' => _t('圆角白'), 'rounded-black' => _t('圆角黑'), 'glossy-dark' => _t('亮泽黑'), 'outer-glow' => _t('外发光'), 'beveled' => _t('半透明')), '', _t('边框风格')); $form->addInput($outline); $butn = new Typecho_Widget_Helper_Form_Element_Radio('butn', array('false' => _t('不显示'), 'true' => _t('显示')), 'false', _t('关闭按钮')); $form->addInput($butn); $ltext = new Typecho_Widget_Helper_Form_Element_Text('ltext', NULL, '© ' . $_SERVER['HTTP_HOST'] . '', _t('角标文字'), _t('弹窗logo文字与显示位置,留空则不显示')); $ltext->input->setAttribute('class', 'mini'); $form->addInput($ltext); $lpos = new Typecho_Widget_Helper_Form_Element_Select('lpos', array('top left' => _t('左上'), 'top center' => _t('中上'), 'top right' => _t('右上'), 'bottom left' => _t('左下'), 'bottom center' => _t('中下'), 'bottom right' => _t('右下')), 'top left', ''); $lpos->removeAttribute('class', 'typecho-label'); $lpos->input->setAttribute('style', 'position:absolute;bottom:42px;left:165px;'); $lpos->setAttribute('style', 'list-style:none;position:relative;'); $form->addInput($lpos); $capt = new Typecho_Widget_Helper_Form_Element_Radio('capt', array('' => _t('不显示'), 'this.a.title' => _t('显示链接title'), 'this.thumb.alt' => _t('显示图片alt')), '', _t('图片说明'), _t('例: <a href="http://xx.jpg" title="图片说明写这"><img src="http://xxx.jpg" alt="或者写这显示"/></a><p class="advanced" style="color:#467B96;font-weight:bold;">全功能版设置 ———————————————————————————————————————</p>')); $form->addInput($capt); $align = new Typecho_Widget_Helper_Form_Element_Radio('align', array('default' => _t('默认'), 'center' => _t('居中')), 'default', _t('弹窗位置')); $form->addInput($align); $opac = new Typecho_Widget_Helper_Form_Element_Text('opac', NULL, '0.65', _t('背景遮罩'), _t('可填入0~1之间小数, 代表透明至纯黑')); $opac->input->setAttribute('class', 'mini'); $form->addInput($opac->addRule('isFloat', _t('请填写数字'))); $slide = new Typecho_Widget_Helper_Form_Element_Radio('slide', array('false' => _t('关闭'), 'true' => _t('开启')), 'true', _t('幻灯按钮')); $form->addInput($slide); $nextimg = new Typecho_Widget_Helper_Form_Element_Radio('nextimg', array('false' => _t('否'), 'true' => _t('是')), 'false', _t('自动翻页'), _t('开启后点击图片为显示下一张')); $form->addInput($nextimg); $cpos = new Typecho_Widget_Helper_Form_Element_Radio('cpos', array('' => _t('不显示'), 'caption' => _t('底部显示'), 'heading' => _t('顶部显示')), '', _t('图片序数')); $form->addInput($cpos); $wrap = new Typecho_Widget_Helper_Form_Element_Checkbox('wrap', array('draggable-header' => _t('标题栏 <span style="color:#999;font-size:0.92857em;">支持<hs title="标题">显示</span>'), 'no-footer' => _t('无拉伸')), NULL, _t('html弹窗效果')); $form->addInput($wrap); //相册设置隐藏域 $storage = new Typecho_Widget_Helper_Form_Element_Hidden('storage', array('local', 'qiniu', 'upyun', 'bcs'), 'local'); $form->addInput($storage); $local = new Typecho_Widget_Helper_Form_Element_Hidden('local', NULL, '/usr/uploads/HSgallery/'); $form->addInput($local); $qiniubucket = new Typecho_Widget_Helper_Form_Element_Hidden('qiniubucket', NULL, ''); $form->addInput($qiniubucket); $qiniudomain = new Typecho_Widget_Helper_Form_Element_Hidden('qiniudomain', NULL, 'http://'); $form->addInput($qiniudomain); $qiniuaccesskey = new Typecho_Widget_Helper_Form_Element_Hidden('qiniuaccesskey', NULL, ''); $form->addInput($qiniuaccesskey); $qiniusecretkey = new Typecho_Widget_Helper_Form_Element_Hidden('qiniusecretkey', NULL, ''); $form->addInput($qiniusecretkey); $qiniuprefix = new Typecho_Widget_Helper_Form_Element_Hidden('qiniuprefix', NULL, 'usr/uploads/HSgallery/'); $form->addInput($qiniuprefix); $upyunbucket = new Typecho_Widget_Helper_Form_Element_Hidden('upyunbucket', NULL, ''); $form->addInput($upyunbucket); $upyundomain = new Typecho_Widget_Helper_Form_Element_Hidden('upyundomain', NULL, 'http://'); $form->addInput($upyundomain); $upyunuser = new Typecho_Widget_Helper_Form_Element_Hidden('upyunuser', NULL, ''); $form->addInput($upyunuser); $upyunpwd = new Typecho_Widget_Helper_Form_Element_Hidden('upyunpwd', NULL, ''); $form->addInput($upyunpwd); $upyunkey = new Typecho_Widget_Helper_Form_Element_Hidden('upyunkey', NULL, ''); $form->addInput($upyunkey); $upyunprefix = new Typecho_Widget_Helper_Form_Element_Hidden('upyunprefix', NULL, '/usr/uploads/HSgallery/'); $form->addInput($upyunprefix); $bcsbucket = new Typecho_Widget_Helper_Form_Element_Hidden('bcsbucket', NULL, ''); $form->addInput($bcsbucket); $bcsapikey = new Typecho_Widget_Helper_Form_Element_Hidden('bcsapikey', NULL, ''); $form->addInput($bcsapikey); $bcssecretkey = new Typecho_Widget_Helper_Form_Element_Hidden('bcssecretkey', NULL, ''); $form->addInput($bcssecretkey); $bcsprefix = new Typecho_Widget_Helper_Form_Element_Hidden('bcsprefix', NULL, '/usr/uploads/HSgallery/'); $form->addInput($bcsprefix); $thumbfix = new Typecho_Widget_Helper_Form_Element_Hidden('thumbfix', array('fixedwidth', 'fixedheight', 'fixedratio'), 'fixedwidth'); $form->addInput($thumbfix); $fixedwidth = new Typecho_Widget_Helper_Form_Element_Hidden('fixedwidth', NULL, '100'); $form->addInput($fixedwidth); $fixedheight = new Typecho_Widget_Helper_Form_Element_Hidden('fixedheight', NULL, '200'); $form->addInput($fixedheight); $fixedratio = new Typecho_Widget_Helper_Form_Element_Hidden('fixedratio', NULL, '4:3'); $form->addInput($fixedratio); $gallery = new Typecho_Widget_Helper_Form_Element_Hidden('gallery', array('gallery-horizontal-strip', 'gallery-thumbstrip-above', 'gallery-vertical-strip', 'gallery-in-box', 'gallery-floating-thumbs', 'gallery-floating-caption', 'gallery-controls-in-heading', 'gallery-in-page'), 'gallery-horizontal-strip'); $form->addInput($gallery); }