/**
	 * Retrieves and shows the user language and test wiki
	 * @param $target Mixed: user whose language and test wiki we're looking up
	 */
	function showInfo( $target ) {
		global $wgOut, $wmincPref, $wmincProjectSite;
		if( User::isIP( $target ) ) {
			# show error if it is an IP address
			$wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
			return;
		}
		$user = User::newFromName( $target );
		$name = $user->getName();
		$id = $user->getId();
		$langNames = Language::getLanguageNames();
		$linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
		if ( $user == null || $id == 0 ) {
			# show error if a user with that name does not exist
			$wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
			return;
		}
		$userproject = $user->getOption( $wmincPref . '-project' );
		$userproject = ( $userproject ? $userproject : 'none' );
		$usercode = $user->getOption( $wmincPref . '-code' );
		$prefix = IncubatorTest::displayPrefix( $userproject, $usercode ? $usercode : 'none' );
		if ( IncubatorTest::isContentProject( $userproject ) ) {
			$testwiki = $linker->link( Title::newFromText( $prefix ) );
		} elseif ( $prefix == $wmincProjectSite['short'] ) {
			$testwiki = htmlspecialchars( $wmincProjectSite['name'] );
		} else {
			$testwiki = wfMsgHtml( 'wminc-testwiki-none' );
		}
		$wgOut->addHtml(
			Xml::openElement( 'ul' ) .
			'<li>' . wfMsgHtml( 'username' ) . ' ' .
				$linker->userLink( $id, $name ) . $linker->userToolLinks( $id, $name, true ) . '</li>' .
			'<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] .
				' (' . $user->getOption( 'language' ) . ')' ) . '</li>' .
			'<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' .
			Xml::closeElement( 'ul' )
		);
	}
    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol, $wgEnableHtmlDiff;
        wfProfileIn(__METHOD__);
        # 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
\t\t\t[Process]
\t\t\tType=Diff text
\t\t\tEngine=MediaWiki
\t\t\tScript={$wgServer}{$wgScript}
\t\t\tSpecial namespace={$special}

\t\t\t[File]
\t\t\tExtension=wiki
\t\t\tURL={$url1}

