/** * Check whether data should be loaded for the stylometric analysis namespace page */ private function StylometricanalysisDataShouldBeLoaded(Title $title, WebRequest $request, MediaWiki $wiki) { if ($wiki->getAction($request) !== 'view') { return false; } $namespace = $title->getNamespace(); if ($namespace !== NS_STYLOMETRICANALYSIS) { return false; } return true; }
/** * MediaWikiPerformAction hook. Retrieve the collatex output stored in the database and render the table if the user is in NS_COLLATIONS */ public function onMediaWikiPerformAction(OutputPage $output, Article $article, Title $title, User $user, WebRequest $request, MediaWiki $wiki) { try { if ($wiki->getAction($request) !== 'view' || !$this->isCollationsNamespace($title)) { return true; } $wrapper = $this->wrapper; $partial_url = $title->getPrefixedUrl(); $this->signature = $wrapper->getSignatureWrapper()->getCollationsSignature($partial_url); if (!$this->userIsAllowedToViewThePage($user)) { return true; } $this->user_has_view_permission = true; $data = $wrapper->getCollationsData($partial_url); $viewer = new CollateViewer($output); $viewer->showCollateNamespacePage($data); } catch (Exception $e) { $this->page_exists = false; return true; } return true; }