return $return;
}
+ /**
+ * Counts posts for given tag
+ *
+ * @param string $search
+ * @param integer $uid
+ * @return integer number of posts
+ */
+ public static function countByTag(string $search, int $uid = 0)
+ {
+ $condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))", $search, $uid];
+ $params = ['group_by' => ['uri-id']];
+
+ return DBA::count('tag-search-view', $condition, $params);
+ }
+
/**
* Search posts for given tag
*
$params = ['order' => ['id' => true], 'group_by' => ['uri-id']];
$items = Item::selectForUser(local_user(), [], ['uri-id' => $uriids], $params);
$r = Item::inArray($items);
+ $count = Tag::countByTag($search, local_user());
} else {
- $r = [];
+ $count = 0;
}
} else {
Logger::info('Start fulltext search.', ['q' => $search]);
];
$items = Item::selectForUser(local_user(), [], $condition, $params);
$r = Item::inArray($items);
+ $count = DBA::count('item', $condition);
}
if (!DBA::isResult($r)) {
$o .= conversation(DI::app(), $r, 'search', false, false, 'commented', local_user());
- $o .= $pager->renderMinimal(count($r));
+ $o .= $pager->renderMinimal($count);
return $o;
}