/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { /** user agent icons **/ $icons = new Typecho_Widget_Helper_Form_Element_Radio('icons', array('16' => '16px 大小', '24' => '24px 大小'), '16', _t('选择图标尺寸大小'), _t('')); $form->addInput($icons->multiMode()); /** user agent show **/ $show = new Typecho_Widget_Helper_Form_Element_Radio('show', array('1' => '只显示图标', '2' => '只显示文字', '3' => '显示图片和文字'), '1', _t('选择显示的内容'), _t('')); $form->addInput($show->multiMode()); }
function themeConfig($form) { $logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点LOGO地址'), _t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO')); $form->addInput($logoUrl); $sidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarBlock', array('ShowSearch' => _t('显示搜索框'), 'ShowCategory' => _t('显示分类'), 'ShowRecentPosts' => _t('显示最新文章'), 'ShowRecentComments' => _t('显示最近回复'), 'ShowArchive' => _t('显示归档'), 'ShowTags' => _t('显示标签')), array('ShowSearch', 'ShowCategory', 'ShowRecentPosts', 'ShowRecentComments', 'ShowArchive', 'ShowTags'), _t('侧边栏显示')); $form->addInput($sidebarBlock->multiMode()); $css = new Typecho_Widget_Helper_Form_Element_Radio('css', array('red' => _t('红色系'), 'green' => _t('绿色系'), 'blue' => _t('蓝色系'), 'purple' => _t('紫色'), 'black' => _t('黑色')), 'green', _t('配色选择')); $form->addInput($css->multiMode()); }
function themeConfig($form) { echo '<p style="font-size:16px;text-align:center;">感谢您使用TE响应式主题 :<font color="#4A89DC"> Themia</font><font color="#F40"> ' . Themia_Version . '</font> ![<a href="http://qqdie.com/archives/with-the-help-of-themia-subject-to-update-the-manual" target="_blank">更新与帮助</a>]</p>'; $SmiliesSetting = new Typecho_Widget_Helper_Form_Element_Checkbox('SmiliesSetting', array('Showimg' => _t('缩略图固定')), array('Showimg'), _t('缩略图设置'), _t('文章没有图片时会随机调用缩略图,开启此项可将没有图片的文章缩略图固定为一张')); $form->addInput($SmiliesSetting->multiMode()); //网站LOGO $logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('博主头像地址'), _t('logo头像地址,不填写默认内置头像,这个建议用正方形的图片√')); $form->addInput($logoUrl); //背景 $bgUrl = new Typecho_Widget_Helper_Form_Element_Text('bgUrl', NULL, NULL, _t('背景图地址'), _t('背景图地址,不填写默认为内置的图片,这个建议用高清大图√')); $form->addInput($bgUrl); $weibo = new Typecho_Widget_Helper_Form_Element_Text('weibo', NULL, 'http://weibo.com/jinzeboke', _t('新浪微博地址'), _t('填写你的新浪微博主页地址到菜单目录中')); $form->addInput($weibo); $Categories = new Typecho_Widget_Helper_Form_Element_Text('Categories', NULL, NULL, _t('Categories分类归档地址'), _t('新建独立页面,选择模板Categories,这里填入独立页面的完整地址')); $form->addInput($Categories); $Archive = new Typecho_Widget_Helper_Form_Element_Text('Archive', NULL, NULL, _t('Archive时间归档地址'), _t('新建独立页面,选择模板Archive,这里填入独立页面的完整地址')); $form->addInput($Archive); $links = new Typecho_Widget_Helper_Form_Element_Text('links', NULL, NULL, _t('links友情链接地址'), _t('新建独立页面,写上朋友的链接,作为友情链接页面,然后把页面地址填入这里')); $form->addInput($links); $about = new Typecho_Widget_Helper_Form_Element_Text('about', NULL, NULL, _t('about链接地址'), _t('新建独立页面,写上关于自己的属性,然后把页面地址填入这里')); $form->addInput($about); $css = new Typecho_Widget_Helper_Form_Element_Radio('css', array('1' => _t('1.在大屏幕显示宽的SideBar,在中屏幕显示窄的SideBar,在小屏幕显示抽屉SideBar(宽)'), '2' => _t('2.在大屏幕和中屏幕显示窄的SideBar,在小屏幕显示抽屉SideBar(窄)'), '3' => _t('3.在所有屏幕显示抽屉SideBar(宽)'), '4' => _t('4.在所有屏幕显示抽屉SideBar(窄)')), '1', _t('sidebar风格'), _t('这里的风格指的是网站整体风格,文章风格可通过自定义字段字段名ys和字段值来控制,实现对单独的一篇文章的风格重定义(字段值就是上边对应的数字,如风格3,就在文章字段名填入ys,字段值填入3即可),文章封面效果也是用自定义字段,字段名fm,字段值就是封面的图片地址,启动封面效果的文章风格会变更为3(优先级高)√')); $form->addInput($css->multiMode()); $tf = new Typecho_Widget_Helper_Form_Element_Radio('tf', array('open' => _t('启用居中风格,使用默认方式截取缩略内容'), 'more' => _t('启用居中风格,并强制使用more语法截取缩略内容'), 'close' => _t('不启用')), 'close', _t('文章标题居中风格'), _t('默认不启用,启用后文章缩略图会关闭显示,并且文章标题,分类等信息居中')); $form->addInput($tf); //工具开关 $sidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarBlock', array('kp' => _t('文章中加入跨屏浏览二维码,支付宝打赏,及文章版权声明'), 'bjq' => _t('文章内容增强,加入最后编辑时间'), 'Showfull' => _t('手机浏览器强制全屏,仅限于uc和QQ浏览器'), 'Showcolor' => _t('手机谷歌浏览器状态栏颜色渲染为白色'), 'kiana' => _t('kiana封印解除'), 'simg' => _t('全局不显示文章缩略图')), array('Showcolor', 'bjq'), _t('工具开关')); $form->addInput($sidebarBlock->multiMode()); $jsq = new Typecho_Widget_Helper_Form_Element_Radio('jsq', array('0' => _t('不显示文章浏览次数'), '1' => _t('非插件实现'), '2' => _t('绛木子TePostViews插件')), '0', _t('文章阅读次数显示方案(后一项需要自行安装对应插件)'), _t("在工具开关中,打开文章浏览次数,然后选择这里的方案,两款方案最终效果都一样<br>在不清除cookie或者cookie未过期的情况下不会重复计数<br>提示:非插件的方案和Hanny的Stat插件使用的是同一个数据,所以如果你曾经用的是Star插件,可以直接选择第一项,同时禁用Star插件,以免重复计数【不禁用的话,访问一次,计数器会加2】")); $form->addInput($jsq); $cdl = new Typecho_Widget_Helper_Form_Element_Radio('cdl', array('0' => _t('English'), '1' => _t('日本語【渣翻译】 '), '2' => _t('中文')), '0', _t('界面语言设置'), _t("尽管英文逼格比较高,但是中文有中文的好处。此处默认是英文,因为我比较屌,所以有日文选项")); $form->addInput($cdl); $bqg = new Typecho_Widget_Helper_Form_Element_Radio('bqg', array('1' => _t('不开启版权狗'), '2' => _t('开启版权声明')), '1', _t('版权声明'), _t("复制文章内容时,会出现版权声明提示,并且复制的内容自带版权声明。")); $form->addInput($bqg); //文章首行缩进 $page_suo = new Typecho_Widget_Helper_Form_Element_Radio('page_suo', array('display' => _t('post和page页面启用'), 'display1' => _t('仅post页面启用'), 'display2' => _t('仅page页面启用'), 'close' => _t('禁用')), 'close', _t('文章首行缩进'), _t('开启后,所有文章内容将自动缩进2em(两个中文汉字宽度)')); $form->addInput($page_suo); //建站时间 $time = new Typecho_Widget_Helper_Form_Element_Text('time', NULL, '2015/06/06', _t('博客成立时间'), _t('此功能是摆设,事件需要在模板kz.js中修改')); $form->addInput($time); //统计代码 $tongji = new Typecho_Widget_Helper_Form_Element_Textarea('tongji', NULL, '', _t('底部声明什么的'), _t('填入备案链接或者统计代码或者版权什么的')); $form->addInput($tongji); $sticky_1 = new Typecho_Widget_Helper_Form_Element_Text('sticky_1', NULL, NULL, '置顶主题ID', '填写对应主题的 id 即可使某些分类的文章在置顶首页显示(例如 1)。'); $sticky_1->input->setAttribute('class', 'mini'); $form->addInput($sticky_1->addRule('isInteger', '请填入数字')); $sticky_2 = new Typecho_Widget_Helper_Form_Element_Text('sticky_2', NULL, NULL, '置顶主题ID', '填写对应主题的 id 即可使某些分类的文章在置顶首页显示(例如 1)。'); $sticky_2->input->setAttribute('class', 'mini'); $form->addInput($sticky_2->addRule('isInteger', '请填入数字')); $sticky_3 = new Typecho_Widget_Helper_Form_Element_Text('sticky_3', NULL, NULL, '置顶主题ID', '填写对应主题的 id 即可使某些分类的文章在置顶首页显示(例如 1)。'); $sticky_3->input->setAttribute('class', 'mini'); $form->addInput($sticky_3->addRule('isInteger', '请填入数字')); }
/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { $cfg_usejs = new Typecho_Widget_Helper_Form_Element_Checkbox('cfg_usejs', array('usejs' => '使用Javascript折叠显示存档效果'), array('usejs'), '是否使用 JavaScript'); $form->addInput($cfg_usejs); $cfg_monthorder = new Typecho_Widget_Helper_Form_Element_Radio('cfg_monthorder', array('month_desc' => '按时间倒叙排列月份(离现在最近的月份排最前)', 'month_asc' => '按时间正序排列月份(离现在最远的月份排最前)'), 'month_desc', '存档月份排序'); $form->addInput($cfg_monthorder->multiMode()); $cfg_postorder = new Typecho_Widget_Helper_Form_Element_Radio('cfg_postorder', array('post_desc' => '将最新的日志显示在第一位', 'post_asc' => '将最旧的日志显示在第一位'), 'post_desc', '存档文章排序'); $form->addInput($cfg_postorder->multiMode()); $cfg_postcount = new Typecho_Widget_Helper_Form_Element_Checkbox('cfg_postcount', array('show' => '显示文章数'), array('show'), '是否显示文章数'); $form->addInput($cfg_postcount); $cfg_commentcount = new Typecho_Widget_Helper_Form_Element_Checkbox('cfg_commentcount', array('show' => '显示评论数'), array('show'), '是否显示评论数'); $form->addInput($cfg_commentcount); $cfg_delcache = new Typecho_Widget_Helper_Form_Element_Checkbox('cfg_delcache', array('comment' => '有新的评论时删除归档缓存'), array(), '删除缓存', '默认只有在你创建文章时删除缓存,勾选后同时在有新评论时也删除缓存,主要是为了显示评论数与数据库的一致'); $form->addInput($cfg_delcache); }
/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { $version = new Typecho_Widget_Helper_Form_Element_Radio('version', array('MTTextile' => 'MTTextile - includes Brad Choates\' extensions.', 'Textile' => 'Textile for the Textile purist.'), 'MTTextile', 'Textile Flavor'); $form->addInput($version->multiMode()); $filters = new Typecho_Widget_Helper_Form_Element_Checkbox('filters', array('SmartyPants' => 'Apply SmartyPants (provides em and en dashes, and other typographic niceities)', 'EducateQuotes' => 'Apply Texturize (applies curly quotes)'), array('SmartyPants', 'EducateQuotes'), 'Text Filters'); $form->addInput($filters->multiMode()); $headerOffset = new Typecho_Widget_Helper_Form_Element_Select('headerOffset', array('0 (.h1 = .h1)', '1 (.h1 = .h2)', '2 (.h1 = .h3)', '3 (.h1 = .h4)', '4 (.h1 = .h5)', '5 (.h1 = .h6)'), 0, 'Header Offset'); $form->addInput($headerOffset); $parsing = new Typecho_Widget_Helper_Form_Element_Checkbox('parsing', array('ClearLines' => 'Strip extra spaces from the end of each line.', 'PreserveSpaces' => 'Change double-spaces to the HTML entity for an em-space (&8195;).'), NULL, 'Parsing Options'); $form->addInput($parsing->multiMode()); $inputEncoding = new Typecho_Widget_Helper_Form_Element_Text('inputEncoding', NULL, Helper::options()->charset, _t('Input Character Encoding')); $inputEncoding->input->setAttribute('class', 'mini'); $form->addInput($inputEncoding); $encoding = new Typecho_Widget_Helper_Form_Element_Text('encoding', NULL, Helper::options()->charset, _t('Output Character Encoding')); $encoding->input->setAttribute('class', 'mini'); $form->addInput($encoding); }
/** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form) { $sect = new Typecho_Widget_Helper_Form_Element_Select('sect', array('Default', 'Django', 'Eclipse', 'Emacs', 'FadeToGrey', 'Midnight', 'RDark'), 0, _t('代码样式')); $form->addInput($sect); $CodeType = new Typecho_Widget_Helper_Form_Element_Radio('CodeType', array('Code1' => '[code=php123]代码[/code]', 'Code2' => '<code lang=php>代码</code>', 'Code3' => '<code lang=php line=123>代码</code>'), 'Code1', '标签格式'); $form->addInput($CodeType->multiMode()); $showzh = new Typecho_Widget_Helper_Form_Element_Radio('showzh', array('true' => '显示中文提示,如“viewSource”=>“查看代码”。', 'false' => '使用默认的英文提示。'), 'true', '提示语言'); $form->addInput($showzh->multiMode()); $collapse = new Typecho_Widget_Helper_Form_Element_Radio('collapse', array('true' => '打开网页时折叠代码。', 'false' => '代码一直展开。'), 'true', '代码折叠'); $form->addInput($collapse->multiMode()); $gutter = new Typecho_Widget_Helper_Form_Element_Radio('gutter', array('true' => '显示行号。', 'false' => '隐藏行号。'), 'true', '行号显示'); $form->addInput($gutter->multiMode()); $auto_links = new Typecho_Widget_Helper_Form_Element_Radio('auto_links', array('true' => '代码中有网址时自动添加超链接。', 'false' => '不使用超链接。'), 'false', '自动链接'); $form->addInput($auto_links->multiMode()); $filters = new Typecho_Widget_Helper_Form_Element_Checkbox('filters', array('AS3' => 'AS3', 'Bash' => 'Bash', 'ColdFusion' => 'ColdFusion', 'Cpp' => 'Cpp,C,C++', 'CSharp' => 'CSharp,C#', 'Css' => 'Css', 'Delphi' => 'Delphi', 'Diff' => 'Diff', 'Erlang' => 'Erlang', 'Groovy' => 'Groovy', 'Java' => 'Java', 'JavaFX' => 'JavaFX', 'JScript' => 'JScript', 'Perl' => 'Perl', 'Php' => 'Php', 'Plain' => 'Plain', 'PowerShell' => 'PowerShell', 'Python' => 'Python', 'Ruby' => 'Ruby', 'Scala' => 'Scala', 'Sql' => 'Sql', 'Vb' => 'Vb', 'Xml' => 'Xml'), array('Php', 'JScript', 'Python', 'Cpp', 'Vb', 'CSS', 'Xml'), '语言支持', _t('选取需要支持的语言,勿多选,选得多载入的js文件越多,对速度有一定的影响')); $form->addInput($filters->multiMode()); }
/** * 输出表单结构 * * @access public * @return Typecho_Widget_Helper_Form */ public function form() { /** 构建表格 */ $form = new Typecho_Widget_Helper_Form($this->security->getRootUrl('index.php/action/options-permalink'), Typecho_Widget_Helper_Form::POST_METHOD); if (!defined('__TYPECHO_REWRITE__')) { /** 是否使用地址重写功能 */ $rewrite = new Typecho_Widget_Helper_Form_Element_Radio('rewrite', array('0' => _t('不启用'), '1' => _t('启用')), $this->options->rewrite, _t('是否使用地址重写功能'), _t('地址重写即 rewrite 功能是某些服务器软件提供的优化内部连接的功能.') . '<br />' . _t('打开此功能可以让你的链接看上去完全是静态地址.')); // disable rewrite check when rewrite opened if (!$this->options->rewrite && !$this->request->is('enableRewriteAnyway=1')) { $errorStr = _t('重写功能检测失败, 请检查你的服务器设置'); /** 如果是apache服务器, 可能存在无法写入.htaccess文件的现象 */ if ((isset($_SERVER['SERVER_SOFTWARE']) && false !== strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') || function_exists('apache_get_version')) && !file_exists(__TYPECHO_ROOT_DIR__ . '/.htaccess') && !is_writeable(__TYPECHO_ROOT_DIR__)) { $errorStr .= '<br /><strong>' . _t('我们检测到你使用了apache服务器, 但是程序无法在根目录创建.htaccess文件, 这可能是产生这个错误的原因.') . _t('请调整你的目录权限, 或者手动创建一个.htaccess文件.') . '</strong>'; } $errorStr .= '<br /><input type="checkbox" name="enableRewriteAnyway" id="enableRewriteAnyway" value="1" />' . ' <label for="enableRewriteAnyway">' . _t('如果你仍然想启用此功能, 请勾选这里') . '</label>'; $rewrite->addRule(array($this, 'checkRewrite'), $errorStr); } $form->addInput($rewrite); } $patterns = array('/archives/[cid:digital]/' => _t('默认风格') . ' <code>/archives/{cid}/</code>', '/archives/[slug].html' => _t('wordpress风格') . ' <code>/archives/{slug}.html</code>', '/[year:digital:4]/[month:digital:2]/[day:digital:2]/[slug].html' => _t('按日期归档') . ' <code>/archives/{year}/{month}/{day}/{slug}.html</code>', '/[category]/[slug].html' => _t('按分类归档') . ' <code>/{category}/{slug}.html</code>'); /** 自定义文章路径 */ $postPatternValue = $this->options->routingTable['post']['url']; /** 增加个性化路径 */ $customPatternValue = NULL; if (isset($this->request->__typecho_form_item_postPattern)) { $customPatternValue = $this->request->__typecho_form_item_postPattern; Typecho_Cookie::delete('__typecho_form_item_postPattern'); } else { if (!isset($patterns[$postPatternValue])) { $customPatternValue = $this->decodeRule($postPatternValue); } } $patterns['custom'] = _t('个性化定义') . ' <input type="text" class="w-50 text-s mono" name="customPattern" value="' . $customPatternValue . '" />'; $postPattern = new Typecho_Widget_Helper_Form_Element_Radio('postPattern', $patterns, $postPatternValue, _t('自定义文章路径'), _t('可用参数: <code>{cid}</code> 日志 ID, <code>{slug}</code> 日志缩略名, <code>{category}</code> 分类, <code>{directory}</code> 多级分类, <code>{year}</code> 年, <code>{month}</code> 月, <code>{day}</code> 日') . '<br />' . _t('选择一种合适的文章静态路径风格, 使得你的网站链接更加友好.') . '<br />' . _t('一旦你选择了某种链接风格请不要轻易修改它.')); if ($customPatternValue) { $postPattern->value('custom'); } $form->addInput($postPattern->multiMode()); /** 独立页面后缀名 */ $pagePattern = new Typecho_Widget_Helper_Form_Element_Text('pagePattern', NULL, $this->decodeRule($this->options->routingTable['page']['url']), _t('独立页面路径'), _t('可用参数: <code>{cid}</code> 页面 ID, <code>{slug}</code> 页面缩略名') . '<br />' . _t('请在路径中至少包含上述的一项参数.')); $pagePattern->input->setAttribute('class', 'mono w-60'); $form->addInput($pagePattern->addRule(array($this, 'checkPagePattern'), _t('独立页面路径中没有包含 {cid} 或者 {slug} '))); /** 分类页面 */ $categoryPattern = new Typecho_Widget_Helper_Form_Element_Text('categoryPattern', NULL, $this->decodeRule($this->options->routingTable['category']['url']), _t('分类路径'), _t('可用参数: <code>{mid}</code> 分类 ID, <code>{slug}</code> 分类缩略名, <code>{directory}</code> 多级分类') . '<br />' . _t('请在路径中至少包含上述的一项参数.')); $categoryPattern->input->setAttribute('class', 'mono w-60'); $form->addInput($categoryPattern->addRule(array($this, 'checkCategoryPattern'), _t('分类路径中没有包含 {mid} 或者 {slug} '))); /** 提交按钮 */ $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置')); $submit->input->setAttribute('class', 'btn primary'); $form->addItem($submit); return $form; }
function themeConfig($form) { $css = new Typecho_Widget_Helper_Form_Element_Radio('css', array('default' => _t('default'), 'light' => _t('light'), 'blue' => _t('blue'), 'coffee' => _t('coffee'), 'ectoplasm' => _t('ectoplasm'), 'midnight' => _t('midnight'), 'ocean' => _t('ocean')), 'default', _t('配色选择')); $form->addInput($css->multiMode()); }
/** * 输出表单结构 * * @access public * @return Typecho_Widget_Helper_Form */ public function form() { /** 构建表格 */ $form = new Typecho_Widget_Helper_Form($this->security->getIndex('/action/options-reading'), Typecho_Widget_Helper_Form::POST_METHOD); /** 文章日期格式 */ $postDateFormat = new Typecho_Widget_Helper_Form_Element_Text('postDateFormat', NULL, $this->options->postDateFormat, _t('文章日期格式'), _t('此格式用于指定显示在文章归档中的日期默认显示格式.') . '<br />' . _t('在某些主题中这个格式可能不会生效, 因为主题作者可以自定义日期格式.') . '<br />' . _t('请参考 <a href="http://www.php.net/manual/zh/function.date.php">PHP 日期格式写法</a>.')); $postDateFormat->input->setAttribute('class', 'w-40 mono'); $form->addInput($postDateFormat->addRule('xssCheck', _t('请不要在日期格式中使用特殊字符'))); //首页显示 $frontPageParts = explode(':', $this->options->frontPage); $frontPageType = $frontPageParts[0]; $frontPageValue = count($frontPageParts) > 1 ? $frontPageParts[1] : ''; $frontPageOptions = array('recent' => _t('显示最新发布的文章')); $frontPattern = '</label></span><span class="multiline front-archive%class%">' . '<input type="checkbox" id="frontArchive" name="frontArchive" value="1"' . ($this->options->frontArchive && 'recent' != $frontPageType ? ' checked' : '') . ' /> <label for="frontArchive">' . _t('同时将文章列表页路径更改为 %s', '<input type="text" name="archivePattern" class="w-20 mono" value="' . htmlspecialchars($this->decodeRule($this->options->routingTable['archive']['url'])) . '" />') . '</label>'; // 页面列表 $pages = $this->db->fetchAll($this->db->select('cid', 'title')->from('table.contents')->where('type = ?', 'page')->where('status = ?', 'publish')->where('created < ?', $this->options->gmtTime)); if (!empty($pages)) { $pagesSelect = '<select name="frontPagePage" id="frontPage-frontPagePage">'; foreach ($pages as $page) { $selected = ''; if ('page' == $frontPageType && $page['cid'] == $frontPageValue) { $selected = ' selected="true"'; } $pagesSelect .= '<option value="' . $page['cid'] . '"' . $selected . '>' . $page['title'] . '</option>'; } $pagesSelect .= '</select>'; $frontPageOptions['page'] = _t('使用 %s 页面作为首页', '</label>' . $pagesSelect . '<label for="frontPage-frontPagePage">'); $selectedFrontPageType = 'page'; } // 自定义文件列表 $files = glob($this->options->themeFile($this->options->theme, '*.php')); $filesSelect = ''; foreach ($files as $file) { $info = Typecho_Plugin::parseInfo($file); $file = basename($file); if ('index.php' != $file && 'index' == $info['title']) { $selected = ''; if ('file' == $frontPageType && $file == $frontPageValue) { $selected = ' selected="true"'; } $filesSelect .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>'; } } if (!empty($filesSelect)) { $frontPageOptions['file'] = _t('直接调用 %s 模板文件', '</label><select name="frontPageFile" id="frontPage-frontPageFile">' . $filesSelect . '</select><label for="frontPage-frontPageFile">'); $selectedFrontPageType = 'file'; } if (isset($frontPageOptions[$frontPageType]) && 'recent' != $frontPageType && isset($selectedFrontPageType)) { $selectedFrontPageType = $frontPageType; $frontPattern = str_replace('%class%', '', $frontPattern); } if (isset($selectedFrontPageType)) { $frontPattern = str_replace('%class%', ' hidden', $frontPattern); $frontPageOptions[$selectedFrontPageType] .= $frontPattern; } $frontPage = new Typecho_Widget_Helper_Form_Element_Radio('frontPage', $frontPageOptions, $frontPageType, _t('站点首页')); $form->addInput($frontPage->multiMode()); /** 文章列表数目 */ $postsListSize = new Typecho_Widget_Helper_Form_Element_Text('postsListSize', NULL, $this->options->postsListSize, _t('文章列表数目'), _t('此数目用于指定显示在侧边栏中的文章列表数目.')); $postsListSize->input->setAttribute('class', 'w-20'); $form->addInput($postsListSize->addRule('isInteger', _t('请填入一个数字'))); /** 每页文章数目 */ $pageSize = new Typecho_Widget_Helper_Form_Element_Text('pageSize', NULL, $this->options->pageSize, _t('每页文章数目'), _t('此数目用于指定文章归档输出时每页显示的文章数目.')); $pageSize->input->setAttribute('class', 'w-20'); $form->addInput($pageSize->addRule('isInteger', _t('请填入一个数字'))); /** FEED全文输出 */ $feedFullText = new Typecho_Widget_Helper_Form_Element_Radio('feedFullText', array('0' => _t('仅输出摘要'), '1' => _t('全文输出')), $this->options->feedFullText, _t('聚合全文输出'), _t('如果你不希望在聚合中输出文章全文,请使用仅输出摘要选项.') . '<br />' . _t('摘要的文字取决于你在文章中使用分隔符的位置.')); $form->addInput($feedFullText); /** 提交按钮 */ $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置')); $submit->input->setAttribute('class', 'btn primary'); $form->addItem($submit); return $form; }
/** * 输出表单结构 * * @access public * @return Typecho_Widget_Helper_Form */ public function form() { /** 构建表格 */ $form = new Typecho_Widget_Helper_Form(Typecho_Common::url('/action/options-reading', $this->options->index), Typecho_Widget_Helper_Form::POST_METHOD); /** 文章日期格式 */ $postDateFormat = new Typecho_Widget_Helper_Form_Element_Text('postDateFormat', NULL, $this->options->postDateFormat, _t('文章日期格式'), _t('此格式用于指定显示在文章归档中的日期默认显示格式.<br /> 在某些主题中这个格式可能不会生效, 因为主题作者可以自定义日期格式.<br /> 请参考<a href="http://cn.php.net/manual/zh/function.date.php">PHP日期格式写法</a>.')); $form->addInput($postDateFormat); //首页显示 $frontPageParts = explode(':', $this->options->frontPage); $frontPageType = $frontPageParts[0]; $frontPageValue = count($frontPageParts) > 1 ? $frontPageParts[1] : ''; $frontPageOptions = array('recent' => _t('显示最新发布的文章')); // 页面列表 $pages = $this->db->fetchAll($this->db->select('cid', 'title')->from('table.contents')->where('type = ?', 'page')->where('status = ?', 'publish')->where('created < ?', $this->options->gmtTime)); if (!empty($pages)) { $pagesSelect = '<select name="frontPagePage" id="frontPage-frontPagePage">'; foreach ($pages as $page) { $selected = ''; if ('page' == $frontPageType && $page['cid'] == $frontPageValue) { $selected = ' selected="true"'; } $pagesSelect .= '<option value="' . $page['cid'] . '"' . $selected . '>' . $page['title'] . '</option>'; } $pagesSelect .= '</select>'; $frontPageOptions['page'] = _t('使用 %s 页面作为首页', '</label>' . $pagesSelect . '<label for="frontPage-frontPagePage">'); } // 自定义文件列表 $files = glob(__TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_THEME_DIR__ . '/' . $this->options->theme . '/*.php'); $filesSelect = ''; foreach ($files as $file) { $info = Typecho_Plugin::parseInfo($file); $file = basename($file); if ('index.php' != $file && 'index' == $info['title']) { $selected = ''; if ('file' == $frontPageType && $file == $frontPageValue) { $selected = ' selected="true"'; } $filesSelect .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>'; } } if (!empty($filesSelect)) { $frontPageOptions['file'] = _t('直接调用 %s 模板文件', '</label><select name="frontPageFile" id="frontPage-frontPageFile">' . $filesSelect . '</select><label for="frontPage-frontPageFile">'); } $frontPage = new Typecho_Widget_Helper_Form_Element_Radio('frontPage', $frontPageOptions, $frontPageType, _t('站点首页')); $form->addInput($frontPage->multiMode()); /** 文章列表数目 */ $postsListSize = new Typecho_Widget_Helper_Form_Element_Text('postsListSize', NULL, $this->options->postsListSize, _t('文章列表数目'), _t('此数目用于指定显示在侧边拦中的文章列表数目.')); $postsListSize->input->setAttribute('class', 'mini'); $form->addInput($postsListSize->addRule('isInteger', _t('请填入一个数字'))); /** 每页文章数目 */ $pageSize = new Typecho_Widget_Helper_Form_Element_Text('pageSize', NULL, $this->options->pageSize, _t('每页文章数目'), _t('此数目用于指定文章归档输出时每页显示的文章数目.')); $pageSize->input->setAttribute('class', 'mini'); $form->addInput($pageSize->addRule('isInteger', _t('请填入一个数字'))); /** FEED全文输出 */ $feedFullText = new Typecho_Widget_Helper_Form_Element_Radio('feedFullText', array('0' => _t('仅输出摘要'), '1' => _t('全文输出')), $this->options->feedFullText, _t('聚合全文输出'), _t('如果你不希望在聚合中输出文章全文,请使用仅输出摘要选项.<br /> 摘要的文字取决于你在文章中使用分隔符的位置.')); $form->addInput($feedFullText); /** 提交按钮 */ $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置')); $form->addItem($submit); return $form; }
/** * 输出表单结构 * * @access public * @return Typecho_Widget_Helper_Form */ public function form() { /** 构建表格 */ $form = new Typecho_Widget_Helper_Form(Typecho_Common::url('index.php/action/options-permalink', $this->options->siteUrl), Typecho_Widget_Helper_Form::POST_METHOD); /** 是否使用地址重写功能 */ $rewrite = new Typecho_Widget_Helper_Form_Element_Radio('rewrite', array('0' => _t('不启用'), '1' => _t('启用')), $this->options->rewrite, _t('是否使用地址重写功能'), _t('地址重写即rewrite功能是某些服务器软件提供的优化内部连接的功能.<br /> 打开此功能可以让你的链接看上去完全是静态地址.')); $errorStr = _t('重写功能检测失败, 请检查你的服务器设置'); /** 如果是apache服务器, 可能存在无法写入.htaccess文件的现象 */ if ((isset($_SERVER['SERVER_SOFTWARE']) && false !== strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') || function_exists('apache_get_version')) && !file_exists(__TYPECHO_ROOT_DIR__ . '/.htaccess') && !is_writeable(__TYPECHO_ROOT_DIR__)) { $errorStr .= '<br /><strong>' . _t('我们检测到你使用了apache服务器, 但是程序无法在根目录创建.htaccess文件, 这可能是产生这个错误的原因. 请调整你的目录权限, 或者手动创建一个.htaccess文件.') . '</strong>'; } $errorStr .= _t('<br />如果你仍然想启用此功能, <a href="%s">请点击这里</a>', Typecho_Common::url('index.php/action/options-permalink?do=enableRewriteAnyway', $this->options->siteUrl)); $form->addInput($rewrite->addRule(array($this, 'checkRewrite'), $errorStr)); $patterns = array('/archives/[cid:digital]/' => _t('默认风格') . ' <strong><small>/archives/{cid}/</small></strong>', '/archives/[slug].html' => _t('wordpress风格') . ' <strong><small>/archives/{slug}.html</small></strong>', '/[year:digital:4]/[month:digital:2]/[day:digital:2]/[slug].html' => _t('按日期归档') . ' <strong><small>/archives/{year}/{month}/{day}/{slug}.html</small></strong>', '/[category]/[slug].html' => _t('按分类归档') . ' <strong><small>/{category}/{slug}.html</small></strong>'); /** 自定义文章路径 */ $postPatternValue = $this->options->routingTable['post']['url']; /** 增加个性化路径 */ $customPatternValue = NULL; if (isset($this->request->__typecho_form_item_postPattern)) { $customPatternValue = $this->request->__typecho_form_item_postPattern; Typecho_Cookie::delete('__typecho_form_item_postPattern'); } else { if (!isset($patterns[$postPatternValue])) { $customPatternValue = $this->decodeRule($postPatternValue); } } $patterns['custom'] = _t('个性化定义') . ' <input type="text" style="width: 250px;" name="customPattern" value="' . $customPatternValue . '" />'; $postPattern = new Typecho_Widget_Helper_Form_Element_Radio('postPattern', $patterns, $postPatternValue, _t('自定义文章路径'), _t('可用参数:{cid} 日志ID、{slug} 日志缩略名、{category} 分类、{year} 年、{month} 月、{day} 日<br />选择一种合适的文章静态路径风格, 使得你的网站链接更加友好.<br /> 一旦你选择了某种链接风格请不要轻易修改它.')); if ($customPatternValue) { $postPattern->value('custom'); } $form->addInput($postPattern->multiMode()); /** 独立页面后缀名 */ $pageSuffixValue = false !== ($pos = strrpos($this->options->routingTable['page']['url'], '.')) ? substr($this->options->routingTable['page']['url'], $pos) : '/'; $pageSuffix = new Typecho_Widget_Helper_Form_Element_Radio('pageSuffix', array('/' => '<strong>' . _t('无') . '</strong>', '.html' => '<strong>html</strong>', '.htm' => '<strong>htm</strong>', '.php' => '<strong>php</strong>'), $pageSuffixValue, _t('独立页面后缀名'), _t('给独立页面设置一种文件后缀名, 使得它看起来像 <br /><strong>%s</strong>', Typecho_Common::url('example.html', $this->options->index))); $form->addInput($pageSuffix); /** 提交按钮 */ $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置')); $form->addItem($submit); return $form; }
/** * 构建相册表单 * * @access public * @param string $action,$render * @return Typecho_Widget_Helper_Form */ public static function form($action = NULL, $render = '1') { $options = Helper::options(); $settings = $options->plugin('HighSlide'); //图片编辑表单 $form1 = new Typecho_Widget_Helper_Form(Typecho_Common::url('/action/gallery-edit', $options->index), Typecho_Widget_Helper_Form::POST_METHOD); $image = new Typecho_Widget_Helper_Form_Element_Text('image', NULL, "http://", _t('原图地址*')); $form1->addInput($image); $thumb = new Typecho_Widget_Helper_Form_Element_Text('thumb', NULL, "http://", _t('缩略图地址*')); $form1->addInput($thumb); $name = new Typecho_Widget_Helper_Form_Element_Text('name', NULL, NULL, _t('图片名称')); $name->input->setAttribute('class', 'mini'); $form1->addInput($name); $description = new Typecho_Widget_Helper_Form_Element_Textarea('description', NULL, NULL, _t('图片描述'), _t('推荐填写, 用于展示相册中图片的文字说明效果')); $form1->addInput($description); $sort = new Typecho_Widget_Helper_Form_Element_Text('sort', NULL, "1", _t('相册组*'), _t('输入数字, 对应写入[GALLERY-数字]在页面调用')); $sort->input->setAttribute('class', 'w-10'); $form1->addInput($sort); $do = new Typecho_Widget_Helper_Form_Element_Hidden('do'); $form1->addInput($do); $gid = new Typecho_Widget_Helper_Form_Element_Hidden('gid'); $form1->addInput($gid); $submit = new Typecho_Widget_Helper_Form_Element_Submit(); $submit->input->setAttribute('class', 'btn'); $form1->addItem($submit); //相册设置表单 $form2 = new Typecho_Widget_Helper_Form(Typecho_Common::url('/action/gallery-edit?do=sync', $options->index), Typecho_Widget_Helper_Form::POST_METHOD); $gallery = new Typecho_Widget_Helper_Form_Element_Select('gallery', array('gallery-horizontal-strip' => _t('连环画册'), 'gallery-thumbstrip-above' => _t('黑色影夹'), 'gallery-vertical-strip' => _t('时光胶带'), 'gallery-in-box' => _t('纯白记忆'), 'gallery-floating-thumbs' => _t('往事片段'), 'gallery-floating-caption' => _t('沉默注脚'), 'gallery-controls-in-heading' => _t('岁月名片'), 'gallery-in-page' => _t('幻影橱窗(单相册)')), $settings->gallery, _t('相册风格'), _t('套装效果, 不受插件通用设置影响')); $form2->addInput($gallery); $thumboptions = array('fixedwidth' => _t('固定宽度 %s', ' <input type="text" class="w-10 text-s mono" name="fixedwidth" value="' . $settings->fixedwidth . '" />'), 'fixedheight' => _t('固定高度 %s', ' <input type="text" class="w-10 text-s mono" name="fixedheight" value="' . $settings->fixedheight . '" />'), 'fixedratio' => _t('固定比例 %s', ' <input type="text" class="w-10 text-s mono" name="fixedratio" value="' . $settings->fixedratio . '" />')); $thumbfix = new Typecho_Widget_Helper_Form_Element_Radio('thumbfix', $thumboptions, $settings->thumbfix, _t('缩略图规格'), _t('宽高单位px(无需填写), 比例注意使用半角冒号')); $form2->addInput($thumbfix->multiMode()); $storage = new Typecho_Widget_Helper_Form_Element_Radio('storage', array('local' => _t('本地'), 'qiniu' => _t('七牛'), 'upyun' => _t('又拍云'), 'bcs' => _t('百度BCS')), $settings->storage, _t('储存位置')); $form2->addInput($storage); $local = new Typecho_Widget_Helper_Form_Element_Text('local', NULL, $settings->local, _t('本地路径'), _t('确保首层目录可写, 结尾带/号')); $form2->addInput($local); $qiniubucket = new Typecho_Widget_Helper_Form_Element_Text('qiniubucket', NULL, $settings->qiniubucket, _t('空间名称')); $form2->addInput($qiniubucket); $qiniudomain = new Typecho_Widget_Helper_Form_Element_Text('qiniudomain', NULL, $settings->qiniudomain, _t('空间域名')); $form2->addInput($qiniudomain); $qiniuaccesskey = new Typecho_Widget_Helper_Form_Element_Text('qiniuaccesskey', NULL, $settings->qiniuaccesskey, _t('AccessKey')); $form2->addInput($qiniuaccesskey); $qiniusecretkey = new Typecho_Widget_Helper_Form_Element_Text('qiniusecretkey', NULL, $settings->qiniusecretkey, _t('SecretKey')); $form2->addInput($qiniusecretkey); $qiniuprefix = new Typecho_Widget_Helper_Form_Element_Text('qiniuprefix', NULL, $settings->qiniuprefix, _t('路径前缀'), _t('注意开头不要加/号')); $form2->addInput($qiniuprefix); $upyunbucket = new Typecho_Widget_Helper_Form_Element_Text('upyunbucket', NULL, $settings->upyunbucket, _t('空间名称')); $form2->addInput($upyunbucket); $upyundomain = new Typecho_Widget_Helper_Form_Element_Text('upyundomain', NULL, $settings->upyundomain, _t('绑定域名')); $form2->addInput($upyundomain); $upyunuser = new Typecho_Widget_Helper_Form_Element_Text('upyunuser', NULL, $settings->upyunuser, _t('操作员')); $form2->addInput($upyunuser); $upyunpwd = new Typecho_Widget_Helper_Form_Element_Text('upyunpwd', NULL, $settings->upyunpwd, _t('密码')); $form2->addInput($upyunpwd); $upyunkey = new Typecho_Widget_Helper_Form_Element_Text('upyunkey', NULL, $settings->upyunkey, _t('密匙')); $form2->addInput($upyunkey); $upyunprefix = new Typecho_Widget_Helper_Form_Element_Text('upyunprefix', NULL, $settings->upyunprefix, _t('路径前缀')); $form2->addInput($upyunprefix); $bcsbucket = new Typecho_Widget_Helper_Form_Element_Text('bcsbucket', NULL, $settings->bcsbucket, _t('空间名称')); $form2->addInput($bcsbucket); $bcsapikey = new Typecho_Widget_Helper_Form_Element_Text('bcsapikey', NULL, $settings->bcsapikey, _t('APIKey')); $form2->addInput($bcsapikey); $bcssecretkey = new Typecho_Widget_Helper_Form_Element_Text('bcssecretkey', NULL, $settings->bcssecretkey, _t('SecretKey')); $form2->addInput($bcssecretkey); $bcsprefix = new Typecho_Widget_Helper_Form_Element_Text('bcsprefix', NULL, $settings->bcsprefix, _t('路径前缀')); $form2->addInput($bcsprefix); $form2->addItem($submit); //隐藏模式 switch ($settings->storage) { case 'local': $qiniubucket->setAttribute('style', 'display:none;'); $qiniudomain->setAttribute('style', 'display:none;'); $qiniuaccesskey->setAttribute('style', 'display:none;'); $qiniusecretkey->setAttribute('style', 'display:none;'); $qiniuprefix->setAttribute('style', 'display:none;'); $upyunbucket->setAttribute('style', 'display:none;'); $upyundomain->setAttribute('style', 'display:none;'); $upyunuser->setAttribute('style', 'display:none;'); $upyunpwd->setAttribute('style', 'display:none;'); $upyunkey->setAttribute('style', 'display:none;'); $upyunprefix->setAttribute('style', 'display:none;'); $bcsbucket->setAttribute('style', 'display:none;'); $bcsapikey->setAttribute('style', 'display:none;'); $bcssecretkey->setAttribute('style', 'display:none;'); $bcsprefix->setAttribute('style', 'display:none;'); break; case 'qiniu': $local->setAttribute('style', 'display:none;'); $upyunbucket->setAttribute('style', 'display:none;'); $upyundomain->setAttribute('style', 'display:none;'); $upyunuser->setAttribute('style', 'display:none;'); $upyunpwd->setAttribute('style', 'display:none;'); $upyunkey->setAttribute('style', 'display:none;'); $upyunprefix->setAttribute('style', 'display:none;'); $bcsbucket->setAttribute('style', 'display:none;'); $bcsapikey->setAttribute('style', 'display:none;'); $bcssecretkey->setAttribute('style', 'display:none;'); $bcsprefix->setAttribute('style', 'display:none;'); break; case 'upyun': $local->setAttribute('style', 'display:none;'); $qiniubucket->setAttribute('style', 'display:none;'); $qiniudomain->setAttribute('style', 'display:none;'); $qiniuaccesskey->setAttribute('style', 'display:none;'); $qiniusecretkey->setAttribute('style', 'display:none;'); $qiniuprefix->setAttribute('style', 'display:none;'); $bcsbucket->setAttribute('style', 'display:none;'); $bcsapikey->setAttribute('style', 'display:none;'); $bcssecretkey->setAttribute('style', 'display:none;'); $bcsprefix->setAttribute('style', 'display:none;'); break; case 'bcs': $local->setAttribute('style', 'display:none;'); $qiniubucket->setAttribute('style', 'display:none;'); $qiniudomain->setAttribute('style', 'display:none;'); $qiniuaccesskey->setAttribute('style', 'display:none;'); $qiniusecretkey->setAttribute('style', 'display:none;'); $qiniuprefix->setAttribute('style', 'display:none;'); $upyunbucket->setAttribute('style', 'display:none;'); $upyundomain->setAttribute('style', 'display:none;'); $upyunuser->setAttribute('style', 'display:none;'); $upyunpwd->setAttribute('style', 'display:none;'); $upyunkey->setAttribute('style', 'display:none;'); $upyunprefix->setAttribute('style', 'display:none;'); break; } //更新模式 $request = Typecho_Request::getInstance(); if (isset($request->gid) && $action !== 'insert') { $db = Typecho_Db::get(); $prefix = $db->getPrefix(); $gallery = $db->fetchRow($db->select()->from($prefix . 'gallery')->where('gid=?', $request->gid)); if (!$gallery) { throw new Typecho_Widget_Exception(_t('图片不存在'), 404); } $thumb->value($gallery['thumb']); $image->value($gallery['image']); $sort->value($gallery['sort']); $name->value($gallery['name']); $description->value($gallery['description']); $do->value('update'); $gid->value($gallery['gid']); $submit->value(_t('修改图片')); $_action = 'update'; } elseif ($action == 'sync' && $render == '2') { $submit->value(_t('保存设置')); $_action = 'sync'; } else { $do->value('insert'); $submit->value(_t('添加图片')); $_action = 'insert'; } if (empty($action)) { $action = $_action; } //验证规则 if ($action == 'insert' || $action == 'update') { $thumb->addRule('required', _t('缩略图地址不能为空')); $image->addRule('required', _t('原图地址不能为空')); $sort->addRule('required', _t('相册组不能为空')); $thumb->addRule('url', _t('请输入合法的图片地址')); $image->addRule('url', _t('请输入合法的图片地址')); $sort->addRule('isInteger', _t('请输入一个整数数字')); } if ($action == 'update') { $gid->addRule('required', _t('图片主键不存在')); $gid->addRule(array(new HighSlide_Plugin(), 'galleryexists'), _t('图片不存在')); } $form = $render == '1' ? $form1 : $form2; return $form; }