本文整理汇总了PHP中Linker::revComment方法的典型用法代码示例。如果您正苦于以下问题:PHP Linker::revComment方法的具体用法?PHP Linker::revComment怎么用?PHP Linker::revComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Linker
的用法示例。
在下文中一共展示了Linker::revComment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatRow
function formatRow($row)
{
wfProfileIn(__METHOD__);
global $wgLang, $wgUser, $wgContLang;
$rev = new Revision($row);
$page = Title::makeTitle($row->page_namespace, $row->page_title);
$link = Linker::link($page);
$difftext = $topmarktext = '';
if ($row->rev_id == $row->page_latest) {
if (!$row->page_is_new) {
$difftext .= '(' . Linker::link($page, $this->messages['diff'], array(), 'diff=0') . ')';
} else {
$difftext .= $this->messages['newarticle'];
}
}
if ($rev->userCan(Revision::DELETED_TEXT)) {
$difftext = '(' . Linker::link($page, $this->messages['diff'], array(), 'diff=prev&oldid=' . $row->rev_id) . ')';
} else {
$difftext = '(' . $this->messages['diff'] . ')';
}
$comment = $wgContLang->getDirMark() . Linker::revComment($rev);
$d = $wgLang->timeanddate(wfTimestamp(TS_MW, $row->rev_timestamp), true);
if ($this->target == 'newbies') {
$userlink = ' . . ' . Linker::userLink($row->rev_user, $row->rev_user_text);
$userlink .= ' (' . Linker::userTalkLink($row->rev_user, $row->rev_user_text) . ') ';
} else {
$userlink = '';
}
if ($rev->isDeleted(Revision::DELETED_TEXT)) {
$d = '<span class="history-deleted">' . $d . '</span>';
}
if ($row->rev_minor_edit) {
$mflag = '<span class="minor">' . $this->messages['minoreditletter'] . '</span> ';
} else {
$mflag = '';
}
$ret = "{$d} {$difftext} {$mflag} {$link}{$userlink}{$comment} {$topmarktext}";
if ($rev->isDeleted(Revision::DELETED_TEXT)) {
$ret .= ' ' . wfMsgHtml('deletedrev');
}
$ret = "<li>{$ret}</li>\n";
wfProfileOut(__METHOD__);
return $ret;
}
示例2: getHTML
/**
* @return string A HTML <li> element representing this revision, showing
* change tags and everything
*/
public function getHTML()
{
$difflink = $this->list->msg('parentheses')->rawParams($this->getDiffLink())->escaped();
$revlink = $this->getRevisionLink();
$userlink = Linker::revUserLink($this->revision);
$comment = Linker::revComment($this->revision);
if ($this->isDeleted()) {
$revlink = "<span class=\"history-deleted\">{$revlink}</span>";
}
$content = "{$difflink} {$revlink} {$userlink} {$comment}";
$attribs = array();
$tags = $this->getTags();
if ($tags) {
list($tagSummary, $classes) = ChangeTags::formatSummaryRow($tags, 'edittags');
$content .= " {$tagSummary}";
$attribs['class'] = implode(' ', $classes);
}
return Xml::tags('li', $attribs, $content);
}
示例3: setOldSubtitle
/**
* Generate the navigation links when browsing through an article revisions
* It shows the information as:
* Revision as of \<date\>; view current revision
* \<- Previous version | Next Version -\>
*
* @param int $oldid Revision ID of this article revision
*/
public function setOldSubtitle($oldid = 0)
{
if (!Hooks::run('DisplayOldSubtitle', array(&$this, &$oldid))) {
return;
}
$context = $this->getContext();
$unhide = $context->getRequest()->getInt('unhide') == 1;
# Cascade unhide param in links for easy deletion browsing
$extraParams = array();
if ($unhide) {
$extraParams['unhide'] = 1;
}
if ($this->mRevision && $this->mRevision->getId() === $oldid) {
$revision = $this->mRevision;
} else {
$revision = Revision::newFromId($oldid);
}
$timestamp = $revision->getTimestamp();
$current = $oldid == $this->mPage->getLatest();
$language = $context->getLanguage();
$user = $context->getUser();
$td = $language->userTimeAndDate($timestamp, $user);
$tddate = $language->userDate($timestamp, $user);
$tdtime = $language->userTime($timestamp, $user);
# Show user links if allowed to see them. If hidden, then show them only if requested...
$userlinks = Linker::revUserTools($revision, !$unhide);
$infomsg = $current && !$context->msg('revision-info-current')->isDisabled() ? 'revision-info-current' : 'revision-info';
$outputPage = $context->getOutput();
$outputPage->addSubtitle("<div id=\"mw-{$infomsg}\">" . $context->msg($infomsg, $td)->rawParams($userlinks)->params($revision->getID(), $tddate, $tdtime, $revision->getUserText())->rawParams(Linker::revComment($revision, true, true))->parse() . "</div>");
$lnk = $current ? $context->msg('currentrevisionlink')->escaped() : Linker::linkKnown($this->getTitle(), $context->msg('currentrevisionlink')->escaped(), array(), $extraParams);
$curdiff = $current ? $context->msg('diff')->escaped() : Linker::linkKnown($this->getTitle(), $context->msg('diff')->escaped(), array(), array('diff' => 'cur', 'oldid' => $oldid) + $extraParams);
$prev = $this->getTitle()->getPreviousRevisionID($oldid);
$prevlink = $prev ? Linker::linkKnown($this->getTitle(), $context->msg('previousrevision')->escaped(), array(), array('direction' => 'prev', 'oldid' => $oldid) + $extraParams) : $context->msg('previousrevision')->escaped();
$prevdiff = $prev ? Linker::linkKnown($this->getTitle(), $context->msg('diff')->escaped(), array(), array('diff' => 'prev', 'oldid' => $oldid) + $extraParams) : $context->msg('diff')->escaped();
$nextlink = $current ? $context->msg('nextrevision')->escaped() : Linker::linkKnown($this->getTitle(), $context->msg('nextrevision')->escaped(), array(), array('direction' => 'next', 'oldid' => $oldid) + $extraParams);
$nextdiff = $current ? $context->msg('diff')->escaped() : Linker::linkKnown($this->getTitle(), $context->msg('diff')->escaped(), array(), array('diff' => 'next', 'oldid' => $oldid) + $extraParams);
$cdel = Linker::getRevDeleteLink($user, $revision, $this->getTitle());
if ($cdel !== '') {
$cdel .= ' ';
}
$outputPage->addSubtitle("<div id=\"mw-revision-nav\">" . $cdel . $context->msg('revision-nav')->rawParams($prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff)->escaped() . "</div>");
}
示例4: historyLine
/**
* Returns a row from the history printout.
*
* @todo document some more, and maybe clean up the code (some params redundant?)
*
* @param stdClass $row The database row corresponding to the previous line.
* @param mixed $next The database row corresponding to the next line
* (chronologically previous)
* @param bool|string $notificationtimestamp
* @param bool $latest Whether this row corresponds to the page's latest revision.
* @param bool $firstInList Whether this row corresponds to the first
* displayed on this history page.
* @return string HTML output for the row
*/
function historyLine($row, $next, $notificationtimestamp = false, $latest = false, $firstInList = false)
{
$rev = new Revision($row);
$rev->setTitle($this->getTitle());
if (is_object($next)) {
$prevRev = new Revision($next);
$prevRev->setTitle($this->getTitle());
} else {
$prevRev = null;
}
$curlink = $this->curLink($rev, $latest);
$lastlink = $this->lastLink($rev, $next);
$curLastlinks = $curlink . $this->historyPage->message['pipe-separator'] . $lastlink;
$histLinks = Html::rawElement('span', array('class' => 'mw-history-histlinks'), $this->msg('parentheses')->rawParams($curLastlinks)->escaped());
$diffButtons = $this->diffButtons($rev, $firstInList);
$s = $histLinks . $diffButtons;
$link = $this->revLink($rev);
$classes = array();
$del = '';
$user = $this->getUser();
// Show checkboxes for each revision
if ($user->isAllowed('deleterevision')) {
$this->preventClickjacking();
// If revision was hidden from sysops, disable the checkbox
if (!$rev->userCan(Revision::DELETED_RESTRICTED, $user)) {
$del = Xml::check('deleterevisions', false, array('disabled' => 'disabled'));
// Otherwise, enable the checkbox...
} else {
$del = Xml::check('showhiderevisions', false, array('name' => 'ids[' . $rev->getId() . ']'));
}
// User can only view deleted revisions...
} elseif ($rev->getVisibility() && $user->isAllowed('deletedhistory')) {
// If revision was hidden from sysops, disable the link
if (!$rev->userCan(Revision::DELETED_RESTRICTED, $user)) {
$del = Linker::revDeleteLinkDisabled(false);
// Otherwise, show the link...
} else {
$query = array('type' => 'revision', 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId());
$del .= Linker::revDeleteLink($query, $rev->isDeleted(Revision::DELETED_RESTRICTED), false);
}
}
if ($del) {
$s .= " {$del} ";
}
$lang = $this->getLanguage();
$dirmark = $lang->getDirMark();
$s .= " {$link}";
$s .= $dirmark;
$s .= " <span class='history-user'>" . Linker::revUserTools($rev, true) . "</span>";
$s .= $dirmark;
if ($rev->isMinor()) {
$s .= ' ' . ChangesList::flag('minor');
}
# Sometimes rev_len isn't populated
if ($rev->getSize() !== null) {
# Size is always public data
$prevSize = isset($this->parentLens[$row->rev_parent_id]) ? $this->parentLens[$row->rev_parent_id] : 0;
$sDiff = ChangesList::showCharacterDifference($prevSize, $rev->getSize());
$fSize = Linker::formatRevisionSize($rev->getSize());
$s .= ' <span class="mw-changeslist-separator">. .</span> ' . "{$fSize} {$sDiff}";
}
# Text following the character difference is added just before running hooks
$s2 = Linker::revComment($rev, false, true);
if ($notificationtimestamp && $row->rev_timestamp >= $notificationtimestamp) {
$s2 .= ' <span class="updatedmarker">' . $this->msg('updatedmarker')->escaped() . '</span>';
$classes[] = 'mw-history-line-updated';
}
$tools = array();
# Rollback and undo links
if ($prevRev && $this->getTitle()->quickUserCan('edit', $user)) {
if ($latest && $this->getTitle()->quickUserCan('rollback', $user)) {
// Get a rollback link without the brackets
$rollbackLink = Linker::generateRollback($rev, $this->getContext(), array('verify', 'noBrackets'));
if ($rollbackLink) {
$this->preventClickjacking();
$tools[] = $rollbackLink;
}
}
if (!$rev->isDeleted(Revision::DELETED_TEXT) && !$prevRev->isDeleted(Revision::DELETED_TEXT)) {
# Create undo tooltip for the first (=latest) line only
$undoTooltip = $latest ? array('title' => $this->msg('tooltip-undo')->text()) : array();
$undolink = Linker::linkKnown($this->getTitle(), $this->msg('editundo')->escaped(), $undoTooltip, array('action' => 'edit', 'undoafter' => $prevRev->getId(), 'undo' => $rev->getId()));
$tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
}
}
// Allow extension to add their own links here
//.........这里部分代码省略.........
示例5: formatRow
/**
* Generates each row in the contributions list.
*
* Contributions which are marked "top" are currently on top of the history.
* For these contributions, a [rollback] link is shown for users with roll-
* back privileges. The rollback link restores the most recent version that
* was not written by the target user.
*
* @todo This would probably look a lot nicer in a table.
* @param $row
* @return string
*/
function formatRow($row)
{
wfProfileIn(__METHOD__);
$ret = '';
$classes = array();
/*
* There may be more than just revision rows. To make sure that we'll only be processing
* revisions here, let's _try_ to build a revision out of our row (without displaying
* notices though) and then trying to grab data from the built object. If we succeed,
* we're definitely dealing with revision data and we may proceed, if not, we'll leave it
* to extensions to subscribe to the hook to parse the row.
*/
wfSuppressWarnings();
$rev = new Revision($row);
$validRevision = $rev->getParentId() !== null;
wfRestoreWarnings();
if ($validRevision) {
$classes = array();
$page = Title::newFromRow($row);
$link = Linker::link($page, htmlspecialchars($page->getPrefixedText()), array('class' => 'mw-contributions-title'), $page->isRedirect() ? array('redirect' => 'no') : array());
# Mark current revisions
$topmarktext = '';
$user = $this->getUser();
if ($row->rev_id == $row->page_latest) {
$topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
# Add rollback link
if (!$row->page_is_new && $page->quickUserCan('rollback', $user) && $page->quickUserCan('edit', $user)) {
$this->preventClickjacking();
$topmarktext .= ' ' . Linker::generateRollback($rev, $this->getContext());
}
}
# Is there a visible previous revision?
if ($rev->userCan(Revision::DELETED_TEXT, $user) && $rev->getParentId() !== 0) {
$difftext = Linker::linkKnown($page, $this->messages['diff'], array(), array('diff' => 'prev', 'oldid' => $row->rev_id));
} else {
$difftext = $this->messages['diff'];
}
$histlink = Linker::linkKnown($page, $this->messages['hist'], array(), array('action' => 'history'));
if ($row->rev_parent_id === null) {
// For some reason rev_parent_id isn't populated for this row.
// Its rumoured this is true on wikipedia for some revisions (bug 34922).
// Next best thing is to have the total number of bytes.
$chardiff = ' <span class="mw-changeslist-separator">. .</span> ' . Linker::formatRevisionSize($row->rev_len) . ' <span class="mw-changeslist-separator">. .</span> ';
} else {
$parentLen = isset($this->mParentLens[$row->rev_parent_id]) ? $this->mParentLens[$row->rev_parent_id] : 0;
$chardiff = ' <span class="mw-changeslist-separator">. .</span> ' . ChangesList::showCharacterDifference($parentLen, $row->rev_len, $this->getContext()) . ' <span class="mw-changeslist-separator">. .</span> ';
}
$lang = $this->getLanguage();
$comment = $lang->getDirMark() . Linker::revComment($rev, false, true);
$date = $lang->userTimeAndDate($row->rev_timestamp, $user);
if ($rev->userCan(Revision::DELETED_TEXT, $user)) {
$d = Linker::linkKnown($page, htmlspecialchars($date), array('class' => 'mw-changeslist-date'), array('oldid' => intval($row->rev_id)));
} else {
$d = htmlspecialchars($date);
}
if ($rev->isDeleted(Revision::DELETED_TEXT)) {
$d = '<span class="history-deleted">' . $d . '</span>';
}
# Show user names for /newbies as there may be different users.
# Note that we already excluded rows with hidden user names.
if ($this->contribs == 'newbie') {
$userlink = ' . . ' . Linker::userLink($rev->getUser(), $rev->getUserText());
$userlink .= ' ' . $this->msg('parentheses')->rawParams(Linker::userTalkLink($rev->getUser(), $rev->getUserText()))->escaped() . ' ';
} else {
$userlink = '';
}
if ($rev->getParentId() === 0) {
$nflag = ChangesList::flag('newpage');
} else {
$nflag = '';
}
if ($rev->isMinor()) {
$mflag = ChangesList::flag('minor');
} else {
$mflag = '';
}
$del = Linker::getRevDeleteLink($user, $rev, $page);
if ($del !== '') {
$del .= ' ';
}
$diffHistLinks = $this->msg('parentheses')->rawParams($difftext . $this->messages['pipe-separator'] . $histlink)->escaped();
$ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
# Denote if username is redacted for this edit
if ($rev->isDeleted(Revision::DELETED_USER)) {
$ret .= " <strong>" . $this->msg('rev-deleted-user-contribs')->escaped() . "</strong>";
}
# Tags, if any.
list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow($row->ts_tags, 'contributions');
//.........这里部分代码省略.........
示例6: formatRow
/**
* Format a row, providing the timestamp, links to the page/history, size, user links, and a comment
*
* @param $result Result row
* @return String
*/
public function formatRow($result)
{
$title = Title::newFromRow($result);
# Revision deletion works on revisions, so we should cast one
$row = array('comment' => $result->rc_comment, 'deleted' => $result->rc_deleted, 'user_text' => $result->rc_user_text, 'user' => $result->rc_user);
$rev = new Revision($row);
$rev->setTitle($title);
$classes = array();
$lang = $this->getLanguage();
$dm = $lang->getDirMark();
$spanTime = Html::element('span', array('class' => 'mw-newpages-time'), $lang->userTimeAndDate($result->rc_timestamp, $this->getUser()));
$time = Linker::linkKnown($title, $spanTime, array(), array('oldid' => $result->rc_this_oldid), array());
$query = array('redirect' => 'no');
if ($this->patrollable($result)) {
$query['rcid'] = $result->rc_id;
}
// Linker::linkKnown() uses 'known' and 'noclasses' options. This breaks the colouration for stubs.
$plink = Linker::link($title, null, array('class' => 'mw-newpages-pagename'), $query, array('known'));
$histLink = Linker::linkKnown($title, $this->msg('hist')->escaped(), array(), array('action' => 'history'));
$hist = Html::rawElement('span', array('class' => 'mw-newpages-history'), $this->msg('parentheses')->rawParams($histLink)->escaped());
$length = Html::element('span', array('class' => 'mw-newpages-length'), $this->msg('brackets')->params($this->msg('nbytes')->numParams($result->length)->text()));
$ulink = Linker::revUserTools($rev);
$comment = Linker::revComment($rev);
if ($this->patrollable($result)) {
$classes[] = 'not-patrolled';
}
# Add a class for zero byte pages
if ($result->length == 0) {
$classes[] = 'mw-newpages-zero-byte-page';
}
# Tags, if any.
if (isset($result->ts_tags)) {
list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow($result->ts_tags, 'newpages');
$classes = array_merge($classes, $newClasses);
} else {
$tagDisplay = '';
}
$css = count($classes) ? ' class="' . implode(' ', $classes) . '"' : '';
# Display the old title if the namespace/title has been changed
$oldTitleText = '';
$oldTitle = Title::makeTitle($result->rc_namespace, $result->rc_title);
if (!$title->equals($oldTitle)) {
$oldTitleText = $this->msg('rc-old-title')->params($oldTitle->getPrefixedText())->escaped();
}
return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
}
示例7: showDiffPage
public function showDiffPage($diffOnly = false)
{
# Allow frames except in certain special cases
$out = $this->getOutput();
$out->allowClickjacking();
$out->setRobotPolicy('noindex,nofollow');
if (!$this->loadRevisionData()) {
$this->showMissingRevision();
return;
}
$user = $this->getUser();
$permErrors = $this->mNewPage->getUserPermissionsErrors('read', $user);
if ($this->mOldPage) {
# mOldPage might not be set, see below.
$permErrors = wfMergeErrorArrays($permErrors, $this->mOldPage->getUserPermissionsErrors('read', $user));
}
if (count($permErrors)) {
throw new PermissionsError('read', $permErrors);
}
$rollback = '';
$query = array();
# Carry over 'diffonly' param via navigation links
if ($diffOnly != $user->getBoolOption('diffonly')) {
$query['diffonly'] = $diffOnly;
}
# Cascade unhide param in links for easy deletion browsing
if ($this->unhide) {
$query['unhide'] = 1;
}
# Check if one of the revisions is deleted/suppressed
$deleted = $suppressed = false;
$allowed = $this->mNewRev->userCan(Revision::DELETED_TEXT, $user);
$revisionTools = array();
# mOldRev 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->mOldRev === false) {
$out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
$samePage = true;
$oldHeader = '';
} else {
Hooks::run('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
if ($this->mNewPage->equals($this->mOldPage)) {
$out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
$samePage = true;
} else {
$out->setPageTitle($this->msg('difference-title-multipage', $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText()));
$out->addSubtitle($this->msg('difference-multipage'));
$samePage = false;
}
if ($samePage && $this->mNewPage->quickUserCan('edit', $user)) {
if ($this->mNewRev->isCurrent() && $this->mNewPage->userCan('rollback', $user)) {
$rollbackLink = Linker::generateRollback($this->mNewRev, $this->getContext());
if ($rollbackLink) {
$out->preventClickjacking();
$rollback = '   ' . $rollbackLink;
}
}
if (!$this->mOldRev->isDeleted(Revision::DELETED_TEXT) && !$this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
$undoLink = Html::element('a', array('href' => $this->mNewPage->getLocalURL(array('action' => 'edit', 'undoafter' => $this->mOldid, 'undo' => $this->mNewid)), 'title' => Linker::titleAttrib('undo')), $this->msg('editundo')->text());
$revisionTools['mw-diff-undo'] = $undoLink;
}
}
# Make "previous revision link"
if ($samePage && $this->mOldRev->getPrevious()) {
$prevlink = Linker::linkKnown($this->mOldPage, $this->msg('previousdiff')->escaped(), array('id' => 'differences-prevlink'), array('diff' => 'prev', 'oldid' => $this->mOldid) + $query);
} else {
$prevlink = ' ';
}
if ($this->mOldRev->isMinor()) {
$oldminor = ChangesList::flag('minor');
} else {
$oldminor = '';
}
$ldel = $this->revisionDeleteLink($this->mOldRev);
$oldRevisionHeader = $this->getRevisionHeader($this->mOldRev, 'complete');
$oldChangeTags = ChangeTags::formatSummaryRow($this->mOldTags, 'diff');
$oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' . '<div id="mw-diff-otitle2">' . Linker::revUserTools($this->mOldRev, !$this->unhide) . '</div>' . '<div id="mw-diff-otitle3">' . $oldminor . Linker::revComment($this->mOldRev, !$diffOnly, !$this->unhide) . $ldel . '</div>' . '<div id="mw-diff-otitle5">' . $oldChangeTags[0] . '</div>' . '<div id="mw-diff-otitle4">' . $prevlink . '</div>';
if ($this->mOldRev->isDeleted(Revision::DELETED_TEXT)) {
$deleted = true;
// old revisions text is hidden
if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) {
$suppressed = true;
// also suppressed
}
}
# Check if this user can see the revisions
if (!$this->mOldRev->userCan(Revision::DELETED_TEXT, $user)) {
$allowed = false;
}
}
# Make "next revision link"
# Skip next link on the top revision
if ($samePage && !$this->mNewRev->isCurrent()) {
$nextlink = Linker::linkKnown($this->mNewPage, $this->msg('nextdiff')->escaped(), array('id' => 'differences-nextlink'), array('diff' => 'next', 'oldid' => $this->mNewid) + $query);
} else {
$nextlink = ' ';
}
if ($this->mNewRev->isMinor()) {
$newminor = ChangesList::flag('minor');
//.........这里部分代码省略.........
示例8: formatRow
/**
* Generates each row in the contributions list.
*
* Contributions which are marked "top" are currently on top of the history.
* For these contributions, a [rollback] link is shown for users with roll-
* back privileges. The rollback link restores the most recent version that
* was not written by the target user.
*
* @todo This would probably look a lot nicer in a table.
* @param object $row
* @return string
*/
function formatRow($row)
{
$ret = '';
$classes = [];
/*
* There may be more than just revision rows. To make sure that we'll only be processing
* revisions here, let's _try_ to build a revision out of our row (without displaying
* notices though) and then trying to grab data from the built object. If we succeed,
* we're definitely dealing with revision data and we may proceed, if not, we'll leave it
* to extensions to subscribe to the hook to parse the row.
*/
MediaWiki\suppressWarnings();
try {
$rev = new Revision($row);
$validRevision = (bool) $rev->getId();
} catch (Exception $e) {
$validRevision = false;
}
MediaWiki\restoreWarnings();
if ($validRevision) {
$classes = [];
$page = Title::newFromRow($row);
$link = Linker::link($page, htmlspecialchars($page->getPrefixedText()), ['class' => 'mw-contributions-title'], $page->isRedirect() ? ['redirect' => 'no'] : []);
# Mark current revisions
$topmarktext = '';
$user = $this->getUser();
if ($row->rev_id === $row->page_latest) {
$topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
$classes[] = 'mw-contributions-current';
# Add rollback link
if (!$row->page_is_new && $page->quickUserCan('rollback', $user) && $page->quickUserCan('edit', $user)) {
$this->preventClickjacking();
$topmarktext .= ' ' . Linker::generateRollback($rev, $this->getContext());
}
}
# Is there a visible previous revision?
if ($rev->userCan(Revision::DELETED_TEXT, $user) && $rev->getParentId() !== 0) {
$difftext = Linker::linkKnown($page, $this->messages['diff'], [], ['diff' => 'prev', 'oldid' => $row->rev_id]);
} else {
$difftext = $this->messages['diff'];
}
$histlink = Linker::linkKnown($page, $this->messages['hist'], [], ['action' => 'history']);
if ($row->rev_parent_id === null) {
// For some reason rev_parent_id isn't populated for this row.
// Its rumoured this is true on wikipedia for some revisions (bug 34922).
// Next best thing is to have the total number of bytes.
$chardiff = ' <span class="mw-changeslist-separator">. .</span> ';
$chardiff .= Linker::formatRevisionSize($row->rev_len);
$chardiff .= ' <span class="mw-changeslist-separator">. .</span> ';
} else {
$parentLen = 0;
if (isset($this->mParentLens[$row->rev_parent_id])) {
$parentLen = $this->mParentLens[$row->rev_parent_id];
}
$chardiff = ' <span class="mw-changeslist-separator">. .</span> ';
$chardiff .= ChangesList::showCharacterDifference($parentLen, $row->rev_len, $this->getContext());
$chardiff .= ' <span class="mw-changeslist-separator">. .</span> ';
}
$lang = $this->getLanguage();
$comment = $lang->getDirMark() . Linker::revComment($rev, false, true);
$date = $lang->userTimeAndDate($row->rev_timestamp, $user);
if ($rev->userCan(Revision::DELETED_TEXT, $user)) {
$d = Linker::linkKnown($page, htmlspecialchars($date), ['class' => 'mw-changeslist-date'], ['oldid' => intval($row->rev_id)]);
} else {
$d = htmlspecialchars($date);
}
if ($rev->isDeleted(Revision::DELETED_TEXT)) {
$d = '<span class="history-deleted">' . $d . '</span>';
}
# Show user names for /newbies as there may be different users.
# Note that we already excluded rows with hidden user names.
if ($this->contribs == 'newbie') {
$userlink = ' . . ' . $lang->getDirMark() . Linker::userLink($rev->getUser(), $rev->getUserText());
$userlink .= ' ' . $this->msg('parentheses')->rawParams(Linker::userTalkLink($rev->getUser(), $rev->getUserText()))->escaped() . ' ';
} else {
$userlink = '';
}
$flags = [];
if ($rev->getParentId() === 0) {
$flags[] = ChangesList::flag('newpage');
}
if ($rev->isMinor()) {
$flags[] = ChangesList::flag('minor');
}
$del = Linker::getRevDeleteLink($user, $rev, $page);
if ($del !== '') {
$del .= ' ';
}
//.........这里部分代码省略.........
示例9: onDifferenceEngineNewHeader
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;
}
示例10: formatRevisionRow
private function formatRevisionRow($row, $earliestLiveTime, $remaining)
{
$rev = Revision::newFromArchiveRow($row, array('page' => $this->mTargetObj->getArticleId()));
$stxt = '';
$ts = wfTimestamp(TS_MW, $row->ar_timestamp);
// Build checkboxen...
if ($this->mAllowed) {
if ($this->mInvert) {
if (in_array($ts, $this->mTargetTimestamp)) {
$checkBox = Xml::check("ts{$ts}");
} else {
$checkBox = Xml::check("ts{$ts}", true);
}
} else {
$checkBox = Xml::check("ts{$ts}");
}
} else {
$checkBox = '';
}
$user = $this->getUser();
// Build page & diff links...
if ($this->mCanView) {
$titleObj = $this->getTitle();
# Last link
if (!$rev->userCan(Revision::DELETED_TEXT, $this->getUser())) {
$pageLink = htmlspecialchars($this->getLanguage()->userTimeAndDate($ts, $user));
$last = $this->msg('diff')->escaped();
} elseif ($remaining > 0 || $earliestLiveTime && $ts > $earliestLiveTime) {
$pageLink = $this->getPageLink($rev, $titleObj, $ts);
$last = Linker::linkKnown($titleObj, $this->msg('diff')->escaped(), array(), array('target' => $this->mTargetObj->getPrefixedText(), 'timestamp' => $ts, 'diff' => 'prev'));
} else {
$pageLink = $this->getPageLink($rev, $titleObj, $ts);
$last = $this->msg('diff')->escaped();
}
} else {
$pageLink = htmlspecialchars($this->getLanguage()->userTimeAndDate($ts, $user));
$last = $this->msg('diff')->escaped();
}
// User links
$userLink = Linker::revUserTools($rev);
// Revision text size
$size = $row->ar_len;
if (!is_null($size)) {
$stxt = Linker::formatRevisionSize($size);
}
// Edit summary
$comment = Linker::revComment($rev);
// Revision delete links
$revdlink = Linker::getRevDeleteLink($user, $rev, $this->mTargetObj);
return "<li>{$checkBox} {$revdlink} ({$last}) {$pageLink} . . {$userLink} {$stxt} {$comment}</li>";
}
示例11: contributionsLineEndingProcess
public static function contributionsLineEndingProcess(ContribsPager &$contribsPager, &$ret, $row)
{
wfProfileIn(__METHOD__);
$rev = new Revision($row);
$page = $rev->getTitle();
$page->resetArticleId($row->rev_page);
$wfMsgOptsBase = self::getMessageOptions(null, $row);
$isThread = $wfMsgOptsBase['isThread'];
$isNew = $wfMsgOptsBase['isNew'];
// Don't show useless link to people who cannot hide revisions
$del = Linker::getRevDeleteLink($contribsPager->getUser(), $rev, $page);
if ($del !== '') {
$del .= ' ';
} else {
$del = '';
}
// VOLDEV-40: remove html messages
$ret = $del;
$ret .= Linker::linkKnown($page, $contribsPager->getLanguage()->userTimeAndDate($row->rev_timestamp, $contribsPager->getUser()), [], ['oldid' => $row->rev_id]) . ' (';
if ($isNew) {
$ret .= $contribsPager->msg('diff')->escaped();
} else {
$ret .= Linker::linkKnown($page, $contribsPager->msg('diff')->escaped(), [], ['diff' => 'prev', 'oldid' => $row->rev_id]);
}
$wallMessage = new WallMessage($page);
$threadId = $wallMessage->getMessagePageId();
$threadTitle = Title::newFromText($threadId, NS_USER_WALL_MESSAGE);
$ret .= ' | ' . Linker::linkKnown($threadTitle, $contribsPager->msg('hist')->escaped(), [], ['action' => 'history']) . ') ';
if ($isThread && $isNew) {
$ret .= ChangesList::flag('newpage') . ' ';
}
if (MWNamespace::getSubject($row->page_namespace) === NS_WIKIA_FORUM_BOARD && empty($wfMsgOptsBase['articleTitleVal'])) {
$wfMsgOptsBase['articleTitleTxt'] = $contribsPager->msg('forum-recentchanges-deleted-reply-title')->text();
}
$prefix = MWNamespace::getSubject($row->page_namespace) === NS_WIKIA_FORUM_BOARD ? 'forum' : 'wall';
$ret .= $contribsPager->msg($prefix . '-contributions-line')->params($wfMsgOptsBase['articleTitle'])->rawParams(htmlspecialchars($wfMsgOptsBase['articleTitleTxt']))->params($wfMsgOptsBase['wallTitleTxt'], $wfMsgOptsBase['wallPageName'])->parse();
if (!$isNew) {
$summary = $rev->getComment();
if (empty($summary)) {
$msg = Linker::commentBlock($contribsPager->msg(static::getMessagePrefix($row->page_namespace) . '-edit')->inContentLanguage()->text());
} else {
$msg = Linker::revComment($rev, false, true);
}
$ret .= ' ' . $contribsPager->getLanguage()->getDirMark() . $msg;
}
wfProfileOut(__METHOD__);
return true;
}
示例12: getHTML
public function getHTML()
{
$difflink = $this->getDiffLink();
$revlink = $this->getRevisionLink();
$userlink = Linker::revUserLink($this->revision);
$comment = Linker::revComment($this->revision);
if ($this->isDeleted()) {
$revlink = "<span class=\"history-deleted\">{$revlink}</span>";
}
return "<li>({$difflink}) {$revlink} {$userlink} {$comment}</li>";
}
示例13: formatRow
/**
* Format a row, providing the timestamp, links to the page/history, size, user links, and a comment
*
* @param $result Result row
* @return String
*/
public function formatRow($result)
{
# Revision deletion works on revisions, so we should cast one
$row = array('comment' => $result->rc_comment, 'deleted' => $result->rc_deleted, 'user_text' => $result->rc_user_text, 'user' => $result->rc_user);
$rev = new Revision($row);
$classes = array();
$lang = $this->getLanguage();
$dm = $lang->getDirMark();
$title = Title::newFromRow($result);
$spanTime = Html::element('span', array('class' => 'mw-newpages-time'), $lang->timeanddate($result->rc_timestamp, true));
$time = Linker::linkKnown($title, $spanTime, array(), array('oldid' => $result->rc_this_oldid), array());
$query = array('redirect' => 'no');
if ($this->patrollable($result)) {
$query['rcid'] = $result->rc_id;
}
$plink = Linker::linkKnown($title, null, array('class' => 'mw-newpages-pagename'), $query, array('known'));
$histLink = Linker::linkKnown($title, wfMsgHtml('hist'), array(), array('action' => 'history'));
$hist = Html::rawElement('span', array('class' => 'mw-newpages-history'), wfMsg('parentheses', $histLink));
$length = Html::element('span', array('class' => 'mw-newpages-length'), '[' . $this->msg('nbytes')->numParams($result->length)->text() . ']');
$ulink = Linker::revUserTools($rev);
$comment = Linker::revComment($rev);
if ($this->patrollable($result)) {
$classes[] = 'not-patrolled';
}
# Add a class for zero byte pages
if ($result->length == 0) {
$classes[] = 'mw-newpages-zero-byte-page';
}
# Tags, if any. check for including due to bug 23293
if (!$this->including()) {
list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow($result->ts_tags, 'newpages');
$classes = array_merge($classes, $newClasses);
} else {
$tagDisplay = '';
}
$css = count($classes) ? ' class="' . implode(' ', $classes) . '"' : '';
# Display the old title if the namespace has been changed
$oldTitleText = '';
if ($result->page_namespace !== $result->rc_namespace) {
$oldTitleText = wfMessage('rc-old-title')->params(Title::makeTitle($result->rc_namespace, $result->rc_title)->getPrefixedText())->escaped();
}
return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
}
示例14: showDiffPage
function showDiffPage($diffOnly = false)
{
wfProfileIn(__METHOD__);
# Allow frames except in certain special cases
$out = $this->getOutput();
$out->allowClickjacking();
$out->setRobotPolicy('noindex,nofollow');
if (!$this->loadRevisionData()) {
$this->showMissingRevision();
wfProfileOut(__METHOD__);
return;
}
$user = $this->getUser();
$permErrors = $this->mNewPage->getUserPermissionsErrors('read', $user);
if ($this->mOldPage) {
# mOldPage might not be set, see below.
$permErrors = wfMergeErrorArrays($permErrors, $this->mOldPage->getUserPermissionsErrors('read', $user));
}
if (count($permErrors)) {
wfProfileOut(__METHOD__);
throw new PermissionsError('read', $permErrors);
}
# 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 (ExternalEdit::useExternalEngine($this->getContext(), 'diff')) {
//TODO: come up with a good solution for non-text content here.
// at least, the content format needs to be passed to the client somehow.
// Currently, action=raw will just fail for non-text content.
$urls = array('File' => array('Extension' => 'wiki', 'URL' => $this->mNewPage->getCanonicalURL(array('action' => 'raw', 'oldid' => $this->mOldid))), 'File2' => array('Extension' => 'wiki', 'URL' => $this->mNewPage->getCanonicalURL(array('action' => 'raw', 'oldid' => $this->mNewid))));
$externalEditor = new ExternalEdit($this->getContext(), $urls);
$externalEditor->execute();
wfProfileOut(__METHOD__);
return;
}
$rollback = '';
$undoLink = '';
$query = array();
# Carry over 'diffonly' param via navigation links
if ($diffOnly != $user->getBoolOption('diffonly')) {
$query['diffonly'] = $diffOnly;
}
# Cascade unhide param in links for easy deletion browsing
if ($this->unhide) {
$query['unhide'] = 1;
}
# Check if one of the revisions is deleted/suppressed
$deleted = $suppressed = false;
$allowed = $this->mNewRev->userCan(Revision::DELETED_TEXT, $user);
# mOldRev 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->mOldRev === false) {
$out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
$samePage = true;
$oldHeader = '';
} else {
wfRunHooks('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
$sk = $this->getSkin();
if (method_exists($sk, 'suppressQuickbar')) {
$sk->suppressQuickbar();
}
if ($this->mNewPage->equals($this->mOldPage)) {
$out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
$samePage = true;
} else {
$out->setPageTitle($this->msg('difference-title-multipage', $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText()));
$out->addSubtitle($this->msg('difference-multipage'));
$samePage = false;
}
if ($samePage && $this->mNewPage->quickUserCan('edit', $user)) {
if ($this->mNewRev->isCurrent() && $this->mNewPage->userCan('rollback', $user)) {
$out->preventClickjacking();
$rollback = '   ' . Linker::generateRollback($this->mNewRev, $this->getContext());
}
if (!$this->mOldRev->isDeleted(Revision::DELETED_TEXT) && !$this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
$undoLink = ' ' . $this->msg('parentheses')->rawParams(Html::element('a', array('href' => $this->mNewPage->getLocalUrl(array('action' => 'edit', 'undoafter' => $this->mOldid, 'undo' => $this->mNewid)), 'title' => Linker::titleAttrib('undo')), $this->msg('editundo')->text()))->escaped();
}
}
# Make "previous revision link"
if ($samePage && $this->mOldRev->getPrevious()) {
$prevlink = Linker::linkKnown($this->mOldPage, $this->msg('previousdiff')->escaped(), array('id' => 'differences-prevlink'), array('diff' => 'prev', 'oldid' => $this->mOldid) + $query);
} else {
$prevlink = ' ';
}
if ($this->mOldRev->isMinor()) {
$oldminor = ChangesList::flag('minor');
} else {
$oldminor = '';
}
$ldel = $this->revisionDeleteLink($this->mOldRev);
$oldRevisionHeader = $this->getRevisionHeader($this->mOldRev, 'complete');
$oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' . '<div id="mw-diff-otitle2">' . Linker::revUserTools($this->mOldRev, !$this->unhide) . '</div>' . '<div id="mw-diff-otitle3">' . $oldminor . Linker::revComment($this->mOldRev, !$diffOnly, !$this->unhide) . $ldel . '</div>' . '<div id="mw-diff-otitle4">' . $prevlink . '</div>';
if ($this->mOldRev->isDeleted(Revision::DELETED_TEXT)) {
$deleted = true;
// old revisions text is hidden
if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) {
$suppressed = true;
// also suppressed
}
//.........这里部分代码省略.........
示例15: historyLine
/**
* Returns a row from the history printout.
*
* @todo document some more, and maybe clean up the code (some params redundant?)
*
* @param $row Object: the database row corresponding to the previous line.
* @param $next Mixed: the database row corresponding to the next line. (chronologically previous)
* @param $notificationtimestamp
* @param $latest Boolean: whether this row corresponds to the page's latest revision.
* @param $firstInList Boolean: whether this row corresponds to the first displayed on this history page.
* @return String: HTML output for the row
*/
function historyLine($row, $next, $notificationtimestamp = false, $latest = false, $firstInList = false)
{
$rev = new Revision($row);
$rev->setTitle($this->getTitle());
if (is_object($next)) {
$prevRev = new Revision($next);
$prevRev->setTitle($this->getTitle());
} else {
$prevRev = null;
}
$curlink = $this->curLink($rev, $latest);
$lastlink = $this->lastLink($rev, $next);
$diffButtons = $this->diffButtons($rev, $firstInList);
$histLinks = Html::rawElement('span', array('class' => 'mw-history-histlinks'), '(' . $curlink . $this->historyPage->message['pipe-separator'] . $lastlink . ') ');
$s = $histLinks . $diffButtons;
$link = $this->revLink($rev);
$classes = array();
$del = '';
$user = $this->getUser();
// Show checkboxes for each revision
if ($user->isAllowed('deleterevision')) {
$this->preventClickjacking();
// If revision was hidden from sysops, disable the checkbox
if (!$rev->userCan(Revision::DELETED_RESTRICTED, $user)) {
$del = Xml::check('deleterevisions', false, array('disabled' => 'disabled'));
// Otherwise, enable the checkbox...
} else {
$del = Xml::check('showhiderevisions', false, array('name' => 'ids[' . $rev->getId() . ']'));
}
// User can only view deleted revisions...
} elseif ($rev->getVisibility() && $user->isAllowed('deletedhistory')) {
// If revision was hidden from sysops, disable the link
if (!$rev->userCan(Revision::DELETED_RESTRICTED, $user)) {
$cdel = Linker::revDeleteLinkDisabled(false);
// Otherwise, show the link...
} else {
$query = array('type' => 'revision', 'target' => $this->getTitle()->getPrefixedDbkey(), 'ids' => $rev->getId());
$del .= Linker::revDeleteLink($query, $rev->isDeleted(Revision::DELETED_RESTRICTED), false);
}
}
if ($del) {
$s .= " {$del} ";
}
$lang = $this->getLanguage();
$dirmark = $lang->getDirMark();
$s .= " {$link}";
$s .= $dirmark;
$s .= " <span class='history-user'>" . Linker::revUserTools($rev, true) . "</span>";
$s .= $dirmark;
if ($rev->isMinor()) {
$s .= ' ' . ChangesList::flag('minor');
}
# Size is always public data
$prevSize = $prevRev ? $prevRev->getSize() : 0;
$sDiff = ChangesList::showCharacterDifference($prevSize, $rev->getSize());
$fSize = Linker::formatRevisionSize($rev->getSize());
$s .= " . . {$fSize} {$sDiff} . . ";
$s .= Linker::revComment($rev, false, true);
if ($notificationtimestamp && $row->rev_timestamp >= $notificationtimestamp) {
$s .= ' <span class="updatedmarker">' . $this->msg('updatedmarker')->escaped() . '</span>';
}
$tools = array();
# Rollback and undo links
if ($prevRev && !count($this->getTitle()->getUserPermissionsErrors('edit', $this->getUser()))) {
if ($latest && !count($this->getTitle()->getUserPermissionsErrors('rollback', $this->getUser()))) {
$this->preventClickjacking();
$tools[] = '<span class="mw-rollback-link">' . Linker::buildRollbackLink($rev) . '</span>';
}
if (!$rev->isDeleted(Revision::DELETED_TEXT) && !$prevRev->isDeleted(Revision::DELETED_TEXT)) {
# Create undo tooltip for the first (=latest) line only
$undoTooltip = $latest ? array('title' => $this->msg('tooltip-undo')->text()) : array();
$undolink = Linker::linkKnown($this->getTitle(), $this->msg('editundo')->escaped(), $undoTooltip, array('action' => 'edit', 'undoafter' => $prevRev->getId(), 'undo' => $rev->getId()));
$tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
}
}
if ($tools) {
$s .= ' (' . $lang->pipeList($tools) . ')';
}
# Tags
list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow($row->ts_tags, 'history');
$classes = array_merge($classes, $newClasses);
$s .= " {$tagSummary}";
wfRunHooks('PageHistoryLineEnding', array($this, &$row, &$s, &$classes));
$attribs = array();
if ($classes) {
$attribs['class'] = implode(' ', $classes);
}
return Xml::tags('li', $attribs, $s) . "\n";
//.........这里部分代码省略.........