示例#1
13
    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol, $wgRequest, $wgTitle, $wgLanguageCode;
        $fname = 'DifferenceEngine::showDiffPage';
        wfProfileIn($fname);
        # If external diffs are enabled both globally and for the user,
        # we'll use the application/x-external-editor interface to call
        # an external diff tool like kompare, kdiff3, etc.
        if ($wgUseExternalEditor && $wgUser->getOption('externaldiff')) {
            global $wgInputEncoding, $wgServer, $wgScript, $wgLang;
            $wgOut->disable();
            header("Content-type: application/x-external-editor; charset=" . $wgInputEncoding);
            $url1 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mOldid);
            $url2 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mNewid);
            $special = $wgLang->getNsText(NS_SPECIAL);
            $control = <<<CONTROL
[Process]
Type=Diff text
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Special namespace={$special}

[File]
Extension=wiki
URL={$url1}

[File 2]
Extension=wiki
URL={$url2}
CONTROL;
            echo $control;
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, {$this->mNewid})";
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missingarticle', "<nowiki>{$t}</nowiki>");
            wfProfileOut($fname);
            return;
        }
        wfRunHooks('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
        if ($this->mNewRev->isCurrent()) {
            $wgOut->setArticleFlag(true);
        }
        # mOldid is false if the difference engine is called with a "vague" query for
        # a diff between a version V and its previous version V' AND the version V
        # is the first version of that article. In that case, V' does not exist.
        if ($this->mOldid === false && false) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut($fname);
            return;
        }
        $wgOut->suppressQuickbar();
        if (!$this->mOldPage) {
            $this->mOldPage = $this->mNewPage;
        }
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsg('difference'));
        $wgOut->setRobotpolicy('noindex,nofollow');
        if (!($this->mOldPage->userCanRead() && $this->mNewPage->userCanRead())) {
            $wgOut->loginToUse();
            $wgOut->output();
            wfProfileOut($fname);
            exit;
        }
        $sk = $wgUser->getSkin();
        if ($this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback') && $this->mTitle->userCanEdit()) {
            $rollback = $sk->generateRollback($this->mNewRev);
        } else {
            $rollback = '';
        }
        // Prepare a change patrol link, if applicable
        if ($wgUseRCPatrol && $wgUser->isAllowed('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
            } else {
                // Look for an unpatrolled change corresponding to this diff
                $db = wfGetDB(DB_SLAVE);
                $change = RecentChange::newFromConds(array('rc_user_text' => $this->mNewRev->getRawUserText(), 'rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_last_oldid' => $this->mOldid, 'rc_patrolled' => 0), __METHOD__);
                if ($change instanceof RecentChange) {
                    $rcid = $change->mAttribs['rc_id'];
                } else {
                    // None found
                    $rcid = 0;
                }
            }
            // Build the link
            if ($rcid) {
                //XXCHANGED for recent changes patrolling
                $show_namespace = $wgRequest->getVal('show_namespace');
                $invert = $wgRequest->getVal('invert');
                $featured = $wgRequest->getVal('featured');
                $reverse = $wgRequest->getVal('reverse');
                //XXCHANGED
                $fromrc = "";
                if ($wgRequest->getVal('fromrc', null) != null) {
                    $fromrc = "&fromrc=1";
                }
                if ($this->mRcidMarkPatrolledCount > 1) {
                    $msg = wfMsg('markaspatrolleddiff_multiple', $this->mRcidMarkPatrolledCount);
                    $patrol = '[' . $sk->makeKnownLinkObj($this->mTitle, $msg, "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}&show_namespace={$show_namespace}" . "&invert={$invert}&reverse={$reverse}&featured={$featured}" . "&rchi={$this->mRcidMarkPatrolledMax}&rclow={$this->mRcidMarkPatrolledMin}{$fromrc}", '', '', "accesskey='p'") . ']';
                    $patrol .= '[' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('skip'), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}&show_namespace={$show_namespace}" . "&invert={$invert}&reverse={$reverse}&featured={$featured}" . "&rchi={$this->mRcidMarkPatrolledMax}&rclow={$this->mRcidMarkPatrolledMin}{$fromrc}&skip=1", '', '', "") . ']';
                } else {
                    $patrol = '[' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('markaspatrolleddiff'), "action=markpatrolled&rcid={$rcid}&show_namespace={$show_namespace}&invert={$invert}&reverse={$reverse}&featured={$featured}{$fromrc}", '', '', "accesskey='p'") . ']';
                    $patrol .= ' [' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('skip'), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}&show_namespace={$show_namespace}&invert={$invert}&reverse={$reverse}&featured={$featured}&skip=1{$fromrc}") . ']';
                }
                $patrol = "<span id='markaspatrolledlinks'>{$patrol}</span>";
                //XXADDED
            } else {
                $patrol = '';
            }
        } else {
            $patrol = '';
        }
        //XXADDED
        if ($wgUser->isAllowed('rollback') && $this->mTitle->userCanEdit()) {
            //$rollback .= '<br/>&nbsp;&nbsp;&nbsp;<strong>' . SpamDiffTool::getDiffLink($this->mTitle) . '</strong>';
        }
        $prevlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('previousdiff'), 'diff=prev&oldid=' . $this->mOldid, '', '', 'id="differences-prevlink"');
        if ($this->mNewRev->isCurrent()) {
            $nextlink = '';
        } else {
            $nextlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('nextdiff'), 'diff=next&oldid=' . $this->mNewid, '', '', 'id="differences-nextlink"');
        }
        $oldminor = '';
        $newminor = '';
        if ($this->mOldRev->mMinorEdit == 1) {
            $oldminor = wfElement('span', array('class' => 'minor'), wfMsg('minoreditletter')) . ' ';
        }
        if ($this->mNewRev->mMinorEdit == 1) {
            $newminor = wfElement('span', array('class' => 'minor'), wfMsg('minoreditletter')) . ' ';
        }
        $rdel = '';
        $ldel = '';
        if ($wgUser->isAllowed('deleterevision')) {
            $revdel = SpecialPage::getTitleFor('Revisiondelete');
            if (!$this->mOldRev->userCan(Revision::DELETED_RESTRICTED)) {
                // If revision was hidden from sysops
                $ldel = wfMsgHtml('rev-delundel');
            } else {
                $ldel = $sk->makeKnownLinkObj($revdel, wfMsgHtml('rev-delundel'), 'target=' . urlencode($this->mOldRev->mTitle->getPrefixedDbkey()) . '&oldid=' . urlencode($this->mOldRev->getId()));
                // Bolden oversighted content
                if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) {
                    $ldel = "<strong>{$ldel}</strong>";
                }
            }
            $ldel = "&nbsp;&nbsp;&nbsp;<tt>(<small>{$ldel}</small>)</tt> ";
            // We don't currently handle well changing the top revision's settings
            if ($this->mNewRev->isCurrent()) {
                // If revision was hidden from sysops
                $rdel = wfMsgHtml('rev-delundel');
            } else {
                if (!$this->mNewRev->userCan(Revision::DELETED_RESTRICTED)) {
                    // If revision was hidden from sysops
                    $rdel = wfMsgHtml('rev-delundel');
                } else {
                    $rdel = $sk->makeKnownLinkObj($revdel, wfMsgHtml('rev-delundel'), 'target=' . urlencode($this->mNewRev->mTitle->getPrefixedDbkey()) . '&oldid=' . urlencode($this->mNewRev->getId()));
                    // Bolden oversighted content
                    if ($this->mNewRev->isDeleted(Revision::DELETED_RESTRICTED)) {
                        $rdel = "<strong>{$rdel}</strong>";
                    }
                }
            }
            $rdel = "&nbsp;&nbsp;&nbsp;<tt>(<small>{$rdel}</small>)</tt> ";
        }
        if ($this->mOldRev) {
            /*$oldHeader = '<div id="mw-diff-otitle1"><strong>'.$this->mOldtitle.'</strong></div>' .
            		'<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, true ) . "</div>" .
            		'<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, true ) . $ldel . "</div>" .
            		'<div id="mw-diff-otitle4">' . $prevlink .'</div>';*/
            $comment = $oldminor . $sk->revComment($this->mOldRev, !$diffOnly, true) . $ldel;
            //INTL: Avatar database data doesn't exist for sites other than English
            if ($wgLanguageCode == 'en') {
                $av = '<img src="' . Avatar::getAvatarURL($this->mOldRev->mUserText) . '" class="diff_avatar" />';
            }
            //$userToolsString = $sk->revUserTools( $this->mOldRev, true );
            //$userParts = explode("(", $userToolsString, 2);
            //$userName = $userParts[0];
            //$userTools = "(" . $userParts[1];
            $userName = $sk->userLink($this->mOldRev->getUser(), $this->mOldRev->getUserText());
            $userTools = $sk->userToolLinks($this->mOldRev->getUser(), $this->mOldRev->getUserText());
            $oldHeader = '<div id="mw-diff-otitle1"><h4>' . $prevlink . $this->mOldtitle . '</h4></div>' . '<div class="diff_details">' . $av . '<div id="mw-diff-otitle1a">' . wfMsg('diff_by') . ' ' . $userName . '</div>' . '<div id="mw-diff-otitle2">' . $this->mOldDate . "</div>" . '<div id="mw-diff-otitle2b">' . $userTools . "</div>";
            if ($comment != "") {
                $oldHeader .= '<div id="mw-diff-otitle3" class="rccomment"><div class="">' . $comment . '</div></div>';
            }
            $oldHeader .= '</div>';
        } else {
            $oldHeader = wfMsg('diff_noprev');
        }
        /*$newHeader = '<div id="mw-diff-ntitle1"><strong>'.$this->mNewtitle.'</strong></div>' .
        		'<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, true ) . "</div>" .
        		'<div id="mw-diff-ntitle2a">' . $rollback . "</div>" .
        		'<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "</div>" .
        		'<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';*/
        $comment = $newminor . $sk->revComment($this->mNewRev, !$diffOnly, true) . $rdel;
        //INTL: Avatar database data doesn't exist for sites other than English
        if ($wgLanguageCode == 'en') {
            $av = '<img src="' . Avatar::getAvatarURL($this->mNewRev->mUserText) . '" class="diff_avatar" />';
        }
        //$userToolsString = $sk->revUserTools( $this->mNewRev, true );
        //$userParts = explode("(", $userToolsString, 2);
        //$userName = $userParts[0];
        //$userTools = "(" . $userParts[1];
        $userName = $sk->userLink($this->mNewRev->getUser(), $this->mNewRev->getUserText());
        $userTools = $sk->userToolLinks($this->mNewRev->getUser(), $this->mNewRev->getUserText());
        $thumbsHtml = "";
        $thumbHeader = "";
        $th_diff_div = "";
        if ($wgUser->getId() != 0 && $wgTitle->getText() != "RCPatrol" && $wgTitle->getText() != "RCPatrolGuts" && $this->mNewRev->getTitle()->getNamespace() == NS_MAIN) {
            $oldId = $this->mNewRev->getPrevious();
            $oldId = $oldId ? $oldId->getId() : -1;
            // Only show thumbs up for diffs that look back one revision
            if (class_exists('ThumbsUp')) {
                if ($oldId == -1 || $this->mOldRev && $oldId == $this->mOldRev->getId()) {
                    $params = array('title' => $this->mNewRev->getTitle(), 'new' => $this->mNewid, 'old' => $oldId, 'vandal' => 0);
                    $thumbsHtml = ThumbsUp::getThumbsUpButton($params, true);
                    //$thumbHeader = 'class="th_diff_h4"';
                    $th_diff_div = 'class="th_diff_div"';
                }
            }
        }
        $newHeader = '<div id="mw-diff-ntitle1" ' . $th_diff_div . '><h4 ' . $thumbHeader . '>' . $this->mNewtitle . ' ' . $nextlink . '</h4></div>' . '<div class="diff_details">' . $av . $thumbsHtml . '<div id="mw-diff-ntitle1a">' . wfMsg('diff_by') . ' ' . $userName . '</div>' . '<div id="mw-diff-ntitle2">' . $this->mNewDate . "</div>" . '<div id="mw-diff-ntitle2b">' . $userTools . "</div>" . '<div id="mw-diff-ntitle4" style="text-align:left">' . $rollback . $nextlink . $patrol . '</div>';
        if ($comment != "") {
            $newHeader .= '<div id="mw-diff-ntitle3" class="rccomment"><div class="">' . $comment . '</div></div>';
        }
        $newHeader .= '</div>';
        $this->showDiff($oldHeader, $newHeader);
        if (!$diffOnly) {
            $this->renderNewRevision();
        }
        wfProfileOut($fname);
    }