\t\t\t[File 2]
\t\t\tExtension=wiki
\t\t\tURL={$url2}
CONTROL;
            echo $control;
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            $t = $this->mTitle->getPrefixedText();
            $d = wfMsgExt('missingarticle-diff', array('escape'), $this->mOldid, $this->mNewid);
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missing-article', "<nowiki>{$t}</nowiki>", $d);
            wfProfileOut(__METHOD__);
            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) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut(__METHOD__);
            return;
        }
        $wgOut->suppressQuickbar();
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsgExt('difference', array('parseinline')));
        $wgOut->setRobotPolicy('noindex,nofollow');
        if (!$this->mOldPage->userCanRead() || !$this->mNewPage->userCanRead()) {
            $wgOut->loginToUse();
            $wgOut->output();
            $wgOut->disable();
            wfProfileOut(__METHOD__);
            return;
        }
        $sk = $wgUser->getSkin();
        // Check if page is editable
        $editable = $this->mNewRev->getTitle()->userCan('edit');
        if ($editable && $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback')) {
            $rollback = '&nbsp;&nbsp;&nbsp;' . $sk->generateRollback($this->mNewRev);
        } else {
            $rollback = '';
        }
        // Prepare a change patrol link, if applicable
        if ($wgUseRCPatrol && $this->mTitle->userCan('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
                $rc = RecentChange::newFromId($rcid);
                // Already patrolled?
                $rcid = is_object($rc) && !$rc->getAttribute('rc_patrolled') ? $rcid : 0;
            } 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'];
                    $this->mRcidMarkPatrolled = $rcid;
                } else {
                    // None found
                    $rcid = 0;
                }
            }
            // Build the link
            if ($rcid) {
                $patrol = ' <span class="patrollink">[' . $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('markaspatrolleddiff'), "action=markpatrolled&rcid={$rcid}") . ']</span>';
            } else {
                $patrol = '';
            }
        } else {
            $patrol = '';
        }
        $diffOnlyArg = '';
        # Carry over 'diffonly' param via navigation links
        if ($diffOnly != $wgUser->getBoolOption('diffonly')) {
            $diffOnlyArg = '&diffonly=' . $diffOnly;
        }
        $htmldiffarg = $this->htmlDiffArgument();
        # Make "previous revision link"
        $prevlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('previousdiff'), "diff=prev&oldid={$this->mOldid}{$htmldiffarg}{$diffOnlyArg}", '', '', 'id="differences-prevlink"');
        # Make "next revision link"
        if ($this->mNewRev->isCurrent()) {
            $nextlink = '&nbsp;';
        } else {
            $nextlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('nextdiff'), "diff=next&oldid={$this->mNewid}{$htmldiffarg}{$diffOnlyArg}", '', '', 'id="differences-nextlink"');
        }
        $oldminor = '';
        $newminor = '';
        if ($this->mOldRev->isMinor()) {
            $oldminor = Xml::span(wfMsg('minoreditletter'), 'minor') . ' ';
        }
        if ($this->mNewRev->isMinor()) {
            $newminor = Xml::span(wfMsg('minoreditletter'), 'minor') . ' ';
        }
        $rdel = '';
        $ldel = '';
        if ($wgUser->isAllowed('deleterevision')) {
            if (!$this->mOldRev->userCan(Revision::DELETED_RESTRICTED)) {
                // If revision was hidden from sysops
                $ldel = Xml::tags('span', array('class' => 'mw-revdelundel-link'), '(' . wfMsgHtml('rev-delundel') . ')');
            } else {
                $query = array('target' => $this->mOldRev->mTitle->getPrefixedDbkey(), 'oldid' => $this->mOldRev->getId());
                $ldel = $sk->revDeleteLink($query, $this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED));
            }
            $ldel = "&nbsp;&nbsp;&nbsp;{$ldel} ";
            // We don't currently handle well changing the top revision's settings
            if ($this->mNewRev->isCurrent()) {
                $rdel = Xml::tags('span', array('class' => 'mw-revdelundel-link'), '(' . wfMsgHtml('rev-delundel') . ')');
            } else {
                if (!$this->mNewRev->userCan(Revision::DELETED_RESTRICTED)) {
                    // If revision was hidden from sysops
                    $rdel = Xml::tags('span', array('class' => 'mw-revdelundel-link'), '(' . wfMsgHtml('rev-delundel') . ')');
                } else {
                    $query = array('target' => $this->mNewRev->mTitle->getPrefixedDbkey(), 'oldid' => $this->mNewRev->getId());
                    $rdel = $sk->revDeleteLink($query, $this->mNewRev->isDeleted(Revision::DELETED_RESTRICTED));
                }
            }
            $rdel = "&nbsp;&nbsp;&nbsp;{$rdel} ";
        }
        $oldHeader = '<div id="mw-diff-otitle1"><strong>' . $this->mOldtitle . '</strong></div>' . '<div id="mw-diff-otitle2">' . $sk->revUserTools($this->mOldRev, !$this->unhide) . "</div>" . '<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment($this->mOldRev, !$diffOnly, !$this->unhide) . $ldel . "</div>" . '<div id="mw-diff-otitle4">' . $prevlink . '</div>';
        $newHeader = '<div id="mw-diff-ntitle1"><strong>' . $this->mNewtitle . '</strong></div>' . '<div id="mw-diff-ntitle2">' . $sk->revUserTools($this->mNewRev, !$this->unhide) . " {$rollback}</div>" . '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment($this->mNewRev, !$diffOnly, !$this->unhide) . $rdel . "</div>" . '<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';
        # Check if this user can see the revisions
        $allowed = $this->mOldRev->userCan(Revision::DELETED_TEXT) && $this->mNewRev->userCan(Revision::DELETED_TEXT);
        $deleted = $this->mOldRev->isDeleted(Revision::DELETED_TEXT) || $this->mNewRev->isDeleted(Revision::DELETED_TEXT);
        # Output the diff if allowed...
        if ($deleted && (!$this->unhide || !$allowed)) {
            $this->showDiffStyle();
            $multi = $this->getMultiNotice();
            $wgOut->addHTML($this->addHeader('', $oldHeader, $newHeader, $multi));
            if (!$allowed) {
                # Give explanation for why revision is not visible
                $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", array('rev-deleted-no-diff'));
            } else {
                # Give explanation and add a link to view the diff...
                $link = $this->mTitle->getFullUrl("diff={$this->mNewid}&oldid={$this->mOldid}" . '&unhide=1&token=' . urlencode($wgUser->editToken($this->mNewid)));
                $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", array('rev-deleted-unhide-diff', $link));
            }
        } else {
            if ($wgEnableHtmlDiff && $this->htmldiff) {
                $multi = $this->getMultiNotice();
                $wgOut->addHTML('<div class="diff-switchtype">' . $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('wikicodecomparison'), 'diff=' . $this->mNewid . '&oldid=' . $this->mOldid . '&htmldiff=0', '', '', 'id="differences-switchtype"') . '</div>');
                $wgOut->addHTML($this->addHeader('', $oldHeader, $newHeader, $multi));
                $this->renderHtmlDiff();
            } else {
                if ($wgEnableHtmlDiff) {
                    $wgOut->addHTML('<div class="diff-switchtype">' . $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('visualcomparison'), 'diff=' . $this->mNewid . '&oldid=' . $this->mOldid . '&htmldiff=1', '', '', 'id="differences-switchtype"') . '</div>');
                }
                $this->showDiff($oldHeader, $newHeader);
                if (!$diffOnly) {
                    $this->renderNewRevision();
                }
            }
        }
        wfProfileOut(__METHOD__);
    }
