Skip to content

Commit

Permalink
简化代码
Browse files Browse the repository at this point in the history
1,sql代码简化
2,去重功能的代码删除,因为现在插件设置是勾选的所以不存在重复设置的情况
  • Loading branch information
jrotty authored Feb 10, 2024
1 parent 18bb6e4 commit 467fcfd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions CateFilter/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package CateFilter
* @author Rakiy
* @version 1.2.4
* @version 1.2.5
* @link
*/
class CateFilter_Plugin implements Typecho_Plugin_Interface
Expand Down Expand Up @@ -73,12 +73,11 @@ 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->select('table.contents.cid', 'table.contents.title', 'table.contents.slug', 'table.contents.created', 'table.contents.authorId','table.contents.modified', 'table.contents.type', 'table.contents.status', 'table.contents.text', 'table.contents.commentsNum', 'table.contents.order','table.contents.template', 'table.contents.password', 'table.contents.allowComment', 'table.contents.allowPing', 'table.contents.allowFeed','table.contents.parent')->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');
$CateIds = array_unique($CateIds); //去除重复值
$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;
}

}
}

0 comments on commit 467fcfd

Please sign in to comment.