Ejemplo n.º 1
0
 /**
  * cuteCUTE
  **/
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang, $wgParser, $efType, $wgTitle;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     wfLoadExtensionMessages('EditFinder');
     self::setTemplatePath();
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if ($wgUser->getID() == 0) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $this->topicMode = strtolower($par) == 'topic' || strtolower($wgRequest->getVal('edittype')) == 'topic';
     if ($wgRequest->getVal('fetchArticle')) {
         $wgOut->setArticleBodyOnly(true);
         echo json_encode($this->getNextArticle());
         return;
     } elseif ($wgRequest->getVal('show-article')) {
         $wgOut->setArticleBodyOnly(true);
         if ($wgRequest->getInt('aid') == '') {
             $catsJs = $this->topicMode ? "editFinder.getThoseInterests();" : "editFinder.getThoseCats();";
             $catsTxt = $this->topicMode ? "interests" : "categories";
             $wgOut->addHTML('<div class="article_inner">No articles found.  <a href="#" onclick="' . $catsJs . '">Select more ' . $catsTxt . '</a> and try again.</div>');
             return;
         }
         $t = Title::newFromID($wgRequest->getInt('aid'));
         $articleTitleLink = $t->getLocalURL();
         $articleTitle = $t->getText();
         //$edittype = $a['edittype'];
         //get article
         $a = new Article($t);
         $r = Revision::newFromTitle($t);
         $popts = $wgOut->parserOptions();
         $popts->setTidy(true);
         $popts->enableLimitReport();
         $parserOutput = $wgParser->parse($r->getText(), $t, $popts, true, true, $a->getRevIdFetched());
         $popts->setTidy(false);
         $popts->enableLimitReport(false);
         $html = WikihowArticleHTML::processArticleHTML($parserOutput->getText(), array('no-ads', 'ns' => NS_MAIN));
         $wgOut->addHTML($html);
         return;
     } elseif ($wgRequest->getVal('edit-article')) {
         // SHOW THE EDIT FORM
         $wgOut->setArticleBodyOnly(true);
         $t = Title::newFromID($wgRequest->getInt('aid'));
         $a = new Article($t);
         $editor = new EditPage($a);
         $editor->edit();
         return;
     } elseif ($wgRequest->getVal('action') == 'submit') {
         $wgOut->setArticleBodyOnly(true);
         $efType = strtolower($wgRequest->getVal('type'));
         $t = Title::newFromID($wgRequest->getInt('aid'));
         $a = new Article($t);
         //log it
         $params = array($efType);
         $log = new LogPage('EF_' . substr($efType, 0, 7), false);
         // false - dont show in recentchanges
         $log->addEntry('', $t, 'Repaired an article -- ' . strtoupper($efType) . '.', $params);
         $text = $wgRequest->getVal('wpTextbox1');
         $sum = $wgRequest->getVal('wpSummary');
         //save the edit
         $a->doEdit($text, $sum, EDIT_UPDATE);
         wfRunHooks("EditFinderArticleSaveComplete", array($a, $text, $sum, $wgUser, $efType));
         return;
     } elseif ($wgRequest->getVal('confirmation')) {
         $wgOut->setArticleBodyOnly(true);
         echo $this->confirmationModal($wgRequest->getVal('type'), $wgRequest->getInt('aid'));
         wfProfileOut(__METHOD__);
         return;
     } elseif ($wgRequest->getVal('cancel-confirmation')) {
         $wgOut->setArticleBodyOnly(true);
         echo $this->cancelConfirmationModal($wgRequest->getInt('aid'));
         wfProfileOut(__METHOD__);
         return;
     } else {
         //default view (same as most of the views)
         $sk = $wgUser->getSkin();
         $wgOut->setArticleBodyOnly(false);
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('mousetrap.min.js', 'jquery.cookie.js'), 'extensions/wikihow/common', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('preview.js'), 'skins/common', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('clientscript.js', 'preview.js'), 'skins/common', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('editfinder.js'), 'extensions/wikihow/editfinder', false));
         $efType = strtolower($target);
         if (strpos($efType, '/') !== false) {
             $efType = substr($efType, 0, strpos($efType, '/'));
         }
         if ($efType == '') {
             //no type specified?  send 'em to format...
             $wgOut->redirect('/Special:EditFinder/Format');
         }
         $wgOut->addHTML('<script>var g_eftype = "' . $target . '";</script>');
         //add main article info
         $vars = array('pagetitle' => wfMsg('app-name') . ': ' . wfMsg($efType), 'question' => wfMsg('editfinder-question'), 'yep' => wfMsg('editfinder_yes'), 'nope' => wfMsg('editfinder_no'), 'helparticle' => wfMsg('help_' . $efType));
         $vars['uc_categories'] = $this->topicMode ? 'Interests' : 'Categories';
         $vars['lc_categories'] = $this->topicMode ? 'interests' : 'categories';
         $vars['editfinder_edit_title'] = wfMsg('editfinder_edit_title');
         $vars['editfinder_skip_title'] = wfMsg('editfinder_skip_title');
         $vars['css'] = HtmlSnips::makeUrlTags('css', array('editfinder.css'), 'extensions/wikihow/editfinder', false);
         $vars['css'] .= HtmlSnips::makeUrlTags('css', array('suggestedtopics.css'), 'extensions/wikihow', false);
         $html = EasyTemplate::html('editfinder_main', $vars);
         $wgOut->addHTML($html);
         $wgOut->setHTMLTitle(wfMsg('app-name') . ': ' . wfMsg($efType) . ' - wikiHow');
         $wgOut->setPageTitle(wfMsg('app-name') . ': ' . wfMsg($efType) . ' - wikiHow');
     }
     $stats = new EditFinderStandingsIndividual($efType);
     $stats->addStatsWidget();
     $standings = new EditFinderStandingsGroup($efType);
     $standings->addStandingsWidget();
 }
Ejemplo n.º 2
0
 public function getUserCount()
 {
     $standings = new EditFinderStandingsIndividual('topic');
     $data = $standings->fetchStats();
     return $data['week'];
 }