/**
  * 获取插件配置面板
  * 
  * @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));
 }
Esempio n. 2
0
 /**
  * 获取插件配置面板
  * 
  * @access public
  * @param Typecho_Widget_Helper_Form $form 配置面板
  * @return void
  */
 public static function config(Typecho_Widget_Helper_Form $form)
 {
     $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)));
     $default_pay = new Typecho_Widget_Helper_Form_Element_Text('default_pay', NULL, 'https://www.hongweipeng.com/usr/uploads/2016/09/555702225.jpg', _t('默认的二维码'), _t('该项用于用户自定义数据扩展'));
     $form->addInput($default_pay);
     $user = new Typecho_Widget_Helper_Form_Element_Textarea('authors', NULL, NULL, _t('打赏二维码信息'), _t('输入合法的json数据'));
     $form->addInput($user);
 }
Esempio n. 3
0
function themeConfig($form)
{
    $logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, 'http://www.dotedu.me/usr/themes/materialize/img/logo.png', _t('站点LOGO地址'), _t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO'));
    $form->addInput($logoUrl);
    $bannerUrl = new Typecho_Widget_Helper_Form_Element_Text('bannerUrl', NULL, 'http://www.dotedu.me/usr/themes/materialize/img/transparent.jpg', _t('顶部大图'), _t('在这里填入一个图片URL地址, 以显示网站默认大图'));
    $form->addInput($bannerUrl);
    $siteIcon = new Typecho_Widget_Helper_Form_Element_Text('siteIcon', NULL, NULL, _t('标题栏和书签栏Icon'), _t('在这里填入一个图片URL地址, 作为标题栏和书签栏Icon, 默认不显示'));
    $form->addInput($siteIcon);
    $colorstyle = array_map('basename', glob(dirname(__FILE__) . '/css/color/*.css'));
    $colorThemeOptions = array_combine($colorstyle, $colorstyle);
    $colorTheme = new Typecho_Widget_Helper_Form_Element_Select('colorTheme', $colorThemeOptions, 'default', _t('主题配色'));
    $form->addInput($colorTheme);
    $layoutMode = new Typecho_Widget_Helper_Form_Element_Radio('layoutMode', array(0 => _t('GRID'), 1 => _t('单栏'), 2 => _t('双栏-左侧边栏'), 3 => _t('双栏-右侧边栏'), 4 => _t('三栏')), 3, _t('页面布局'), _t('选择对应的主题风格'));
    $form->addInput($layoutMode->addRule('enum', _t('必须选择一个模式'), array(0, 1, 2, 3, 4)));
    $sidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarBlock', array('ShowRecentPosts' => _t('显示最新文章'), 'ShowRecentComments' => _t('显示最近回复'), 'ShowCategory' => _t('显示分类'), 'ShowArchive' => _t('显示归档'), 'ShowLinks' => _t('友情链接'), 'ShowOther' => _t('显示其它杂项')), array('ShowRecentPosts', 'ShowRecentComments', 'ShowCategory', 'ShowArchive', 'ShowLinks', 'ShowOther'), _t('侧边栏显示'));
    $form->addInput($sidebarBlock->multiMode());
    $misc = new Typecho_Widget_Helper_Form_Element_Checkbox('misc', array('ShowLogin' => _t('前台显示登录入口'), 'ShowLoadTime' => _t('页脚显示加载耗时')), array('ShowLogin'), _t('杂项'));
    $form->addInput($misc->multiMode());
    $codeThemeToggle = new Typecho_Widget_Helper_Form_Element_Radio('codeThemeToggle', array(0 => _t('关闭'), 1 => _t('开启')), 0, _t('代码高亮'), _t('开启/关闭代码高亮功能'));
    $form->addInput($codeThemeToggle->addRule('enum', _t('必须选择一个模式'), array(0, 1)));
    $miibeian = new Typecho_Widget_Helper_Form_Element_Text('miibeian', NULL, _t('粤ICP备00000000号'), _t('备案号'), _t('在这里填入天朝备案号,不显示则留空'));
    $form->addInput($miibeian);
}
Esempio n. 4
0
 /**
  * 输出表单结构
  *
  * @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;
 }
Esempio n. 5
0
 /**
  * 获取插件配置面板
  *
  * @access public
  * @param Typecho_Widget_Helper_Form $form 配置面板
  * @return void
  */
 public static function config(Typecho_Widget_Helper_Form $form)
 {
     $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)));
 }
Esempio n. 6
0
 /**
  * 输出表单结构
  *
  * @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;
 }