Commit fc1dd955 authored by Luke081515's avatar Luke081515

temp

parent 25bf5973
Pipeline #2861 failed with stages
in 2 minutes and 37 seconds
...@@ -1238,6 +1238,25 @@ class Core extends Password { ...@@ -1238,6 +1238,25 @@ class Core extends Password {
} }
return false; return false;
} }
/** getLinksHere
* returns all links that point to a page, maximum 10
* @author Luke081515
* @param $id - pageid
* @return array with page titles, false if no links
*/
public function getLinksHere($id) {
$request = "action=query&assert=bot&maxlag=5&prop=linkshere&lhprop=pageid%7Ctitle&lhnamespace=0&lhshow=!redirect&lhlimit=10&pageids=" . urlencode($id);
$result = json_decode($this->httpRequest($request, $this->job, "GET"), true);
$count = 0;
while (isset($result["query"]["pages"][$id]["linkshere"][$count]["title"])) {
$links[] = $result["query"]["pages"][$id]["linkshere"][$count]["title"];
$count++;
}
if (isset($links[0])) {
return $links;
}
return false;
}
/** getSectionTitle /** getSectionTitle
* returns the title and the number of a section * returns the title and the number of a section
* @author Freddy2001 * @author Freddy2001
......
...@@ -544,6 +544,20 @@ class Debug extends Core { ...@@ -544,6 +544,20 @@ class Debug extends Core {
$this->processError($e, $starttime, $endtime); $this->processError($e, $starttime, $endtime);
} }
break; break;
case 'getLinksHere':
$required = array("title");
$Param = $this->getParams($required);
$this->echoMsg("Starting the function call of getLinksHere...", "notice");
$starttime = microtime (true);
try {
$ret = $this->getLinksHere($Param[0]);
$endtime = microtime (true);
$this->processFunction($ret, $starttime, $endtime);
} catch (Exception $e) {
$endtime = microtime (true);
$this->processError($e, $starttime, $endtime);
}
break;
case 'getSectionTitle': case 'getSectionTitle':
$required = array("title", "section"); $required = array("title", "section");
$Param = $this->getParams($required); $Param = $this->getParams($required);
......
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