diff --git a/includes/LinkCount.php b/includes/LinkCount.php index 05de5a4..b509810 100644 --- a/includes/LinkCount.php +++ b/includes/LinkCount.php @@ -158,6 +158,20 @@ private function counts($table, $prefix, $mode = self::COUNT_MODE_LINK, $hasFrom ]; } + public function getTitle() { + $parts = []; + + if (isset($this->error)) { + array_push($parts, 'Error'); + } elseif (isset($this->counts)) { + array_push($parts, $this->title->getFullText()); + } + + array_push($parts, 'Link Count'); + + return implode(' - ', $parts); + } + public function getHtml() { if (isset($this->error)) { return (new OOUI\Tag('div'))->addClasses(['error'])->appendContent($this->error)->toString(); @@ -212,6 +226,13 @@ public function getHtml() { return $out . $links; } + public function getPageUpdateJson() { + return json_encode([ + 'title' => $this->getTitle(), + 'html' => $this->getHtml() + ]); + } + public function getJson() { if (isset($this->error)) { return json_encode(['error' => $this->error]); diff --git a/index.php b/index.php index d2a1810..74fd73b 100644 --- a/index.php +++ b/index.php @@ -2,11 +2,13 @@ require 'vendor/autoload.php'; +$linkCount = new LinkCount(get('page'), get('project'), get('namespaces')); + ?>
-