X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=f7b126d9ecb7cdbf3519f7570bcc4e2b80029378;hb=7f6310847d78fde5c8b024f52cdcee88057d54c5;hp=f9a04cc7f3963d006082d6b2fb02508737b502a0;hpb=5c735694b14264cd03317a1e5f0bd0d8e249e3be;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Article.php b/includes/Article.php
index f9a04cc7f3..f7b126d9ec 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -60,7 +60,9 @@ class Article {
*/
public static function newFromID( $id ) {
$t = Title::newFromID( $id );
- return $t == null ? null : new Article( $t );
+ # FIXME: doesn't inherit right
+ return $t == null ? null : new self( $t );
+ #return $t == null ? null : new static( $t ); // PHP 5.3
}
/**
@@ -205,7 +207,7 @@ class Article {
* the shortcut in Article::followContent()
*
* @return Return the text of this revision
- */
+ */
public function getContent() {
global $wgUser, $wgContLang, $wgOut, $wgMessageCache;
wfProfileIn( __METHOD__ );
@@ -235,7 +237,7 @@ class Article {
* 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 ) {
@@ -497,7 +499,7 @@ class Article {
*
* @param $x Mixed: FIXME
*/
- public function forUpdate( $x = NULL ) {
+ public function forUpdate( $x = null ) {
return wfSetVar( $this->mForUpdate, $x );
}
@@ -612,7 +614,7 @@ class Article {
} else {
$titleObj = Title::newFromRedirect( $text );
}
- return $titleObj !== NULL;
+ return $titleObj !== null;
}
/**
@@ -726,9 +728,9 @@ class Article {
}
/**
- * This is the default action of the index.php entry point: just view the
+ * This is the default action of the index.php entry point: just view the
* page of the given title.
- */
+ */
public function view() {
global $wgUser, $wgOut, $wgRequest, $wgContLang;
global $wgEnableParserCache, $wgStylePath, $wgParser;
@@ -938,16 +940,15 @@ class Article {
*/
public function showDiffPage() {
global $wgOut, $wgRequest, $wgUser;
-
+
$diff = $wgRequest->getVal( 'diff' );
$rcid = $wgRequest->getVal( 'rcid' );
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
$purge = $wgRequest->getVal( 'action' ) == 'purge';
- $htmldiff = $wgRequest->getBool( 'htmldiff' );
$unhide = $wgRequest->getInt('unhide') == 1;
$oldid = $this->getOldID();
- $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff, $unhide );
+ $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $unhide );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage( $diffOnly );
@@ -961,10 +962,10 @@ class Article {
}
/**
- * Show a page view for a page formatted as CSS or JavaScript. To be called by
+ * Show a page view for a page formatted as CSS or JavaScript. To be called by
* Article::view() only.
*
- * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
+ * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
* page views.
*/
public function showCssOrJsPage() {
@@ -992,7 +993,7 @@ class Article {
$policy = $this->getRobotPolicy( 'view' );
return $policy['index'] . ',' . $policy['follow'];
}
-
+
/**
* Get the robot policy to be used for the current view
* @param $action String the action= GET parameter
@@ -1000,7 +1001,7 @@ class Article {
* TODO: actions other than 'view'
*/
public function getRobotPolicy( $action ){
-
+
global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
global $wgDefaultRobotPolicy, $wgRequest;
@@ -1084,8 +1085,8 @@ class Article {
}
/**
- * If this request is a redirect view, send "redirected from" subtitle to
- * $wgOut. Returns true if the header was needed, false if this is not a
+ * If this request is a redirect view, send "redirected from" subtitle to
+ * $wgOut. Returns true if the header was needed, false if this is not a
* redirect view. Handles both local and remote redirects.
*/
public function showRedirectedFromHeader() {
@@ -1133,7 +1134,7 @@ class Article {
}
/**
- * Show a header specific to the namespace currently being viewed, like
+ * Show a header specific to the namespace currently being viewed, like
* [[MediaWiki:Talkpagetext]]. For Article::view().
*/
public function showNamespaceHeader() {
@@ -1167,8 +1168,8 @@ class Article {
}
/**
- * If patrol is possible, output a patrol UI box. This is called from the
- * footer section of ordinary page views. If patrol is not possible or not
+ * If patrol is possible, output a patrol UI box. This is called from the
+ * footer section of ordinary page views. If patrol is not possible or not
* desired, does nothing.
*/
public function showPatrolFooter() {
@@ -1198,24 +1199,39 @@ class Article {
) .
''
);
- }
+ }
/**
- * Show the error text for a missing article. For articles in the MediaWiki
+ * Show the error text for a missing article. For articles in the MediaWiki
* namespace, show the default message text. To be called from Article::view().
*/
public function showMissingArticle() {
global $wgOut, $wgRequest, $wgUser;
- # Show info in user (talk) namespace. Does the user exist?
+ # Show info in user (talk) namespace. Does the user exist? Is he blocked?
if ( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
$parts = explode( '/', $this->mTitle->getText() );
$rootPart = $parts[0];
$id = User::idFromName( $rootPart );
$ip = User::isIP( $rootPart );
if ( $id == 0 && !$ip ) { # User does not exist
- $wgOut->wrapWikiMsg( '
' .
+ '
' .
$status->getWikiText( false, 'view-pool-error' ) .
'
'
);
@@ -1370,7 +1386,7 @@ class Article {
* @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;
+ global $wgOut, $wgContLang, $wgStylePath, $wgUser;
# Display redirect
if( !is_array( $target ) ) {
$target = array( $target );
@@ -1508,7 +1524,7 @@ class Article {
if( $wgUseSquid ) {
// Commit the transaction before the purge is sent
$dbw = wfGetDB( DB_MASTER );
- $dbw->immediateCommit();
+ $dbw->commit();
// Send purge
$update = SquidUpdate::newSimplePurge( $this->mTitle );
@@ -1574,7 +1590,7 @@ class Article {
* Giving 0 indicates the new page flag should be set
* on.
* @param $lastRevIsRedirect Boolean: if given, will optimize adding and
- * removing rows in redirect table.
+ * removing rows in redirect table.
* @return bool true on success, false on failure
* @private
*/
@@ -1595,7 +1611,7 @@ class Article {
'page_latest' => $revision->getId(),
'page_touched' => $dbw->timestamp(),
'page_is_new' => ($lastRevision === 0) ? 1 : 0,
- 'page_is_redirect' => $rt !== NULL ? 1 : 0,
+ 'page_is_redirect' => $rt !== null ? 1 : 0,
'page_len' => strlen( $text ),
),
$conditions,
@@ -1615,9 +1631,9 @@ class Article {
*
* @param $dbw Database
* @param $redirectTitle a title object pointing to the redirect target,
- * or NULL if this is not a redirect
+ * or NULL if this is not a redirect
* @param $lastRevIsRedirect If given, will optimize adding and
- * removing rows in redirect table.
+ * removing rows in redirect table.
* @return bool true on success, false on failure
* @private
*/
@@ -1687,7 +1703,7 @@ 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 ) {
+ public function replaceSection( $section, $text, $summary = '', $edittime = null ) {
wfProfileIn( __METHOD__ );
if( strval( $section ) == '' ) {
// Whole-page edit; let the whole text through
@@ -2151,14 +2167,13 @@ class Article {
# Inform the user
$wgOut->setPageTitle( wfMsg( 'markedaspatrolled' ) );
- $wgOut->addWikiMsg( 'markedaspatrolledtext' );
+ $wgOut->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
$wgOut->returnToMain( false, $return );
}
/**
* User-interface handler for the "watch" action
*/
-
public function watch() {
global $wgUser, $wgOut;
if( $wgUser->isAnon() ) {
@@ -2255,7 +2270,9 @@ class Article {
* @return bool true on success
*/
public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
- global $wgUser, $wgRestrictionTypes, $wgContLang;
+ global $wgUser, $wgContLang;
+
+ $restrictionTypes = $this->mTitle->getRestrictionTypes();
$id = $this->mTitle->getArticleID();
if ( $id <= 0 ) {
@@ -2285,7 +2302,7 @@ class Article {
$current = array();
$updated = Article::flattenRestrictions( $limit );
$changed = false;
- foreach( $wgRestrictionTypes as $action ) {
+ foreach( $restrictionTypes as $action ) {
if( isset( $expiry[$action] ) ) {
# Get current restrictions on $action
$aLimits = $this->mTitle->getRestrictions( $action );
@@ -2584,7 +2601,7 @@ class Article {
if( $confirm ) {
$this->doDelete( $reason, $suppress );
- if( $wgRequest->getCheck( 'wpWatch' ) ) {
+ if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
$this->doWatch();
} elseif( $this->mTitle->userIsWatching() ) {
$this->doUnwatch();
@@ -2598,11 +2615,16 @@ class Article {
// If the page has a history, insert a warning
if( $hasHistory && !$confirm ) {
+ global $wgLang;
$skin = $wgUser->getSkin();
$revisions = $this->estimateRevisionCount();
- $wgOut->addHTML( '
' . wfMsgExt( 'historywarning', array( 'parseinline' ), $revisions ) . ' ' . $skin->historyLink() . '' );
+ $wgOut->addHTML( '
' .
+ wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
+ wfMsgHtml( 'word-separator' ) . $skin->historyLink() .
+ ''
+ );
if( $bigHistory ) {
- global $wgLang, $wgDeleteRevisionsLimit;
+ global $wgDeleteRevisionsLimit;
$wgOut->wrapWikiMsg( "
\n$1
\n",
array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
}
@@ -2632,7 +2654,7 @@ class Article {
//return $dbr->selectField( 'revision', 'COUNT(*)',
// array( 'rev_page' => $this->getId() ), __METHOD__ );
return $dbr->estimateRowCount( 'revision', '*',
- array( 'rev_page' => $this->getId() ), __METHOD__ );
+ array( 'rev_page' => $this->getId() ), __METHOD__ );
}
/**
@@ -2699,7 +2721,7 @@ class Article {
$wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'confirmdeletetext' );
-
+
wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
if( $wgUser->isAllowed( 'suppressrevision' ) ) {
@@ -2743,14 +2765,19 @@ class Article {
'autofocus'
) ) .
"
-
+ ";
+ # Dissalow watching is user is not logged in
+ if( $wgUser->isLoggedIn() ) {
+ $form .= "
|
" .
Xml::checkLabel( wfMsg( 'watchthis' ),
'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
" |
-
+ ";
+ }
+ $form .= "
$suppress
|
@@ -3047,10 +3074,10 @@ class Article {
$user_text = $dbw->addQuotes( $current->getRawUserText() );
$s = $dbw->selectRow( 'revision',
array( 'rev_id', 'rev_timestamp', 'rev_deleted' ),
- array( 'rev_page' => $current->getPage(),
+ array( 'rev_page' => $current->getPage(),
"rev_user != {$user} OR rev_user_text != {$user_text}"
), __METHOD__,
- array( 'USE INDEX' => 'page_timestamp',
+ array( 'USE INDEX' => 'page_timestamp',
'ORDER BY' => 'rev_timestamp DESC' )
);
if( $s === false ) {
@@ -3184,8 +3211,12 @@ class Article {
$newId = $details['newid'];
$wgOut->setPageTitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
- $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
- . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
+ if ( $current->getUserText() === '' ) {
+ $old = wfMsg( 'rev-deleted-user' );
+ } else {
+ $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
+ . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
+ }
$new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() )
. $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
$wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
@@ -3252,7 +3283,7 @@ class Article {
* @param $changed Whether or not the content actually changed
*/
public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) {
- global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser, $wgEnableParserCache;
+ global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgEnableParserCache;
wfProfileIn( __METHOD__ );
@@ -3365,6 +3396,13 @@ class Article {
return;
}
+ $unhide = $wgRequest->getInt('unhide') == 1 &&
+ $wgUser->matchEditToken( $wgRequest->getVal('token'), $oldid );
+ # Cascade unhide param in links for easy deletion browsing
+ $extraParams = array();
+ if( $wgRequest->getVal('unhide') ) {
+ $extraParams['unhide'] = 1;
+ }
$revision = Revision::newFromId( $oldid );
$current = ( $oldid == $this->mLatest );
@@ -3378,7 +3416,7 @@ class Article {
$this->mTitle,
wfMsgHtml( 'currentrevisionlink' ),
array(),
- array(),
+ $extraParams,
array( 'known', 'noclasses' )
);
$curdiff = $current
@@ -3390,7 +3428,7 @@ class Article {
array(
'diff' => 'cur',
'oldid' => $oldid
- ),
+ ) + $extraParams,
array( 'known', 'noclasses' )
);
$prev = $this->mTitle->getPreviousRevisionID( $oldid ) ;
@@ -3402,7 +3440,7 @@ class Article {
array(
'direction' => 'prev',
'oldid' => $oldid
- ),
+ ) + $extraParams,
array( 'known', 'noclasses' )
)
: wfMsgHtml( 'previousrevision' );
@@ -3414,7 +3452,7 @@ class Article {
array(
'diff' => 'prev',
'oldid' => $oldid
- ),
+ ) + $extraParams,
array( 'known', 'noclasses' )
)
: wfMsgHtml( 'diff' );
@@ -3427,7 +3465,7 @@ class Article {
array(
'direction' => 'next',
'oldid' => $oldid
- ),
+ ) + $extraParams,
array( 'known', 'noclasses' )
);
$nextdiff = $current
@@ -3439,35 +3477,27 @@ class Article {
array(
'diff' => 'next',
'oldid' => $oldid
- ),
+ ) + $extraParams,
array( 'known', 'noclasses' )
);
- $cdel='';
- // Don't show useless link to people who cannot hide revisions
- if( $wgUser->isAllowed('deleterevision') || ($revision->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
+ $cdel = '';
+ // User can delete revisions or view deleted revisions...
+ $canHide = $wgUser->isAllowed( 'deleterevision' );
+ if( $canHide || ($revision->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
if( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
- // If revision was hidden from sysops
- $cdel = wfMsgHtml( 'rev-delundel' );
+ $cdel = $sk->revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
} else {
- $cdel = $sk->link(
- SpecialPage::getTitleFor( 'Revisiondelete' ),
- wfMsgHtml('rev-delundel'),
- array(),
- array(
- 'type' => 'revision',
- 'target' => urlencode( $this->mTitle->getPrefixedDbkey() ),
- 'ids' => urlencode( $oldid )
- ),
- array( 'known', 'noclasses' )
+ $query = array(
+ 'type' => 'revision',
+ 'target' => $this->mTitle->getPrefixedDbkey(),
+ 'ids' => $oldid
);
- // Bolden oversighted content
- if( $revision->isDeleted( Revision::DELETED_RESTRICTED ) )
- $cdel = "$cdel";
+ $cdel = $sk->revDeleteLink( $query, $revision->isDeleted(File::DELETED_RESTRICTED), $canHide );
}
- $cdel = "($cdel) ";
+ $cdel .= ' ';
}
- $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 );
@@ -3479,7 +3509,7 @@ class Article {
$r = "\n\t\t\t\t" .
wfMsgExt(
$infomsg,
- array( 'parseinline', 'replaceafter' ),
+ array( 'parseinline', 'replaceafter' ),
$td,
$userlinks,
$revision->getID(),
@@ -3616,7 +3646,7 @@ class Article {
*/
public static function incViewCount( $id ) {
$id = intval( $id );
- global $wgHitcounterUpdateFreq, $wgDBtype;
+ global $wgHitcounterUpdateFreq;
$dbw = wfGetDB( DB_MASTER );
$pageTable = $dbw->tableName( 'page' );
@@ -3647,23 +3677,23 @@ class Article {
wfProfileIn( 'Article::incViewCount-collect' );
$old_user_abort = ignore_user_abort( true );
- if($wgDBtype == 'mysql')
- $dbw->query("LOCK TABLES $hitcounterTable WRITE");
- $tabletype = $wgDBtype == 'mysql' ? "ENGINE=HEAP " : '';
- $dbw->query("CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ".
+ $dbType = $dbw->getType();
+ $dbw->lockTables( array(), array( 'hitcounter' ), __METHOD__, false );
+ $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : '';
+ $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ".
"SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ".
- 'GROUP BY hc_id');
- $dbw->query("DELETE FROM $hitcounterTable");
- if($wgDBtype == 'mysql') {
- $dbw->query('UNLOCK TABLES');
- $dbw->query("UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ".
- 'WHERE page_id = hc_id');
+ 'GROUP BY hc_id', __METHOD__ );
+ $dbw->delete( 'hitcounter', '*', __METHOD__ );
+ $dbw->unlockTables( __METHOD__ );
+ if( $dbType == 'mysql' ) {
+ $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ".
+ 'WHERE page_id = hc_id', __METHOD__ );
}
else {
- $dbw->query("UPDATE $pageTable SET page_counter=page_counter + hc_n ".
- "FROM $acchitsTable WHERE page_id = hc_id");
+ $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n ".
+ "FROM $acchitsTable WHERE page_id = hc_id", __METHOD__ );
}
- $dbw->query("DROP TABLE $acchitsTable");
+ $dbw->query( "DROP TABLE $acchitsTable", __METHOD__ );
ignore_user_abort( $old_user_abort );
wfProfileOut( 'Article::incViewCount-collect' );
@@ -3682,7 +3712,6 @@ class Article {
*
* @param $title a title object
*/
-
public static function onArticleCreate( $title ) {
# Update existence markers on article/talk tabs...
if( $title->isTalkPage() ) {
@@ -3964,7 +3993,7 @@ class Article {
$this->mParserOutput = $this->getOutputFromWikitext( $text, $cache, $parserOptions );
$wgOut->addParserOutput( $this->mParserOutput );
}
-
+
/**
* This does all the heavy lifting for outputWikitext, except it returns the parser
* output instead of sending it straight to $wgOut. Makes things nice and simple for,
@@ -4087,8 +4116,10 @@ class Article {
}
$insertRows = array();
foreach( $insertCats as $cat ) {
- $insertRows[] = array( 'cat_id' => $dbw->nextSequenceValue( 'category_id_seq' ),
- 'cat_title' => $cat );
+ $insertRows[] = array(
+ 'cat_id' => $dbw->nextSequenceValue( 'category_cat_id_seq' ),
+ 'cat_title' => $cat
+ );
}
$dbw->insert( 'category', $insertRows, __METHOD__, 'IGNORE' );
@@ -4119,10 +4150,11 @@ class Article {
);
}
}
-
+
/** Lightweight method to get the parser output for a page, checking the parser cache
- * and so on. Doesn't consider most of the stuff that Article::view is forced to
- * consider, so it's not appropriate to use there. */
+ * and so on. Doesn't consider most of the stuff that Article::view is forced to
+ * consider, so it's not appropriate to use there.
+ */
function getParserOutput( $oldid = null ) {
global $wgEnableParserCache, $wgUser, $wgOut;
@@ -4130,8 +4162,8 @@ class Article {
$useParserCache = $wgEnableParserCache &&
intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
$this->exists() &&
- $oldid === null;
-
+ $oldid === null;
+
wfDebug( __METHOD__.': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
if ( $wgUser->getOption( 'stubthreshold' ) ) {
wfIncrStats( 'pcache_miss_stub' );
@@ -4145,7 +4177,7 @@ class Article {
if ( $parserOutput === false ) {
// Cache miss; parse and output it.
$rev = Revision::newFromTitle( $this->getTitle(), $oldid );
-
+
return $this->getOutputFromWikitext( $rev->getText(), $useParserCache );
} else {
return $parserOutput;