Files
plugins/Soso/search.php
chorblack e75f275ef4
Some checks failed
定时更新GitHub源插件 / 自动更新GitHub插件 (push) Has been cancelled
Initial commit
2026-03-07 11:19:25 +08:00

35 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$po = $obj->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')
->where("table.contents.password IS NULL OR table.contents.password = ''")
->where('table.contents.status = ?', 'publish')
->where('table.contents.title LIKE ? OR table.contents.text LIKE ?', $searchQuery, $searchQuery)
->where('table.contents.type = ?', 'post')->group('cid');
//定制功能用来根据分类id搜索内容需模板代码配合才会启用
if($cat>0){
$po = $po->where('table.relationships.mid = ? OR table.metas.parent = ?',$cat,$cat);
}
//常规搜索
if($Somo==2){
$po = $po->where('table.contents.title LIKE ?', $searchQuery);//只允许搜索文章标题
}
$sid = Typecho_Widget::widget('Widget_Options')->plugin('Soso')->sid;
if(!$sid){}else{
$sid = explode(',', $sid);
$sid = array_unique($sid); //去除重复值
foreach ($sid as $k => $v) {
$po = $po->where('table.relationships.mid != '.intval($v));//确保每个值都是数字
}
}
$se = clone $po;
$obj->setCountSql($se);
$page=$obj->request->get('page');
$po = $po->order('table.contents.created', Typecho_Db::SORT_DESC)
->page($page, $obj->parameter->pageSize);
$obj->query($po);
return $keywords;
?>