示例#2
0
function onDifferenceEngineNewHeader($differenceEngine, &$newHeader, $formattedRevisionTools, $nextlink, $rollback, $newminor, $diffOnly, $rdel, $unhide)
{
    global $wgLanguageCode, $wgTitle;
    $user = $differenceEngine->getUser();
    $newRevisionHeader = $differenceEngine->getRevisionHeader($differenceEngine->mNewRev, 'complete', 'new') . ' ' . implode(' ', $formattedRevisionTools);
    $newDaysAgo = wfTimeAgo($differenceEngine->mNewRev->getTimestamp());
    //INTL: Avatar database data doesn't exist for sites other than English
    if ($wgLanguageCode == 'en') {
        $av = '<img src="' . Avatar::getAvatarURL($differenceEngine->mNewRev->getUserText()) . '" class="diff_avatar" />';
    }
    $thumbsHtml = "";
    $thumbHeader = "";
    $th_diff_div = "";
    if ($user->getId() != 0 && $wgTitle->getText() != "RCPatrol" && $wgTitle->getText() != "RCPatrolGuts" && $differenceEngine->mNewRev->getTitle()->getNamespace() == NS_MAIN) {
        $oldId = $differenceEngine->mNewRev->getPrevious();
        $oldId = $oldId ? $oldId->getId() : -1;
        // Only show thumbs up for diffs that look back one revision
        if (class_exists('ThumbsUp')) {
            if ($oldId == -1 || $differenceEngine->mOldRev && $oldId == $differenceEngine->mOldRev->getId()) {
                $params = array('title' => $differenceEngine->mNewRev->getTitle(), 'new' => $differenceEngine->mNewid, 'old' => $oldId, 'vandal' => 0);
                $thumbsHtml = ThumbsUp::getThumbsUpButton($params, true);
                $th_diff_div = 'class="th_diff_div"';
            }
        }
    }
    $newHeader = '<div id="mw-diff-ntitle1" ' . $th_diff_div . '><h4 ' . $thumbHeader . '>' . $newRevisionHeader . $nextlink . '</h4></div>' . '<div id="mw-diff-ntitle2">' . $av . $thumbsHtml . '<div id="mw-diff-oinfo">' . Linker::revUserTools($differenceEngine->mNewRev, !$unhide) . " {$rollback} " . '<br /><div id="mw-diff-ndaysago">' . $newDaysAgo . '</div>' . "</div>" . '<div id="mw-diff-ntitle4">' . $differenceEngine->markPatrolledLink() . '</div>' . "</div>" . '<div id="mw-diff-ntitle3" class="rccomment">' . $newminor . Linker::revComment($differenceEngine->mNewRev, !$diffOnly, !$unhide) . $rdel . '</div>';
    return true;
}
示例#3
0
 static function getThumbsUpButton($result, &$rcTest)
 {
     $button = "";
     if (class_exists('RCTest') && RCTest::isEnabled()) {
         if ($rcTest && $rcTest->isTestTime()) {
             $result = $rcTest->getResultParams();
         }
     }
     if (class_exists('ThumbsUp')) {
         $button = ThumbsUp::getThumbsUpButton($result);
     }
     return $button;
 }
