Commit ef0793be authored by Luke081515's avatar Luke081515
Browse files

Merge branch '22-add-function-getmissinglinks' into 'master'

Resolve "Add function getMissingLinks"

Closes #22

See merge request Cygnus/Cygnus!28
parents 85de532d 39bf2e1f
......@@ -830,6 +830,34 @@ class Core extends Password {
}
return serialize($page);
}
/** getMissingLinks
* Returns missing links "redlinks" on a page
* @author Freddy2001
* @param $Site - Page with links that will be checked
* @returns Array with missing pages or false if there are no links
*/
public function getMissingLinks ($Site) {
$data = "action=query&format=json&prop=info&generator=links&utf8=1&formatversion=2&gpllimit=max&titles=" . urlencode($Site);
try {
$website = $this->httpRequest($data, $this->job, 'GET');
$website = json_decode($website, true);
$answer = $website['query']['pages'];
$result = array();
for ($i = 0; $i < count($answer); $i++) {
if (isset($answer[$i]['missing'])) {
$result[] = $answer[$i]['title'];
}
}
if (count($result) < 1) {
return false;
} else {
return $result;
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
return false;
}
}
/** getAllPages
* returns all pages of namespace
* @author Luke081515
......@@ -1194,4 +1222,4 @@ class Core extends Password {
return "success";
}
}
?>
\ No newline at end of file
?>
......@@ -5,7 +5,6 @@
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
......
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