Commit 181dc3d9 authored by Luke081515's avatar Luke081515

Get page cats

parent 4c186db6
...@@ -1076,15 +1076,26 @@ class Core extends Password { ...@@ -1076,15 +1076,26 @@ class Core extends Password {
} }
return serialize($catResults); return serialize($catResults);
} }
/** getAllEmbedings /** getPageCatsID
* Returns a note that the method should get renamed. * reads out all categories of a page
* Used Fatal instead of notice since renaming a method is not that difficult. * works till the page has more than 500 categories
* @author Luke081515 * @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) { public function getPageCatsID($id) {
throw new Exception ("This method is misspelled, this was the fault of the programmers, and" $cats = $this->httpRequest("action=query&prop=categories&format=json&cllimit=max&pageids=" . urlencode($id) .
. "have now been fixed. Please rename your method to 'getAllEmbeddings', then it will work again."); "&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 /** getAllEmbeddings
* returns all embeddings of a page * returns all embeddings of a page
......
...@@ -460,6 +460,20 @@ class Debug extends Core { ...@@ -460,6 +460,20 @@ class Debug extends Core {
$this->processError($e, $starttime, $endtime); $this->processError($e, $starttime, $endtime);
} }
break; 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': case 'getAllEmbeddings':
$required = array("templ"); $required = array("templ");
$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