Commit 181dc3d9 authored by Luke081515's avatar Luke081515

Get page cats

parent 4c186db6
......@@ -1076,15 +1076,26 @@ class Core extends Password {
}
return serialize($catResults);
}
/** getAllEmbedings
* Returns a note that the method should get renamed.
* Used Fatal instead of notice since renaming a method is not that difficult.
/** getPageCatsID
* reads out all categories of a page
* works till the page has more than 500 categories
* @author Luke081515
* Should be removed at 2.2
* @param $id - pageid that should get analyzed
* @return all categories as serialized array
*/
public function getAllEmbedings($templ) {
throw new Exception ("This method is misspelled, this was the fault of the programmers, and"
. "have now been fixed. Please rename your method to 'getAllEmbeddings', then it will work again.");
public function getPageCatsID($id) {
$cats = $this->httpRequest("action=query&prop=categories&format=json&cllimit=max&pageids=" . urlencode($id) .
"&cldir=ascending&rawcontinue=&assert=" . $this->assert . "&maxlag=" .
$this->maxlag . "&indexpageids=1", $this->job, "GET");
$cats = json_decode($cats, true);
$pageID = $cats["query"]["pageids"][0];
for ($a = 0; isset($cats["query"]["pages"][$pageID]["categories"][$a]); $a++) {
$catResults[$a] = $cats["query"]["pages"][$pageID]["categories"][$a];
}
if (!isset($catResults[0])) {
return false;
}
return serialize($catResults);
}
/** getAllEmbeddings
* returns all embeddings of a page
......
......@@ -460,6 +460,20 @@ class Debug extends Core {
$this->processError($e, $starttime, $endtime);
}
break;
case 'getPageCatsID':
$required = array("id");
$Param = $this->getParams($required);
$this->echoMsg("Starting the function call of getPageCatsID...", "notice");
$starttime = microtime (true);
try {
$ret = $this->getPageCatsID($Param[0]);
$endtime = microtime (true);
$this->processFunction($ret, $starttime, $endtime);
} catch (Exception $e) {
$endtime = microtime (true);
$this->processError($e, $starttime, $endtime);
}
break;
case 'getAllEmbeddings':
$required = array("templ");
$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