function wfSpan($text, $class, $attribs = array())
{
    return Xml::span($text, $class, $attribs);
}
Esempio n. 4
0
function wfSpan($text, $class, $attribs = array())
{
    wfDeprecated(__FUNCTION__);
    return Xml::span($text, $class, $attribs);
}
 function formatResult($skin, $result)
 {
     $title = Title::newFromRow($result);
     $ret = Linker::link($title, null, array(), array(), array('known'));
     if ($result->pp_value !== '') {
         $value = $this->msg('parentheses')->rawParams(Xml::span($result->pp_value, 'prop-value'))->escaped();
         $ret .= " {$value}";
     }
     return $ret;
 }
    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
        wfProfileIn(__METHOD__);
        # 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();
            $d = wfMsgExt('missingarticle-diff', array('escape'), $this->mOldid, $this->mNewid);
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missing-article', "<nowiki>{$t}</nowiki>", $d);
            wfProfileOut(__METHOD__);
            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) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut(__METHOD__);
            return;
        }
        $wgOut->suppressQuickbar();
        $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(__METHOD__);
            exit;
        }
        $sk = $wgUser->getSkin();
        // Check if page is editable
        $editable = $this->mNewRev->getTitle()->userCan('edit');
        if ($editable && $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback')) {
            $rollback = '&nbsp;&nbsp;&nbsp;' . $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) {
                $patrol = ' <span class="patrollink">[' . $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('markaspatrolleddiff'), "action=markpatrolled&rcid={$rcid}") . ']</span>';
            } else {
                $patrol = '';
            }
        } else {
            $patrol = '';
        }
        $prevlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('previousdiff'), 'diff=prev&oldid=' . $this->mOldid, '', '', 'id="differences-prevlink"');
        if ($this->mNewRev->isCurrent()) {
            $nextlink = '&nbsp;';
        } else {
            $nextlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('nextdiff'), 'diff=next&oldid=' . $this->mNewid, '', '', 'id="differences-nextlink"');
        }
        $oldminor = '';
        $newminor = '';
        if ($this->mOldRev->mMinorEdit == 1) {
            $oldminor = Xml::span(wfMsg('minoreditletter'), 'minor') . ' ';
        }
        if ($this->mNewRev->mMinorEdit == 1) {
            $newminor = Xml::span(wfMsg('minoreditletter'), 'minor') . ' ';
        }
        $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> ";
        }
        $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>';
        $newHeader = '<div id="mw-diff-ntitle1"><strong>' . $this->mNewtitle . '</strong></div>' . '<div id="mw-diff-ntitle2">' . $sk->revUserTools($this->mNewRev, true) . " {$rollback}</div>" . '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment($this->mNewRev, !$diffOnly, true) . $rdel . "</div>" . '<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';
        $this->showDiff($oldHeader, $newHeader);
        if (!$diffOnly) {
            $this->renderNewRevision();
        }
        wfProfileOut(__METHOD__);
    }