X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=5c33c75e12e5303be0d5242bded4bf4a5bd1b33a;hb=252ef37028af515326bf281bf40ad80792540a2d;hp=88b182e140952de411fa47c1da038db4d1d4ae39;hpb=5acfd2e095dae1b5fbbd7506f907a9ee5072a84f;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Article.php b/includes/Article.php
index 88b182e140..5c33c75e12 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -135,7 +135,7 @@ class Article {
* @return mixed false, Title of in-wiki target, or string with URL
*/
public function followRedirectText( $text ) {
- $rt = Title::newFromRedirect( $text );
+ $rt = Title::newFromRedirectRecurse( $text ); // recurse through to only get the final target
# process if title object is valid and not special:userlogout
if( $rt ) {
if( $rt->getInterwiki() != '' ) {
@@ -218,7 +218,7 @@ class Article {
if( wfEmptyMsg( $message, $text ) )
$text = '';
} else {
- $text = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
+ $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
}
wfProfileOut( __METHOD__ );
return $text;
@@ -228,6 +228,21 @@ class Article {
return $this->mContent;
}
}
+
+ /**
+ * Get the text of the current revision. No side-effects...
+ *
+ * @return Return the text of the current revision
+ */
+ public function getRawText() {
+ // Check process cache for current revision
+ if( $this->mContentLoaded && $this->mOldId == 0 ) {
+ return $this->mContent;
+ }
+ $rev = Revision::newFromTitle( $this->mTitle );
+ $text = $rev ? $rev->getRawText() : false;
+ return $text;
+ }
/**
* This function returns the text of a section, specified by a number ($section).
@@ -245,6 +260,28 @@ class Article {
global $wgParser;
return $wgParser->getSection( $text, $section );
}
+
+ /**
+ * Get the text that needs to be saved in order to undo all revisions
+ * between $undo and $undoafter. Revisions must belong to the same page,
+ * must exist and must not be deleted
+ * @param $undo Revision
+ * @param $undoafter Revision Must be an earlier revision than $undo
+ * @return mixed string on success, false on failure
+ */
+ public function getUndoText( Revision $undo, Revision $undoafter = null ) {
+ $undo_text = $undo->getText();
+ $undoafter_text = $undoafter->getText();
+ $cur_text = $this->getContent();
+ if ( $cur_text == $undo_text ) {
+ # No use doing a merge if it's just a straight revert.
+ return $undoafter_text;
+ }
+ $undone_text = '';
+ if ( !wfMerge( $undo_text, $undoafter_text, $cur_text, $undone_text ) )
+ return false;
+ return $undone_text;
+ }
/**
* @return int The oldid of the article that is to be shown, 0 for the
@@ -369,11 +406,9 @@ class Article {
$lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
$this->mTitle->mArticleID = $data->page_id;
- $this->mTitle->mTouched = wfTimestamp( TS_MW, $data->page_touched );
# Old-fashioned restrictions
- if( $data->page_restrictions )
- $this->mTitle->loadRestrictions( $data->page_restrictions );
+ $this->mTitle->loadRestrictions( $data->page_restrictions );
$this->mCounter = $data->page_counter;
$this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
@@ -510,6 +545,18 @@ class Article {
public function exists() {
return $this->getId() > 0;
}
+
+ /**
+ * Check if this page is something we're going to be showing
+ * some sort of sensible content for. If we return false, page
+ * views (plain action=view) will return an HTTP 404 response,
+ * so spiders and robots can know they're following a bad link.
+ *
+ * @return bool
+ */
+ public function hasViewableContent() {
+ return $this->exists() || $this->mTitle->isAlwaysKnown();
+ }
/**
* @return int The view count for the page
@@ -559,7 +606,7 @@ class Article {
}
// Apparently loadPageData was never called
$this->loadContent();
- $titleObj = Title::newFromRedirect( $this->fetchContent() );
+ $titleObj = Title::newFromRedirectRecurse( $this->fetchContent() );
} else {
$titleObj = Title::newFromRedirect( $text );
}
@@ -679,16 +726,17 @@ class Article {
wfProfileIn( __METHOD__ );
- $parserCache = ParserCache::singleton();
- $ns = $this->mTitle->getNamespace(); # shortcut
-
# Get variables from query string
$oldid = $this->getOldID();
# Try file cache
if( $oldid === 0 && $this->checkTouched() ) {
- $wgOut->setETag( $parserCache->getETag($this,$wgUser) );
- if( $wgOut->checkLastModified( $this->getTouched() ) ){
+ 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() ) {
@@ -700,6 +748,7 @@ class Article {
}
}
+ $ns = $this->mTitle->getNamespace(); # shortcut
$sk = $wgUser->getSkin();
# getOldID may want us to redirect somewhere else
@@ -714,6 +763,7 @@ class Article {
$rdfrom = $wgRequest->getVal( 'rdfrom' );
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
$purge = $wgRequest->getVal( 'action' ) == 'purge';
+ $return404 = false;
$wgOut->setArticleFlag( true );
@@ -730,15 +780,17 @@ class Article {
}
$wgOut->setRobotPolicy( $policy );
+ # Allow admins to see deleted content if explicitly requested
+ $delId = $diff ? $diff : $oldid;
+ $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $delId );
# 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);
+ $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff, $unhide );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage( $diffOnly );
@@ -752,6 +804,16 @@ class Article {
wfProfileOut( __METHOD__ );
return;
}
+
+ if( $ns == NS_USER || $ns == NS_USER_TALK ) {
+ # User/User_talk subpages are not modified. (bug 11443)
+ if( !$this->mTitle->isSubpage() ) {
+ $block = new Block();
+ if( $block->load( $this->mTitle->getBaseText() ) ) {
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ }
+ }
+ }
# Should the parser cache be used?
$pcache = $this->useParserCache( $oldid );
@@ -766,7 +828,7 @@ class Article {
// We'll need a backlink to the source page for navigation.
if( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
$redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' );
- $s = wfMsg( 'redirectedfrom', $redir );
+ $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
$wgOut->setSubtitle( $s );
// Set the fragment if one was specified in the redirect
@@ -782,7 +844,7 @@ class Article {
global $wgRedirectSources;
if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
$redir = $sk->makeExternalLink( $rdfrom, $rdfrom );
- $s = wfMsg( 'redirectedfrom', $redir );
+ $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
$wgOut->setSubtitle( $s );
$wasRedirected = true;
}
@@ -803,29 +865,48 @@ class Article {
$this->showDeletionLog();
}
$text = $this->getContent();
- if( $text === false ) {
+ // For now, check also for ID until getContent actually returns
+ // false for pages that do not exists
+ if( $text === false || $this->getID() === 0 ) {
# 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' );
+ $d = wfMsgExt( 'missingarticle-rev', 'escape', $oldid );
+ $text = wfMsgExt( 'missing-article', 'parsemag', $t, $d );
+ // Always use page content for pages in the MediaWiki namespace
+ // since it contains the default message
+ } elseif ( $this->mTitle->getNamespace() != NS_MEDIAWIKI ) {
+ $text = wfMsgExt( 'noarticletext', 'parsemag' );
}
}
+
# Non-existent pages
if( $this->getID() === 0 ) {
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$text = "
" .
wfMsgHtml( 'markaspatrolledlink',
@@ -975,24 +1057,41 @@ class Article {
/**
* View redirect
- * @param $target Title object of destination to redirect
+ * @param $target Title object or Array of destination(s) to redirect
* @param $appendSubtitle Boolean [optional]
* @param $forceKnown Boolean: should the image be shown as a bluelink regardless of existence?
*/
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
# Display redirect
+ if( !is_array( $target ) ) {
+ $target = array( $target );
+ }
$imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
- $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
-
+ $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
+ $imageUrl2 = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
+ $alt2 = $wgContLang->isRTL() ? '←' : '→'; // should -> and <- be used instead of entities?
+
if( $appendSubtitle ) {
$wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
}
$sk = $wgUser->getSkin();
+ // the loop prepends the arrow image before the link, so the first case needs to be outside
+ $title = array_shift( $target );
if( $forceKnown ) {
- $link = $sk->makeKnownLinkObj( $target, htmlspecialchars( $target->getFullText() ) );
+ $link = $sk->makeKnownLinkObj( $title, htmlspecialchars( $title->getFullText() ) );
} else {
- $link = $sk->makeLinkObj( $target, htmlspecialchars( $target->getFullText() ) );
+ $link = $sk->makeLinkObj( $title, htmlspecialchars( $title->getFullText() ) );
+ }
+ // automatically append redirect=no to each link, since most of them are redirect pages themselves
+ foreach( $target as $rt ) {
+ if( $forceKnown ) {
+ $link .= '
'
+ . $sk->makeKnownLinkObj( $rt, htmlspecialchars( $rt->getFullText() ) );
+ } else {
+ $link .= '
'
+ . $sk->makeLinkObj( $rt, htmlspecialchars( $rt->getFullText() ) );
+ }
}
return '
' .
'
'.$link.'';
@@ -1100,7 +1199,7 @@ class Article {
if( $this->getID() == 0 ) {
$text = false;
} else {
- $text = $this->getContent();
+ $text = $this->getRawText();
}
$wgMessageCache->replace( $this->mTitle->getDBkey(), $text );
}
@@ -1265,11 +1364,12 @@ class Article {
}
/**
+ * @param $section empty/null/false or a section number (0, 1, 2, T1, T2...)
* @return string Complete article text, or null if error
*/
public function replaceSection( $section, $text, $summary = '', $edittime = NULL ) {
wfProfileIn( __METHOD__ );
- if( $section === '' ) {
+ if( strval( $section ) == '' ) {
// Whole-page edit; let the whole text through
} else {
if( is_null($edittime) ) {
@@ -1461,7 +1561,7 @@ class Article {
$isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed('minoredit');
$bot = $flags & EDIT_FORCE_BOT;
- $oldtext = $this->getContent();
+ $oldtext = $this->getRawText(); // current revision
$oldsize = strlen( $oldtext );
# Provide autosummaries if one is not provided and autosummaries are enabled.
@@ -1538,7 +1638,7 @@ class Article {
# Update recentchanges
if( !( $flags & EDIT_SUPPRESS_RC ) ) {
# Mark as patrolled if the user can do so
- $patrolled = $wgUseRCPatrol && $user->isAllowed('autopatrol');
+ $patrolled = $wgUseRCPatrol && $this->mTitle->userCan('autopatrol');
# Add RC row to the DB
$rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
$this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
@@ -1620,7 +1720,7 @@ class Article {
if( !( $flags & EDIT_SUPPRESS_RC ) ) {
global $wgUseRCPatrol, $wgUseNPPatrol;
# Mark as patrolled if the user can do so
- $patrolled = ($wgUseRCPatrol || $wgUseNPPatrol) && $user->isAllowed('autopatrol');
+ $patrolled = ($wgUseRCPatrol || $wgUseNPPatrol) && $this->mTitle->userCan('autopatrol');
# Add RC row to the DB
$rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
'', strlen($text), $revisionId, $patrolled );
@@ -1701,8 +1801,8 @@ class Article {
}
#It would be nice to see where the user had actually come from, but for now just guess
- $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'Newpages' : 'Recentchanges';
- $return = Title::makeTitle( NS_SPECIAL, $returnto );
+ $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'newpages' : 'recentchanges';
+ $return = SpecialPage::getTitleFor( $returnto );
$dbw = wfGetDB( DB_MASTER );
$errors = $rc->doMarkPatrolled();
@@ -1830,11 +1930,11 @@ class Article {
*
* @param $limit Array: set of restriction keys
* @param $reason String
- * @param $cascade Integer
+ * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
* @param $expiry Array: per restriction type expiration
* @return bool true on success
*/
- public function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) {
+ public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
global $wgUser, $wgRestrictionTypes, $wgContLang;
$id = $this->mTitle->getArticleID();
@@ -1855,13 +1955,24 @@ class Article {
$updated = Article::flattenRestrictions( $limit );
$changed = false;
foreach( $wgRestrictionTypes as $action ) {
- $current[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
- $changed = ($changed || ($this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) );
+ if( isset( $expiry[$action] ) ) {
+ # Get current restrictions on $action
+ $aLimits = $this->mTitle->getRestrictions( $action );
+ $current[$action] = implode( '', $aLimits );
+ # Are any actual restrictions being dealt with here?
+ $aRChanged = count($aLimits) || !empty($limit[$action]);
+ # If something changed, we need to log it. Checking $aRChanged
+ # assures that "unprotecting" a page that is not protected does
+ # not log just because the expiry was "changed".
+ if( $aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action] ) {
+ $changed = true;
+ }
+ }
}
$current = Article::flattenRestrictions( $current );
- $changed = ($changed || ( $current != $updated ) );
+ $changed = ($changed || $current != $updated );
$changed = $changed || ($updated && $this->mTitle->areRestrictionsCascading() != $cascade);
$protect = ( $updated != '' );
@@ -1882,13 +1993,10 @@ class Article {
# Only restrictions with the 'protect' right can cascade...
# Otherwise, people who cannot normally protect can "protect" pages via transclusion
- foreach( $limit as $action => $restriction ) {
- # FIXME: can $restriction be an array or what? (same as fixme above)
- if( $restriction != 'protect' && $restriction != 'sysop' ) {
- $cascade = false;
- break;
- }
- }
+ $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
+ # The schema allows multiple restrictions
+ if(!in_array('protect', $editrestriction) && !in_array('sysop', $editrestriction))
+ $cascade = false;
$cascade_description = '';
if( $cascade ) {
$cascade_description = ' ['.wfMsgForContent('protect-summary-cascade').']';
@@ -1906,7 +2014,9 @@ class Article {
$protect_description .= "[$action=$restrictions] (";
if( $encodedExpiry[$action] != 'infinity' ) {
$protect_description .= wfMsgForContent( 'protect-expiring',
- $wgContLang->timeanddate( $expiry[$action], false, false ) );
+ $wgContLang->timeanddate( $expiry[$action], false, false ) ,
+ $wgContLang->date( $expiry[$action], false, false ) ,
+ $wgContLang->time( $expiry[$action], false, false ) );
} else {
$protect_description .= wfMsgForContent( 'protect-expiry-indefinite' );
}
@@ -2083,14 +2193,14 @@ class Article {
$reason = $this->DeleteReasonList;
- if( $reason != 'other' && $this->DeleteReason != '') {
+ if( $reason != 'other' && $this->DeleteReason != '' ) {
// Entry from drop down menu + additional comment
- $reason .= ': ' . $this->DeleteReason;
+ $reason .= wfMsgForContent( 'colon-separator' ) . $this->DeleteReason;
} elseif( $reason == 'other' ) {
$reason = $this->DeleteReason;
}
# Flag to hide all contents of the archived revisions
- $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('suppressrevision');
+ $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
# This code desperately needs to be totally rewritten
@@ -2103,7 +2213,7 @@ class Article {
# Check permissions
$permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
- if(count($permission_errors)>0) {
+ if( count( $permission_errors ) > 0 ) {
$wgOut->showPermissionsErrorPage( $permission_errors );
return;
}
@@ -2115,7 +2225,9 @@ class Article {
$conds = $this->mTitle->pageCond();
$latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
if( $latest === false ) {
- $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
+ $wgOut->showFatalError( wfMsgExt( 'cannotdelete', array( 'parse' ) ) );
+ $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() );
return;
}
@@ -2144,8 +2256,8 @@ class Article {
// If the page has a history, insert a warning
if( $hasHistory && !$confirm ) {
- $skin=$wgUser->getSkin();
- $wgOut->addHTML( '
' . wfMsg( 'historywarning' ) . ' ' . $skin->historyLink() . '' );
+ $skin = $wgUser->getSkin();
+ $wgOut->addHTML( '
' . wfMsgExt( 'historywarning', array( 'parseinline' ) ) . ' ' . $skin->historyLink() . '' );
if( $bigHistory ) {
global $wgLang, $wgDeleteRevisionsLimit;
$wgOut->wrapWikiMsg( "
\n$1
\n",
@@ -2234,7 +2346,7 @@ class Article {
wfDebug( "Article::confirmDelete\n" );
- $wgOut->setSubtitle( wfMsg( 'delete-backlink', $wgUser->getSkin()->makeKnownLinkObj( $this->mTitle ) ) );
+ $wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $wgUser->getSkin()->makeKnownLinkObj( $this->mTitle ) ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'confirmdeletetext' );
@@ -2326,10 +2438,13 @@ class Article {
$wgOut->returnToMain( false );
wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id));
} else {
- if( $error == '' )
- $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
- else
+ if( $error == '' ) {
+ $wgOut->showFatalError( wfMsgExt( 'cannotdelete', array( 'parse' ) ) );
+ $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() );
+ } else {
$wgOut->showFatalError( $error );
+ }
}
}
}
@@ -2354,7 +2469,7 @@ class Article {
return false;
}
- $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getContent() ), -1 );
+ $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getRawText() ), -1 );
array_push( $wgDeferredUpdateList, $u );
// Bitfields to further suppress the content
@@ -2616,7 +2731,7 @@ class Article {
$revId = false;
}
- wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target ) );
+ wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target, $current ) );
$resultDetails = array(
'summary' => $summary,
@@ -2702,16 +2817,13 @@ class Article {
/**
* Do standard deferred updates after page view
*/
- protected function viewUpdates() {
- global $wgDeferredUpdateList, $wgUser;
- if( 0 != $this->getID() ) {
- # Don't update page view counters on views from bot users (bug 14044)
- global $wgDisableCounters;
- if( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) ) {
- Article::incViewCount( $this->getID() );
- $u = new SiteStatsUpdate( 1, 0, 0 );
- array_push( $wgDeferredUpdateList, $u );
- }
+ public function viewUpdates() {
+ global $wgDeferredUpdateList, $wgDisableCounters, $wgUser;
+ # Don't update page view counters on views from bot users (bug 14044)
+ if( !$wgDisableCounters && !$wgUser->isAllowed('bot') && $this->getID() ) {
+ Article::incViewCount( $this->getID() );
+ $u = new SiteStatsUpdate( 1, 0, 0 );
+ array_push( $wgDeferredUpdateList, $u );
}
# Update newtalk / watchlist notification status
$wgUser->clearNotification( $this->mTitle );
@@ -2861,10 +2973,10 @@ class Article {
*
* @param $oldid String: revision ID of this article revision
*/
- public function setOldSubtitle( $oldid=0 ) {
- global $wgLang, $wgOut, $wgUser;
+ public function setOldSubtitle( $oldid = 0 ) {
+ global $wgLang, $wgOut, $wgUser, $wgRequest;
- if( !wfRunHooks( 'DisplayOldSubtitle', array(&$this, &$oldid) ) ) {
+ if( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
return;
}
@@ -2874,34 +2986,34 @@ class Article {
$td = $wgLang->timeanddate( $this->mTimestamp, true );
$sk = $wgUser->getSkin();
$lnk = $current
- ? wfMsg( 'currentrevisionlink' )
- : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'currentrevisionlink' ) );
+ ? wfMsgHtml( 'currentrevisionlink' )
+ : $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'currentrevisionlink' ) );
$curdiff = $current
- ? wfMsg( 'diff' )
- : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=cur&oldid='.$oldid );
+ ? wfMsgHtml( 'diff' )
+ : $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'diff' ), 'diff=cur&oldid='.$oldid );
$prev = $this->mTitle->getPreviousRevisionID( $oldid ) ;
$prevlink = $prev
- ? $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'previousrevision' ), 'direction=prev&oldid='.$oldid )
- : wfMsg( 'previousrevision' );
+ ? $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'previousrevision' ), 'direction=prev&oldid='.$oldid )
+ : wfMsgHtml( 'previousrevision' );
$prevdiff = $prev
- ? $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=prev&oldid='.$oldid )
- : wfMsg( 'diff' );
+ ? $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'diff' ), 'diff=prev&oldid='.$oldid )
+ : wfMsgHtml( 'diff' );
$nextlink = $current
- ? wfMsg( 'nextrevision' )
- : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'nextrevision' ), 'direction=next&oldid='.$oldid );
+ ? wfMsgHtml( 'nextrevision' )
+ : $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextrevision' ), 'direction=next&oldid='.$oldid );
$nextdiff = $current
- ? wfMsg( 'diff' )
- : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=next&oldid='.$oldid );
+ ? wfMsgHtml( 'diff' )
+ : $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'diff' ), 'diff=next&oldid='.$oldid );
$cdel='';
if( $wgUser->isAllowed( 'deleterevision' ) ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
if( $revision->isCurrent() ) {
// We don't handle top deleted edits too well
- $cdel = wfMsgHtml('rev-delundel');
+ $cdel = wfMsgHtml( 'rev-delundel' );
} else if( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
// If revision was hidden from sysops
- $cdel = wfMsgHtml('rev-delundel');
+ $cdel = wfMsgHtml( 'rev-delundel' );
} else {
$cdel = $sk->makeKnownLinkObj( $revdel,
wfMsgHtml('rev-delundel'),
@@ -2913,18 +3025,19 @@ class Article {
}
$cdel = "(
$cdel) ";
}
- # Show user links if allowed to see them. Normally they
- # are hidden regardless, but since we can already see the text here...
- $userlinks = $sk->revUserTools( $revision, false );
+ $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $oldid );
+ # Show user links if allowed to see them. If hidden, then show them only if requested...
+ $userlinks = $sk->revUserTools( $revision, !$unhide );
$m = wfMsg( 'revision-info-current' );
$infomsg = $current && !wfEmptyMsg( 'revision-info-current', $m ) && $m != '-'
? 'revision-info-current'
: 'revision-info';
- $r = "\n\t\t\t\t
" . wfMsg( $infomsg, $td, $userlinks, $revision->getID() ) . "
\n" .
+ $r = "\n\t\t\t\t
" . wfMsgExt( $infomsg, array( 'parseinline', 'replaceafter' ),
+ $td, $userlinks, $revision->getID() ) . "
\n" .
- "\n\t\t\t\t
" . $cdel . wfMsg( 'revision-nav', $prevdiff,
+ "\n\t\t\t\t
" . $cdel . wfMsgHtml( 'revision-nav', $prevdiff,
$prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "
\n\t\t\t";
$wgOut->setSubtitle( $r );
}
@@ -2975,31 +3088,14 @@ class Article {
* @return bool
*/
public function isFileCacheable() {
- global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest, $wgLang, $wgContLang;
- // Get all query values
- $queryVals = $wgRequest->getValues();
- foreach( $queryVals as $query => $val ) {
- // Normal page view in query form can have action=view
- if( $query !== 'title' && $query !== 'curid' && !($query == 'action' && $val == 'view') ) {
- return false;
+ $cacheable = false;
+ if( HTMLFileCache::useFileCache() ) {
+ $cacheable = $this->getID() && !$this->mRedirectedFrom;
+ // Extension may have reason to disable file caching on some pages.
+ if( $cacheable ) {
+ $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
}
}
- // Check for non-standard user language; this covers uselang,
- // and extensions for auto-detecting user language.
- $ulang = $wgLang->getCode();
- $clang = $wgContLang->getCode();
-
- $cacheable = $wgUseFileCache
- && !$wgShowIPinHeader
- && $this->getID() > 0
- && $wgUser->isAnon()
- && !$wgUser->getNewtalk()
- && !$this->mRedirectedFrom
- && $ulang === $clang;
- // Extension may have reason to disable file caching on some pages.
- if( $cacheable ) {
- $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
- }
return $cacheable;
}
@@ -3152,7 +3248,7 @@ class Article {
}
public static function onArticleDelete( $title ) {
- global $wgUseFileCache, $wgMessageCache;
+ global $wgMessageCache;
# Update existence markers on article/talk tabs...
if( $title->isTalkPage() ) {
$other = $title->getSubjectPage();
@@ -3166,10 +3262,7 @@ class Article {
$title->purgeSquid();
# File cache
- if( $wgUseFileCache ) {
- $cm = new HTMLFileCache( $title );
- @unlink( $cm->fileCacheName() );
- }
+ HTMLFileCache::clearFileCache( $title );
# Messages
if( $title->getNamespace() == NS_MEDIAWIKI ) {
@@ -3191,7 +3284,7 @@ class Article {
* Purge caches on page update etc
*/
public static function onArticleEdit( $title, $transclusions = 'transclusions' ) {
- global $wgDeferredUpdateList, $wgUseFileCache;
+ global $wgDeferredUpdateList;
// Invalidate caches of articles which include this page
if( $transclusions !== 'skiptransclusions' )
@@ -3204,10 +3297,7 @@ class Article {
$title->purgeSquid();
# Clear file cache for this page only
- if( $wgUseFileCache ) {
- $cm = new HTMLFileCache( $title );
- @unlink( $cm->fileCacheName() );
- }
+ HTMLFileCache::clearFileCache( $title );
}
/**#@-*/
@@ -3237,7 +3327,7 @@ class Article {
$wgOut->setPagetitle( $page->getPrefixedText() );
$wgOut->setPageTitleActionText( wfMsg( 'info_short' ) );
- $wgOut->setSubtitle( wfMsg( 'infosubtitle' ) );
+ $wgOut->setSubtitle( wfMsgHtml( 'infosubtitle' ) );
if( !$this->mTitle->exists() ) {
$wgOut->addHTML( '
' );