This commit is contained in:
83
CateFilter/Plugin.php
Normal file
83
CateFilter/Plugin.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* 首页过滤指定分类
|
||||
*
|
||||
* @package CateFilter
|
||||
* @author Rakiy
|
||||
* @version 1.2.5
|
||||
* @link
|
||||
*/
|
||||
class CateFilter_Plugin implements Typecho_Plugin_Interface
|
||||
{
|
||||
/**
|
||||
* 激活插件方法,如果激活失败,直接抛出异常
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @throws Typecho_Plugin_Exception
|
||||
*/
|
||||
public static function activate()
|
||||
{
|
||||
Typecho_Plugin::factory('Widget_Archive')->indexHandle = array(__CLASS__, 'filter');
|
||||
return _t('插件已激活,现在可以对插件进行设置!');
|
||||
}
|
||||
/**
|
||||
* 禁用插件方法,如果禁用失败,直接抛出异常
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return void
|
||||
* @throws Typecho_Plugin_Exception
|
||||
*/
|
||||
public static function deactivate(){}
|
||||
/**
|
||||
* 获取插件配置面板
|
||||
*
|
||||
* @access public
|
||||
* @param Typecho_Widget_Helper_Form $form 配置面板
|
||||
* @return void
|
||||
*/
|
||||
public static function config(Typecho_Widget_Helper_Form $form){
|
||||
|
||||
Typecho_Widget::widget('Widget_Metas_Category_List')->to($categories);
|
||||
while($categories->next()){$cate[$categories->mid]=$categories->name;}//获取分类列表
|
||||
|
||||
$CateId = new Typecho_Widget_Helper_Form_Element_Checkbox('CateId',
|
||||
$cate,[], _t('勾选首页不想显示的分类'), NULL);
|
||||
$form->addInput($CateId->multiMode());
|
||||
|
||||
}
|
||||
/**
|
||||
* 个人用户的配置面板
|
||||
*
|
||||
* @access public
|
||||
* @param Typecho_Widget_Helper_Form $form
|
||||
* @return void
|
||||
*/
|
||||
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
|
||||
|
||||
/**
|
||||
* 插件实现方法
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/**
|
||||
* 插件实现方法
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function filter($obj, $select){
|
||||
//if('/feed' == strtolower(Typecho_Router::getPathInfo()) || '/feed/' == strtolower(Typecho_Router::getPathInfo())) return $select;
|
||||
$CateIds = Typecho_Widget::widget('Widget_Options')->plugin('CateFilter')->CateId;
|
||||
if(empty($CateIds)) return $select; //数组为空,则直接返回
|
||||
$select = $select->join('table.relationships','table.relationships.cid = table.contents.cid','right')->join('table.metas','table.relationships.mid = table.metas.mid','right')->where('table.metas.type=?','category');
|
||||
foreach ($CateIds as $k => $v) {
|
||||
$select = $select->where('table.relationships.mid != '.intval($v))->group('cid');//确保每个值都是数字;排除重复文章
|
||||
}
|
||||
return $select;
|
||||
}
|
||||
|
||||
}
|
||||
34
CateFilter/README.md
Normal file
34
CateFilter/README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# CateFilter
|
||||
***
|
||||
|
||||
##版本
|
||||
1.2.5
|
||||
|
||||
##说明
|
||||
首页过滤指定分类
|
||||
|
||||
##历史更新
|
||||
|
||||
V1.2.5 2024.02.10
|
||||
简化代码,使其代码更加简练
|
||||
|
||||
V1.2.4 2024.01.14
|
||||
修复Typecho1.2.1勾选不上设置的问题
|
||||
|
||||
V1.2.3 2022.04.03
|
||||
删除原作者失效域名,优化一处写法
|
||||
|
||||
V1.2.2 2019.04.07
|
||||
修复文章勾选多个分类,文章就会重复输出多篇的bug
|
||||
|
||||
V1.2.1 2017.07.09
|
||||
修复使用插件在PHP7.1下启用时报500的错误
|
||||
|
||||
V1.1.1 2017.03.22
|
||||
修复使用插件后首页文章链接变成分类链接的BUG
|
||||
|
||||
V1.1.0 2016.11.25
|
||||
修复过滤分类时同时会过滤FEED的BUG
|
||||
|
||||
V1.0 2013.12.22
|
||||
实现功能
|
||||
Reference in New Issue
Block a user