Commit c9692b3d authored by ~rs's avatar ~rs Committed by Luke081515

add function search

parent 0c3da563
......@@ -1222,6 +1222,22 @@ class Core extends Password {
$content = substr($content, 0, strpos($content, "="));
return ["title" => $content, "level" => $sectionlevel, ];
}
/** search
* uses API fulltext search
* @author KPFC
* @param pattern - pattern to search
* @param ns - numbers of the namespaces to search in; seperate with "|"
* @param prop - properties to return; seperate with "|" (size, wordcount, timestamp, snippet, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, isfilematch, categorysnippet, extensiondata)
* @param limit - number of results to return; max 500 or 5000 for bots
* @param offset - show only the results from position on
* @param what - what to search (title/text/nearmatch)
* @return result - array with the results
*/
public function search($pattern, $ns=0, $prop="size|wordcount|timestamp|snippet", $limit=50, $offset=0, $what="text") {
$data = "action=query&format=json&assert=" . $this->assert . "&maxlag=" . $this->maxlag . "&list=search&srsearch=" . $pattern . "&srnamespace=" . $ns . "&srprop=" . $prop . "&sroffset=" . $offset . "&srwhat=" . $what;
$result = json_decode($this->httpRequest($data, $this->job, "GET"), true);
return $result;
}
/** getMaxlag
* @author Luke081515
* @return $this->maxlag
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment