public function setup()
 {
     global $wgOut, $wgResourceModules, $wgAutoloadClasses, $wgExtensionAssetsPath, $IP, $wgUser, $wgAjaxCommentsPollServer, $wgAjaxCommentsLikeDislike, $wgAjaxCommentsCopyTalkpages, $wgAjaxCommentsAdmins;
     // Determine if the current user is an admin for comments
     self::$admin = count(array_intersect($wgAjaxCommentsAdmins, $wgUser->getEffectiveGroups())) > 0;
     // If options set, hook into the new revisions to change talk page additions to ajaxcomments
     if ($wgAjaxCommentsCopyTalkpages) {
         Hooks::register('PageContentSave', $this);
     }
     // Create a hook to allow external condition for whether there should be comments shown
     $title = array_key_exists('title', $_GET) ? Title::newFromText($_GET['title']) : false;
     if (!array_key_exists('action', $_REQUEST) && self::checkTitle($title)) {
         Hooks::register('BeforePageDisplay', $this);
     } else {
         $wgAjaxCommentsPollServer = -1;
     }
     // Create a hook to allow external condition for whether comments can be added or replied to (default is just user logged in)
     $this->canComment = $wgUser->isLoggedIn();
     Hooks::run('AjaxCommentsCheckWritable', array($title, &$this->canComment));
     // Redirect talk pages with AjaxComments to the comments
     if (is_object($title) && $title->getNamespace() > 0 && $title->getNamespace() & 1) {
         $ret = true;
         Hooks::run('AjaxCommentsCheckTitle', array($userpage, &$ret));
         if ($ret) {
             $userpage = Title::newFromText($title->getText(), $title->getNamespace() - 1);
             global $mediaWiki;
             if (is_object($mediaWiki)) {
                 $mediaWiki->restInPeace();
             }
             $wgOut->disable();
             wfResetOutputBuffers();
             $url = $userpage->getLocalUrl();
             header("Location: {$url}#ajaxcomments");
             wfDebugLog(__CLASS__, "Redirecting to {$url}");
             exit;
         }
     }
     // This gets the remote path even if it's a symlink (MW1.25+)
     $path = $wgExtensionAssetsPath . str_replace("{$IP}/extensions", '', dirname($wgAutoloadClasses[__CLASS__]));
     $wgResourceModules['ext.ajaxcomments']['remoteExtPath'] = $path;
     $wgOut->addModules('ext.ajaxcomments');
     $wgOut->addStyle("{$path}/styles/ajaxcomments.css");
     // Add config vars to client side
     $wgOut->addJsConfigVars('ajaxCommentsPollServer', $wgAjaxCommentsPollServer);
     $wgOut->addJsConfigVars('ajaxCommentsCanComment', $this->canComment);
     $wgOut->addJsConfigVars('ajaxCommentsLikeDislike', $wgAjaxCommentsLikeDislike);
     $wgOut->addJsConfigVars('ajaxCommentsAdmin', self::$admin);
 }