/** * Adds stable version tags to page when editing */ public function addToEditView(EditPage $editPage) { global $wgParser; $reqUser = $this->getUser(); $this->load(); # Must be reviewable. UI may be limited to unobtrusive patrolling system. if (!$this->article->isReviewable()) { return true; } $items = array(); # Show stabilization log $log = $this->stabilityLogNotice(); if ($log) { $items[] = $log; } # Check the newest stable version $frev = $this->article->getStableRev(); if ($frev) { $quality = $frev->getQuality(); # Find out revision id of base version $latestId = $this->article->getLatest(); $revId = $editPage->oldid ? $editPage->oldid : $latestId; # Let users know if their edit will have to be reviewed. # Note: if the log excerpt was shown then this is redundant. if (!$log && $this->editWillRequireReview($editPage)) { $items[] = wfMsgExt('revreview-editnotice', 'parseinline'); } # Add a notice if there are pending edits... if ($this->article->revsArePending()) { $revsSince = $this->article->getPendingRevCount(); $items[] = FlaggedRevsXML::pendingEditNotice($this->article, $frev, $revsSince); } # Show diff to stable, to make things less confusing. # This can be disabled via user preferences and other conditions... if ($frev->getRevId() < $latestId && $reqUser->getBoolOption('flaggedrevseditdiffs') && $revId == $latestId && $editPage->section != 'new' && $editPage->formtype != 'diff') { # Left diff side... $leftNote = $quality ? 'revreview-hist-quality' : 'revreview-hist-basic'; $lClass = FlaggedRevsXML::getQualityColor((int) $quality); $leftNote = "<span class='{$lClass}'>[" . wfMsgHtml($leftNote) . "]</span>"; # Right diff side... $rClass = FlaggedRevsXML::getQualityColor(false); $rightNote = "<span class='{$rClass}'>[" . wfMsgHtml('revreview-hist-pending') . "]</span>"; # Get the stable version source $text = $frev->getRevText(); # Are we editing a section? $section = $editPage->section == "" ? false : intval($editPage->section); if ($section !== false) { $text = $wgParser->getSection($text, $section); } if ($text !== false && strcmp($text, $editPage->textbox1) !== 0) { $diffEngine = new DifferenceEngine($this->article->getTitle()); $diffBody = $diffEngine->generateDiffBody($text, $editPage->textbox1); $diffHtml = wfMsgExt('review-edit-diff', 'parseinline') . ' ' . FlaggedRevsXML::diffToggle() . "<div id='mw-fr-stablediff'>" . self::getFormattedDiff($diffBody, '', $leftNote, $rightNote) . "</div>\n"; $items[] = $diffHtml; $diffEngine->showDiffStyle(); // add CSS } } # Output items if (count($items)) { $html = "<table class='flaggedrevs_editnotice plainlinks'>"; foreach ($items as $item) { $html .= '<tr><td>' . $item . '</td></tr>'; } $html .= '</table>'; $this->out->addHTML($html); } } return true; }