示例#4
0
 function getNextToPatrolHTML()
 {
     global $wgOut;
     if (!$this->mResult) {
         // nothing to patrol
         return null;
     }
     // construct the HTML to reply
     // load the page
     $t = 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::newFromId($this->mResult->qc_rev_id);
     if (!$r) {
         return "Error creating revision";
     }
     // grab the intro image
     $text = $r->getText();
     $intro = Article::getSection($text, 0);
     //ignore if we have a {{nointroimg}} template in there
     $a = new Article($t);
     $templates = $a->getUsedTemplates();
     if (in_array('Template:Nointroimg', $templates)) {
         $this->deleteBad($this->mResult->qc_page);
         return "<!--{$this->mResult->qc_page}--><p></p><p>Intro images have been disabled for this article. Please <a href='#' onclick='window.location.reload()'>refresh</a> for the next article.</p>";
     }
     $html = "";
     $changedby = self::getChangedBy("Image added by: ");
     $pic = self::getPicture($intro);
     if ($pic) {
         //make sure it's not too big
         if ($pic->width > 600) {
             $pic = $pic->getThumbnail(600);
         }
         if ($r->getPrevious()) {
             $old = $r->getPrevious()->getID();
         } else {
             $old = -1;
         }
         $thumbresult['new'] = $r->getID();
         $thumbresult['old'] = $old;
         $thumbresult['title'] = $t;
         $pic_width = (632 - $pic->width) / 2 + $pic->width - 32;
         //31px = thumbbutton width
         $thumbs = ThumbsUp::getThumbsUpButton($thumbresult);
         $style = " style='margin-left:" . $pic_width . "px;'";
         $thumbs = "<div class='qc_changedby_inset'{$style}>{$thumbs}</div>";
         $html .= "<div id='qc_bigpic'>\n\t\t\t\t\t\t" . $thumbs . "\n\t\t\t\t\t\t<img class='qc_bigpic_img' src='" . $pic->getURL() . "' width='" . $pic->width . "' height='" . $pic->height . "' />\n\t\t\t\t\t\t</div>";
     } else {
         $html .= "<br />" . wfMsg('qc_nothing_found');
     }
     $html = "<div id='quickeditlink'></div>";
     $html .= "<div id='qc_box'>" . $changedby . $html . "</div>";
     $popts = $wgOut->parserOptions();
     $popts->setTidy(true);
     $html .= WikihowArticleHTML::processArticleHTML($wgOut->parse($text, $t, $popts), array('ns' => $t->getNamespace()));
     $html .= "<input type='hidden' name='qc_id' value='{$this->mResult->qc_id}'/>";
     $html .= "<div id='numqcusers'>{$this->mUsers}</div>";
     return $html;
 }
示例#5
-1
 static function getThumbsUpButton($result, &$rcTest)
 {
     $button = "";
     if (class_exists('RCTest') && RCTest::isEnabled()) {
         if ($rcTest && $rcTest->isTestTime()) {
             $result = $rcTest->getResultParams();
         }
     }
     if (class_exists('ThumbsUp')) {
         //-1 is a secret code to our thumbs up function
         $result['old'] = $result['old'] != 0 ? $result['old'] : -1;
         $button = ThumbsUp::getThumbsUpButton($result);
     }
     return $button;
 }