public function writeBunchPatrolTableContent(&$dbr, $target, $readOnly) { global $wgOut, $wgUser; $wgOut->addHTML("<table width='100%' align='center' class='bunchtable'><tr>"); if (!$readOnly) { $wgOut->addHTML("<td><b>Patrol?</b></td>"); } $wgOut->addHTML("<td align='center'><b>Diff</b></td></tr>"); $opts = array('rc_user_text' => $target, 'rc_patrolled=0'); $opts[] = ' (rc_namespace = 2 OR rc_namespace = 3) '; $res = $dbr->select('recentchanges', array('rc_id', 'rc_title', 'rc_namespace', 'rc_this_oldid', 'rc_cur_id', 'rc_last_oldid'), $opts, "wfSpecialBunchpatrol", array('LIMIT' => 15)); $count = 0; while (($row = $dbr->fetchObject($res)) != null) { $t = Title::makeTitle($row->rc_namespace, $row->rc_title); $diff = $row->rc_this_oldid; $rcid = $row->rc_id; $oldid = $row->rc_last_oldid; $de = new DifferenceEngine($t, $oldid, $diff, $rcid); $wgOut->addHTML("<tr>"); if (!$readOnly) { $wgOut->addHTML("<td valign='middle' style='padding-right:24px; border-right: 1px solid #eee;'><input type='checkbox' name='rc_{$rcid}'></td>"); } $wgOut->addHTML("<td style='border-top: 1px solid #eee;'>"); $wgOut->addHTML($wgUser->getSkin()->makeLinkObj($t)); $de->showDiffPage(true); $wgOut->addHTML("</td></tr>"); $count++; } $dbr->freeResult($res); $wgOut->addHTML("</table><br/><br/>"); return $count; }
public static function showDiff($data, HTMLForm $form) { $rev1 = self::revOrTitle($data['Revision1'], $data['Page1']); $rev2 = self::revOrTitle($data['Revision2'], $data['Page2']); if ($rev1 && $rev2) { $de = new DifferenceEngine($form->getContext(), $rev1, $rev2, null, $data['Action'] == 'purge', $data['Unhide'] == '1'); $de->showDiffPage(true); } }
public static function showDiff($data) { $rev1 = self::revOrTitle($data['Revision1'], $data['Page1']); $rev2 = self::revOrTitle($data['Revision2'], $data['Page2']); if ($rev1 && $rev2) { $de = new DifferenceEngine(null, $rev1, $rev2, null, $data["Action"] == 'purge', false); $de->showDiffPage(true); } }
public function writeDiff(&$dbr, $target) { global $wgOut, $wgUser; $wgOut->addHTML("<table width='100%' align='center' class='bunchtable'><tr>"); $opts = array('rc_user_text' => $target); $opts[] = ' (rc_namespace = 0) '; $res = $dbr->select('recentchanges', array('rc_id', 'rc_title', 'rc_namespace', 'rc_this_oldid', 'rc_cur_id', 'rc_last_oldid'), $opts, __METHOD__, array('LIMIT' => 15)); $count = 0; foreach ($res as $row) { $t = Title::makeTitle($row->rc_namespace, $row->rc_title); $diff = $row->rc_this_oldid; $rcid = $row->rc_id; $oldid = $row->rc_last_oldid; $de = new DifferenceEngine($t, $oldid, $diff, $rcid); $wgOut->addHTML("<tr>"); $wgOut->addHTML("<td>"); $wgOut->addHTML($wgUser->getSkin()->makeLinkObj($t)); $de->showDiffPage(true); $wgOut->addHTML("</td></tr>"); $count++; } $dbr->freeResult($res); $wgOut->addHTML("</table><br/><br/>"); return $count; }
/** * Show a diff page according to current request variables. For use within * Article::view() only, other callers should use the DifferenceEngine class. */ public function showDiffPage() { global $wgRequest, $wgUser; $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly')); $purge = $wgRequest->getVal('action') == 'purge'; $unhide = $wgRequest->getInt('unhide') == 1; $oldid = $this->getOldID(); $de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid, $purge, $unhide); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage($diffOnly); // Needed to get the page's current revision $this->loadPageData(); if ($diff == 0 || $diff == $this->mLatest) { # Run view updates for current revision only $this->viewUpdates(); } }
/** * This is the default action of the script: just view the page of * the given title. */ function view() { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser; global $wgUseTrackbacks, $wgNamespaceRobotPolicies; $sk = $wgUser->getSkin(); wfProfileIn(__METHOD__); $parserCache =& ParserCache::singleton(); $ns = $this->mTitle->getNamespace(); # shortcut # Get variables from query string $oldid = $this->getOldID(); # getOldID may want us to redirect somewhere else if ($this->mRedirectUrl) { $wgOut->redirect($this->mRedirectUrl); wfProfileOut(__METHOD__); return; } $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $rdfrom = $wgRequest->getVal('rdfrom'); $wgOut->setArticleFlag(true); if (isset($wgNamespaceRobotPolicies[$ns])) { $policy = $wgNamespaceRobotPolicies[$ns]; } else { # The default policy. Dev note: make sure you change the documentation # in DefaultSettings.php before changing it. $policy = 'index,follow'; } $wgOut->setRobotpolicy($policy); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. if (!is_null($diff)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage(); // Needed to get the page's current revision $this->loadPageData(); if ($diff == 0 || $diff == $this->mLatest) { # Run view updates for current revision only $this->viewUpdates(); } wfProfileOut(__METHOD__); return; } if (empty($oldid) && $this->checkTouched()) { $wgOut->setETag($parserCache->getETag($this, $wgUser)); if ($wgOut->checkLastModified($this->mTouched)) { wfProfileOut(__METHOD__); return; } else { if ($this->tryFileCache()) { # tell wgOut that output is taken care of $wgOut->disable(); $this->viewUpdates(); wfProfileOut(__METHOD__); return; } } } # Should the parser cache be used? $pcache = $wgEnableParserCache && intval($wgUser->getOption('stubthreshold')) == 0 && $this->exists() && empty($oldid); wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n"); if ($wgUser->getOption('stubthreshold')) { wfIncrStats('pcache_miss_stub'); } $wasRedirected = false; if (isset($this->mRedirectedFrom)) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. if (wfRunHooks('ArticleViewRedirect', array(&$this))) { $sk = $wgUser->getSkin(); $redir = $sk->makeKnownLinkObj($this->mRedirectedFrom, '', 'redirect=no'); $s = wfMsg('redirectedfrom', $redir); $wgOut->setSubtitle($s); // Set the fragment if one was specified in the redirect if (strval($this->mTitle->getFragment()) != '') { $fragment = Xml::escapeJsString($this->mTitle->getFragmentForURL()); $wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");"); } $wasRedirected = true; } } elseif (!empty($rdfrom)) { // This is an externally redirected view, from some other wiki. // If it was reported from a trusted site, supply a backlink. global $wgRedirectSources; if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) { $sk = $wgUser->getSkin(); $redir = $sk->makeExternalLink($rdfrom, $rdfrom); $s = wfMsg('redirectedfrom', $redir); $wgOut->setSubtitle($s); $wasRedirected = true; } } $outputDone = false; if ($pcache) { if ($wgOut->tryParserCache($this, $wgUser)) { wfRunHooks('ArticleViewHeader', array(&$this)); $outputDone = true; } } if (!$outputDone) { $text = $this->getContent(); if ($text === false) { # Failed to load, replace text with error message $t = $this->mTitle->getPrefixedText(); if ($oldid) { $t .= ',oldid=' . $oldid; $text = wfMsg('missingarticle', $t); } else { $text = wfMsg('noarticletext', $t); } } # Another whitelist check in case oldid is altering the title if (!$this->mTitle->userCanRead()) { $wgOut->loginToUse(); $wgOut->output(); exit; } # We're looking at an old revision if (!empty($oldid)) { $wgOut->setRobotpolicy('noindex,nofollow'); if (is_null($this->mRevision)) { // FIXME: This would be a nice place to load the 'no such page' text. } else { $this->setOldSubtitle(isset($this->mOldId) ? $this->mOldId : $oldid); if ($this->mRevision->isDeleted(Revision::DELETED_TEXT)) { if (!$this->mRevision->userCan(Revision::DELETED_TEXT)) { $wgOut->addWikiText(wfMsg('rev-deleted-text-permission')); $wgOut->setPageTitle($this->mTitle->getPrefixedText()); return; } else { $wgOut->addWikiText(wfMsg('rev-deleted-text-view')); // and we are allowed to see... } } } } } if (!$outputDone) { /** * @fixme: this hook doesn't work most of the time, as it doesn't * trigger when the parser cache is used. */ wfRunHooks('ArticleViewHeader', array(&$this)); $wgOut->setRevisionId($this->getRevIdFetched()); # wrap user css and user js in pre and don't parse # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found if ($ns == NS_USER && preg_match('/\\/[\\w]+\\.(css|js)$/', $this->mTitle->getDBkey())) { $wgOut->addWikiText(wfMsg('clearyourcache')); $wgOut->addHTML('<pre>' . htmlspecialchars($this->mContent) . "\n</pre>"); } else { if ($rt = Title::newFromRedirect($text)) { # Display redirect $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png'; # Don't overwrite the subtitle if this was an old revision if (!$wasRedirected && $this->isCurrent()) { $wgOut->setSubtitle(wfMsgHtml('redirectpagesub')); } $link = $sk->makeLinkObj($rt, $rt->getFullText()); $wgOut->addHTML('<img src="' . $imageUrl . '" alt="#REDIRECT " />' . '<span class="redirectText">' . $link . '</span>'); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText($parseout); } else { if ($pcache) { # Display content and save to parser cache $wgOut->addPrimaryWikiText($text, $this); } else { # Display content, don't attempt to save to parser cache # Don't show section-edit links on old revisions... this way lies madness. if (!$this->isCurrent()) { $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false); } # Display content and don't save to parser cache $wgOut->addPrimaryWikiText($text, $this, false); if (!$this->isCurrent()) { $wgOut->parserOptions()->setEditSection($oldEditSectionSetting); } } } } } /* title may have been set from the cache */ $t = $wgOut->getPageTitle(); if (empty($t)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); } # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if ($ns == NS_USER_TALK && User::isIP($this->mTitle->getText())) { $wgOut->addWikiText(wfMsg('anontalkpagetext')); } # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if ($wgUseRCPatrol && !is_null($rcid) && $rcid != 0 && $wgUser->isAllowed('patrol')) { $wgOut->addHTML("<div class='patrollink'>" . wfMsg('markaspatrolledlink', $sk->makeKnownLinkObj($this->mTitle, wfMsg('markaspatrolledtext'), "action=markpatrolled&rcid={$rcid}")) . '</div>'); } # Trackbacks if ($wgUseTrackbacks) { $this->addTrackbacks(); } $this->viewUpdates(); wfProfileOut(__METHOD__); }
/** * Show a form for filtering namespace and username * * @param $par String * @return String */ public function execute($par) { $this->setHeaders(); $this->outputHeader(); $this->setup($par); // Settings $this->form(); if ($this->opts->getValue('rev1') && $this->opts->getValue('rev2')) { $de = new DifferenceEngine(null, $this->opts->getValue('rev1'), $this->opts->getValue('rev2'), null, $this->opts->getValue('action') == 'purge', false); $de->showDiffPage(true); } }
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; }
/** * Show a diff page according to current request variables. For use within * Article::view() only, other callers should use the DifferenceEngine class. */ public function showDiffPage() { global $wgRequest, $wgUser; $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getGlobalPreference('diffonly')); $purge = $wgRequest->getVal('action') == 'purge'; $unhide = $wgRequest->getInt('unhide') == 1; $oldid = $this->getOldID(); $de = new DifferenceEngine($this->getContext(), $oldid, $diff, $rcid, $purge, $unhide); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage($diffOnly); if ($diff == 0 || $diff == $this->mPage->getLatest()) { # Run view updates for current revision only $this->mPage->doViewUpdates($wgUser); } }
/** * This is the default action of the script: just view the page of * the given title. */ function view() { global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgLang; global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol; global $wgParser, $wgParserCache, $wgUseTrackbacks; $sk = $wgUser->getSkin(); $fname = 'Article::view'; wfProfileIn($fname); # Get variables from query string $oldid = $this->getOldID(); $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $rdfrom = $wgRequest->getVal('rdfrom'); $wgOut->setArticleFlag(true); $wgOut->setRobotpolicy('index,follow'); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. if (!is_null($diff)) { require_once 'DifferenceEngine.php'; $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $de = new DifferenceEngine($oldid, $diff, $rcid); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage(); if ($diff == 0) { # Run view updates for current revision only $this->viewUpdates(); } wfProfileOut($fname); return; } if (empty($oldid) && $this->checkTouched()) { $wgOut->setETag($wgParserCache->getETag($this, $wgUser)); if ($wgOut->checkLastModified($this->mTouched)) { wfProfileOut($fname); return; } else { if ($this->tryFileCache()) { # tell wgOut that output is taken care of $wgOut->disable(); $this->viewUpdates(); wfProfileOut($fname); return; } } } # Should the parser cache be used? $pcache = $wgEnableParserCache && intval($wgUser->getOption('stubthreshold')) == 0 && $this->exists() && empty($oldid); wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n"); $outputDone = false; if ($pcache) { if ($wgOut->tryParserCache($this, $wgUser)) { $outputDone = true; } } if (!$outputDone) { $text = $this->getContent(false); # May change mTitle by following a redirect # Another whitelist check in case oldid or redirects are altering the title if (!$this->mTitle->userCanRead()) { $wgOut->loginToUse(); $wgOut->output(); exit; } # We're looking at an old revision if (!empty($oldid)) { $this->setOldSubtitle(isset($this->mOldId) ? $this->mOldId : $oldid); $wgOut->setRobotpolicy('noindex,follow'); } if ('' != $this->mRedirectedFrom) { $sk = $wgUser->getSkin(); $redir = $sk->makeKnownLink($this->mRedirectedFrom, '', 'redirect=no'); $s = wfMsg('redirectedfrom', $redir); $wgOut->setSubtitle($s); # Can't cache redirects $pcache = false; } elseif (!empty($rdfrom)) { global $wgRedirectSources; if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) { $sk = $wgUser->getSkin(); $redir = $sk->makeExternalLink($rdfrom, $rdfrom); $s = wfMsg('redirectedfrom', $redir); $wgOut->setSubtitle($s); } } # wrap user css and user js in pre and don't parse # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found if ($this->mTitle->getNamespace() == NS_USER && preg_match('/\\/[\\w]+\\.(css|js)$/', $this->mTitle->getDBkey())) { $wgOut->addWikiText(wfMsg('clearyourcache')); $wgOut->addHTML('<pre>' . htmlspecialchars($this->mContent) . "\n</pre>"); } else { if ($rt = Title::newFromRedirect($text)) { # Display redirect $imageUrl = $wgStylePath . '/common/images/redirect.png'; $targetUrl = $rt->escapeLocalURL(); $titleText = htmlspecialchars($rt->getPrefixedText()); $link = $sk->makeLinkObj($rt); $wgOut->addHTML('<img valign="center" src="' . $imageUrl . '" alt="#REDIRECT" />' . '<span class="redirectText">' . $link . '</span>'); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $catlinks = $parseout->getCategoryLinks(); $wgOut->addCategoryLinks($catlinks); $skin = $wgUser->getSkin(); } else { if ($pcache) { # Display content and save to parser cache $wgOut->addPrimaryWikiText($text, $this); } else { # Display content, don't attempt to save to parser cache # Don't show section-edit links on old revisions... this way lies madness. if (!$this->isCurrent()) { $oldEditSectionSetting = $wgOut->mParserOptions->setEditSection(false); } $wgOut->addWikiText($text); if (!$this->isCurrent()) { $wgOut->mParserOptions->setEditSection($oldEditSectionSetting); } } } } } /* title may have been set from the cache */ $t = $wgOut->getPageTitle(); if (empty($t)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); } # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if ($wgUseRCPatrol && !is_null($rcid) && $rcid != 0 && $wgUser->isLoggedIn() && ($wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol)) { $wgOut->addHTML("<div class='patrollink'>" . wfMsg('markaspatrolledlink', $sk->makeKnownLinkObj($this->mTitle, wfMsg('markaspatrolledtext'), "action=markpatrolled&rcid={$rcid}")) . '</div>'); } # Trackbacks if ($wgUseTrackbacks) { $this->addTrackbacks(); } # Put link titles into the link cache $wgOut->transformBuffer(); # Add link titles as META keywords $wgOut->addMetaTags(); $this->viewUpdates(); wfProfileOut($fname); }
/** * This is the default action of the script: just view the page of * the given title. */ public function view() { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgParser; global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies; global $wgDefaultRobotPolicy; wfProfileIn(__METHOD__); # Get variables from query string $oldid = $this->getOldID(); # Try file cache if ($oldid === 0 && $this->checkTouched()) { global $wgUseETag; if ($wgUseETag) { $parserCache = ParserCache::singleton(); $wgOut->setETag($parserCache->getETag($this, $wgUser)); } if ($wgOut->checkLastModified($this->getTouched())) { wfProfileOut(__METHOD__); return; } else { if ($this->tryFileCache()) { # tell wgOut that output is taken care of $wgOut->disable(); $this->viewUpdates(); wfProfileOut(__METHOD__); return; } } } $ns = $this->mTitle->getNamespace(); # shortcut $sk = $wgUser->getSkin(); # getOldID may want us to redirect somewhere else if ($this->mRedirectUrl) { $wgOut->redirect($this->mRedirectUrl); wfProfileOut(__METHOD__); return; } $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $rdfrom = $wgRequest->getVal('rdfrom'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly')); $purge = $wgRequest->getVal('action') == 'purge'; $return404 = false; $wgOut->setArticleFlag(true); # Discourage indexing of printable versions, but encourage following if ($wgOut->isPrintable()) { $policy = 'noindex,follow'; } elseif (isset($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])) { $policy = $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()]; } elseif (isset($wgNamespaceRobotPolicies[$ns])) { # Honour customised robot policies for this namespace $policy = $wgNamespaceRobotPolicies[$ns]; } else { $policy = $wgDefaultRobotPolicy; } $wgOut->setRobotPolicy($policy); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. if (!is_null($diff)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $diff = $wgRequest->getVal('diff'); $htmldiff = $wgRequest->getVal('htmldiff', false); $de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage($diffOnly); // Needed to get the page's current revision $this->loadPageData(); if ($diff == 0 || $diff == $this->mLatest) { # Run view updates for current revision only $this->viewUpdates(); } wfProfileOut(__METHOD__); return; } # Should the parser cache be used? $pcache = $this->useParserCache($oldid); wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n"); if ($wgUser->getOption('stubthreshold')) { wfIncrStats('pcache_miss_stub'); } $wasRedirected = false; if (isset($this->mRedirectedFrom)) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. if (wfRunHooks('ArticleViewRedirect', array(&$this))) { $redir = $sk->makeKnownLinkObj($this->mRedirectedFrom, '', 'redirect=no'); $s = wfMsgExt('redirectedfrom', array('parseinline', 'replaceafter'), $redir); $wgOut->setSubtitle($s); // Set the fragment if one was specified in the redirect if (strval($this->mTitle->getFragment()) != '') { $fragment = Xml::escapeJsString($this->mTitle->getFragmentForURL()); $wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");"); } $wasRedirected = true; } } elseif (!empty($rdfrom)) { // This is an externally redirected view, from some other wiki. // If it was reported from a trusted site, supply a backlink. global $wgRedirectSources; if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) { $redir = $sk->makeExternalLink($rdfrom, $rdfrom); $s = wfMsgExt('redirectedfrom', array('parseinline', 'replaceafter'), $redir); $wgOut->setSubtitle($s); $wasRedirected = true; } } $outputDone = false; wfRunHooks('ArticleViewHeader', array(&$this, &$outputDone, &$pcache)); if ($pcache && $wgOut->tryParserCache($this, $wgUser)) { // Ensure that UI elements requiring revision ID have // the correct version information. $wgOut->setRevisionId($this->mLatest); $outputDone = true; } # Fetch content and check for errors if (!$outputDone) { # If the article does not exist and was deleted, show the log if ($this->getID() == 0) { $this->showDeletionLog(); } $text = $this->getContent(); if ($text === false) { # Failed to load, replace text with error message $t = $this->mTitle->getPrefixedText(); if ($oldid) { $d = wfMsgExt('missingarticle-rev', array('escape'), $oldid); $text = wfMsg('missing-article', $t, $d); } else { $text = wfMsg('noarticletext'); } } # Non-existent pages if ($this->getID() === 0) { $wgOut->setRobotPolicy('noindex,nofollow'); $text = "<div class='noarticletext'>\n{$text}\n</div>"; if (!$this->hasViewableContent()) { // If there's no backing content, send a 404 Not Found // for better machine handling of broken links. $return404 = true; } } if ($return404) { $wgRequest->response()->header("HTTP/1.x 404 Not Found"); } # Another whitelist check in case oldid is altering the title if (!$this->mTitle->userCanRead()) { $wgOut->loginToUse(); $wgOut->output(); $wgOut->disable(); wfProfileOut(__METHOD__); return; } # For ?curid=x urls, disallow indexing if ($wgRequest->getInt('curid')) { $wgOut->setRobotPolicy('noindex,follow'); } # We're looking at an old revision if (!empty($oldid)) { $wgOut->setRobotPolicy('noindex,nofollow'); if (is_null($this->mRevision)) { // FIXME: This would be a nice place to load the 'no such page' text. } else { $this->setOldSubtitle(isset($this->mOldId) ? $this->mOldId : $oldid); if ($this->mRevision->isDeleted(Revision::DELETED_TEXT)) { if (!$this->mRevision->userCan(Revision::DELETED_TEXT)) { $wgOut->addWikiMsg('rev-deleted-text-permission'); $wgOut->setPageTitle($this->mTitle->getPrefixedText()); wfProfileOut(__METHOD__); return; } else { $wgOut->addWikiMsg('rev-deleted-text-view'); // and we are allowed to see... } } } } $wgOut->setRevisionId($this->getRevIdFetched()); // Pages containing custom CSS or JavaScript get special treatment if ($this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage()) { $wgOut->addHTML(wfMsgExt('clearyourcache', 'parse')); // Give hooks a chance to customise the output if (wfRunHooks('ShowRawCssJs', array($this->mContent, $this->mTitle, $wgOut))) { // Wrap the whole lot in a <pre> and don't parse $m = array(); preg_match('!\\.(css|js)$!u', $this->mTitle->getText(), $m); $wgOut->addHTML("<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n"); $wgOut->addHTML(htmlspecialchars($this->mContent)); $wgOut->addHTML("\n</pre>\n"); } } else { if ($rt = Title::newFromRedirect($text)) { # Don't append the subtitle if this was an old revision $wgOut->addHTML($this->viewRedirect($rt, !$wasRedirected && $this->isCurrent())); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText($parseout); } else { if ($pcache) { # Display content and save to parser cache $this->outputWikiText($text); } else { # Display content, don't attempt to save to parser cache # Don't show section-edit links on old revisions... this way lies madness. if (!$this->isCurrent()) { $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false); } # Display content and don't save to parser cache # With timing hack -- TS 2006-07-26 $time = -wfTime(); $this->outputWikiText($text, false); $time += wfTime(); # Timing hack if ($time > 3) { wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->mTitle->getPrefixedDBkey())); } if (!$this->isCurrent()) { $wgOut->parserOptions()->setEditSection($oldEditSectionSetting); } } } } } /* title may have been set from the cache */ $t = $wgOut->getPageTitle(); if (empty($t)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); # For the main page, overwrite the <title> element with the con- # tents of 'pagetitle-view-mainpage' instead of the default (if # that's not empty). if ($this->mTitle->equals(Title::newMainPage()) && wfMsgForContent('pagetitle-view-mainpage') !== '') { $wgOut->setHTMLTitle(wfMsgForContent('pagetitle-view-mainpage')); } } # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if ($ns == NS_USER_TALK && IP::isValid($this->mTitle->getText())) { $wgOut->addWikiMsg('anontalkpagetext'); } # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if (!empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol')) { $wgOut->addHTML("<div class='patrollink'>" . wfMsgHtml('markaspatrolledlink', $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('markaspatrolledtext'), "action=markpatrolled&rcid={$rcid}")) . '</div>'); } # Trackbacks if ($wgUseTrackbacks) { $this->addTrackbacks(); } $this->viewUpdates(); wfProfileOut(__METHOD__); }
function getNextToPatrolHTML() { global $wgOut; if (!$this->mResult) { // nothing to patrol return null; } // construct the HTML to reply // load the page $t = $this->mTitle; // Title::newFromID($this->mResult->qc_page); if (!$t) { $this->deleteBad($this->mResult->qc_page); return "<!--{$this->mResult->qc_page}-->error creating title, oops, please <a href='#' onclick='window.location.reload()'>refresh</a>"; } // get current revsion $r = Revision::newFromTitle($t); if (!$r) { return "Error creating revision"; } $d = new DifferenceEngine($t, $this->mResult->qc_old_rev_id, $this->mResult->qc_rev_id); $d->loadRevisionData(); // interesting $html = ""; $changedby = self::getChangedBy("Edits patrolled by: "); $wgOut->clearHTML(); $d->showDiffPage(true); $html = "<div id='qc_box'>" . $changedby . $html . $wgOut->getHTML() . "</div>"; $wgOut->clearHTML(); $html .= "<div id='quickeditlink'></div>"; $popts = $wgOut->parserOptions(); $popts->setTidy(true); $html .= WikihowArticleHTML::processArticleHTML($wgOut->parse($r->getText(), $t, $popts), array('no-ads' => 1, 'ns' => $t->getNamespace())); $html .= "<input type='hidden' name='qc_id' value='{$this->mResult->qc_id}'/>"; $html .= "<div id='numqcusers'>{$this->mUsers}</div>"; return $html; }
/** * This is the default action of the script: just view the page of * the given title. */ function view() { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgParser; global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies; global $wgDefaultRobotPolicy; $sk = $wgUser->getSkin(); wfProfileIn(__METHOD__); $parserCache =& ParserCache::singleton(); $ns = $this->mTitle->getNamespace(); # shortcut # Get variables from query string $oldid = $this->getOldID(); # getOldID may want us to redirect somewhere else if ($this->mRedirectUrl) { $wgOut->redirect($this->mRedirectUrl); wfProfileOut(__METHOD__); return; } $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $rdfrom = $wgRequest->getVal('rdfrom'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly')); $purge = $wgRequest->getVal('action') == 'purge'; $wgOut->setArticleFlag(true); # Discourage indexing of printable versions, but encourage following if ($wgOut->isPrintable()) { $policy = 'noindex,follow'; } elseif (isset($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])) { $policy = $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()]; } elseif (isset($wgNamespaceRobotPolicies[$ns])) { # Honour customised robot policies for this namespace $policy = $wgNamespaceRobotPolicies[$ns]; } else { $policy = $wgDefaultRobotPolicy; } // XXX: take out user talk pages and user profile box pages if ($this->mTitle->getNamespace() == NS_USER_TALK || $this->mTitle->getNamespace() == NS_USER && preg_match("@profilebox@", $this->mTitle->getText())) { $policy = "noindex,follow"; } $wgOut->setRobotPolicy($policy); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. if (!is_null($diff)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid, $purge); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage($diffOnly); // Needed to get the page's current revision $this->loadPageData(); if ($diff == 0 || $diff == $this->mLatest) { # Run view updates for current revision only $this->viewUpdates(); } wfProfileOut(__METHOD__); return; } if (empty($oldid) && $this->checkTouched()) { $wgOut->setETag($parserCache->getETag($this, $wgUser)); if ($wgOut->checkLastModified($this->mTouched)) { wfProfileOut(__METHOD__); return; } else { if ($this->tryFileCache()) { # tell wgOut that output is taken care of $wgOut->disable(); $this->viewUpdates(); wfProfileOut(__METHOD__); return; } } } # Should the parser cache be used? $pcache = $wgEnableParserCache && intval($wgUser->getOption('stubthreshold')) == 0 && $this->exists() && empty($oldid) && !$this->mTitle->isCssOrJsPage() && !$this->mTitle->isCssJsSubpage(); wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n"); if ($wgUser->getOption('stubthreshold')) { wfIncrStats('pcache_miss_stub'); } $wasRedirected = false; if (isset($this->mRedirectedFrom)) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. if (wfRunHooks('ArticleViewRedirect', array(&$this))) { $sk = $wgUser->getSkin(); $redir = $sk->makeKnownLinkObj($this->mRedirectedFrom, '', 'redirect=no'); $s = wfMsg('redirectedfrom', $redir); $wgOut->setSubtitle($s); // Set the fragment if one was specified in the redirect if (strval($this->mTitle->getFragment()) != '') { $fragment = Xml::escapeJsString($this->mTitle->getFragmentForURL()); $wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");"); } $wasRedirected = true; } } elseif (!empty($rdfrom)) { // This is an externally redirected view, from some other wiki. // If it was reported from a trusted site, supply a backlink. global $wgRedirectSources; if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) { $sk = $wgUser->getSkin(); $redir = $sk->makeExternalLink($rdfrom, $rdfrom); $s = wfMsg('redirectedfrom', $redir); $wgOut->setSubtitle($s); $wasRedirected = true; } } $outputDone = false; wfRunHooks('ArticleViewHeader', array(&$this, &$outputDone, &$pcache)); if ($pcache) { if ($wgOut->tryParserCache($this, $wgUser)) { // Ensure that UI elements requiring revision ID have // the correct version information. $wgOut->setRevisionId($this->mLatest); $outputDone = true; } } if (!$outputDone) { $text = $this->getContent(); if ($text === false) { # Failed to load, replace text with error message $t = $this->mTitle->getPrefixedText(); if ($oldid) { $t .= ',oldid=' . $oldid; $text = wfMsg('missingarticle', $t); } else { $text = wfMsg('noarticletext', $t); } } # Another whitelist check in case oldid is altering the title if (!$this->mTitle->userCanRead()) { $wgOut->loginToUse(); $wgOut->output(); exit; } # We're looking at an old revision if (!empty($oldid)) { // XXCHANGED: reuben- needed this change // because of "patrolled good revision" feature. // RobotsPolicy class handles this now //$wgOut->setRobotpolicy( 'noindex,nofollow' ); if (is_null($this->mRevision)) { // FIXME: This would be a nice place to load the 'no such page' text. } else { $this->setOldSubtitle(isset($this->mOldId) ? $this->mOldId : $oldid); if ($this->mRevision->isDeleted(Revision::DELETED_TEXT)) { if (!$this->mRevision->userCan(Revision::DELETED_TEXT)) { $wgOut->addWikiMsg('rev-deleted-text-permission'); $wgOut->setPageTitle($this->mTitle->getPrefixedText()); return; } else { $wgOut->addWikiMsg('rev-deleted-text-view'); // and we are allowed to see... } } } } } if (!$outputDone) { $wgOut->setRevisionId($this->getRevIdFetched()); // Pages containing custom CSS or JavaScript get special treatment if ($this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage()) { $wgOut->addHtml(wfMsgExt('clearyourcache', 'parse')); // Give hooks a chance to customise the output if (wfRunHooks('ShowRawCssJs', array($this->mContent, $this->mTitle, $wgOut))) { // Wrap the whole lot in a <pre> and don't parse $m = array(); preg_match('!\\.(css|js)$!u', $this->mTitle->getText(), $m); $wgOut->addHtml("<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n"); $wgOut->addHtml(htmlspecialchars($this->mContent)); $wgOut->addHtml("\n</pre>\n"); } } elseif ($rt = Title::newFromRedirect($text)) { # Display redirect $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png'; # Don't overwrite the subtitle if this was an old revision if (!$wasRedirected && $this->isCurrent()) { $wgOut->setSubtitle(wfMsgHtml('redirectpagesub')); } $link = $sk->makeLinkObj($rt, $rt->getFullText()); $wgOut->addHTML('<img src="' . $imageUrl . '" alt="#REDIRECT " />' . '<span class="redirectText">' . $link . '</span>'); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText($parseout); } else { if ($pcache) { # Display content and save to parser cache $this->outputWikiText($text); } else { # Display content, don't attempt to save to parser cache # Don't show section-edit links on old revisions... this way lies madness. if (!$this->isCurrent()) { $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false); } # Display content and don't save to parser cache # With timing hack -- TS 2006-07-26 $time = -wfTime(); $this->outputWikiText($text, false); $time += wfTime(); # Timing hack if ($time > 3) { wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->mTitle->getPrefixedDBkey())); } if (!$this->isCurrent()) { $wgOut->parserOptions()->setEditSection($oldEditSectionSetting); } } } } /* title may have been set from the cache */ $t = $wgOut->getPageTitle(); if (empty($t)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); } # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if ($ns == NS_USER_TALK && User::isIP($this->mTitle->getText())) { $wgOut->addWikiMsg('anontalkpagetext'); } # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if (!is_null($rcid) && $rcid != 0 && $wgUser->isAllowed('patrol') && $this->mTitle->exists()) { //XXADDED $show_namespace = $wgRequest->getVal('show_namespace'); $invert = $wgRequest->getVal('invert'); $reverse = $wgRequest->getVal('reverse'); $featured = $wgRequest->getVal('featured'); $fromrc = $wgRequest->getVal('fromrc', null) == null ? "" : "&fromrc=1"; $wgOut->addHTML("<div class='patrollink'>" . wfMsg('markaspatrolledlink', $sk->makeKnownLinkObj($this->mTitle, wfMsg('markaspatrolledtext'), "action=markpatrolled&rcid={$rcid}&show_namespace={$show_namespace}&invert={$invert}&featured={$featured}&reverse={$reverse}{$fromrc}", '', '', "accesskey='p'")) . "[" . $sk->makeKnownLinkObj($this->mTitle, wfMsg('skip'), "action=markpatrolled&rcid={$rcid}&show_namespace={$show_namespace}&invert={$invert}&featured={$featured}&reverse={$reverse}&skip=1{$fromrc}") . ']' . "</div>"); } # Trackbacks if ($wgUseTrackbacks) { $this->addTrackbacks(); } $this->viewUpdates(); wfProfileOut(__METHOD__); }