From 554d4a20772bd967e63266db4a280cb8d8ea6693 Mon Sep 17 00:00:00 2001 From: Eltrac <45323514+BigCoke233@users.noreply.github.com> Date: Sat, 31 Aug 2019 14:23:28 +0800 Subject: =?UTF-8?q?=F0=9F=93=8C=20Del&Add:=20=E7=94=A8`Helper::options()`?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=9B=BF=E4=BB=A3=E6=9F=A5=E8=AF=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/functions.php b/functions.php index dd70365..adc4fa6 100644 --- a/functions.php +++ b/functions.php @@ -9,8 +9,6 @@ date_default_timezone_set("Asia/Shanghai"); /** * 注册文章解析 hook - * 具体的解析代码需要在 Contents::parseContent() 方法中实现 - * 解析不会改变数据库中的内容,体现在文章前台输出、RSS 输出时 * From AlanDecode(https://imalan.cn) */ Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('Contents','parseContent'); @@ -20,24 +18,11 @@ Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('Contents * 主题启用时执行的方法 */ function themeInit() { - $db = Typecho_Db::get(); - - $query = $db->update('table.options')->rows(array('value'=>'0'))->where('name=?', 'commentsAntiSpam'); - $db->query($query); - $query = $db->update('table.options')->rows(array('value'=>'0'))->where('name=?', 'commentsCheckReferer'); - $db->query($query); - - /* 设置评论最大嵌套层数 */ - $query = $db->update('table.options')->rows(array('value'=>'999'))->where('name=?', 'commentsMaxNestingLevels'); - $db->query($query); - - /* 强制新评论在前 */ - $query = $db->update('table.options')->rows(array('value'=>'DESC'))->where('name=?', 'commentsOrder'); - $db->query($query); - - /* 默认显示第一页评论 */ - $query = $db->update('table.options')->rows(array('value'=>'first'))->where('name=?', 'commentsPageDisplay'); - $db->query($query); + Helper::options()->commentsAntiSpam = false;//关闭反垃圾 + Helper::options()->commentsHTMLTagAllowed = ' '; + Helper::options()->commentsMaxNestingLevels = '9999';//最大嵌套层数 + Helper::options()->commentsPageDisplay = 'first';//强制评论第一页 + Helper::options()->commentsOrder = 'DESC';//将最新的评论展示在前 } /** @@ -46,7 +31,6 @@ function themeInit() { function themeFields(Typecho_Widget_Helper_Layout $layout) { $banner = new Typecho_Widget_Helper_Form_Element_Text('banner', NULL, NULL,_t('文章头图'), _t('输入一个图片 url,作为缩略图显示在文章列表,没有则不显示')); $layout->addItem($banner); - $excerpt = new Typecho_Widget_Helper_Form_Element_Text('excerpt', NULL, NULL,_t('文章摘要'), _t('输入一段文本来自定义摘要,如果为空则自动提取文章前 130 字。')); $layout->addItem($excerpt); } -- cgit v1.2.3