10 defined(
'JPATH_PLATFORM') or die;
34 public function editPage($title, $section = null, $sectiontitle = null, $text = null, $summary = null)
37 $token = $this->getToken($title,
'edit');
40 $path =
'?action=edit';
46 'section' => $section,
47 'sectiontitle' => $section,
53 $response = $this->client->post($this->fetchUrl($path), $data);
55 return $this->validateResponse($response);
70 public function deletePageByName($title, $reason = null, $watchlist = null, $oldimage = null)
73 $token = $this->getToken($title,
'delete');
76 $path =
'?action=delete';
83 'watchlist' => $watchlist,
84 'oldimage' => $oldimage
88 $response = $this->client->post($this->fetchUrl($path), $data);
90 return $this->validateResponse($response);
105 public function deletePageByID($pageid, $reason = null, $watchlist = null, $oldimage = null)
108 $token = $this->getToken($pageid,
'delete');
111 $path =
'?action=delete';
118 'watchlist' => $watchlist,
119 'oldimage' => $oldimage
123 $response = $this->client->post($this->fetchUrl($path), $data);
125 return $this->validateResponse($response);
140 public function undeletePage($title, $reason = null, $timestamp = null, $watchlist = null)
143 $token = $this->getToken($title,
'undelete');
146 $path =
'?action=undelete';
153 'timestamp' => $timestamp,
154 'watchlist' => $watchlist,
158 $response = $this->client->post($this->fetchUrl($path), $data);
160 return $this->validateResponse($response);
179 public function movePageByName($from, $to, $reason = null, $movetalk = null, $movesubpages = null, $noredirect = null,
180 $watchlist =null, $ignorewarnings = null)
183 $token = $this->getToken($from,
'move');
186 $path =
'?action=move';
194 'movetalk' => $movetalk,
195 'movesubpages' => $movesubpages,
196 'noredirect' => $noredirect,
197 'watchlist' => $watchlist,
198 'ignorewarnings' => $ignorewarnings
202 $response = $this->client->post($this->fetchUrl($path), $data);
204 return $this->validateResponse($response);
223 public function movePageByID($fromid, $to, $reason = null, $movetalk = null, $movesubpages = null, $noredirect = null,
224 $watchlist =null, $ignorewarnings = null)
227 $token = $this->getToken($fromid,
'move');
230 $path =
'?action=move';
238 'movetalk' => $movetalk,
239 'movesubpages' => $movesubpages,
240 'noredirect' => $noredirect,
241 'watchlist' => $watchlist,
242 'ignorewarnings' => $ignorewarnings
246 $response = $this->client->post($this->fetchUrl($path), $data);
248 return $this->validateResponse($response);
264 public function rollback($title, $user, $summary = null, $markbot = null, $watchlist = null)
267 $token = $this->getToken($title,
'rollback');
270 $path =
'?action=rollback';
277 'expiry' => $summary,
278 'markbot' => $markbot,
279 'watchlist' => $watchlist
283 $response = $this->client->post($this->fetchUrl($path), $data);
285 return $this->validateResponse($response);
302 public function changeProtection($title, $protections, $expiry = null, $reason = null, $cascade = null, $watchlist = null)
305 $token = $this->getToken($title,
'unblock');
308 $path =
'?action=protect';
314 'protections' => $protections,
317 'cascade' => $cascade,
318 'watchlist' => $watchlist
322 $response = $this->client->post($this->fetchUrl($path), $data);
324 return $this->validateResponse($response);
339 public function getPageInfo(array $titles, array $inprop = null, array $intoken = null, $incontinue = null)
342 $path =
'?action=query&prop=info';
345 $path .=
'&titles=' . $this->buildParameter($titles);
349 $path .=
'&inprop=' . $this->buildParameter($inprop);
354 $path .=
'&intoken=' . $this->buildParameter($intoken);
359 $path .=
'&incontinue=';
363 $response = $this->client->get($this->fetchUrl($path));
365 return $this->validateResponse($response);
379 public function getPageProperties(array $titles, $ppcontinue = null, $ppprop = null)
382 $path =
'?action=query&prop=pageprops';
385 $path .=
'&titles=' . $this->buildParameter($titles);
389 $path .=
'&ppcontinue=';
394 $path .=
'&ppprop=' . $ppprop;
398 $response = $this->client->get($this->fetchUrl($path));
400 return $this->validateResponse($response);
415 public function getRevisions(array $titles, array $rvprop = null, $rvparse = null, $rvlimit = null)
418 $path =
'?action=query&prop=revisions';
421 $path .=
'&titles=' . $this->buildParameter($titles);
425 $path .=
'&rvprop=' . $this->buildParameter($rvprop);
430 $path .=
'&rvparse=';
435 $path .=
'&rvlimit=' . $rvlimit;
439 $response = $this->client->get($this->fetchUrl($path));
441 return $this->validateResponse($response);
458 public function getPageTemplates(array $titles, array $tlnamespace = null, $tllimit = null, $tlcontinue = null, $tltemplates = null, $tldir = null)
461 $path =
'?action=query&prop=templates';
464 $path .=
'&titles=' . $this->buildParameter($titles);
466 if (isset($tlnamespace))
468 $path .=
'&tlnamespace=' . $this->buildParameter($tlnamespace);
473 $path .=
'&tllimit=' . $tllimit;
478 $path .=
'&tlcontinue=';
481 if (isset($tltemplates))
483 $path .=
'&tltemplates=' . $tltemplates;
488 $path .=
'&tldir=' . $tldir;
492 $response = $this->client->get($this->fetchUrl($path));
494 return $this->validateResponse($response);
512 public function getBackLinks($bltitle, $blpageid = null, $blcontinue = null, array $blnamespace = null, $blfilterredirect = null,
513 $bllimit = null, $blredirect = null)
516 $path =
'?action=query&list=backlinks';
520 $path .=
'&bltitle=' . $bltitle;
523 if (isset($blpageid))
525 $path .=
'&blpageid=' . $blpageid;
530 $path .=
'&blcontinue=';
533 if (isset($blnamespace))
535 $path .=
'&blnamespace=' . $this->buildParameter($blnamespace);
538 if (isset($blfilterredirect))
540 $path .=
'&blfilterredirect=' . $blfilterredirect;
545 $path .=
'&bllimit=' . $bllimit;
550 $path .=
'&blredirect=';
554 $response = $this->client->get($this->fetchUrl($path));
556 return $this->validateResponse($response);
572 public function getIWBackLinks($iwbltitle, $iwblprefix = null, $iwblcontinue = null, $iwbllimit = null, array $iwblprop = null)
575 $path =
'?action=query&list=iwbacklinks';
577 if (isset($iwbltitle))
579 $path .=
'&iwbltitle=' . $iwbltitle;
582 if (isset($iwblprefix))
584 $path .=
'&iwblprefix=' . $iwblprefix;
589 $path .=
'&iwblcontinue=';
592 if (isset($iwbllimit))
594 $path .=
'&bllimit=' . $iwbllimit;
597 if (isset($iwblprop))
599 $path .=
'&iwblprop=' . $this->buildParameter($iwblprop);
603 $response = $this->client->get($this->fetchUrl($path));
605 return $this->validateResponse($response);
618 public function getToken($user, $intoken)
621 $path =
'?action=query&prop=info&intoken=' . $intoken .
'&titles=User:' . $user;
624 $response = $this->client->post($this->fetchUrl($path), null);
626 return (
string) $this->validateResponse($response)->query->pages->page[$intoken .
'token'];