X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=68290a6291b48a3e209900e53bd65888b4700d28;hb=bbd225e01312fd56845d8fbf650aa3cd184bb731;hp=8290f21da026961984c45fd9f70c7f0ef66b3162;hpb=33f66d157b96ee10db0c18122179db8ca89627a7;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Article.php b/includes/Article.php
index 8290f21da0..68290a6291 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -17,7 +17,12 @@ class Article {
/**@{{
* @private
*/
- var $mComment = ''; // !<
+
+ /**
+ * @var RequestContext
+ */
+ protected $mContext;
+
var $mContent; // !<
var $mContentLoaded = false; // !<
var $mCounter = -1; // !< Not loaded
@@ -26,22 +31,50 @@ class Article {
var $mGoodAdjustment = 0; // !<
var $mIsRedirect = false; // !<
var $mLatest = false; // !<
- var $mMinorEdit; // !<
var $mOldId; // !<
- var $mPreparedEdit = false; // !< Title object if set
- var $mRedirectedFrom = null; // !< Title object if set
- var $mRedirectTarget = null; // !< Title object if set
+ var $mPreparedEdit = false;
+
+ /**
+ * @var Title
+ */
+ var $mRedirectedFrom = null;
+
+ /**
+ * @var Title
+ */
+ var $mRedirectTarget = null;
+
+ /**
+ * @var Title
+ */
var $mRedirectUrl = false; // !<
var $mRevIdFetched = 0; // !<
- var $mRevision = null; // !< Revision object if set
+
+ /**
+ * @var Revision
+ */
+ var $mLastRevision = null;
+
+ /**
+ * @var Revision
+ */
+ var $mRevision = null;
+
var $mTimestamp = ''; // !<
var $mTitle; // !< Title object
var $mTotalAdjustment = 0; // !<
var $mTouched = '19700101000000'; // !<
- var $mUser = -1; // !< Not loaded
- var $mUserText = ''; // !< username from Revision if set
- var $mParserOptions; // !< ParserOptions object for $wgUser articles
- var $mParserOutput; // !< ParserCache object if set
+
+ /**
+ * @var ParserOptions
+ */
+ var $mParserOptions;
+
+ /**
+ * @var ParserOutput
+ */
+ var $mParserOutput;
+
/**@}}*/
/**
@@ -159,7 +192,7 @@ class Article {
*
* @param $text string article content containing redirect info
* @return mixed false, Title of in-wiki target, or string with URL
- * @deprecated @since 1.17
+ * @deprecated since 1.17
*/
public function followRedirectText( $text ) {
// recurse through to only get the final target
@@ -223,11 +256,11 @@ class Article {
$this->mDataLoaded = false;
$this->mContentLoaded = false;
- $this->mUser = $this->mCounter = -1; # Not loaded
+ $this->mCounter = -1; # Not loaded
$this->mRedirectedFrom = null; # Title object if set
$this->mRedirectTarget = null; # Title object if set
- $this->mUserText =
- $this->mTimestamp = $this->mComment = '';
+ $this->mLastRevision = null; # Latest revision
+ $this->mTimestamp = '';
$this->mGoodAdjustment = $this->mTotalAdjustment = 0;
$this->mTouched = '19700101000000';
$this->mForUpdate = false;
@@ -292,23 +325,6 @@ class Article {
return $text;
}
- /**
- * This function returns the text of a section, specified by a number ($section).
- * A section is text under a heading like == Heading == or \
" .
wfMsgHtml(
'markaspatrolledlink',
- $sk->link(
+ Linker::link(
$this->mTitle,
wfMsgHtml( 'markaspatrolledtext' ),
array(),
@@ -1405,7 +1441,7 @@ class Article {
if ( !$this->hasViewableContent() ) {
// If there's no backing content, send a 404 Not Found
// for better machine handling of broken links.
- $wgRequest->response()->header( "HTTP/1.x 404 Not Found" );
+ $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
}
$wgOut->addWikiText( $text );
@@ -1537,7 +1573,7 @@ class Article {
* @return string containing HMTL with redirect link
*/
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
- global $wgOut, $wgContLang, $wgStylePath, $wgUser;
+ global $wgOut, $wgContLang, $wgStylePath;
if ( !is_array( $target ) ) {
$target = array( $target );
@@ -1549,14 +1585,13 @@ class Article {
$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->linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
+ $link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
} else {
- $link = $sk->link( $title, htmlspecialchars( $title->getFullText() ) );
+ $link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) );
}
$nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
@@ -1565,9 +1600,9 @@ class Article {
foreach ( $target as $rt ) {
$link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
if ( $forceKnown ) {
- $link .= $sk->linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
+ $link .= Linker::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
} else {
- $link .= $sk->link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
+ $link .= Linker::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
}
}
@@ -1581,7 +1616,7 @@ class Article {
* Builds trackback links for article display if $wgUseTrackbacks is set to true
*/
public function addTrackbacks() {
- global $wgOut, $wgUser;
+ global $wgOut;
$dbr = wfGetDB( DB_SLAVE );
$tbs = $dbr->select( 'trackbacks',
@@ -1599,9 +1634,9 @@ class Article {
foreach ( $tbs as $o ) {
$rmvtxt = "";
- if ( $wgUser->isAllowed( 'trackback' ) ) {
+ if ( $wgOut->getUser()->isAllowed( 'trackback' ) ) {
$delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" .
- $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) );
+ $o->tb_id . "&token=" . urlencode( $wgOut->getUser()->editToken() ) );
$rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
}
@@ -1621,15 +1656,15 @@ class Article {
* Removes trackback record for current article from trackbacks table
*/
public function deletetrackback() {
- global $wgUser, $wgRequest, $wgOut;
+ global $wgRequest, $wgOut;
- if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
+ if ( !$wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
$wgOut->addWikiMsg( 'sessionfailure' );
return;
}
- $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() );
if ( count( $permission_errors ) ) {
$wgOut->showPermissionsErrorPage( $permission_errors );
@@ -1659,32 +1694,7 @@ class Article {
* Handle action=purge
*/
public function purge() {
- global $wgUser, $wgRequest, $wgOut;
-
- if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
- //FIXME: shouldn't this be in doPurge()?
- if ( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
- $this->doPurge();
- $this->view();
- }
- } else {
- $formParams = array(
- 'method' => 'post',
- 'action' => $wgRequest->getRequestURL(),
- );
-
- $wgOut->addWikiMsg( 'confirm-purge-top' );
-
- $form = Html::openElement( 'form', $formParams );
- $form .= Xml::submitButton( wfMsg( 'confirm_purge_button' ) );
- $form .= Html::closeElement( 'form' );
-
- $wgOut->addHTML( $form );
- $wgOut->addWikiMsg( 'confirm-purge-bottom' );
-
- $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
- }
+ return Action::factory( 'purge', $this )->show();
}
/**
@@ -1693,6 +1703,10 @@ class Article {
public function doPurge() {
global $wgUseSquid;
+ if( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ){
+ return false;
+ }
+
// Invalidate the cache
$this->mTitle->invalidateCache();
$this->clear();
@@ -1770,12 +1784,10 @@ class Article {
* on.
* @param $lastRevIsRedirect Boolean: if given, will optimize adding and
* removing rows in redirect table.
- * @param $setNewFlag Boolean: Set to true if a page flag should be set
- * Needed when $lastRevision has to be set to sth. !=0
* @return bool true on success, false on failure
* @private
*/
- public function updateRevisionOn( &$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null, $setNewFlag = false ) {
+ public function updateRevisionOn( &$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
wfProfileIn( __METHOD__ );
$text = $revision->getText();
@@ -1788,15 +1800,11 @@ class Article {
$conditions['page_latest'] = $lastRevision;
}
- if ( !$setNewFlag ) {
- $setNewFlag = ( $lastRevision === 0 );
- }
-
$dbw->update( 'page',
array( /* SET */
'page_latest' => $revision->getId(),
'page_touched' => $dbw->timestamp(),
- 'page_is_new' => $setNewFlag,
+ 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
'page_is_redirect' => $rt !== null ? 1 : 0,
'page_len' => strlen( $text ),
),
@@ -1815,7 +1823,7 @@ class Article {
/**
* Add row to the redirect table if this is a redirect, remove otherwise.
*
- * @param $dbw Database
+ * @param $dbw DatabaseBase
* @param $redirectTitle Title object pointing to the redirect target,
* or NULL if this is not a redirect
* @param $lastRevIsRedirect If given, will optimize adding and
@@ -1935,78 +1943,6 @@ class Article {
return $text;
}
- /**
- * @deprecated @since 1.7 use Article::doEdit()
- */
- function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC = false, $comment = false, $bot = false ) {
- wfDeprecated( __METHOD__ );
-
- $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
- ( $isminor ? EDIT_MINOR : 0 ) |
- ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) |
- ( $bot ? EDIT_FORCE_BOT : 0 );
-
- # If this is a comment, add the summary as headline
- if ( $comment && $summary != "" ) {
- $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text;
- }
- $this->doEdit( $text, $summary, $flags );
-
- $dbw = wfGetDB( DB_MASTER );
- if ( $watchthis ) {
- if ( !$this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doWatch();
- $dbw->commit();
- }
- } else {
- if ( $this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doUnwatch();
- $dbw->commit();
- }
- }
- $this->doRedirect( $this->isRedirect( $text ) );
- }
-
- /**
- * @deprecated @since 1.7 use Article::doEdit()
- */
- function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
- wfDeprecated( __METHOD__ );
-
- $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
- ( $minor ? EDIT_MINOR : 0 ) |
- ( $forceBot ? EDIT_FORCE_BOT : 0 );
-
- $status = $this->doEdit( $text, $summary, $flags );
-
- if ( !$status->isOK() ) {
- return false;
- }
-
- $dbw = wfGetDB( DB_MASTER );
- if ( $watchthis ) {
- if ( !$this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doWatch();
- $dbw->commit();
- }
- } else {
- if ( $this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doUnwatch();
- $dbw->commit();
- }
- }
-
- $extraQuery = ''; // Give extensions a chance to modify URL query on update
- wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) );
-
- $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery );
- return true;
- }
-
/**
* Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
* @param $flags Int
@@ -2346,14 +2282,14 @@ class Article {
* Mark this particular edit/page as patrolled
*/
public function markpatrolled() {
- global $wgOut, $wgUser, $wgRequest;
+ global $wgOut, $wgRequest;
$wgOut->setRobotPolicy( 'noindex,nofollow' );
# If we haven't been given an rc_id value, we can't do anything
$rcid = (int) $wgRequest->getVal( 'rcid' );
- if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) {
+ if ( !$wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) {
$wgOut->showErrorPage( 'sessionfailure-title', 'sessionfailure' );
return;
}
@@ -2385,7 +2321,7 @@ class Article {
if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) {
$wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) );
$wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
- $wgOut->returnToMain( false, $return );
+ $wgOut->returnToMain( null, $return );
return;
}
@@ -2399,32 +2335,15 @@ class Article {
# Inform the user
$wgOut->setPageTitle( wfMsg( 'markedaspatrolled' ) );
$wgOut->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
- $wgOut->returnToMain( false, $return );
+ $wgOut->returnToMain( null, $return );
}
/**
* User-interface handler for the "watch" action
+ * @deprecated since 1.18
*/
public function watch() {
- global $wgUser, $wgOut;
-
- if ( $wgUser->isAnon() ) {
- $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
- return;
- }
-
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
-
- if ( $this->doWatch() ) {
- $wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
- $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
- }
-
- $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
+ Action::factory( 'watch', $this )->show();
}
/**
@@ -2433,64 +2352,27 @@ class Article {
* This is safe to be called multiple times
*
* @return bool true on successful watch operation
+ * @deprecated since 1.18
*/
public function doWatch() {
- global $wgUser;
-
- if ( $wgUser->isAnon() ) {
- return false;
- }
-
- if ( wfRunHooks( 'WatchArticle', array( &$wgUser, &$this ) ) ) {
- $wgUser->addWatch( $this->mTitle );
- return wfRunHooks( 'WatchArticleComplete', array( &$wgUser, &$this ) );
- }
-
- return false;
+ return Action::factory( 'watch', $this )->execute();
}
/**
* User interface handler for the "unwatch" action.
+ * @deprecated since 1.18
*/
public function unwatch() {
- global $wgUser, $wgOut;
-
- if ( $wgUser->isAnon() ) {
- $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
- return;
- }
-
- if ( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
-
- if ( $this->doUnwatch() ) {
- $wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
- $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
- }
-
- $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
+ Action::factory( 'unwatch', $this )->show();
}
/**
* Stop watching a page
* @return bool true on successful unwatch
+ * @deprecated since 1.18
*/
public function doUnwatch() {
- global $wgUser;
-
- if ( $wgUser->isAnon() ) {
- return false;
- }
-
- if ( wfRunHooks( 'UnwatchArticle', array( &$wgUser, &$this ) ) ) {
- $wgUser->removeWatch( $this->mTitle );
- return wfRunHooks( 'UnwatchArticleComplete', array( &$wgUser, &$this ) );
- }
-
- return false;
+ return Action::factory( 'unwatch', $this )->execute();
}
/**
@@ -2615,9 +2497,9 @@ class Article {
$protect_description = '';
foreach ( $limit as $action => $restrictions ) {
if ( !isset( $expiry[$action] ) )
- $expiry[$action] = Block::infinity();
+ $expiry[$action] = $dbw->getInfinity();
- $encodedExpiry[$action] = Block::encodeExpiry( $expiry[$action], $dbw );
+ $encodedExpiry[$action] = $dbw->encodeExpiry( $expiry[$action] );
if ( $restrictions != '' ) {
$protect_description .= "[$action=$restrictions] (";
if ( $encodedExpiry[$action] != 'infinity' ) {
@@ -2799,8 +2681,8 @@ class Article {
// Replace newlines with spaces to prevent uglyness
$contents = preg_replace( "/[\n\r]/", ' ', $contents );
// Calculate the maximum amount of chars to get
- // Max content length = max comment length - length of the comment (excl. $1) - '...'
- $maxLength = 255 - ( strlen( $reason ) - 2 ) - 3;
+ // Max content length = max comment length - length of the comment (excl. $1)
+ $maxLength = 255 - ( strlen( $reason ) - 2 );
$contents = $wgContLang->truncate( $contents, $maxLength );
// Remove possible unfinished links
$contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents );
@@ -2815,10 +2697,10 @@ class Article {
* UI entry point for page deletion
*/
public function delete() {
- global $wgUser, $wgOut, $wgRequest;
+ global $wgOut, $wgRequest;
$confirm = $wgRequest->wasPosted() &&
- $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
+ $wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
$this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
$this->DeleteReason = $wgRequest->getText( 'wpReason' );
@@ -2833,7 +2715,7 @@ class Article {
}
# Flag to hide all contents of the archived revisions
- $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
+ $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgOut->getUser()->isAllowed( 'suppressrevision' );
# This code desperately needs to be totally rewritten
@@ -2845,7 +2727,7 @@ class Article {
}
# Check permissions
- $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() );
if ( count( $permission_errors ) > 0 ) {
$wgOut->showPermissionsErrorPage( $permission_errors );
@@ -2891,7 +2773,7 @@ class Article {
if ( $confirm ) {
$this->doDelete( $reason, $suppress );
- if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
+ if ( $wgRequest->getCheck( 'wpWatch' ) && $wgOut->getUser()->isLoggedIn() ) {
$this->doWatch();
} elseif ( $this->mTitle->userIsWatching() ) {
$this->doUnwatch();
@@ -2910,12 +2792,11 @@ class Article {
if ( $hasHistory && !$confirm ) {
global $wgLang;
- $skin = $wgUser->getSkin();
$revisions = $this->estimateRevisionCount();
//FIXME: lego
$wgOut->addHTML( '
' .
wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
- wfMsgHtml( 'word-separator' ) . $skin->link( $this->mTitle,
+ wfMsgHtml( 'word-separator' ) . Linker::link( $this->mTitle,
wfMsgHtml( 'history' ),
array( 'rel' => 'archives' ),
array( 'action' => 'history' ) ) .
@@ -2980,10 +2861,11 @@ class Article {
'page_namespace' => $this->mTitle->getNamespace(),
'page_title' => $this->mTitle->getDBkey(),
'rev_page = page_id'
- ), __METHOD__, $this->getSelectOptions( array(
+ ), __METHOD__,
+ array(
'ORDER BY' => 'rev_timestamp DESC',
'LIMIT' => $num
- ) )
+ )
);
if ( !$res ) {
@@ -3017,18 +2899,18 @@ class Article {
* @param $reason String: prefilled reason
*/
public function confirmDelete( $reason ) {
- global $wgOut, $wgUser;
+ global $wgOut;
wfDebug( "Article::confirmDelete\n" );
- $deleteBackLink = $wgUser->getSkin()->linkKnown( $this->mTitle );
+ $deleteBackLink = Linker::linkKnown( $this->mTitle );
$wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'confirmdeletetext' );
wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
- if ( $wgUser->isAllowed( 'suppressrevision' ) ) {
+ if ( $wgOut->getUser()->isAllowed( 'suppressrevision' ) ) {
$suppress = "
|
" .
@@ -3039,7 +2921,7 @@ class Article {
} else {
$suppress = '';
}
- $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching();
+ $checkWatch = $wgOut->getUser()->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching();
$form = Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->mTitle->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
@@ -3072,7 +2954,7 @@ class Article {
|
";
# Disallow watching if user is not logged in
- if ( $wgUser->isLoggedIn() ) {
+ if ( $wgOut->getUser()->isLoggedIn() ) {
$form .= "
|
@@ -3094,13 +2976,12 @@ class Article {
" .
Xml::closeElement( 'table' ) .
Xml::closeElement( 'fieldset' ) .
- Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
+ Html::hidden( 'wpEditToken', $wgOut->getUser()->editToken() ) .
Xml::closeElement( 'form' );
- if ( $wgUser->isAllowed( 'editinterface' ) ) {
- $skin = $wgUser->getSkin();
+ if ( $wgOut->getUser()->isAllowed( 'editinterface' ) ) {
$title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
- $link = $skin->link(
+ $link = Linker::link(
$title,
wfMsgHtml( 'delete-edit-reasonlist' ),
array(),
@@ -3120,24 +3001,21 @@ class Article {
* Perform a deletion and output success or failure messages
*/
public function doDelete( $reason, $suppress = false ) {
- global $wgOut, $wgUser;
+ global $wgOut;
$id = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
$error = '';
- if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
- if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
- $deleted = $this->mTitle->getPrefixedText();
+ if ( $this->doDeleteArticle( $reason, $suppress, $id, $error ) ) {
+ $deleted = $this->mTitle->getPrefixedText();
- $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
- $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
+ $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
- $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
- $wgOut->returnToMain( false );
- wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) );
- }
+ $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
+ $wgOut->returnToMain( false );
} else {
if ( $error == '' ) {
$wgOut->showFatalError(
@@ -3175,11 +3053,15 @@ class Article {
* @param $commit boolean defaults to true, triggers transaction end
* @return boolean true if successful
*/
- public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true ) {
+ public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) {
global $wgDeferredUpdateList, $wgUseTrackbacks;
+ global $wgUser;
wfDebug( __METHOD__ . "\n" );
+ if ( ! wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
+ return false;
+ }
$dbw = wfGetDB( DB_MASTER );
$t = $this->mTitle->getDBkey();
$id = $id ? $id : $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
@@ -3272,6 +3154,7 @@ class Article {
$dbw->delete( 'templatelinks', array( 'tl_from' => $id ) );
$dbw->delete( 'externallinks', array( 'el_from' => $id ) );
$dbw->delete( 'langlinks', array( 'll_from' => $id ) );
+ $dbw->delete( 'iwlinks', array( 'iwl_from' => $id ) );
$dbw->delete( 'redirect', array( 'rd_from' => $id ) );
}
@@ -3305,6 +3188,7 @@ class Article {
$dbw->commit();
}
+ wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) );
return true;
}
@@ -3458,7 +3342,7 @@ class Article {
$flags |= EDIT_MINOR;
}
- if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) ) {
+ if ( $bot && ( $wgUser->isAllowedAny( 'markbotedits', 'bot' ) ) ) {
$flags |= EDIT_FORCE_BOT;
}
@@ -3514,7 +3398,7 @@ class Article {
if ( $current->getComment() != '' ) {
$wgOut->addWikiMsgArray( 'editcomment', array(
- $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
+ Linker::formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
}
}
@@ -3553,12 +3437,12 @@ class Article {
if ( $current->getUserText() === '' ) {
$old = wfMsg( 'rev-deleted-user' );
} else {
- $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
- . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
+ $old = Linker::userLink( $current->getUser(), $current->getUserText() )
+ . Linker::userToolLinks( $current->getUser(), $current->getUserText() );
}
- $new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() )
- . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
+ $new = Linker::userLink( $target->getUser(), $target->getUserText() )
+ . Linker::userToolLinks( $target->getUser(), $target->getUserText() );
$wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
$wgOut->returnToMain( false, $this->mTitle );
@@ -3610,7 +3494,7 @@ class Article {
$edit->revid = $revid;
$edit->newText = $text;
$edit->pst = $this->preSaveTransform( $text, $user, $popts );
- $edit->popts = $this->getParserOptions( true );
+ $edit->popts = $this->getParserOptions();
$edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
$edit->oldText = $this->getRawText();
@@ -3669,10 +3553,11 @@ class Article {
$dbw = wfGetDB( DB_MASTER );
$cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
- $recentchanges = $dbw->tableName( 'recentchanges' );
- $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$cutoff}'";
-
- $dbw->query( $sql );
+ $dbw->delete(
+ 'recentchanges',
+ array( "rc_timestamp < '$cutoff'" ),
+ __METHOD__
+ );
}
}
@@ -3759,15 +3644,16 @@ class Article {
}
$revision = Revision::newFromId( $oldid );
+ $timestamp = $revision->getTimestamp();
$current = ( $oldid == $this->mLatest );
- $td = $wgLang->timeanddate( $this->mTimestamp, true );
- $tddate = $wgLang->date( $this->mTimestamp, true );
- $tdtime = $wgLang->time( $this->mTimestamp, true );
- $sk = $wgUser->getSkin();
+ $td = $wgLang->timeanddate( $timestamp, true );
+ $tddate = $wgLang->date( $timestamp, true );
+ $tdtime = $wgLang->time( $timestamp, true );
+
$lnk = $current
? wfMsgHtml( 'currentrevisionlink' )
- : $sk->link(
+ : Linker::link(
$this->mTitle,
wfMsgHtml( 'currentrevisionlink' ),
array(),
@@ -3776,7 +3662,7 @@ class Article {
);
$curdiff = $current
? wfMsgHtml( 'diff' )
- : $sk->link(
+ : Linker::link(
$this->mTitle,
wfMsgHtml( 'diff' ),
array(),
@@ -3788,7 +3674,7 @@ class Article {
);
$prev = $this->mTitle->getPreviousRevisionID( $oldid ) ;
$prevlink = $prev
- ? $sk->link(
+ ? Linker::link(
$this->mTitle,
wfMsgHtml( 'previousrevision' ),
array(),
@@ -3800,7 +3686,7 @@ class Article {
)
: wfMsgHtml( 'previousrevision' );
$prevdiff = $prev
- ? $sk->link(
+ ? Linker::link(
$this->mTitle,
wfMsgHtml( 'diff' ),
array(),
@@ -3813,7 +3699,7 @@ class Article {
: wfMsgHtml( 'diff' );
$nextlink = $current
? wfMsgHtml( 'nextrevision' )
- : $sk->link(
+ : Linker::link(
$this->mTitle,
wfMsgHtml( 'nextrevision' ),
array(),
@@ -3825,7 +3711,7 @@ class Article {
);
$nextdiff = $current
? wfMsgHtml( 'diff' )
- : $sk->link(
+ : Linker::link(
$this->mTitle,
wfMsgHtml( 'diff' ),
array(),
@@ -3842,20 +3728,20 @@ class Article {
$canHide = $wgUser->isAllowed( 'deleterevision' );
if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) {
if ( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
- $cdel = $sk->revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
+ $cdel = Linker::revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
} else {
$query = array(
'type' => 'revision',
'target' => $this->mTitle->getPrefixedDbkey(),
'ids' => $oldid
);
- $cdel = $sk->revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide );
+ $cdel = Linker::revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide );
}
$cdel .= ' ';
}
# Show user links if allowed to see them. If hidden, then show them only if requested...
- $userlinks = $sk->revUserTools( $revision, !$unhide );
+ $userlinks = Linker::revUserTools( $revision, !$unhide );
$infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled()
? 'revision-info-current'
@@ -3876,7 +3762,7 @@ class Article {
"\n\t\t\t\t" . $cdel . wfMsgExt( 'revision-nav', array( 'escapenoentities', 'parsemag', 'replaceafter' ),
$prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "
\n\t\t\t";
- $wgOut->setSubtitle( $r );
+ $wgOut->addHTML( $r );
}
/**
@@ -4052,6 +3938,8 @@ class Article {
/**
* Clears caches when article is deleted
+ *
+ * @param $title Title
*/
public static function onArticleDelete( $title ) {
# Update existence markers on article/talk tabs...
@@ -4152,7 +4040,7 @@ class Article {
$msg = $wgUser->isLoggedIn()
? 'noarticletext'
: 'noarticletextanon';
- $wgOut->addHTML( wfMsgExt( $msg, 'parse' ) );
+ $wgOut->addWikiMsg( $msg );
}
$wgOut->addHTML( ' ' );
@@ -4165,8 +4053,7 @@ class Article {
'watchlist',
'COUNT(*)',
$wl_clause,
- __METHOD__,
- $this->getSelectOptions() );
+ __METHOD__ );
$pageInfo = $this->pageCountInfo( $page );
$talkInfo = $this->pageCountInfo( $page->getTalkPage() );
@@ -4210,15 +4097,13 @@ class Article {
'revision',
'COUNT(rev_page)',
$rev_clause,
- __METHOD__,
- $this->getSelectOptions()
+ __METHOD__
);
$authors = $dbr->selectField(
'revision',
'COUNT(DISTINCT rev_user_text)',
$rev_clause,
- __METHOD__,
- $this->getSelectOptions()
+ __METHOD__
);
return array( 'edits' => $edits, 'authors' => $authors );
@@ -4395,34 +4280,33 @@ class Article {
/**
* Get parser options suitable for rendering the primary article wikitext
- * @param $canonical boolean Determines that the generated must not depend on user preferences (see bug 14404)
- * @return mixed ParserOptions object or boolean false
+ * @return ParserOptions object
*/
- public function getParserOptions( $canonical = false ) {
- global $wgUser, $wgLanguageCode;
-
- if ( !$this->mParserOptions || $canonical ) {
- $user = !$canonical ? $wgUser : new User;
- $parserOptions = new ParserOptions( $user );
- $parserOptions->setTidy( true );
- $parserOptions->enableLimitReport();
-
- if ( $canonical ) {
- $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely
- return $parserOptions;
- }
- $this->mParserOptions = $parserOptions;
+ public function getParserOptions() {
+ global $wgUser;
+ if ( !$this->mParserOptions ) {
+ $this->mParserOptions = $this->makeParserOptions( $wgUser );
}
-
- // Clone to allow modifications of the return value without affecting
- // the cache
+ // Clone to allow modifications of the return value without affecting cache
return clone $this->mParserOptions;
}
+ /**
+ * Get parser options suitable for rendering the primary article wikitext
+ * @param User $user
+ * @return ParserOptions
+ */
+ public function makeParserOptions( User $user ) {
+ $options = ParserOptions::newFromUser( $user );
+ $options->enableLimitReport(); // show inclusion/loop reports
+ $options->setTidy( true ); // fix bad HTML
+ return $options;
+ }
+
/**
* Updates cascading protections
*
- * @param $parserOutput mixed ParserOptions object, or boolean false
+ * @param $parserOutput ParserOutput object, or boolean false
**/
protected function doCascadeProtectionUpdates( $parserOutput ) {
if ( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
@@ -4579,9 +4463,38 @@ class Article {
return $this->getOutputFromWikitext( $text, $useParserCache );
}
+ /**
+ * Sets the context this Article is executed in
+ *
+ * @param $context RequestContext
+ * @since 1.18
+ */
+ public function setContext( $context ) {
+ $this->mContext = $context;
+ }
+
+ /**
+ * Gets the context this Article is executed in
+ *
+ * @return RequestContext
+ * @since 1.18
+ */
+ public function getContext() {
+ if ( $this->mContext instanceof RequestContext ) {
+ return $this->mContext;
+ } else {
+ wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
+ return RequestContext::getMain();
+ }
+ }
+
}
class PoolWorkArticleView extends PoolCounterWork {
+
+ /**
+ * @var Article
+ */
private $mArticle;
function __construct( $article, $key, $useParserCache, $parserOptions ) {
@@ -4616,6 +4529,9 @@ class PoolWorkArticleView extends PoolCounterWork {
return $this->mArticle->tryDirtyCache();
}
+ /**
+ * @param $status Status
+ */
function error( $status ) {
global $wgOut;