Exemplo n.º 1
0
 public function getUserCount()
 {
     $standings = new NFDStandingsIndividual();
     $data = $standings->fetchStats();
     return $data['week'];
 }
Exemplo n.º 2
0
 function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgTitle;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (!($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()))) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     wfLoadExtensionMessages("NFDGuardian");
     if ($wgRequest->getVal('fetchInnards')) {
         //get next article to vote on
         $wgOut->disable();
         $result = self::getNextInnards($wgRequest->getVal('nfd_type'));
         print_r(json_encode($result));
         return;
     } else {
         if ($wgRequest->getVal('getVoteBlock')) {
             //get all the votes for the right rail module
             $wgOut->setArticleBodyOnly(true);
             $wgOut->addHTML(self::getVoteBlock($wgRequest->getVal('nfd_id')));
             return;
         } else {
             if ($wgRequest->getVal('edit')) {
                 //get the html that goes into the page when a user clicks the edit tab
                 $wgOut->setArticleBodyOnly(true);
                 $t = Title::newFromID($wgRequest->getVal('articleId'));
                 if ($t) {
                     $a = new Article($t);
                     $editor = new EditPage($a);
                     $editor->edit();
                     //Old code for when we wanted to remove
                     //the nfd template from the edit window
                     /*$content = $wgOut->getHTML();
                     				$wgOut->clearHTML();
                     
                     				//grab the edit form
                     				$data = array();
                     				$data['form'] = $content;
                     
                     				//then take out the template
                     				$c = new NFDProcessor();
                     				$template = $c->getFullTemplate($wgRequest->getVal('nfd_id'));
                     				$articleContent = $a->getContent();
                     				$articleContent = str_replace($template, "", $articleContent);
                     				$data['newContent'] = $articleContent;
                     				print_r(json_encode($data));*/
                 }
                 return;
             } else {
                 if ($wgRequest->getVal('discussion')) {
                     //get the html that goes into the page when a user clicks the discussion tab
                     $wgOut->setArticleBodyOnly(true);
                     $t = Title::newFromID($wgRequest->getVal('articleId'));
                     if ($t) {
                         $tDiscussion = $t->getTalkPage();
                         if ($tDiscussion) {
                             $a = new Article($tDiscussion);
                             $content = $a->getContent();
                             $wgOldTitle = $wgTitle;
                             $wgTitle = $tDiscussion;
                             $wgOut->addHTML($wgOut->parse($content));
                             $wgOut->addHTML(PostComment::getForm(true, $tDiscussion, true));
                             $wgTitle = $wgOldTitle;
                         }
                     }
                     return;
                 } else {
                     if ($wgRequest->getVal('confirmation')) {
                         //get confirmation dialog after user has edited the article
                         $wgOut->setArticleBodyOnly(true);
                         echo $this->confirmationModal($wgRequest->getVal('articleId'));
                         return;
                     } else {
                         if ($wgRequest->getVal('history')) {
                             //get the html that goes into the page when a user clicks the history tab
                             $wgOut->setArticleBodyOnly(true);
                             $t = Title::newFromID($wgRequest->getVal('articleId'));
                             if ($t) {
                                 $historyContext = clone $this->getContext();
                                 $historyContext->setTitle($t);
                                 $historyContext->setWikiPage(WikiPage::factory($t));
                                 $pageHistory = Action::factory("history", WikiPage::factory($t), $historyContext);
                                 $pageHistory->onView();
                                 return;
                             }
                         } else {
                             if ($wgRequest->getVal('diff')) {
                                 //get the html that goes into the page when a user asks for a diffs
                                 $wgOut->setArticleBodyOnly(true);
                                 $t = Title::newFromID($wgRequest->getVal('articleId'));
                                 if ($t) {
                                     $a = new Article($t);
                                     $wgOut->addHtml('<div class="article_inner">');
                                     $a->view();
                                     $wgOut->addHtml('</div>');
                                 }
                                 return;
                             } else {
                                 if ($wgRequest->getVal('article')) {
                                     //get the html that goes into the page when a user clicks the article tab
                                     $wgOut->setArticleBodyOnly(true);
                                     $t = Title::newFromId($wgRequest->getVal('articleId'));
                                     if ($t) {
                                         $r = Revision::newFromTitle($t);
                                         if ($r) {
                                             $popts = $wgOut->parserOptions();
                                             $popts->setTidy(true);
                                             echo WikihowArticleHTML::processArticleHTML($wgOut->parse($r->getText(), $t, $popts), array('no-ads' => true, 'ns' => $t->getNamespace()));
                                         }
                                     }
                                     return;
                                 } else {
                                     if ($wgRequest->wasPosted()) {
                                         $wgOut->setArticleBodyOnly(true);
                                         if ($wgRequest->getVal('submitEditForm')) {
                                             //user has edited the article from within the NFD Guardian tool
                                             $wgOut->disable();
                                             $this->submitEdit();
                                             $result = self::getNextInnards($wgRequest->getVal('nfd_type'));
                                             print_r(json_encode($result));
                                             return;
                                         } else {
                                             //user has voted
                                             if ($wgRequest->getVal('nfd_skip', 0) == 1) {
                                                 NFDProcessor::skip($wgRequest->getVal('nfd_id'));
                                             } else {
                                                 NFDProcessor::vote($wgRequest->getVal('nfd_id'), $wgRequest->getVal('nfd_vote'));
                                             }
                                             $wgOut->disable();
                                             $result = self::getNextInnards($wgRequest->getVal('nfd_type'));
                                             print_r(json_encode($result));
                                             return;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /**
      * This is the shell of the page, has the buttons, etc.
      */
     $wgOut->addJScode('nfdgj');
     $wgOut->addJScode('csjs');
     $wgOut->addCSScode('nfdgc');
     $wgOut->addCSScode('diffc');
     //add delete confirmation to bottom of page
     $wgOut->addHtml("<div class='waiting'><img src='" . wfGetPad('/extensions/wikihow/rotate.gif') . "' alt='' /></div>");
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $wgOut->addHTML($tmpl->execute('NFDdelete.tmpl.php'));
     $wgOut->setHTMLTitle(wfMsg('nfd'));
     $wgOut->setPageTitle(wfMsg('nfd'));
     // add standings widget
     $group = new NFDStandingsGroup();
     $indi = new NFDStandingsIndividual();
     $indi->addStatsWidget();
     $group->addStandingsWidget();
 }