Ejemplo n.º 1
0
 function execute($par)
 {
     global $wgRequest, $wgOut;
     $t = Title::newFromText($wgRequest->getVal('target'));
     $wgOut->setArticleBodyOnly(true);
     if ($wgRequest->getVal('action') == 'permalink') {
         $result = array();
         $result['title'] = $t;
         $result['rchi'] = $wgRequest->getVal('rchi');
         $result['rclo'] = $wgRequest->getVal('rclow');
         $result['rcid'] = $wgRequest->getVal('rcid');
         $result['old'] = $wgRequest->getVal('old');
         $result['new'] = $wgRequest->getVal('new');
         $result['vandal'] = $wgRequest->getVal('vandal');
         $result['rc_cur_id'] = $t->getArticleID();
         $result = RCPatrolData::getListofEditors($result);
         $wgOut->addHTML("<div id='articletitle' style='display:none;'><a href='{$t->getLocalURL()}'>{$t->getFullText()}</a></div>");
         $oldTitle = $this->getContext()->getTitle();
         $this->getContext()->setTitle($result['title']);
         $d = new DifferenceEngine($this->getContext(), RCPatrol::cleanOldId($wgRequest->getVal('old')), $wgRequest->getVal('new'), $wgRequest->getVal('rcid'));
         $d->loadRevisionData();
         $this->getContext()->setTitle($oldTitle);
         $wgOut->addHTML("<div id='rc_header' class='tool_header'>");
         $wgOut->addHTML('<a href="#" id="rcpatrol_keys">Get Shortcuts</a>');
         $wgOut->addHTML(RCPatrol::getButtons($result, $d->mNewRev));
         $wgOut->addHTML("</div>");
         $wgOut->addHTML('<div id="rcpatrol_info" style="display:none;">' . wfMessage('rcpatrol_keys')->text() . '</div>');
         $d->showDiffPage();
         $wgOut->disable();
         $response['html'] = $wgOut->getHTML();
         print_r(json_encode($response));
         return;
     }
     $a = new Article($t);
     if (!$wgRequest->getVal('grabnext')) {
         if (class_exists('RCTest') && RCTest::isEnabled() && $wgRequest->getVal('rctest')) {
             // Don't do anything if it's a test
         } elseif (!$wgRequest->getVal('skip') && $wgRequest->getVal('action') == 'markpatrolled') {
             $this->markRevisionsPatrolled($a);
         } elseif ($wgRequest->getVal('skip')) {
             // skip the article for now
             RCPatrol::skipArticle($t->getArticleID());
         }
     }
     $wgOut->clearHTML();
     $wgOut->redirect('');
     $result = RCPatrol::getNextArticleToPatrol($wgRequest->getVal('rcid'));
     $response = array();
     if ($result) {
         $rcTest = null;
         $testHtml = "";
         if (class_exists('RCTest') && RCTest::isEnabled()) {
             $rcTest = new RCTest();
             $testHtml = $rcTest->getTestHtml();
             /* Uncomment to debug rctest
             			$response['testtime'] = $rcTest->isTestTime() ? 1 : 0;
             			$response['totpatrol'] = $rcTest->getTotalPatrols();
             			$response['adjpatrol'] = $rcTest->getAdjustedPatrolCount();
             			global $wgCookiePrefix;
             			$response['testcookie'] = $_COOKIE[$wgCookiePrefix . '_rct_a'];
             			*/
         }
         $t = $result['title'];
         $wgOut->addHTML("<div id='bodycontents2'>");
         $titleText = RCTestStub::getTitleText($result, $rcTest);
         $wgOut->addHTML("<div id='articletitle' style='display:none;'>{$titleText}</div>");
         // Initialize the RCTest object. This is use to inject
         // tests into the RC Patrol queue.
         $d = RCTestStub::getDifferenceEngine($this->getContext(), $result, $rcTest);
         $d->loadRevisionData();
         $wgOut->addHTML("<div id='rc_header' class='tool_header'>");
         $wgOut->addHTML('<a href="#" id="rcpatrol_keys">Get Shortcuts</a>');
         $wgOut->addHTML(RCPatrol::getButtons($result, $d->mNewRev, $rcTest));
         $wgOut->addHTML("</div>");
         $wgOut->addHTML('<div id="rcpatrol_info" style="display:none;">' . wfMessage('rcpatrol_keys')->text() . '</div>');
         $d->showDiffPage();
         $wgOut->addHtml($testHtml);
         $wgOut->addHTML("</div>");
         $response['unpatrolled'] = self::getUnpatrolledCount();
     } else {
         $wgOut->addWikiMsg('markedaspatrolledtext');
         $response['unpatrolled'] = self::getUnpatrolledCount();
     }
     $wgOut->disable();
     header('Vary: Cookie');
     $response['html'] = $wgOut->getHTML();
     print_r(json_encode($response));
     return;
 }