function execute($par) { global $wgOut, $wgRequest, $wgUser, $wgParser; wfLoadExtensionMessages("TipsPatrol"); if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if ($wgUser->isAnon() || self::isBlockedFromTipsPatrol($wgUser)) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext'); return; } $this->skipTool = new ToolSkip("tiptool", "tipsandwarnings", "tw_checkout", "tw_checkout_user", "tw_id"); if ($wgRequest->wasPosted()) { $wgOut->disable(); $result = array(); $tipId = $wgRequest->getVal('tipId'); if ($wgRequest->getVal('coachTip')) { $this->coachResult($tipId, &$result); } elseif ($tipId != null && $wgRequest->getVal('skipTip')) { $this->logTip($tipId, self::TIP_ACTION_SKIP); $this->skipTool->skipItem($tipId); $this->skipTool->unUseItem($tipId); } elseif ($wgRequest->getVal('deleteTip')) { $articleId = $wgRequest->getVal('articleId'); $tip = $wgRequest->getVal('tip'); $this->deleteTip($tipId, $articleId, $tip); } elseif ($wgRequest->getVal('keepTip')) { //used to send to keepTip, but now we have an extra step: QG $articleId = $wgRequest->getVal('articleId'); $tip = $wgRequest->getVal('tip'); $this->logTip($tipId, self::TIP_ACTION_QG, '', $tip); $this->addToQG($tipId, $articleId, $tip, $result); } $this->getNextTip(&$result); echo json_encode($result); return; } $wgOut->setHTMLTitle(wfMsg('tipspatrol')); $wgOut->setPageTitle(wfMsg('tipspatrol')); $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('tipspatrol.css'), 'extensions/wikihow/tipsandwarnings', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('tipspatrol.js'), 'extensions/wikihow/tipsandwarnings', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('mousetrap.min.js,jquery.cookie.js'), 'extensions/wikihow/common', false)); EasyTemplate::set_path(dirname(__FILE__)); $vars = array(); $vars['tip_skip_title'] = wfMsg('tip_skip_title'); $vars['tip_keep_title'] = wfMsg('tip_keep_title'); $vars['tip_delete_title'] = wfMsg('tip_delete_title'); $wgOut->addHTML(EasyTemplate::html('TipsPatrol.tmpl.php', $vars)); $bubbleText = "Only publish this tip if you can make it helpful, clear, and grammatically correct. Most tips should get deleted."; InterfaceElements::addBubbleTipToElement('tip_tip', 'tptrl', $bubbleText); $this->displayLeaderboards(); }
/** * Execute special page. Only available to wikihow staff. */ public function execute() { global $wgUser, $wgRequest, $wgOut, $wgLang, $wgMemc; if (!$this->userAllowed()) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } if ($wgRequest->wasPosted()) { switch ($wgRequest->getVal('action')) { case 'nextUser': $this->nextUser(); break; case 'logMessage': $wgOut->disable(); $toId = $wgRequest->getVal('toId'); $revId = $wgRequest->getVal('revId'); $message = $wgRequest->getVal('message'); $this->logMessage($wgUser->getId(), $toId, $revId, $message); echo json_encode(array('stats' => $this->getStats())); break; case 'switchTab': $this->tabSwitch(); break; default: break; } return; } $target = $wgRequest->getVal('target'); if ($target) { $targetUser = User::newFromName($target); if ($targetUser->getId() > 0) { InterfaceElements::addJSVars($this->getOutputVariables($targetUser)); } } if (!$wgMemc->get($this->cacheOk)) { $this->resetCache(); } $wgOut->setPageTitle('Welcome Wagon'); $wgOut->setHTMLTitle('Welcome Wagon'); $tmpl = new EasyTemplate(dirname(__FILE__)); $wgOut->addHTML($tmpl->execute('WelcomeWagon.tmpl.php')); $wgOut->addCSScode('diffc'); $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('welcomewagon.css'), 'extensions/wikihow/WelcomeWagon', false)); $wgOut->addHTML(HtmlSnips::makeUrlTags('js', array('welcomewagon.js'), 'extensions/wikihow/WelcomeWagon', false)); InterfaceElements::addBubbleTipToElement('form-header', 'wwagon', 'No matter what happens keep the message positive and personalized.'); $this->displayLeaderboards(); }
function execute($par) { global $wgOut, $wgRequest, $wgUser, $wgParser, $wgDebugToolbar; $user = $this->getUser(); wfLoadExtensionMessages("TipsPatrol"); if ($user->isBlocked()) { $wgOut->blockedPage(); return; } if ($user->isAnon() || self::isBlockedFromTipsPatrol($user)) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } $this->skipTool = new ToolSkip("tiptool", "tipsandwarnings", "tw_checkout", "tw_checkout_user", "tw_id"); if ($wgRequest->wasPosted()) { $wgOut->disable(); $result = array(); try { $tipId = $wgRequest->getVal('tipId'); if ($wgRequest->getVal('coachTip')) { $tip = $wgRequest->getVal('tip'); $this->coachResult($tipId, $tip, &$result); } elseif ($tipId != null && $wgRequest->getVal('skipTip')) { $this->logTip($tipId, self::TIP_ACTION_SKIP); $this->skipTool->skipItem($tipId); $this->skipTool->unUseItem($tipId); } elseif ($wgRequest->getVal('deleteTip')) { $tip = $wgRequest->getVal('tip'); $this->logTip($tipId, self::TIP_ACTION_DELETE, $tip); $articleId = $wgRequest->getVal('articleId'); $this->deleteTip($tipId, $articleId, $tip); } elseif ($wgRequest->getVal('keepTip')) { $articleId = $wgRequest->getVal('articleId'); $tip = $wgRequest->getVal('tip'); $qcId = $this->addToQG($tipId, $articleId, $tip); $this->logTip($tipId, self::TIP_ACTION_KEEP, $tip, $qcId); $dbw = wfGetDB(DB_MASTER); $dbw->delete('tipsandwarnings', array('tw_id' => $tipId)); } $this->getNextTip(&$result); // if debug toolbark pass logs back in response if ($wgDebugToolbar) { $result['debug']['log'] = MWDebug::getLog(); } echo json_encode($result); } catch (MWException $e) { $result['error'][] = $e->getText(); echo json_encode($result); throw $e; } return; } $wgOut->setHTMLTitle(wfMessage('tipspatrol')->text()); $wgOut->setPageTitle(wfMessage('tipspatrol')->text()); $wgOut->addJSCode('mt'); // Mousetrap library $wgOut->addCSSCode('tpc'); // Tips Patrol CSS $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('tipspatrol.js'), 'extensions/wikihow/tipsandwarnings')); if ($wgDebugToolbar) { $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('consoledebug.js'), 'extensions/wikihow/debug', false)); } EasyTemplate::set_path(dirname(__FILE__)); $vars = array(); $vars['tip_skip_title'] = wfMessage('tip_skip_title')->text(); $vars['tip_keep_title'] = wfMessage('tip_keep_title')->text(); $vars['tip_delete_title'] = wfMessage('tip_delete_title')->text(); $wgOut->addHTML(EasyTemplate::html('TipsPatrol.tmpl.php', $vars)); $coach = $this->getRequest()->getVal("coach"); // code to init the tipspatrol javascript.. doing it here lets us pass in extra variables when we init $wgOut->addScript("<script>\$(document).ready(function(){WH.tipsPatrol.init({$coach})});</script>"); $bubbleText = "Only publish this tip if you can make it helpful, clear, and grammatically correct. Most tips should get deleted."; InterfaceElements::addBubbleTipToElement('tip_tip', 'tptrl', $bubbleText); $this->displayLeaderboards(); }
function execute($par) { global $wgDebugToolbar; $request = $this->getRequest(); $out = $this->getOutput(); $this->checkPermissions(); wfLoadExtensionMessages("UCIPatrol"); if ($request->getVal("stats")) { $out->disable(); $result = $this->getStats(); if ($request->getVal("format") == "json") { echo json_encode($result); return; } UCIPatrol::printStatsUploads($result['uploads']); UCIPatrol::printStatsTitles($result['titles']); return; } if ($request->wasPosted()) { $out->disable(); // wrapping it all in try catch to get any database errors try { $result = array(); if ($request->getVal('next')) { $result = $this->getNext(); } elseif ($request->getVal('skip')) { $this->skip(); } elseif ($request->getVal('bad')) { $this->downVote(); } elseif ($request->getVal('good')) { $this->upVote(); } elseif ($request->getVal('undo')) { $this->undo(); } elseif ($request->getVal('error')) { $this->error(); $result = $this->getNext(); } elseif ($request->getVal('resetskip')) { $this->resetSkip(); $result = $this->getNext(); } elseif ($request->getVal('flag')) { $this->flag(); $result = UCIPatrol::getImagesHTML($request->getVal('hostPage')); echo $result; return; } // if debug toolbar is active, pass logs back in json response if ($wgDebugToolbar) { $result['debug']['log'] = MWDebug::getLog(); } echo json_encode($result); } catch (MWException $e) { $result = $result ?: array(); $result['error'][] = $e->getText(); echo json_encode($result); throw $e; } } else { $out->setHTMLTitle(wfMessage('ucipatrol')->text()); $out->setPageTitle(wfMessage('ucipatrol')->text()); $out->addJSCode('mt'); // Mousetrap library $out->addCSSCode('ucipc'); // Tips Patrol CSS $out->addScript(HtmlSnips::makeUrlTags('js', array('ucipatrol.js'), 'extensions/wikihow/mobile/ucipatrol', false)); if ($wgDebugToolbar) { $out->addScript(HtmlSnips::makeUrlTags('js', array('consoledebug.js'), 'extensions/wikihow/debug', false)); } EasyTemplate::set_path(dirname(__FILE__)); $anon = $this->getUser()->isAnon(); $out->addHTML(EasyTemplate::html('UCIPatrol.tmpl.php', $vars)); $out->addScript("<script>\$(document).ready(function(){WH.uciPatrol.init({$anon})});</script>"); $bubbleText = "Help us pick the best user submitted photos to match the article."; InterfaceElements::addBubbleTipToElement('uci', 'ucitp', $bubbleText); $this->displayLeaderboards(); } }